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=-16.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 E5B3AC43460 for ; Mon, 26 Apr 2021 16:40:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B2C0561059 for ; Mon, 26 Apr 2021 16:40:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234541AbhDZQkv (ORCPT ); Mon, 26 Apr 2021 12:40:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234566AbhDZQiw (ORCPT ); Mon, 26 Apr 2021 12:38:52 -0400 Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 329C7C061574 for ; Mon, 26 Apr 2021 09:38:11 -0700 (PDT) Received: by mail-io1-xd2b.google.com with SMTP id e186so3588832iof.7 for ; Mon, 26 Apr 2021 09:38:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=cFKXKq/sKurvSVgvNvGkxgOiMlOZ5bG92GQyZxG6/Ow=; b=hQyrvIvY0OkwlUkO65L/o3TMJboyrA/EOLuUe0Pq7KgqeFtR8O9LJWrjeU2EQISYlu bJHPBsPqEo2jNERM7Qly7inrbryADiFPyU5whSnn5mfATXbgH1UnC4GjWrov7E7itgl/ y/vmAUUGiGEmxu0IFynSQLccMWdifgG50rRhw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cFKXKq/sKurvSVgvNvGkxgOiMlOZ5bG92GQyZxG6/Ow=; b=BlSmpq+WUHIOvCRDOykDXDKGBdT0HrHWiSIk4i4S5MLuaKSu5oXkdKZtXzdZ/QriN9 msVBYQhP5bg7W8lQ6+KDxG0ucrAZlnh7gI6lHfkJmNddt8/FLJRL/URehfcIfuDTvZdM yRoL5lyY888OYboT3cltXjigZg4L/r1ECLr6e4M3N1FimqS6f66qvUw33I/yGJUTGHsS m2S/DxrPJtp1/6cznVkK/bYN6iUko2TKE7pNx++LIBF/5SlhK3j6dWU/U4K44bw4lmfL odPnoyUXn+Eb6R5Z/p3CMIEwSvgBCWYX0yDTfn9kepx0KREAn4kG/KRKlZI8DMzKZgEU LMpA== X-Gm-Message-State: AOAM530hFheksKwKHprwvzUqfPqAPs4MBsIh2DzL+wKkK7048pdvS3iv EqKQf7R2PJuSoYBbO7R7NOaUt2Jw5bINJA== X-Google-Smtp-Source: ABdhPJzmr9PwVx3/rr3jhi2q/Dab+lix8Jx9OhhHQiOa8yAJ+20K77OHSlJFA0mktIhUzMS6p8SapA== X-Received: by 2002:a05:6602:168d:: with SMTP id s13mr3701311iow.82.1619455089992; Mon, 26 Apr 2021 09:38:09 -0700 (PDT) Received: from mail-il1-f176.google.com (mail-il1-f176.google.com. [209.85.166.176]) by smtp.gmail.com with ESMTPSA id v10sm166580ilc.80.2021.04.26.09.38.08 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Apr 2021 09:38:08 -0700 (PDT) Received: by mail-il1-f176.google.com with SMTP id c18so47083173iln.7 for ; Mon, 26 Apr 2021 09:38:08 -0700 (PDT) X-Received: by 2002:a92:7307:: with SMTP id o7mr14655769ilc.5.1619455077553; Mon, 26 Apr 2021 09:37:57 -0700 (PDT) MIME-Version: 1.0 References: <20210422081508.3942748-1-tientzu@chromium.org> <20210422081508.3942748-9-tientzu@chromium.org> <1f84aa4c-f966-0986-b5a4-eecbf3b454ec@arm.com> In-Reply-To: <1f84aa4c-f966-0986-b5a4-eecbf3b454ec@arm.com> From: Claire Chang Date: Tue, 27 Apr 2021 00:37:46 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v5 08/16] swiotlb: Update is_swiotlb_active to add a struct device argument To: Robin Murphy Cc: Joerg Roedel , Will Deacon , Frank Rowand , Konrad Rzeszutek Wilk , boris.ostrovsky@oracle.com, jgross@suse.com, Christoph Hellwig , Marek Szyprowski , benh@kernel.crashing.org, paulus@samba.org, "list@263.net:IOMMU DRIVERS" , sstabellini@kernel.org, grant.likely@arm.com, xypron.glpk@gmx.de, Thierry Reding , mingo@kernel.org, bauerman@linux.ibm.com, peterz@infradead.org, Greg KH , Saravana Kannan , "Rafael J . Wysocki" , heikki.krogerus@linux.intel.com, Andy Shevchenko , Randy Dunlap , Dan Williams , Bartosz Golaszewski , linux-devicetree , lkml , linuxppc-dev@lists.ozlabs.org, xen-devel@lists.xenproject.org, Nicolas Boichat , Jim Quinlan , Tomasz Figa , bskeggs@redhat.com, Bjorn Helgaas , chris@chris-wilson.co.uk, Daniel Vetter , airlied@linux.ie, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, jani.nikula@linux.intel.com, Jianxiong Gao , joonas.lahtinen@linux.intel.com, linux-pci@vger.kernel.org, maarten.lankhorst@linux.intel.com, matthew.auld@intel.com, nouveau@lists.freedesktop.org, rodrigo.vivi@intel.com, thomas.hellstrom@linux.intel.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 23, 2021 at 9:31 PM Robin Murphy wrote: > > On 2021-04-22 09:15, Claire Chang wrote: > > Update is_swiotlb_active to add a struct device argument. This will be > > useful later to allow for restricted DMA pool. > > > > Signed-off-by: Claire Chang > > --- > > drivers/gpu/drm/i915/gem/i915_gem_internal.c | 2 +- > > drivers/gpu/drm/nouveau/nouveau_ttm.c | 2 +- > > drivers/pci/xen-pcifront.c | 2 +- > > include/linux/swiotlb.h | 4 ++-- > > kernel/dma/direct.c | 2 +- > > kernel/dma/swiotlb.c | 4 ++-- > > 6 files changed, 8 insertions(+), 8 deletions(-) > > > > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_internal.c b/drivers/gpu/drm/i915/gem/i915_gem_internal.c > > index ce6b664b10aa..7d48c433446b 100644 > > --- a/drivers/gpu/drm/i915/gem/i915_gem_internal.c > > +++ b/drivers/gpu/drm/i915/gem/i915_gem_internal.c > > @@ -42,7 +42,7 @@ static int i915_gem_object_get_pages_internal(struct drm_i915_gem_object *obj) > > > > max_order = MAX_ORDER; > > #ifdef CONFIG_SWIOTLB > > - if (is_swiotlb_active()) { > > + if (is_swiotlb_active(NULL)) { > > unsigned int max_segment; > > > > max_segment = swiotlb_max_segment(); > > diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c > > index e8b506a6685b..2a2ae6d6cf6d 100644 > > --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c > > +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c > > @@ -321,7 +321,7 @@ nouveau_ttm_init(struct nouveau_drm *drm) > > } > > > > #if IS_ENABLED(CONFIG_SWIOTLB) && IS_ENABLED(CONFIG_X86) > > - need_swiotlb = is_swiotlb_active(); > > + need_swiotlb = is_swiotlb_active(NULL); > > #endif > > > > ret = ttm_device_init(&drm->ttm.bdev, &nouveau_bo_driver, drm->dev->dev, > > diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c > > index b7a8f3a1921f..6d548ce53ce7 100644 > > --- a/drivers/pci/xen-pcifront.c > > +++ b/drivers/pci/xen-pcifront.c > > @@ -693,7 +693,7 @@ static int pcifront_connect_and_init_dma(struct pcifront_device *pdev) > > > > spin_unlock(&pcifront_dev_lock); > > > > - if (!err && !is_swiotlb_active()) { > > + if (!err && !is_swiotlb_active(NULL)) { > > err = pci_xen_swiotlb_init_late(); > > if (err) > > dev_err(&pdev->xdev->dev, "Could not setup SWIOTLB!\n"); > > diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h > > index 2a6cca07540b..c530c976d18b 100644 > > --- a/include/linux/swiotlb.h > > +++ b/include/linux/swiotlb.h > > @@ -123,7 +123,7 @@ static inline bool is_swiotlb_buffer(struct device *dev, phys_addr_t paddr) > > void __init swiotlb_exit(void); > > unsigned int swiotlb_max_segment(void); > > size_t swiotlb_max_mapping_size(struct device *dev); > > -bool is_swiotlb_active(void); > > +bool is_swiotlb_active(struct device *dev); > > void __init swiotlb_adjust_size(unsigned long size); > > #else > > #define swiotlb_force SWIOTLB_NO_FORCE > > @@ -143,7 +143,7 @@ static inline size_t swiotlb_max_mapping_size(struct device *dev) > > return SIZE_MAX; > > } > > > > -static inline bool is_swiotlb_active(void) > > +static inline bool is_swiotlb_active(struct device *dev) > > { > > return false; > > } > > diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c > > index 84c9feb5474a..7a88c34d0867 100644 > > --- a/kernel/dma/direct.c > > +++ b/kernel/dma/direct.c > > @@ -495,7 +495,7 @@ int dma_direct_supported(struct device *dev, u64 mask) > > size_t dma_direct_max_mapping_size(struct device *dev) > > { > > /* If SWIOTLB is active, use its maximum mapping size */ > > - if (is_swiotlb_active() && > > + if (is_swiotlb_active(dev) && > > (dma_addressing_limited(dev) || swiotlb_force == SWIOTLB_FORCE)) > > I wonder if it's worth trying to fold these other conditions into > is_swiotlb_active() itself? I'm not entirely sure what matters for Xen, > but for the other cases it seems like they probably only care about > whether bouncing may occur for their particular device or not (possibly > they want to be using dma_max_mapping_size() now anyway - TBH I'm > struggling to make sense of what the swiotlb_max_segment business is > supposed to mean). I think leaving those conditions outside of is_swiotlb_active() might help avoid confusion with is_dev_swiotlb_force() in patch #9? We need is_dev_swiotlb_force() only because the restricted DMA pool supports memory allocation, but the default swiotlb doesn't. > > Otherwise, patch #9 will need to touch here as well to make sure that > per-device forced bouncing is reflected correctly. You're right. Otherwise, is_dev_swiotlb_force is needed here. > > Robin. > > > return swiotlb_max_mapping_size(dev); > > return SIZE_MAX; > > diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c > > index ffbb8724e06c..1d221343f1c8 100644 > > --- a/kernel/dma/swiotlb.c > > +++ b/kernel/dma/swiotlb.c > > @@ -659,9 +659,9 @@ size_t swiotlb_max_mapping_size(struct device *dev) > > return ((size_t)IO_TLB_SIZE) * IO_TLB_SEGSIZE; > > } > > > > -bool is_swiotlb_active(void) > > +bool is_swiotlb_active(struct device *dev) > > { > > - return io_tlb_default_mem != NULL; > > + return get_io_tlb_mem(dev) != NULL; > > } > > EXPORT_SYMBOL_GPL(is_swiotlb_active); > > > > 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=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 A0FB8C433ED for ; Mon, 26 Apr 2021 16:38:45 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 A38E361009 for ; Mon, 26 Apr 2021 16:38:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A38E361009 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4FTVvl0Mzkz30Cw for ; Tue, 27 Apr 2021 02:38:43 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=hQyrvIvY; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=chromium.org (client-ip=2607:f8b0:4864:20::d32; helo=mail-io1-xd32.google.com; envelope-from=tientzu@chromium.org; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=hQyrvIvY; dkim-atps=neutral Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4FTVvD1W4Bz2yRX for ; Tue, 27 Apr 2021 02:38:15 +1000 (AEST) Received: by mail-io1-xd32.google.com with SMTP id t21so5801133iob.2 for ; Mon, 26 Apr 2021 09:38:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=cFKXKq/sKurvSVgvNvGkxgOiMlOZ5bG92GQyZxG6/Ow=; b=hQyrvIvY0OkwlUkO65L/o3TMJboyrA/EOLuUe0Pq7KgqeFtR8O9LJWrjeU2EQISYlu bJHPBsPqEo2jNERM7Qly7inrbryADiFPyU5whSnn5mfATXbgH1UnC4GjWrov7E7itgl/ y/vmAUUGiGEmxu0IFynSQLccMWdifgG50rRhw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cFKXKq/sKurvSVgvNvGkxgOiMlOZ5bG92GQyZxG6/Ow=; b=YT4pAHQau3X8gdqWlc7J4IKQY37yCgi7vp618YiSm4fOYzVTNwYxUTWctqdH2kLZzn aVaemZEUppjnoBJLufd5NIKzb7kBoNChOrSUk693yiwD1Rfbc0G0kcGHnZru05chZE03 lf4ACh+xqAKngRzLNN05ncIo09sH7se33X3G9Z1+A0aOUj/F4ODxV9NWhZiKVctdHfc5 P+zN3skuWj5p/3Q6NS1vHMKh/kUsxyctBIZkaKNjH5VppOeJfeC0sriJMUDLxbgVr7B0 JlDV7eFILCfwRDnWmMNh3Mlq6mc3aPev2o0YAHBwTANR1tF0WrUnn806Zcq8f4sixVZa stTA== X-Gm-Message-State: AOAM530ElXVU93VkzZhZUoozQgUJHX9n6PDr1BM/wolqqE1UEe3PJgcO Vb0HUlE9uhALsmUpMUsrYpc8eIi2sMUhaA== X-Google-Smtp-Source: ABdhPJwXy8B1HwZYNTGfF5zFSg13X8mq0yaqzz3jNlNzwGDiv8dRY4N9zHcIUziWcHLRHU9kpXdyUQ== X-Received: by 2002:a05:6602:1689:: with SMTP id s9mr14725210iow.171.1619455090915; Mon, 26 Apr 2021 09:38:10 -0700 (PDT) Received: from mail-il1-f175.google.com (mail-il1-f175.google.com. [209.85.166.175]) by smtp.gmail.com with ESMTPSA id j20sm174501ilo.17.2021.04.26.09.38.08 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Apr 2021 09:38:10 -0700 (PDT) Received: by mail-il1-f175.google.com with SMTP id a9so1530617ilh.9 for ; Mon, 26 Apr 2021 09:38:08 -0700 (PDT) X-Received: by 2002:a92:7307:: with SMTP id o7mr14655769ilc.5.1619455077553; Mon, 26 Apr 2021 09:37:57 -0700 (PDT) MIME-Version: 1.0 References: <20210422081508.3942748-1-tientzu@chromium.org> <20210422081508.3942748-9-tientzu@chromium.org> <1f84aa4c-f966-0986-b5a4-eecbf3b454ec@arm.com> In-Reply-To: <1f84aa4c-f966-0986-b5a4-eecbf3b454ec@arm.com> From: Claire Chang Date: Tue, 27 Apr 2021 00:37:46 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v5 08/16] swiotlb: Update is_swiotlb_active to add a struct device argument To: Robin Murphy Content-Type: text/plain; charset="UTF-8" X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: heikki.krogerus@linux.intel.com, thomas.hellstrom@linux.intel.com, peterz@infradead.org, joonas.lahtinen@linux.intel.com, dri-devel@lists.freedesktop.org, lkml , grant.likely@arm.com, paulus@samba.org, Will Deacon , mingo@kernel.org, Marek Szyprowski , sstabellini@kernel.org, Saravana Kannan , xypron.glpk@gmx.de, Joerg Roedel , "Rafael J . Wysocki" , Christoph Hellwig , Bartosz Golaszewski , bskeggs@redhat.com, linux-pci@vger.kernel.org, xen-devel@lists.xenproject.org, Thierry Reding , intel-gfx@lists.freedesktop.org, matthew.auld@intel.com, linux-devicetree , Jianxiong Gao , Daniel Vetter , Konrad Rzeszutek Wilk , maarten.lankhorst@linux.intel.com, airlied@linux.ie, Dan Williams , jani.nikula@linux.intel.com, Nicolas Boichat , rodrigo.vivi@intel.com, Bjorn Helgaas , boris.ostrovsky@oracle.com, Andy Shevchenko , jgross@suse.com, chris@chris-wilson.co.uk, nouveau@lists.freedesktop.org, Greg KH , Randy Dunlap , Frank Rowand , Tomasz Figa , "list@263.net:IOMMU DRIVERS" , Jim Quinlan , linuxppc-dev@lists.ozlabs.org, bauerman@linux.ibm.com Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Fri, Apr 23, 2021 at 9:31 PM Robin Murphy wrote: > > On 2021-04-22 09:15, Claire Chang wrote: > > Update is_swiotlb_active to add a struct device argument. This will be > > useful later to allow for restricted DMA pool. > > > > Signed-off-by: Claire Chang > > --- > > drivers/gpu/drm/i915/gem/i915_gem_internal.c | 2 +- > > drivers/gpu/drm/nouveau/nouveau_ttm.c | 2 +- > > drivers/pci/xen-pcifront.c | 2 +- > > include/linux/swiotlb.h | 4 ++-- > > kernel/dma/direct.c | 2 +- > > kernel/dma/swiotlb.c | 4 ++-- > > 6 files changed, 8 insertions(+), 8 deletions(-) > > > > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_internal.c b/drivers/gpu/drm/i915/gem/i915_gem_internal.c > > index ce6b664b10aa..7d48c433446b 100644 > > --- a/drivers/gpu/drm/i915/gem/i915_gem_internal.c > > +++ b/drivers/gpu/drm/i915/gem/i915_gem_internal.c > > @@ -42,7 +42,7 @@ static int i915_gem_object_get_pages_internal(struct drm_i915_gem_object *obj) > > > > max_order = MAX_ORDER; > > #ifdef CONFIG_SWIOTLB > > - if (is_swiotlb_active()) { > > + if (is_swiotlb_active(NULL)) { > > unsigned int max_segment; > > > > max_segment = swiotlb_max_segment(); > > diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c > > index e8b506a6685b..2a2ae6d6cf6d 100644 > > --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c > > +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c > > @@ -321,7 +321,7 @@ nouveau_ttm_init(struct nouveau_drm *drm) > > } > > > > #if IS_ENABLED(CONFIG_SWIOTLB) && IS_ENABLED(CONFIG_X86) > > - need_swiotlb = is_swiotlb_active(); > > + need_swiotlb = is_swiotlb_active(NULL); > > #endif > > > > ret = ttm_device_init(&drm->ttm.bdev, &nouveau_bo_driver, drm->dev->dev, > > diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c > > index b7a8f3a1921f..6d548ce53ce7 100644 > > --- a/drivers/pci/xen-pcifront.c > > +++ b/drivers/pci/xen-pcifront.c > > @@ -693,7 +693,7 @@ static int pcifront_connect_and_init_dma(struct pcifront_device *pdev) > > > > spin_unlock(&pcifront_dev_lock); > > > > - if (!err && !is_swiotlb_active()) { > > + if (!err && !is_swiotlb_active(NULL)) { > > err = pci_xen_swiotlb_init_late(); > > if (err) > > dev_err(&pdev->xdev->dev, "Could not setup SWIOTLB!\n"); > > diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h > > index 2a6cca07540b..c530c976d18b 100644 > > --- a/include/linux/swiotlb.h > > +++ b/include/linux/swiotlb.h > > @@ -123,7 +123,7 @@ static inline bool is_swiotlb_buffer(struct device *dev, phys_addr_t paddr) > > void __init swiotlb_exit(void); > > unsigned int swiotlb_max_segment(void); > > size_t swiotlb_max_mapping_size(struct device *dev); > > -bool is_swiotlb_active(void); > > +bool is_swiotlb_active(struct device *dev); > > void __init swiotlb_adjust_size(unsigned long size); > > #else > > #define swiotlb_force SWIOTLB_NO_FORCE > > @@ -143,7 +143,7 @@ static inline size_t swiotlb_max_mapping_size(struct device *dev) > > return SIZE_MAX; > > } > > > > -static inline bool is_swiotlb_active(void) > > +static inline bool is_swiotlb_active(struct device *dev) > > { > > return false; > > } > > diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c > > index 84c9feb5474a..7a88c34d0867 100644 > > --- a/kernel/dma/direct.c > > +++ b/kernel/dma/direct.c > > @@ -495,7 +495,7 @@ int dma_direct_supported(struct device *dev, u64 mask) > > size_t dma_direct_max_mapping_size(struct device *dev) > > { > > /* If SWIOTLB is active, use its maximum mapping size */ > > - if (is_swiotlb_active() && > > + if (is_swiotlb_active(dev) && > > (dma_addressing_limited(dev) || swiotlb_force == SWIOTLB_FORCE)) > > I wonder if it's worth trying to fold these other conditions into > is_swiotlb_active() itself? I'm not entirely sure what matters for Xen, > but for the other cases it seems like they probably only care about > whether bouncing may occur for their particular device or not (possibly > they want to be using dma_max_mapping_size() now anyway - TBH I'm > struggling to make sense of what the swiotlb_max_segment business is > supposed to mean). I think leaving those conditions outside of is_swiotlb_active() might help avoid confusion with is_dev_swiotlb_force() in patch #9? We need is_dev_swiotlb_force() only because the restricted DMA pool supports memory allocation, but the default swiotlb doesn't. > > Otherwise, patch #9 will need to touch here as well to make sure that > per-device forced bouncing is reflected correctly. You're right. Otherwise, is_dev_swiotlb_force is needed here. > > Robin. > > > return swiotlb_max_mapping_size(dev); > > return SIZE_MAX; > > diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c > > index ffbb8724e06c..1d221343f1c8 100644 > > --- a/kernel/dma/swiotlb.c > > +++ b/kernel/dma/swiotlb.c > > @@ -659,9 +659,9 @@ size_t swiotlb_max_mapping_size(struct device *dev) > > return ((size_t)IO_TLB_SIZE) * IO_TLB_SEGSIZE; > > } > > > > -bool is_swiotlb_active(void) > > +bool is_swiotlb_active(struct device *dev) > > { > > - return io_tlb_default_mem != NULL; > > + return get_io_tlb_mem(dev) != NULL; > > } > > EXPORT_SYMBOL_GPL(is_swiotlb_active); > > > > 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=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 93C8BC433ED for ; Mon, 26 Apr 2021 22:23:07 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 353CF613AB for ; Mon, 26 Apr 2021 22:23:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 353CF613AB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=nouveau-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D4A046E030; Mon, 26 Apr 2021 22:23:06 +0000 (UTC) Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6ACFB6E84F for ; Mon, 26 Apr 2021 16:44:29 +0000 (UTC) Received: by mail-io1-xd2f.google.com with SMTP id t21so5823369iob.2 for ; Mon, 26 Apr 2021 09:44:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=cFKXKq/sKurvSVgvNvGkxgOiMlOZ5bG92GQyZxG6/Ow=; b=hQyrvIvY0OkwlUkO65L/o3TMJboyrA/EOLuUe0Pq7KgqeFtR8O9LJWrjeU2EQISYlu bJHPBsPqEo2jNERM7Qly7inrbryADiFPyU5whSnn5mfATXbgH1UnC4GjWrov7E7itgl/ y/vmAUUGiGEmxu0IFynSQLccMWdifgG50rRhw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cFKXKq/sKurvSVgvNvGkxgOiMlOZ5bG92GQyZxG6/Ow=; b=dncTr0+QC3xMbmUjEzg5PRS6Z7Zc9WS93WzTBwSofTOSXrVXAzr6Gj/T59+E1NXjTm zFRewdAIZ7kfXSWfS6d82xrP+1k0AMDoiWbcgHaJzO/EsaXIhoC4d6qNLO+Sdn3w/jFg VJJE+U7E2bsPwNxCWzXOoKUkf0pmSw+4M8qrI/8YaeHADYVQqieYnP9SrogWlvDPNx33 kvkSt0PUceLukKdol9gS1ve5oh1Xxd8hsuoB5AByyWpCm/4p6fAj1xQ9X3+bSIFqTEmN HjMHRDUSBuTZHe8PYAn6RAjBXtqZFSJlcoQ/74S6pcFIo0LdHFm0coGidCbHAAtslT6Y NLqg== X-Gm-Message-State: AOAM533X28i7kBZxLol6RiKCfuRRgeBRI5buGmWwmN2Qf77x0T0Yr5Dq hmDEcT4rJhARN+HUci/2SjK3dxlPmP/DdA== X-Google-Smtp-Source: ABdhPJwlAjW+Hk3EIbBFDSLXSHETFXoClXE5wWoaqNZMII0tOkS8m21Q9C2vDJ1ftA+XRojbHjqAvQ== X-Received: by 2002:a02:818b:: with SMTP id n11mr17638344jag.62.1619455468251; Mon, 26 Apr 2021 09:44:28 -0700 (PDT) Received: from mail-io1-f43.google.com (mail-io1-f43.google.com. [209.85.166.43]) by smtp.gmail.com with ESMTPSA id g26sm7596205iom.14.2021.04.26.09.44.27 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Apr 2021 09:44:28 -0700 (PDT) Received: by mail-io1-f43.google.com with SMTP id g125so2341558iof.3 for ; Mon, 26 Apr 2021 09:44:27 -0700 (PDT) X-Received: by 2002:a92:7307:: with SMTP id o7mr14655769ilc.5.1619455077553; Mon, 26 Apr 2021 09:37:57 -0700 (PDT) MIME-Version: 1.0 References: <20210422081508.3942748-1-tientzu@chromium.org> <20210422081508.3942748-9-tientzu@chromium.org> <1f84aa4c-f966-0986-b5a4-eecbf3b454ec@arm.com> In-Reply-To: <1f84aa4c-f966-0986-b5a4-eecbf3b454ec@arm.com> From: Claire Chang Date: Tue, 27 Apr 2021 00:37:46 +0800 X-Gmail-Original-Message-ID: Message-ID: To: Robin Murphy X-Mailman-Approved-At: Mon, 26 Apr 2021 22:23:06 +0000 Subject: Re: [Nouveau] [PATCH v5 08/16] swiotlb: Update is_swiotlb_active to add a struct device argument X-BeenThere: nouveau@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Nouveau development list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: heikki.krogerus@linux.intel.com, thomas.hellstrom@linux.intel.com, peterz@infradead.org, benh@kernel.crashing.org, joonas.lahtinen@linux.intel.com, dri-devel@lists.freedesktop.org, lkml , grant.likely@arm.com, paulus@samba.org, Will Deacon , mingo@kernel.org, Marek Szyprowski , sstabellini@kernel.org, Saravana Kannan , xypron.glpk@gmx.de, Joerg Roedel , "Rafael J . Wysocki" , Christoph Hellwig , Bartosz Golaszewski , bskeggs@redhat.com, linux-pci@vger.kernel.org, xen-devel@lists.xenproject.org, Thierry Reding , intel-gfx@lists.freedesktop.org, matthew.auld@intel.com, linux-devicetree , Jianxiong Gao , Daniel Vetter , Konrad Rzeszutek Wilk , maarten.lankhorst@linux.intel.com, airlied@linux.ie, Dan Williams , jani.nikula@linux.intel.com, Nicolas Boichat , rodrigo.vivi@intel.com, Bjorn Helgaas , boris.ostrovsky@oracle.com, Andy Shevchenko , jgross@suse.com, chris@chris-wilson.co.uk, nouveau@lists.freedesktop.org, Greg KH , Randy Dunlap , Frank Rowand , Tomasz Figa , "list@263.net:IOMMU DRIVERS" , Jim Quinlan , linuxppc-dev@lists.ozlabs.org, bauerman@linux.ibm.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: nouveau-bounces@lists.freedesktop.org Sender: "Nouveau" On Fri, Apr 23, 2021 at 9:31 PM Robin Murphy wrote: > > On 2021-04-22 09:15, Claire Chang wrote: > > Update is_swiotlb_active to add a struct device argument. This will be > > useful later to allow for restricted DMA pool. > > > > Signed-off-by: Claire Chang > > --- > > drivers/gpu/drm/i915/gem/i915_gem_internal.c | 2 +- > > drivers/gpu/drm/nouveau/nouveau_ttm.c | 2 +- > > drivers/pci/xen-pcifront.c | 2 +- > > include/linux/swiotlb.h | 4 ++-- > > kernel/dma/direct.c | 2 +- > > kernel/dma/swiotlb.c | 4 ++-- > > 6 files changed, 8 insertions(+), 8 deletions(-) > > > > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_internal.c b/drivers/gpu/drm/i915/gem/i915_gem_internal.c > > index ce6b664b10aa..7d48c433446b 100644 > > --- a/drivers/gpu/drm/i915/gem/i915_gem_internal.c > > +++ b/drivers/gpu/drm/i915/gem/i915_gem_internal.c > > @@ -42,7 +42,7 @@ static int i915_gem_object_get_pages_internal(struct drm_i915_gem_object *obj) > > > > max_order = MAX_ORDER; > > #ifdef CONFIG_SWIOTLB > > - if (is_swiotlb_active()) { > > + if (is_swiotlb_active(NULL)) { > > unsigned int max_segment; > > > > max_segment = swiotlb_max_segment(); > > diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c > > index e8b506a6685b..2a2ae6d6cf6d 100644 > > --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c > > +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c > > @@ -321,7 +321,7 @@ nouveau_ttm_init(struct nouveau_drm *drm) > > } > > > > #if IS_ENABLED(CONFIG_SWIOTLB) && IS_ENABLED(CONFIG_X86) > > - need_swiotlb = is_swiotlb_active(); > > + need_swiotlb = is_swiotlb_active(NULL); > > #endif > > > > ret = ttm_device_init(&drm->ttm.bdev, &nouveau_bo_driver, drm->dev->dev, > > diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c > > index b7a8f3a1921f..6d548ce53ce7 100644 > > --- a/drivers/pci/xen-pcifront.c > > +++ b/drivers/pci/xen-pcifront.c > > @@ -693,7 +693,7 @@ static int pcifront_connect_and_init_dma(struct pcifront_device *pdev) > > > > spin_unlock(&pcifront_dev_lock); > > > > - if (!err && !is_swiotlb_active()) { > > + if (!err && !is_swiotlb_active(NULL)) { > > err = pci_xen_swiotlb_init_late(); > > if (err) > > dev_err(&pdev->xdev->dev, "Could not setup SWIOTLB!\n"); > > diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h > > index 2a6cca07540b..c530c976d18b 100644 > > --- a/include/linux/swiotlb.h > > +++ b/include/linux/swiotlb.h > > @@ -123,7 +123,7 @@ static inline bool is_swiotlb_buffer(struct device *dev, phys_addr_t paddr) > > void __init swiotlb_exit(void); > > unsigned int swiotlb_max_segment(void); > > size_t swiotlb_max_mapping_size(struct device *dev); > > -bool is_swiotlb_active(void); > > +bool is_swiotlb_active(struct device *dev); > > void __init swiotlb_adjust_size(unsigned long size); > > #else > > #define swiotlb_force SWIOTLB_NO_FORCE > > @@ -143,7 +143,7 @@ static inline size_t swiotlb_max_mapping_size(struct device *dev) > > return SIZE_MAX; > > } > > > > -static inline bool is_swiotlb_active(void) > > +static inline bool is_swiotlb_active(struct device *dev) > > { > > return false; > > } > > diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c > > index 84c9feb5474a..7a88c34d0867 100644 > > --- a/kernel/dma/direct.c > > +++ b/kernel/dma/direct.c > > @@ -495,7 +495,7 @@ int dma_direct_supported(struct device *dev, u64 mask) > > size_t dma_direct_max_mapping_size(struct device *dev) > > { > > /* If SWIOTLB is active, use its maximum mapping size */ > > - if (is_swiotlb_active() && > > + if (is_swiotlb_active(dev) && > > (dma_addressing_limited(dev) || swiotlb_force == SWIOTLB_FORCE)) > > I wonder if it's worth trying to fold these other conditions into > is_swiotlb_active() itself? I'm not entirely sure what matters for Xen, > but for the other cases it seems like they probably only care about > whether bouncing may occur for their particular device or not (possibly > they want to be using dma_max_mapping_size() now anyway - TBH I'm > struggling to make sense of what the swiotlb_max_segment business is > supposed to mean). I think leaving those conditions outside of is_swiotlb_active() might help avoid confusion with is_dev_swiotlb_force() in patch #9? We need is_dev_swiotlb_force() only because the restricted DMA pool supports memory allocation, but the default swiotlb doesn't. > > Otherwise, patch #9 will need to touch here as well to make sure that > per-device forced bouncing is reflected correctly. You're right. Otherwise, is_dev_swiotlb_force is needed here. > > Robin. > > > return swiotlb_max_mapping_size(dev); > > return SIZE_MAX; > > diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c > > index ffbb8724e06c..1d221343f1c8 100644 > > --- a/kernel/dma/swiotlb.c > > +++ b/kernel/dma/swiotlb.c > > @@ -659,9 +659,9 @@ size_t swiotlb_max_mapping_size(struct device *dev) > > return ((size_t)IO_TLB_SIZE) * IO_TLB_SEGSIZE; > > } > > > > -bool is_swiotlb_active(void) > > +bool is_swiotlb_active(struct device *dev) > > { > > - return io_tlb_default_mem != NULL; > > + return get_io_tlb_mem(dev) != NULL; > > } > > EXPORT_SYMBOL_GPL(is_swiotlb_active); > > > > _______________________________________________ Nouveau mailing list Nouveau@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/nouveau 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=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_RED 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 61594C433ED for ; Mon, 26 Apr 2021 16:38:07 +0000 (UTC) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.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 D531C6103E for ; Mon, 26 Apr 2021 16:38:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D531C6103E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=iommu-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 7738F4029B; Mon, 26 Apr 2021 16:38:06 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0EJapgF1soEc; Mon, 26 Apr 2021 16:38:05 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp2.osuosl.org (Postfix) with ESMTP id 3EFFE40285; Mon, 26 Apr 2021 16:38:05 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1E67CC000F; Mon, 26 Apr 2021 16:38:05 +0000 (UTC) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 54510C000B for ; Mon, 26 Apr 2021 16:38:04 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 41E8D6061E for ; Mon, 26 Apr 2021 16:38:04 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp3.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=chromium.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jg-X238qoxh1 for ; Mon, 26 Apr 2021 16:38:03 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) by smtp3.osuosl.org (Postfix) with ESMTPS id 66140606C6 for ; Mon, 26 Apr 2021 16:38:03 +0000 (UTC) Received: by mail-io1-xd2a.google.com with SMTP id f21so20492768ioh.8 for ; Mon, 26 Apr 2021 09:38:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=cFKXKq/sKurvSVgvNvGkxgOiMlOZ5bG92GQyZxG6/Ow=; b=hQyrvIvY0OkwlUkO65L/o3TMJboyrA/EOLuUe0Pq7KgqeFtR8O9LJWrjeU2EQISYlu bJHPBsPqEo2jNERM7Qly7inrbryADiFPyU5whSnn5mfATXbgH1UnC4GjWrov7E7itgl/ y/vmAUUGiGEmxu0IFynSQLccMWdifgG50rRhw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cFKXKq/sKurvSVgvNvGkxgOiMlOZ5bG92GQyZxG6/Ow=; b=LtSBmo1FKKnofVPxGeLbi6XYpo7RnKraGdioxQoKFELIooLFDrs/XJOZ5Y741nQchR zPFbSrOXVZLJCBp56cVq9ON96FMgjasW8qL4oBEfqnn+gqCjjk3xNMqs3evibCp3+ZRn ZzPAgU2NSL2PFdMgYwA5027RvuFMr3sYFqsII9stJSpPYa5UWBDzvXm1VOBjwdxlsXHD HCmcBGotGTNKDIZ2vWAFBxI/xMAldz0JgD+mXbBs2Ad2VwgKrhdGedYsAHfMtWCkrBJl akWUF0gyY15yhnnjl6uQNHWayJY5uWtVuczz9dPpX3HSOaj7IlMyZmUL0qbdtBOWIKXS zc4Q== X-Gm-Message-State: AOAM532YBmBR6zd3PTIJoELwL9HwBY8rdk6NGlr5yhqBIPfX/m08b98S BtRxbAdK1skrjE9R4MGJnZxkQ1aYNsb4IA== X-Google-Smtp-Source: ABdhPJzU7IHBA3iYvAg+C9t9EUFOdYHponmYpjW0sGqW9jZQa3wEb3Ew5ehuLU1K/bVmMHxbRUnCaw== X-Received: by 2002:a02:818b:: with SMTP id n11mr17608378jag.62.1619455081152; Mon, 26 Apr 2021 09:38:01 -0700 (PDT) Received: from mail-il1-f173.google.com (mail-il1-f173.google.com. [209.85.166.173]) by smtp.gmail.com with ESMTPSA id a8sm7889643iod.4.2021.04.26.09.37.58 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Apr 2021 09:37:58 -0700 (PDT) Received: by mail-il1-f173.google.com with SMTP id r5so6917248ilb.2 for ; Mon, 26 Apr 2021 09:37:58 -0700 (PDT) X-Received: by 2002:a92:7307:: with SMTP id o7mr14655769ilc.5.1619455077553; Mon, 26 Apr 2021 09:37:57 -0700 (PDT) MIME-Version: 1.0 References: <20210422081508.3942748-1-tientzu@chromium.org> <20210422081508.3942748-9-tientzu@chromium.org> <1f84aa4c-f966-0986-b5a4-eecbf3b454ec@arm.com> In-Reply-To: <1f84aa4c-f966-0986-b5a4-eecbf3b454ec@arm.com> From: Claire Chang Date: Tue, 27 Apr 2021 00:37:46 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v5 08/16] swiotlb: Update is_swiotlb_active to add a struct device argument To: Robin Murphy Cc: heikki.krogerus@linux.intel.com, thomas.hellstrom@linux.intel.com, peterz@infradead.org, benh@kernel.crashing.org, joonas.lahtinen@linux.intel.com, dri-devel@lists.freedesktop.org, lkml , grant.likely@arm.com, paulus@samba.org, Will Deacon , mingo@kernel.org, sstabellini@kernel.org, Saravana Kannan , xypron.glpk@gmx.de, "Rafael J . Wysocki" , Christoph Hellwig , Bartosz Golaszewski , bskeggs@redhat.com, linux-pci@vger.kernel.org, xen-devel@lists.xenproject.org, Thierry Reding , intel-gfx@lists.freedesktop.org, matthew.auld@intel.com, linux-devicetree , Jianxiong Gao , Daniel Vetter , Konrad Rzeszutek Wilk , maarten.lankhorst@linux.intel.com, airlied@linux.ie, Dan Williams , jani.nikula@linux.intel.com, Nicolas Boichat , rodrigo.vivi@intel.com, Bjorn Helgaas , boris.ostrovsky@oracle.com, Andy Shevchenko , jgross@suse.com, chris@chris-wilson.co.uk, nouveau@lists.freedesktop.org, Greg KH , Randy Dunlap , Frank Rowand , "list@263.net:IOMMU DRIVERS" , Jim Quinlan , linuxppc-dev@lists.ozlabs.org, bauerman@linux.ibm.com X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" On Fri, Apr 23, 2021 at 9:31 PM Robin Murphy wrote: > > On 2021-04-22 09:15, Claire Chang wrote: > > Update is_swiotlb_active to add a struct device argument. This will be > > useful later to allow for restricted DMA pool. > > > > Signed-off-by: Claire Chang > > --- > > drivers/gpu/drm/i915/gem/i915_gem_internal.c | 2 +- > > drivers/gpu/drm/nouveau/nouveau_ttm.c | 2 +- > > drivers/pci/xen-pcifront.c | 2 +- > > include/linux/swiotlb.h | 4 ++-- > > kernel/dma/direct.c | 2 +- > > kernel/dma/swiotlb.c | 4 ++-- > > 6 files changed, 8 insertions(+), 8 deletions(-) > > > > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_internal.c b/drivers/gpu/drm/i915/gem/i915_gem_internal.c > > index ce6b664b10aa..7d48c433446b 100644 > > --- a/drivers/gpu/drm/i915/gem/i915_gem_internal.c > > +++ b/drivers/gpu/drm/i915/gem/i915_gem_internal.c > > @@ -42,7 +42,7 @@ static int i915_gem_object_get_pages_internal(struct drm_i915_gem_object *obj) > > > > max_order = MAX_ORDER; > > #ifdef CONFIG_SWIOTLB > > - if (is_swiotlb_active()) { > > + if (is_swiotlb_active(NULL)) { > > unsigned int max_segment; > > > > max_segment = swiotlb_max_segment(); > > diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c > > index e8b506a6685b..2a2ae6d6cf6d 100644 > > --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c > > +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c > > @@ -321,7 +321,7 @@ nouveau_ttm_init(struct nouveau_drm *drm) > > } > > > > #if IS_ENABLED(CONFIG_SWIOTLB) && IS_ENABLED(CONFIG_X86) > > - need_swiotlb = is_swiotlb_active(); > > + need_swiotlb = is_swiotlb_active(NULL); > > #endif > > > > ret = ttm_device_init(&drm->ttm.bdev, &nouveau_bo_driver, drm->dev->dev, > > diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c > > index b7a8f3a1921f..6d548ce53ce7 100644 > > --- a/drivers/pci/xen-pcifront.c > > +++ b/drivers/pci/xen-pcifront.c > > @@ -693,7 +693,7 @@ static int pcifront_connect_and_init_dma(struct pcifront_device *pdev) > > > > spin_unlock(&pcifront_dev_lock); > > > > - if (!err && !is_swiotlb_active()) { > > + if (!err && !is_swiotlb_active(NULL)) { > > err = pci_xen_swiotlb_init_late(); > > if (err) > > dev_err(&pdev->xdev->dev, "Could not setup SWIOTLB!\n"); > > diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h > > index 2a6cca07540b..c530c976d18b 100644 > > --- a/include/linux/swiotlb.h > > +++ b/include/linux/swiotlb.h > > @@ -123,7 +123,7 @@ static inline bool is_swiotlb_buffer(struct device *dev, phys_addr_t paddr) > > void __init swiotlb_exit(void); > > unsigned int swiotlb_max_segment(void); > > size_t swiotlb_max_mapping_size(struct device *dev); > > -bool is_swiotlb_active(void); > > +bool is_swiotlb_active(struct device *dev); > > void __init swiotlb_adjust_size(unsigned long size); > > #else > > #define swiotlb_force SWIOTLB_NO_FORCE > > @@ -143,7 +143,7 @@ static inline size_t swiotlb_max_mapping_size(struct device *dev) > > return SIZE_MAX; > > } > > > > -static inline bool is_swiotlb_active(void) > > +static inline bool is_swiotlb_active(struct device *dev) > > { > > return false; > > } > > diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c > > index 84c9feb5474a..7a88c34d0867 100644 > > --- a/kernel/dma/direct.c > > +++ b/kernel/dma/direct.c > > @@ -495,7 +495,7 @@ int dma_direct_supported(struct device *dev, u64 mask) > > size_t dma_direct_max_mapping_size(struct device *dev) > > { > > /* If SWIOTLB is active, use its maximum mapping size */ > > - if (is_swiotlb_active() && > > + if (is_swiotlb_active(dev) && > > (dma_addressing_limited(dev) || swiotlb_force == SWIOTLB_FORCE)) > > I wonder if it's worth trying to fold these other conditions into > is_swiotlb_active() itself? I'm not entirely sure what matters for Xen, > but for the other cases it seems like they probably only care about > whether bouncing may occur for their particular device or not (possibly > they want to be using dma_max_mapping_size() now anyway - TBH I'm > struggling to make sense of what the swiotlb_max_segment business is > supposed to mean). I think leaving those conditions outside of is_swiotlb_active() might help avoid confusion with is_dev_swiotlb_force() in patch #9? We need is_dev_swiotlb_force() only because the restricted DMA pool supports memory allocation, but the default swiotlb doesn't. > > Otherwise, patch #9 will need to touch here as well to make sure that > per-device forced bouncing is reflected correctly. You're right. Otherwise, is_dev_swiotlb_force is needed here. > > Robin. > > > return swiotlb_max_mapping_size(dev); > > return SIZE_MAX; > > diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c > > index ffbb8724e06c..1d221343f1c8 100644 > > --- a/kernel/dma/swiotlb.c > > +++ b/kernel/dma/swiotlb.c > > @@ -659,9 +659,9 @@ size_t swiotlb_max_mapping_size(struct device *dev) > > return ((size_t)IO_TLB_SIZE) * IO_TLB_SEGSIZE; > > } > > > > -bool is_swiotlb_active(void) > > +bool is_swiotlb_active(struct device *dev) > > { > > - return io_tlb_default_mem != NULL; > > + return get_io_tlb_mem(dev) != NULL; > > } > > EXPORT_SYMBOL_GPL(is_swiotlb_active); > > > > _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu 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=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 3D31FC433ED for ; Mon, 26 Apr 2021 16:44:42 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 D812A6101C for ; Mon, 26 Apr 2021 16:44:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D812A6101C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 311D46E844; Mon, 26 Apr 2021 16:44:41 +0000 (UTC) Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) by gabe.freedesktop.org (Postfix) with ESMTPS id D86356E85F for ; Mon, 26 Apr 2021 16:44:39 +0000 (UTC) Received: by mail-il1-x134.google.com with SMTP id a9so1547915ilh.9 for ; Mon, 26 Apr 2021 09:44:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=cFKXKq/sKurvSVgvNvGkxgOiMlOZ5bG92GQyZxG6/Ow=; b=hQyrvIvY0OkwlUkO65L/o3TMJboyrA/EOLuUe0Pq7KgqeFtR8O9LJWrjeU2EQISYlu bJHPBsPqEo2jNERM7Qly7inrbryADiFPyU5whSnn5mfATXbgH1UnC4GjWrov7E7itgl/ y/vmAUUGiGEmxu0IFynSQLccMWdifgG50rRhw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cFKXKq/sKurvSVgvNvGkxgOiMlOZ5bG92GQyZxG6/Ow=; b=boLofMnezBsY+uTFdppzXh3iXwb8+5arF8v9/3yvLae3qRA4XqDvwhk+GWlxUOIlMN yEN/ZWsWZnNacfT++7XFDRTwYHioBDsL3Unem1MSLBXVuje7ltp4cyCaWVz97KnLRckB aD20YHYqkCwsmkVzuS/fXEjSWTJ/tO+lDZIucw23KeyyliiBvc6GzGl1o3jKRnpzj9Dr csJHnneUO05BldhPIt+KmJYRm7F4ea01yzVA0Xg8H5WfwUU4oD9sZ4UJ1ZHepa/GGCKd U2OpQzjWIQRjIc2du0JDvr2mxZp+WwAXWt/46BRIZltnOed2wJgwpWG3OTI3NwpEg3Qn oauQ== X-Gm-Message-State: AOAM532T4bAYC/lQ/QecwkHLbPgAfLanVAQ+qIDc6PaKRL6tEiVnvgwU 7Svgeg8o6bHnqtVtdBfqxVZlGp2EVJ3REw== X-Google-Smtp-Source: ABdhPJwQ/8E/BDNG5Ae1nYYQsELO7WTDspzkiiiNLeGCaLDmC1Fl6ygj4rEthrq86YijQUzEvhOAYA== X-Received: by 2002:a92:da8a:: with SMTP id u10mr14959707iln.100.1619455478912; Mon, 26 Apr 2021 09:44:38 -0700 (PDT) Received: from mail-io1-f43.google.com (mail-io1-f43.google.com. [209.85.166.43]) by smtp.gmail.com with ESMTPSA id 6sm7844912iog.36.2021.04.26.09.44.38 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Apr 2021 09:44:38 -0700 (PDT) Received: by mail-io1-f43.google.com with SMTP id t21so5823917iob.2 for ; Mon, 26 Apr 2021 09:44:38 -0700 (PDT) X-Received: by 2002:a92:7307:: with SMTP id o7mr14655769ilc.5.1619455077553; Mon, 26 Apr 2021 09:37:57 -0700 (PDT) MIME-Version: 1.0 References: <20210422081508.3942748-1-tientzu@chromium.org> <20210422081508.3942748-9-tientzu@chromium.org> <1f84aa4c-f966-0986-b5a4-eecbf3b454ec@arm.com> In-Reply-To: <1f84aa4c-f966-0986-b5a4-eecbf3b454ec@arm.com> From: Claire Chang Date: Tue, 27 Apr 2021 00:37:46 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v5 08/16] swiotlb: Update is_swiotlb_active to add a struct device argument To: Robin Murphy X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: heikki.krogerus@linux.intel.com, thomas.hellstrom@linux.intel.com, peterz@infradead.org, dri-devel@lists.freedesktop.org, lkml , grant.likely@arm.com, paulus@samba.org, Will Deacon , mingo@kernel.org, Marek Szyprowski , sstabellini@kernel.org, Saravana Kannan , xypron.glpk@gmx.de, Joerg Roedel , "Rafael J . Wysocki" , Christoph Hellwig , Bartosz Golaszewski , bskeggs@redhat.com, linux-pci@vger.kernel.org, xen-devel@lists.xenproject.org, Thierry Reding , intel-gfx@lists.freedesktop.org, matthew.auld@intel.com, linux-devicetree , Jianxiong Gao , Konrad Rzeszutek Wilk , airlied@linux.ie, Dan Williams , Nicolas Boichat , rodrigo.vivi@intel.com, Bjorn Helgaas , boris.ostrovsky@oracle.com, Andy Shevchenko , jgross@suse.com, chris@chris-wilson.co.uk, nouveau@lists.freedesktop.org, Greg KH , Randy Dunlap , Frank Rowand , Tomasz Figa , "list@263.net:IOMMU DRIVERS" , Jim Quinlan , linuxppc-dev@lists.ozlabs.org, bauerman@linux.ibm.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Fri, Apr 23, 2021 at 9:31 PM Robin Murphy wrote: > > On 2021-04-22 09:15, Claire Chang wrote: > > Update is_swiotlb_active to add a struct device argument. This will be > > useful later to allow for restricted DMA pool. > > > > Signed-off-by: Claire Chang > > --- > > drivers/gpu/drm/i915/gem/i915_gem_internal.c | 2 +- > > drivers/gpu/drm/nouveau/nouveau_ttm.c | 2 +- > > drivers/pci/xen-pcifront.c | 2 +- > > include/linux/swiotlb.h | 4 ++-- > > kernel/dma/direct.c | 2 +- > > kernel/dma/swiotlb.c | 4 ++-- > > 6 files changed, 8 insertions(+), 8 deletions(-) > > > > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_internal.c b/drivers/gpu/drm/i915/gem/i915_gem_internal.c > > index ce6b664b10aa..7d48c433446b 100644 > > --- a/drivers/gpu/drm/i915/gem/i915_gem_internal.c > > +++ b/drivers/gpu/drm/i915/gem/i915_gem_internal.c > > @@ -42,7 +42,7 @@ static int i915_gem_object_get_pages_internal(struct drm_i915_gem_object *obj) > > > > max_order = MAX_ORDER; > > #ifdef CONFIG_SWIOTLB > > - if (is_swiotlb_active()) { > > + if (is_swiotlb_active(NULL)) { > > unsigned int max_segment; > > > > max_segment = swiotlb_max_segment(); > > diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c > > index e8b506a6685b..2a2ae6d6cf6d 100644 > > --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c > > +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c > > @@ -321,7 +321,7 @@ nouveau_ttm_init(struct nouveau_drm *drm) > > } > > > > #if IS_ENABLED(CONFIG_SWIOTLB) && IS_ENABLED(CONFIG_X86) > > - need_swiotlb = is_swiotlb_active(); > > + need_swiotlb = is_swiotlb_active(NULL); > > #endif > > > > ret = ttm_device_init(&drm->ttm.bdev, &nouveau_bo_driver, drm->dev->dev, > > diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c > > index b7a8f3a1921f..6d548ce53ce7 100644 > > --- a/drivers/pci/xen-pcifront.c > > +++ b/drivers/pci/xen-pcifront.c > > @@ -693,7 +693,7 @@ static int pcifront_connect_and_init_dma(struct pcifront_device *pdev) > > > > spin_unlock(&pcifront_dev_lock); > > > > - if (!err && !is_swiotlb_active()) { > > + if (!err && !is_swiotlb_active(NULL)) { > > err = pci_xen_swiotlb_init_late(); > > if (err) > > dev_err(&pdev->xdev->dev, "Could not setup SWIOTLB!\n"); > > diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h > > index 2a6cca07540b..c530c976d18b 100644 > > --- a/include/linux/swiotlb.h > > +++ b/include/linux/swiotlb.h > > @@ -123,7 +123,7 @@ static inline bool is_swiotlb_buffer(struct device *dev, phys_addr_t paddr) > > void __init swiotlb_exit(void); > > unsigned int swiotlb_max_segment(void); > > size_t swiotlb_max_mapping_size(struct device *dev); > > -bool is_swiotlb_active(void); > > +bool is_swiotlb_active(struct device *dev); > > void __init swiotlb_adjust_size(unsigned long size); > > #else > > #define swiotlb_force SWIOTLB_NO_FORCE > > @@ -143,7 +143,7 @@ static inline size_t swiotlb_max_mapping_size(struct device *dev) > > return SIZE_MAX; > > } > > > > -static inline bool is_swiotlb_active(void) > > +static inline bool is_swiotlb_active(struct device *dev) > > { > > return false; > > } > > diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c > > index 84c9feb5474a..7a88c34d0867 100644 > > --- a/kernel/dma/direct.c > > +++ b/kernel/dma/direct.c > > @@ -495,7 +495,7 @@ int dma_direct_supported(struct device *dev, u64 mask) > > size_t dma_direct_max_mapping_size(struct device *dev) > > { > > /* If SWIOTLB is active, use its maximum mapping size */ > > - if (is_swiotlb_active() && > > + if (is_swiotlb_active(dev) && > > (dma_addressing_limited(dev) || swiotlb_force == SWIOTLB_FORCE)) > > I wonder if it's worth trying to fold these other conditions into > is_swiotlb_active() itself? I'm not entirely sure what matters for Xen, > but for the other cases it seems like they probably only care about > whether bouncing may occur for their particular device or not (possibly > they want to be using dma_max_mapping_size() now anyway - TBH I'm > struggling to make sense of what the swiotlb_max_segment business is > supposed to mean). I think leaving those conditions outside of is_swiotlb_active() might help avoid confusion with is_dev_swiotlb_force() in patch #9? We need is_dev_swiotlb_force() only because the restricted DMA pool supports memory allocation, but the default swiotlb doesn't. > > Otherwise, patch #9 will need to touch here as well to make sure that > per-device forced bouncing is reflected correctly. You're right. Otherwise, is_dev_swiotlb_force is needed here. > > Robin. > > > return swiotlb_max_mapping_size(dev); > > return SIZE_MAX; > > diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c > > index ffbb8724e06c..1d221343f1c8 100644 > > --- a/kernel/dma/swiotlb.c > > +++ b/kernel/dma/swiotlb.c > > @@ -659,9 +659,9 @@ size_t swiotlb_max_mapping_size(struct device *dev) > > return ((size_t)IO_TLB_SIZE) * IO_TLB_SEGSIZE; > > } > > > > -bool is_swiotlb_active(void) > > +bool is_swiotlb_active(struct device *dev) > > { > > - return io_tlb_default_mem != NULL; > > + return get_io_tlb_mem(dev) != NULL; > > } > > EXPORT_SYMBOL_GPL(is_swiotlb_active); > > > > _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel 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=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 A7B90C433ED for ; Mon, 26 Apr 2021 16:45:47 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 5D90B6101C for ; Mon, 26 Apr 2021 16:45:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5D90B6101C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C89936E84F; Mon, 26 Apr 2021 16:45:46 +0000 (UTC) Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by gabe.freedesktop.org (Postfix) with ESMTPS id DE1026E84F for ; Mon, 26 Apr 2021 16:45:45 +0000 (UTC) Received: by mail-pg1-x530.google.com with SMTP id t22so5182103pgu.0 for ; Mon, 26 Apr 2021 09:45:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=cFKXKq/sKurvSVgvNvGkxgOiMlOZ5bG92GQyZxG6/Ow=; b=hQyrvIvY0OkwlUkO65L/o3TMJboyrA/EOLuUe0Pq7KgqeFtR8O9LJWrjeU2EQISYlu bJHPBsPqEo2jNERM7Qly7inrbryADiFPyU5whSnn5mfATXbgH1UnC4GjWrov7E7itgl/ y/vmAUUGiGEmxu0IFynSQLccMWdifgG50rRhw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cFKXKq/sKurvSVgvNvGkxgOiMlOZ5bG92GQyZxG6/Ow=; b=fKRmxwQym++Q3VcORR2HqqJM1q0QtvUJaySZWSnUO1ds4XW4GghkTNh0o9BrBIUr7a jyfr+Ox3JAii6izThtfMlPO4rQk4J1JLo2uZD0eB/aC0qTSTBJ8QZgsP7lsQ7rIiItio VaIMHf0836XWMkKrxxttHMDB3mKz4vf8JxsgRLminAgoE7Q4r8x+w3gwFQfs3dAUSO23 kHxXRHh1pwEmVm/Yhq7OsfFW2gJ7pfSbgn3QXX4d5nFIndL5Ay99/qKnhgR+/RSjEZUM nyvN2s66SbT4m2EpT/rPyNzL8bRgLrXFCHY/ejWq72KHZCHrmnDEmMjbnZlCavdP6mnd OrTQ== X-Gm-Message-State: AOAM531zgiBZUu8rdVOBVC/q8KpQHBNOrG0+DIXrp8WJJi3NC1eqQKjM NR+Hl3/HPD9m6Wi376tZLtiqjd3hVuyJLQ== X-Google-Smtp-Source: ABdhPJxQP7DIP+TJEdEufOw3Z94L40YGZzxt/60EqkAEvXdA60QR0CmIDk4EAmGaer+IT3tIcwKAWw== X-Received: by 2002:aa7:9f02:0:b029:25d:26b2:ecac with SMTP id g2-20020aa79f020000b029025d26b2ecacmr18958004pfr.61.1619455545109; Mon, 26 Apr 2021 09:45:45 -0700 (PDT) Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com. [209.85.215.177]) by smtp.gmail.com with ESMTPSA id u18sm249694pfm.4.2021.04.26.09.45.44 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Apr 2021 09:45:44 -0700 (PDT) Received: by mail-pg1-f177.google.com with SMTP id f29so3308691pgm.8 for ; Mon, 26 Apr 2021 09:45:44 -0700 (PDT) X-Received: by 2002:a92:7307:: with SMTP id o7mr14655769ilc.5.1619455077553; Mon, 26 Apr 2021 09:37:57 -0700 (PDT) MIME-Version: 1.0 References: <20210422081508.3942748-1-tientzu@chromium.org> <20210422081508.3942748-9-tientzu@chromium.org> <1f84aa4c-f966-0986-b5a4-eecbf3b454ec@arm.com> In-Reply-To: <1f84aa4c-f966-0986-b5a4-eecbf3b454ec@arm.com> From: Claire Chang Date: Tue, 27 Apr 2021 00:37:46 +0800 X-Gmail-Original-Message-ID: Message-ID: To: Robin Murphy Subject: Re: [Intel-gfx] [PATCH v5 08/16] swiotlb: Update is_swiotlb_active to add a struct device argument X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: heikki.krogerus@linux.intel.com, thomas.hellstrom@linux.intel.com, peterz@infradead.org, benh@kernel.crashing.org, dri-devel@lists.freedesktop.org, lkml , grant.likely@arm.com, paulus@samba.org, Will Deacon , mingo@kernel.org, Marek Szyprowski , sstabellini@kernel.org, Saravana Kannan , xypron.glpk@gmx.de, Joerg Roedel , "Rafael J . Wysocki" , Christoph Hellwig , Bartosz Golaszewski , bskeggs@redhat.com, linux-pci@vger.kernel.org, xen-devel@lists.xenproject.org, Thierry Reding , intel-gfx@lists.freedesktop.org, matthew.auld@intel.com, linux-devicetree , Jianxiong Gao , Konrad Rzeszutek Wilk , airlied@linux.ie, Dan Williams , Nicolas Boichat , Bjorn Helgaas , boris.ostrovsky@oracle.com, Andy Shevchenko , jgross@suse.com, chris@chris-wilson.co.uk, nouveau@lists.freedesktop.org, Greg KH , Randy Dunlap , Frank Rowand , Tomasz Figa , "list@263.net:IOMMU DRIVERS" , Jim Quinlan , linuxppc-dev@lists.ozlabs.org, bauerman@linux.ibm.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On Fri, Apr 23, 2021 at 9:31 PM Robin Murphy wrote: > > On 2021-04-22 09:15, Claire Chang wrote: > > Update is_swiotlb_active to add a struct device argument. This will be > > useful later to allow for restricted DMA pool. > > > > Signed-off-by: Claire Chang > > --- > > drivers/gpu/drm/i915/gem/i915_gem_internal.c | 2 +- > > drivers/gpu/drm/nouveau/nouveau_ttm.c | 2 +- > > drivers/pci/xen-pcifront.c | 2 +- > > include/linux/swiotlb.h | 4 ++-- > > kernel/dma/direct.c | 2 +- > > kernel/dma/swiotlb.c | 4 ++-- > > 6 files changed, 8 insertions(+), 8 deletions(-) > > > > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_internal.c b/drivers/gpu/drm/i915/gem/i915_gem_internal.c > > index ce6b664b10aa..7d48c433446b 100644 > > --- a/drivers/gpu/drm/i915/gem/i915_gem_internal.c > > +++ b/drivers/gpu/drm/i915/gem/i915_gem_internal.c > > @@ -42,7 +42,7 @@ static int i915_gem_object_get_pages_internal(struct drm_i915_gem_object *obj) > > > > max_order = MAX_ORDER; > > #ifdef CONFIG_SWIOTLB > > - if (is_swiotlb_active()) { > > + if (is_swiotlb_active(NULL)) { > > unsigned int max_segment; > > > > max_segment = swiotlb_max_segment(); > > diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c > > index e8b506a6685b..2a2ae6d6cf6d 100644 > > --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c > > +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c > > @@ -321,7 +321,7 @@ nouveau_ttm_init(struct nouveau_drm *drm) > > } > > > > #if IS_ENABLED(CONFIG_SWIOTLB) && IS_ENABLED(CONFIG_X86) > > - need_swiotlb = is_swiotlb_active(); > > + need_swiotlb = is_swiotlb_active(NULL); > > #endif > > > > ret = ttm_device_init(&drm->ttm.bdev, &nouveau_bo_driver, drm->dev->dev, > > diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c > > index b7a8f3a1921f..6d548ce53ce7 100644 > > --- a/drivers/pci/xen-pcifront.c > > +++ b/drivers/pci/xen-pcifront.c > > @@ -693,7 +693,7 @@ static int pcifront_connect_and_init_dma(struct pcifront_device *pdev) > > > > spin_unlock(&pcifront_dev_lock); > > > > - if (!err && !is_swiotlb_active()) { > > + if (!err && !is_swiotlb_active(NULL)) { > > err = pci_xen_swiotlb_init_late(); > > if (err) > > dev_err(&pdev->xdev->dev, "Could not setup SWIOTLB!\n"); > > diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h > > index 2a6cca07540b..c530c976d18b 100644 > > --- a/include/linux/swiotlb.h > > +++ b/include/linux/swiotlb.h > > @@ -123,7 +123,7 @@ static inline bool is_swiotlb_buffer(struct device *dev, phys_addr_t paddr) > > void __init swiotlb_exit(void); > > unsigned int swiotlb_max_segment(void); > > size_t swiotlb_max_mapping_size(struct device *dev); > > -bool is_swiotlb_active(void); > > +bool is_swiotlb_active(struct device *dev); > > void __init swiotlb_adjust_size(unsigned long size); > > #else > > #define swiotlb_force SWIOTLB_NO_FORCE > > @@ -143,7 +143,7 @@ static inline size_t swiotlb_max_mapping_size(struct device *dev) > > return SIZE_MAX; > > } > > > > -static inline bool is_swiotlb_active(void) > > +static inline bool is_swiotlb_active(struct device *dev) > > { > > return false; > > } > > diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c > > index 84c9feb5474a..7a88c34d0867 100644 > > --- a/kernel/dma/direct.c > > +++ b/kernel/dma/direct.c > > @@ -495,7 +495,7 @@ int dma_direct_supported(struct device *dev, u64 mask) > > size_t dma_direct_max_mapping_size(struct device *dev) > > { > > /* If SWIOTLB is active, use its maximum mapping size */ > > - if (is_swiotlb_active() && > > + if (is_swiotlb_active(dev) && > > (dma_addressing_limited(dev) || swiotlb_force == SWIOTLB_FORCE)) > > I wonder if it's worth trying to fold these other conditions into > is_swiotlb_active() itself? I'm not entirely sure what matters for Xen, > but for the other cases it seems like they probably only care about > whether bouncing may occur for their particular device or not (possibly > they want to be using dma_max_mapping_size() now anyway - TBH I'm > struggling to make sense of what the swiotlb_max_segment business is > supposed to mean). I think leaving those conditions outside of is_swiotlb_active() might help avoid confusion with is_dev_swiotlb_force() in patch #9? We need is_dev_swiotlb_force() only because the restricted DMA pool supports memory allocation, but the default swiotlb doesn't. > > Otherwise, patch #9 will need to touch here as well to make sure that > per-device forced bouncing is reflected correctly. You're right. Otherwise, is_dev_swiotlb_force is needed here. > > Robin. > > > return swiotlb_max_mapping_size(dev); > > return SIZE_MAX; > > diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c > > index ffbb8724e06c..1d221343f1c8 100644 > > --- a/kernel/dma/swiotlb.c > > +++ b/kernel/dma/swiotlb.c > > @@ -659,9 +659,9 @@ size_t swiotlb_max_mapping_size(struct device *dev) > > return ((size_t)IO_TLB_SIZE) * IO_TLB_SEGSIZE; > > } > > > > -bool is_swiotlb_active(void) > > +bool is_swiotlb_active(struct device *dev) > > { > > - return io_tlb_default_mem != NULL; > > + return get_io_tlb_mem(dev) != NULL; > > } > > EXPORT_SYMBOL_GPL(is_swiotlb_active); > > > > _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx 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=-16.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 40620C433ED for ; Mon, 26 Apr 2021 16:38:25 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 D092C61059 for ; Mon, 26 Apr 2021 16:38:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D092C61059 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.117812.223718 (Exim 4.92) (envelope-from ) id 1lb4FS-0006cS-2M; Mon, 26 Apr 2021 16:38:14 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 117812.223718; Mon, 26 Apr 2021 16:38:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lb4FR-0006cK-Vd; Mon, 26 Apr 2021 16:38:13 +0000 Received: by outflank-mailman (input) for mailman id 117812; Mon, 26 Apr 2021 16:38:12 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lb4FQ-0006c8-Oi for xen-devel@lists.xenproject.org; Mon, 26 Apr 2021 16:38:12 +0000 Received: from mail-pj1-x1035.google.com (unknown [2607:f8b0:4864:20::1035]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 0cd4ae7c-88fe-4363-8a0a-01fcf29c9b9b; Mon, 26 Apr 2021 16:38:11 +0000 (UTC) Received: by mail-pj1-x1035.google.com with SMTP id f11-20020a17090a638bb02901524d3a3d48so5521091pjj.3 for ; Mon, 26 Apr 2021 09:38:11 -0700 (PDT) Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com. [209.85.210.176]) by smtp.gmail.com with ESMTPSA id q26sm224567pfg.146.2021.04.26.09.38.08 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Apr 2021 09:38:08 -0700 (PDT) Received: by mail-pf1-f176.google.com with SMTP id c3so20553592pfo.3 for ; Mon, 26 Apr 2021 09:38:08 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 0cd4ae7c-88fe-4363-8a0a-01fcf29c9b9b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=cFKXKq/sKurvSVgvNvGkxgOiMlOZ5bG92GQyZxG6/Ow=; b=hQyrvIvY0OkwlUkO65L/o3TMJboyrA/EOLuUe0Pq7KgqeFtR8O9LJWrjeU2EQISYlu bJHPBsPqEo2jNERM7Qly7inrbryADiFPyU5whSnn5mfATXbgH1UnC4GjWrov7E7itgl/ y/vmAUUGiGEmxu0IFynSQLccMWdifgG50rRhw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cFKXKq/sKurvSVgvNvGkxgOiMlOZ5bG92GQyZxG6/Ow=; b=KE7ycAex85qFYZUnP7WuRfJ3KrCl49If8yODagciK9CGu0Yg15YePK6irj7zXKRoNY 76qlrrx2/AUwiDSVlIqxIlxtyFMnTgIQXsfG6dxejPuFMnCtGo3AHAP4NfD79FSufy9a 2qn9SFVRLDuaTFNlTS4/zOe4ag0LBVjMv7zxYXZdUXsABmB3pLMZBeYB2NvSz9cEWPdT vV0Y2mhRi05kafJg7fCveLXurzsGs9JkXVYyAJQoGCk32qDW3iaFZvR8iEm5ltLV3oov DcIvJKaDcJA5ocq8Zc8eOwvManxb8cUHHWw48DA8u5yk53JQj3NEBTBcy3NY2S1YKGT6 jLww== X-Gm-Message-State: AOAM533uOkvrnK69g4TBxCQhxAzgUc0GnxBN6HTb1crrJ+3vy8OEnIpr 2lzcOQJg9P3tLyBSCIuhwAFXviMVewLzhQ== X-Google-Smtp-Source: ABdhPJy2tmpQDEHs6da1EkE2NEPQIbqbfCMXRrHbmcxgdnBYNqEm9wruWum5ezMjDUYCLlveodSf2g== X-Received: by 2002:a17:90a:303:: with SMTP id 3mr24147321pje.36.1619455090084; Mon, 26 Apr 2021 09:38:10 -0700 (PDT) X-Received: by 2002:a92:7307:: with SMTP id o7mr14655769ilc.5.1619455077553; Mon, 26 Apr 2021 09:37:57 -0700 (PDT) MIME-Version: 1.0 References: <20210422081508.3942748-1-tientzu@chromium.org> <20210422081508.3942748-9-tientzu@chromium.org> <1f84aa4c-f966-0986-b5a4-eecbf3b454ec@arm.com> In-Reply-To: <1f84aa4c-f966-0986-b5a4-eecbf3b454ec@arm.com> From: Claire Chang Date: Tue, 27 Apr 2021 00:37:46 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v5 08/16] swiotlb: Update is_swiotlb_active to add a struct device argument To: Robin Murphy Cc: Joerg Roedel , Will Deacon , Frank Rowand , Konrad Rzeszutek Wilk , boris.ostrovsky@oracle.com, jgross@suse.com, Christoph Hellwig , Marek Szyprowski , benh@kernel.crashing.org, paulus@samba.org, "list@263.net:IOMMU DRIVERS" , sstabellini@kernel.org, grant.likely@arm.com, xypron.glpk@gmx.de, Thierry Reding , mingo@kernel.org, bauerman@linux.ibm.com, peterz@infradead.org, Greg KH , Saravana Kannan , "Rafael J . Wysocki" , heikki.krogerus@linux.intel.com, Andy Shevchenko , Randy Dunlap , Dan Williams , Bartosz Golaszewski , linux-devicetree , lkml , linuxppc-dev@lists.ozlabs.org, xen-devel@lists.xenproject.org, Nicolas Boichat , Jim Quinlan , Tomasz Figa , bskeggs@redhat.com, Bjorn Helgaas , chris@chris-wilson.co.uk, Daniel Vetter , airlied@linux.ie, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, jani.nikula@linux.intel.com, Jianxiong Gao , joonas.lahtinen@linux.intel.com, linux-pci@vger.kernel.org, maarten.lankhorst@linux.intel.com, matthew.auld@intel.com, nouveau@lists.freedesktop.org, rodrigo.vivi@intel.com, thomas.hellstrom@linux.intel.com Content-Type: text/plain; charset="UTF-8" On Fri, Apr 23, 2021 at 9:31 PM Robin Murphy wrote: > > On 2021-04-22 09:15, Claire Chang wrote: > > Update is_swiotlb_active to add a struct device argument. This will be > > useful later to allow for restricted DMA pool. > > > > Signed-off-by: Claire Chang > > --- > > drivers/gpu/drm/i915/gem/i915_gem_internal.c | 2 +- > > drivers/gpu/drm/nouveau/nouveau_ttm.c | 2 +- > > drivers/pci/xen-pcifront.c | 2 +- > > include/linux/swiotlb.h | 4 ++-- > > kernel/dma/direct.c | 2 +- > > kernel/dma/swiotlb.c | 4 ++-- > > 6 files changed, 8 insertions(+), 8 deletions(-) > > > > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_internal.c b/drivers/gpu/drm/i915/gem/i915_gem_internal.c > > index ce6b664b10aa..7d48c433446b 100644 > > --- a/drivers/gpu/drm/i915/gem/i915_gem_internal.c > > +++ b/drivers/gpu/drm/i915/gem/i915_gem_internal.c > > @@ -42,7 +42,7 @@ static int i915_gem_object_get_pages_internal(struct drm_i915_gem_object *obj) > > > > max_order = MAX_ORDER; > > #ifdef CONFIG_SWIOTLB > > - if (is_swiotlb_active()) { > > + if (is_swiotlb_active(NULL)) { > > unsigned int max_segment; > > > > max_segment = swiotlb_max_segment(); > > diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c > > index e8b506a6685b..2a2ae6d6cf6d 100644 > > --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c > > +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c > > @@ -321,7 +321,7 @@ nouveau_ttm_init(struct nouveau_drm *drm) > > } > > > > #if IS_ENABLED(CONFIG_SWIOTLB) && IS_ENABLED(CONFIG_X86) > > - need_swiotlb = is_swiotlb_active(); > > + need_swiotlb = is_swiotlb_active(NULL); > > #endif > > > > ret = ttm_device_init(&drm->ttm.bdev, &nouveau_bo_driver, drm->dev->dev, > > diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c > > index b7a8f3a1921f..6d548ce53ce7 100644 > > --- a/drivers/pci/xen-pcifront.c > > +++ b/drivers/pci/xen-pcifront.c > > @@ -693,7 +693,7 @@ static int pcifront_connect_and_init_dma(struct pcifront_device *pdev) > > > > spin_unlock(&pcifront_dev_lock); > > > > - if (!err && !is_swiotlb_active()) { > > + if (!err && !is_swiotlb_active(NULL)) { > > err = pci_xen_swiotlb_init_late(); > > if (err) > > dev_err(&pdev->xdev->dev, "Could not setup SWIOTLB!\n"); > > diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h > > index 2a6cca07540b..c530c976d18b 100644 > > --- a/include/linux/swiotlb.h > > +++ b/include/linux/swiotlb.h > > @@ -123,7 +123,7 @@ static inline bool is_swiotlb_buffer(struct device *dev, phys_addr_t paddr) > > void __init swiotlb_exit(void); > > unsigned int swiotlb_max_segment(void); > > size_t swiotlb_max_mapping_size(struct device *dev); > > -bool is_swiotlb_active(void); > > +bool is_swiotlb_active(struct device *dev); > > void __init swiotlb_adjust_size(unsigned long size); > > #else > > #define swiotlb_force SWIOTLB_NO_FORCE > > @@ -143,7 +143,7 @@ static inline size_t swiotlb_max_mapping_size(struct device *dev) > > return SIZE_MAX; > > } > > > > -static inline bool is_swiotlb_active(void) > > +static inline bool is_swiotlb_active(struct device *dev) > > { > > return false; > > } > > diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c > > index 84c9feb5474a..7a88c34d0867 100644 > > --- a/kernel/dma/direct.c > > +++ b/kernel/dma/direct.c > > @@ -495,7 +495,7 @@ int dma_direct_supported(struct device *dev, u64 mask) > > size_t dma_direct_max_mapping_size(struct device *dev) > > { > > /* If SWIOTLB is active, use its maximum mapping size */ > > - if (is_swiotlb_active() && > > + if (is_swiotlb_active(dev) && > > (dma_addressing_limited(dev) || swiotlb_force == SWIOTLB_FORCE)) > > I wonder if it's worth trying to fold these other conditions into > is_swiotlb_active() itself? I'm not entirely sure what matters for Xen, > but for the other cases it seems like they probably only care about > whether bouncing may occur for their particular device or not (possibly > they want to be using dma_max_mapping_size() now anyway - TBH I'm > struggling to make sense of what the swiotlb_max_segment business is > supposed to mean). I think leaving those conditions outside of is_swiotlb_active() might help avoid confusion with is_dev_swiotlb_force() in patch #9? We need is_dev_swiotlb_force() only because the restricted DMA pool supports memory allocation, but the default swiotlb doesn't. > > Otherwise, patch #9 will need to touch here as well to make sure that > per-device forced bouncing is reflected correctly. You're right. Otherwise, is_dev_swiotlb_force is needed here. > > Robin. > > > return swiotlb_max_mapping_size(dev); > > return SIZE_MAX; > > diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c > > index ffbb8724e06c..1d221343f1c8 100644 > > --- a/kernel/dma/swiotlb.c > > +++ b/kernel/dma/swiotlb.c > > @@ -659,9 +659,9 @@ size_t swiotlb_max_mapping_size(struct device *dev) > > return ((size_t)IO_TLB_SIZE) * IO_TLB_SEGSIZE; > > } > > > > -bool is_swiotlb_active(void) > > +bool is_swiotlb_active(struct device *dev) > > { > > - return io_tlb_default_mem != NULL; > > + return get_io_tlb_mem(dev) != NULL; > > } > > EXPORT_SYMBOL_GPL(is_swiotlb_active); > > > >