qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Sai Pavan Boddu <saipava@xilinx.com>
To: Gerd Hoffmann <kraxel@redhat.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: Laurent Vivier <lvivier@redhat.com>,
	Thomas Huth <thuth@redhat.com>,
	Eduardo Habkost <ehabkost@redhat.com>,
	Sergio Lopez <slp@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Igor Mammedov <imammedo@redhat.com>,
	Richard Henderson <rth@twiddle.net>
Subject: RE: [PATCH v3 02/10] usb/xhci: add include/hw/usb/xhci.h header file
Date: Tue, 20 Oct 2020 13:42:11 +0000	[thread overview]
Message-ID: <BY5PR02MB6772B8E614B51E297D68AA70CA1F0@BY5PR02MB6772.namprd02.prod.outlook.com> (raw)
In-Reply-To: <20201020074844.5304-3-kraxel@redhat.com>

Hi,
> -----Original Message-----
> From: Gerd Hoffmann <kraxel@redhat.com>
> Sent: Tuesday, October 20, 2020 1:19 PM
> To: qemu-devel@nongnu.org
> Cc: Sergio Lopez <slp@redhat.com>; Sai Pavan Boddu <saipava@xilinx.com>;
> Igor Mammedov <imammedo@redhat.com>; Michael S. Tsirkin
> <mst@redhat.com>; Marcel Apfelbaum <marcel.apfelbaum@gmail.com>;
> Paolo Bonzini <pbonzini@redhat.com>; Thomas Huth <thuth@redhat.com>;
> Richard Henderson <rth@twiddle.net>; Gerd Hoffmann <kraxel@redhat.com>;
> Eduardo Habkost <ehabkost@redhat.com>; Laurent Vivier
> <lvivier@redhat.com>
> Subject: [PATCH v3 02/10] usb/xhci: add include/hw/usb/xhci.h header file
> 
> Move a bunch of defines which might be needed outside core xhci code to that
> place.  Add XHCI_ prefixes to avoid name clashes.
> No functional change.
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
[Sai Pavan Boddu] Looks good.

Reviewed-by: Sai Pavan Boddu <sai.pavan.boddu@xilinx.com>

Regards,
Sai Pavan


