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=-9.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_PASS,USER_AGENT_GIT 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 0FA1DC04EB8 for ; Fri, 30 Nov 2018 13:23:08 +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 A33F32082F for ; Fri, 30 Nov 2018 13:23:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Agi31L2a" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A33F32082F 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:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=J0ZP61D38CMInK80oANe6JPAFK0n5NUCuX6eHI8UhrM=; b=Agi31L2aO1CH96 RXIxwCEKSwNgq1k8vShv/obIvpCxGn7iEQW12HOYenUFIIaeL1LuwUL62DoscSgFk4S83KEDvPj4C AbA34yuBqxvqSK4kS7ZbVAjotVCqtTfnKbv7U43+xTI3X0hs5OCb2tx7DiXTuU84V1puYSkeDq5Bh 9tkg3bkr+tiDe0ms4MkDQSaYYHYSDS+5OlBp0VmSdi6IdRDj02henlOZAYbcBx40ea2XrZoUsJohh gx62cJSjJDVydf9zI9QqZMHuCdOykXmbg716HDois03gNWtCoNeG/D+r9v5mdQAcvYjA7SYcruoGr 3JE6dPpUcm8bQnRKagvw==; 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 1gSil5-0004H7-E6; Fri, 30 Nov 2018 13:23:03 +0000 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 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 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-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 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 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel