Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1330207pxk; Fri, 25 Sep 2020 11:47:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWZf5MD3InIDzruB2ZEIom8GMBln4yKa+0gP97mFJM/iVYNaRO9aZqZ4mby+bPMuP4u89w X-Received: by 2002:a50:fb99:: with SMTP id e25mr2775983edq.281.1601059666926; Fri, 25 Sep 2020 11:47:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601059666; cv=none; d=google.com; s=arc-20160816; b=nf5zTLLKHl6MIgcrEQeVkWjr6ZhP58Bu3gs87TEAUBJWVQ/jisP6gfUdVOHCi+JsR4 IH8f30x1w0Y6k/CyRUONlUq4u8lBlpSuWNNSPSPDUM3fKbeWn3+WKKhfc/BTbI7eFoMM N2lAfTLqID66k+WnwkYQbK8Cj6FrXB+ND2rlQvk46IX7qx96G2uadonT0ZMxWVAsLyu2 pq5bMX5ls8O5TPbx6dS2tW51HAf21zbGaQfMbJF4ctyD7sYjpOtTOwrL9d8D4RTIjlYL e37d4Ae60g739ApBzS5tryKJ0zrLD8w+Rm4hvnpIfXTw4Iu4kQsaUI6vqtsMvzvkFmcX j+3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=AlDiV2I2Pb3l4Sw1FS8MXXmwraDk5F1rgxliXh5N5CM=; b=wxlQoUtxj782ucoNBFbWt3I40Z+5fHTIHbw5vi1gcPrqB8lxxgo/sylqHV48o6DfSj GJKrts8fK28ee7MRXkvz2ZyURmdMgJX9zAIybqqFO8g2h6LSV5gLdRi1X3Nz6cN1lHVV mgX9ueYb7A7Tux13n51RKWx74DpUaFAEcDSiPFnl2r5SvpcuERJyD/8w5c0QQ0Iwf3iQ PjKdsSvbLaAP86EI8rpALuNGhiBSP70X0susUcQjfkZ9KNGmDVqEVfeYcbb0Ddej3pAv w1XcnrzdRdLbBQwnMTOyXox1OA7a3IGzUvptYObRmeln1quiKMeQw+BdM1tlSr0Ypxp5 YH7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=hNVaqgoi; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g2si2433120ejp.429.2020.09.25.11.47.23; Fri, 25 Sep 2020 11:47:46 -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=pass header.i=@chromium.org header.s=google header.b=hNVaqgoi; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729697AbgIYSq1 (ORCPT + 99 others); Fri, 25 Sep 2020 14:46:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729728AbgIYSq0 (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 3A18DC0613D9 for ; Fri, 25 Sep 2020 11:46:26 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id t10so4787722wrv.1 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=TcLqNnPFKD7PDfXyPgrMQ43eoEp2BsWzsW3uXxZaagKjbkBKE7wq1xLV4PJvw4xGUS qLTNMZU3GWhziAZ2qHkfkenxnHdj5GpvAY75bQz++y57t7mwMRKKhFKgg0o9f94AEvGP k1xTaw7EkqoUgZxWyhvWfhLDmwrOflXmpHwXAC5O9EOEp+NxK+PaLXb9ktZ3UT48M/G+ WO9+mR5l+WT/SNooZ1CGvyodfOa20ucaTARgEN0BUvJ9115NyPzyhVKFscco+jCH8ROy YE5XJp+4U+GBli6zHiI2p9mubvlYY+py4onEsZITFVi9poblJyxQHLEqffnk2pUgA+Mw 5mQg== X-Gm-Message-State: AOAM5338WeHz6eBNzhpHOq3b16EqOmDmFQORZ/wObRF6PPMFg3elBQCi 4RgI7Di3V4iqAxewmfde7pwHXw== 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-kernel@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