All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Hannes Reinecke <hare@suse.de>
Cc: qemu-devel@nongnu.org,
	Stefan Haynoczi <stefanha@linux.vnet.ibm.com>,
	kvm@vger.kernel.org, Alexander Graf <agraf@suse.de>
Subject: Re: [PATCH 2/3] scsi: replace 'tag' with 'hba_private' pointer
Date: Fri, 01 Jul 2011 10:27:11 +0200	[thread overview]
Message-ID: <4E0D84DF.7030303@redhat.com> (raw)
In-Reply-To: <1309506172-17762-3-git-send-email-hare@suse.de>

On 07/01/2011 09:42 AM, Hannes Reinecke wrote:
> 'tag' is just an abstraction to identify the command
> from the driver. So we should make that explicit by
> replacing 'tag' with a driver-defined pointer 'hba_private'.
> This saves the lookup for driver handling several commands
> in parallel.

This makes tracing a bit harder to follow.  Perhaps you can keep the 
transport tag (a uint64_t) in the SCSIRequest for debugging purposes?

> Signed-off-by: Hannes Reinecke<hare@suse.de>
> ---
>   hw/esp.c          |    2 +-
>   hw/lsi53c895a.c   |   17 ++++++++---------
>   hw/scsi-bus.c     |   22 +++++++++++-----------
>   hw/scsi-disk.c    |    5 ++---
>   hw/scsi-generic.c |    4 ++--
>   hw/scsi.h         |    8 ++++----
>   hw/spapr_vscsi.c  |   41 ++++++++++++-----------------------------
>   hw/usb-msd.c      |   10 +++++-----
>   trace-events      |   14 +++++++-------
>   9 files changed, 52 insertions(+), 71 deletions(-)
>
> diff --git a/hw/esp.c b/hw/esp.c
> index 6d3f5d2..912ff89 100644
> --- a/hw/esp.c
> +++ b/hw/esp.c
> @@ -244,7 +244,7 @@ static void do_busid_cmd(ESPState *s, uint8_t *buf, uint8_t busid)
>
>       DPRINTF("do_busid_cmd: busid 0x%x\n", busid);
>       lun = busid&  7;
> -    s->current_req = scsi_req_new(s->current_dev, 0, lun);
> +    s->current_req = scsi_req_new(s->current_dev, lun, s);

Might as well pass NULL here.  The hba_private value is basically 
unnecessary when the adapter doesn't support tagged command queuing.

