mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mukesh R <mrathor@linux.microsoft.com>
To: linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org,
	iommu@lists.linux.dev, linux-arch@vger.kernel.org
Cc: jgg@nvidia.com, jacob.pan@linux.microsoft.com, kys@microsoft.com,
	haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com,
	tglx@kernel.org, mingo@redhat.com, bp@alien8.de,
	dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com,
	joro@8bytes.org, will@kernel.org, robin.murphy@arm.com,
	arnd@arndb.de, mrathor@linux.microsoft.com
Subject: [PATCH V2 1/4] mshv: Add gfp_flags parameter to hv_call_deposit_pages()
Date: Tue, 29 Sep 2026 15:36:19 -0700	[thread overview]
Message-ID: <20260929223622.778617-2-mrathor@linux.microsoft.com> (raw)
In-Reply-To: <20260929223622.778617-1-mrathor@linux.microsoft.com>

Currently GFP_KERNEL is hard coded in hv_call_deposit_pages(). Add
gfp_flags parameter so it can be called in atomic context from
map_pages callback in struct iommu_domain_ops and other places in
future.

Signed-off-by: Mukesh R <mrathor@linux.microsoft.com>
---
 drivers/hv/hv_proc.c           | 14 +++++++-------
 drivers/hv/mshv_root_hv_call.c |  6 ++++--
 include/asm-generic/mshyperv.h |  6 ++++--
 3 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/drivers/hv/hv_proc.c b/drivers/hv/hv_proc.c
index 57b2c64197cb..ce4276d37d45 100644
--- a/drivers/hv/hv_proc.c
+++ b/drivers/hv/hv_proc.c
@@ -15,8 +15,8 @@
  */
 #define HV_DEPOSIT_MAX (HV_HYP_PAGE_SIZE / sizeof(u64) - 1)
 
