Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp345671pxv; Thu, 24 Jun 2021 09:09:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+OwLfbLQqGDp2Ir9CFPEn9VYcpDyLSxELFFWBANmpN6GGlnysn8DmNBJbyY0wdRsOWB5E X-Received: by 2002:a17:906:f847:: with SMTP id ks7mr6112507ejb.338.1624550961598; Thu, 24 Jun 2021 09:09:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624550961; cv=none; d=google.com; s=arc-20160816; b=Ger/YKuuQe71vzczGcYUKlIg6T7RucHrGkjV04CcHAoG3/cQXRIkwJJvK2+T3e0M+O hqmcUOw6Vzou1vJ3bbcfIxVL/IltnR+r6ycoiAkMO2kBHZvnG4UJRHl5vEwlHuDgEQvh 3ro+XXgRG6srh67yD9F3fI4/fn/B5j4+EkhYCae4FV3cwDtZHWng/sdYBuQ1xASd3V0Z QaxCLsZdCShqvOem7kpttqbzYO6yJKVR7AJsxoj9/Hx80UcyYJSlSmKETZk1lJMU8n8U roKzd7Og/xKJv4KPcJZJo8vpjlCmm5/Q6001txoCFS7p9419nzkBbsWywcQ75K8Zjfar 2oNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=OUC0E76X92PmzUvBM3M58z5qjgzPKxJvrlMYIlH3t/A=; b=uaP/MKZxp6NuwFq3HPhcjGYubLTKrYUyXAJ5DrPhXpBcuAEVaxVLOrtoiYgkwrGO5Y vuh3y2fdKU+IADhuZVqd4KKabq1DtaLhTUjQXMdp+jK7cRGmBPGskvmTOLESIrm/7d5n SShl8gBtC5lCpsUj/aBCAlezaCrZpM/4csjF2DHwL3Krwe3cwD1E/h3tNdGMdTuxhIEk gURiDsr2Sy1GVs2va7XOBvkqzfjHMREc3M0TrtiihQ3QH80+yM8ImHYp3QZYUjcrGx9P 3jUh/ZEviJMqVQYM5C8CtSLatx1gO9s6Rt7wZ6KviL0eDDlebjzZB673eH4QO+RXqZWS OrHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=V1DUMk4p; 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 hw7si3179218ejc.405.2021.06.24.09.08.54; Thu, 24 Jun 2021 09:09:21 -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=V1DUMk4p; 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 S229928AbhFXQHY (ORCPT + 99 others); Thu, 24 Jun 2021 12:07:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229464AbhFXQHX (ORCPT ); Thu, 24 Jun 2021 12:07:23 -0400 Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C13BC061574 for ; Thu, 24 Jun 2021 09:05:03 -0700 (PDT) Received: by mail-il1-x12e.google.com with SMTP id i17so6837149ilj.11 for ; Thu, 24 Jun 2021 09:05: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=OUC0E76X92PmzUvBM3M58z5qjgzPKxJvrlMYIlH3t/A=; b=V1DUMk4pWXUrJHEg/9Kd4ukoLxbJGeXfb8ZAhSFnF6RVbF8t2Z5J1ymG4niuoHNq4v lR13PRE87YP1jrN3LaPEaViS+9EA9qGG/k81iCPvzgmr34ySIt4SvvmFKyoWhdSPE98X KaxkIr3Pk6gTC5BkELMIeQJS2sWcVoDywrhkk= 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=OUC0E76X92PmzUvBM3M58z5qjgzPKxJvrlMYIlH3t/A=; b=Oqk3RcwaOTe4KtILURGnh/RYma1GYYRfewUww9dBxDO8bs6UEPuoKwW7r19NhFxq0M CG+j5XSz4ySDvADV1dmbgCmp0zjnalRkupHat12HoXxhZ6edDGT88nBqDevNbaw29OVB OjY+fq+uCxcmNU59we8cJmQa9C5hrv9D5zFdzcHVdw3mQaoxdgV/mLl9+PJiLFf8LI0W 8SG1tIPg+4elKtaAmSJdU0ZW74lPSsYjmUUtqgCZaFqahAlCgQg7HGGy8mmpeErVsWEB IV+imPZq8KdOtdqiVP74ATuH2RpC+gl/E59f40WXKRQzdngYY1Z+E0NzCa15NRnWn/he FEzw== X-Gm-Message-State: AOAM531zHOeR7NZfzENqltsKCT0wagSRWN3b0+oR2C5ye2mpG/biz8q/ AYc1en62njExmX3mynN4rKq1efZDrOpnvw== X-Received: by 2002:a92:dc48:: with SMTP id x8mr4266050ilq.213.1624550702567; Thu, 24 Jun 2021 09:05:02 -0700 (PDT) Received: from mail-il1-f179.google.com (mail-il1-f179.google.com. [209.85.166.179]) by smtp.gmail.com with ESMTPSA id g4sm2062784ilk.37.2021.06.24.09.05.02 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 24 Jun 2021 09:05:02 -0700 (PDT) Received: by mail-il1-f179.google.com with SMTP id h3so6843003ilc.9 for ; Thu, 24 Jun 2021 09:05:02 -0700 (PDT) X-Received: by 2002:a92:9509:: with SMTP id y9mr4122371ilh.18.1624550347935; Thu, 24 Jun 2021 08:59:07 -0700 (PDT) MIME-Version: 1.0 References: <76c3343d-72e5-9df3-8924-5474ee698ef4@quicinc.com> <20210623183736.GA472@willie-the-truck> <19d4c7a2-744d-21e0-289c-a576e1f0e6f3@quicinc.com> <20210624054315.GA25381@lst.de> <364e6715-eafd-fc4a-e0af-ce2a042756b4@arm.com> <20210624111855.GA1382@willie-the-truck> <452155d2-c98e-23f6-86d6-3a2ff2e74783@arm.com> <20210624114829.GB1382@willie-the-truck> <43ec9dd6-12c0-98ec-8d5d-b2904292721e@quicinc.com> In-Reply-To: From: Claire Chang Date: Thu, 24 Jun 2021 23:58:57 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v14 06/12] swiotlb: Use is_swiotlb_force_bounce for swiotlb data bouncing To: Konrad Rzeszutek Wilk Cc: Qian Cai , Will Deacon , Robin Murphy , Christoph Hellwig , Rob Herring , mpe@ellerman.id.au, Joerg Roedel , Frank Rowand , boris.ostrovsky@oracle.com, jgross@suse.com, Marek Szyprowski , 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, chris@chris-wilson.co.uk, grant.likely@arm.com, paulus@samba.org, mingo@kernel.org, Jianxiong Gao , Stefano Stabellini , Saravana Kannan , xypron.glpk@gmx.de, "Rafael J . Wysocki" , 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 , Daniel Vetter , airlied@linux.ie, maarten.lankhorst@linux.intel.com, linuxppc-dev@lists.ozlabs.org, jani.nikula@linux.intel.com, Nicolas Boichat , rodrigo.vivi@intel.com, Bjorn Helgaas , Dan Williams , Andy Shevchenko , Greg KH , Randy Dunlap , lkml , "list@263.net:IOMMU DRIVERS" , Jim Quinlan , Tom Lendacky , bauerman@linux.ibm.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 24, 2021 at 11:56 PM Konrad Rzeszutek Wilk wrote: > > On Thu, Jun 24, 2021 at 10:10:51AM -0400, Qian Cai wrote: > > > > > > On 6/24/2021 7:48 AM, Will Deacon wrote: > > > Ok, diff below which attempts to tackle the offset issue I mentioned as > > > well. Qian Cai -- please can you try with these changes? > > > > This works fine. > > Cool. Let me squash this patch in #6 and rebase the rest of them. > > Claire, could you check the devel/for-linus-5.14 say by end of today to > double check that I didn't mess anything up please? I just submitted v15 here (https://lore.kernel.org/patchwork/cover/1451322/) in case it's helpful. I'll double check of course. Thanks for the efforts! > > Will, > > Thank you for generating the fix! I am going to run it on x86 and Xen > to make sure all is good (granted last time I ran devel/for-linus-5.14 > on that setup I didn't see any errors so I need to double check > I didn't do something silly like run a wrong kernel). > > > > > > > > > > Will > > > > > > --->8 > > > > > > diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h > > > index 175b6c113ed8..39284ff2a6cd 100644 > > > --- a/include/linux/swiotlb.h > > > +++ b/include/linux/swiotlb.h > > > @@ -116,7 +116,9 @@ static inline bool is_swiotlb_buffer(struct device *dev, phys_addr_t paddr) > > > > > > static inline bool is_swiotlb_force_bounce(struct device *dev) > > > { > > > - return dev->dma_io_tlb_mem->force_bounce; > > > + struct io_tlb_mem *mem = dev->dma_io_tlb_mem; > > > + > > > + return mem && mem->force_bounce; > > > } > > > > > > void __init swiotlb_exit(void); > > > diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c > > > index 44be8258e27b..0ffbaae9fba2 100644 > > > --- a/kernel/dma/swiotlb.c > > > +++ b/kernel/dma/swiotlb.c > > > @@ -449,6 +449,7 @@ static int swiotlb_find_slots(struct device *dev, phys_addr_t orig_addr, > > > dma_get_min_align_mask(dev) & ~(IO_TLB_SIZE - 1); > > > unsigned int nslots = nr_slots(alloc_size), stride; > > > unsigned int index, wrap, count = 0, i; > > > + unsigned int offset = swiotlb_align_offset(dev, orig_addr); > > > unsigned long flags; > > > > > > BUG_ON(!nslots); > > > @@ -497,7 +498,7 @@ static int swiotlb_find_slots(struct device *dev, phys_addr_t orig_addr, > > > for (i = index; i < index + nslots; i++) { > > > mem->slots[i].list = 0; > > > mem->slots[i].alloc_size = > > > - alloc_size - ((i - index) << IO_TLB_SHIFT); > > > + alloc_size - (offset + ((i - index) << IO_TLB_SHIFT)); > > > } > > > for (i = index - 1; > > > io_tlb_offset(i) != IO_TLB_SEGSIZE - 1 && > > >