Re: [Bug 7026] CD/DVD burning with USB writer doesn't work

2007-02-09 Thread James Bottomley
On Fri, 2007-02-09 at 12:57 -0500, Alan Stern wrote:
> > it's 2 monts that we did discuss this problem.
> > Has the solution integrated into the Linux kernel?
> > 
> > Jörg
> 
> Not yet.  Despited repeated inquiries, I still haven't heard anything back 
> from James regarding the patch that he wrote.
> 
> James, if you prefer I can send that patch to Andrew Morton.  Would that 
> be easier for you?

Actually, the patch I wrote was a block patch, so it goes through Jens'
tree.

I know he had it a while ago ... but I'm afraid there's a bit of a
fundamental breakdown in the usual open source process because the
author (unfortunately me) should be tracking it, and I'm not really ...
if it were my tree, I would probably have just slipped it in to prevent
my forgetting about it, but it isn't.

I added Jens to the cc list, so he can probably tell us what happened to
it.

James


-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Bugme-new] [Bug 7980] New: scsi_wait_scan module should be always available

2007-02-09 Thread Andrew Morton
On Fri, 9 Feb 2007 17:14:12 -0800
[EMAIL PROTECTED] wrote:

> http://bugzilla.kernel.org/show_bug.cgi?id=7980
> 
>Summary: scsi_wait_scan module should be always available
> Kernel Version: 2.6.20
> Status: NEW
>   Severity: normal
>  Owner: [EMAIL PROTECTED]
>  Submitter: [EMAIL PROTECTED]
> 
> 
> The scsi_wait_scan module should be always available, even if scsi was build 
> into the kernel (not as module). E.g. I'm having two scsi-controllers in one 
> machine, one as module and one from which the machine is booting. Currently 
> this does not work, because I'm getting failures for devices of the driver 
> which is build as a module. And because scsi is not build as module, the 
> scsi_wait_scan module is not available.
> 
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Bugme-new] [Bug 7979] New: 2.6.20-rt2: high prio task yields journal commit I/O error

2007-02-09 Thread Andrew Morton
On Fri, 9 Feb 2007 15:45:31 -0800
[EMAIL PROTECTED] wrote:

> http://bugzilla.kernel.org/show_bug.cgi?id=7979
> 
>Summary: 2.6.20-rt2: high prio task yields journal commit I/O
> error

Well you've been having fun there.

I'd say that you've hit two (maybe 1.5) bugs in the scsi code:

- I assume that your high-priority task has starved a scsi kernel thread
  for so long that when that thread finally got control, it decided that
  something had timed out and declared an error.

  Maybe.  Or perhaps the card decided that it hadn't been serviced for so
  long that it declared an error.  It would need someone who is familiar
  with scsi and aic7xxx to determine that.

- In response to the timeout, aic7xxx error handling went and passed crap
  into the scatter/gather unmapping code and the kernel oopsed.


Frankly, I doubt if either of these things (or at least, the first one) are
likely to be fixed in a hurry and I'd suggest that you look at continuing
your work on (say) a SATA or IDE machine, sorry.
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch] Re: SCSI logging sucks

2007-02-09 Thread Chuck Ebbert
Randy Dunlap wrote:
> Patch for Documentation/kernel-parameters.txt is below.
> Want more/different?
>
>
> Is this part of drivers/scsi/Kconfig correct??
>
> """
> config SCSI_LOGGING
>   bool "SCSI logging facility"
>   depends on SCSI
>   ---help---
> This turns on a logging facility that can be used to debug a number
> of SCSI related problems.
>
> If you say Y here, no logging output will appear by default, but you
> can enable logging by saying Y to "/proc file system support" and
> "Sysctl support" below and executing the command
>
> echo "scsi log token [level]" > /proc/scsi/scsi
>
> at boot time after the /proc file system has been mounted.
>
> There are a number of things that can be used for 'token' (you can
> find them in the source: ), and this
> allows you to select the types of information you want, and the
> level allows you to select the level of verbosity.
> """
>
>   
I have no clue whether that works, but looking at scsi.c it would
seem it doesn't.  I only see add-single-device and remove-single-device
in there.
> From: Randy Dunlap <[EMAIL PROTECTED]>
>
> Minor corrections and additions to 'scsi_logging_level', as pointed out
> by Chuck Ebbert.
>
> Signed-off-by: Randy Dunlap <[EMAIL PROTECTED]>
> ---
>  Documentation/kernel-parameters.txt |5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> --- linux-2620-work.orig/Documentation/kernel-parameters.txt
> +++ linux-2620-work/Documentation/kernel-parameters.txt
> @@ -1444,7 +1444,10 @@ and is between 256 and 4096 characters. 
>   Format: ::
>   (flags are integer value)
>  
> - scsi_logging=   [SCSI]
> + scsi_logging_level= [SCSI] a bit mask of logging levels
> + See drivers/scsi/scsi_logging.h for bits.  Also
> + settable via sysctl at dev.scsi.logging_level
> + (/proc/sys/dev/scsi/logging_level).
>  
>   scsi_mod.scan=  [SCSI] sync (default) scans SCSI busses as they are
>   discovered.  async scans them in kernel threads,
>   

Patch looks good. The script from IBM looks even better.

-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Bugme-new] [Bug 7976] New: failure of MATSHITACD-R CW-7502 using ACARD AEC-671X PCI Ultra/W SCSI-2/3 Host Adapter

2007-02-09 Thread Andrew Morton

This appears to be a regression.  Does anyone know what might have caused
it?


On Fri, 9 Feb 2007 11:02:40 -0800
[EMAIL PROTECTED] wrote:

> http://bugzilla.kernel.org/show_bug.cgi?id=7976
> 
>Summary: failure of MATSHITACD-R CW-7502 using ACARD AEC-671X PCI
> Ultra/W SCSI-2/3 Host Adapter
> Kernel Version: 2.6.20
> Status: NEW
>   Severity: normal
>  Owner: [EMAIL PROTECTED]
>  Submitter: [EMAIL PROTECTED]
> 
> 
> Most recent kernel where this bug did *NOT* occur: 2.6.19 from Knoppix 5.1 
> live CD 
> 
> Distribution: Ubuntu feisty
> 
> Hardware Environment: pentium2 350, 
> using a MATSHITACD-R CW-7502 using ACARD AEC-671X PCI Ultra/W SCSI-2/3 Host 
> Adapter
> 
> Software Environment: recompiled with vanilla 2.6.20 kernel from kernel.org
> 
> Problem Description:
> My system has a CR-R MATSHITACD-R CW-7502
> connected using an ACARD AEC-671X PCI Ultra/W SCSI-2/3 Host Adapter
> during boot the CD-R fails to be initialized
> 
> [  104.503513] atp870u: use 32bit DMA mask.
> [  104.503580]ACARD AEC-671X PCI Ultra/W SCSI-2/3 Host Adapter: 0 IO:e400,
> IRQ:11.
> [  105.821671]  ID:  6  MATSHITACD-R   CW-7502  4.10
> [  105.823026]  ID:  7  Host Adapter
> [  105.823182] scsi0 : ACARD AEC-6710/6712/67160 PCI Ultra/W/LVD SCSI-3 
> Adapter
> Driver V2.6+ac 
> [  105.832764] ACPI: PCI Interrupt Link [LNKC] enabled at IRQ 12
> [  105.832850] PCI: setting IRQ 12 as level-triggered
> [  105.832864] ACPI: PCI Interrupt :00:0b.0[A] -> Link [LNKC] -> GSI 12
> (level, low) -> IRQ 12
> [  105.834964] eth0: RealTek RTL8139 at 0xe883, 00:50:fc:8b:8f:a3, IRQ 12
> [  105.835038] eth0:  Identified 8139 chip type 'RTL-8100B/8139D'
> [  105.856371] scsi 0:0:6:0: CD-ROMMATSHITA CD-R   CW-7502   4.10
> PQ: 0 ANSI: 2
> [  105.861521] 8139cp: 10/100 PCI Ethernet driver v1.3 (Mar 22, 2004)
> [  105.940693] hda: max request size: 128KiB
> [  105.985291] sr 0:0:6:0: scsi: Device offlined - not ready after error 
> recovery
> [  106.055645] hda: 33022080 sectors (16907 MB) w/462KiB Cache, 
> CHS=32760/16/63,
> UDMA(33)
> [  106.055885] hda: cache flushes not supported
> [  106.056090]  hda:<3>sr 0:0:6:0: rejecting I/O to offline device
> [  106.056461] sr 0:0:6:0: rejecting I/O to offline device
> [  106.056542] sr0: scsi3-mmc drive: 0x/0x caddy
> [  106.056605] Uniform CD-ROM driver Revision: 3.20
> [  106.056888] sr 0:0:6:0: Attached scsi CD-ROM sr0
> [  106.094129]  hda1 hda2 <<5>sr 0:0:6:0: Attached scsi generic sg0 type 5
> [  106.151516]  hda5 >
> 
> and it is unusable after, attempting to mount it gets this in dmesg:
> 
> [  953.388796] sr 0:0:6:0: rejecting I/O to offline device
> [  953.425672] sr 0:0:6:0: rejecting I/O to offline device
> 
> 
> 
> Steps to reproduce:
> 
> I can get the CD-R to work just fine in Knoppix 5.1 live CD :
> 
> Linux version 2.6.19 ([EMAIL PROTECTED]) (gcc version 4.1.2 20061028 
> (prerelease)
> (Debian 4.1.1-19)) #7 SMP
> ...
> atp870u: use 32bit DMA mask.
>ACARD AEC-671X PCI Ultra/W SCSI-2/3 Host Adapter: 0 IO:e400, IRQ:11.
>  ID: 6 MATSHITACD-R CW-7502 4.10
>  ID: 7 Host Adapter
> scsi0 : ACARD AEC-6710/6712/67160 PCI Ultra/W/LVD SCSI-3 Adapter Driver 
> V2.6+ac
> scsi 0:0:6:0: CD-ROM MATSHITA CD-R CW-7502 4.10 PQ: 0 ANSI: 2
> sr0: scsi3-mmc drive: 8x/8x writer xa/form2 cdda tray
> sr 0:0:6:0: Attached scsi CD-ROM sr0
> 
> --- You are receiving this mail because: ---
> You are on the CC list for the bug, or are watching someone who is.
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] completely convert sg to block layer helpers

2007-02-09 Thread Mike Christie
Mike Christie wrote:
> Mike Christie wrote:
>> Mike Christie wrote:
>>> any missing functionality. I am still testing the patch. I have not
>>> tested some of the older sg interfaces
>> I am pretty sure (100% :)), that I messed up the old interface handling.
>>
>>> -
>>> -static int
>>> -sg_write_xfer(Sg_request * srp)
>>> -{
>>> -   sg_io_hdr_t *hp = &srp->header;
>>> -   Sg_scatter_hold *schp = &srp->data;
>>> -   struct scatterlist *sg = schp->buffer;
>>> -   int num_xfer = 0;
>>> -   int j, k, onum, usglen, ksglen, res;
>>> -   int iovec_count = (int) hp->iovec_count;
>>> -   int dxfer_dir = hp->dxfer_direction;
>>> -   unsigned char *p;
>>> -   unsigned char __user *up;
>>> -   int new_interface = ('\0' == hp->interface_id) ? 0 : 1;
>>> -
>>> -   if ((SG_DXFER_UNKNOWN == dxfer_dir) || (SG_DXFER_TO_DEV == dxfer_dir) ||
>>> -   (SG_DXFER_TO_FROM_DEV == dxfer_dir)) {
>>> -   num_xfer = (int) (new_interface ? hp->dxfer_len : hp->flags);
>>> -   if (schp->bufflen < num_xfer)
>>> -   num_xfer = schp->bufflen;
>> In sg_write_xfer here, for the old interface is it valid to have
>> hp->dxfer_len greater than hp->flags, then have sg_read_oxfer get
>> num_read_xfer that is not equal to hp->dxfer_len?
> 
> Could num_read_xfer would also not be equal to hp->flags, so three
> different values?


Three different values might be a bug, but the code should not oops. I
updated the code so that could support three different sizes if it ever
comes up. It does the same checks for schp->bufflen < num_xfer to handle
some of the problems and blk_rq_copy_user takes a write_len and len
value so if hp->dxfer_len are different hp->flags we copy the right
amount of data. I already changed the uncopy equivalent to copy on what
is passed in sg_read for the old interface.

I put the updated patches here
http://people.redhat.com/mchristi/sg/v3/
they were made against Jens bsg branch.

I will resend them, once I get comments or do more major cleanups and
fixes. But they are there if you want to look at them.
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] completely convert sg to block layer helpers

2007-02-09 Thread Mike Christie
Mike Christie wrote:
> Mike Christie wrote:
>> any missing functionality. I am still testing the patch. I have not
>> tested some of the older sg interfaces
> 
> I am pretty sure (100% :)), that I messed up the old interface handling.
> 
>> -
>> -static int
>> -sg_write_xfer(Sg_request * srp)
>> -{
>> -sg_io_hdr_t *hp = &srp->header;
>> -Sg_scatter_hold *schp = &srp->data;
>> -struct scatterlist *sg = schp->buffer;
>> -int num_xfer = 0;
>> -int j, k, onum, usglen, ksglen, res;
>> -int iovec_count = (int) hp->iovec_count;
>> -int dxfer_dir = hp->dxfer_direction;
>> -unsigned char *p;
>> -unsigned char __user *up;
>> -int new_interface = ('\0' == hp->interface_id) ? 0 : 1;
>> -
>> -if ((SG_DXFER_UNKNOWN == dxfer_dir) || (SG_DXFER_TO_DEV == dxfer_dir) ||
>> -(SG_DXFER_TO_FROM_DEV == dxfer_dir)) {
>> -num_xfer = (int) (new_interface ? hp->dxfer_len : hp->flags);
>> -if (schp->bufflen < num_xfer)
>> -num_xfer = schp->bufflen;
> 
> In sg_write_xfer here, for the old interface is it valid to have
> hp->dxfer_len greater than hp->flags, then have sg_read_oxfer get
> num_read_xfer that is not equal to hp->dxfer_len?

Could num_read_xfer would also not be equal to hp->flags, so three
different values?
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] completely convert sg to block layer helpers

2007-02-09 Thread Mike Christie
Mike Christie wrote:
> any missing functionality. I am still testing the patch. I have not
> tested some of the older sg interfaces

I am pretty sure (100% :)), that I messed up the old interface handling.

> -
> -static int
> -sg_write_xfer(Sg_request * srp)
> -{
> - sg_io_hdr_t *hp = &srp->header;
> - Sg_scatter_hold *schp = &srp->data;
> - struct scatterlist *sg = schp->buffer;
> - int num_xfer = 0;
> - int j, k, onum, usglen, ksglen, res;
> - int iovec_count = (int) hp->iovec_count;
> - int dxfer_dir = hp->dxfer_direction;
> - unsigned char *p;
> - unsigned char __user *up;
> - int new_interface = ('\0' == hp->interface_id) ? 0 : 1;
> -
> - if ((SG_DXFER_UNKNOWN == dxfer_dir) || (SG_DXFER_TO_DEV == dxfer_dir) ||
> - (SG_DXFER_TO_FROM_DEV == dxfer_dir)) {
> - num_xfer = (int) (new_interface ? hp->dxfer_len : hp->flags);
> - if (schp->bufflen < num_xfer)
> - num_xfer = schp->bufflen;

In sg_write_xfer here, for the old interface is it valid to have
hp->dxfer_len greater than hp->flags, then have sg_read_oxfer get
num_read_xfer that is not equal to hp->dxfer_len?

-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/2] convert sg to use block layer helpers

2007-02-09 Thread Mike Christie
Douglas Gilbert wrote:
> Mike Christie wrote:
>> sg duplicates a lot of block layer dio and copying code. The block layer
>> is missing some things like mmap helpers and a way to support sg and
>> st's reserve buffer. The next two patches move move functionality from
>> sg to the block layer so later st and osst can use it, and then coverts
>> sg to use the block layer helper.
>>
>> The goal is to kill scsi_execute_async and friends and covert the ULDs
>> to use the block layer functions directly. This is nice because
>> scsi_execute_async sucks and it actually duplicates block layer code,
>> and in the end the scsi layer does not have to do any bio processing
>> (which irks Jens :)), and we have common code for all ULDs.
>>
>> The patches were made over Jens's bsg branch in his block layer git tree
>> on kernel.org. Sorry for the large patches. The sg conversion patch rips
>> out alot of code duplicated in the block layer and the patch to add some
>> missing functionality to the block layer has conversions to bsg, tgt,
>> etc so git bisect works on it.
> 
> Mike,
> Might I suggest ripping all the scatter gather list
> handling out of the block layer and putting it in
> a library (a bit like libata). That way when the
> block layer paradigm doesn't apply, we don't lose
> all the useful things that have been put in there.

I think this might be a good idea. We want to do something similar for
target requests. For tgt, we allocate a request_queue, and at one point
were using it to queue requests from the host to the userspace code (the
queue was to communicate with the host instead of specific device). We
now only use the queue for scatterlist building, so if you are talking
about making a new struct which holds those q limits that a
request_queue or some other object could use, then making some things
like max_sectors less block layerish, then we might be talking about the
same thing.

But we may not be thinking about the same thing or maybe we are :) When
I saw convert sg to block layer helpers, I do not mean exactly block
layer. The code we are using is based off the request_queue and that
does not need something like a block_device. You could interact with a
request_queue through sysfs or netlink (tgt did both at different points
:)). The queue, as we use it for scatterlist building, has some values
which are blockish like max_sectors, but for values like that we need a
way to for the LLDs to tell upper layers the max size command (any
command) a card can take. Maybe some people would say it is unfortunate
it has to be based on values like sectors which do not make sense for a
command like inquiry and maybe others will say what other values should
we use. I asked about just expressing it in bytes the other day when
asking about transport level commands but did not get any replies/ideas.
When going over the block sg code I noticed we assume 512 byte sectors
in some places so the code needs some changes.

What about moving the queue limits that are used for scatterlist
building: like max_phys_segments, max_hw_segments, dma alignments,
max_sectors, max_segment size, etc to a new struct "struct sg_limits".
The request queue could have one and any other objects like tgt could
use one. The block layer helpers we use would take a sg_limit struct
instead of a request_queue. And the functions like blk_rq_*_user,
blk_rq_map_sg, etc could be renamed to something without the blk prefix
and moved to some new file. Would this be a cleaner abstraction or do
you guys think it would just be a lot of code movement for just a big
name change? And of course max_sectors can be made less block layerish.
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [usb-storage] [PATCH]indistinguishable devices with broken and unbroken firmware #2

2007-02-09 Thread Matthew Dharm
On Fri, Feb 09, 2007 at 10:30:37AM -0500, Alan Stern wrote:
> On Thu, 8 Feb 2007, Greg KH wrote:
> 
> > On Thu, Feb 08, 2007 at 09:04:48AM +0100, Oliver Neukum wrote:
> > > Hi,
> > > 
> > > there's a USB mass storage device which exists in two version. One
> > > reports the correct size and the other does not. Apart from that they
> > > are identical and cannot be told apart. Here's a heuristic based on the
> > > empirical finding that drives have even sizes.
> > > 
> > > The requested changes have been made.
> > > Greg, can this go through your tree?
> > 
> > If the usb-storage people ACK it, I'll be glad to add it to my trees.
> 
> It's okay with me.
> 
> Acked-by: Alan Stern <[EMAIL PROTECTED]>

Looks okay to me too.

Acked-by: Matthew Dharm <[EMAIL PROTECTED]>

Matt

-- 
Matthew Dharm  Home: [EMAIL PROTECTED] 
Maintainer, Linux USB Mass Storage Driver

E:  You run this ship with Windows?!  YOU IDIOT!
L:  Give me a break, it came bundled with the computer!
-- ESR and Lan Solaris
User Friendly, 12/8/1998


pgp85ptVottNv.pgp
Description: PGP signature


Re: [Bug 7026] CD/DVD burning with USB writer doesn't work

2007-02-09 Thread Alan Stern
On Fri, 9 Feb 2007, Joerg Schilling wrote:

> Hi,
> 
> it's 2 monts that we did discuss this problem.
> Has the solution integrated into the Linux kernel?
> 
> Jörg

Not yet.  Despited repeated inquiries, I still haven't heard anything back 
from James regarding the patch that he wrote.

James, if you prefer I can send that patch to Andrew Morton.  Would that 
be easier for you?

Alan Stern

-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] ibmvscsi: allow for dynamic adjustment of server request_limit

2007-02-09 Thread Robert Jennings
The request limit calculations used previously on the client failed to
mirror the state of the server.  Additionally, when a value < 3 was provided
there could be problems setting can_queue and handling abort and reset 
commands.

Signed-off-by: "Robert Jennings" <[EMAIL PROTECTED]>
---
 drivers/scsi/ibmvscsi/ibmvscsi.c |   58 +--
 drivers/scsi/ibmvscsi/ibmvscsi.h |2 +
 2 files changed, 40 insertions(+), 20 deletions(-)

Index: ibmvscsi-23509/drivers/scsi/ibmvscsi/ibmvscsi.c
===
--- ibmvscsi-23509.orig/drivers/scsi/ibmvscsi/ibmvscsi.c
+++ ibmvscsi-23509/drivers/scsi/ibmvscsi/ibmvscsi.c
@@ -85,7 +85,7 @@
 static int max_id = 64;
 static int max_channel = 3;
 static int init_timeout = 5;
-static int max_requests = 50;
+static int max_requests = IBMVSCSI_MAX_REQUESTS_DEFAULT;
 
 #define IBMVSCSI_VERSION "1.5.8"
 
@@ -538,7 +538,8 @@
int request_status;
int rc;
 
-   /* If we have exhausted our request limit, just fail this request.
+   /* If we have exhausted our request limit, just fail this request,
+* unless it is for a reset or abort.
 * Note that there are rare cases involving driver generated requests 
 * (such as task management requests) that the mid layer may think we
 * can handle more requests (can_queue) when we actually can't
@@ -551,9 +552,30 @@
 */
if (request_status < -1)
goto send_error;
-   /* Otherwise, if we have run out of requests */
-   else if (request_status < 0)
-   goto send_busy;
+   /* Otherwise, we may have run out of requests. */
+   /* Abort and reset calls should make it through.
+* Nothing except abort and reset should use the last two
+* slots unless we had two or less to begin with.
+*/
+   else if (request_status < 2 &&
+evt_struct->iu.srp.cmd.opcode != SRP_TSK_MGMT) {
+   /* In the case that we have less than two requests
+* available, check the server limit as a combination
+* of the request limit and the number of requests
+* in-flight (the size of the send list).  If the
+* server limit is greater than 2, return busy so
+* that the last two are reserved for reset and abort.
+*/
+   int server_limit = request_status;
+   struct srp_event_struct *tmp_evt;
+
+   list_for_each_entry(tmp_evt, &hostdata->sent, list) {
+   server_limit++;
+   }
+
+   if (server_limit > 2)
+   goto send_busy;
+   }
}
 
/* Copy the IU into the transfer area */
@@ -572,6 +594,7 @@
 
printk(KERN_ERR "ibmvscsi: send error %d\n",
   rc);
+   atomic_inc(&hostdata->request_limit);
goto send_error;
}
 
@@ -581,7 +604,8 @@
unmap_cmd_data(&evt_struct->iu.srp.cmd, evt_struct, hostdata->dev);
 
free_event_struct(&hostdata->pool, evt_struct);
-   return SCSI_MLQUEUE_HOST_BUSY;
+   atomic_inc(&hostdata->request_limit);
+   return SCSI_MLQUEUE_HOST_BUSY;
 
  send_error:
unmap_cmd_data(&evt_struct->iu.srp.cmd, evt_struct, hostdata->dev);
@@ -831,23 +855,16 @@
 
printk(KERN_INFO "ibmvscsi: SRP_LOGIN succeeded\n");
 
-   if (evt_struct->xfer_iu->srp.login_rsp.req_lim_delta >
-   (max_requests - 2))
-   evt_struct->xfer_iu->srp.login_rsp.req_lim_delta =
-   max_requests - 2;
+   if (evt_struct->xfer_iu->srp.login_rsp.req_lim_delta < 0)
+   printk(KERN_ERR "ibmvscsi: Invalid request_limit.\n");
 
-   /* Now we know what the real request-limit is */
+   /* Now we know what the real request-limit is.
+* This value is set rather than added to request_limit because
+* request_limit could have been set to -1 by this client.
+*/
atomic_set(&hostdata->request_limit,
   evt_struct->xfer_iu->srp.login_rsp.req_lim_delta);
 
-   hostdata->host->can_queue =
-   evt_struct->xfer_iu->srp.login_rsp.req_lim_delta - 2;
-
-   if (hostdata->host->can_queue < 1) {
-   printk(KERN_ERR "ibmvscsi: Invalid request_limit_delta\n");
-   return;
-   }
-
/* If we had any pending I/Os, kick them */
scsi_unblock_requests(hostdata->host);
 
@@ -1483,7 +1500,7 @@
.eh_abort_handler = ibmvscsi_eh_abort_handler,
.eh_device_reset_handler = ibmvscsi_eh_device_reset_handler,
.cmd_per_lun = 16,
-   .can_queue = 1, /* Updated after 

[PATCH 2/2] ibmvscsi: add slave_configure to allow device restart

2007-02-09 Thread Robert Jennings
Adding a slave_configure function for the driver. Now the disks can be
restarted by the scsi mid-layer when the are disconnected and reconnected.

Signed-off-by: "Robert Jennings" <[EMAIL PROTECTED]>
---
 drivers/scsi/ibmvscsi/ibmvscsi.c |   18 ++
 1 file changed, 18 insertions(+)

Index: ibmvscsi-23509/drivers/scsi/ibmvscsi/ibmvscsi.c
===
--- ibmvscsi-23509.orig/drivers/scsi/ibmvscsi/ibmvscsi.c
+++ ibmvscsi-23509/drivers/scsi/ibmvscsi/ibmvscsi.c
@@ -1354,6 +1354,23 @@
return rc;
 }
 
+/**
+ * ibmvscsi_slave_configure: For each slave device that is a disk,
+ * ensure that the "allow_restart" flag is enabled.
+ */
+static int ibmvscsi_slave_configure(struct scsi_device *sdev)
+{
+   struct Scsi_Host *shost = sdev->host;
+   int lock_flags = 0;
+
+   spin_lock_irqsave(shost->host_lock, lock_flags);
+   if (sdev->type == TYPE_DISK)
+   sdev->allow_restart = 1;
+   scsi_adjust_queue_depth(sdev, 0, shost->cmd_per_lun);
+   spin_unlock_irqrestore(shost->host_lock, lock_flags);
+   return 0;
+}
+
 /* 
  * sysfs attributes
  */
@@ -1499,6 +1516,7 @@
.queuecommand = ibmvscsi_queuecommand,
.eh_abort_handler = ibmvscsi_eh_abort_handler,
.eh_device_reset_handler = ibmvscsi_eh_device_reset_handler,
+   .slave_configure = ibmvscsi_slave_configure,
.cmd_per_lun = 16,
.can_queue = IBMVSCSI_MAX_REQUESTS_DEFAULT,
.this_id = -1,
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2] ibmvscsi: dynamic request_limit and device restart

2007-02-09 Thread Robert Jennings
There are two fixes for the ibmvscsi client driver in this set.

- Dynamic request_limit
The request_limit for the driver was not properly reflecting the value on
the server side and could cause can_queue to be set to improper values (-1).
The patch corrects this so that request_limit mirrors the value
on the server and sets can_queue appropriately.

- Device restart
When a drive was removed from the server and then re-added the client
would not be able to use that device.  The device would return a unit
attention and then not ready.  By adding a slave_configure function we
can set the "allow_restart" flag for all disk devices.  Now devices will
resume functioning when they are re-added to the server.

---
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/2] convert sg to use block layer helpers

2007-02-09 Thread Jens Axboe
On Fri, Feb 09 2007, Douglas Gilbert wrote:
> Mike Christie wrote:
> > sg duplicates a lot of block layer dio and copying code. The block layer
> > is missing some things like mmap helpers and a way to support sg and
> > st's reserve buffer. The next two patches move move functionality from
> > sg to the block layer so later st and osst can use it, and then coverts
> > sg to use the block layer helper.
> > 
> > The goal is to kill scsi_execute_async and friends and covert the ULDs
> > to use the block layer functions directly. This is nice because
> > scsi_execute_async sucks and it actually duplicates block layer code,
> > and in the end the scsi layer does not have to do any bio processing
> > (which irks Jens :)), and we have common code for all ULDs.
> > 
> > The patches were made over Jens's bsg branch in his block layer git tree
> > on kernel.org. Sorry for the large patches. The sg conversion patch rips
> > out alot of code duplicated in the block layer and the patch to add some
> > missing functionality to the block layer has conversions to bsg, tgt,
> > etc so git bisect works on it.
> 
> Mike,
> Might I suggest ripping all the scatter gather list
> handling out of the block layer and putting it in
> a library (a bit like libata). That way when the
> block layer paradigm doesn't apply, we don't lose
> all the useful things that have been put in there.

Don't think block layer, think block IO helpers. That's essentially what
large parts of the block layer is.

-- 
Jens Axboe

-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/2] convert sg to use block layer helpers

2007-02-09 Thread Douglas Gilbert
Mike Christie wrote:
> sg duplicates a lot of block layer dio and copying code. The block layer
> is missing some things like mmap helpers and a way to support sg and
> st's reserve buffer. The next two patches move move functionality from
> sg to the block layer so later st and osst can use it, and then coverts
> sg to use the block layer helper.
> 
> The goal is to kill scsi_execute_async and friends and covert the ULDs
> to use the block layer functions directly. This is nice because
> scsi_execute_async sucks and it actually duplicates block layer code,
> and in the end the scsi layer does not have to do any bio processing
> (which irks Jens :)), and we have common code for all ULDs.
> 
> The patches were made over Jens's bsg branch in his block layer git tree
> on kernel.org. Sorry for the large patches. The sg conversion patch rips
> out alot of code duplicated in the block layer and the patch to add some
> missing functionality to the block layer has conversions to bsg, tgt,
> etc so git bisect works on it.

