[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC PATCH 2/3] drivers/char: search all buses for xhci


  • To: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 14 Dec 2022 11:51:31 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=76LIOYxzyYWLY++n6bI0Ju/ckTO2RIiiredNjz4AO6M=; b=hoj+KH7YCQZYjkoDQjvYfJaHb6qFyOp1pB7xeJkTg9oDfj6gBlAUJUNJxOfLPjYUuiyoIvh98SHqGTUj2fV4rp58yyC/ZRrwdBf34ghAygkfLshDNNSuYDWtcykrj0M7nUIRsQ45mdRL7tDCJnQ6uA7aidnv9rE9+ih/be4i7J8v4Bfh8M0JRCcWHnSkFGL0vBvPSswemWbnZ429Oz1vDhhMhwk5Vgtb2zR3GCkL5I0gh/3m1MKdJ8nF2eU/qLzmFOGGkLi6fI5ImNTPyEdB9mNRZfOHY0aYAlisiVzr+CiUWBVZWClg1yZCUXXgG5h0aB08pnDpxjy0wKDJbfZnCQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KVklUqsLtCG68hSL1MazJ4CrNzU0ParRIbL2sJW1xDv6SZvN+nBY0TrsMRn4gyGOxrG02KcO76ZnjvVW9ixkGNDT7v7pj2hV8bwbV6fDNJj69rsRN+Eff8vdKytmRkrhZ2guQ5LFdNpxRcL4lkw6gElk1XXrww4phwTXJFpvZniaxDxgGNAbfgMFLgMPItCIDJMB2dkjEemL9JRagY93eKL84hf7UPINpSzIW262PL/UmQu48oaEn7v74Ls65+DclyiqTVBcAuJKHR3uldzgyjqgZOXycmGbamLuS9t5XmTBzJywxpfxpu1IHAr0v6u6i5k0RDErfMfyAX9PLPgs1w==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Wed, 14 Dec 2022 10:51:42 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 11.12.2022 03:10, Marek Marczykowski-Górecki wrote:
> --- a/xen/drivers/char/xhci-dbc.c
> +++ b/xen/drivers/char/xhci-dbc.c
> @@ -286,39 +286,87 @@ static void *dbc_sys_map_xhc(uint64_t phys, size_t size)
>      return fix_to_virt(FIX_XHCI_END);
>  }
>  
> +static void xhci_bios_handoff(struct dbc *dbc)
> +{
> +    const uint32_t __iomem *xcap;
> +    uint32_t xcap_val;
> +    uint32_t next;
> +    uint32_t id = 0;
> +    const void __iomem *mmio = dbc->xhc_mmio;
> +    const uint32_t __iomem *hccp1 = mmio + 0x10;
> +    const uint32_t LEGACY_ID = 0x1;
> +    int ttl = 48;
> +    int timeout = 10000;
> +
> +    xcap = mmio;
> +    /*
> +     * This is initially an offset to the first capability. All the offsets
> +     * (both in HCCP1 and then next capability pointer) are dword-based.
> +     */
> +    next = (readl(hccp1) & 0xFFFF0000) >> 16;
> +
> +    while ( id != LEGACY_ID && next && ttl-- )
> +    {
> +        xcap += next;
> +        xcap_val = readl(xcap);
> +        id = xcap_val & 0xFF;
> +        next = (xcap_val & 0xFF00) >> 8;
> +    }
> +
> +    if ( id != LEGACY_ID )
> +        return;
> +
> +    xcap_val = readl(xcap);
> +#define XHCI_HC_BIOS_OWNED (1U << 16)
> +#define XHCI_HC_OS_OWNED (1U << 24)
> +    if (xcap_val & XHCI_HC_BIOS_OWNED) {
> +        dbc_error("bios owned\n");
> +        writeb(1, (uint8_t*)xcap + 3);
> +        while ((readl(xcap) & (XHCI_HC_BIOS_OWNED | XHCI_HC_OS_OWNED)) != 
> XHCI_HC_OS_OWNED)
> +        {
> +            cpu_relax();
> +            if (!--timeout)
> +                break;
> +        }
> +        if (!timeout)
> +            dbc_error("handoff timeout\n");
> +        xcap_val = readl(xcap + 1);
> +        xcap_val &= ((0x7 << 1) + (0xff << 5) + (0x7 << 17)); // 
> XHCI_LEGACY_DISABLE_SMI
> +        xcap_val |= (0x7 << 29); // XHCI_LEGACY_SMI_EVENTS
> +        writel(xcap_val, xcap + 1);
> +    }
> +}
> +

Unused new function (introducing a build failure at this point of the series)?

>  static bool __init dbc_init_xhc(struct dbc *dbc)
>  {
>      uint32_t bar0;
>      uint64_t bar1;
>      uint64_t bar_val;
>      uint64_t bar_size;
> -    uint64_t devfn;
> +    unsigned int bus, devfn;
>      uint16_t cmd;
>      size_t xhc_mmio_size;
>  
>      if ( dbc->sbdf.sbdf == 0 )
>      {
> -        /*
> -         * 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++ )
> -        {
> -            pci_sbdf_t sbdf = PCI_SBDF(0, 0, devfn);
> -            uint8_t hdr = pci_conf_read8(sbdf, PCI_HEADER_TYPE);
> -
> -            if ( hdr == 0 || hdr == 0x80 )
> +        for ( bus = 0; bus < 0x100; bus++ )

Hex here and ...

> +            for ( devfn = 0; devfn < 256; devfn++ )

... dec here looks odd. Now that you want to fully iterate segment 0,
may I suggest to move the function closer to ehci-dbgp.c:find_dbgp(),
making use of pci_device_detect() and iterating over busses, slots,
and functions separately?

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.