Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4102416imu; Fri, 30 Nov 2018 11:01:53 -0800 (PST) X-Google-Smtp-Source: AFSGD/XqDslsTIxb7Qwm7v+mgLnLIMANzKQKycYn4GpsUaj8MLzUcIcCMeT5lHDLNTYIABJ5++6G X-Received: by 2002:a62:546:: with SMTP id 67mr6581998pff.99.1543604513253; Fri, 30 Nov 2018 11:01:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543604513; cv=none; d=google.com; s=arc-20160816; b=WpM7MtYdfkFq/ATsH6SsAyjdc+zhDs6Kp4HAhkdpDvyeJisnGVYTcWJc6jUyN85zHw Lgk3b34YacPfbW/w9SC5x+y3qjx9OGQU4BpalrwYPdprJI0kngHL7eriw+YsXvVZBPDa PLN2n5LscBi+sfyNnYFbJK0kcLNkk6Fx29jaOLho4nDOydU7ynDjqSN7v+gzZEKWAl0R 6uwyjUAm70i1MmQFN7XPiem6vh/yNFNnzls2JqQ47kmcVfd40YfJsQHw3diVN/Vy3Mpp nOtrdeesWEpmsqybkvl9eZxKhfqkAlpgcm+7QVImXAQ4yLJH1BTmQYdYUDsRxJFC39mI nTcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=A+hP/kWFL3F+0C9qjiWsucmvZtfGx78Cupc7DWWqQIA=; b=bho54DQYZuJq0efFN1+JCCDIEnfsllsd19Uc+y+i5Rdsa9nkKpuF610IjL19oOj/R9 Rj6k+zobvxn8u7V7kwsHjKhIYn6Vm5lMaLCGMIy2C3C9rhPMEv1slMksIAiIwerp6pn5 Y4WSlh3QNP36j5drc2Y9hQgIt6gwNfJIPhw/8WvfFp1br6Gh2e1j0iTPWG7CMd4LrShh J7fHoOXlK3lE04dX9MPmDSdkXsGw8CvxJzYho56QfqvTwM5XXnkQefQ7E3+IPiUhj904 KcxLJoJXA7Rkbr+M9pUomAUVBUgzCDG7zXr1kOtqhHyv+w0r8yIrBLcsY2JC91hIIRJa e54g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@armlinux.org.uk header.s=pandora-2014 header.b=lXt5tIOs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x6si5770359pln.425.2018.11.30.11.01.38; Fri, 30 Nov 2018 11:01:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@armlinux.org.uk header.s=pandora-2014 header.b=lXt5tIOs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726800AbeLAGJt (ORCPT + 99 others); Sat, 1 Dec 2018 01:09:49 -0500 Received: from pandora.armlinux.org.uk ([78.32.30.218]:58802 "EHLO pandora.armlinux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725993AbeLAGJt (ORCPT ); Sat, 1 Dec 2018 01:09:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2014; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=A+hP/kWFL3F+0C9qjiWsucmvZtfGx78Cupc7DWWqQIA=; b=lXt5tIOspOHVOt36+udBUSV1C GOhvsfSFWxcA4ivOXXEP6EankcVZN2vybbjhGUssR7LWMTTBG0nX4X+c525PkgFpjKFEx9HgXPl+u MlU/9o2XYiEFrk5JSgvqId5jg6M9BMJ1fkdenqx8FrC0w7tz/UlldH5XpNahuLgNewC5M=; Received: from n2100.armlinux.org.uk ([2001:4d48:ad52:3201:214:fdff:fe10:4f86]:46659) by pandora.armlinux.org.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.90_1) (envelope-from ) id 1gSo0a-0001UZ-Sj; Fri, 30 Nov 2018 18:59:25 +0000 Received: from linux by n2100.armlinux.org.uk with local (Exim 4.90_1) (envelope-from ) id 1gSo0Y-0002BF-8e; Fri, 30 Nov 2018 18:59:22 +0000 Date: Fri, 30 Nov 2018 18:59:20 +0000 From: Russell King - ARM Linux To: Christoph Hellwig Cc: iommu@lists.linux-foundation.org, linux-arch@vger.kernel.org, linux-alpha@vger.kernel.org, linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org, Linus Torvalds , Joerg Roedel , x86@kernel.org, Robin Murphy , linux-kernel@vger.kernel.org, Jon Mason , xen-devel@lists.xenproject.org, David Woodhouse , linux-arm-kernel@lists.infradead.org, Marek Szyprowski Subject: Re: remove the ->mapping_error method from dma_map_ops V3 Message-ID: <20181130185920.GG30658@n2100.armlinux.org.uk> References: <20181130132231.16512-1-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181130132231.16512-1-hch@lst.de> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 30, 2018 at 02:22:08PM +0100, Christoph Hellwig wrote: > Error reporting for the dma_map_single and dma_map_page operations is > currently a mess. Both APIs directly return the dma_addr_t to be used for > the DMA, with a magic error escape that is specific to the instance and > checked by another method provided. This has a few downsides: > > - the error check is easily forgotten and a __must_check marker doesn't > help as the value always is consumed anyway > - the error checking requires another indirect call, which have gotten > incredibly expensive > - a lot of code is wasted on implementing these methods > > The historical reason for this is that people thought DMA mappings would > not fail when the API was created, which sounds like a really bad > assumption in retrospective, and then we tried to cram error handling > onto it later on. > > There basically are two variants: the error code is 0 because the > implementation will never return 0 as a valid DMA address, or the error > code is all-F as the implementation won't ever return an address that > high. The old AMD GART is the only one not falling into these two camps > as it picks sort of a relative zero relative to where it is mapped. > > The 0 return doesn't work for direct mappings that have ram at address > zero and a lot of IOMMUs that start allocating bus space from address > zero, so we can't consolidate on that, but I think we can move everyone > to all-Fs, which the patch here does. The reason for that is that > there is only one way to ever get this address: by doing a 1-byte long, > 1-byte aligned mapping, but all our mappings are not only longer but > generally aligned, and the mappings have to keep at least the basic > alignment. > > A git tree is also available here: > > git://git.infradead.org/users/hch/misc.git dma-mapping-error.3 Hi Chris, For patches 1, 3 and 23, Acked-by: Russell King Thanks. -- RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up