Mike,
Might I suggest ripping all the scatter gather list
handling out of the block layer and putting it in
a library (a bit like libata). That way when the
block layer paradigm doesn't apply, we don't lose
all the useful things that have been put in there.

OSD and char devices (e.g. SSC, SES, wlun, security)
are not block devices in any reasonable sense. It
would be good to get away from "devices" that need
a "/dev/" or even a sysfs representation. A REPORT
LUNS well known LU is only needed during a LU
discovery process on a target. So if that is done
from the user space why do we need a "/dev" or
sysfs entry hanging around clogging up the device
space?

Pushing SCSI pass-through functionality further and
further up the stack diminishes its utility and may
lead to a re-introduction of useful pass-throughs
at a lower level (actually there are some already there).

Think about a SCSI INQUIRY command, it is implicit
"head of queue" which means it should bypass all
the block layer queuing and other impediments. It can
be sent to logical units that don't even exist!
Task management functions should not be queued.
SMP functions should not be queued. And so it goes
on.

Doug Gilbert
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] osst endianness annotations

2007-02-09 Thread Al Viro

Signed-off-by: Al Viro <[EMAIL PROTECTED]>
---
 drivers/scsi/osst.c |8 +++---
 drivers/scsi/osst.h |   68 +-
 2 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index 7d23110..bd6bbf6 100644
--- a/drivers/scsi/osst.c
+++ b/drivers/scsi/osst.c
@@ -521,10 +521,10 @@ static void osst_init_aux(struct osst_tape * STp, int 
frame_type, int frame_seq_
break;
  default: ; /* probably FILL */
}
-   aux->filemark_cnt = ntohl(STp->filemark_cnt);
-   aux->phys_fm = ntohl(0x);
-   aux->last_mark_ppos = ntohl(STp->last_mark_ppos);
-   aux->last_mark_lbn  = ntohl(STp->last_mark_lbn);
+   aux->filemark_cnt = htonl(STp->filemark_cnt);
+   aux->phys_fm = htonl(0x);
+   aux->last_mark_ppos = htonl(STp->last_mark_ppos);
+   aux->last_mark_lbn  = htonl(STp->last_mark_lbn);
 }
 
 /*
diff --git a/drivers/scsi/osst.h b/drivers/scsi/osst.h
index 1e426f5..2cc7b5a 100644
--- a/drivers/scsi/osst.h
+++ b/drivers/scsi/osst.h
@@ -288,11 +288,11 @@ typedef struct {
 #else
 #error "Please fix "
 #endif
-u16 max_speed;  /* Maximum speed supported in 
KBps */
+__be16  max_speed;  /* Maximum speed supported in 
KBps */
 u8  reserved10, reserved11;
-u16 ctl;/* Continuous Transfer Limit 
in blocks */
-u16 speed;  /* Current Speed, in KBps */
-u16 buffer_size;/* Buffer Size, in 512 bytes */
+__be16  ctl;/* Continuous Transfer Limit 
in blocks */
+__be16  speed;  /* Current Speed, in KBps */
+__be16  buffer_size;/* Buffer Size, in 512 bytes */
 u8  reserved18, reserved19;
 } osst_capabilities_page_t;
 
@@ -352,8 +352,8 @@ typedef struct {
u8  reserved2;
u8  density;
u8  reserved3,reserved4;
-   u16 segtrk;
-   u16 trks;
+   __be16  segtrk;
+   __be16  trks;
u8  
reserved5,reserved6,reserved7,reserved8,reserved9,reserved10;
 } osst_tape_paramtr_page_t;
 
@@ -369,18 +369,18 @@ typedef struct {
 typedef struct os_partition_s {
 __u8partition_num;
 __u8par_desc_ver;
-__u16   wrt_pass_cntr;
-__u32   first_frame_ppos;
-__u32   last_frame_ppos;
-__u32   eod_frame_ppos;
+__be16  wrt_pass_cntr;
+__be32  first_frame_ppos;
+__be32  last_frame_ppos;
+__be32  eod_frame_ppos;
 } os_partition_t;
 
 /*
  * DAT entry
  */
 typedef struct os_dat_entry_s {
-__u32   blk_sz;
-__u16   blk_cnt;
+__be32  blk_sz;
+__be16  blk_cnt;
 __u8flags;
 __u8reserved;
 } os_dat_entry_t;
@@ -412,23 +412,23 @@ typedef struct os_dat_s {
  * AUX
  */
 typedef struct os_aux_s {
-__u32   format_id;  /* hardware compability AUX is 
based on */
+__be32  format_id;  /* hardware compability AUX is 
based on */
 charapplication_sig[4]; /* driver used to write this 
media */
-__u32   hdwr;   /* reserved */
-__u32   update_frame_cntr;  /* for configuration frame */
+__be32  hdwr;   /* reserved */
+__be32  update_frame_cntr;  /* for configuration frame */
 __u8frame_type;
 __u8frame_type_reserved;
 __u8reserved_18_19[2];
 os_partition_t  partition;
 __u8reserved_36_43[8];
-__u32   frame_seq_num;
-__u32   logical_blk_num_high;
-__u32   logical_blk_num;
+__be32  frame_seq_num;
+__be32  logical_blk_num_high;
+__be32  logical_blk_num;
 os_dat_tdat;
 __u8reserved188_191[4];
-__u32   filemark_cnt;
-__u32   phys_fm;
-__u32   last_mark_ppos;
+__be32  filemark_cnt;
+__be32  phys_fm;
+__be32  last_mark_ppos;
 __u8reserved204_223[20];
 
 /*
@@ -436,8 +436,8 @@ typedef struct os_aux_s {
  *
  * Linux specific fields:
  */
- __u32  next_mark_ppos; /* when known, points to next 
marker */
-__u32  last_mark_lbn;  /* storing log_blk_num of last 
mark is extends ADR spec */
+ __be32 next_mark_ppos; /* when known, points to next 
marker */
+__be32 last_mark_lbn;  /* storing log_blk_num of last 
mark is extends ADR spec

[PATCH] iscsi endianness annotations

2007-02-09 Thread Al Viro

Signed-off-by: Al Viro <[EMAIL PROTECTED]>
---
 drivers/infiniband/ulp/iser/iser_initiator.c |4 +-
 drivers/scsi/iscsi_tcp.c |2 +-
 drivers/scsi/libiscsi.c  |   40 +++
 include/scsi/iscsi_proto.h   |   46 +++---
 4 files changed, 49 insertions(+), 43 deletions(-)

diff --git a/drivers/infiniband/ulp/iser/iser_initiator.c 
b/drivers/infiniband/ulp/iser/iser_initiator.c
index 0a7d1ab..89e3728 100644
--- a/drivers/infiniband/ulp/iser/iser_initiator.c
+++ b/drivers/infiniband/ulp/iser/iser_initiator.c
@@ -567,7 +567,7 @@ void iser_rcv_completion(struct iser_desc *rx_desc,
opcode = hdr->opcode & ISCSI_OPCODE_MASK;
 
if (opcode == ISCSI_OP_SCSI_CMD_RSP) {
-   itt = hdr->itt & ISCSI_ITT_MASK; /* mask out cid and age bits */
+   itt = get_itt(hdr->itt); /* mask out cid and age bits */
if (!(itt < session->cmds_max))
iser_err("itt can't be matched to task!!!"
 "conn %p opcode %d cmds_max %d itt %d\n",
@@ -625,7 +625,7 @@ void iser_snd_completion(struct iser_desc *tx_desc)
/* this arithmetic is legal by libiscsi dd_data allocation */
mtask = (void *) ((long)(void *)tx_desc -
  sizeof(struct iscsi_mgmt_task));
-   if (mtask->hdr->itt == cpu_to_be32(ISCSI_RESERVED_TAG)) {
+   if (mtask->hdr->itt == RESERVED_ITT) {
struct iscsi_session *session = conn->session;
 
spin_lock(&conn->session->lock);
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index 4376840..8f55e14 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -1375,7 +1375,7 @@ iscsi_tcp_mtask_xmit(struct iscsi_conn *conn, struct 
iscsi_mgmt_task *mtask)
}
 
BUG_ON(tcp_mtask->xmstate != XMSTATE_IDLE);
-   if (mtask->hdr->itt == cpu_to_be32(ISCSI_RESERVED_TAG)) {
+   if (mtask->hdr->itt == RESERVED_ITT) {
struct iscsi_session *session = conn->session;
 
spin_lock_bh(&session->lock);
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index d37048c..7c75771 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -113,8 +113,7 @@ static void iscsi_prep_scsi_cmd_pdu(struct iscsi_cmd_task 
*ctask)
 hdr->opcode = ISCSI_OP_SCSI_CMD;
 hdr->flags = ISCSI_ATTR_SIMPLE;
 int_to_scsilun(sc->device->lun, (struct scsi_lun *)hdr->lun);
-hdr->itt = ctask->itt | (conn->id << ISCSI_CID_SHIFT) |
- (session->age << ISCSI_AGE_SHIFT);
+hdr->itt = build_itt(ctask->itt, conn->id, session->age);
 hdr->data_length = cpu_to_be32(sc->request_bufflen);
 hdr->cmdsn = cpu_to_be32(session->cmdsn);
 session->cmdsn++;
@@ -270,7 +269,7 @@ invalid_datalen:
goto out;
}
 
-   senselen = be16_to_cpu(*(uint16_t *)data);
+   senselen = be16_to_cpu(*(__be16 *)data);
if (datalen < senselen)
goto invalid_datalen;
 
@@ -338,7 +337,7 @@ static int iscsi_handle_reject(struct iscsi_conn *conn, 
struct iscsi_hdr *hdr,
 
if (ntoh24(reject->dlength) >= sizeof(struct iscsi_hdr)) {
memcpy(&rejected_pdu, data, sizeof(struct iscsi_hdr));
-   itt = rejected_pdu.itt & ISCSI_ITT_MASK;
+   itt = get_itt(rejected_pdu.itt);
printk(KERN_ERR "itt 0x%x had pdu (op 0x%x) rejected "
"due to DataDigest error.\n", itt,
rejected_pdu.opcode);
@@ -367,10 +366,10 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct 
iscsi_hdr *hdr,
struct iscsi_mgmt_task *mtask;
uint32_t itt;
 
-   if (hdr->itt != cpu_to_be32(ISCSI_RESERVED_TAG))
-   itt = hdr->itt & ISCSI_ITT_MASK;
+   if (hdr->itt != RESERVED_ITT)
+   itt = get_itt(hdr->itt);
else
-   itt = hdr->itt;
+   itt = ~0U;
 
if (itt < session->cmds_max) {
ctask = session->cmds[itt];
@@ -440,7 +439,7 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct 
iscsi_hdr *hdr,
iscsi_tmf_rsp(conn, hdr);
break;
case ISCSI_OP_NOOP_IN:
-   if (hdr->ttt != ISCSI_RESERVED_TAG || datalen) {
+   if (hdr->ttt != cpu_to_be32(ISCSI_RESERVED_TAG) || 
datalen) {
rc = ISCSI_ERR_PROTO;
break;
}
@@ -457,7 +456,7 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct 
iscsi_hdr *hdr,
rc = ISCSI_ERR_BAD_OPCODE;
break;
}
-   }

Re: [PATCH] aic79xx: use dma_get_required_mask()

2007-02-09 Thread James Bottomley
On Fri, 2007-02-09 at 16:10 +, Christoph Hellwig wrote:
> On Fri, Feb 09, 2007 at 10:55:39AM -0500, James Bottomley wrote:
> > On Thu, 2007-02-08 at 19:40 +, Christoph Hellwig wrote:
> > > The logic here seems odd to me.  Shouldn't we first check
> > > dma_get_required_mask and the do dma_set_mask?
> > 
> > Yes ... I picked up the mask problem, but not that.  And actually
> > there's a missing zero check on one of the dma_set_mask()s.
> > 
> > Does this look like the right patch then?
> 
> This looks functionally correct to me, but there's some cosmetic issues
> left:

OK, try this one.

By the way, when did I suddenly become your patch monkey?

James

>From 095ec6c45d80171b31ee04da62618dcad31b8aef Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <[EMAIL PROTECTED]>
Date: Wed, 7 Feb 2007 09:47:44 +0100
Subject: [SCSI] aic79xx: use dma_get_required_mask()

As originally noted by Frederic Temporelli, the aic79xx supports 64
bit addressing, but the initialization code of the driver is wrong: it
tests the available memory size instead of testing the maximum
available memory address.

This patch uses the correct dma_get_required_mask() macros to
determine the correct addressing method.

Signed-off-by: Hannes Reinecke <[EMAIL PROTECTED]>
Cc: Xavier Bru <[EMAIL PROTECTED]>
CC: Frederic Temporelli <[EMAIL PROTECTED]>

cosmetic fixes
Signed-off-by: James Bottomley <[EMAIL PROTECTED]>
---
 drivers/scsi/aic7xxx/aic79xx_osm.c |9 -
 drivers/scsi/aic7xxx/aic79xx_osm.h |2 --
 drivers/scsi/aic7xxx/aic79xx_osm_pci.c |   20 +---
 3 files changed, 9 insertions(+), 22 deletions(-)

Index: scsi-misc-2.6/drivers/scsi/aic7xxx/aic79xx_osm.c
===
--- scsi-misc-2.6.orig/drivers/scsi/aic7xxx/aic79xx_osm.c   2007-02-09 
09:12:55.0 -0500
+++ scsi-misc-2.6/drivers/scsi/aic7xxx/aic79xx_osm.c2007-02-09 
09:17:36.0 -0500
@@ -1126,15 +1126,6 @@ ahd_linux_register_host(struct ahd_softc
return 0;
 }
 
-uint64_t
-ahd_linux_get_memsize(void)
-{
-   struct sysinfo si;
-
-   si_meminfo(&si);
-   return ((uint64_t)si.totalram << PAGE_SHIFT);
-}
-
 /*
  * Place the SCSI bus into a known state by either resetting it,
  * or forcing transfer negotiations on the next command to any
Index: scsi-misc-2.6/drivers/scsi/aic7xxx/aic79xx_osm.h
===
--- scsi-misc-2.6.orig/drivers/scsi/aic7xxx/aic79xx_osm.h   2007-02-09 
09:12:55.0 -0500
+++ scsi-misc-2.6/drivers/scsi/aic7xxx/aic79xx_osm.h2007-02-09 
09:17:36.0 -0500
@@ -496,8 +496,6 @@ ahd_insb(struct ahd_softc * ahd, long po
 intahd_linux_register_host(struct ahd_softc *,
struct scsi_host_template *);
 
-uint64_t   ahd_linux_get_memsize(void);
-
 /*** Pretty Printing 
**/
 struct info_str {
char *buffer;
Index: scsi-misc-2.6/drivers/scsi/aic7xxx/aic79xx_osm_pci.c
===
--- scsi-misc-2.6.orig/drivers/scsi/aic7xxx/aic79xx_osm_pci.c   2007-02-09 
09:12:55.0 -0500
+++ scsi-misc-2.6/drivers/scsi/aic7xxx/aic79xx_osm_pci.c2007-02-09 
11:21:41.0 -0500
@@ -132,6 +132,7 @@ ahd_linux_pci_dev_probe(struct pci_dev *
struct   ahd_pci_identity *entry;
char*name;
int  error;
+   struct device   *dev = &pdev->dev;
 
pci = pdev;
entry = ahd_find_pci_device(pci);
@@ -161,20 +162,18 @@ ahd_linux_pci_dev_probe(struct pci_dev *
pci_set_master(pdev);
 
if (sizeof(dma_addr_t) > 4) {
-   uint64_t   memsize;
-   const uint64_t mask_39bit = 0x7FULL;
+   const u64 required_mask = dma_get_required_mask(dev);
 
-   memsize = ahd_linux_get_memsize();
-
-   if (memsize >= 0x80ULL
-&& pci_set_dma_mask(pdev, DMA_64BIT_MASK) == 0) {
+   if (required_mask > DMA_39BIT_MASK &&
+   dma_set_mask(dev, DMA_64BIT_MASK) == 0)
ahd->flags |= AHD_64BIT_ADDRESSING;
-   } else if (memsize > 0x8000
-   && pci_set_dma_mask(pdev, mask_39bit) == 0) {
+   else if (required_mask > DMA_32BIT_MASK &&
+dma_set_mask(dev, DMA_39BIT_MASK) == 0)
ahd->flags |= AHD_39BIT_ADDRESSING;
-   }
+   else
+   dma_set_mask(dev, DMA_32BIT_MASK);
} else {
-   pci_set_dma_mask(pdev, DMA_32BIT_MASK);
+   dma_set_mask(dev, DMA_32BIT_MASK);
}
ahd->dev_softc = pci;
error = ahd_pci_config(ahd, entry);


-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More m

Re: [PATCH] aic79xx: use dma_get_required_mask()

2007-02-09 Thread Christoph Hellwig
On Fri, Feb 09, 2007 at 10:55:39AM -0500, James Bottomley wrote:
> On Thu, 2007-02-08 at 19:40 +, Christoph Hellwig wrote:
> > The logic here seems odd to me.  Shouldn't we first check
> > dma_get_required_mask and the do dma_set_mask?
> 
> Yes ... I picked up the mask problem, but not that.  And actually
> there's a missing zero check on one of the dma_set_mask()s.
> 
> Does this look like the right patch then?

This looks functionally correct to me, but there's some cosmetic issues
left:

> Index: scsi-misc-2.6/drivers/scsi/aic7xxx/aic79xx_osm_pci.c
> ===
> --- scsi-misc-2.6.orig/drivers/scsi/aic7xxx/aic79xx_osm_pci.c 2007-02-09 
> 09:12:55.0 -0500
> +++ scsi-misc-2.6/drivers/scsi/aic7xxx/aic79xx_osm_pci.c  2007-02-09 
> 09:21:32.0 -0500
> @@ -132,6 +132,7 @@ ahd_linux_pci_dev_probe(struct pci_dev *
>   struct   ahd_pci_identity *entry;
>   char*name;
>   int  error;
> + struct device   *dev = &pdev->dev;
>  
>   pci = pdev;
>   entry = ahd_find_pci_device(pci);
> @@ -161,20 +162,16 @@ ahd_linux_pci_dev_probe(struct pci_dev *
>   pci_set_master(pdev);
>  
>   if (sizeof(dma_addr_t) > 4) {
> - uint64_t   memsize;
> - const uint64_t mask_39bit = 0x7FULL;
> -
> - memsize = ahd_linux_get_memsize();
> -
> - if (memsize >= 0x80ULL
> -  && pci_set_dma_mask(pdev, DMA_64BIT_MASK) == 0) {
> + if (dma_get_required_mask(dev) > DMA_39BIT_MASK
> + && dma_set_mask(dev, DMA_64BIT_MASK) == 0)
>   ahd->flags |= AHD_64BIT_ADDRESSING;
> - } else if (memsize > 0x8000
> - && pci_set_dma_mask(pdev, mask_39bit) == 0) {
> + else if (dma_get_required_mask(dev) > DMA_32BIT_MASK
> +  && dma_set_mask(dev, DMA_39BIT_MASK) == 0)
>   ahd->flags |= AHD_39BIT_ADDRESSING;
> - }
> + else
> + dma_set_mask(dev, DMA_32BIT_MASK);
>   } else {

I'd rather do the dma_get_required_mask only once, and we we want
&& at the end of the first instead of at the beginning of the second
line.  So this block should look like:

u64 required_mask = dma_get_required_mask(dev);

if (required_mask > DMA_39BIT_MASK &&
dma_set_mask(dev, DMA_64BIT_MASK) == 0)
ahd->flags |= AHD_64BIT_ADDRESSING;
else if (required_mask > DMA_32BIT_MASK &&
 dma_set_mask(dev, DMA_39BIT_MASK) == 0)
ahd->flags |= AHD_39BIT_ADDRESSING;
else
dma_set_mask(dev, DMA_32BIT_MASK);
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] aic79xx: use dma_get_required_mask()

2007-02-09 Thread James Bottomley
On Thu, 2007-02-08 at 19:40 +, Christoph Hellwig wrote:
> The logic here seems odd to me.  Shouldn't we first check
> dma_get_required_mask and the do dma_set_mask?

Yes ... I picked up the mask problem, but not that.  And actually
there's a missing zero check on one of the dma_set_mask()s.

Does this look like the right patch then?

James

>From 095ec6c45d80171b31ee04da62618dcad31b8aef Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <[EMAIL PROTECTED]>
Date: Wed, 7 Feb 2007 09:47:44 +0100
Subject: [SCSI] aic79xx: use dma_get_required_mask()

As originally noted by Frederic Temporelli, the aic79xx supports 64
bit addressing, but the initialization code of the driver is wrong: it
tests the available memory size instead of testing the maximum
available memory address.

This patch uses the correct dma_get_required_mask() macros to
determine the correct addressing method.

Signed-off-by: Hannes Reinecke <[EMAIL PROTECTED]>
Cc: Xavier Bru <[EMAIL PROTECTED]>
CC: Frederic Temporelli <[EMAIL PROTECTED]>

cosmetic fixes
Signed-off-by: James Bottomley <[EMAIL PROTECTED]>
---
 drivers/scsi/aic7xxx/aic79xx_osm.c |9 -
 drivers/scsi/aic7xxx/aic79xx_osm.h |2 --
 drivers/scsi/aic7xxx/aic79xx_osm_pci.c |   20 +---
 3 files changed, 9 insertions(+), 22 deletions(-)

Index: scsi-misc-2.6/drivers/scsi/aic7xxx/aic79xx_osm.c
===
--- scsi-misc-2.6.orig/drivers/scsi/aic7xxx/aic79xx_osm.c   2007-02-09 
09:12:55.0 -0500
+++ scsi-misc-2.6/drivers/scsi/aic7xxx/aic79xx_osm.c2007-02-09 
09:17:36.0 -0500
@@ -1126,15 +1126,6 @@ ahd_linux_register_host(struct ahd_softc
return 0;
 }
 
-uint64_t
-ahd_linux_get_memsize(void)
-{
-   struct sysinfo si;
-
-   si_meminfo(&si);
-   return ((uint64_t)si.totalram << PAGE_SHIFT);
-}
-
 /*
  * Place the SCSI bus into a known state by either resetting it,
  * or forcing transfer negotiations on the next command to any
Index: scsi-misc-2.6/drivers/scsi/aic7xxx/aic79xx_osm.h
===
--- scsi-misc-2.6.orig/drivers/scsi/aic7xxx/aic79xx_osm.h   2007-02-09 
09:12:55.0 -0500
+++ scsi-misc-2.6/drivers/scsi/aic7xxx/aic79xx_osm.h2007-02-09 
09:17:36.0 -0500
@@ -496,8 +496,6 @@ ahd_insb(struct ahd_softc * ahd, long po
 intahd_linux_register_host(struct ahd_softc *,
struct scsi_host_template *);
 
-uint64_t   ahd_linux_get_memsize(void);
-
 /*** Pretty Printing 
**/
 struct info_str {
char *buffer;
Index: scsi-misc-2.6/drivers/scsi/aic7xxx/aic79xx_osm_pci.c
===
--- scsi-misc-2.6.orig/drivers/scsi/aic7xxx/aic79xx_osm_pci.c   2007-02-09 
09:12:55.0 -0500
+++ scsi-misc-2.6/drivers/scsi/aic7xxx/aic79xx_osm_pci.c2007-02-09 
09:21:32.0 -0500
@@ -132,6 +132,7 @@ ahd_linux_pci_dev_probe(struct pci_dev *
struct   ahd_pci_identity *entry;
char*name;
int  error;
+   struct device   *dev = &pdev->dev;
 
pci = pdev;
entry = ahd_find_pci_device(pci);
@@ -161,20 +162,16 @@ ahd_linux_pci_dev_probe(struct pci_dev *
pci_set_master(pdev);
 
if (sizeof(dma_addr_t) > 4) {
-   uint64_t   memsize;
-   const uint64_t mask_39bit = 0x7FULL;
-
-   memsize = ahd_linux_get_memsize();
-
-   if (memsize >= 0x80ULL
-&& pci_set_dma_mask(pdev, DMA_64BIT_MASK) == 0) {
+   if (dma_get_required_mask(dev) > DMA_39BIT_MASK
+   && dma_set_mask(dev, DMA_64BIT_MASK) == 0)
ahd->flags |= AHD_64BIT_ADDRESSING;
-   } else if (memsize > 0x8000
-   && pci_set_dma_mask(pdev, mask_39bit) == 0) {
+   else if (dma_get_required_mask(dev) > DMA_32BIT_MASK
+&& dma_set_mask(dev, DMA_39BIT_MASK) == 0)
ahd->flags |= AHD_39BIT_ADDRESSING;
-   }
+   else
+   dma_set_mask(dev, DMA_32BIT_MASK);
} else {
-   pci_set_dma_mask(pdev, DMA_32BIT_MASK);
+   dma_set_mask(dev, DMA_32BIT_MASK);
}
ahd->dev_softc = pci;
error = ahd_pci_config(ahd, entry);


-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH]indistinguishable devices with broken and unbroken firmware #2

2007-02-09 Thread Alan Stern
On Thu, 8 Feb 2007, Greg KH wrote:

> On Thu, Feb 08, 2007 at 09:04:48AM +0100, Oliver Neukum wrote:
> > Hi,
> > 
> > there's a USB mass storage device which exists in two version. One
> > reports the correct size and the other does not. Apart from that they
> > are identical and cannot be told apart. Here's a heuristic based on the
> > empirical finding that drives have even sizes.
> > 
> > The requested changes have been made.
> > Greg, can this go through your tree?
> 
> If the usb-storage people ACK it, I'll be glad to add it to my trees.

It's okay with me.

Acked-by: Alan Stern <[EMAIL PROTECTED]>

Alan Stern

-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/3] pci: New PCI-E reset API

2007-02-09 Thread Brian King
Matthew,

Any further comments on this?

Thanks,

Brian

Brian King wrote:
> Matthew Wilcox wrote:
>> On Thu, Feb 01, 2007 at 11:30:21AM -0600, Brian King wrote:
>>> Adds a new API which can be used to issue various types
>>> of PCI-E reset, including PCI-E warm reset and PCI-E hot reset.
>>> This is needed for an ipr PCI-E adapter which does not properly
>>> implement BIST. Running BIST on this adapter results in PCI-E
>>> errors. The only reliable reset mechanism that exists on this
>>> hardware is PCI Fundamental reset (warm reset). Since driving
>>> this type of reset is architecture unique, this provides the
>>> necessary hooks for architectures to add this support.
>> A few points ...
>>
>>  - When doing a warm reset, you reset the entire device not just the
>>function (== pci_dev) that gets passed in.  How happy are drivers for
>>the other functions going to be about this?
> 
> I guess I don't see how a warm reset could be issued to a single function
> of a PCI device. I would argue that for a multi-function device, you would
> have to use function level reset. 
> 
> 
>>  - You've missed the requirement:
>>
>> "To allow components to perform internal initialization, system software
>> must wait for at least 100 ms from the end of a Conventional Reset of one
>> or more devices before it is permitted to issue Configuration Requests
>> to those devices."
>>
>>To fix this, we need to call pci_block_user_cfg_access() before
>>calling the pcibios function, then msleep(100) after calling it, then
>>call pci_unblock_user_cfg_access().
> 
> What I've done is to provide a very low-level API that can be used to
> accomplish this. In my implementation, the ipr driver is the one doing
> all the required delays and calling pci_block_user_cfg_access, since it
> already was doing that in order to run BIST on the adapter.
> 
>>  - There's no attempt to support either cold or function-level reset in
>>this patch.
> 
> Correct. I had no requirement to implement this. It can always be added
> if there is a need. A function level reset can be performed by simply
> writing a bit in config space, so *technically* we wouldn't need an
> API to do that for us, but it could certainly be added here.
> 
>> I suspect the Right Way of handling hot/warm/cold reset is going to be
>> some kind of integration with error handling.  This driver understands
>> about slots being different from functions, and has the ability to
>> notify drivers of other functions that a reset is happening.
> 
> Perhaps. It would require a way for the adapter device driver to
> indicate what type of reset(s) will work for a particular pci device.
> It would also require a method for a device driver to invoke a reset,
> which does not currently exist today. I think it would be the first
> case of the device driver invoking pci error recovery, so I'm not sure
> how difficult that would be to do with the current code.
> 
> I actually thought this API might be used by PCI error recovery
> code, since it may need to perform these sorts of functions.
> 
> CC'ing Linas Vepstas since he wrote the powerpc pci recovery code.
> 
> Brian
> 
> 


-- 
Brian King
eServer Storage I/O
IBM Linux Technology Center
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Bug 7026] CD/DVD burning with USB writer doesn't work

2007-02-09 Thread Joerg Schilling
Hi,

it's 2 monts that we did discuss this problem.
Has the solution integrated into the Linux kernel?

Jörg

-- 
 EMail:[EMAIL PROTECTED] (home) Jörg Schilling D-13353 Berlin
   [EMAIL PROTECTED](uni)  
   [EMAIL PROTECTED] (work) Blog: http://schily.blogspot.com/
 URL:  http://cdrecord.berlios.de/old/private/ ftp://ftp.berlios.de/pub/schily
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] mv sg.c features to the block layer

2007-02-09 Thread Mike Christie
This patch moves the reserve buffer, large segment allocations, and mmap
to the block layer. This patches also converts bsg, tgt, cdrom, and
scsi_ioctl.c to the change in the blk_rq_map_user api. A side affect of
coverting tgt to the new api, is that I killed the scsi_cmnd->offset
field which was supposed to be removed before merging but snuck in. It
also kills the tgt bio layer violations.

The mmap code and reserve buffer code is very simple. It should behave
and work like sg where we have one command using the reserve buffer at a
time. If it does not and will affect users, let me know and I will fix.
The bsg and scsi_ioctl code does not use the reserve buffer or mmap
code, and that should behave like it did before, except for the copy
path we allocated multiple pages at a time so we can get very large IOs.

The patches have been lightly tested. I ran sg utils over a block
device. I did not test cdrom, tgt or bsg.

If you guys want me to try and break up the patches to make it easier to
review I will. Then I can resend them in a git bisect friendly way.

Signed-off-by: Mike Christie <[EMAIL PROTECTED]>

diff --git a/block/bsg.c b/block/bsg.c
index e97e3ec..0bc819d 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -321,7 +321,7 @@ bsg_map_hdr(struct bsg_device *bd, struc
dxfer_len = 0;
 
if (dxfer_len) {
-   ret = blk_rq_map_user(q, rq, dxferp, dxfer_len);
+   ret = blk_rq_init_transfer(q, rq, dxferp, dxfer_len);
if (ret) {
dprintk("failed map at %d\n", ret);
blk_put_request(rq);
@@ -460,7 +460,8 @@ static int blk_complete_sgv4_hdr_rq(stru
ret = -EFAULT;
}
 
-   blk_rq_unmap_user(bio);
+   blk_rq_complete_transfer(rq->q, bio, (void __user *)hdr->din_xferp,
+hdr->din_xfer_len);
blk_put_request(rq);
 
return ret;
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c
index 45bbf8b..d1b9799 100644
--- a/block/ll_rw_blk.c
+++ b/block/ll_rw_blk.c
@@ -2314,138 +2314,456 @@ void blk_insert_request(request_queue_t 
 
 EXPORT_SYMBOL(blk_insert_request);
 
-static int __blk_rq_unmap_user(struct bio *bio)
+static void free_reserve_buf(struct request_queue *q)
 {
-   int ret = 0;
+   struct blk_reserve_buf *rbuf = q->reserve_buf;
+   struct scatterlist *sg;
+   int i;
+
+   for (i = 0; i < rbuf->sg_count; i++) {
+   sg = &rbuf->sg[i];
+   if (sg->page)
+   __free_pages(sg->page, get_order(sg->length));
+   }
+
+   kfree(rbuf->sg);
+   kfree(rbuf);
+   q->reserve_buf = NULL;
+}
+
+/**
+ * blk_queue_free_reserve_buf - free reserve buffer
+ * @q: the request queue for the device
+ *
+ * It is the responsibility of the caller to make sure it is
+ * no longer processing requests that may be using the reserved
+ * buffer.
+ **/
+int blk_queue_free_reserve_buf(request_queue_t *q)
+{
+   if (!q->reserve_buf)
+   return -EINVAL;
+
+   if (test_and_set_bit(QUEUE_FLAG_RESERVE_USED, &q->queue_flags))
+   return -EBUSY;
 
+   free_reserve_buf(q);
+   clear_bit(QUEUE_FLAG_RESERVE_USED, &q->queue_flags);
+   return 0;
+}
+EXPORT_SYMBOL(blk_queue_free_reserve_buf);
+
+/**
+ * blk_queue_alloc_reserve_buf - allocate a buffer for pass through
+ * @q: the request queue for the device
+ * @buf_size: size of reserve buffer to allocate
+ *
+ * This is very simple for now. It is copied from sg.c because it is only
+ * meant to support what sg had supported.
+ **/
+int blk_queue_alloc_reserve_buf(request_queue_t *q, unsigned long buf_size)
+{
+   struct blk_reserve_buf *rbuf;
+   struct page *pg;
+   struct scatterlist *sg;
+   int order, i, remainder, allocated;
+   unsigned int segment_size;
+
+   if (q->reserve_buf)
+   return -EEXIST;
+
+   if (test_and_set_bit(QUEUE_FLAG_RESERVE_USED, &q->queue_flags))
+   return -EBUSY;
+
+   rbuf = kzalloc(sizeof(*rbuf), GFP_KERNEL);
+   if (!rbuf)
+   goto clear_use;
+   q->reserve_buf = rbuf;
+   rbuf->buf_size = buf_size;
+   rbuf->sg_count = min(q->max_phys_segments, q->max_hw_segments);
+
+   rbuf->sg = kzalloc(rbuf->sg_count * sizeof(struct scatterlist),
+ GFP_KERNEL);
+   if (!rbuf->sg)
+   goto free_buf;
+
+   segment_size = bio_estimate_max_segment_size(q);
+   for (i = 0, remainder = buf_size;
+(remainder > 0) && (i < rbuf->sg_count);
+ ++i, remainder -= allocated) {
+   unsigned int requested_size;
+
+   sg = &rbuf->sg[i];
+
+   requested_size = remainder;
+   if (requested_size > segment_size)
+   requested_size = segment_size;
+
+   pg = bio_alloc_pages(q, requested_size, &order);
+   if (!pg)
+   goto free_buf;

[PATCH 2/2] completely convert sg to block layer helpers

2007-02-09 Thread Mike Christie
This patch converts sg to the block layer helpers. There should not be
any missing functionality. I am still testing the patch. I have not
tested some of the older sg interfaces and the sg_iovec path.

I switched the DIO default to on, but I will change that back for the
final patch if you guys want. I found one bug (in this patch and the old
sg.c) where interupting a command or closing a device while a command
was doing DIO can result in sleeping from invalid errors (sg_cmd_done
runs from a softirq, but dio unmapping needs process context).

Signed-off-by: Mike Christie <[EMAIL PROTECTED]>


diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 81e3bc7..706e57b 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -66,8 +66,7 @@ static int sg_proc_init(void);
 static void sg_proc_cleanup(void);
 #endif
 
-#define SG_ALLOW_DIO_DEF 0
-#define SG_ALLOW_DIO_CODE /* compile out by commenting this define */
+#define SG_ALLOW_DIO_DEF 1
 
 #define SG_MAX_DEVS 32768
 
@@ -94,9 +93,6 @@ int sg_big_buff = SG_DEF_RESERVED_SIZE;
 static int def_reserved_size = -1; /* picks up init parameter */
 static int sg_allow_dio = SG_ALLOW_DIO_DEF;
 
-static int scatter_elem_sz = SG_SCATTER_SZ;
-static int scatter_elem_sz_prev = SG_SCATTER_SZ;
-
 #define SG_SECTOR_SZ 512
 #define SG_SECTOR_MSK (SG_SECTOR_SZ - 1)
 
@@ -115,11 +111,7 @@ static struct class_interface sg_interfa
 
 typedef struct sg_scatter_hold { /* holding area for scsi scatter gather info 
*/
unsigned short k_use_sg; /* Count of kernel scatter-gather pieces */
-   unsigned short sglist_len; /* size of malloc'd scatter-gather list ++ */
unsigned bufflen;   /* Size of (aggregate) data buffer */
-   unsigned b_malloc_len;  /* actual len malloc'ed in buffer */
-   struct scatterlist *buffer;/* scatter list */
-   char dio_in_use;/* 0->indirect IO (or mmap), 1->dio */
unsigned char cmd_opcode; /* first byte of command */
 } Sg_scatter_hold;
 
@@ -132,6 +124,8 @@ typedef struct sg_request { /* SG_MAX_QU
Sg_scatter_hold data;   /* hold buffer, perhaps scatter list */
sg_io_hdr_t header; /* scsi command+info, see  */
unsigned char sense_b[SCSI_SENSE_BUFFERSIZE];
+   struct request *request;
+   struct bio *bio;/* ptr to bio for later unmapping */
char res_used;  /* 1 -> using reserve buffer, 0 -> not ... */
char orphan;/* 1 -> drop on sight, 0 -> normal */
char sg_io_owned;   /* 1 -> packet belongs to SG_IO */
@@ -146,7 +140,6 @@ typedef struct sg_fd {  /* holds the sta
int timeout;/* defaults to SG_DEFAULT_TIMEOUT  */
int timeout_user;   /* defaults to SG_DEFAULT_TIMEOUT_USER */
Sg_scatter_hold reserve;/* buffer held for this file descriptor 
*/
-   unsigned save_scat_len; /* original length of trunc. scat. element */
Sg_request *headrp; /* head of request slist, NULL->empty */
struct fasync_struct *async_qp; /* used by asynchronous notification */
Sg_request req_arr[SG_MAX_QUEUE];   /* used as singly-linked list */
@@ -156,6 +149,7 @@ typedef struct sg_fd {  /* holds the sta
char cmd_q; /* 1 -> allow command queuing, 0 -> don't */
char next_cmd_len;  /* 0 -> automatic (def), >0 -> use on next 
write() */
char keep_orphan;   /* 0 -> drop orphan (def), 1 -> keep for read() 
*/
+   struct request *mmap_rq;/* request used for mmap */
char mmap_called;   /* 0 -> mmap() never called on this fd */
 } Sg_fd;
 
@@ -173,38 +167,24 @@ typedef struct sg_device { /* holds the 
 
 static int sg_fasync(int fd, struct file *filp, int mode);
 /* tasklet or soft irq callback */
-static void sg_cmd_done(void *data, char *sense, int result, int resid);
-static int sg_start_req(Sg_request * srp);
+static void sg_cmd_done(struct request *rq, int uptodate);
+static int sg_setup_req(Sg_request * srp);
 static void sg_finish_rem_req(Sg_request * srp);
-static int sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int 
buff_size);
-static int sg_build_sgat(Sg_scatter_hold * schp, const Sg_fd * sfp,
-int tablesize);
 static ssize_t sg_new_read(Sg_fd * sfp, char __user *buf, size_t count,
   Sg_request * srp);
 static ssize_t sg_new_write(Sg_fd * sfp, const char __user *buf, size_t count,
int blocking, int read_only, Sg_request ** o_srp);
 static int sg_common_write(Sg_fd * sfp, Sg_request * srp,
   unsigned char *cmnd, int timeout, int blocking);
-static int sg_u_iovec(sg_io_hdr_t * hp, int sg_num, int ind,
- int wr_xf, int *countp, unsigned char __user **up);
-static int sg_write_xfer(Sg_request * srp);
 static int sg_read_xfer(Sg_request * srp);
-static int sg_read_oxfer(Sg_request * srp, char __user *outp, int 
num_read_xfer);
-static void sg_remove_

[PATCH 0/2] convert sg to use block layer helpers

2007-02-09 Thread Mike Christie
sg duplicates a lot of block layer dio and copying code. The block layer
is missing some things like mmap helpers and a way to support sg and
st's reserve buffer. The next two patches move move functionality from
sg to the block layer so later st and osst can use it, and then coverts
sg to use the block layer helper.

The goal is to kill scsi_execute_async and friends and covert the ULDs
to use the block layer functions directly. This is nice because
scsi_execute_async sucks and it actually duplicates block layer code,
and in the end the scsi layer does not have to do any bio processing
(which irks Jens :)), and we have common code for all ULDs.

The patches were made over Jens's bsg branch in his block layer git tree
on kernel.org. Sorry for the large patches. The sg conversion patch rips
out alot of code duplicated in the block layer and the patch to add some
missing functionality to the block layer has conversions to bsg, tgt,
etc so git bisect works on it.

-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] zfcp: removed wrong comment

2007-02-09 Thread Swen Schillig
commit 07a105136f07f0cf1b476383e43033b8a65e13ff
Author: Swen Schillig <[EMAIL PROTECTED]>
Date:   Fri Feb 9 09:58:09 2007 +0100

removed wrong comment

Signed-off-by: Swen Schillig <[EMAIL PROTECTED]>

---
diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c
index cbe47a2..0cc8603 100644
--- a/drivers/s390/scsi/zfcp_erp.c
+++ b/drivers/s390/scsi/zfcp_erp.c
@@ -838,8 +838,6 @@ zfcp_erp_action_exists(struct zfcp_erp_action *erp_action)
  * and does appropriate preparations (dismiss fsf request, ...)
  *
  * locks:  called under erp_lock (disabled interrupts)
- *
- * returns:0
  */
 static void
 zfcp_erp_strategy_check_fsfreq(struct zfcp_erp_action *erp_action)
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] zfcp: use of uninitialized variable

2007-02-09 Thread Swen Schillig
commit 988d955c3314336d716a9208f3d565b06f262e07
Author: Swen Schillig <[EMAIL PROTECTED]>
Date:   Fri Feb 9 09:40:11 2007 +0100

Use of uninitialized variable.
ERP action might not be finished accordingly.

Signed-off-by: Swen Schillig <[EMAIL PROTECTED]>

---
diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c
index c88babc..cbe47a2 100644
--- a/drivers/s390/scsi/zfcp_erp.c
+++ b/drivers/s390/scsi/zfcp_erp.c
@@ -841,29 +841,27 @@ zfcp_erp_action_exists(struct zfcp_erp_action *erp_action)
  *
  * returns:0
  */
-static int
+static void
 zfcp_erp_strategy_check_fsfreq(struct zfcp_erp_action *erp_action)
 {
-   int retval = 0;
-   struct zfcp_fsf_req *fsf_req = NULL;
struct zfcp_adapter *adapter = erp_action->adapter;
 
if (erp_action->fsf_req) {
/* take lock to ensure that request is not deleted meanwhile */
spin_lock(&adapter->req_list_lock);
-   if ((!zfcp_reqlist_ismember(adapter,
-   erp_action->fsf_req->req_id)) &&
-   (fsf_req->erp_action == erp_action)) {
+   if (zfcp_reqlist_ismember(adapter,
+   erp_action->fsf_req->req_id)) {
/* fsf_req still exists */
debug_text_event(adapter->erp_dbf, 3, "a_ca_req");
-   debug_event(adapter->erp_dbf, 3, &fsf_req,
+   debug_event(adapter->erp_dbf, 3, &erp_action->fsf_req,
sizeof (unsigned long));
/* dismiss fsf_req of timed out/dismissed erp_action */
if (erp_action->status & (ZFCP_STATUS_ERP_DISMISSED |
  ZFCP_STATUS_ERP_TIMEDOUT)) {
debug_text_event(adapter->erp_dbf, 3,
 "a_ca_disreq");
-   fsf_req->status |= ZFCP_STATUS_FSFREQ_DISMISSED;
+   erp_action->fsf_req->status |= 
+   ZFCP_STATUS_FSFREQ_DISMISSED;
}
if (erp_action->status & ZFCP_STATUS_ERP_TIMEDOUT) {
ZFCP_LOG_NORMAL("error: erp step timed out "
@@ -876,11 +874,11 @@ zfcp_erp_strategy_check_fsfreq(struct zfcp_erp_action 
*erp_action)
 * then keep it running asynchronously and don't mess
 * with the association of erp_action and fsf_req.
 */
-   if (fsf_req->status & (ZFCP_STATUS_FSFREQ_COMPLETED |
+   if (erp_action->fsf_req->status & 
+   (ZFCP_STATUS_FSFREQ_COMPLETED |
   ZFCP_STATUS_FSFREQ_DISMISSED)) {
/* forget about association between fsf_req
   and erp_action */
-   fsf_req->erp_action = NULL;
erp_action->fsf_req = NULL;
}
} else {
@@ -894,8 +892,6 @@ zfcp_erp_strategy_check_fsfreq(struct zfcp_erp_action 
*erp_action)
spin_unlock(&adapter->req_list_lock);
} else
debug_text_event(adapter->erp_dbf, 3, "a_ca_noreq");
-
-   return retval;
 }
 
 /**
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] SCSI: Make error printing more user friendly

2007-02-09 Thread Martin K. Petersen

This patch makes SCSI error printing more user friendly by:

1. Replacing the (currently unused) functions scsi_print_hostbyte()
   and scsi_print_driverbyte() with scsi_print_result()

2. Replacing the dreaded "SCSI error: return code" in
   scsi_io_completion with a call to scsi_print_result()

3. Making scmd_printk() output the disk name if available

The net result is that:

   sd 0:0:0:0: SCSI error: return code = 0x0802
   sda: Current: sense key: Aborted Command
   Additional sense: Logical block reference tag check failed

becomes:

   sda: Error: hostbyte=DID_OK  driverbyte=DRIVER_SENSE,SUGGEST_OK
   sda: Current: sense key: Aborted Command
   Additional sense: Logical block reference tag check failed

Signed-off-by: Martin K. Petersen <[EMAIL PROTECTED]>

---

 drivers/scsi/constants.c   |   48 +++--
 drivers/scsi/scsi_lib.c|4 ---
 include/scsi/scsi_dbg.h|3 --
 include/scsi/scsi_device.h |3 ++
 4 files changed, 26 insertions(+), 32 deletions(-)

diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
index 61f6024..48038ea 100644
--- a/drivers/scsi/constants.c
+++ b/drivers/scsi/constants.c
@@ -1327,25 +1327,6 @@ static const char * const hostbyte_table[]={
 "DID_PASSTHROUGH", "DID_SOFT_ERROR", "DID_IMM_RETRY"};
 #define NUM_HOSTBYTE_STRS ARRAY_SIZE(hostbyte_table)
 
-void scsi_print_hostbyte(int scsiresult)
-{
-   int hb = host_byte(scsiresult);
-
-   printk("Hostbyte=0x%02x", hb);
-   if (hb < NUM_HOSTBYTE_STRS)
-   printk("(%s) ", hostbyte_table[hb]);
-   else
-   printk("is invalid ");
-}
-#else
-void scsi_print_hostbyte(int scsiresult)
-{
-   printk("Hostbyte=0x%02x ", host_byte(scsiresult));
-}
-#endif
-
-#ifdef CONFIG_SCSI_CONSTANTS
-
 static const char * const driverbyte_table[]={
 "DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT",  "DRIVER_MEDIA", "DRIVER_ERROR",
 "DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD", "DRIVER_SENSE"};
@@ -1356,19 +1337,32 @@ static const char * const 
driversuggest_table[]={"SUGGEST_OK",
 "SUGGEST_5", "SUGGEST_6", "SUGGEST_7", "SUGGEST_SENSE"};
 #define NUM_SUGGEST_STRS ARRAY_SIZE(driversuggest_table)
 
-void scsi_print_driverbyte(int scsiresult)
+void scsi_print_result(struct scsi_cmnd *cmd)
 {
-   int dr = (driver_byte(scsiresult) & DRIVER_MASK);
-   int su = ((driver_byte(scsiresult) & SUGGEST_MASK) >> 4);
+   int hb = host_byte(cmd->result);
+   int db = (driver_byte(cmd->result) & DRIVER_MASK);
+   int su = ((driver_byte(cmd->result) & SUGGEST_MASK) >> 4);
+
+   scmd_printk(KERN_INFO, cmd, "Error: ");
 
-   printk("Driverbyte=0x%02x ", driver_byte(scsiresult));
-   printk("(%s,%s) ",
-  (dr < NUM_DRIVERBYTE_STRS ? driverbyte_table[dr] : "invalid"),
+   printk("hostbyte=%s  driverbyte=%s,%s\n",
+  (hb < NUM_HOSTBYTE_STRS ? hostbyte_table[hb] : "invalid"),
+  (db < NUM_DRIVERBYTE_STRS ? driverbyte_table[db] : "invalid"),
   (su < NUM_SUGGEST_STRS ? driversuggest_table[su] : "invalid"));
 }
+
 #else
-void scsi_print_driverbyte(int scsiresult)
+
+void scsi_print_result(struct scsi_cmnd *cmd)
 {
-   printk("Driverbyte=0x%02x ", driver_byte(scsiresult));
+   int result = cmd->result;
+
+   scmd_printk(KERN_INFO, cmd,
+   "Error: hostbyte=0x%02x  driverbyte=0x%02x\n",
+   host_byte(result), driver_byte(result));
 }
+
 #endif
+
+EXPORT_SYMBOL(scsi_print_result);
+
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 0f9b6c2..bf766d8 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -969,9 +969,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int 
good_bytes)
}
if (result) {
if (!(req->cmd_flags & REQ_QUIET)) {
-   scmd_printk(KERN_INFO, cmd,
-   "SCSI error: return code = 0x%08x\n",
-   result);
+   scsi_print_result(cmd);
if (driver_byte(result) & DRIVER_SENSE)
scsi_print_sense("", cmd);
}
diff --git a/include/scsi/scsi_dbg.h b/include/scsi/scsi_dbg.h
index 3bbbfbe..426cfa3 100644
--- a/include/scsi/scsi_dbg.h
+++ b/include/scsi/scsi_dbg.h
@@ -11,8 +11,7 @@ extern void scsi_print_sense(const char *, struct scsi_cmnd 
*);
 extern void __scsi_print_sense(const char *name,
   const unsigned char *sense_buffer,
   int sense_len);
-extern void scsi_print_driverbyte(int);
-extern void scsi_print_hostbyte(int);
+extern void scsi_print_result(struct scsi_cmnd *);
 extern void scsi_print_status(unsigned char);
 extern const char *scsi_sense_key_string(unsigned char);
 extern const char *scsi_extd_sense_format(unsigned char, unsigned char);
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index ebf31b1.