> diff --git a/hw/usb-msd.c b/hw/usb-msd.c
> index 86582cc..4e2ea03 100644
> --- a/hw/usb-msd.c
> +++ b/hw/usb-msd.c
> @@ -216,8 +216,8 @@ static void usb_msd_transfer_data(SCSIRequest *req, uint32_t len)
>       MSDState *s = DO_UPCAST(MSDState, dev.qdev, req->bus->qbus.parent);
>       USBPacket *p = s->packet;
>
> -    if (req->tag != s->tag) {
> -        fprintf(stderr, "usb-msd: Unexpected SCSI Tag 0x%x\n", req->tag);
> +    if (req->hba_private != s) {
> +        fprintf(stderr, "usb-msd: Unexpected SCSI command 0x%p\n", req);
>       }

Same here, just pass NULL and remove these ifs.

Otherwise looks like a very good idea.

Paolo

WARNING: multiple messages have this Message-ID (diff)
From: Paolo Bonzini <pbonzini@redhat.com>
To: Hannes Reinecke <hare@suse.de>
Cc: Alexander Graf <agraf@suse.de>,
	qemu-devel@nongnu.org, kvm@vger.kernel.org,
	Stefan Haynoczi <stefanha@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [PATCH 2/3] scsi: replace 'tag' with 'hba_private' pointer
Date: Fri, 01 Jul 2011 10:27:11 +0200	[thread overview]
Message-ID: <4E0D84DF.7030303@redhat.com> (raw)
In-Reply-To: <1309506172-17762-3-git-send-email-hare@suse.de>

On 07/01/2011 09:42 AM, Hannes Reinecke wrote:
> 'tag' is just an abstraction to identify the command
> from the driver. So we should make that explicit by
> replacing 'tag' with a driver-defined pointer 'hba_private'.
> This saves the lookup for driver handling several commands
> in parallel.

This makes tracing a bit harder to follow.  Perhaps you can keep the 
transport tag (a uint64_t) in the SCSIRequest for debugging purposes?

> Signed-off-by: Hannes Reinecke<hare@suse.de>
> ---
>   hw/esp.c          |    2 +-
>   hw/lsi53c895a.c   |   17 ++++++++---------
>   hw/scsi-bus.c     |   22 +++++++++++-----------
>   hw/scsi-disk.c    |    5 ++---
>   hw/scsi-generic.c |    4 ++--
>   hw/scsi.h         |    8 ++++----
>   hw/spapr_vscsi.c  |   41 ++++++++++++-----------------------------
>   hw/usb-msd.c      |   10 +++++-----
>   trace-events      |   14 +++++++-------
>   9 files changed, 52 insertions(+), 71 deletions(-)
>
> diff --git a/hw/esp.c b/hw/esp.c
> index 6d3f5d2..912ff89 100644
> --- a/hw/esp.c
> +++ b/hw/esp.c
> @@ -244,7 +244,7 @@ static void do_busid_cmd(ESPState *s, uint8_t *buf, uint8_t busid)
>
>       DPRINTF("do_busid_cmd: busid 0x%x\n", busid);
>       lun = busid&  7;
> -    s->current_req = scsi_req_new(s->current_dev, 0, lun);
> +    s->current_req = scsi_req_new(s->current_dev, lun, s);

Might as well pass NULL here.  The hba_private value is basically 
unnecessary when the adapter doesn't support tagged command queuing.

> diff --git a/hw/usb-msd.c b/hw/usb-msd.c
> index 86582cc..4e2ea03 100644
> --- a/hw/usb-msd.c
> +++ b/hw/usb-msd.c
> @@ -216,8 +216,8 @@ static void usb_msd_transfer_data(SCSIRequest *req, uint32_t len)
>       MSDState *s = DO_UPCAST(MSDState, dev.qdev, req->bus->qbus.parent);
>       USBPacket *p = s->packet;
>
> -    if (req->tag != s->tag) {
> -        fprintf(stderr, "usb-msd: Unexpected SCSI Tag 0x%x\n", req->tag);
> +    if (req->hba_private != s) {
> +        fprintf(stderr, "usb-msd: Unexpected SCSI command 0x%p\n", req);
>       }

Same here, just pass NULL and remove these ifs.

Otherwise looks like a very good idea.

Paolo

  parent reply	other threads:[~2011-07-01  8:27 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-01  7:42 [PATCH 0/3] [v4] Megasas HBA emulation Hannes Reinecke
2011-07-01  7:42 ` [Qemu-devel] " Hannes Reinecke
2011-07-01  7:42 ` [PATCH 1/3] iov: Add 'offset' parameter to iov_to_buf() Hannes Reinecke
2011-07-01  7:42   ` [Qemu-devel] " Hannes Reinecke
2011-07-01  7:42   ` [PATCH 2/3] scsi: replace 'tag' with 'hba_private' pointer Hannes Reinecke
2011-07-01  7:42     ` [Qemu-devel] " Hannes Reinecke
2011-07-01  7:42     ` [PATCH 3/3] megasas: LSI Megaraid SAS emulation Hannes Reinecke
2011-07-01  7:42       ` [Qemu-devel] " Hannes Reinecke
2011-07-01  9:16       ` Alexander Graf
2011-07-01  9:16         ` [Qemu-devel] " Alexander Graf
2011-07-03  8:09         ` Michael S. Tsirkin
2011-07-03  8:09           ` [Qemu-devel] " Michael S. Tsirkin
2011-07-01  8:27     ` Paolo Bonzini [this message]
2011-07-01  8:27       ` [Qemu-devel] [PATCH 2/3] scsi: replace 'tag' with 'hba_private' pointer Paolo Bonzini
2011-07-01  8:57       ` Hannes Reinecke
2011-07-01  8:57         ` [Qemu-devel] " Hannes Reinecke
2011-07-01 13:11       ` Hannes Reinecke
2011-07-01 13:11         ` [Qemu-devel] " Hannes Reinecke
2011-07-01 14:33         ` Paolo Bonzini
2011-07-01 14:33           ` [Qemu-devel] " Paolo Bonzini
2011-07-01  8:02   ` [PATCH 1/3] iov: Add 'offset' parameter to iov_to_buf() Alexander Graf
2011-07-01  8:02     ` [Qemu-devel] " Alexander Graf
2011-07-01  8:07     ` Hannes Reinecke
2011-07-01  8:07       ` [Qemu-devel] " Hannes Reinecke
2011-07-01  8:11       ` Alexander Graf
2011-07-01  8:11         ` [Qemu-devel] " Alexander Graf
2011-07-01  8:03   ` Paolo Bonzini
2011-07-01  8:03     ` [Qemu-devel] " Paolo Bonzini
2011-07-01  8:04     ` Hannes Reinecke
2011-07-01  8:04       ` [Qemu-devel] " Hannes Reinecke

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=4E0D84DF.7030303@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=agraf@suse.de \
    --cc=hare@suse.de \
    --cc=kvm@vger.kernel.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@linux.vnet.ibm.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 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.