Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1395628ybe; Mon, 2 Sep 2019 20:33:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqzbjDV+N8rQve3RqDgL84z4Epy7qc37iNXkohAMDtG4h8j0kMFgE8x21HOgd26kYfcxU65N X-Received: by 2002:a17:902:aa08:: with SMTP id be8mr33478350plb.144.1567481611235; Mon, 02 Sep 2019 20:33:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567481611; cv=none; d=google.com; s=arc-20160816; b=REkijM/4rDaSVhHfveAsAhZa+2Gvpj9v4G08wQaF5fAXW40o4JEL0M78ET8OHm4M2z 6FNnF+Pcl86v1c5soCWfSX63SO32wLx872b9Zkxt/SkOP6OaXuDAOn/GRdcOIRtTfSRk iNCBJyfV2QsUOE+3GPX6Hh+2gH+Xva/5tIR2c/nZbuaVW4hSz2QRwQ9RWTz0kmoMGlt/ mQK+A/l1r7SIoG8jkx/qNFkt5sc6khpNfL2tloe93huaHxghxEOEtf7i+53/zs8g3h+H Vercy/xHiIU1u1T31glEc2+bKQYudOpf1gZ5RI0xrIUSbKGn71wpvtL8WcyjdYNfrzTj E+ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:dkim-signature:mime-version:references :in-reply-to:message-id:date:subject:cc:from; bh=6vXneL5w/dKxNs1agMGvEAj0te9++B7Cg1CX1uMLfPU=; b=wyFEII1WqjJ/+8IwcPjChGcbDb4s6LCvooZ5SAYjQhxRg/jOX7bwdW8Wz4R8kl3wIA Pc2ws9e1BMxqwrxeat+9D6Eh2Em0x18qM5apq03D5sE1FunzBct8HqOdRN1jan3dcX2Y esq68sYmNMp8yuwg/m65fhLR0Hhqg8AXNXA+JRu0hetpwqK/wyoD1c4M9sPw6W6XCwFH XPODs+edntgPi5TOoBbVuzKQh5rJUpRqmXU7EjDv0h1EV+/HLP/DBRpJOiVuKZEa3h5Y 0mShx63HNJTvPNSdxnOiIXiPeiKXckUPY/uem0ZFw9c7REPSjl1fA5zDXHbDGPdG6zCy BDmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nvidia.com header.s=n1 header.b="Pnscg8e/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a15si15598379pfi.48.2019.09.02.20.33.15; Mon, 02 Sep 2019 20:33:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@nvidia.com header.s=n1 header.b="Pnscg8e/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726670AbfICDaq (ORCPT + 99 others); Mon, 2 Sep 2019 23:30:46 -0400 Received: from hqemgate16.nvidia.com ([216.228.121.65]:6088 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726450AbfICDag (ORCPT ); Mon, 2 Sep 2019 23:30:36 -0400 Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqemgate16.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Mon, 02 Sep 2019 20:30:36 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Mon, 02 Sep 2019 20:30:33 -0700 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Mon, 02 Sep 2019 20:30:33 -0700 Received: from HQMAIL110.nvidia.com (172.18.146.15) by HQMAIL105.nvidia.com (172.20.187.12) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 3 Sep 2019 03:30:33 +0000 Received: from HQMAIL107.nvidia.com (172.20.187.13) by hqmail110.nvidia.com (172.18.146.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 3 Sep 2019 03:30:33 +0000 Received: from hqnvemgw01.nvidia.com (172.20.150.20) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Tue, 3 Sep 2019 03:30:33 +0000 Received: from vdumpa-ubuntu.nvidia.com (Not Verified[172.17.173.140]) by hqnvemgw01.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Mon, 02 Sep 2019 20:30:33 -0700 From: Krishna Reddy CC: , , , , , , , , , , , , , , , , , Krishna Reddy Subject: [PATCH v2 1/7] iommu/arm-smmu: prepare arm_smmu_flush_ops for override Date: Mon, 2 Sep 2019 20:32:02 -0700 Message-ID: <1567481528-31163-2-git-send-email-vdumpa@nvidia.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1567481528-31163-1-git-send-email-vdumpa@nvidia.com> References: <1567481528-31163-1-git-send-email-vdumpa@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1567481436; bh=6vXneL5w/dKxNs1agMGvEAj0te9++B7Cg1CX1uMLfPU=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:X-NVConfidentiality:MIME-Version: Content-Type; b=Pnscg8e/1hjbDigLSdzhiEKpdQ0dYhv0rFU1IjA8SEtWE1FCRWkrgbsrvbeoxNfM9 t31dATyxHvH3CwedSkb073YdwHl0GrK1txBr5v9Fl4Kt709QGOMDS1kn7CUgpzG16a Wv65C4K+NmmfG/veIfsTDdBNGQN+Z/gxVtVqBJ95FPEWGWuHoDS1odXGJ7HCWmSWgI NajPgrPupw/mgcaCVxfegj+GnDK4tNwokOnWbGWaYx2xavWfUlT7ji8ufsEBvUEt/c 7rKRnu3qcQlw0axBgGT7BOOVXX1x3Ly7nAIyovJWlAsCfTxJyi70QLW3ffScAo2Sk9 6BDSNCbIs/MbA== To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Remove const keyword for arm_smmu_flush_ops in arm_smmu_domain and replace direct references to arm_smmu_tlb_sync* functions with arm_smmu_flush_ops->tlb_sync(). This is necessary for vendor specific implementations that need to override arm_smmu_flush_ops in part or full. Signed-off-by: Krishna Reddy --- drivers/iommu/arm-smmu.c | 16 ++++++++-------- drivers/iommu/arm-smmu.h | 4 +++- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index 5b93c79..16b5c54 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -52,9 +52,6 @@ */ #define QCOM_DUMMY_VAL -1 -#define TLB_LOOP_TIMEOUT 1000000 /* 1s! */ -#define TLB_SPIN_COUNT 10 - #define MSI_IOVA_BASE 0x8000000 #define MSI_IOVA_LENGTH 0x100000 @@ -290,6 +287,8 @@ static void arm_smmu_tlb_sync_vmid(void *cookie) static void arm_smmu_tlb_inv_context_s1(void *cookie) { struct arm_smmu_domain *smmu_domain = cookie; + const struct arm_smmu_flush_ops *ops = smmu_domain->flush_ops; + /* * The TLBI write may be relaxed, so ensure that PTEs cleared by the * current CPU are visible beforehand. @@ -297,18 +296,19 @@ static void arm_smmu_tlb_inv_context_s1(void *cookie) wmb(); arm_smmu_cb_write(smmu_domain->smmu, smmu_domain->cfg.cbndx, ARM_SMMU_CB_S1_TLBIASID, smmu_domain->cfg.asid); - arm_smmu_tlb_sync_context(cookie); + ops->tlb_sync(cookie); } static void arm_smmu_tlb_inv_context_s2(void *cookie) { struct arm_smmu_domain *smmu_domain = cookie; struct arm_smmu_device *smmu = smmu_domain->smmu; + const struct arm_smmu_flush_ops *ops = smmu_domain->flush_ops; /* See above */ wmb(); arm_smmu_gr0_write(smmu, ARM_SMMU_GR0_TLBIVMID, smmu_domain->cfg.vmid); - arm_smmu_tlb_sync_global(smmu); + ops->tlb_sync(cookie); } static void arm_smmu_tlb_inv_range_s1(unsigned long iova, size_t size, @@ -410,7 +410,7 @@ static void arm_smmu_tlb_add_page(struct iommu_iotlb_gather *gather, ops->tlb_inv_range(iova, granule, granule, true, cookie); } -static const struct arm_smmu_flush_ops arm_smmu_s1_tlb_ops = { +static struct arm_smmu_flush_ops arm_smmu_s1_tlb_ops = { .tlb = { .tlb_flush_all = arm_smmu_tlb_inv_context_s1, .tlb_flush_walk = arm_smmu_tlb_inv_walk, @@ -421,7 +421,7 @@ static const struct arm_smmu_flush_ops arm_smmu_s1_tlb_ops = { .tlb_sync = arm_smmu_tlb_sync_context, }; -static const struct arm_smmu_flush_ops arm_smmu_s2_tlb_ops_v2 = { +static struct arm_smmu_flush_ops arm_smmu_s2_tlb_ops_v2 = { .tlb = { .tlb_flush_all = arm_smmu_tlb_inv_context_s2, .tlb_flush_walk = arm_smmu_tlb_inv_walk, @@ -432,7 +432,7 @@ static const struct arm_smmu_flush_ops arm_smmu_s2_tlb_ops_v2 = { .tlb_sync = arm_smmu_tlb_sync_context, }; -static const struct arm_smmu_flush_ops arm_smmu_s2_tlb_ops_v1 = { +static struct arm_smmu_flush_ops arm_smmu_s2_tlb_ops_v1 = { .tlb = { .tlb_flush_all = arm_smmu_tlb_inv_context_s2, .tlb_flush_walk = arm_smmu_tlb_inv_walk, diff --git a/drivers/iommu/arm-smmu.h b/drivers/iommu/arm-smmu.h index b19b6ca..b2d6c7f 100644 --- a/drivers/iommu/arm-smmu.h +++ b/drivers/iommu/arm-smmu.h @@ -207,6 +207,8 @@ enum arm_smmu_cbar_type { /* Maximum number of context banks per SMMU */ #define ARM_SMMU_MAX_CBS 128 +#define TLB_LOOP_TIMEOUT 1000000 /* 1s! */ +#define TLB_SPIN_COUNT 10 /* Shared driver definitions */ enum arm_smmu_arch_version { @@ -314,7 +316,7 @@ struct arm_smmu_flush_ops { struct arm_smmu_domain { struct arm_smmu_device *smmu; struct io_pgtable_ops *pgtbl_ops; - const struct arm_smmu_flush_ops *flush_ops; + struct arm_smmu_flush_ops *flush_ops; struct arm_smmu_cfg cfg; enum arm_smmu_domain_stage stage; bool non_strict; -- 2.1.4