public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* Some question about usb scsi storage driver
@ 2014-07-04 14:44 loody
       [not found] ` <CANudz+sXH55BJDWf3zy18ERixQWDnqtfv7GHmHPsqqJG9EGyxg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: loody @ 2014-07-04 14:44 UTC (permalink / raw)
  To: linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	SCSI development list

hi all:
when I trace kernel driver source about usb scsi storage driver, I
have below 2 questions:
1. in sd.c -> static int sd_probe(struct device *dev)
    we use below macro to get scsi_device.
           struct scsi_device *sdp = to_scsi_device(dev);

    take usb for example, is usb storage driver allocate memory for
scsi_device then calling sd_probe?
    I am looking for usb_stor_probe1 and usb_stor_probe2 but not find
where it is.

2. at the end of sd.c -> sd_probe, why we call async_schedule_domain like below
      async_schedule_domain(sd_probe_async, sdkp, &scsi_sd_probe_domain);
    to finish scsi device initialization?
    Couldn't we put what sd_probe_async directly in sd_probe?
    is there any benefit to do so?

-- 
Regards,
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Some question about usb scsi storage driver
       [not found] ` <CANudz+sXH55BJDWf3zy18ERixQWDnqtfv7GHmHPsqqJG9EGyxg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2014-07-04 15:47   ` Maurizio Lombardi
  2014-07-04 16:35   ` Alan Stern
  1 sibling, 0 replies; 3+ messages in thread
From: Maurizio Lombardi @ 2014-07-04 15:47 UTC (permalink / raw)
  To: loody, linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	SCSI development list



On 07/04/2014 04:44 PM, loody wrote:
> 
> 2. at the end of sd.c -> sd_probe, why we call async_schedule_domain like below
>       async_schedule_domain(sd_probe_async, sdkp, &scsi_sd_probe_domain);
>     to finish scsi device initialization?
>     Couldn't we put what sd_probe_async directly in sd_probe?
>     is there any benefit to do so?

A possible explanation may be that sd_probe_async() calls sd_spinup_disk(), this function spins up the drive and
may block for some seconds, so it is better to do that asynchronously.

Regards,
Maurizio Lombardi
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Some question about usb scsi storage driver
       [not found] ` <CANudz+sXH55BJDWf3zy18ERixQWDnqtfv7GHmHPsqqJG9EGyxg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  2014-07-04 15:47   ` Maurizio Lombardi
@ 2014-07-04 16:35   ` Alan Stern
  1 sibling, 0 replies; 3+ messages in thread
From: Alan Stern @ 2014-07-04 16:35 UTC (permalink / raw)
  To: loody
  Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	SCSI development list

On Fri, 4 Jul 2014, loody wrote:

> hi all:
> when I trace kernel driver source about usb scsi storage driver, I
> have below 2 questions:
> 1. in sd.c -> static int sd_probe(struct device *dev)
>     we use below macro to get scsi_device.
>            struct scsi_device *sdp = to_scsi_device(dev);
> 
>     take usb for example, is usb storage driver allocate memory for
> scsi_device then calling sd_probe?

No.

>     I am looking for usb_stor_probe1 and usb_stor_probe2 but not find
> where it is.

Because it's not there.  The memory is allocated by 
drivers/scsi/scsi_scan.c:scsi_alloc_sdev().

> 2. at the end of sd.c -> sd_probe, why we call async_schedule_domain like below
>       async_schedule_domain(sd_probe_async, sdkp, &scsi_sd_probe_domain);
>     to finish scsi device initialization?
>     Couldn't we put what sd_probe_async directly in sd_probe?
>     is there any benefit to do so?

Like Maurizio said, the benefit is that the probe routine will return
quickly so that other devices can be probed while the drive spins up.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-07-04 16:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-04 14:44 Some question about usb scsi storage driver loody
     [not found] ` <CANudz+sXH55BJDWf3zy18ERixQWDnqtfv7GHmHPsqqJG9EGyxg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-07-04 15:47   ` Maurizio Lombardi
2014-07-04 16:35   ` Alan Stern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox