* About SCSI INQUIRY command
@ 2009-06-16 7:33 Madhavi Manchala
2009-06-16 13:11 ` James Bottomley
0 siblings, 1 reply; 2+ messages in thread
From: Madhavi Manchala @ 2009-06-16 7:33 UTC (permalink / raw)
To: linux-scsi
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.
Thanks and Regards,
Madhavi M
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: About SCSI INQUIRY command
2009-06-16 7:33 About SCSI INQUIRY command Madhavi Manchala
@ 2009-06-16 13:11 ` James Bottomley
0 siblings, 0 replies; 2+ messages in thread
From: James Bottomley @ 2009-06-16 13:11 UTC (permalink / raw)
To: Madhavi Manchala; +Cc: linux-scsi
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-06-16 13:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-16 7:33 About SCSI INQUIRY command Madhavi Manchala
2009-06-16 13:11 ` James Bottomley
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox