From patchwork Tue Apr 20 08:27:46 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: 424558 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp206733jao; Tue, 20 Apr 2021 02:28:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxPph6mv0q0akq2TDnMCcDDiXdouNltX0Ql1+b5tIGEjmVl8hALsnxr/NXCy8V3VprllVB X-Received: by 2002:a50:9e4f:: with SMTP id z73mr9130049ede.338.1618910924795; Tue, 20 Apr 2021 02:28:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618910924; cv=none; d=google.com; s=arc-20160816; b=Wv0wJPyd295jS8yRrFD5gym/RJkNqS8dA92xUEG83DXG+YNl4UlMDQRCVUoWABu7Qt pj1CVd96FLdP+FkKRYO9ffucwVcL90mW0Vvzem0yLw24aNnOuWXeLe4iChsGIk5EE/Rv vtydT7T0otjuuhg6fA2F1CPtyg83+lWHjh1Lg29H1sw8vHFC+qKagvCdJ6hCUNdL9xba eDmyaD1ZiIxbLPWtRIOMeo+PaV/6D6zHn9KUURiNy/Y3V86BBsemATdrICJ14tlKDRsd 3mAZF9Cv12att0nZ77kgNuyA8s2A5iYmwNjv7lAM3Wu7igfufgDqnrJHEmzbto8d1+OM avNA== 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=TmkP27Pk+f8J0TllDrId8yr/vncTk4G5gISzN9VDrtM=; b=kP/f0M+wxRWnUuiL8vOeqkYKSjRNuZirRZjQ7aBkWDQs3InPXQMu9n8UWJMLgjyza7 PELH3Cw3UyE95FTr4/OA55qRTF3yQ16mL4iE2M1WGUtc7UoBlGeBnIsq2phz7QsuovOz HQQGVafy2WdoRNefym0+gv0FVnpTkkVFSbfn12+EhPaG7hjNZl3/JDQvhhmFCblbAmbq 2M3NSJnWQ2VjPUV0dfrziEQW9N9atBRy4xgpnb99BwpCiySj3BZOccBM+ig6TyP5j716 YOFh9j4XC+ry9JuXoCYvihc5n6RBf3Lfu5bRn90/ZSB4p1dz4z1NCtVKSW3q/8cVceAA NEDg== 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 i2si5177143edq.3.2021.04.20.02.28.44; Tue, 20 Apr 2021 02:28:44 -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 S229937AbhDTJ3O (ORCPT + 4 others); Tue, 20 Apr 2021 05:29:14 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:16484 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229494AbhDTJ3N (ORCPT ); Tue, 20 Apr 2021 05:29:13 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4FPdbc1ky7zrfYB; Tue, 20 Apr 2021 17:26:20 +0800 (CST) Received: from A2006125610.china.huawei.com (10.47.83.26) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.498.0; Tue, 20 Apr 2021 17:28:32 +0800 From: Shameer Kolothum To: , , CC: , , , , , , , , , Subject: [PATCH v3 05/10] iommu/arm-smmu-v3: Introduce strtab init helper Date: Tue, 20 Apr 2021 10:27:46 +0200 Message-ID: <20210420082751.1829-6-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20210420082751.1829-1-shameerali.kolothum.thodi@huawei.com> References: <20210420082751.1829-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.83.26] 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 | 26 ++++++++++++--------- 1 file changed, 15 insertions(+), 11 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 8594b4a83043..29da3b681621 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2347,6 +2347,19 @@ static bool arm_smmu_sid_in_range(struct arm_smmu_device *smmu, u32 sid) static struct iommu_ops arm_smmu_ops; +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 struct iommu_device *arm_smmu_probe_device(struct device *dev) { int i, ret; @@ -2375,21 +2388,12 @@ static struct iommu_device *arm_smmu_probe_device(struct device *dev) INIT_LIST_HEAD(&master->bonds); dev_iommu_priv_set(dev, master); - /* Check the SIDs are in range of the SMMU and our stream table */ for (i = 0; i < master->num_sids; i++) { u32 sid = master->sids[i]; - if (!arm_smmu_sid_in_range(smmu, sid)) { - ret = -ERANGE; + ret = arm_smmu_init_sid_strtab(smmu, sid); + if (ret) goto err_free_master; - } - - /* Ensure l2 strtab is initialised */ - if (smmu->features & ARM_SMMU_FEAT_2_LVL_STRTAB) { - ret = arm_smmu_init_l2_strtab(smmu, sid); - if (ret) - goto err_free_master; - } } master->ssid_bits = min(smmu->ssid_bits, fwspec->num_pasid_bits);