qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 13/35] scsi: move tcq/ndev to SCSIBusOps (now SCSIBusInfo)
Date: Fri, 21 Oct 2011 14:01:19 +0200	[thread overview]
Message-ID: <4EA15F0F.8040006@redhat.com> (raw)
In-Reply-To: <1318503845-11473-14-git-send-email-pbonzini@redhat.com>

Am 13.10.2011 13:03, schrieb Paolo Bonzini:
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  hw/esp.c         |    7 +++++--
>  hw/lsi53c895a.c  |    9 ++++++---
>  hw/scsi-bus.c    |   27 ++++++++++++---------------
>  hw/scsi-disk.c   |    2 +-
>  hw/scsi.h        |   11 +++++------
>  hw/spapr_vscsi.c |    8 +++++---
>  hw/usb-msd.c     |    7 +++++--
>  7 files changed, 39 insertions(+), 32 deletions(-)
> 
> diff --git a/hw/esp.c b/hw/esp.c
> index 697c2c5..d3fb1c6 100644
> --- a/hw/esp.c
> +++ b/hw/esp.c
> @@ -720,7 +720,10 @@ void esp_init(target_phys_addr_t espaddr, int it_shift,
>      *dma_enable = qdev_get_gpio_in(dev, 1);
>  }
>  
> -static const struct SCSIBusOps esp_scsi_ops = {
> +static const struct SCSIBusInfo esp_scsi_info = {
> +    .tcq = false,
> +    .ndev = ESP_MAX_DEVS,
> +
>      .transfer_data = esp_transfer_data,
>      .complete = esp_command_complete,
>      .cancel = esp_request_cancelled
> @@ -740,7 +743,7 @@ static int esp_init1(SysBusDevice *dev)
>  
>      qdev_init_gpio_in(&dev->qdev, esp_gpio_demux, 2);
>  
> -    scsi_bus_new(&s->bus, &dev->qdev, 0, ESP_MAX_DEVS, &esp_scsi_ops);
> +    scsi_bus_new(&s->bus, &dev->qdev, &esp_scsi_info);
>      return scsi_bus_legacy_handle_cmdline(&s->bus);
>  }
>  
> diff --git a/hw/lsi53c895a.c b/hw/lsi53c895a.c
> index e077ec0..4eeb496 100644
> --- a/hw/lsi53c895a.c
> +++ b/hw/lsi53c895a.c
> @@ -1686,7 +1686,7 @@ static void lsi_reg_writeb(LSIState *s, int offset, uint8_t val)
>                  DeviceState *dev;
>                  int id;
>  
> -                for (id = 0; id < s->bus.ndev; id++) {
> +                for (id = 0; id < LSI_MAX_DEVS; id++) {
>                      if (s->bus.devs[id]) {
>                          dev = &s->bus.devs[id]->qdev;
>                          dev->info->reset(dev);
> @@ -2091,7 +2091,10 @@ static int lsi_scsi_uninit(PCIDevice *d)
>      return 0;
>  }
>  
> -static const struct SCSIBusOps lsi_scsi_ops = {
> +static const struct SCSIBusInfo lsi_scsi_info = {
> +    .tcq = true,
> +    .ndev = LSI_MAX_DEVS,
> +
>      .transfer_data = lsi_transfer_data,
>      .complete = lsi_command_complete,
>      .cancel = lsi_request_cancelled
> @@ -2118,7 +2121,7 @@ static int lsi_scsi_init(PCIDevice *dev)
>      pci_register_bar(&s->dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->ram_io);
>      QTAILQ_INIT(&s->queue);
>  
> -    scsi_bus_new(&s->bus, &dev->qdev, 1, LSI_MAX_DEVS, &lsi_scsi_ops);
> +    scsi_bus_new(&s->bus, &dev->qdev, &lsi_scsi_info);
>      if (!dev->qdev.hotplugged) {
>          return scsi_bus_legacy_handle_cmdline(&s->bus);
>      }
> diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
> index 867b1a8..d9d4e18 100644
> --- a/hw/scsi-bus.c
> +++ b/hw/scsi-bus.c
> @@ -24,14 +24,11 @@ static struct BusInfo scsi_bus_info = {
>  static int next_scsi_bus;
>  
>  /* Create a scsi bus, and attach devices to it.  */
> -void scsi_bus_new(SCSIBus *bus, DeviceState *host, int tcq, int ndev,
> -                  const SCSIBusOps *ops)
> +void scsi_bus_new(SCSIBus *bus, DeviceState *host, const SCSIBusInfo *info)
>  {
>      qbus_create_inplace(&bus->qbus, &scsi_bus_info, host, NULL);
>      bus->busnr = next_scsi_bus++;
> -    bus->tcq = tcq;
> -    bus->ndev = ndev;
> -    bus->ops = ops;
> +    bus->info = info;
>      bus->qbus.allow_hotplug = 1;
>  }
>  
> @@ -43,12 +40,12 @@ static int scsi_qdev_init(DeviceState *qdev, DeviceInfo *base)
>      int rc = -1;
>  
>      if (dev->id == -1) {
> -        for (dev->id = 0; dev->id < bus->ndev; dev->id++) {
> +        for (dev->id = 0; dev->id < bus->info->ndev; dev->id++) {
>              if (bus->devs[dev->id] == NULL)
>                  break;
>          }
>      }
> -    if (dev->id >= bus->ndev) {
> +    if (dev->id >= bus->info->ndev) {
>          error_report("bad scsi device id: %d", dev->id);
>          goto err;
>      }
> @@ -120,7 +117,7 @@ int scsi_bus_legacy_handle_cmdline(SCSIBus *bus)
>      int res = 0, unit;
>  
>      loc_push_none(&loc);
> -    for (unit = 0; unit < bus->ndev; unit++) {
> +    for (unit = 0; unit < bus->info->ndev; unit++) {
>          dinfo = drive_get(IF_SCSI, bus->busnr, unit);
>          if (dinfo == NULL) {
>              continue;
> @@ -265,7 +262,7 @@ static bool scsi_target_emulate_inquiry(SCSITargetReq *r)
>          r->buf[2] = 5; /* Version */
>          r->buf[3] = 2 | 0x10; /* HiSup, response data format */
>          r->buf[4] = r->len - 5; /* Additional Length = (Len - 1) - 4 */
> -        r->buf[7] = 0x10 | (r->req.bus->tcq ? 0x02 : 0); /* Sync, TCQ.  */
> +        r->buf[7] = 0x10 | (r->req.bus->info->tcq ? 0x02 : 0); /* Sync, TCQ.  */
>          memcpy(&r->buf[8], "QEMU    ", 8);
>          memcpy(&r->buf[16], "QEMU TARGET     ", 16);
>          strncpy((char *) &r->buf[32], QEMU_VERSION, 4);
> @@ -1062,7 +1059,7 @@ void scsi_req_continue(SCSIRequest *req)
>  void scsi_req_data(SCSIRequest *req, int len)
>  {
>      trace_scsi_req_data(req->dev->id, req->lun, req->tag, len);
> -    req->bus->ops->transfer_data(req, len);
> +    req->bus->info->transfer_data(req, len);
>  }
>  
>  void scsi_req_print(SCSIRequest *req)
> @@ -1121,7 +1118,7 @@ void scsi_req_complete(SCSIRequest *req, int status)
>  
>      scsi_req_ref(req);
>      scsi_req_dequeue(req);
> -    req->bus->ops->complete(req, req->status);
> +    req->bus->info->complete(req, req->status);
>      scsi_req_unref(req);
>  }
>  
> @@ -1132,8 +1129,8 @@ void scsi_req_cancel(SCSIRequest *req)
>      }
>      scsi_req_ref(req);
>      scsi_req_dequeue(req);
> -    if (req->bus->ops->cancel) {
> -        req->bus->ops->cancel(req);
> +    if (req->bus->info->cancel) {
> +        req->bus->info->cancel(req);
>      }
>      scsi_req_unref(req);
>  }
> @@ -1164,13 +1161,13 @@ static char *scsibus_get_fw_dev_path(DeviceState *dev)
>      char path[100];
>      int i;
>  
> -    for (i = 0; i < bus->ndev; i++) {
> +    for (i = 0; i < bus->info->ndev; i++) {
>          if (bus->devs[i] == d) {
>              break;
>          }
>      }
>  
> -    assert(i != bus->ndev);
> +    assert(i != bus->info->ndev);
>  
>      snprintf(path, sizeof(path), "%s@%x", qdev_fw_name(dev), i);
>  
> diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
> index ce71df4..97a7335 100644
> --- a/hw/scsi-disk.c
> +++ b/hw/scsi-disk.c
> @@ -560,7 +560,7 @@ static int scsi_disk_emulate_inquiry(SCSIRequest *req, uint8_t *outbuf)
>      }
>  
>      /* Sync data transfer and TCQ.  */
> -    outbuf[7] = 0x10 | (req->bus->tcq ? 0x02 : 0);
> +    outbuf[7] = 0x10 | (req->bus->info->tcq ? 0x02 : 0);
>      return buflen;
>  }
>  
> diff --git a/hw/scsi.h b/hw/scsi.h
> index 7004aaa..b76c4ee 100644
> --- a/hw/scsi.h
> +++ b/hw/scsi.h
> @@ -9,7 +9,7 @@
>  #define SCSI_CMD_BUF_SIZE     16
>  
>  typedef struct SCSIBus SCSIBus;
> -typedef struct SCSIBusOps SCSIBusOps;
> +typedef struct SCSIBusInfo SCSIBusInfo;
>  typedef struct SCSICommand SCSICommand;
>  typedef struct SCSIDevice SCSIDevice;
>  typedef struct SCSIDeviceInfo SCSIDeviceInfo;
> @@ -97,7 +97,8 @@ struct SCSIDeviceInfo {
>      SCSIReqOps reqops;
>  };
>  
> -struct SCSIBusOps {
> +struct SCSIBusInfo {
> +    int tcq, ndev;
>      void (*transfer_data)(SCSIRequest *req, uint32_t arg);
>      void (*complete)(SCSIRequest *req, uint32_t arg);
>      void (*cancel)(SCSIRequest *req);
> @@ -108,14 +109,12 @@ struct SCSIBus {
>      int busnr;
>  
>      SCSISense unit_attention;
> -    int tcq, ndev;
> -    const SCSIBusOps *ops;
> +    const SCSIBusInfo *info;
>  
>      SCSIDevice *devs[MAX_SCSI_DEVS];
>  };
>  
> -void scsi_bus_new(SCSIBus *bus, DeviceState *host, int tcq, int ndev,
> -                  const SCSIBusOps *ops);
> +void scsi_bus_new(SCSIBus *bus, DeviceState *host, const SCSIBusInfo *info);
>  void scsi_qdev_register(SCSIDeviceInfo *info);
>  
>  static inline SCSIBus *scsi_bus_from_device(SCSIDevice *d)
> diff --git a/hw/spapr_vscsi.c b/hw/spapr_vscsi.c
> index e8426d7..6c5faf2 100644
> --- a/hw/spapr_vscsi.c
> +++ b/hw/spapr_vscsi.c
> @@ -862,7 +862,10 @@ static int vscsi_do_crq(struct VIOsPAPRDevice *dev, uint8_t *crq_data)
>      return 0;
>  }
>  
> -static const struct SCSIBusOps vscsi_scsi_ops = {
> +static const struct SCSIBusInfo vscsi_scsi_info = {
> +    .tcq = true,
> +    .ndev = 63, /* logical unit addressing format */

This is a change from VSCSI_REQ_LIMIT = 24. This may be a bugfix or not
- I don't know the hardware - but it's matter for a separate patch.

Kevin

  reply	other threads:[~2011-10-21 11:58 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-13 11:03 [Qemu-devel] [PULL 00/35] SCSI uber-patch Paolo Bonzini
2011-10-13 11:03 ` [Qemu-devel] [PATCH 01/35] scsi: pass correct sense code for ENOMEDIUM Paolo Bonzini
2011-10-13 11:03 ` [Qemu-devel] [PATCH 02/35] atapi/scsi: unify definitions for MMC Paolo Bonzini
2011-10-13 11:03 ` [Qemu-devel] [PATCH 03/35] atapi: move GESN definitions to scsi-defs.h Paolo Bonzini
2011-10-17 13:41   ` Kevin Wolf
2011-10-17 13:53     ` Paolo Bonzini
2011-10-13 11:03 ` [Qemu-devel] [PATCH 04/35] atapi: fill in AUDIO_CTL page correctly Paolo Bonzini
2011-10-17 14:05   ` Kevin Wolf
2011-10-17 14:04     ` Paolo Bonzini
2011-10-17 14:10       ` Kevin Wolf
2011-10-17 14:22         ` Paolo Bonzini
2011-10-13 11:03 ` [Qemu-devel] [PATCH 05/35] scsi: notify the device when unit attention is reported Paolo Bonzini
2011-10-13 11:03 ` [Qemu-devel] [PATCH 06/35] scsi-disk: report media changed via unit attention sense codes Paolo Bonzini
2011-10-13 11:03 ` [Qemu-devel] [PATCH 07/35] scsi-disk: add stubs for more MMC commands Paolo Bonzini
2011-10-17 14:27   ` Kevin Wolf
2011-10-17 14:28     ` Paolo Bonzini
2011-10-17 14:44       ` Paolo Bonzini
2011-10-13 11:03 ` [Qemu-devel] [PATCH 08/35] scsi-disk: store valid mode pages in a table Paolo Bonzini
2011-10-13 11:03 ` [Qemu-devel] [PATCH 09/35] atapi/scsi-disk: make mode page values coherent between the two Paolo Bonzini
2011-10-17 15:05   ` Kevin Wolf
2011-10-17 15:06     ` Paolo Bonzini
2011-10-13 11:03 ` [Qemu-devel] [PATCH 10/35] scsi-disk: support DVD profile in GET CONFIGURATION Paolo Bonzini
2011-10-17 15:20   ` Kevin Wolf
2011-10-17 15:28     ` Paolo Bonzini
2011-10-13 11:03 ` [Qemu-devel] [PATCH 11/35] scsi-disk: support READ DVD STRUCTURE Paolo Bonzini
2011-10-21 11:42   ` Kevin Wolf
2011-10-21 13:11     ` Paolo Bonzini
2011-10-21 13:12     ` Paolo Bonzini
2011-10-21 13:32       ` Kevin Wolf
2011-10-21 13:36         ` Paolo Bonzini
2011-10-13 11:03 ` [Qemu-devel] [PATCH 12/35] scsi-disk: report media changed via GET EVENT STATUS NOTIFICATION Paolo Bonzini
2011-10-21 11:54   ` Kevin Wolf
2011-10-21 13:08     ` Paolo Bonzini
2011-10-13 11:03 ` [Qemu-devel] [PATCH 13/35] scsi: move tcq/ndev to SCSIBusOps (now SCSIBusInfo) Paolo Bonzini
2011-10-21 12:01   ` Kevin Wolf [this message]
2011-10-21 12:21     ` Paolo Bonzini
2011-10-13 11:03 ` [Qemu-devel] [PATCH 14/35] qdev: switch children device list to QTAILQ Paolo Bonzini
2011-10-13 11:03 ` [Qemu-devel] [PATCH 15/35] scsi: remove devs array from SCSIBus Paolo Bonzini
2011-10-21 12:31   ` Kevin Wolf
2011-10-21 13:03     ` Paolo Bonzini
2011-10-13 11:03 ` [Qemu-devel] [PATCH 16/35] scsi: implement REPORT LUNS for arbitrary LUNs Paolo Bonzini
2011-10-13 11:03 ` [Qemu-devel] [PATCH 17/35] scsi: allow " Paolo Bonzini
2011-10-13 11:03 ` [Qemu-devel] [PATCH 18/35] scsi: add channel to addressing Paolo Bonzini
2011-10-13 11:03 ` [Qemu-devel] [PATCH 19/35] scsi-disk: fail READ CAPACITY if LBA != 0 but PMI == 0 Paolo Bonzini
2011-10-13 11:03 ` [Qemu-devel] [PATCH 20/35] scsi-disk: do not complete requests twice Paolo Bonzini
2011-10-19 13:13   ` Paolo Bonzini
2011-10-13 11:03 ` [Qemu-devel] [PATCH 21/35] scsi-disk: bump SCSIRequest reference count until aio completion runs Paolo Bonzini
2011-10-17 15:37   ` [Qemu-devel] [PATCH v2 " Paolo Bonzini
2011-10-19 13:13     ` Paolo Bonzini
2011-10-13 11:03 ` [Qemu-devel] [PATCH 22/35] scsi-disk: fix retrying a flush Paolo Bonzini
2011-10-13 11:03 ` [Qemu-devel] [PATCH 23/35] scsi-generic: drop SCSIGenericState Paolo Bonzini
2011-10-13 11:03 ` [Qemu-devel] [PATCH 24/35] scsi-generic: remove scsi_req_fixup Paolo Bonzini
2011-10-13 11:03 ` [Qemu-devel] [PATCH 25/35] scsi-generic: check ioctl statuses when SG_IO succeeds Paolo Bonzini
2011-10-13 11:03 ` [Qemu-devel] [PATCH 26/35] scsi-generic: look at host status Paolo Bonzini
2011-10-13 11:03 ` [Qemu-devel] [PATCH 27/35] scsi-generic: snoop READ CAPACITY commands to get block size Paolo Bonzini
2011-10-13 11:03 ` [Qemu-devel] [PATCH 28/35] scsi-disk: do not duplicate BlockDriverState member Paolo Bonzini
2011-10-13 11:03 ` [Qemu-devel] [PATCH 29/35] scsi-disk: remove cluster_size Paolo Bonzini
2011-10-24 15:10   ` Kevin Wolf
2011-10-24 15:36     ` Paolo Bonzini
2011-10-13 11:04 ` [Qemu-devel] [PATCH 30/35] scsi-disk: small clean up to INQUIRY Paolo Bonzini
2011-10-13 11:04 ` [Qemu-devel] [PATCH 31/35] scsi: move max_lba to SCSIDevice Paolo Bonzini
2011-10-13 11:04 ` [Qemu-devel] [PATCH 32/35] scsi: make reqops static const Paolo Bonzini
2011-10-13 11:04 ` [Qemu-devel] [PATCH 33/35] scsi: export scsi_generic_reqops Paolo Bonzini
2011-10-13 11:04 ` [Qemu-devel] [PATCH 34/35] scsi: pass cdb to alloc_req Paolo Bonzini
2011-10-13 11:04 ` [Qemu-devel] [PATCH 35/35] scsi-disk: add scsi-block for device passthrough Paolo Bonzini
2011-10-24 15:28   ` Kevin Wolf
2011-10-24 15:28     ` Paolo Bonzini
2011-10-24 15:38       ` Kevin Wolf

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=4EA15F0F.8040006@redhat.com \
    --to=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.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 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).