From patchwork Mon May 24 11:02:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 446438 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp3238367jac; Mon, 24 May 2021 04:04:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzWQB8/mDfZ5xCWjOfYzzeqQ+JUVhxLlwKxlhmVZFfIzZfDOxTDfcjuI2+ADRSnIVUlo3Vf X-Received: by 2002:a05:6e02:1b87:: with SMTP id h7mr15761467ili.185.1621854252686; Mon, 24 May 2021 04:04:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621854252; cv=none; d=google.com; s=arc-20160816; b=foVenYzZukUdqV9lVuWv40rtFdTzTeRDLY8p2NeF4rlTSB5sQdoXfzVhOMG8obsXy7 ADZNzhgf8TPO7szQDJCjySdA0jXOob/VLnXpssbWxNzETNs5QQuT5X394k2kLM0vkDSR xvdYjqBzu2ahG2ei4P4kGYz3dtsaH46OdVLqctV0adXfL0gKbKh/VPYZUREtoYLlmwUj ETD1iBVWjjyoRHKuvHURfBjl10fSvMj7QbZmqAdadMMhblRhdzH+++Qb3Ysn0mabdS8v jNWzXsp//NCSZ4+U4WjhuBi43sSmsFWJLFuDweKtq/HnmR/FKwybeZRjUUp+PAhjCXKD /4qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=LuI+MqMeih6DpacXu7GHfXHm8xq2oKYMFz/gawR+j2Y=; b=ueewXdSF24eH4Y0t4vHkmvSkilmYB+8hZ+71gqdUCjIUx+rvG8grRApcobgv2gObGD e4wr2KDPKX9SD7LZBFRZ2yUnkaMXEHOecSmuvmteHeR9OkrKxwdEhU/9xku6FCy6KlLL 1N3Vj1HD7/23XWV+WVAUWJenBzjsVdT6pXWLxcsssVKPuXx6KA1iO8xITgByhOCEr5RC Fz07LiQBMmC/SH42ximfFA6KlzFJG27B7cy5Y4nSHA6f4Pp1ZlhpN8obQycYg0uGwid+ 1TL2snIKPT5nH6er4wtiGmFTuZEZVeqzEmXfFHeiz7c2RrYrSngEpVIejneSEDV8WgX3 g4mQ== 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.04.12; Mon, 24 May 2021 04:04:12 -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 S232548AbhEXLFj (ORCPT + 4 others); Mon, 24 May 2021 07:05:39 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:5750 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232547AbhEXLFi (ORCPT ); Mon, 24 May 2021 07:05:38 -0400 Received: from dggems703-chm.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FpZ4f2rBbzmknN; Mon, 24 May 2021 19:00:34 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by dggems703-chm.china.huawei.com (10.3.19.180) 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:04:08 +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:59 +0100 From: Shameer Kolothum To: , , CC: , , , , , , , , , , Subject: [PATCH v5 6/8] iommu/arm-smmu-v3: Get associated RMR info and install Date: Mon, 24 May 2021 12:02:20 +0100 Message-ID: <20210524110222.2212-7-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 Check if there is any RMR info associated with the devices behind the SMMUv3 and if any, install bypass STEs for them. This is to keep any ongoing traffic associated with these devices alive when we enable/reset SMMUv3 during probe(). Signed-off-by: Shameer Kolothum --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 36 +++++++++++++++++++++ 1 file changed, 36 insertions(+) -- 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 f9195b740f48..be1563e06732 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -3574,6 +3574,39 @@ static void __iomem *arm_smmu_ioremap(struct device *dev, resource_size_t start, return devm_ioremap_resource(dev, &res); } +static void arm_smmu_rmr_install_bypass_ste(struct arm_smmu_device *smmu) +{ + struct list_head rmr_list; + struct iommu_resv_region *e; + int ret; + + INIT_LIST_HEAD(&rmr_list); + if (iommu_dma_get_rmrs(dev_fwnode(smmu->dev), &rmr_list)) + return; + + /* + * Since, we don't have a mechanism to differentiate the RMR + * SIDs that has an ongoing live stream, install bypass STEs + * for all the reported ones.  + */ + list_for_each_entry(e, &rmr_list, list) { + __le64 *step; + u32 sid = e->fw_data.rmr.sid; + + ret = arm_smmu_init_sid_strtab(smmu, sid); + if (ret) { + dev_err(smmu->dev, "RMR bypass(0x%x) failed\n", + sid); + continue; + } + + step = arm_smmu_get_step_for_sid(smmu, sid); + arm_smmu_write_strtab_ent(NULL, sid, step, true); + } + + iommu_dma_put_rmrs(dev_fwnode(smmu->dev), &rmr_list); +} + static int arm_smmu_device_probe(struct platform_device *pdev) { int irq, ret; @@ -3657,6 +3690,9 @@ static int arm_smmu_device_probe(struct platform_device *pdev) /* Record our private device structure */ platform_set_drvdata(pdev, smmu); + /* Check for RMRs and install bypass STEs if any */ + arm_smmu_rmr_install_bypass_ste(smmu); + /* Reset the device */ ret = arm_smmu_device_reset(smmu, bypass); if (ret)