Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2225090pxk; Mon, 14 Sep 2020 07:50:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDYK1bjy4TqRPOF1MINPnLNhL8lTAO5hgEnRojB7ucs/lmlmfnfUUjXNTBNWE24fiqvLNI X-Received: by 2002:a17:907:4276:: with SMTP id nq6mr10892368ejb.246.1600095051862; Mon, 14 Sep 2020 07:50:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600095051; cv=none; d=google.com; s=arc-20160816; b=ujqe47UiAq2kqyr4r8dp9CAX1Wu8FMdf3tk002q2vVq8IbJk9GF8qDa3Lr3ig4lh3P 7RShgGn1pFaC0Iq0fHq4mZLoFEYHE2PSBTiVYWYD7JL9oqeFGgR/w6cYc1m+RjsF/OVa JEmrJK7WluPfjm67WBLJxil/hhq7Un8zJUL8AionwrIBkvUMDmKMR5A06P8MG5HJ1E81 ftwuUmUybMhzx7xHFIbwS9HItx5ffaOkzEkbmczx3OUHbryqiIWcK49qBS7vjuTY8bi/ 0K4UN2b4mhfZSZu2fBJ7+Q9x7GLr4nLlAXVwGNUDFCTswiaU7zG1y6ACZAlYnPKKPDB8 IzyA== 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=ZNjtOprQ0CMyI4ATRWqucmdOpx+hHcpY44uRUfjYcDA=; b=fh8NcROaWxfbimuPyg9hzJFZ5EG8Xvff1988+V4Kj+1X0VXAzOK2Po7vP+cAtm58u4 Q4GM7coIcFhCcwuD7lCYOuj3U0AT8sI1U9x5VX3oRdmx0DtPdPlVxJdOIhk6zVhwpDfF m63fGSIUSPfcsAJ/Q3IFH6/NfhpzVHtuCUa/jB7ttGfFV0GfvfQAjqquBE3u5EjfPfe1 /uAMr/bed/nNSl+ztfKkbA2VnfsqSfpooajObPU8Uust/AzcQCVdcCtZ5pkDlADad4OS z4HybdckRUGjzuhWCi/UGPz4HhtLM/GJIXsk7mZjfmZ0djMFhn7nZA64lXkdRD1jqBTo lWCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=N4NdSCqp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w11si7257666ejy.632.2020.09.14.07.50.29; Mon, 14 Sep 2020 07:50:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=N4NdSCqp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726875AbgINOth (ORCPT + 99 others); Mon, 14 Sep 2020 10:49:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726836AbgINOrj (ORCPT ); Mon, 14 Sep 2020 10:47:39 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17069C061788; Mon, 14 Sep 2020 07:47:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=ZNjtOprQ0CMyI4ATRWqucmdOpx+hHcpY44uRUfjYcDA=; b=N4NdSCqp08oFrOv3mtyviiYwas oNsCF+Dc8Ja0cguO7+ZPTYUzH37/R/e85Vh80cBfx4KckZelgIyQd543/M1egNtkylVU6AB/wVfBM Tlkxi46PvOhn46tciCiOecLWzjs46m9we7uYxaasaogiTmImYuOdp/gt2FgdFngL+ZN6LS6utTo0O Hm9LbW/uDyDkAIigJFLQXrAZkOr7o09fPL6HdPU4QQq1TyT5bp3IWI2Cw1qQE5T5w1y0VaAfJxPRZ aK96DU68S1PJnrr+xN+ybqrGZgNzPzvroduSeid9Yw4t5OHe2QnIzFzfQyScSm13brcMUjUX0bu0P Q8mlhOfQ==; Received: from 089144214092.atnat0023.highway.a1.net ([89.144.214.92] helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHpkk-0001Er-WB; Mon, 14 Sep 2020 14:46:47 +0000 From: Christoph Hellwig To: Mauro Carvalho Chehab , Thomas Bogendoerfer , "James E.J. Bottomley" , Joonyoung Shim , Seung-Woo Kim , Ben Skeggs , Marek Szyprowski , Tomasz Figa , Matt Porter , iommu@lists.linux-foundation.org Cc: Stefan Richter , linux1394-devel@lists.sourceforge.net, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linux-samsung-soc@vger.kernel.org, nouveau@lists.freedesktop.org, netdev@vger.kernel.org, linux-scsi@vger.kernel.org, linux-mm@kvack.org, alsa-devel@alsa-project.org Subject: a saner API for allocating DMA addressable pages v2 Date: Mon, 14 Sep 2020 16:44:16 +0200 Message-Id: <20200914144433.1622958-1-hch@lst.de> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.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 Hi all, this series replaced the DMA_ATTR_NON_CONSISTENT flag to dma_alloc_attrs with a separate new dma_alloc_pages API, which is available on all platforms. In addition to cleaning up the convoluted code path, this ensures that other drivers that have asked for better support for non-coherent DMA to pages with incurring bounce buffering over can finally be properly supported. I'm still a little unsure about the API naming, as alloc_pages sort of implies a struct page return value, but we return a kernel virtual address. The other alternative would be to name the API dma_alloc_noncoherent, but the whole non-coherent naming seems to put people off. As a follow up I plan to move the implementation of the DMA_ATTR_NO_KERNEL_MAPPING flag over to this framework as well, given that is also is a fundamentally non coherent allocation. The replacement for that flag would then return a struct page, as it is allowed to actually return pages without a kernel mapping as the name suggested (although most of the time they will actually have a kernel mapping..) In addition to the conversions of the existing non-coherent DMA users, I've also added a patch to convert the firewire ohci driver to use the new dma_alloc_pages API. Note that I haven't carried over any Tested-by: tags for the noncoherent allocation conversions as there was a bit of a patch reshuffle, but the result should be the same. The first patch is queued up for 5.9 in the media tree, but included here for completeness. A git tree is available here: git://git.infradead.org/users/hch/misc.git dma_alloc_pages Gitweb: http://git.infradead.org/users/hch/misc.git/shortlog/refs/heads/dma_alloc_pages Changes since v1: - rebased on the latests dma-mapping tree, which merged many of the cleanups - fix an argument passing typo in 53c700, caught by sparse - rename a few macro arguments in 53c700 - pass the right device to the DMA API in the lib82596 drivers - fix memory ownershiptransfers in sgiseeq - better document what a page in the direct kernel mapping means - split into dma_alloc_pages that returns a struct page and is in the direct mapping vs dma_alloc_noncoherent that can be vmapped - conver the firewire ohci driver to dma_alloc_pages Diffstat: