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>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"George Dunlap" <george.dunlap@citrix.com>,
	"Jan Beulich" <jbeulich@suse.com>,
	"Julien Grall" <julien@xen.org>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	"Wei Liu" <wl@xen.org>
Subject: [PATCH v2 3/9] xue: add support for selecting specific xhci
Date: Wed,  6 Jul 2022 17:32:08 +0200	[thread overview]
Message-ID: <399a41db5eb32197364b47a7031c30464803fa76.1657121519.git-series.marmarek@invisiblethingslab.com> (raw)
In-Reply-To: <cover.991b72d99d9e5bd4c2c76791ceb49f1056ce5d1c.1657121519.git-series.marmarek@invisiblethingslab.com>

Handle parameters similar to dbgp=ehci.

Implement this by not resettting xhc_cf8 again in xue_init_xhc(), but
using a value found there if non-zero. Additionally, add xue->xhc_num to
select n-th controller.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
---
Changes in v2:
 - unsigned int xhc_num
 - code style
---
 docs/misc/xen-command-line.pandoc |  2 +-
 xen/drivers/char/xue.c            | 53 ++++++++++++++++++++++++--------
 2 files changed, 42 insertions(+), 13 deletions(-)

diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line.pandoc
index f9fa857bd84e..1ab92bf7b50a 100644
--- a/docs/misc/xen-command-line.pandoc
+++ b/docs/misc/xen-command-line.pandoc
@@ -721,7 +721,7 @@ Available alternatives, with their meaning, are:
 
 ### dbgp
 > `= ehci[ <integer> | @pci<bus>:<slot>.<func> ]`
-> `= xue`
+> `= xue[ <integer> | @pci<bus>:<slot>.<func> ]`
 
 Specify the USB controller to use, either by instance number (when going
 over the PCI busses sequentially) or by PCI device (must be on segment 0).
diff --git a/xen/drivers/char/xue.c b/xen/drivers/char/xue.c
index 2cbbaea11fa0..9d48068a5fba 100644
--- a/xen/drivers/char/xue.c
+++ b/xen/drivers/char/xue.c
@@ -205,6 +205,7 @@ struct xue {
     void *xhc_mmio;
 
     int open;
+    unsigned int xhc_num; /* look for n-th xhc */
 };
 
 static void xue_sys_pause(void)
@@ -238,24 +239,35 @@ static bool __init xue_init_xhc(struct xue *xue)
     uint64_t bar1;
     uint64_t devfn;
 
-    /*
-     * Search PCI bus 0 for the xHC. All the host controllers supported so far
-     * are part of the chipset and are on bus 0.
-     */
-    for ( devfn = 0; devfn < 256; devfn++ )
+    if ( xue->sbdf.sbdf == 0 )
     {
-        pci_sbdf_t sbdf = PCI_SBDF(0, 0, devfn);
-        uint32_t hdr = pci_conf_read8(sbdf, PCI_HEADER_TYPE);
-
-        if ( hdr == 0 || hdr == 0x80 )
+        /*
+         * Search PCI bus 0 for the xHC. All the host controllers supported so far
+         * are part of the chipset and are on bus 0.
+         */
+        for ( devfn = 0; devfn < 256; devfn++ )
         {
-            if ( (pci_conf_read32(sbdf, PCI_CLASS_REVISION) >> 8) == XUE_XHC_CLASSC )
+            pci_sbdf_t sbdf = PCI_SBDF(0, 0, devfn);
+            uint32_t hdr = pci_conf_read8(sbdf, PCI_HEADER_TYPE);
+
+            if ( hdr == 0 || hdr == 0x80 )
             {
-                xue->sbdf = sbdf;
-                break;
+                if ( (pci_conf_read32(sbdf, PCI_CLASS_REVISION) >> 8) == XUE_XHC_CLASSC )
+                {
+                    if ( xue->xhc_num-- )
+                        continue;
+                    xue->sbdf = sbdf;
+                    break;
+                }
             }
         }
     }
+    else
+    {
+        /* Verify if selected device is really xHC */
+        if ( (pci_conf_read32(xue->sbdf, PCI_CLASS_REVISION) >> 8) != XUE_XHC_CLASSC )
+            xue->sbdf.sbdf = 0;
+    }
 
     if ( !xue->sbdf.sbdf )
     {
@@ -955,12 +967,29 @@ void __init xue_uart_init(void)
 {
     struct xue_uart *uart = &xue_uart;
     struct xue *xue = &uart->xue;
+    const char *e;
 
     if ( strncmp(opt_dbgp, "xue", 3) )
         return;
 
     memset(xue, 0, sizeof(*xue));
 
+    if ( isdigit(opt_dbgp[3]) || !opt_dbgp[3] )
+    {
+        if ( opt_dbgp[3] )
+            xue->xhc_num = simple_strtoul(opt_dbgp + 3, &e, 10);
+    }
+    else if ( strncmp(opt_dbgp + 3, "@pci", 4) == 0 )
+    {
+        unsigned int bus, slot, func;
+
+        e = parse_pci(opt_dbgp + 7, NULL, &bus, &slot, &func);
+        if ( !e || *e )
+            return;
+
+        xue->sbdf = PCI_SBDF(0, bus, slot, func);
+    }
+
     xue->dbc_ctx = &ctx;
     xue->dbc_erst = &erst;
     xue->dbc_ering.trb = evt_trb;
-- 
git-series 0.9.1


  parent reply	other threads:[~2022-07-06 15:33 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-06 15:32 [PATCH v2 0/9] Add Xue - console over USB 3 Debug Capability Marek Marczykowski-Górecki
2022-07-06 15:32 ` [PATCH v2 1/9] drivers/char: Add support for Xue USB3 debugger Marek Marczykowski-Górecki
2022-07-08  2:11   ` Marek Marczykowski-Górecki
2022-07-12 15:59   ` Jan Beulich
2022-07-18 10:45     ` Marek Marczykowski-Górecki
2022-07-18 10:55       ` Jan Beulich
2022-07-12 16:06   ` Jan Beulich
2022-07-14  6:05   ` Jan Beulich
2022-07-16 22:40     ` Marek Marczykowski-Górecki
2022-07-14 11:58   ` Jan Beulich
2022-07-16 23:32     ` Marek Marczykowski-Górecki
2022-07-20 20:12     ` Marek Marczykowski-Górecki
2022-07-21 10:25       ` Jan Beulich
2022-07-06 15:32 ` [PATCH v2 2/9] xue: reset XHCI ports when initializing dbc Marek Marczykowski-Górecki
2022-07-13  7:19   ` Jan Beulich
2022-07-06 15:32 ` Marek Marczykowski-Górecki [this message]
2022-07-13  7:24   ` [PATCH v2 3/9] xue: add support for selecting specific xhci Jan Beulich
2022-07-06 15:32 ` [PATCH v2 4/9] console: support multiple serial console simultaneously Marek Marczykowski-Górecki
2022-07-13  9:39   ` Jan Beulich
2022-07-18 12:48     ` Marek Marczykowski-Górecki
2022-07-18 14:37       ` Jan Beulich
2022-07-06 15:32 ` [PATCH v2 5/9] IOMMU: add common API for device reserved memory Marek Marczykowski-Górecki
2022-07-14 10:17   ` Jan Beulich
2022-07-18 10:53     ` Marek Marczykowski-Górecki
2022-07-18 11:14       ` Jan Beulich
2022-07-18 11:03     ` Marek Marczykowski-Górecki
2022-07-18 11:15       ` Jan Beulich
2022-07-06 15:32 ` [PATCH v2 6/9] IOMMU/VT-d: wire common device reserved memory API Marek Marczykowski-Górecki
2022-07-06 15:32 ` [PATCH v2 7/9] IOMMU/AMD: " Marek Marczykowski-Górecki
2022-07-14 10:22   ` Jan Beulich
2022-07-18 11:35     ` Marek Marczykowski-Górecki
2022-07-18 11:44       ` Jan Beulich
2022-07-06 15:32 ` [PATCH v2 8/9] xue: mark DMA buffers as reserved for the device Marek Marczykowski-Górecki
2022-07-14 11:51   ` Jan Beulich
2022-07-18 13:15     ` Marek Marczykowski-Górecki
2022-07-20 20:17     ` Marek Marczykowski-Górecki
2022-07-21 10:30       ` Jan Beulich
2022-07-06 15:32 ` [PATCH v2 9/9] xue: allow driving the rest of XHCI by a domain while Xen uses DbC Marek Marczykowski-Górecki
2022-07-14 12:06   ` Jan Beulich
2022-07-18 12:54     ` Marek Marczykowski-Górecki
2022-07-18 15:07       ` 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=399a41db5eb32197364b47a7031c30464803fa76.1657121519.git-series.marmarek@invisiblethingslab.com \
    --to=marmarek@invisiblethingslab.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=sstabellini@kernel.org \
    --cc=wl@xen.org \
    --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.