From patchwork Fri Jul 16 08:34:40 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: 478372 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp1146720jao; Fri, 16 Jul 2021 01:35:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzq1lH9TRXUI5v9jTPlSRUZqLiqeM1cd0X0wf6sjLL1Yxpq4XHQCnmClK4K2fVWDm4lje75 X-Received: by 2002:a50:ce51:: with SMTP id k17mr8577909edj.185.1626424551993; Fri, 16 Jul 2021 01:35:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626424551; cv=none; d=google.com; s=arc-20160816; b=fxKDXg3ieDmqwrlc1FtiaU9aoRFyN7CVz3XiqEl7u+rfzvhGBzPOLNzDZmXGAzx3+5 jPSKyvoe2JKEJezf0u3nVPuw6mSI87mtEeNQ+6vx/X4oPfNiXvKcmm0Ss+A/DCNfazLa 0mxGP+8fiCJbQB0S1gecuFDBCLlGVepv9r4NFo9NSXBpL+83x2yk2A3EoSvZZ5jAbWZz oECYpXMatyrhLWauHHnS4eLYNQycGCEMuHwvHhEfv7QP5iMlqGKdd+h1QTMWAwtX0hJG 6r9mrTVBb+1hWDCvHzS87WGIzmo6T7av28lq3OOFNaUCJIWR5kRF2SDz3sp7kZ5UiQOo ZaOQ== 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=SPa/MsIIqR3CNMdU7wlNoY0Yj1Aejk0gseQ+DqQaZ/c=; b=sVIAabwvhuzhmbPay2y9r6T7FU77GfDfcqJBekW5KCcEO5gsUhujMeYRmGjv3kzVs0 qX9DP98hL3CxQh0+6UOdIPFXvfFtPspda7LjWmcIJm+V1fSFPwKyb+/02KdrmRyaHy5B sfqTE0zqOdZUXtFtGmaTxpBJNEm+VUXdXbydJMjtwqT6Di1cQgrbPngdn/EOUkgT2ip+ e5frFIZA7hxF7oXw2SZRxxTTvHePRj+QP23ZVQ/nr2hVL4HADcP5ovQpzBHL3qwH9frP nJ4jNjgwE5N43klV6ug+xqsdlEOQR7psSkoWroiEPl8uPut517cebk+JNm+fMwJY23a2 JzTw== 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 dd21si2610993edb.514.2021.07.16.01.35.51; Fri, 16 Jul 2021 01:35:51 -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 S237577AbhGPIip (ORCPT + 4 others); Fri, 16 Jul 2021 04:38:45 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]:3424 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237055AbhGPIio (ORCPT ); Fri, 16 Jul 2021 04:38:44 -0400 Received: from fraeml706-chm.china.huawei.com (unknown [172.18.147.226]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4GR42N5bQqz6D8WS; Fri, 16 Jul 2021 16:21:16 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by fraeml706-chm.china.huawei.com (10.206.15.55) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Fri, 16 Jul 2021 10:35:48 +0200 Received: from A2006125610.china.huawei.com (10.47.80.222) 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; Fri, 16 Jul 2021 09:35:41 +0100 From: Shameer Kolothum To: , , CC: , , , , , , , , , , Subject: [PATCH v6 7/9] iommu/arm-smmu-v3: Get associated RMR info and install bypass STE Date: Fri, 16 Jul 2021 09:34:40 +0100 Message-ID: <20210716083442.1708-8-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20210716083442.1708-1-shameerali.kolothum.thodi@huawei.com> References: <20210716083442.1708-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.80.222] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) 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 34f84641dc6a..71a682fb375b 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -3759,6 +3759,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; @@ -3840,6 +3868,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)