From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D8AAC4360F for ; Wed, 3 Apr 2019 19:42:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D31252171F for ; Wed, 3 Apr 2019 19:42:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726536AbfDCTmc (ORCPT ); Wed, 3 Apr 2019 15:42:32 -0400 Received: from verein.lst.de ([213.95.11.211]:35263 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726064AbfDCTmc (ORCPT ); Wed, 3 Apr 2019 15:42:32 -0400 Received: by newverein.lst.de (Postfix, from userid 2407) id 605FD68AFE; Wed, 3 Apr 2019 21:42:20 +0200 (CEST) Date: Wed, 3 Apr 2019 21:42:20 +0200 From: Christoph Hellwig To: Russell King - ARM Linux admin Cc: Christoph Hellwig , x86@kernel.org, Sudip Mukherjee , Bartlomiej Zolnierkiewicz , linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: remove NULL struct device support in the DMA API Message-ID: <20190403194220.GA30376@lst.de> References: <20190321225235.30648-1-hch@lst.de> <20190403182640.2ca6w2hngjqp35mt@shell.armlinux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190403182640.2ca6w2hngjqp35mt@shell.armlinux.org.uk> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 03, 2019 at 07:26:40PM +0100, Russell King - ARM Linux admin wrote: > On Thu, Mar 21, 2019 at 03:52:28PM -0700, Christoph Hellwig wrote: > > We still have a few drivers which pass a NULL struct device pointer > > to DMA API functions, which generally is a bad idea as the API > > implementations rely on the device not only for ops selection, but > > also the dma mask and various other attributes, and many implementations > > have been broken for NULL device support for a while. > > I think I must be missing something, but... > > My understanding is that ISA DMA is normally limited to 24 bits of > address Yes. > - indeed, the x86 version only programs 24 bits of DMA address. > Looking through this series, it appears that the conversions mean that > the DMA mask for ISA becomes the full all-ones DMA mask, which would > of course lead to memory corruption if only 24 bits of the address end > up being programmed into the hardware. In the generic dma mapping code no struct device has always meant a 32-bit DMA mask - take a look at the dma_get_mask() function. > Maybe you could say why you think this series is safe in regard to ISA > DMA? ISA DMA has always been rather painful in a myriad of ways, and the DMA API so far hasn't helped, given that we don't do bounce buffering for the 24-bit limit, but just the higher limits. So far even if you do use the DMA API and pass a device ISA DMA so far always meant that the higher layers had to assure things are addressable, either by using GFP_DMA allocation in the drivers, or mid-layer hacks like the unchecked_isa_dma flag in SCSI and/or BLK_BOUNCE_ISA in the block layer. This series doesn't change those facts at all. I have some half started series to clean some of this up but it isn't high up on the priority list. From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoph Hellwig Date: Wed, 03 Apr 2019 19:42:20 +0000 Subject: Re: remove NULL struct device support in the DMA API Message-Id: <20190403194220.GA30376@lst.de> List-Id: References: <20190321225235.30648-1-hch@lst.de> <20190403182640.2ca6w2hngjqp35mt@shell.armlinux.org.uk> In-Reply-To: <20190403182640.2ca6w2hngjqp35mt@shell.armlinux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Russell King - ARM Linux admin Cc: Christoph Hellwig , x86@kernel.org, Sudip Mukherjee , Bartlomiej Zolnierkiewicz , linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org On Wed, Apr 03, 2019 at 07:26:40PM +0100, Russell King - ARM Linux admin wrote: > On Thu, Mar 21, 2019 at 03:52:28PM -0700, Christoph Hellwig wrote: > > We still have a few drivers which pass a NULL struct device pointer > > to DMA API functions, which generally is a bad idea as the API > > implementations rely on the device not only for ops selection, but > > also the dma mask and various other attributes, and many implementations > > have been broken for NULL device support for a while. > > I think I must be missing something, but... > > My understanding is that ISA DMA is normally limited to 24 bits of > address Yes. > - indeed, the x86 version only programs 24 bits of DMA address. > Looking through this series, it appears that the conversions mean that > the DMA mask for ISA becomes the full all-ones DMA mask, which would > of course lead to memory corruption if only 24 bits of the address end > up being programmed into the hardware. In the generic dma mapping code no struct device has always meant a 32-bit DMA mask - take a look at the dma_get_mask() function. > Maybe you could say why you think this series is safe in regard to ISA > DMA? ISA DMA has always been rather painful in a myriad of ways, and the DMA API so far hasn't helped, given that we don't do bounce buffering for the 24-bit limit, but just the higher limits. So far even if you do use the DMA API and pass a device ISA DMA so far always meant that the higher layers had to assure things are addressable, either by using GFP_DMA allocation in the drivers, or mid-layer hacks like the unchecked_isa_dma flag in SCSI and/or BLK_BOUNCE_ISA in the block layer. This series doesn't change those facts at all. I have some half started series to clean some of this up but it isn't high up on the priority list. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS, USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDB6AC4360F for ; Wed, 3 Apr 2019 19:42:39 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AB2A020700 for ; Wed, 3 Apr 2019 19:42:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="lnsgWFPK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AB2A020700 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=nN1A5B3cnvcVVUjS2Ai2UttyDMyorD2Uzh42W0USyu4=; b=lnsgWFPKJPRYxn WSu+yct99nXXAuEmvF/QY9Y5Jks3yHT5i5a6iQleAX16RKBfOFUX66fEFGDspwbiCLxectp6AR7ng X5Ow3KWoS3Zi59jMF84aCDbILjSIjBqZ4N9r1lbsBo0rq2ZG3L1NJ2SL7C/7UlxEPg3vuvL/L5nnT zBbEAi6qu7uJ5C/snNGLRtCp72Fdy7oN5mDPONUuM12zzDzZ+Y3dUA8Bt98f+NV1hGKvgspAOmZe/ 6P9YT3zQ31xA8fQsl2kAQJEDp7g+HCNGQ1mkocRTXQY15TLLAB92xzLn1LV1t/4mryXcuN+UtrP/x GMYeG8yEWnA7DYJcr6mw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hBlmM-00019h-G4; Wed, 03 Apr 2019 19:42:34 +0000 Received: from verein.lst.de ([213.95.11.211] helo=newverein.lst.de) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hBlmK-00019O-1U for linux-arm-kernel@lists.infradead.org; Wed, 03 Apr 2019 19:42:33 +0000 Received: by newverein.lst.de (Postfix, from userid 2407) id 605FD68AFE; Wed, 3 Apr 2019 21:42:20 +0200 (CEST) Date: Wed, 3 Apr 2019 21:42:20 +0200 From: Christoph Hellwig To: Russell King - ARM Linux admin Subject: Re: remove NULL struct device support in the DMA API Message-ID: <20190403194220.GA30376@lst.de> References: <20190321225235.30648-1-hch@lst.de> <20190403182640.2ca6w2hngjqp35mt@shell.armlinux.org.uk> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190403182640.2ca6w2hngjqp35mt@shell.armlinux.org.uk> User-Agent: Mutt/1.5.17 (2007-11-01) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190403_124232_236455_F9985B01 X-CRM114-Status: GOOD ( 17.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fbdev@vger.kernel.org, Bartlomiej Zolnierkiewicz , x86@kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Sudip Mukherjee , iommu@lists.linux-foundation.org, Christoph Hellwig , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Apr 03, 2019 at 07:26:40PM +0100, Russell King - ARM Linux admin wrote: > On Thu, Mar 21, 2019 at 03:52:28PM -0700, Christoph Hellwig wrote: > > We still have a few drivers which pass a NULL struct device pointer > > to DMA API functions, which generally is a bad idea as the API > > implementations rely on the device not only for ops selection, but > > also the dma mask and various other attributes, and many implementations > > have been broken for NULL device support for a while. > > I think I must be missing something, but... > > My understanding is that ISA DMA is normally limited to 24 bits of > address Yes. > - indeed, the x86 version only programs 24 bits of DMA address. > Looking through this series, it appears that the conversions mean that > the DMA mask for ISA becomes the full all-ones DMA mask, which would > of course lead to memory corruption if only 24 bits of the address end > up being programmed into the hardware. In the generic dma mapping code no struct device has always meant a 32-bit DMA mask - take a look at the dma_get_mask() function. > Maybe you could say why you think this series is safe in regard to ISA > DMA? ISA DMA has always been rather painful in a myriad of ways, and the DMA API so far hasn't helped, given that we don't do bounce buffering for the 24-bit limit, but just the higher limits. So far even if you do use the DMA API and pass a device ISA DMA so far always meant that the higher layers had to assure things are addressable, either by using GFP_DMA allocation in the drivers, or mid-layer hacks like the unchecked_isa_dma flag in SCSI and/or BLK_BOUNCE_ISA in the block layer. This series doesn't change those facts at all. I have some half started series to clean some of this up but it isn't high up on the priority list. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel