From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CAB2AC47082 for ; Thu, 3 Jun 2021 11:22:51 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 958EB60C3E for ; Thu, 3 Jun 2021 11:22:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 958EB60C3E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1nvNoPEKVFED7QXjtW8HJHyfzIMgeRPyRR8NKTWKVM8=; b=WopZmKR+1U/erf ysOpiFaRy25C/Nl6f5CAVYK4dj8HpzcGGrsG7vsbX0+KtAYUA0I88xVh5hrViyyFSOuN6ql3qMiyP 731Bqq1/RbVMk5mnRYcUMwjstU3GHhBjjGWQoRTjcJRo+Lv/xTg2lfnigyWeBiH8HaqCz359NksNQ tT6kW/O1G+3WHaHsOEbUZ8PRncR8n5NQqCcz1lnyvWJZX6W+0JY0ar79fgMcaMo67cwnC9Fo/XVVa UajvAs5x6+FcZ8unda7KPkzP4J1eIrMSAddOVi0XfqAZjmo3nKanGNqsRCmNARbxlGVWynrub2wVj WuyAT9IpHJcjhcx/EDIQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lolPU-008Ksp-HW; Thu, 03 Jun 2021 11:21:12 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lolPO-008KrW-9J for linux-arm-kernel@lists.infradead.org; Thu, 03 Jun 2021 11:21:09 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1FE681063; Thu, 3 Jun 2021 04:21:01 -0700 (PDT) Received: from lpieralisi (e121166-lin.cambridge.arm.com [10.1.196.255]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 585D83F774; Thu, 3 Jun 2021 04:20:59 -0700 (PDT) Date: Thu, 3 Jun 2021 12:20:54 +0100 From: Lorenzo Pieralisi To: Shameer Kolothum Cc: linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, iommu@lists.linux-foundation.org, linuxarm@huawei.com, joro@8bytes.org, robin.murphy@arm.com, wanghuiqiang@huawei.com, guohanjun@huawei.com, steven.price@arm.com, Sami.Mujawar@arm.com, jon@solid-run.com, eric.auger@redhat.com, yangyicong@huawei.com Subject: Re: [PATCH v4 3/8] ACPI/IORT: Add a helper to retrieve RMR memory regions Message-ID: <20210603112054.GA14606@lpieralisi> References: <20210513134550.2117-1-shameerali.kolothum.thodi@huawei.com> <20210513134550.2117-4-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210513134550.2117-4-shameerali.kolothum.thodi@huawei.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210603_042106_448223_7E11F488 X-CRM114-Status: GOOD ( 26.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, May 13, 2021 at 02:45:45PM +0100, Shameer Kolothum wrote: > Add a helper function that retrieves RMR memory descriptors > associated with a given IOMMU. This will be used by IOMMU > drivers to setup necessary mappings. > > Now that we have this, invoke it from the generic helper "Add a helper function (iort_iommu_get_rmrs()) that retrieves RMR memory descriptors associated with a given IOMMU. This will be used by IOMMU drivers to setup necessary mappings. Invoke it from the generic helper iommu_dma_get_rmrs()." > interface. > > Signed-off-by: Shameer Kolothum > --- > drivers/acpi/arm64/iort.c | 40 +++++++++++++++++++++++++++++++++++++++ > drivers/iommu/dma-iommu.c | 3 +++ > include/linux/acpi_iort.h | 7 +++++++ > 3 files changed, 50 insertions(+) > > diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c > index fea1ffaedf3b..6ca88c38987a 100644 > --- a/drivers/acpi/arm64/iort.c > +++ b/drivers/acpi/arm64/iort.c > @@ -12,6 +12,7 @@ > > #include > #include > +#include > #include > #include > #include > @@ -837,6 +838,43 @@ static inline int iort_add_device_replay(struct device *dev) > return err; > } > > +/** > + * iort_iommu_get_rmrs - Helper to retrieve RMR info associated with IOMMU iort_iommu_get_rmrs() please check other functions comments in the patchset. > + * @iommu: fwnode for the IOMMU Does not match the parameter. > + * @head: RMR list head to be populated > + * > + * Returns: 0 on success, <0 failure > + */ > +int iort_iommu_get_rmrs(struct fwnode_handle *iommu_fwnode, > + struct list_head *head) > +{ > + struct iort_rmr_entry *e; > + struct acpi_iort_node *iommu; > + > + iommu = iort_get_iort_node(iommu_fwnode); > + if (!iommu) > + return -EINVAL; > + > + list_for_each_entry(e, &iort_rmr_list, list) { > + struct acpi_iort_rmr_desc *rmr_desc; > + struct iommu_rmr *rmr; > + > + if (e->smmu != iommu) > + continue; > + > + rmr_desc = e->rmr_desc; > + rmr = iommu_dma_alloc_rmr(rmr_desc->base_address, > + rmr_desc->length, e->sid, > + e->flags); > + if (!rmr) > + return -ENOMEM; I suppose it is OK to leave the already allocated regions allocated on -ENOMEM. Probably worth clarifying it in the function comment. Lorenzo > + > + list_add_tail(&rmr->list, head); > + } > + > + return 0; > +} > + > /** > * iort_iommu_msi_get_resv_regions - Reserved region driver helper > * @dev: Device from iommu_get_resv_regions() > @@ -1108,6 +1146,8 @@ int iort_iommu_msi_get_resv_regions(struct device *dev, struct list_head *head) > const struct iommu_ops *iort_iommu_configure_id(struct device *dev, > const u32 *input_id) > { return NULL; } > +int iort_iommu_get_rmrs(struct fwnode_handle *fwnode, struct list_head *head) > +{ return -ENODEV; } > #endif > > static int nc_dma_get_range(struct device *dev, u64 *size) > diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c > index 674bd8815159..2d9caf548a32 100644 > --- a/drivers/iommu/dma-iommu.c > +++ b/drivers/iommu/dma-iommu.c > @@ -203,6 +203,9 @@ EXPORT_SYMBOL(iommu_dma_get_resv_regions); > int iommu_dma_get_rmrs(struct fwnode_handle *iommu_fwnode, > struct list_head *list) > { > + if (!is_of_node(iommu_fwnode)) > + return iort_iommu_get_rmrs(iommu_fwnode, list); > + > return -EINVAL; > } > EXPORT_SYMBOL(iommu_dma_get_rmrs); > diff --git a/include/linux/acpi_iort.h b/include/linux/acpi_iort.h > index 1a12baa58e40..e8c45fa59531 100644 > --- a/include/linux/acpi_iort.h > +++ b/include/linux/acpi_iort.h > @@ -39,6 +39,8 @@ const struct iommu_ops *iort_iommu_configure_id(struct device *dev, > const u32 *id_in); > int iort_iommu_msi_get_resv_regions(struct device *dev, struct list_head *head); > phys_addr_t acpi_iort_dma_get_max_cpu_address(void); > +int iort_iommu_get_rmrs(struct fwnode_handle *iommu_fwnode, > + struct list_head *list); > #else > static inline void acpi_iort_init(void) { } > static inline u32 iort_msi_map_id(struct device *dev, u32 id) > @@ -59,6 +61,11 @@ int iort_iommu_msi_get_resv_regions(struct device *dev, struct list_head *head) > > static inline phys_addr_t acpi_iort_dma_get_max_cpu_address(void) > { return PHYS_ADDR_MAX; } > + > +static inline > +int iort_iommu_get_rmrs(struct fwnode_handle *iommu_fwnode, > + struct list_head *list) > +{ return -ENODEV; } > #endif > > #endif /* __ACPI_IORT_H__ */ > -- > 2.17.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel