On 07.06.2022 16:30, Marek Marczykowski-Górecki wrote:
> Reset ports, to force host system to re-enumerate devices. Otheriwse it
> will require the cable to be re-plugged, or will wait in the
> "configuring" state indefinitely.
> 
> Trick and code copied from Linux:
> drivers/usb/early/xhci-dbc.c:xdbc_start()->xdbc_reset_debug_port()
> 
> Signed-off-by: Marek Marczykowski-Górecki <marma...@invisiblethingslab.com>

Just two style nits:

> --- a/xen/drivers/char/xue.c
> +++ b/xen/drivers/char/xue.c
> @@ -60,6 +60,10 @@
>      ((1UL << XUE_PSC_CSC) | (1UL << XUE_PSC_PRC) | (1UL << XUE_PSC_PLC) |    
>   \
>       (1UL << XUE_PSC_CEC))
>  
> +#define     XUE_XHC_EXT_PORT_MAJOR(x)  (((x) >> 24) & 0xff)
> +#define PORT_RESET  (1 << 4)
> +#define PORT_CONNECT  (1 << 0)

Odd multiple blanks on the first of the lines you add.

> @@ -604,6 +608,68 @@ static void xue_init_strings(struct xue *xue, uint32_t 
> *info)
>      info[8] = (4 << 24) | (30 << 16) | (8 << 8) | 6;
>  }
>  
> +static void xue_do_reset_debug_port(struct xue *xue, u32 id, u32 count)
> +{
> +    uint32_t *ops_reg;
> +    uint32_t *portsc;
> +    u32 val, cap_length;
> +    int i;
> +
> +    cap_length = (*(uint32_t*)xue->xhc_mmio) & 0xff;
> +    ops_reg = xue->xhc_mmio + cap_length;
> +
> +    id--;
> +    for ( i = id; i < (id + count); i++ )
> +    {
> +        portsc = ops_reg + 0x100 + i * 0x4;
> +        val = *portsc;
> +        if ( !(val & PORT_CONNECT) )
> +            *portsc = val | PORT_RESET;
> +    }
> +}
> +
> +
> +static void xue_reset_debug_port(struct xue *xue)

Please don't add double blank lines.

Jan

Reply via email to