Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3744690imu; Fri, 30 Nov 2018 05:28:05 -0800 (PST) X-Google-Smtp-Source: AFSGD/UCU99SKvTIJEe7EonbTdjas0tgGFuy6cNsh1o8G0DkdBTOmwj8MzgAgBVYszFq/aWl6Gw1 X-Received: by 2002:a63:bd1a:: with SMTP id a26mr4805396pgf.121.1543584485396; Fri, 30 Nov 2018 05:28:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543584485; cv=none; d=google.com; s=arc-20160816; b=omGWptIHz5XgPEORWTXIA7YPeNZhCZXulCnLhC4ilmF9nuiqDGFBfrLBp4xG0lMMi0 KGKKp76oQ8pjQR/u6sG8/KmJXGDWcBNnhoN5OQxgH6QP5Psm81SZeDRcj2JSY2YJM96Z rTNzracX8RU6YQzqDN98YOdnPUj+vSQUoZI1cODymZKuA5LEO1rqnVCk51wePg9jez+q DLwKz1i1SUEqXTtyCxKhd+81S35rKwbHi1T/UVD+mSVdC+NUL/bUllTVSzeRyi7d1wkM UhokjcFlt8/vhMlGboGKA+g39DPcmpBua5l63vrNNdWDyUkVv/vGcSBKFNzpWkxrRqzk HnGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=A/J16M6FpKMXGkalsHGNWwyWuLoovXiruopq0QWan0w=; b=gHJSui7Sd8BCxKrKiwA73/Hz8tu7n+fNl3z59cEO6Wfa2I2h7PYmkTZt9wUGBZ+3Vn 96SQo4m172maYzOUfPOPbPR2PuALu+pupFU2fPFla4wW5C0+A6rPkM/P/wAcNWvyaRHU 5UB0HQNrO89ZYvPG6ZM0XD0xlLt5VWvBitUBxRv5H9KyP/NTOuJXooHm514I3jpq7PgZ AG1rrJ4lsz9M1UKAhieRsRM+gwhqEijsKvKEWYuuX1b6YUUWdZlC2lm2uD/6Obhsz8Wx Pm3iFYHpzGKd3evVoajROrSl4NSArlMHk0xSPGCQfg/oqiiEu20lJHAvcP9SH9JDpekD ZeUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=JOf9fiGG; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z6si5326782pgl.109.2018.11.30.05.27.51; Fri, 30 Nov 2018 05:28:05 -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=@infradead.org header.s=bombadil.20170209 header.b=JOf9fiGG; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726732AbeLAAc3 (ORCPT + 99 others); Fri, 30 Nov 2018 19:32:29 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:45746 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726270AbeLAAc3 (ORCPT ); Fri, 30 Nov 2018 19:32:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=A/J16M6FpKMXGkalsHGNWwyWuLoovXiruopq0QWan0w=; b=JOf9fiGGeEzv7Mt/zHkUdvbTB zHtAa1SoRX05GKpGnE5qIzzxnlalDkQqgyT3ju5lZXgn6hkJDaFUkcnQquhPA2Qp0C1TcCTvPKI8h T/tRDgywtXeZ2rMJ4vS476aCCZ4wGTVJXFdNW6eRvbw0VJ2mILvgUf5jz1sskmxkB64jjxnlI+Shs SVrgLZu0rGaEqTan6jjh1lcnfGVdoC2pK3I7Mve6SHSQvFrWmjqvL3+JCORLuM29LMF9DUPZAFtAE tNpZlq5wvBmSeFKhBoOsmssSFKlBLL8RR95oxAY4kJs8bbvrXOJeNt+uiPEFbc0VQChsbSkz99+S5 fdx5C6l1w==; Received: from 089144206221.atnat0015.highway.bob.at ([89.144.206.221] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gSil1-0004Ge-1e; Fri, 30 Nov 2018 13:22:59 +0000 From: Christoph Hellwig To: iommu@lists.linux-foundation.org Cc: Linus Torvalds , Jon Mason , Joerg Roedel , David Woodhouse , Marek Szyprowski , Robin Murphy , x86@kernel.org, linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org, xen-devel@lists.xenproject.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: remove the ->mapping_error method from dma_map_ops V3 Date: Fri, 30 Nov 2018 14:22:08 +0100 Message-Id: <20181130132231.16512-1-hch@lst.de> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Gitweb: http://git.infradead.org/users/hch/misc.git/shortlog/refs/heads/dma-mapping-error.3 Changes since v2: - fix a compile error in the ia64 sba_iommu driver - return an errno value from dma_mapping_error Changes since v1: - dropped the signature change - split into multiple patches - fixed the iova allocator return check in amd-iommu - remove EMERGENCY_PAGES in amd_gart and calgary