Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Madhavi Manchala <madhavi.lscsi@gmail.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: About SCSI INQUIRY command
Date: Tue, 16 Jun 2009 09:11:56 -0400	[thread overview]
Message-ID: <1245157916.3965.4.camel@mulgrave.site> (raw)
In-Reply-To: <97a757510906160033r4245c9aan2eac3d4dc1e45765@mail.gmail.com>

On Tue, 2009-06-16 at 13:03 +0530, Madhavi Manchala wrote:
> Dear All,
> 
> I'm developing a USB class driver for UAS device. I have modified the
> storage driver code as per my custom driver requirements. As a part of
> this, I have registered to the scsi layer through following snippet in
> the storage_probe function. I have seen the code in one of the SAS
> driver's implementation.
> 
> 
> static DECLARE_TRANSPORT_CLASS(host_class,
> 		"uas_host", NULL, NULL, NULL);
> 
> /*
>  * Register transport class with SCSI layer
> */
> error = transport_class_register(&host_class);
> if (error)
> 	goto BadDevice;
> 
> /*
>  * Attach transport template to SCSI layer
>  * which shall be used for executing tasks and
>  * task management functions.
>  */
> transport_template = domain_attach_transport(&transport_functions);
> if (!transport_template)
> 	goto BadDevice;
> 
> /* Associate transport template to SCSI host transport template */
> host->transportt = transport_template;
> host->max_id = ~0;
> host->max_lun = ~0;
> 
> struct scsi_transport_template *
> attach_transport(void)
> {
> 	struct uas_internal *i;
> 
> 	i = kzalloc(sizeof(struct uas_internal), GFP_KERNEL);
> 	if (!i)
> 		return NULL;
> 
> 	i->t.host_attrs.ac.attrs = &i->host_attrs[0];
> 	i->t.host_attrs.ac.class = &host_class.class;
> 	i->t.host_attrs.ac.match = uas_host_match;
> 	transport_container_register(&i->t.host_attrs);
> 	i->t.host_size = sizeof(struct uas_host_attrs);
> 
> 	return &i->t;
> }
> 
> struct scsi_transport_template *
> domain_attach_transport(struct domain_function_template *dft)
> {
> 	struct scsi_transport_template *stt = attach_transport();
> 
> 	if (!stt)
> 		return stt;
> 
> 	i = to_uas_internal(stt);
> 	i->dft = dft;
> 	stt->create_work_queue = 1;
> 	stt->eh_timed_out = uas_scsi_timed_out;
> 	stt->eh_strategy_handler = uas_scsi_recover_host;
> 
> 	return stt;
> }
> 
> When I insert the device I am able to see the disk drive (fdisk -l).
> However, I am continuously getting the following statements
> infinitely. I get the INQUIRY command continuously with "Bad Target
> Number". For normal usb-storage devices I get this message 7 times and
> stops and get the next command like TEST_UNIT_READY.
> 
> <scsi_get_command> invoked!
> <__scsi_get_command> invoked!
> <scsi_dispatch_cmd> invoked!
> <drivers/usb/storage/scsiglue.c> <queuecommand> Entry!
> <usb_stor_show_command> Entry. Command INQUIRY (6 Bytes)!
> Command INQUIRY (6 bytes)
>  12 00 00 00 24 00
> <drivers/usb/storage/scsiglue.c> <queuecommand> Exit!
> *** thread awakened
> Bad target number (1400:0)
> scsi cmd done, result=0x40000
> *** thread sleeping
> <scsi_finish_command> invoked!
> 
> Please suggest me where am I doing wrong. Do I need any other ways to
> register the transport layer to SCSI layer.
> 
> Any suggestion would help me and it would be appreciated.

Since you don't post the code, I have to guess, but I suspect you've
called scsi_scan_host() somewhere ... that would loop around for your
template max_id, which looks like the behaviour you're seeing.  If the
bus is hotplug (like USB or SAS or something) you don't need to call
scsi_scan_host() instead just report each instance you discover inside
your transport class.

James



      reply	other threads:[~2009-06-16 13:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-16  7:33 About SCSI INQUIRY command Madhavi Manchala
2009-06-16 13:11 ` James Bottomley [this message]

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=1245157916.3965.4.camel@mulgrave.site \
    --to=james.bottomley@hansenpartnership.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=madhavi.lscsi@gmail.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