From patchwork Thu May 13 13:45: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: 437330 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp345499jao; Thu, 13 May 2021 06:46:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycciX4FeaXPhLA/m3UYmbYSuFuTrKnIQ+FBFPGkiisizaMcmXJcjbL4s8BXA8sYfPbj4x4 X-Received: by 2002:a5d:87c4:: with SMTP id q4mr29137541ios.141.1620913612173; Thu, 13 May 2021 06:46:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620913612; cv=none; d=google.com; s=arc-20160816; b=m4jJMnJOeTOqJd67VWWCneTp3KnTTtnPUdgFl4UJHkNO5zWS7eP5N1yRH6qWklFjad 48XOHkwJL5E6czu6Jp6QrI4hMhPaaJV4+Zmej9CZHakalGRqNmi9HX2fL5y+ktvzkmjY 7Y4fkRTKhPY5TUVDsRMnud/dhTMLC0eXnjVxFO/Pz3HNQQoHar5ZppPtL8xvSZc78rQo ztHx4aoqed5bwiDTs9fiTB1IXq4ha2WBS+OvA6/RAm4do5nglyaVnr8Cy1RI3J8ymskN hdVOcgyUP+/d6EhGAR/Lc+0nvFGX0bFas7UJecvZKdLLtsR0Ab+Hcgd4YbL+MYsNcg1t R/oA== 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=M1sNWRMFYwiq8WEv5Rax6XCvPR0lWJWJ9Dj2hUcE8jTY47962DYJmlfp6/8I7lG+6T 3UUL88DgKL9Tpgc0CJBnZN0/iNfOL/HPIjz7plD5KMA05s1I+NMMWcKTi2HbjQzhUmF7 2xl2cdxBAHnpG0YjqUY/tDyt3qo3RB9YCOwl3XAwy817+GN412mCPxnosHYhFtR8ijsm rjbn81Hiw6U1KtMS+i69khHG5P4aWMqHYIiDsVNjGSDkhpni+SCG/tEYRTwG/MOvdYvI O6LnabrvERxfhrELkFBboNF8UsAfyq/MFtSl5h/5+D9k3QJszFE2dTilVB3t+OXhUWOZ sJDA== 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 u10si3346494ilv.5.2021.05.13.06.46.52; Thu, 13 May 2021 06:46: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 S234024AbhEMNsA (ORCPT + 4 others); Thu, 13 May 2021 09:48:00 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:2592 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231159AbhEMNr7 (ORCPT ); Thu, 13 May 2021 09:47:59 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4FgtDS1vrVzsRJ1; Thu, 13 May 2021 21:44:08 +0800 (CST) Received: from A2006125610.china.huawei.com (10.47.81.63) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.498.0; Thu, 13 May 2021 21:46:40 +0800 From: Shameer Kolothum To: , , CC: , , , , , , , , , , Subject: [PATCH v4 4/8] iommu/arm-smmu-v3: Introduce strtab init helper Date: Thu, 13 May 2021 14:45:46 +0100 Message-ID: <20210513134550.2117-5-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20210513134550.2117-1-shameerali.kolothum.thodi@huawei.com> References: <20210513134550.2117-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.81.63] 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);