Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp251192pxv; Thu, 24 Jun 2021 07:12:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9isM9XGc2AjiNusiHiXdikbI7OEZxUZTaFh5xxLOHHrwklYkerAZwmsjdG9RZKL/lg88N X-Received: by 2002:a92:ce50:: with SMTP id a16mr3800109ilr.142.1624543922274; Thu, 24 Jun 2021 07:12:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624543922; cv=none; d=google.com; s=arc-20160816; b=TdHf2BbryrhCdxSCq6PGIUhS+W4bVumscb2M9FsE69l25BIzWNG/mFvL7ne160cKDf yAPKi7OHNfvePxPP7ZS8Uj3Znas+uwtJqyaxDMkZh4SxbqZcIBNPC5SZDQTNFVI7tGwE dO7pJhHoJ7tiyf0QnggTbcWYCJuVDDh6YHWrgaWRG5BPWIptcA5/jHF4EVfEBlFNUDEy 3/wWZzy0YJGC+NlY/Vh/RL9UVRyfQeBiJzaLuGVFnoJUufBFKZO0SusM6XGQCTs55P4n SpXHc7BkcFF2Mi/uGpMBWn97jiGHISiagvJ3J43yuH7DlzEFb7YsaIGrVUQOqhruDWmf nwzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=N/lPm7p1vvoiq3zKWKSQyewTju6BBsi/hvQi50Hj4tE=; b=uCgqiBKESFXVQKyFsAlA4Mnqzmrx69mxNofGWxneRDDiJ8Vy0+QOHpPUD9Qvy9xiC2 rOfurO3sMRadf1xyI9XXE+iTUZRJ2SheLZfHWaWYOkkAgdErKvZaZJAdWttFIGuM+Vvj lgQYD/LBQ2MqbgXJH8ZdhyS4Yksa9rCPLrimsk0RqJZ1rftcJMf5smelwS/QHTEim+jB fAkata6Y98SrizBqpcr6PnFJNnYhXFIIj7ebgca0qAexUicQPPotCthJV9H0beFhJaM6 TwIluBHXKKlvJem584i/icZfewY8j1SfQoqirrdawDSycrV/R3w/COQ8nw/hRg7qgyqf mB5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@quicinc.com header.s=qcdkim header.b=HPrafZwe; 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=fail (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t3si2704983iof.33.2021.06.24.07.11.48; Thu, 24 Jun 2021 07:12:02 -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=fail header.i=@quicinc.com header.s=qcdkim header.b=HPrafZwe; 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=fail (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231475AbhFXONS (ORCPT + 99 others); Thu, 24 Jun 2021 10:13:18 -0400 Received: from alexa-out-sd-02.qualcomm.com ([199.106.114.39]:7502 "EHLO alexa-out-sd-02.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229878AbhFXONS (ORCPT ); Thu, 24 Jun 2021 10:13:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1624543859; x=1656079859; h=subject:to:cc:references:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=jIPt55RUzMMbkq7vhbeD6czYPulB4Zz8LFVe0v3gRZ0=; b=HPrafZwejBwzC36jkSdbvaUBdQLBaQtfGa+xaiqEN//oDn9ae67TJgVg ZXIdONhObbr4ReCMTBBnx/aEivFxDvcYeamgta7UWJaQfTCDEDHFmdWLy xgRFgkPBIu9kR20CxGZsaLUNEcHr+WoXRoSVLx26W/JWJh1lnMehhlZ39 U=; Received: from unknown (HELO ironmsg04-sd.qualcomm.com) ([10.53.140.144]) by alexa-out-sd-02.qualcomm.com with ESMTP; 24 Jun 2021 07:10:59 -0700 X-QCInternal: smtphost Received: from nasanexm03e.na.qualcomm.com ([10.85.0.48]) by ironmsg04-sd.qualcomm.com with ESMTP/TLS/AES256-SHA; 24 Jun 2021 07:10:57 -0700 Received: from [10.111.163.161] (10.80.80.8) by nasanexm03e.na.qualcomm.com (10.85.0.48) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 24 Jun 2021 07:10:52 -0700 Subject: Re: [PATCH v14 06/12] swiotlb: Use is_swiotlb_force_bounce for swiotlb data bouncing To: Will Deacon , Robin Murphy CC: Claire Chang , Christoph Hellwig , Rob Herring , , Joerg Roedel , Frank Rowand , Konrad Rzeszutek Wilk , , , Marek Szyprowski , , , , , , , , , , , Jianxiong Gao , Stefano Stabellini , Saravana Kannan , , "Rafael J . Wysocki" , Bartosz Golaszewski , , , , Thierry Reding , , , linux-devicetree , Daniel Vetter , , , , , Nicolas Boichat , , Bjorn Helgaas , Dan Williams , Andy Shevchenko , Greg KH , Randy Dunlap , lkml , "list@263.net:IOMMU DRIVERS" , Jim Quinlan , Tom Lendacky , References: <20210619034043.199220-1-tientzu@chromium.org> <20210619034043.199220-7-tientzu@chromium.org> <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> From: Qian Cai Message-ID: <43ec9dd6-12c0-98ec-8d5d-b2904292721e@quicinc.com> Date: Thu, 24 Jun 2021 10:10:51 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210624114829.GB1382@willie-the-truck> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanexm03c.na.qualcomm.com (10.85.0.106) To nasanexm03e.na.qualcomm.com (10.85.0.48) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > > 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 && >