Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp4569802pxt; Wed, 11 Aug 2021 08:55:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyr8J6DDM3Rpwfea5abdW1DUCLe/LByywL6WqoJT/SxJ711hfDd3IAVqW5JcG6ZPWkqRGoG X-Received: by 2002:a5d:9d9a:: with SMTP id ay26mr73794iob.41.1628697335141; Wed, 11 Aug 2021 08:55:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628697335; cv=none; d=google.com; s=arc-20160816; b=Ya1Kn0Xf5529cE3gvFgFaJmdqsmBX2SsQrHXrluhUu/nuqkdx7hHB4zLpHeYRyAtRJ FbETR05FnFmv+gWKJUmo6pud6BD/b63F1H5A9d/I9y2qu7WWblanOI4glAqrtDFZ8MzK 6CQUvtiJqYlpEJXrhV0Wvd6GfMBsT1+xQFmzDu39mliD0Cj+m+R8EhP67xnh4cB7Wf69 nl9nZviFl+Sa2zjzDuvRW+rMfnZeJcKLChVafXCx8trXZ+OOM31Nfvi5ifUKZB9o6SR8 uUrsIhu/9LuMcEl/AOHw0J0+7FZCupYTYoOpRsQ828Phr1TPaunzXnSHdC7cGSRnnDkv 4l0g== 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; bh=CXOPtg1yekCinMgnRczkhreBuDO+hMzz4zHQyj4jIqA=; b=RCxUEdSAODwPh2YrAGGWKyayVSkRre+8k6IBXnxlWZ2pVmJ8EkpoiMCSmRltHhcfPj yhshmP1AbdTSxVEZBDg7UMABEn8N/+wL/nLbMlZCDF/CFMNTlvyU503nlm2Nx5wzh25T EGE1MRI6PvD/8HPOd+gnTsDLgWF3o6fGB+iNvY+luStkBfL6yiK8g64heKFZrisePwRv l+4WLb4wZy9k5P0cgK2sfPneFJk2rUg1f2aRyV/5rrHX4uefP/3JUebn1TYs2WhNHLK1 +q7kW0f80L1xZP/9qHdO7OoIh8OhF7+W0J2Hj4Tysp36AajO/jTfOArMrSMPDPhMvd0k m5FA== ARC-Authentication-Results: i=1; mx.google.com; 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=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j1si26699977jak.102.2021.08.11.08.55.21; Wed, 11 Aug 2021 08:55:35 -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; 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=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233703AbhHKPyq (ORCPT + 99 others); Wed, 11 Aug 2021 11:54:46 -0400 Received: from foss.arm.com ([217.140.110.172]:53514 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232847AbhHKPxw (ORCPT ); Wed, 11 Aug 2021 11:53:52 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CCA36106F; Wed, 11 Aug 2021 08:53:28 -0700 (PDT) Received: from [10.57.36.146] (unknown [10.57.36.146]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 00EEA3F718; Wed, 11 Aug 2021 08:53:26 -0700 (PDT) Subject: Re: [PATCHv4] iommu/arm-smmu: Optimize ->tlb_flush_walk() for qcom implementation To: Will Deacon , Sai Prakash Ranjan Cc: Joerg Roedel , iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Doug Anderson , Krishna Reddy , Thierry Reding , Tomasz Figa , Bjorn Andersson References: <20210811060725.25221-1-saiprakash.ranjan@codeaurora.org> <20210811103011.GD4426@willie-the-truck> From: Robin Murphy Message-ID: <7be65300-632a-8626-e5da-13bc9e276763@arm.com> Date: Wed, 11 Aug 2021 16:53:25 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <20210811103011.GD4426@willie-the-truck> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-08-11 11:30, Will Deacon wrote: > On Wed, Aug 11, 2021 at 11:37:25AM +0530, Sai Prakash Ranjan wrote: >> diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c >> index f7da8953afbe..3904b598e0f9 100644 >> --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c >> +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c >> @@ -327,9 +327,16 @@ static void arm_smmu_tlb_inv_range_s2(unsigned long iova, size_t size, >> static void arm_smmu_tlb_inv_walk_s1(unsigned long iova, size_t size, >> size_t granule, void *cookie) >> { >> - arm_smmu_tlb_inv_range_s1(iova, size, granule, cookie, >> - ARM_SMMU_CB_S1_TLBIVA); >> - arm_smmu_tlb_sync_context(cookie); >> + struct arm_smmu_domain *smmu_domain = cookie; >> + struct arm_smmu_cfg *cfg = &smmu_domain->cfg; >> + >> + if (cfg->flush_walk_prefer_tlbiasid) { >> + arm_smmu_tlb_inv_context_s1(cookie); > > Hmm, this introduces an unconditional wmb() if tlbiasid is preferred. I > think that should be predicated on ARM_SMMU_FEAT_COHERENT_WALK like it is > for the by-VA ops. Worth doing as a separate patch. > >> + } else { >> + arm_smmu_tlb_inv_range_s1(iova, size, granule, cookie, >> + ARM_SMMU_CB_S1_TLBIVA); >> + arm_smmu_tlb_sync_context(cookie); >> + } >> } >> >> static void arm_smmu_tlb_add_page_s1(struct iommu_iotlb_gather *gather, >> @@ -765,8 +772,10 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain, >> .iommu_dev = smmu->dev, >> }; >> >> - if (!iommu_get_dma_strict(domain)) >> + if (!iommu_get_dma_strict(domain)) { >> pgtbl_cfg.quirks |= IO_PGTABLE_QUIRK_NON_STRICT; >> + cfg->flush_walk_prefer_tlbiasid = true; > > This is going to interact badly with Robin's series to allow dynamic > transition to non-strict mode, as we don't have a mechanism to switch > over to the by-ASID behaviour. Yes, it should _work_, but it's ugly having > different TLBI behaviour just because of the how the domain became > non-strict. > > Robin -- I think this originated from your idea at [1]. Any idea how to make > it work with your other series, or shall we drop this part for now and leave > the TLB invalidation behaviour the same for now? Yeah, I'd say drop it - I'm currently half an hour into a first attempt at removing io_pgtable_tlb_flush_walk() entirely, which would make it moot for non-strict anyway. Robin.