From patchwork Mon May 24 11:02:18 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: 446435 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp3238031jac; Mon, 24 May 2021 04:03:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQtWH09m28yMUjj67a9JpjiYt2t3ZeXh/poMDXd5Y+SWweTjqXXEdtVPpMN32VNrkBXAqb X-Received: by 2002:a92:ca0e:: with SMTP id j14mr13427325ils.271.1621854232020; Mon, 24 May 2021 04:03:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621854232; cv=none; d=google.com; s=arc-20160816; b=sn55pMQoeDIXYBvOogIAMSSRV5KEeNA1AkoniIBa+kXuW4Xb729b8oLttrDJ5nN+RQ C38BiAFgwIVtfOJu6amYp8tjnneIQyW/UVU+h5x/ahHdWidqbNcv8nZYIrXGSF8rcfvJ 3mV5yF6OPn9OICR/I5MvUV342iHg2c88tb/auvPnin75pM/W4aHjcovjlOALQIw3wnhQ gKIKMdx6JkCsuf88Wzqi4qUcgtSO6kL4cAMeq/52tOr385t/nmx1SU3LHFVe9sUOglNc Z2NVqODvRteJbWfFUEAeAAQq9svYXYso6hoCFgUcSmSvnXalRNZb3qHNaCi9LlVCJcKj yojw== 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=cgZpEyoKrzBJpPJaOIScjUvR5b91ohFDfmYnYin62cA=; b=m3jYrTB5Nf+XxVCEX/P8zmj91hwF/O6yuSK62GrlMxKU6Q7ADv/B/qnRYrXr7bIRbo sHe7ZysKV5CLw5gmi/prcbDuw5B/KVOr88igsiC1woxK1h41QpYardMuOOH2pWKyVaNI 7UpNg9Bez/U7RvwpWXh4G3p9FfF8hUKexnm3Zad/SDXsTJSukZemhw3e/eKjpfBBphe/ uCMOhZDJVPWKt1F5Fru+RlZXsZQ8ULMz6tNJXvlA0Uju4DAvUuMUtKLg4VDy9HkRvCSH f/P8RUtf5S+zZW6bpQniU4Da37kkuPYWrLHbQgbvnzdjvCKl8xSRCWjmB9oNs8R0atz4 hFAA== 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 f14si12766626ilj.120.2021.05.24.04.03.51; Mon, 24 May 2021 04:03:52 -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 S232666AbhEXLFS (ORCPT + 4 others); Mon, 24 May 2021 07:05:18 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:3924 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232661AbhEXLFR (ORCPT ); Mon, 24 May 2021 07:05:17 -0400 Received: from dggems701-chm.china.huawei.com (unknown [172.30.72.60]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4FpZ555vJnzCx6J; Mon, 24 May 2021 19:00:57 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by dggems701-chm.china.huawei.com (10.3.19.178) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 24 May 2021 19:03:47 +0800 Received: from A2006125610.china.huawei.com (10.47.80.77) 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; Mon, 24 May 2021 12:03:38 +0100 From: Shameer Kolothum To: , , CC: , , , , , , , , , , Subject: [PATCH v5 4/8] iommu/arm-smmu-v3: Introduce strtab init helper Date: Mon, 24 May 2021 12:02:18 +0100 Message-ID: <20210524110222.2212-5-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20210524110222.2212-1-shameerali.kolothum.thodi@huawei.com> References: <20210524110222.2212-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.80.77] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) 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 54b2f27b81d4..754bad6092c1 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2369,6 +2369,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) { @@ -2392,20 +2405,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);