From patchwork Thu May 13 13:45:48 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: 437333 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp345881jao; Thu, 13 May 2021 06:47:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4kzUoTWEdpIcjhuHBegzu/2X+mvcuJye1v1eQxuNWVpah0inFOX3rXWP47SUh4kLLvG4L X-Received: by 2002:a05:6e02:def:: with SMTP id m15mr36466735ilj.12.1620913638577; Thu, 13 May 2021 06:47:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620913638; cv=none; d=google.com; s=arc-20160816; b=zu1A/R0oAKJaFBIXhhnF5mSF5T4zmzHrUCyicTXBzIgdB/gof5JiNuc9waK+3Ub4Kp nucWZLlJeTbmLpt7VBv6m+UE1lPIb7gEUmSf/OH+VwQjdDfLrLmk5x1a0TOIr+xVhfP+ TyQza4Swx9lRaUCZFUseXabpI9sIhJVaU2wHSuCg51h9fhSm9R3RawiWQThAXbrZz7iC jVpiTym7jqX30Yh8DeSsHwf7j+TzMqj3LGORWeTu8Jgy7zdjBj/IKgX0d7AASUzBwA4E akC7AjtLbAfePqXm+EEamBQfqritz/+Pp2uq1Doc+hW/5dBjI7M1CW0XqerHwaxGXUm5 AWBQ== 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=HUs4bEs0y+tVO2fn4aNgkcaN6iDPbWkCUaMjNpHfvGU=; b=0ewN4VqonLzCMPBMxfmif5eZhyORVcJS5LtF2xuMvbjgW78qtXNfunZEFbDWtJblz0 mUgQ/BvNZLWeEQSeWtLALkIVApTyTjAt9BzlTQOJhmw2vZjwCl5nOX0hb8HrIRdsll2p CorXGEgfp7V7BKG4mG5cX+L1EnZCSyzkd9BNwd29MHcl5pnm8IzvTclqGsI35T2qGk2c Q87t2QNY2KSwP3OFrksICLvXnV1G6cfdDIjubNLfGDB1Y6IVLrC4tmF+KURbR2vOIpBi 1yKCi4/PYRDh12MtyzwWkRTUGQ0gIGuYqWNJgVzf0fLEpsy9CISR82a0u8602qwZkcOS WBEw== 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.47.18; Thu, 13 May 2021 06:47:18 -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 S234163AbhEMNs0 (ORCPT + 4 others); Thu, 13 May 2021 09:48:26 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:2478 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234168AbhEMNsQ (ORCPT ); Thu, 13 May 2021 09:48:16 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4FgtDk5dkhzBvBf; Thu, 13 May 2021 21:44:22 +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:54 +0800 From: Shameer Kolothum To: , , CC: , , , , , , , , , , Subject: [PATCH v4 6/8] iommu/arm-smmu-v3: Get associated RMR info and install bypass STE Date: Thu, 13 May 2021 14:45:48 +0100 Message-ID: <20210513134550.2117-7-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 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 | 33 +++++++++++++++++++++ 1 file changed, 33 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..c2d2e65b9856 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,36 @@ 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_rmr *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; + + ret = arm_smmu_init_sid_strtab(smmu, e->sid); + if (ret) { + dev_err(smmu->dev, "RMR bypass(0x%x) failed\n", + e->sid); + continue; + } + + step = arm_smmu_get_step_for_sid(smmu, e->sid); + arm_smmu_write_strtab_ent(NULL, e->sid, step, true); + } +} + static int arm_smmu_device_probe(struct platform_device *pdev) { int irq, ret; @@ -3657,6 +3687,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)