Re: [linux-scsi] scsi_scan_host will hang up my system!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



crazyrushstar@xxxxxxxxxxxx wrote:
> --- Karen Shaeffer <shaeffer@xxxxxxxxxxxxxxx> 說:
>> On Tue, Sep 19, 2006 at 09:48:46PM -0600, Matthew
>> Wilcox wrote:
>>> Documentation/scsi/scsi_mid_low_api.txt was of
>>> immense help to me.

This document is indeed essential for low-level driver development.
However it doesn't (can't) tell you how to avoid some types of deadlocks.

Crazyrushstar, I can't give specific advise about scsi_scan_host() since
the code I'm maintaining (sbp2) doesn't use it. However I have some
basic suggestions:

 - Consider your driver a layer between Linux' SCSI core (higher level)
and the interconnect software/firmware/hardware, e.g. PCI layer (lower
level). Make sure that you first bring up the lower level, then the
higher level. Vice versa, bring down the higher level before the lower
level on driver shutdown.

 - AFAIU your driver and everything below it has to be fully able to
transfer commands, data and status before it calls scsi_scan_host().

 - Also keep the layer paradigm in mind when you design the locking in
your driver. Watch out for the host lock which the SCSI core will use on
several occasions and which your driver may have to use on some
occasions. (The low-level driver I'm maintaining doesn't touch the host
lock.) A clearly layered design helps to avoid deadlocks.

 - Don't use the scsi_block_requests()/ scsi_unblock_requests() API.
(The code I'm maintaining is using these, and it is a nightmare because
it easily leads into deadlocks. I will rework that driver to not use
these calls anymore.) The scsi_block_requests()/ scsi_unblock_requests()
API manipulates host state on a low level, subverting the SCSI core's
assumptions about host/ target/ LU states. This and similar
manipulations of host/ target/ LU state are better _not_ done in a SCSI
low-level driver.

...
>> I also would purchase the applicable scsi standards.
>> 
>> http://www.t10.org/

The drafts at http://www.t10.org/ftp/t10/drafts/ may suffice too, at
least to get started.

...
> I have google out a link 
> "http://www.mjmwired.net/kernel/Documentation/scsi/scsi_mid_low_api.txt";
...

"Documentation/" is a subdirectory of the Linux kernel source distribution.

Another essential resource are of course the sources themselves. Good
tools to browse the code are Cscope or KScope or LXR:
http://free-electrons.com/community/kernel/lxr

You certainly already read the sources in include/scsi/.
-- 
Stefan Richter
-=====-=-==- =--= =--==
http://arcgraph.de/sr/
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux