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=-8.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 02CBDC4741F for ; Fri, 25 Sep 2020 18:46:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8703520878 for ; Fri, 25 Sep 2020 18:46:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="hNVaqgoi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8703520878 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E00636B005C; Fri, 25 Sep 2020 14:46:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DB08E6B005D; Fri, 25 Sep 2020 14:46:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C796C6B0062; Fri, 25 Sep 2020 14:46:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0007.hostedemail.com [216.40.44.7]) by kanga.kvack.org (Postfix) with ESMTP id B33BD6B005C for ; Fri, 25 Sep 2020 14:46:26 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 79B11582C for ; Fri, 25 Sep 2020 18:46:26 +0000 (UTC) X-FDA: 77302464372.30.tramp04_31060d127169 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin30.hostedemail.com (Postfix) with ESMTP id 5A1DC180B3C83 for ; Fri, 25 Sep 2020 18:46:26 +0000 (UTC) X-HE-Tag: tramp04_31060d127169 X-Filterd-Recvd-Size: 5096 Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Fri, 25 Sep 2020 18:46:25 +0000 (UTC) Received: by mail-wr1-f68.google.com with SMTP id x14so4708668wrl.12 for ; Fri, 25 Sep 2020 11:46:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=AlDiV2I2Pb3l4Sw1FS8MXXmwraDk5F1rgxliXh5N5CM=; b=hNVaqgoiF4i4BUKziRlpXfyKzDqaE2Y0RasEA7QnYZaUqmrhYmxmR65VR3QsZGT0/N elfdI2ZtE21gOt8NsKBS76ANRONmfTntZIUBb37OAepaErQ4mHfX26H/avNX5Om2F5Th iF/y4L9RdXJwUeLTzBdv6H/xNDzBbfk+2GMdQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=AlDiV2I2Pb3l4Sw1FS8MXXmwraDk5F1rgxliXh5N5CM=; b=TPDERh+MVcFTo6uoCMvCoIGSdvWQPQ67mMLAhv2IzPGhTKGOuaiYlHNmxEQcbhRIUX 6AAYNG/rdNTXA8GMeDoJ2Qs4MqhBuJSDDJhGwqLvIF1ThSjkFXoxs1khqmmo1TAxEVpO bOG0DgAC+iUrOT8F7NSbIZZqY5JrjSaZ4jH6EyEN/w6a4dxY3QefVduvV3E0fVMz0O0r hHHqPNBfczyZ3ZI6mcN5AjV3yGNsU997V1yf8bjxz/W6J0h9iiGGOw83CaJb1qtfCa6f l4sI9wdRjv399R/zsb8GMR/k5kPQ+ZtBenRvDAgLAaXgZIX8grPzAtMwQyQWORDYyEch A2Lg== X-Gm-Message-State: AOAM531kYyGgRkId6XEmvBmVPAV0akQ+ii3WY1PSdqU9NLLuXHQ9U700 6iCGlCYuGrfR8AeIKTxviqoNMw== X-Google-Smtp-Source: ABdhPJywG75RJx/fVTLzqgivIcRb/Gp708YyNw5VwVyHEf689ET8en+rXMvfgfeOwhu5XQytInH4aQ== X-Received: by 2002:a5d:56cd:: with SMTP id m13mr5730549wrw.261.1601059584552; Fri, 25 Sep 2020 11:46:24 -0700 (PDT) Received: from chromium.org (216.131.76.34.bc.googleusercontent.com. [34.76.131.216]) by smtp.gmail.com with ESMTPSA id z8sm3728264wrl.11.2020.09.25.11.46.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Sep 2020 11:46:23 -0700 (PDT) Date: Fri, 25 Sep 2020 18:46:22 +0000 From: Tomasz Figa To: Christoph Hellwig Cc: Mauro Carvalho Chehab , Thomas Bogendoerfer , "James E.J. Bottomley" , Joonyoung Shim , Seung-Woo Kim , Ben Skeggs , Marek Szyprowski , Matt Porter , iommu@lists.linux-foundation.org, 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: Re: [PATCH 17/18] dma-iommu: implement ->alloc_noncoherent Message-ID: <20200925184622.GB3607091@chromium.org> References: <20200915155122.1768241-1-hch@lst.de> <20200915155122.1768241-18-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200915155122.1768241-18-hch@lst.de> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Hi Christoph, On Tue, Sep 15, 2020 at 05:51:21PM +0200, Christoph Hellwig wrote: > Implement the alloc_noncoherent method to provide memory that is neither > coherent not contiguous. > > Signed-off-by: Christoph Hellwig > --- > drivers/iommu/dma-iommu.c | 41 +++++++++++++++++++++++++++++++++++---- > 1 file changed, 37 insertions(+), 4 deletions(-) > Sorry for being late to the party and thanks a lot for the patch. Please see my comments inline. [snip] > @@ -1052,6 +1055,34 @@ static void *iommu_dma_alloc(struct device *dev, size_t size, > return cpu_addr; > } > > +#ifdef CONFIG_DMA_REMAP > +static void *iommu_dma_alloc_noncoherent(struct device *dev, size_t size, > + dma_addr_t *handle, enum dma_data_direction dir, gfp_t gfp) > +{ > + if (!gfpflags_allow_blocking(gfp)) { > + struct page *page; > + > + page = dma_common_alloc_pages(dev, size, handle, dir, gfp); > + if (!page) > + return NULL; > + return page_address(page); > + } > + > + return iommu_dma_alloc_remap(dev, size, handle, gfp | __GFP_ZERO, > + PAGE_KERNEL, 0); iommu_dma_alloc_remap() makes use of the DMA_ATTR_ALLOC_SINGLE_PAGES attribute to optimize the allocations for devices which don't care about how contiguous the backing memory is. Do you think we could add an attrs argument to this function and pass it there? As ARM is being moved to the common iommu-dma layer as well, we'll probably make use of the argument to support the DMA_ATTR_NO_KERNEL_MAPPING attribute to conserve the vmalloc area. Best regards, Tomasz