-/* Deposits exact number of pages. Must be called with interrupts enabled.  */
-int hv_call_deposit_pages(int node, u64 partition_id, u32 num_pages)
+int hv_call_deposit_pages(int node, u64 partition_id, u32 num_pages,
+			  gfp_t gfp_flags)
 {
 	struct page **pages, *page;
 	int *counts;
@@ -35,12 +35,12 @@ int hv_call_deposit_pages(int node, u64 partition_id, u32 num_pages)
 		return 0;
 
 	/* One buffer for page pointers and counts */
-	page = alloc_page(GFP_KERNEL);
+	page = alloc_page(gfp_flags);
 	if (!page)
 		return -ENOMEM;
 	pages = page_address(page);
 
-	counts = kzalloc_objs(int, HV_DEPOSIT_MAX);
+	counts = kzalloc_objs(int, HV_DEPOSIT_MAX, gfp_flags);
 	if (!counts) {
 		free_page((unsigned long)pages);
 		return -ENOMEM;
@@ -54,7 +54,7 @@ int hv_call_deposit_pages(int node, u64 partition_id, u32 num_pages)
 		order = 31 - __builtin_clz(num_pages);
 
 		while (1) {
-			pages[i] = alloc_pages_node(node, GFP_KERNEL, order);
+			pages[i] = alloc_pages_node(node, gfp_flags, order);
 			if (pages[i])
 				break;
 			if (!order) {
@@ -137,7 +137,7 @@ int hv_deposit_memory_node(int node, u64 partition_id,
 		hv_status_err(hv_status, "Unexpected!\n");
 		return -ENOMEM;
 	}
-	return hv_call_deposit_pages(node, partition_id, num_pages);
+	return hv_call_deposit_pages(node, partition_id, num_pages, GFP_KERNEL);
 }
 EXPORT_SYMBOL_GPL(hv_deposit_memory_node);
 
@@ -206,7 +206,7 @@ int hv_call_create_vp(int node, u64 partition_id, u32 vp_index, u32 flags)
 	/* Root VPs don't seem to need pages deposited */
 	if (partition_id != hv_current_partition_id) {
 		/* The value 90 is empirically determined. It may change. */
-		ret = hv_call_deposit_pages(node, partition_id, 90);
+		ret = hv_call_deposit_pages(node, partition_id, 90, GFP_KERNEL);
 		if (ret)
 			return ret;
 	}
diff --git a/drivers/hv/mshv_root_hv_call.c b/drivers/hv/mshv_root_hv_call.c
index cb55d4d4be2e..bd975239f3bc 100644
--- a/drivers/hv/mshv_root_hv_call.c
+++ b/drivers/hv/mshv_root_hv_call.c
@@ -141,7 +141,8 @@ int hv_call_initialize_partition(u64 partition_id)
 	input.partition_id = partition_id;
 
 	ret = hv_call_deposit_pages(NUMA_NO_NODE, partition_id,
-				    HV_INIT_PARTITION_DEPOSIT_PAGES);
+				    HV_INIT_PARTITION_DEPOSIT_PAGES,
+				    GFP_KERNEL);
 	if (ret)
 		return ret;
 
@@ -249,7 +250,8 @@ static int hv_do_map_gpa_hcall(u64 partition_id, u64 gfn, u64 page_struct_count,
 
 		if (hv_result_needs_memory(status)) {
 			ret = hv_call_deposit_pages(NUMA_NO_NODE, partition_id,
-						    HV_MAP_GPA_DEPOSIT_PAGES);
+						    HV_MAP_GPA_DEPOSIT_PAGES,
+						    GFP_KERNEL);
 			if (ret)
 				break;
 
diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h
index bf601d67cecb..af65dd3e3725 100644
--- a/include/asm-generic/mshyperv.h
+++ b/include/asm-generic/mshyperv.h
@@ -345,7 +345,8 @@ static inline bool hv_parent_partition(void)
 
 bool hv_result_needs_memory(u64 status);
 int hv_deposit_memory_node(int node, u64 partition_id, u64 status);
-int hv_call_deposit_pages(int node, u64 partition_id, u32 num_pages);
+int hv_call_deposit_pages(int node, u64 partition_id, u32 num_pages,
+			  gfp_t gfp_flags);
 int hv_call_add_logical_proc(int node, u32 lp_index, u32 acpi_id);
 int hv_call_notify_all_processors_started(void);
 bool hv_lp_exists(u32 lp_index);
@@ -360,7 +361,8 @@ static inline int hv_deposit_memory_node(int node, u64 partition_id, u64 status)
 {
 	return -EOPNOTSUPP;
 }
-static inline int hv_call_deposit_pages(int node, u64 partition_id, u32 num_pages)
+static inline int hv_call_deposit_pages(int node, u64 partition_id,
+					u32 num_pages, gfp_t gfp_flags)
 {
 	return -EOPNOTSUPP;
 }
-- 
2.51.2.vfs.0.1


  reply	other threads:[~2026-09-29 22:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-29 22:36 [PATCH V2 0/4] Hyper-V: root VM iommu kernel only driver Mukesh R
2026-09-29 22:36 ` Mukesh R [this message]
2026-09-29 22:36 ` [PATCH V2 2/4] PCI: hv: Export hv_build_devid_type_pci() and change return type Mukesh R
2026-09-29 22:36 ` [PATCH V2 3/4] mshv: Import data structs around device domains from hyperv headers Mukesh R
2026-09-29 22:36 ` [PATCH V2 4/4] x86/hyperv: Implement root partition IOMMU kernel only driver Mukesh R

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=20260929223622.778617-2-mrathor@linux.microsoft.com \
    --to=mrathor@linux.microsoft.com \
    --cc=arnd@arndb.de \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=decui@microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=hpa@zytor.com \
    --cc=iommu@lists.linux.dev \
    --cc=jacob.pan@linux.microsoft.com \
    --cc=jgg@nvidia.com \
    --cc=joro@8bytes.org \
    --cc=kys@microsoft.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=robin.murphy@arm.com \
    --cc=tglx@kernel.org \
    --cc=wei.liu@kernel.org \
    --cc=will@kernel.org \
    --cc=x86@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

all inboxes | Powered by JetHome®