From patchwork Tue Apr 20 08:27:49 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: 424561 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp206930jao; Tue, 20 Apr 2021 02:29:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3jVxMxd2dtgP6SRw5cNuVIjvyjvgY4VaEQiOzgPo25VzQ2lXmCne9059F6KwN+3qTgWjt X-Received: by 2002:a17:906:154f:: with SMTP id c15mr26798108ejd.142.1618910944536; Tue, 20 Apr 2021 02:29:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618910944; cv=none; d=google.com; s=arc-20160816; b=sTF4yoyIV/UFW9hwkQtgrRD7rweygC8Izj9Pz40eGatZdsWQykSevYCEyfgffpUJKm C2uz7A8wa6PvTGw2wSJ/J87VOCBBaDb3nXTMpUmEtkS3X7WdAMiusAN5Z76Q+PppfqWs Xl/8pWvRg/FClrak0+7Omzbf3CWNB5NKIb+pynZcGmF/IqE3BMSr/wQRJk4bdb/fGv0W n6fX2MIDF/XWpfQjfduGInTEbkJH2TfkExi3X8m86KKJg4nrRLXYuPBIVrYArn8drnRl KgoGKJ9nbO39qn9o7We1PShzlOQEcfQV1hIZN/hIHWJS26VwwNbtJrhOtGHiH6OH1XDm +/Tg== 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=ZyQLMlenBhIjA4/aCCmelbKRPRRuSzs82jNo/8rVPlM=; b=YtkUnwMeiw85qV/5na/+QTmh7/XQqO2d0/rZvxxsa7vc4pO/Asrr/gcOsrVg6RxztO khZZOAquWaHoO66qgz2GDUdcrj9GYTRcMReSodDkW6p+cs/WbbPH7l//70GoJd5TSAq3 D/ByvyL5JbLXr/COeoRaeeZkyNvH7FhxPSvVzbesFx6mrNnwAuT4NbGxRQn+6SBZquaj b8XveZ9UZBWj7iSlA0QlTf7YATlS+jh8ZcvHr5mw2hhxGszEPYWEiYJayKspd2KaSKCe fbK/a2/Y3DU+JH/ZMCe4RIQ0Az6wAsaXX+YNs2FrsjDOIZRoSGPFPMx3104jAXKqnF5W VnsA== 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.04; Tue, 20 Apr 2021 02:29:04 -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 S231364AbhDTJ3e (ORCPT + 4 others); Tue, 20 Apr 2021 05:29:34 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:16608 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231325AbhDTJ3e (ORCPT ); Tue, 20 Apr 2021 05:29:34 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FPdc02yFRz19Ln5; Tue, 20 Apr 2021 17:26:40 +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:28:51 +0800 From: Shameer Kolothum To: , , CC: , , , , , , , , , Subject: [PATCH v3 08/10] iommu/arm-smmu-v3: Reserve any RMR regions associated with a dev Date: Tue, 20 Apr 2021 10:27:49 +0200 Message-ID: <20210420082751.1829-9-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 Get RMR regions associated with a dev reserved so that there is a unity mapping for them in SMMU. Signed-off-by: Shameer Kolothum --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 29 +++++++++++++++++++++ 1 file changed, 29 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 14e9c7034c04..8bacedf7bb34 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2531,6 +2531,34 @@ static int arm_smmu_of_xlate(struct device *dev, struct of_phandle_args *args) return iommu_fwspec_add_ids(dev, args->args, 1); } +static bool arm_smmu_dev_has_rmr(struct arm_smmu_master *master, + struct iommu_rmr *e) +{ + int i; + + for (i = 0; i < master->num_sids; i++) { + if (e->sid == master->sids[i]) + return true; + } + + return false; +} + +static void arm_smmu_rmr_get_resv_regions(struct device *dev, + struct list_head *head) +{ + struct arm_smmu_master *master = dev_iommu_priv_get(dev); + struct arm_smmu_device *smmu = master->smmu; + struct iommu_rmr *rmr; + + list_for_each_entry(rmr, &smmu->rmr_list, list) { + if (!arm_smmu_dev_has_rmr(master, 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) { @@ -2545,6 +2573,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 bool arm_smmu_dev_has_feature(struct device *dev,