From patchwork Thu Aug 5 08:07:20 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: 492245 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp55466jap; Thu, 5 Aug 2021 01:09:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybLMarx3gWhpytH6YuMv7TuunPWOhiNKQJ0CdHSi2uqPxZ2BTQ/a8S7qa+QsQtAJ7s6ahq X-Received: by 2002:a17:907:2ce7:: with SMTP id hz7mr3550483ejc.35.1628150964980; Thu, 05 Aug 2021 01:09:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628150964; cv=none; d=google.com; s=arc-20160816; b=E5rvUZxaPQOXROceXrTwFQZIaEoxqTLY/vLyIWW1k0Wbpc62MG4+dpebdAxKwQ4UMw Qct1IoeH3aaCFi68bNUq8D8FbLy1E6BYivcRzpdX9lFCbYZyrNt9dCliOH2Gb/TUqKNe BS06RuAs+GUhw/fqkK0dKf2lZ/itUeg1oEJfM8Z6XBQtlLK7iKz4m4fpalJU2hT2FJk3 +26r75Fd4a1fnXdbayDrc6uvdCr6re0GGg94AvIIBf7apI0968eykqaRNWo1aQoZzROM smEdGNYNgUL/liD28dQHCP+cILmUAGFQ1ELo+u9hqjAF7G6Z09L1+0DAp0Wgze1L/bRV EY5Q== 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=TFlIXxrvyAFR10DoLE/xbj0hMm2KyFYC0fKgJPN6dv0=; b=UZBUIbDzB8jEfxHlOPkdVQUDIFxW9JfPlFze2T4pEejdpvCCDd3eM/TmFkFaPaZx+S WhJGHLpOpAwo31RK9JTCqlDf0Voh8YEQNQNCoYwwQIBoXMDWBFkZS/wXPsGs/quaXmvP gkuuk+EEXHZJp1nTVI1gfXV4hzLsNEUGJebu2lVVo4uF8t9q6tGlX5bv7Cl7vok8IpfC s6aR3e1K6WlpFmYwvzh1SovCFSd8m7rGOm/zdbxFVG4lwHT2ckgQ0QKFEa3clqky/mWJ 7r9wqvVk+hdkT3lGzJlnT9EI5Emm2oPvuOHFejX6qAa9fP9Tlte6fYcV7OO8ZVdkss0I RT7g== 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 g18si5224762ejp.458.2021.08.05.01.09.24; Thu, 05 Aug 2021 01:09:24 -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 S232893AbhHEIJh (ORCPT + 4 others); Thu, 5 Aug 2021 04:09:37 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]:3589 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233484AbhHEIJh (ORCPT ); Thu, 5 Aug 2021 04:09:37 -0400 Received: from fraeml738-chm.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4GgLq63Lqgz6GBpG; Thu, 5 Aug 2021 16:09:06 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by fraeml738-chm.china.huawei.com (10.206.15.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 5 Aug 2021 10:09:22 +0200 Received: from A2006125610.china.huawei.com (10.47.91.4) 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; Thu, 5 Aug 2021 09:09:14 +0100 From: Shameer Kolothum To: , , CC: , , , , , , , , , , , Subject: [PATCH v7 5/9] iommu/arm-smmu-v3: Introduce strtab init helper Date: Thu, 5 Aug 2021 09:07:20 +0100 Message-ID: <20210805080724.480-6-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20210805080724.480-1-shameerali.kolothum.thodi@huawei.com> References: <20210805080724.480-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.91.4] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) 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 235f9bdaeaf2..31940e53c675 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2518,6 +2518,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) { @@ -2541,20 +2554,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);