diff mbox series

[RFC,1/3] drivers/char: support up to 1M BAR0 of xhci

Message ID 3398f603208397e2894dd452e9de047431599c58.1670724490.git-series.marmarek@invisiblethingslab.com (mailing list archive)
State New, archived
Headers show
Series Try to fix XHCI console on AMD systems (help needed) | expand

Commit Message

Marek Marczykowski-Górecki Dec. 11, 2022, 2:10 a.m. UTC
AMD's XHCI has BAR0 of 1M (compared to 64K on Intel). Map it as a whole
(reserving more space in the fixmap). Make fixmap slot conditional on
CONFIG_XHCI.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
---
 xen/arch/x86/include/asm/fixmap.h | 4 +++-
 xen/drivers/char/xhci-dbc.c       | 6 ++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

Comments

Jan Beulich Dec. 14, 2022, 10:44 a.m. UTC | #1
On 11.12.2022 03:10, Marek Marczykowski-Górecki wrote:
> AMD's XHCI has BAR0 of 1M (compared to 64K on Intel). Map it as a whole
> (reserving more space in the fixmap). Make fixmap slot conditional on
> CONFIG_XHCI.
> 
> Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>

> --- a/xen/drivers/char/xhci-dbc.c
> +++ b/xen/drivers/char/xhci-dbc.c
> @@ -268,10 +268,12 @@ static void *dbc_sys_map_xhc(uint64_t phys, size_t size)
>  {
>      size_t i;
>  
> -    if ( size != MAX_XHCI_PAGES * PAGE_SIZE )
> +    if ( size > MAX_XHCI_PAGES * PAGE_SIZE )
>          return NULL;

To be honest I didn't really like the original, overly strict check.

Jan
diff mbox series

Patch

diff --git a/xen/arch/x86/include/asm/fixmap.h b/xen/arch/x86/include/asm/fixmap.h
index bc39ffe896b1..516ec3fa6c95 100644
--- a/xen/arch/x86/include/asm/fixmap.h
+++ b/xen/arch/x86/include/asm/fixmap.h
@@ -25,7 +25,7 @@ 
 #include <asm/msi.h>
 #include <acpi/apei.h>
 
-#define MAX_XHCI_PAGES 16
+#define MAX_XHCI_PAGES 256
 
 /*
  * Here we define all the compile-time 'special' virtual
@@ -45,8 +45,10 @@  enum fixed_addresses {
     FIX_COM_BEGIN,
     FIX_COM_END,
     FIX_EHCI_DBGP,
+#ifdef CONFIG_XHCI
     FIX_XHCI_BEGIN,
     FIX_XHCI_END = FIX_XHCI_BEGIN + MAX_XHCI_PAGES - 1,
+#endif
 #ifdef CONFIG_XEN_GUEST
     FIX_PV_CONSOLE,
     FIX_XEN_SHARED_INFO,
diff --git a/xen/drivers/char/xhci-dbc.c b/xen/drivers/char/xhci-dbc.c
index 86f6df6bef67..60b781f87202 100644
--- a/xen/drivers/char/xhci-dbc.c
+++ b/xen/drivers/char/xhci-dbc.c
@@ -268,10 +268,12 @@  static void *dbc_sys_map_xhc(uint64_t phys, size_t size)
 {
     size_t i;
 
-    if ( size != MAX_XHCI_PAGES * PAGE_SIZE )
+    if ( size > MAX_XHCI_PAGES * PAGE_SIZE )
         return NULL;
 
-    for ( i = FIX_XHCI_END; i >= FIX_XHCI_BEGIN; i-- )
+    size >>= PAGE_SHIFT;
+
+    for ( i = FIX_XHCI_END; i > FIX_XHCI_END - size; i-- )
     {
         set_fixmap_nocache(i, phys);
         phys += PAGE_SIZE;