From patchwork Thu Aug 5 08:07:22 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: 492247 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp55698jap; Thu, 5 Aug 2021 01:09:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyz4jnuv/MJyNm3cCAT+QxYPeVT/PhGvbO+DOzepFsxz0cstDPWjD7r3Xj0Und/faFYsHAM X-Received: by 2002:a17:906:c08e:: with SMTP id f14mr3544967ejz.380.1628150984698; Thu, 05 Aug 2021 01:09:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628150984; cv=none; d=google.com; s=arc-20160816; b=Fk1zKUsfYDUPooKrUUyWb85MnW6fBEC53WmKly88E0ymjdMr8VZYiLGF0JLOSm+J2t swjrmLXBCioranph4aM3KqHt+Z/S6HLSPIUy4h+hvbgCU/a56jgojZ4eU+KyPErEhPyx EjzSdMc7uH50XQ/A/5RTHTv5ny4+iS0kCQRgwGvO/TdQQ2XawREl4NlSNaQUkRY7OO7Q KEX//dndvXp1oZTv6T2dwdcABHdK7rhfdyR1IbZppckZdsngUpG3q44D9uKZyqFDOCMN l2IUImGg2VrLDGDVdRk8nkEDpz0v2s4REVoy9fIpKsxtwmsH3MG7KnTwnyn8jDCdZ0/8 Zp9Q== 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=vmPoOQGyrGk1Cc+ceG1F3nkBz/lBXzH0CrZHu6Cd2nk=; b=YwEMxhoMOCUezFikga+XR4aeLv49OVlOz1/bBcWpijG9KUR7gaKOljzCG1XEFIiRYG N6IlBqTGiyozVjg6hUiTjcdstjxLAKY+BI9x4nSsxiGJUHF4buWs6mtpXN2WtfzYeqG+ 6K4/pwGD+u/6/78BrwedUmdaBxKTogRZqW0x5aSu3FxF/ytZZzhXO2Lhh7tvM+tmLgfF Qs8Z8JtPp1rRZ0IjKPqIHOuw+EZQpRpxzpnaJsSmGtgph6p4rNF7iBUcNCdtUkOAeF21 PQiDKUK65udIawXboFCymv2QYju8cW6iSiW7C7gZMD+aDAQDCeGDUhEGga/25m+sZ020 vc4A== 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.44; Thu, 05 Aug 2021 01:09:44 -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 S233484AbhHEIJ5 (ORCPT + 4 others); Thu, 5 Aug 2021 04:09:57 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]:3591 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235821AbhHEIJz (ORCPT ); Thu, 5 Aug 2021 04:09:55 -0400 Received: from fraeml737-chm.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4GgLqT3T2rz6F8Fl; Thu, 5 Aug 2021 16:09:25 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by fraeml737-chm.china.huawei.com (10.206.15.218) 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:40 +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:33 +0100 From: Shameer Kolothum To: , , CC: , , , , , , , , , , , Subject: [PATCH v7 7/9] iommu/arm-smmu-v3: Get associated RMR info and install bypass STE Date: Thu, 5 Aug 2021 09:07:22 +0100 Message-ID: <20210805080724.480-8-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 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 | 31 +++++++++++++++++++++ 1 file changed, 31 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 85f6f1925a36..1165605d6f7a 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -3760,6 +3760,34 @@ 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; + + 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 SID(0x%x) bypass failed\n", + sid); + continue; + } + + step = arm_smmu_get_step_for_sid(smmu, sid); + arm_smmu_init_bypass_stes(step, 1, true); + } + + iommu_dma_put_rmrs(dev_fwnode(smmu->dev), &rmr_list); +} + static int arm_smmu_device_probe(struct platform_device *pdev) { int irq, ret; @@ -3841,6 +3869,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)