All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Cao jin <caoj.fnst@cn.fujitsu.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] SCSI bus: fix to incomplete QOMify
Date: Thu, 7 Jan 2016 10:38:22 +0100	[thread overview]
Message-ID: <568E320E.9@redhat.com> (raw)
In-Reply-To: <1452087782-980-1-git-send-email-caoj.fnst@cn.fujitsu.com>



On 06/01/2016 14:43, Cao jin wrote:
> Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
> ---
>  hw/scsi/scsi-bus.c     | 16 ++++++++--------
>  include/hw/scsi/scsi.h |  5 -----
>  2 files changed, 8 insertions(+), 13 deletions(-)
> 
> diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
> index fea0257..1667e01 100644
> --- a/hw/scsi/scsi-bus.c
> +++ b/hw/scsi/scsi-bus.c
> @@ -54,7 +54,7 @@ static void scsi_device_realize(SCSIDevice *s, Error **errp)
>  int scsi_bus_parse_cdb(SCSIDevice *dev, SCSICommand *cmd, uint8_t *buf,
>                         void *hba_private)
>  {
> -    SCSIBus *bus = DO_UPCAST(SCSIBus, qbus, dev->qdev.parent_bus);
> +    SCSIBus *bus = SCSI_BUS(dev->qdev.parent_bus);
>      int rc;
>  
>      assert(cmd->len == 0);
> @@ -145,7 +145,7 @@ static void scsi_dma_restart_cb(void *opaque, int running, RunState state)
>  static void scsi_qdev_realize(DeviceState *qdev, Error **errp)
>  {
>      SCSIDevice *dev = SCSI_DEVICE(qdev);
> -    SCSIBus *bus = DO_UPCAST(SCSIBus, qbus, dev->qdev.parent_bus);
> +    SCSIBus *bus = SCSI_BUS(dev->qdev.parent_bus);
>      SCSIDevice *d;
>      Error *local_err = NULL;
>  
> @@ -553,7 +553,7 @@ SCSIRequest *scsi_req_alloc(const SCSIReqOps *reqops, SCSIDevice *d,
>                              uint32_t tag, uint32_t lun, void *hba_private)
>  {
>      SCSIRequest *req;
> -    SCSIBus *bus = scsi_bus_from_device(d);
> +    SCSIBus *bus = SCSI_BUS(d->qdev.parent_bus);
>      BusState *qbus = BUS(bus);
>      const int memset_off = offsetof(SCSIRequest, sense)
>                             + sizeof(req->sense);
> @@ -578,7 +578,7 @@ SCSIRequest *scsi_req_alloc(const SCSIReqOps *reqops, SCSIDevice *d,
>  SCSIRequest *scsi_req_new(SCSIDevice *d, uint32_t tag, uint32_t lun,
>                            uint8_t *buf, void *hba_private)
>  {
> -    SCSIBus *bus = DO_UPCAST(SCSIBus, qbus, d->qdev.parent_bus);
> +    SCSIBus *bus = SCSI_BUS(d->qdev.parent_bus);
>      const SCSIReqOps *ops;
>      SCSIDeviceClass *sc = SCSI_DEVICE_GET_CLASS(d);
>      SCSIRequest *req;
> @@ -1272,7 +1272,7 @@ int scsi_req_parse_cdb(SCSIDevice *dev, SCSICommand *cmd, uint8_t *buf)
>  
>  void scsi_device_report_change(SCSIDevice *dev, SCSISense sense)
>  {
> -    SCSIBus *bus = DO_UPCAST(SCSIBus, qbus, dev->qdev.parent_bus);
> +    SCSIBus *bus = SCSI_BUS(dev->qdev.parent_bus);
>  
>      scsi_device_set_ua(dev, sense);
>      if (bus->info->change) {
> @@ -1612,7 +1612,7 @@ void scsi_req_unref(SCSIRequest *req)
>      assert(req->refcount > 0);
>      if (--req->refcount == 0) {
>          BusState *qbus = req->dev->qdev.parent_bus;
> -        SCSIBus *bus = DO_UPCAST(SCSIBus, qbus, qbus);
> +        SCSIBus *bus = SCSI_BUS(qbus);
>  
>          if (bus->info->free_request && req->hba_private) {
>              bus->info->free_request(bus, req->hba_private);
> @@ -1896,7 +1896,7 @@ SCSIDevice *scsi_device_find(SCSIBus *bus, int channel, int id, int lun)
>  static void put_scsi_requests(QEMUFile *f, void *pv, size_t size)
>  {
>      SCSIDevice *s = pv;
> -    SCSIBus *bus = DO_UPCAST(SCSIBus, qbus, s->qdev.parent_bus);
> +    SCSIBus *bus = SCSI_BUS(s->qdev.parent_bus);
>      SCSIRequest *req;
>  
>      QTAILQ_FOREACH(req, &s->requests, next) {
> @@ -1921,7 +1921,7 @@ static void put_scsi_requests(QEMUFile *f, void *pv, size_t size)
>  static int get_scsi_requests(QEMUFile *f, void *pv, size_t size)
>  {
>      SCSIDevice *s = pv;
> -    SCSIBus *bus = DO_UPCAST(SCSIBus, qbus, s->qdev.parent_bus);
> +    SCSIBus *bus = SCSI_BUS(s->qdev.parent_bus);
>      int8_t sbyte;
>  
>      while ((sbyte = qemu_get_sbyte(f)) > 0) {
> diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h
> index 1915a73..2ca1d7b 100644
> --- a/include/hw/scsi/scsi.h
> +++ b/include/hw/scsi/scsi.h
> @@ -167,11 +167,6 @@ struct SCSIBus {
>  void scsi_bus_new(SCSIBus *bus, size_t bus_size, DeviceState *host,
>                    const SCSIBusInfo *info, const char *bus_name);
>  
> -static inline SCSIBus *scsi_bus_from_device(SCSIDevice *d)
> -{
> -    return DO_UPCAST(SCSIBus, qbus, d->qdev.parent_bus);
> -}
> -
>  SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk,
>                                        int unit, bool removable, int bootindex,
>                                        const char *serial, Error **errp);
> 

These functions are called in the data path; changes to use SCSI_BUS()
should come with performance data proving that it doesn't slow down I/O.

Paolo

  reply	other threads:[~2016-01-07  9:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-06 13:43 [Qemu-devel] [PATCH] SCSI bus: fix to incomplete QOMify Cao jin
2016-01-07  9:38 ` Paolo Bonzini [this message]
2016-01-07  9:53   ` Cao jin
2016-01-07 12:05     ` Paolo Bonzini
2016-01-11 17:37       ` Markus Armbruster
2016-01-11 17:45         ` Peter Maydell
2016-01-11 17:57         ` Andreas Färber

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=568E320E.9@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=caoj.fnst@cn.fujitsu.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 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.