From patchwork Tue Apr 20 08:27:51 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: 424563 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp207054jao; Tue, 20 Apr 2021 02:29:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfT2gZHbFWkvadWqmrjzmAJy8EpL7QwF8ZEdU1xn+5CsUROKaaSCX/kFwRuIkrlbq9iaed X-Received: by 2002:a50:aad9:: with SMTP id r25mr31219860edc.125.1618910957138; Tue, 20 Apr 2021 02:29:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618910957; cv=none; d=google.com; s=arc-20160816; b=F/5dBQ2ojW11OkXBMtkOBjpz8o9jbVIXsYspE2UAFzH2FNlmJ5djmN/dfLArKjO4YK S10jDjFLbrw7zwU5otuPiY9ve6kb7j4G4K+uRgGJ6EiF/NpO/f13LHOJ8SV6/UkUM5/N oeaRM5U1q31S8x3tAayKBB4tDOOwa50ViRimGsB3VEPs5JwquGsCW5AkheBYd0H1D609 Phwlfx/9tgKT7/6yXCW9UCjQ013+2s3gtNZg4NhRCfBm5+6DwfGI6CHpPtios311gLbb 9CLTjpDkWlQEK4d1j4+SlluLJJ371fuR87EaBcqS2gjmn0QerRX/Ot1gfyov6vFFJTev +cAg== 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=TdWOjJ1hFBmVmFu2UmzRupM0NvuBxsxXUIShSnQyDqQ=; b=FrxzJSEDUtAA0mI/FOXXVp7Cxosh9MfyCa7zoJoQAnPC4rRq16hhlgS/pNMDWhWStm gUgxLMjbL4wAAvRfSL/noNLbs++oJX+7kA4n9gvPlm2YNRnmE9SxwZi5ecuq5/5CxypZ yE3WLp1rX4oIHaa63y7U9Sn49yjWkP9Fe4ZW9AyW8kHx4c89hq7u+ct4KOKv6St6shRK eRbH9vrCZuUGw0Fl8FeUD+fVpnfbzWSGkCryfUekaQuRkqCuiBOLQe5vkxtqJeU2h8MP KKXfz7+vvCM3zuydII+2c4GvdLFUM2XaCyKLqaBfa9FrUau7moVH5GXUL9Lmn9s7WubI zAXg== 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 ds2si13913381ejc.749.2021.04.20.02.29.16; Tue, 20 Apr 2021 02:29:17 -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 S231325AbhDTJ3r (ORCPT + 4 others); Tue, 20 Apr 2021 05:29:47 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:16143 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231370AbhDTJ3q (ORCPT ); Tue, 20 Apr 2021 05:29:46 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FPdbS6mRpzpZTX; Tue, 20 Apr 2021 17:26:12 +0800 (CST) Received: from A2006125610.china.huawei.com (10.47.83.26) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.498.0; Tue, 20 Apr 2021 17:29:03 +0800 From: Shameer Kolothum To: , , CC: , , , , , , , , , Subject: [PATCH v3 10/10] iommu/arm-smmu: Reserve any RMR regions associated with a dev Date: Tue, 20 Apr 2021 10:27:51 +0200 Message-ID: <20210420082751.1829-11-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20210420082751.1829-1-shameerali.kolothum.thodi@huawei.com> References: <20210420082751.1829-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.83.26] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Jon Nettleton Get RMR regions associated with a dev reserved so that there is a unity mapping for them in SMMU. Signed-off-by: Jon Nettleton Signed-off-by: Shameer Kolothum --- drivers/iommu/arm/arm-smmu/arm-smmu.c | 33 +++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) -- 2.17.1 Reported-by: kernel test robot diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c index 4d2f91626d87..8cbe8b98e8f0 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c @@ -1591,6 +1591,38 @@ static int arm_smmu_of_xlate(struct device *dev, struct of_phandle_args *args) return iommu_fwspec_add_ids(dev, &fwid, 1); } +static bool arm_smmu_dev_has_rmr(struct arm_smmu_master_cfg *cfg, + struct iommu_fwspec *fwspec, + struct iommu_rmr *e) +{ + struct arm_smmu_device *smmu = cfg->smmu; + struct arm_smmu_smr *smrs = smmu->smrs; + int i, idx; + + for_each_cfg_sme(cfg, fwspec, i, idx) { + if (e->sid == smrs[idx].id) + return true; + } + + return false; +} + +static void arm_smmu_rmr_get_resv_regions(struct device *dev, + struct list_head *head) +{ + struct arm_smmu_master_cfg *cfg = dev_iommu_priv_get(dev); + struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev); + struct arm_smmu_device *smmu = cfg->smmu; + struct iommu_rmr *rmr; + + list_for_each_entry(rmr, &smmu->rmr_list, list) { + if (!arm_smmu_dev_has_rmr(cfg, fwspec, rmr)) + continue; + + iommu_dma_get_rmr_resv_regions(dev, rmr, head); + } +} + static void arm_smmu_get_resv_regions(struct device *dev, struct list_head *head) { @@ -1605,6 +1637,7 @@ static void arm_smmu_get_resv_regions(struct device *dev, list_add_tail(®ion->list, head); iommu_dma_get_resv_regions(dev, head); + arm_smmu_rmr_get_resv_regions(dev, head); } static int arm_smmu_def_domain_type(struct device *dev)