From patchwork Thu Nov 19 12:11:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 328404 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:5ce:0:0:0:0 with SMTP id l14csp361507ils; Thu, 19 Nov 2020 04:13:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJwbMWOPoTw59lCyb6WR+QS2GRiOgWmAz2Q+KuFPyeOe/QEyVP6oCpulGxHxCmJoOreg6e4c X-Received: by 2002:a50:e087:: with SMTP id f7mr18510353edl.29.1605788033061; Thu, 19 Nov 2020 04:13:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605788033; cv=none; d=google.com; s=arc-20160816; b=k7pFqDKIpQxTFxJ5J24olfF7Kz4zD7hA8QptoIvd99iLVCoSs4D/O7DxM8UFSRGB2Z JrHPI4RKnF31gCvDgiO5IGTEaTc2bqpALkb5cirsef7N0qr31+HBaiwuHZbrILqNO/yt 8RhqP5KKWGvyQfCZwB12PKQ1/83iU0fVvrLjgBQq3yc+aDV/M5Q2c6CUyyrGvxlbWv22 fmLS/YK/Zh/1Q4ZUeyoWkxfF8zRcRQiWFZibdEMJqcbBqmBNvshtXmcLrtn/PpqBQ2Ki XSxz/LdFr6FetpKTuViJSiePDzGDoR6fKQjG8UWwmTO0eDkF+fgGkHWXPre9wLqBhsT2 4M1w== 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=zl/vCtXOkCvt9VfU0xd8fDTnwPyF4m65kHlVlA/lnyA=; b=Q9CHwGaDYSqqMG0eRpBE8TD4kUUQcdxXEj3wvmGTAtWa6Ug0Vc2d8SxvL7egdPT3c2 oECC5kJLBb5irp+tkNK9a7FTJWDpvD5iFlV8EJpw2GuNAGTyCz03iHL27nwoLBEgjQlT RRgznVH0ys6qIq5L5IPbhJKwX/s1bN4zV7ii0GEGFgS7FIgA1Bkbsp7eAS1X9h3R09Lt /Zvk8z+wXIdspAi3GsfJlRGPVcLDTlg54YiCaf/FwbFhz2+sDDdQs033tsBFo/j7AQTM Mv2LlxV9wf1OKCfQLIB9F/5XitRa30Ew6hEWmt/auzP6+g63u5BKtjHiOXzJOfGVMBOr KKAg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qc4si16705640ejb.188.2020.11.19.04.13.52; Thu, 19 Nov 2020 04:13:53 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727254AbgKSMM6 (ORCPT + 5 others); Thu, 19 Nov 2020 07:12:58 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:8372 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727058AbgKSMM6 (ORCPT ); Thu, 19 Nov 2020 07:12:58 -0500 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4CcJTj099Vz709F; Thu, 19 Nov 2020 20:12:41 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.210.168.73) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.487.0; Thu, 19 Nov 2020 20:12:49 +0800 From: Shameer Kolothum To: , , , CC: , , , , , , , , Subject: [RFC PATCH v2 5/8] iommu/arm-smmu-v3: Introduce strtab init helper Date: Thu, 19 Nov 2020 12:11:47 +0000 Message-ID: <20201119121150.3316-6-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20201119121150.3316-1-shameerali.kolothum.thodi@huawei.com> References: <20201119121150.3316-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.210.168.73] 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 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 e634bbe60573..1953b317d814 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2308,6 +2308,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; @@ -2336,21 +2349,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);