> ---
>  hw/usb/hcd-xhci-sysbus.h |  1 -
>  hw/usb/hcd-xhci.h        | 22 ++++++----------------
>  include/hw/usb/xhci.h    | 19 +++++++++++++++++++
>  hw/usb/hcd-xhci-nec.c    |  4 ++--
>  hw/usb/hcd-xhci-pci.c    |  4 ++--
>  hw/usb/hcd-xhci-sysbus.c |  4 ++--
>  hw/usb/hcd-xhci.c        | 34 ++++++++++++++++------------------
>  7 files changed, 47 insertions(+), 41 deletions(-)  create mode 100644
> include/hw/usb/xhci.h
> 
> diff --git a/hw/usb/hcd-xhci-sysbus.h b/hw/usb/hcd-xhci-sysbus.h index
> a308753ceb9b..fdfcbbee3bf4 100644
> --- a/hw/usb/hcd-xhci-sysbus.h
> +++ b/hw/usb/hcd-xhci-sysbus.h
> @@ -15,7 +15,6 @@
>  #include "hcd-xhci.h"
>  #include "hw/sysbus.h"
> 
> -#define TYPE_XHCI_SYSBUS "sysbus-xhci"
>  #define XHCI_SYSBUS(obj) \
>      OBJECT_CHECK(XHCISysbusState, (obj), TYPE_XHCI_SYSBUS)
> 
> diff --git a/hw/usb/hcd-xhci.h b/hw/usb/hcd-xhci.h index
> f859a17e73ee..ccf50ae28bed 100644
> --- a/hw/usb/hcd-xhci.h
> +++ b/hw/usb/hcd-xhci.h
> @@ -24,23 +24,13 @@
>  #include "qom/object.h"
> 
>  #include "hw/usb.h"
> +#include "hw/usb/xhci.h"
>  #include "sysemu/dma.h"
> 
> -#define TYPE_XHCI "base-xhci"
> -#define TYPE_NEC_XHCI "nec-usb-xhci"
> -#define TYPE_QEMU_XHCI "qemu-xhci"
> -
>  OBJECT_DECLARE_SIMPLE_TYPE(XHCIState, XHCI)
> 
> -#define MAXPORTS_2 15
> -#define MAXPORTS_3 15
> -
> -#define MAXPORTS (MAXPORTS_2 + MAXPORTS_3) -#define MAXSLOTS 64 -
> #define MAXINTRS 16
> -
>  /* Very pessimistic, let's hope it's enough for all cases */ -#define EV_QUEUE
> (((3 * 24) + 16) * MAXSLOTS)
> +#define EV_QUEUE (((3 * 24) + 16) * XHCI_MAXSLOTS)
> 
>  typedef struct XHCIStreamContext XHCIStreamContext;  typedef struct
> XHCIEPContext XHCIEPContext; @@ -217,15 +207,15 @@ typedef struct
> XHCIState {
>      uint32_t dcbaap_high;
>      uint32_t config;
> 
> -    USBPort  uports[MAX_CONST(MAXPORTS_2, MAXPORTS_3)];
> -    XHCIPort ports[MAXPORTS];
> -    XHCISlot slots[MAXSLOTS];
> +    USBPort  uports[MAX_CONST(XHCI_MAXPORTS_2, XHCI_MAXPORTS_3)];
> +    XHCIPort ports[XHCI_MAXPORTS];
> +    XHCISlot slots[XHCI_MAXSLOTS];
>      uint32_t numports;
> 
>      /* Runtime Registers */
>      int64_t mfindex_start;
>      QEMUTimer *mfwrap_timer;
> -    XHCIInterrupter intr[MAXINTRS];
> +    XHCIInterrupter intr[XHCI_MAXINTRS];
> 
>      XHCIRing cmd_ring;
> 
> diff --git a/include/hw/usb/xhci.h b/include/hw/usb/xhci.h new file mode
> 100644 index 000000000000..dc0c29930dcc
> --- /dev/null
> +++ b/include/hw/usb/xhci.h
> @@ -0,0 +1,19 @@
> +#ifndef HW_USB_XHCI_H
> +#define HW_USB_XHCI_H
> +
> +#define TYPE_XHCI "base-xhci"
> +#define TYPE_NEC_XHCI "nec-usb-xhci"
> +#define TYPE_QEMU_XHCI "qemu-xhci"
> +#define TYPE_XHCI_SYSBUS "sysbus-xhci"
> +
> +#define XHCI_MAXPORTS_2 15
> +#define XHCI_MAXPORTS_3 15
> +
> +#define XHCI_MAXPORTS (XHCI_MAXPORTS_2 + XHCI_MAXPORTS_3) #define
> +XHCI_MAXSLOTS 64 #define XHCI_MAXINTRS 16
> +
> +/* must be power of 2 */
> +#define XHCI_LEN_REGS 0x4000
> +
> +#endif
> diff --git a/hw/usb/hcd-xhci-nec.c b/hw/usb/hcd-xhci-nec.c index
> 2efa6fa0f8af..5707b2cabd16 100644
> --- a/hw/usb/hcd-xhci-nec.c
> +++ b/hw/usb/hcd-xhci-nec.c
> @@ -34,8 +34,8 @@ static Property nec_xhci_properties[] = {
>                      xhci.flags, XHCI_FLAG_SS_FIRST, true),
>      DEFINE_PROP_BIT("force-pcie-endcap", XHCIPciState, xhci.flags,
>                      XHCI_FLAG_FORCE_PCIE_ENDCAP, false),
> -    DEFINE_PROP_UINT32("intrs", XHCIPciState, xhci.numintrs, MAXINTRS),
> -    DEFINE_PROP_UINT32("slots", XHCIPciState, xhci.numslots, MAXSLOTS),
> +    DEFINE_PROP_UINT32("intrs", XHCIPciState, xhci.numintrs,
> XHCI_MAXINTRS),
> +    DEFINE_PROP_UINT32("slots", XHCIPciState, xhci.numslots,
> + XHCI_MAXSLOTS),
>      DEFINE_PROP_END_OF_LIST(),
>  };
> 
> diff --git a/hw/usb/hcd-xhci-pci.c b/hw/usb/hcd-xhci-pci.c index
> a6d746e1da38..b78fcd2bb2d5 100644
> --- a/hw/usb/hcd-xhci-pci.c
> +++ b/hw/usb/hcd-xhci-pci.c
> @@ -240,8 +240,8 @@ static void qemu_xhci_instance_init(Object *obj)
> 
>      s->msi      = ON_OFF_AUTO_OFF;
>      s->msix     = ON_OFF_AUTO_AUTO;
> -    xhci->numintrs = MAXINTRS;
> -    xhci->numslots = MAXSLOTS;
> +    xhci->numintrs = XHCI_MAXINTRS;
> +    xhci->numslots = XHCI_MAXSLOTS;
>      xhci_set_flag(xhci, XHCI_FLAG_SS_FIRST);  }
> 
> diff --git a/hw/usb/hcd-xhci-sysbus.c b/hw/usb/hcd-xhci-sysbus.c index
> 852ca5103b4d..570618467356 100644
> --- a/hw/usb/hcd-xhci-sysbus.c
> +++ b/hw/usb/hcd-xhci-sysbus.c
> @@ -69,8 +69,8 @@ static void xhci_sysbus_instance_init(Object *obj)  }
> 
>  static Property xhci_sysbus_props[] = {
> -    DEFINE_PROP_UINT32("intrs", XHCISysbusState, xhci.numintrs, MAXINTRS),
> -    DEFINE_PROP_UINT32("slots", XHCISysbusState, xhci.numslots, MAXSLOTS),
> +    DEFINE_PROP_UINT32("intrs", XHCISysbusState, xhci.numintrs,
> XHCI_MAXINTRS),
> +    DEFINE_PROP_UINT32("slots", XHCISysbusState, xhci.numslots,
> + XHCI_MAXSLOTS),
>      DEFINE_PROP_END_OF_LIST(),
>  };
> 
> diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index
> 5e8bed9ef90c..79ce5c4be6c4 100644
> --- a/hw/usb/hcd-xhci.c
> +++ b/hw/usb/hcd-xhci.c
> @@ -46,15 +46,13 @@
>  #define TRANSFER_LIMIT  256
> 
>  #define LEN_CAP         0x40
> -#define LEN_OPER        (0x400 + 0x10 * MAXPORTS)
> -#define LEN_RUNTIME     ((MAXINTRS + 1) * 0x20)
> -#define LEN_DOORBELL    ((MAXSLOTS + 1) * 0x20)
> +#define LEN_OPER        (0x400 + 0x10 * XHCI_MAXPORTS)
> +#define LEN_RUNTIME     ((XHCI_MAXINTRS + 1) * 0x20)
> +#define LEN_DOORBELL    ((XHCI_MAXSLOTS + 1) * 0x20)
> 
>  #define OFF_OPER        LEN_CAP
>  #define OFF_RUNTIME     0x1000
>  #define OFF_DOORBELL    0x2000
> -/* must be power of 2 */
> -#define LEN_REGS        0x4000
> 
>  #if (OFF_OPER + LEN_OPER) > OFF_RUNTIME  #error Increase OFF_RUNTIME
> @@ -62,8 +60,8 @@  #if (OFF_RUNTIME + LEN_RUNTIME) > OFF_DOORBELL
> #error Increase OFF_DOORBELL  #endif -#if (OFF_DOORBELL + LEN_DOORBELL)
> > LEN_REGS -# error Increase LEN_REGS
> +#if (OFF_DOORBELL + LEN_DOORBELL) > XHCI_LEN_REGS # error Increase
> +XHCI_LEN_REGS
>  #endif
> 
>  /* bit definitions */
> @@ -3276,11 +3274,11 @@ static void usb_xhci_init(XHCIState *xhci)
> 
>      xhci->usbsts = USBSTS_HCH;
> 
> -    if (xhci->numports_2 > MAXPORTS_2) {
> -        xhci->numports_2 = MAXPORTS_2;
> +    if (xhci->numports_2 > XHCI_MAXPORTS_2) {
> +        xhci->numports_2 = XHCI_MAXPORTS_2;
>      }
> -    if (xhci->numports_3 > MAXPORTS_3) {
> -        xhci->numports_3 = MAXPORTS_3;
> +    if (xhci->numports_3 > XHCI_MAXPORTS_3) {
> +        xhci->numports_3 = XHCI_MAXPORTS_3;
>      }
>      usbports = MAX(xhci->numports_2, xhci->numports_3);
>      xhci->numports = xhci->numports_2 + xhci->numports_3; @@ -3302,7
> +3300,7 @@ static void usb_xhci_init(XHCIState *xhci)
>                  USB_SPEED_MASK_LOW  |
>                  USB_SPEED_MASK_FULL |
>                  USB_SPEED_MASK_HIGH;
> -            assert(i < MAXPORTS);
> +            assert(i < XHCI_MAXPORTS);
>              snprintf(port->name, sizeof(port->name), "usb2 port #%d", i+1);
>              speedmask |= port->speedmask;
>          }
> @@ -3316,7 +3314,7 @@ static void usb_xhci_init(XHCIState *xhci)
>              }
>              port->uport = &xhci->uports[i];
>              port->speedmask = USB_SPEED_MASK_SUPER;
> -            assert(i < MAXPORTS);
> +            assert(i < XHCI_MAXPORTS);
>              snprintf(port->name, sizeof(port->name), "usb3 port #%d", i+1);
>              speedmask |= port->speedmask;
>          }
> @@ -3331,8 +3329,8 @@ static void usb_xhci_realize(DeviceState *dev, Error
> **errp)
> 
>      XHCIState *xhci = XHCI(dev);
> 
> -    if (xhci->numintrs > MAXINTRS) {
> -        xhci->numintrs = MAXINTRS;
> +    if (xhci->numintrs > XHCI_MAXINTRS) {
> +        xhci->numintrs = XHCI_MAXINTRS;
>      }
>      while (xhci->numintrs & (xhci->numintrs - 1)) {   /* ! power of 2 */
>          xhci->numintrs++;
> @@ -3340,8 +3338,8 @@ static void usb_xhci_realize(DeviceState *dev, Error
> **errp)
>      if (xhci->numintrs < 1) {
>          xhci->numintrs = 1;
>      }
> -    if (xhci->numslots > MAXSLOTS) {
> -        xhci->numslots = MAXSLOTS;
> +    if (xhci->numslots > XHCI_MAXSLOTS) {
> +        xhci->numslots = XHCI_MAXSLOTS;
>      }
>      if (xhci->numslots < 1) {
>          xhci->numslots = 1;
> @@ -3355,7 +3353,7 @@ static void usb_xhci_realize(DeviceState *dev, Error
> **errp)
>      usb_xhci_init(xhci);
>      xhci->mfwrap_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,
> xhci_mfwrap_timer, xhci);
> 
> -    memory_region_init(&xhci->mem, OBJECT(dev), "xhci", LEN_REGS);
> +    memory_region_init(&xhci->mem, OBJECT(dev), "xhci", XHCI_LEN_REGS);
>      memory_region_init_io(&xhci->mem_cap, OBJECT(dev), &xhci_cap_ops,
> xhci,
>                            "capabilities", LEN_CAP);
>      memory_region_init_io(&xhci->mem_oper, OBJECT(dev), &xhci_oper_ops,
> xhci,
> --
> 2.27.0



  reply	other threads:[~2020-10-20 13:58 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-20  7:48 [PATCH v3 00/10] microvm: add usb support Gerd Hoffmann
2020-10-20  7:48 ` [PATCH v3 01/10] acpi: add aml builder stubs Gerd Hoffmann
2020-10-20  7:48 ` [PATCH v3 02/10] usb/xhci: add include/hw/usb/xhci.h header file Gerd Hoffmann
2020-10-20 13:42   ` Sai Pavan Boddu [this message]
2020-10-20  7:48 ` [PATCH v3 03/10] usb/xhci: add xhci_sysbus_build_aml() helper Gerd Hoffmann
2020-10-20  7:48 ` [PATCH v3 04/10] usb/xhci: fixup xhci kconfig deps Gerd Hoffmann
2020-10-20 13:55   ` Sai Pavan Boddu
2020-11-20  0:27   ` Bruce Rogers
2020-11-20  6:55     ` Gerd Hoffmann
2020-11-20  7:26     ` Paolo Bonzini
2020-10-20  7:48 ` [PATCH v3 05/10] microvm: add usb support Gerd Hoffmann
2020-10-20  7:48 ` [PATCH v3 06/10] tests/acpi: allow updates for expected data files Gerd Hoffmann
2020-10-20  7:48 ` [PATCH v3 07/10] tests/acpi: add empty tests/data/acpi/microvm/DSDT.{usb, rtc} files Gerd Hoffmann
2020-10-20  7:48 ` [PATCH v3 08/10] tests/acpi: add microvm usb test Gerd Hoffmann
2020-10-20  7:48 ` [PATCH v3 09/10] tests/acpi: add microvm rtc test Gerd Hoffmann
2020-10-20  7:48 ` [PATCH v3 10/10] tests/acpi: update expected data files Gerd Hoffmann

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=BY5PR02MB6772B8E614B51E297D68AA70CA1F0@BY5PR02MB6772.namprd02.prod.outlook.com \
    --to=saipava@xilinx.com \
    --cc=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=slp@redhat.com \
    --cc=thuth@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).