From patchwork Thu Aug 5 08:07:23 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: 492248 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp55766jap; Thu, 5 Aug 2021 01:09:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3+K/CuayJnE6n9YFAZCbZ167NO1OZ37/6FQKLASnzubL1jyQiwDioDvOlTQzaSMxhzKYN X-Received: by 2002:a17:906:6cb:: with SMTP id v11mr3587194ejb.482.1628150991893; Thu, 05 Aug 2021 01:09:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628150991; cv=none; d=google.com; s=arc-20160816; b=dhOzamIIm9o25Pf6DaBfrM1fZt6B/20+Mra6Cbhsagikcbje9jWOseErT/A9P/0XgQ dJ6+AxhxQDSZkthY+6fBvl6H0X6DtHqXqvj+tDdDj4IjuXBOGYeT9xJJIEyKoOeilAff r9rBAn/sF9/bPSMaD0Ih7WDrc+Ovb8dYdWOmlOzQXbgR383zXEC5JposT33ZINY+bQFF BvL9Jh6EQ8uqdMPG7uXgjA6Lm2O/x48Oah2VzTMKkM0noNpIOOCwZbITm3bcntHaHe85 xzdY1KotaBCgu8dT1jTjuQGF/wvie4LGWOghZzHnbyr0LXoYz13iiGEVrjUWj+CWTohP 67tA== 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=vVT//bqXaoGRfIUkJDp5nc9oPbpfPEZIwFnwMjD93ic=; b=RBZtL1RUMGctwXlRcImFl0Fp6Y3faIRxdDTaGp4VJv2QqWaf/vV1XDRnwkIErFq5Xa /K7FmxqXLue4cCS6KH/gFEv1fORJ859HlN4Ou3eryiT5MFtrBRpHvtklDBdj1EiDONhP 1va89pkZhhUzoFGL2zF0WBO9FQBak4JGDbSL1n5S/RQQYF9tKIL64HesdrmpRL6MST/v qCSlQN3HDFGWZh0ewJZiNW/J9qQY8k9Jdd6jXq7rTnZ66iaKp1KXmY7NfSXf39jkp6O3 CNbBbZYNJPpmgrlxel9op2dyOxhlNdQ79uXuDqMtm3O65TEELcnEQfUDK0oYtMh6yQYt DLhA== 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.51; Thu, 05 Aug 2021 01:09: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 S236885AbhHEIKE (ORCPT + 4 others); Thu, 5 Aug 2021 04:10:04 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]:3592 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236658AbhHEIKE (ORCPT ); Thu, 5 Aug 2021 04:10:04 -0400 Received: from fraeml735-chm.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4GgLqc12HHz6F8FP; Thu, 5 Aug 2021 16:09:32 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by fraeml735-chm.china.huawei.com (10.206.15.216) 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:49 +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:42 +0100 From: Shameer Kolothum To: , , CC: , , , , , , , , , , , Subject: [PATCH v7 8/9] iommu/arm-smmu: Get associated RMR info and install bypass SMR Date: Thu, 5 Aug 2021 09:07:23 +0100 Message-ID: <20210805080724.480-9-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 From: Jon Nettleton Check if there is any RMR info associated with the devices behind the SMMU and if any, install bypass SMRs for them. This is to keep any ongoing traffic associated with these devices alive when we enable/reset SMMU during probe(). Signed-off-by: Jon Nettleton Signed-off-by: Steven Price Signed-off-by: Shameer Kolothum --- drivers/iommu/arm/arm-smmu/arm-smmu.c | 48 +++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) -- 2.17.1 diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c index f22dbeb1e510..315feab9e85b 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c @@ -2063,6 +2063,50 @@ err_reset_platform_ops: __maybe_unused; return err; } +static void arm_smmu_rmr_install_bypass_smr(struct arm_smmu_device *smmu) +{ + struct list_head rmr_list; + struct iommu_resv_region *e; + int i, cnt = 0; + u32 reg; + + INIT_LIST_HEAD(&rmr_list); + if (iommu_dma_get_rmrs(dev_fwnode(smmu->dev), &rmr_list)) + return; + + /* + * Rather than trying to look at existing mappings that + * are setup by the firmware and then invalidate the ones + * that do no have matching RMR entries, just disable the + * SMMU until it gets enabled again in the reset routine. + */ + reg = arm_smmu_gr0_read(smmu, ARM_SMMU_GR0_sCR0); + reg |= ARM_SMMU_sCR0_CLIENTPD; + arm_smmu_gr0_write(smmu, ARM_SMMU_GR0_sCR0, reg); + + list_for_each_entry(e, &rmr_list, list) { + u32 sid = e->fw_data.rmr.sid; + + i = arm_smmu_find_sme(smmu, sid, ~0); + if (i < 0) + continue; + if (smmu->s2crs[i].count == 0) { + smmu->smrs[i].id = sid; + smmu->smrs[i].mask = 0; + smmu->smrs[i].valid = true; + } + smmu->s2crs[i].count++; + smmu->s2crs[i].type = S2CR_TYPE_BYPASS; + smmu->s2crs[i].privcfg = S2CR_PRIVCFG_DEFAULT; + + cnt++; + } + + dev_notice(smmu->dev, "\tpreserved %d boot mapping%s\n", cnt, + cnt == 1 ? "" : "s"); + iommu_dma_put_rmrs(dev_fwnode(smmu->dev), &rmr_list); +} + static int arm_smmu_device_probe(struct platform_device *pdev) { struct resource *res; @@ -2189,6 +2233,10 @@ static int arm_smmu_device_probe(struct platform_device *pdev) } platform_set_drvdata(pdev, smmu); + + /* Check for RMRs and install bypass SMRs if any */ + arm_smmu_rmr_install_bypass_smr(smmu); + arm_smmu_device_reset(smmu); arm_smmu_test_smr_masks(smmu);