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 106A8C47420 for ; Fri, 25 Sep 2020 18:46:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C959B221E5 for ; Fri, 25 Sep 2020 18:46:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="hNVaqgoi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729728AbgIYSqc (ORCPT ); Fri, 25 Sep 2020 14:46:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729714AbgIYSq0 (ORCPT ); Fri, 25 Sep 2020 14:46:26 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1998CC0613D5 for ; Fri, 25 Sep 2020 11:46:26 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id z4so4771633wrr.4 for ; Fri, 25 Sep 2020 11:46:26 -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=FTma4J5hBfUEDHyVGkF1cOb974rOm6RllRbRh1IpG6juv7SbmHVDKQ3ceb+pYauiKR YbwCwobqnZyVqpQ+5FAusQ1QSHFj1zrKDPWxy/q2rKfkWV36Z6Zo4FlGqRUqBkr3DOnp kFTP5F4JsuulG2EX/FgP9QyxCemmZs34CZSk/5ubL7OGfPx/poY/NmrB5/r1ceYxE4yJ QaXrUOczjNuvQjuW9RhKJnQSp+1SOeWGFpTTLAf1R/nMyeaVp9980J7P4MBQ43lCXsIz QlMRfOBDcOZs85uifKggqRJQLSzUeL+PdospzhBXLhL7E4Axh/u0RdE5bGkWQySfmo0x zu6Q== X-Gm-Message-State: AOAM533uPglCBbm/NGjfuH+px4fyz5VYXzbXRO+UGNXTOjxt6tPH0Xpt iKulhc0puITqxOy+SQh0MzHBlQ== 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> Precedence: bulk List-ID: X-Mailing-List: linux-doc@vger.kernel.org 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