From: Shameer Kolothum via iommu <iommu@lists.linux-foundation.org>
To: <linux-arm-kernel@lists.infradead.org>,
<linux-acpi@vger.kernel.org>, <iommu@lists.linux-foundation.org>
Cc: robin.murphy@arm.com, jon@solid-run.com, linuxarm@huawei.com,
steven.price@arm.com, hch@infradead.org, guohanjun@huawei.com,
Sami.Mujawar@arm.com, will@kernel.org, wanghuiqiang@huawei.com
Subject: [PATCH v13 1/9] iommu: Introduce a callback to struct iommu_resv_region
Date: Wed, 15 Jun 2022 11:10:36 +0100 [thread overview]
Message-ID: <20220615101044.1972-2-shameerali.kolothum.thodi@huawei.com> (raw)
In-Reply-To: <20220615101044.1972-1-shameerali.kolothum.thodi@huawei.com>
A callback is introduced to struct iommu_resv_region to free memory
allocations associated with the reserved region. This will be useful
when we introduce support for IORT RMR based reserved regions.
Reviewed-by: Christoph Hellwig <hch@lst.de>
Tested-by: Steven Price <steven.price@arm.com>
Tested-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>
Tested-by: Hanjun Guo <guohanjun@huawei.com>
Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
---
drivers/iommu/iommu.c | 16 +++++++++++-----
include/linux/iommu.h | 2 ++
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 847ad47a2dfd..298a8c060698 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -2590,16 +2590,22 @@ void iommu_put_resv_regions(struct device *dev, struct list_head *list)
* @list: reserved region list for device
*
* IOMMU drivers can use this to implement their .put_resv_regions() callback
- * for simple reservations. Memory allocated for each reserved region will be
- * freed. If an IOMMU driver allocates additional resources per region, it is
- * going to have to implement a custom callback.
+ * for simple reservations. If a per region callback is provided that will be
+ * used to free all memory allocations associated with the reserved region or
+ * else just free up the memory for the regions. If an IOMMU driver allocates
+ * additional resources per region, it is going to have to implement a custom
+ * callback.
*/
void generic_iommu_put_resv_regions(struct device *dev, struct list_head *list)
{
struct iommu_resv_region *entry, *next;
- list_for_each_entry_safe(entry, next, list, list)
- kfree(entry);
+ list_for_each_entry_safe(entry, next, list, list) {
+ if (entry->free)
+ entry->free(dev, entry);
+ else
+ kfree(entry);
+ }
}
EXPORT_SYMBOL(generic_iommu_put_resv_regions);
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index 5e1afe169549..b22ffa6bc4a9 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -135,6 +135,7 @@ enum iommu_resv_type {
* @length: Length of the region in bytes
* @prot: IOMMU Protection flags (READ/WRITE/...)
* @type: Type of the reserved region
+ * @free: Callback to free associated memory allocations
*/
struct iommu_resv_region {
struct list_head list;
@@ -142,6 +143,7 @@ struct iommu_resv_region {
size_t length;
int prot;
enum iommu_resv_type type;
+ void (*free)(struct device *dev, struct iommu_resv_region *region);
};
/**
--
2.25.1
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2022-06-15 10:11 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-15 10:10 [PATCH v13 0/9] ACPI/IORT: Support for IORT RMR node Shameer Kolothum via iommu
2022-06-15 10:10 ` Shameer Kolothum via iommu [this message]
2022-06-15 10:10 ` [PATCH v13 2/9] ACPI/IORT: Make iort_iommu_msi_get_resv_regions() return void Shameer Kolothum via iommu
2022-06-15 10:10 ` [PATCH v13 3/9] ACPI/IORT: Provide a generic helper to retrieve reserve regions Shameer Kolothum via iommu
2022-06-15 10:10 ` [PATCH v13 4/9] ACPI/IORT: Add support to retrieve IORT RMR reserved regions Shameer Kolothum via iommu
2022-06-15 10:10 ` [PATCH v13 5/9] ACPI/IORT: Add a helper to retrieve RMR info directly Shameer Kolothum via iommu
2022-06-15 10:10 ` [PATCH v13 6/9] iommu/arm-smmu-v3: Introduce strtab init helper Shameer Kolothum via iommu
2022-06-15 10:10 ` [PATCH v13 7/9] iommu/arm-smmu-v3: Refactor arm_smmu_init_bypass_stes() to force bypass Shameer Kolothum via iommu
2022-06-15 10:10 ` [PATCH v13 8/9] iommu/arm-smmu-v3: Get associated RMR info and install bypass STE Shameer Kolothum via iommu
2022-06-15 10:10 ` [PATCH v13 9/9] iommu/arm-smmu: Get associated RMR info and install bypass SMR Shameer Kolothum via iommu
2022-06-17 12:41 ` [PATCH v13 0/9] ACPI/IORT: Support for IORT RMR node Steven Price
2022-06-24 15:44 ` Shameerali Kolothum Thodi via iommu
2022-06-27 11:38 ` Bjoern A. Zeeb
2022-06-27 12:25 ` Robin Murphy
2022-06-28 7:59 ` Shameerali Kolothum Thodi via iommu
2022-07-06 10:51 ` joro
2022-07-01 16:43 ` Shameerali Kolothum Thodi via iommu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220615101044.1972-2-shameerali.kolothum.thodi@huawei.com \
--to=iommu@lists.linux-foundation.org \
--cc=Sami.Mujawar@arm.com \
--cc=guohanjun@huawei.com \
--cc=hch@infradead.org \
--cc=jon@solid-run.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linuxarm@huawei.com \
--cc=robin.murphy@arm.com \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=steven.price@arm.com \
--cc=wanghuiqiang@huawei.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).