All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Marek Marczykowski-Górecki" <marmarek@invisiblethingslab.com>
To: xen-devel@lists.xenproject.org
Cc: "Marek Marczykowski-Górecki" <marmarek@invisiblethingslab.com>,
	"Jan Beulich" <jbeulich@suse.com>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>
Subject: [PATCH v5 5/9] IOMMU/AMD: wire common device reserved memory API
Date: Mon, 22 Aug 2022 17:27:05 +0200	[thread overview]
Message-ID: <725db95e13a7006d55ead9bfb584dce206eaa86c.1661181584.git-series.marmarek@invisiblethingslab.com> (raw)
In-Reply-To: <cover.4afa0fece5b70e838e4f1c7c7f25d0fa3d157073.1661181584.git-series.marmarek@invisiblethingslab.com>

Register common device reserved memory similar to how ivmd= parameter is
handled.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
---
Changes in v3:
 - use variable initializer
 - use pfn_to_paddr()
---
 xen/drivers/passthrough/amd/iommu_acpi.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/xen/drivers/passthrough/amd/iommu_acpi.c b/xen/drivers/passthrough/amd/iommu_acpi.c
index ac6835225bae..3b577c9b390c 100644
--- a/xen/drivers/passthrough/amd/iommu_acpi.c
+++ b/xen/drivers/passthrough/amd/iommu_acpi.c
@@ -1078,6 +1078,25 @@ static inline bool_t is_ivmd_block(u8 type)
             type == ACPI_IVRS_TYPE_MEMORY_IOMMU);
 }
 
+static int __init cf_check add_one_extra_ivmd(unsigned long start,
+                                              unsigned long nr,
+                                              uint32_t id, void *ctxt)
+{
+    struct acpi_ivrs_memory ivmd = {
+        .header = {
+            .length = sizeof(ivmd),
+            .flags = ACPI_IVMD_UNITY | ACPI_IVMD_READ | ACPI_IVMD_WRITE,
+            .device_id = id,
+            .type = ACPI_IVRS_TYPE_MEMORY_ONE,
+        },
+    };
+
+    ivmd.start_address = pfn_to_paddr(start);
+    ivmd.memory_length = pfn_to_paddr(nr);
+
+    return parse_ivmd_block(&ivmd);
+}
+
 static int __init cf_check parse_ivrs_table(struct acpi_table_header *table)
 {
     const struct acpi_ivrs_header *ivrs_block;
@@ -1121,6 +1140,8 @@ static int __init cf_check parse_ivrs_table(struct acpi_table_header *table)
         AMD_IOMMU_DEBUG("IVMD: %u command line provided entries\n", nr_ivmd);
     for ( i = 0; !error && i < nr_ivmd; ++i )
         error = parse_ivmd_block(user_ivmds + i);
+    if ( !error )
+        error = iommu_get_extra_reserved_device_memory(add_one_extra_ivmd, NULL);
 
     /* Each IO-APIC must have been mentioned in the table. */
     for ( apic = 0; !error && iommu_intremap && apic < nr_ioapics; ++apic )
-- 
git-series 0.9.1


  parent reply	other threads:[~2022-08-22 15:27 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-22 15:27 [PATCH v5 0/9] Add Xue - console over USB 3 Debug Capability Marek Marczykowski-Górecki
2022-08-22 15:27 ` [PATCH v5 1/9] drivers/char: separate dbgp=xhci to dbc=xhci option Marek Marczykowski-Górecki
2022-08-25 15:44   ` Jan Beulich
2022-08-26 11:46     ` Marek Marczykowski-Górecki
2022-08-26 14:20       ` Jan Beulich
2022-08-26 14:30         ` Andrew Cooper
2022-08-29 11:49         ` Marek Marczykowski-Górecki
2022-08-29 11:57           ` Marek Marczykowski-Górecki
2022-09-06  6:58             ` Jan Beulich
2022-08-22 15:27 ` [PATCH v5 2/9] console: support multiple serial console simultaneously Marek Marczykowski-Górecki
2022-08-22 15:27 ` [PATCH v5 3/9] IOMMU: add common API for device reserved memory Marek Marczykowski-Górecki
2022-08-25 15:46   ` Jan Beulich
2022-08-22 15:27 ` [PATCH v5 4/9] IOMMU/VT-d: wire common device reserved memory API Marek Marczykowski-Górecki
2022-08-22 15:27 ` Marek Marczykowski-Górecki [this message]
2022-08-22 15:27 ` [PATCH v5 6/9] drivers/char: mark DMA buffers as reserved for the XHCI Marek Marczykowski-Górecki
2022-08-25 15:47   ` Jan Beulich
2022-08-22 15:27 ` [PATCH v5 7/9] drivers/char: add RX support to the XHCI driver Marek Marczykowski-Górecki
2022-08-22 15:27 ` [PATCH v5 8/9] drivers/char: allow driving the rest of XHCI by a domain while Xen uses DbC Marek Marczykowski-Górecki
2022-08-26 14:48   ` Jan Beulich
2022-08-22 15:27 ` [PATCH v5 9/9] drivers/char: fix handling cable re-plug in XHCI console driver Marek Marczykowski-Górecki
2022-08-26 14:50   ` Jan Beulich
2022-08-26 15:44     ` Andrew Cooper
2022-09-06  6:52       ` Jan Beulich

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=725db95e13a7006d55ead9bfb584dce206eaa86c.1661181584.git-series.marmarek@invisiblethingslab.com \
    --to=marmarek@invisiblethingslab.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.