From patchwork Fri Jul 16 08:34:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 478370 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp1146508jao; Fri, 16 Jul 2021 01:35:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWkt8uBLkkWNPpjjm2uWmHT4dHNREraSx5ltRcTq4L1JyRJP6sl+E6PH5WNbgxC2GHfAPm X-Received: by 2002:a17:906:eb99:: with SMTP id mh25mr10579715ejb.330.1626424535149; Fri, 16 Jul 2021 01:35:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626424535; cv=none; d=google.com; s=arc-20160816; b=u+we9b2G8tvaFPRKmk7uu4XAZJW3WLH1wM1AmNVU2UXg4ZUtfCqb+UpMWv8bnviigx 37VER6ti+cWjl5C8JAIto4iyLhcccL/SzLgrsoE52LOQUsXiyVk+AF1gYBw3pkjLCmmM FVwQHgj4pHSjyMR3L7ZbRtGf/P9pVT4SVHjIBRUjaYi8Lxz1d5cWX59TlgTNTz7Vt8PF zo8QHbBez/UBSH+Amfau1SLOVswkJli9U80WBtVbgo+HA8RAqA+/7/1M7Od9t9pd0B3x rN0WpnZ7fVjmSfuKSwnhwTYFfNXR8R/lQqq/nG4og6zj9dZpr7rM1Mgq/SG3kLpF33zg O1vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=qSwcNL6dPkm5TC9PatEqttzSes7BMpC3qD9LDyrO9qs=; b=TCH6CsQiuIHjpDVxNSnoLHGaItOPNO6pA583brX24TvE9pl+6jKJfo32zL2PGSHZC5 XeajmZVSKkWu9Tgsf+S+fb3I3E+reWn+q0lowY9pONkNkBJND0KSdwfjZ0bKWXgalLvm OxqtiLCGlgHVRIInW3PPc4di0qzU2ivbxrStNIiyJBHwLz6o6bi+jLn83NNCXDnQlM3g RzYjLT0Tt120FDWv6kumZhqclsi25bVWh53wmc7XWfNcoq19H1r7MXjbmC5Bvnh4IJHn AKc4R+tfsJb7ahZGyenpPRbiWMPS1JE2DHJU7x7sVjeassvSEv+3iHy+GINg5A98oyY/ M/Yw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dd21si2610993edb.514.2021.07.16.01.35.34; Fri, 16 Jul 2021 01:35:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-acpi-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-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237240AbhGPIi2 (ORCPT + 4 others); Fri, 16 Jul 2021 04:38:28 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]:3422 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237055AbhGPIi2 (ORCPT ); Fri, 16 Jul 2021 04:38:28 -0400 Received: from fraeml707-chm.china.huawei.com (unknown [172.18.147.207]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4GR48x1PfNz6FDCj; Fri, 16 Jul 2021 16:26:57 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by fraeml707-chm.china.huawei.com (10.206.15.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Fri, 16 Jul 2021 10:35:32 +0200 Received: from A2006125610.china.huawei.com (10.47.80.222) by lhreml710-chm.china.huawei.com (10.201.108.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Fri, 16 Jul 2021 09:35:26 +0100 From: Shameer Kolothum To: , , CC: , , , , , , , , , , Subject: [PATCH v6 5/9] iommu/arm-smmu-v3: Introduce strtab init helper Date: Fri, 16 Jul 2021 09:34:38 +0100 Message-ID: <20210716083442.1708-6-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20210716083442.1708-1-shameerali.kolothum.thodi@huawei.com> References: <20210716083442.1708-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.80.222] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To lhreml710-chm.china.huawei.com (10.201.108.61) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Introduce a helper to check the sid range and to init the l2 strtab entries(bypass). This will be useful when we have to initialize the l2 strtab with bypass for RMR SIDs. Signed-off-by: Shameer Kolothum --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 28 +++++++++++---------- 1 file changed, 15 insertions(+), 13 deletions(-) -- 2.17.1 diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c index dd20b01771c4..33f5556aefeb 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2517,6 +2517,19 @@ static bool arm_smmu_sid_in_range(struct arm_smmu_device *smmu, u32 sid) return sid < limit; } +static int arm_smmu_init_sid_strtab(struct arm_smmu_device *smmu, u32 sid) +{ + /* Check the SIDs are in range of the SMMU and our stream table */ + if (!arm_smmu_sid_in_range(smmu, sid)) + return -ERANGE; + + /* Ensure l2 strtab is initialised */ + if (smmu->features & ARM_SMMU_FEAT_2_LVL_STRTAB) + return arm_smmu_init_l2_strtab(smmu, sid); + + return 0; +} + static int arm_smmu_insert_master(struct arm_smmu_device *smmu, struct arm_smmu_master *master) { @@ -2540,20 +2553,9 @@ static int arm_smmu_insert_master(struct arm_smmu_device *smmu, new_stream->id = sid; new_stream->master = master; - /* - * Check the SIDs are in range of the SMMU and our stream table - */ - if (!arm_smmu_sid_in_range(smmu, sid)) { - ret = -ERANGE; + ret = arm_smmu_init_sid_strtab(smmu, sid); + if (ret) break; - } - - /* Ensure l2 strtab is initialised */ - if (smmu->features & ARM_SMMU_FEAT_2_LVL_STRTAB) { - ret = arm_smmu_init_l2_strtab(smmu, sid); - if (ret) - break; - } /* Insert into SID tree */ new_node = &(smmu->streams.rb_node);