Re: [PATCH] SCSI: Remove redundant GFP_KERNEL type flag in kmalloc().

2007-05-04 Thread Andrew Morton

Please be careful to add the appropriate cc's.

On Mon, 30 Apr 2007 04:37:22 -0400 (EDT) Robert P. J. Day [EMAIL PROTECTED] 
wrote:

 
 Remove the apparently redundant GFP_KERNEL type flag in the call to
 kmalloc().
 
 Signed-off-by: Robert P. J. Day [EMAIL PROTECTED]
 
 ---
 
 diff --git a/drivers/scsi/aic7xxx_old.c b/drivers/scsi/aic7xxx_old.c
 index a988d5a..765ded0 100644
 --- a/drivers/scsi/aic7xxx_old.c
 +++ b/drivers/scsi/aic7xxx_old.c
 @@ -6581,7 +6581,7 @@ aic7xxx_slave_alloc(struct scsi_device *SDptr)
struct aic7xxx_host *p = (struct aic7xxx_host *)SDptr-host-hostdata;
struct aic_dev_data *aic_dev;
 
 -  aic_dev = kmalloc(sizeof(struct aic_dev_data), GFP_ATOMIC | GFP_KERNEL);
 +  aic_dev = kmalloc(sizeof(struct aic_dev_data), GFP_ATOMIC);

No, this converts the allocation from a robust one which can sleep into a
flakey one which cannot.

If we want to just clean this code up, we should switch to

GFP_KERNEL|__GFP_HIGH

and add a comment explaining why we're turning on __GFP_HIGH (pointlessly,
I suspect).

However I suspect what the code really meant to do was to use just
GFP_KERNEL.  It's been that way since

commit 5c9342ceb292ac5c619db6eef4ef427a64bcd436
Author: torvalds torvalds
Date:   Thu Nov 7 04:54:32 2002 +

Merge bk://linux-scsi.bkbits.net/scsi-dledford
into home.transmeta.com:/home/torvalds/v2.5/linux

2002/11/06 16:40:20-05:00 dledford
aic7xxx_old: multiple updates and fixes, driver ported to scsi
mid-layer new error handling scheme
-
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] SCSI: Remove redundant GFP_KERNEL type flag in kmalloc().

2007-05-04 Thread Robert P. J. Day
On Fri, 4 May 2007, Andrew Morton wrote:


 Please be careful to add the appropriate cc's.

 On Mon, 30 Apr 2007 04:37:22 -0400 (EDT) Robert P. J. Day [EMAIL 
 PROTECTED] wrote:

 
  Remove the apparently redundant GFP_KERNEL type flag in the call to
  kmalloc().
 
  Signed-off-by: Robert P. J. Day [EMAIL PROTECTED]
 
  ---
 
  diff --git a/drivers/scsi/aic7xxx_old.c b/drivers/scsi/aic7xxx_old.c
  index a988d5a..765ded0 100644
  --- a/drivers/scsi/aic7xxx_old.c
  +++ b/drivers/scsi/aic7xxx_old.c
  @@ -6581,7 +6581,7 @@ aic7xxx_slave_alloc(struct scsi_device *SDptr)
 struct aic7xxx_host *p = (struct aic7xxx_host *)SDptr-host-hostdata;
 struct aic_dev_data *aic_dev;
 
  -  aic_dev = kmalloc(sizeof(struct aic_dev_data), GFP_ATOMIC | GFP_KERNEL);
  +  aic_dev = kmalloc(sizeof(struct aic_dev_data), GFP_ATOMIC);

 No, this converts the allocation from a robust one which can sleep into a
 flakey one which cannot.

... snip ...

at this point, i'd be happier to leave the appropriate patches in the
hands of those who have a better handle on this.  as i posted earlier,
there's only two examples of this in the entire tree:

drivers/scsi/aic7xxx_old.c:  aic_dev = kmalloc(sizeof(struct aic_dev_data), 
GFP_ATOMIC | GFP_KERNEL);
drivers/message/i2o/device.c:   resblk = kmalloc(buflen + 8, GFP_KERNEL | 
GFP_ATOMIC);

it's all yours.

rday
-- 

Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://fsdev.net/wiki/index.php?title=Main_Page

-
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: libata /dev/scd0 problem: mount after burn fails without eject

2007-05-04 Thread Tejun Heo
Frank van Maarseveen wrote:
 On Fri, May 04, 2007 at 10:16:32AM +0200, Tejun Heo wrote:
 Michal Piotrowski wrote:
 On 01/05/07, Mark Lord [EMAIL PROTECTED] wrote:
 Forwarding to linux-scsi and linux-ide mailing lists.

 Frank van Maarseveen wrote:
 Tested on 2.6.20.6 and 2.6.21.1

 I decided to swich from the old IDE drivers to libata and now there
 seems to be a little but annoying problem: cannot mount an ISO image
 after burning it.

 May  1 14:32:55 kernel: attempt to access beyond end of device
 May  1 14:32:55 kernel: sr0: rw=0, want=68, limit=4
 May  1 14:32:55 kernel: isofs_fill_super: bread failed, dev=sr0,
 iso_blknum=16, block=16
 an eject command seems to fix the state of the PATA DVD writer
 or driver. The problem occurs for burning a CD and for DVD too with
 identical error messages.
 Right after burning, if you run 'fuser -v /dev/sr0', what does it say?
 
 Tried the fuser as root to be sure but it didn't show anything.

I guess sr is forgetting to set media changed flag somewhere.  Don't
really know where tho.  CC'd Bartlomiej, linux-scsi and linux-ide.  Any
ideas?

-- 
tejun
-
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: libata /dev/scd0 problem: mount after burn fails without eject

2007-05-04 Thread Frank van Maarseveen
On Fri, May 04, 2007 at 10:41:41AM +0200, Tejun Heo wrote:
 Frank van Maarseveen wrote:
  On Fri, May 04, 2007 at 10:16:32AM +0200, Tejun Heo wrote:
  Michal Piotrowski wrote:
  On 01/05/07, Mark Lord [EMAIL PROTECTED] wrote:
  Forwarding to linux-scsi and linux-ide mailing lists.
 
  Frank van Maarseveen wrote:
  Tested on 2.6.20.6 and 2.6.21.1
 
  I decided to swich from the old IDE drivers to libata and now there
  seems to be a little but annoying problem: cannot mount an ISO image
  after burning it.
 
  May  1 14:32:55 kernel: attempt to access beyond end of device
  May  1 14:32:55 kernel: sr0: rw=0, want=68, limit=4
  May  1 14:32:55 kernel: isofs_fill_super: bread failed, dev=sr0,
  iso_blknum=16, block=16
  an eject command seems to fix the state of the PATA DVD writer
  or driver. The problem occurs for burning a CD and for DVD too with
  identical error messages.
  Right after burning, if you run 'fuser -v /dev/sr0', what does it say?
  
  Tried the fuser as root to be sure but it didn't show anything.
 
 I guess sr is forgetting to set media changed flag somewhere.

Plausible. I get the same kernel messages when I try to mount the CD
before burning.

-- 
Frank
-
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: libata /dev/scd0 problem: mount after burn fails without eject

2007-05-04 Thread Frank van Maarseveen
On Fri, May 04, 2007 at 10:16:32AM +0200, Tejun Heo wrote:
 Michal Piotrowski wrote:
  On 01/05/07, Mark Lord [EMAIL PROTECTED] wrote:
  Forwarding to linux-scsi and linux-ide mailing lists.
 
  Frank van Maarseveen wrote:
   Tested on 2.6.20.6 and 2.6.21.1
  
   I decided to swich from the old IDE drivers to libata and now there
   seems to be a little but annoying problem: cannot mount an ISO image
   after burning it.
  
   May  1 14:32:55 kernel: attempt to access beyond end of device
   May  1 14:32:55 kernel: sr0: rw=0, want=68, limit=4
   May  1 14:32:55 kernel: isofs_fill_super: bread failed, dev=sr0,
  iso_blknum=16, block=16
  
   an eject command seems to fix the state of the PATA DVD writer
   or driver. The problem occurs for burning a CD and for DVD too with
   identical error messages.
 
 Right after burning, if you run 'fuser -v /dev/sr0', what does it say?

Tried the fuser as root to be sure but it didn't show anything.

-- 
Frank
-
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] SCSI: Remove redundant GFP_KERNEL type flag in kmalloc().

2007-05-04 Thread Satyam Sharma

On 5/4/07, Andrew Morton [EMAIL PROTECTED] wrote:

[...]

 -  aic_dev = kmalloc(sizeof(struct aic_dev_data), GFP_ATOMIC | GFP_KERNEL);
 +  aic_dev = kmalloc(sizeof(struct aic_dev_data), GFP_ATOMIC);

No, this converts the allocation from a robust one which can sleep into a
flakey one which cannot.

If we want to just clean this code up, we should switch to

GFP_KERNEL|__GFP_HIGH

and add a comment explaining why we're turning on __GFP_HIGH (pointlessly,
I suspect).

However I suspect what the code really meant to do was to use just
GFP_KERNEL.


Yes.

A recap from http://lkml.org/lkml/2007/4/28/160 ...


 So combining GFP_ATOMIC with GFP_KERNEL gives you
 allow io, allow fs, allow waiting, and use emergency pools when it's
 getting tight which to me looks like a valid, but probably unwanted
 combination.


and:


As a matter of style, the author there could've written (GFP_KERNEL |
__GFP_HIGH) instead, but I'm not sure how much sense that makes
because once we specify GFP_KERNEL, we essentially bring out the heavy
weaponry to *make* some free space for ourselves if it isn't there
already (and we're prepared to sleep when all that happens) -- so
where's the need left to scavenge into emergency pools anymore?
__GFP_HIGH only makes sense for poor atomic contexts for whom sleeping
(when we try_to_free other pages to satisfy our allocation request) is
not an option, which is precisely how things are presently.

[...]
1. If you're in_atomic() context, that GFP_KERNEL is a BUG and *must*
be removed.

2. If not, that GFP_ATOMIC is redundant / nonsensical and *can* be removed.


It _was_ established towards the end of that thread that neither of the two
cases are atomic contexts. And it would still make sense to remove the redundant
__GFP_HIGH, as we don't want to unnecessarily deplete the emergency
reserve pool for normal GFP_KERNEL cases thus making ENOMEM on some future
kmalloc(GFP_ATOMIC) more likely. I'll send out the patches.
-
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] drivers/scsi/aic7xxx_old.c: remove redundant GFP_ATOMIC from kmalloc

2007-05-04 Thread Satyam Sharma
drivers/scsi/aic7xxx_old.c:aic7xxx_slave_alloc() unnecessarily passes 
GFP_ATOMIC (along with GFP_KERNEL) to kmalloc() from a context that is not 
atomic. Remove the pointless GFP_ATOMIC.


Signed-off-by: Satyam Sharma [EMAIL PROTECTED]

---

diff -ruNp linux-2.6.21.1/drivers/scsi/aic7xxx_old.c 
linux-2.6.21.1~patch/drivers/scsi/aic7xxx_old.c
--- linux-2.6.21.1/drivers/scsi/aic7xxx_old.c   2007-04-26 08:38:32.0 
+0530
+++ linux-2.6.21.1~patch/drivers/scsi/aic7xxx_old.c 2007-05-04 
17:47:26.0 +0530
@@ -6581,7 +6581,7 @@ aic7xxx_slave_alloc(struct scsi_device *
   struct aic7xxx_host *p = (struct aic7xxx_host *)SDptr-host-hostdata;
   struct aic_dev_data *aic_dev;

-  aic_dev = kmalloc(sizeof(struct aic_dev_data), GFP_ATOMIC | GFP_KERNEL);
+  aic_dev = kmalloc(sizeof(struct aic_dev_data), GFP_KERNEL);
   if(!aic_dev)
 return 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


Re: [PATCH 4/4] bidi support: bidirectional request

2007-05-04 Thread FUJITA Tomonori
From: Boaz Harrosh [EMAIL PROTECTED]
Subject: Re: [PATCH 4/4] bidi support: bidirectional request
Date: Thu, 03 May 2007 20:42:44 +0300

 FUJITA Tomonori wrote:
  From: Jens Axboe [EMAIL PROTECTED]
  Subject: Re: [PATCH 4/4] bidi support: bidirectional request
  Date: Mon, 30 Apr 2007 13:11:57 +0200
  
  On Sun, Apr 29 2007, James Bottomley wrote:
  On Sun, 2007-04-29 at 18:48 +0300, Boaz Harrosh wrote:
  FUJITA Tomonori wrote:
  From: Boaz Harrosh [EMAIL PROTECTED]
  Subject: [PATCH 4/4] bidi support: bidirectional request
  Date: Sun, 15 Apr 2007 20:33:28 +0300
 
  diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
  index 645d24b..16a02ee 100644
  --- a/include/linux/blkdev.h
  +++ b/include/linux/blkdev.h
  @@ -322,6 +322,7 @@ struct request {
   void *end_io_data;
 
   struct request_io_part uni;
  +struct request_io_part bidi_read;
   };
  Would be more straightforward to have:
 
  struct request_io_part in;
  struct request_io_part out;
 
  Yes I wish I could do that. For bidi supporting drivers this is the most 
  logical.
  But for the 99.9% of uni-directional drivers, calling rq_uni(), and 
  being some what on
  the hotish paths, this means we will need a pointer to a uni 
  request_io_part.
  This is bad because:
  1st- There is no defined stage in a request life where to definitely set 
  that pointer,
   specially in the preparation stages.
  2nd- hacks like scsi_error.c/scsi_send_eh_cmnd() will not work at all. 
  Now this is a
   very bad spot already, and I have a short term fix for it in the 
  SCSI-bidi patches
   (not sent yet) but a more long term solution is needed. Once such 
  hacks are
   cleaned up we can do what you say. This is exactly why I use the 
  access functions
   rq_uni/rq_io/rq_in/rq_out and not open code access.
  I'm still not really convinced about this approach.  The primary job of
  the block layer is to manage and merge READ and WRITE requests.  It
  serves a beautiful secondary function of queueing for arbitrary requests
  it doesn't understand (REQ_TYPE_BLOCK_PC or REQ_TYPE_SPECIAL ... or
  indeed any non REQ_TYPE_FS).
 
  bidirectional requests fall into the latter category (there's nothing
  really we can do to merge them ... they're just transported by the block
  layer).  The only unusual feature is that they carry two bios.  I think
  the drivers that actually support bidirectional will be a rarity, so it
  might even be advisable to add it to the queue capability (refuse
  bidirectional requests at the top rather than perturbing all the drivers
  to process them).
 
  So, what about REQ_TYPE_BIDIRECTIONAL rather than REQ_BIDI?  That will
  remove it from the standard path and put it on the special command type
  path where we can process it specially.  Additionally, if you take this
  approach, you can probably simply chain the second bio through
  req-special as an additional request in the stream.  The only thing
  that would then need modification would be the dequeue of the block
  driver (it would have to dequeue both requests and prepare them) and
  that needs to be done only for drivers handling bidirectional requests.
  I agree, I'm really not crazy about shuffling the entire request setup
  around just for something as exotic as bidirection commands. How about
  just keeping it simple - have a second request linked off the first one
  for the second data phase? So keep it completely seperate, not just
  overload -special for 2nd bio list.
 
  So basically just add a struct request pointer, so you can do rq =
  rq-next_rq or something for the next data phase. I bet this would be a
  LOT less invasive as well, and we can get by with a few helpers to
  support it.
  
  This patch tried this approach. It's just for seeing how it works.
  
  I added bidi support to open-iscsi and bsg and tested this patch
  lightly. I've attached only a patch for the block layer and scsl-ml.
  You can get all the patches are:
  
  http://www.kernel.org/pub/linux/kernel/people/tomo/bidi
  
  If we go with this approach, we need just minor changes to the block
  layer. The overloading rq-special approach needs more but it's
  reasonable too.
  
  I need to add the proper error handling code, which might be a bit
  tricky, but I think that it will not be so complicated.
  
  
  And it should definitely be a request type.
  
  I'm not sure about this. I think that bidi can't be a request type to
  trace bidi pc requests (we have bidi special requests like SMP). I use
  REQ_BIDI though I've not implemented bidi trace code.
  
  
  From 7d278323ff8aad86fb82c823538f7ddfb6ded11c Mon Sep 17 00:00:00 2001
  From: FUJITA Tomonori [EMAIL PROTECTED]
  Date: Wed, 2 May 2007 03:55:56 +0900
  Subject: [PATCH] add bidi support
  
  Signed-off-by: FUJITA Tomonori [EMAIL PROTECTED]
  ---
   block/ll_rw_blk.c|1 +
   drivers/scsi/scsi_lib.c  |   72 
  +++---
   include/linux/blkdev.h   |7 

[patch 0/7] Asynchronous Notification for ATAPI devices (v2) - resend

2007-05-04 Thread Kristen Carlson Accardi
This patch series implements Asynchronous Notification (AN) for SATA
ATAPI devices as defined in SATA 2.5 and AHCI 1.1 and higher.  Drives
which support this feature will send a notification when new media is
inserted and removed, preventing the need for user space to poll for
new media.  This support is exposed to user space via a flag that will
be set in /sys/block/sr*/capability_flags.  If the flag is set, user
space can disable polling for the new media, and the genhd driver will
send a KOBJ_CHANGE event with the envp set to MEDIA_CHANGE_EVENT=1.

Note that this patch only implements support for directly attached
drives - AN with drives attached to a port multiplier requires 
additional changes.

Thanks!
Kristen

-- 
-- 
-
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/7] libata: check for AN support - resend

2007-05-04 Thread Kristen Carlson Accardi
Check to see if an ATAPI device supports Asynchronous Notification.
If so, enable it.

Changes from last version:
* use parens around id in ata.h

Signed-off-by: Kristen Carlson Accardi [EMAIL PROTECTED]

Index: 2.6-git/drivers/ata/libata-core.c
===
--- 2.6-git.orig/drivers/ata/libata-core.c
+++ 2.6-git/drivers/ata/libata-core.c
@@ -70,6 +70,7 @@ const unsigned long sata_deb_timing_long
 static unsigned int ata_dev_init_params(struct ata_device *dev,
u16 heads, u16 sectors);
 static unsigned int ata_dev_set_xfermode(struct ata_device *dev);
+static unsigned int ata_dev_set_AN(struct ata_device *dev);
 static void ata_dev_xfermask(struct ata_device *dev);
 
 static unsigned int ata_print_id = 1;
@@ -1744,6 +1745,22 @@ int ata_dev_configure(struct ata_device 
}
dev-cdb_len = (unsigned int) rc;
 
+   /*
+* check to see if this ATAPI device supports
+* Asynchronous Notification
+*/
+   if ((ap-flags  ATA_FLAG_AN)  ata_id_has_AN(id)) {
+   int err;
+   /* issue SET feature command to turn this on */
+   err = ata_dev_set_AN(dev);
+   if (err)
+   ata_dev_printk(dev, KERN_ERR,
+   unable to set AN, err %x\n,
+   err);
+   else
+   dev-flags |= ATA_DFLAG_AN;
+   }
+
if (ata_id_cdb_intr(dev-id)) {
dev-flags |= ATA_DFLAG_CDB_INTR;
cdb_intr_string = , CDB intr;
@@ -3525,6 +3542,42 @@ static unsigned int ata_dev_set_xfermode
 }
 
 /**
+ * ata_dev_set_AN - Issue SET FEATURES - SATA FEATURES
+ *   with sector count set to indicate
+ *   Asynchronous Notification feature
+ * @dev: Device to which command will be sent
+ *
+ * Issue SET FEATURES - SATA FEATURES command to device @dev
+ * on port @ap.
+ *
+ * LOCKING:
+ * PCI/etc. bus probe sem.
+ *
+ * RETURNS:
+ * 0 on success, AC_ERR_* mask otherwise.
+ */
+static unsigned int ata_dev_set_AN(struct ata_device *dev)
+{
+   struct ata_taskfile tf;
+   unsigned int err_mask;
+
+   /* set up set-features taskfile */
+   DPRINTK(set features - SATA features\n);
+
+   ata_tf_init(dev, tf);
+   tf.command = ATA_CMD_SET_FEATURES;
+   tf.feature = SETFEATURES_SATA_ENABLE;
+   tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
+   tf.protocol = ATA_PROT_NODATA;
+   tf.nsect = SATA_AN;
+
+   err_mask = ata_exec_internal(dev, tf, NULL, DMA_NONE, NULL, 0);
+
+   DPRINTK(EXIT, err_mask=%x\n, err_mask);
+   return err_mask;
+}
+
+/**
  * ata_dev_init_params - Issue INIT DEV PARAMS command
  * @dev: Device to which command will be sent
  * @heads: Number of heads (taskfile parameter)
Index: 2.6-git/include/linux/ata.h
===
--- 2.6-git.orig/include/linux/ata.h
+++ 2.6-git/include/linux/ata.h
@@ -194,6 +194,12 @@ enum {
SETFEATURES_WC_ON   = 0x02, /* Enable write cache */
SETFEATURES_WC_OFF  = 0x82, /* Disable write cache */
 
+   SETFEATURES_SATA_ENABLE = 0x10, /* Enable use of SATA feature */
+   SETFEATURES_SATA_DISABLE = 0x90, /* Disable use of SATA feature */
+
+   /* SETFEATURE Sector counts for SATA features */
+   SATA_AN = 0x05,  /* Asynchronous Notification */
+
/* ATAPI stuff */
ATAPI_PKT_DMA   = (1  0),
ATAPI_DMADIR= (1  2), /* ATAPI data dir:
@@ -299,6 +305,9 @@ struct ata_taskfile {
 #define ata_id_queue_depth(id) (((id)[75]  0x1f) + 1)
 #define ata_id_removeable(id)  ((id)[0]  (1  7))
 #define ata_id_has_dword_io(id)((id)[50]  (1  0))
+#define ata_id_has_AN(id)  \
+   ( (((id)[76] != 0x)  ((id)[76] != 0x))  \
+ ((id)[78]  (1  5)) )
 #define ata_id_iordy_disable(id) ((id)[49]  (1  10))
 #define ata_id_has_iordy(id) ((id)[49]  (1  9))
 #define ata_id_u32(id,n)   \
Index: 2.6-git/include/linux/libata.h
===
--- 2.6-git.orig/include/linux/libata.h
+++ 2.6-git/include/linux/libata.h
@@ -136,6 +136,7 @@ enum {
ATA_DFLAG_CDB_INTR  = (1  2), /* device asserts INTRQ when ready 
for CDB */
ATA_DFLAG_NCQ   = (1  3), /* device supports NCQ */
ATA_DFLAG_FLUSH_EXT = (1  4), /* do FLUSH_EXT instead of FLUSH */
+   ATA_DFLAG_AN= (1  5), /* device supports Async 
notification */
ATA_DFLAG_CFG_MASK  = (1  8) - 1,
 
ATA_DFLAG_PIO   = (1  8), /* device limited to PIO mode */
@@ -174,6 +175,7 @@ enum 

[patch 2/7] genhd: expose AN to user space - resend

2007-05-04 Thread Kristen Carlson Accardi
Allow user space to determine if a disk supports Asynchronous Notification
of media changes.  This is done by adding a new sysfs file capability_flags,
which is documented in (insert file name).  This sysfs file will export all
disk capabilities flags to user space.  We also define a new flag to define
the media change notification capability.

Changed from last version:
* changed sysfs filename to capability from capability_flags

Signed-off-by: Kristen Carlson Accardi [EMAIL PROTECTED]

Index: 2.6-git/block/genhd.c
===
--- 2.6-git.orig/block/genhd.c
+++ 2.6-git/block/genhd.c
@@ -370,7 +370,10 @@ static ssize_t disk_size_read(struct gen
 {
return sprintf(page, %llu\n, (unsigned long long)get_capacity(disk));
 }
-
+static ssize_t disk_capability_read(struct gendisk *disk, char *page)
+{
+   return sprintf(page, %x\n, disk-flags);
+}
 static ssize_t disk_stats_read(struct gendisk * disk, char *page)
 {
preempt_disable();
@@ -413,6 +416,10 @@ static struct disk_attribute disk_attr_s
.attr = {.name = size, .mode = S_IRUGO },
.show   = disk_size_read
 };
+static struct disk_attribute disk_attr_capability = {
+   .attr = {.name = capability, .mode = S_IRUGO },
+   .show   = disk_capability_read
+};
 static struct disk_attribute disk_attr_stat = {
.attr = {.name = stat, .mode = S_IRUGO },
.show   = disk_stats_read
@@ -453,6 +460,7 @@ static struct attribute * default_attrs[
disk_attr_removable.attr,
disk_attr_size.attr,
disk_attr_stat.attr,
+   disk_attr_capability.attr,
 #ifdef CONFIG_FAIL_MAKE_REQUEST
disk_attr_fail.attr,
 #endif
Index: 2.6-git/include/linux/genhd.h
===
--- 2.6-git.orig/include/linux/genhd.h
+++ 2.6-git/include/linux/genhd.h
@@ -94,6 +94,7 @@ struct hd_struct {
 
 #define GENHD_FL_REMOVABLE 1
 #define GENHD_FL_DRIVERFS  2
+#define GENHD_FL_MEDIA_CHANGE_NOTIFY   4
 #define GENHD_FL_CD8
 #define GENHD_FL_UP16
 #define GENHD_FL_SUPPRESS_PARTITION_INFO   32
Index: 2.6-git/Documentation/block/capability.txt
===
--- /dev/null
+++ 2.6-git/Documentation/block/capability.txt
@@ -0,0 +1,15 @@
+Generic Block Device Capability
+===
+This file documents the sysfs file block/disk/capability
+
+capability is a hex word indicating which capabilities a specific disk
+supports.  For more information on bits not listed here, see
+include/linux/genhd.h
+
+Capability Value
+---
+GENHD_FL_MEDIA_CHANGE_NOTIFY   4
+   When this bit is set, the disk supports Asynchronous Notification
+   of media change events.  These events will be broadcast to user
+   space via kernel uevent.
+
-
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 3/7] scsi: expose AN to user space - resend

2007-05-04 Thread Kristen Carlson Accardi
Get media change notification capability from disk and pass this information
to genhd by setting appropriate flag.

Signed-off-by: Kristen Carlson Accardi [EMAIL PROTECTED]

Index: 2.6-git/drivers/scsi/sr.c
===
--- 2.6-git.orig/drivers/scsi/sr.c
+++ 2.6-git/drivers/scsi/sr.c
@@ -601,6 +601,8 @@ static int sr_probe(struct device *dev)
 
dev_set_drvdata(dev, cd);
disk-flags |= GENHD_FL_REMOVABLE;
+   if (sdev-media_change_notify)
+   disk-flags |= GENHD_FL_MEDIA_CHANGE_NOTIFY;
add_disk(disk);
 
sdev_printk(KERN_DEBUG, sdev,
Index: 2.6-git/include/scsi/scsi_device.h
===
--- 2.6-git.orig/include/scsi/scsi_device.h
+++ 2.6-git/include/scsi/scsi_device.h
@@ -124,7 +124,7 @@ struct scsi_device {
unsigned fix_capacity:1;/* READ_CAPACITY is too high by 1 */
unsigned guess_capacity:1;  /* READ_CAPACITY might be too high by 1 
*/
unsigned retry_hwerror:1;   /* Retry HARDWARE_ERROR */
-
+   unsigned media_change_notify:1; /* dev supports async media notify */
unsigned int device_blocked;/* Device returned QUEUE_FULL. */
 
unsigned int max_device_blocked; /* what device_blocked counts down 
from  */
Index: 2.6-git/drivers/scsi/sd.c
===
--- 2.6-git.orig/drivers/scsi/sd.c
+++ 2.6-git/drivers/scsi/sd.c
@@ -1706,6 +1706,9 @@ static int sd_probe(struct device *dev)
if (sdp-removable)
gd-flags |= GENHD_FL_REMOVABLE;
 
+   if (sdp-media_change_notify)
+   gd-flags |= GENHD_FL_MEDIA_CHANGE_NOTIFY;
+
dev_set_drvdata(dev, sdkp);
add_disk(gd);
 

-- 
-
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 5/7] genhd: send async notification on media change

2007-05-04 Thread Kristen Carlson Accardi
Send an uevent to user space to indicate that a media change event has occurred.

Changes from last version:
* use get/put_device to increment reference count on the device struct

Signed-off-by: Kristen Carlson Accardi [EMAIL PROTECTED]

Index: 2.6-git/block/genhd.c
===
--- 2.6-git.orig/block/genhd.c
+++ 2.6-git/block/genhd.c
@@ -643,6 +643,27 @@ struct seq_operations diskstats_op = {
.show   = diskstats_show
 };
 
+static void media_change_notify_thread(struct work_struct *work)
+{
+   struct gendisk *gd = container_of(work, struct gendisk, async_notify);
+   char event[] = MEDIA_CHANGE=1;
+   char *envp[] = { event, NULL };
+
+   /*
+* set enviroment vars to indicate which event this is for
+* so that user space will know to go check the media status.
+*/
+   kobject_uevent_env(gd-kobj, KOBJ_CHANGE, envp);
+   put_device(gd-driverfs_dev);
+}
+
+void genhd_media_change_notify(struct gendisk *disk)
+{
+   get_device(disk-driverfs_dev);
+   schedule_work(disk-async_notify);
+}
+EXPORT_SYMBOL_GPL(genhd_media_change_notify);
+
 struct gendisk *alloc_disk(int minors)
 {
return alloc_disk_node(minors, -1);
@@ -672,6 +693,8 @@ struct gendisk *alloc_disk_node(int mino
kobj_set_kset_s(disk,block_subsys);
kobject_init(disk-kobj);
rand_initialize_disk(disk);
+   INIT_WORK(disk-async_notify,
+   media_change_notify_thread);
}
return disk;
 }
Index: 2.6-git/include/linux/genhd.h
===
--- 2.6-git.orig/include/linux/genhd.h
+++ 2.6-git/include/linux/genhd.h
@@ -66,6 +66,7 @@ struct partition {
 #include linux/smp.h
 #include linux/string.h
 #include linux/fs.h
+#include linux/workqueue.h
 
 struct partition {
unsigned char boot_ind; /* 0x80 - active */
@@ -139,6 +140,7 @@ struct gendisk {
 #else
struct disk_stats dkstats;
 #endif
+   struct work_struct async_notify;
 };
 
 /* Structure for sysfs attributes on block devices */
@@ -419,7 +421,7 @@ extern struct gendisk *alloc_disk_node(i
 extern struct gendisk *alloc_disk(int minors);
 extern struct kobject *get_disk(struct gendisk *disk);
 extern void put_disk(struct gendisk *disk);
-
+extern void genhd_media_change_notify(struct gendisk *disk);
 extern void blk_register_region(dev_t dev, unsigned long range,
struct module *module,
struct kobject *(*probe)(dev_t, int *, void *),
-
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 7/7] libata: send event when AN received - resend

2007-05-04 Thread Kristen Carlson Accardi
When we get an SDB FIS with the 'N' bit set, we should send
an event to user space to indicate that there has been a
media change.  This will be done via the block device. 

changed from last version:
* Make sure that port_addr is within ATA_MAX_DEVICES

Signed-off-by: Kristen Carlson Accardi [EMAIL PROTECTED]
Index: 2.6-git/drivers/ata/ahci.c
===
--- 2.6-git.orig/drivers/ata/ahci.c
+++ 2.6-git/drivers/ata/ahci.c
@@ -1147,6 +1147,28 @@ static void ahci_host_intr(struct ata_po
return;
}
 
+   if (status  PORT_IRQ_SDB_FIS) {
+   /*
+* if this is an ATAPI device with AN turned on,
+* then we should interrogate the device to
+* determine the cause of the interrupt
+*
+* for AN - this we should check the SDB FIS
+* and find the I and N bits set
+*/
+   const u32 *f = pp-rx_fis + RX_FIS_SDB;
+
+   /* check the 'N' bit in word 0 of the FIS */
+   if (f[0]  (1  15)) {
+   int port_addr =  ((f[0]  0x0f00)  8);
+   struct ata_device *adev;
+   if (port_addr  ATA_MAX_DEVICES) {
+   adev = ap-device[port_addr];
+   if (adev-flags  ATA_DFLAG_AN)
+   ata_scsi_media_change_notify(adev);
+   }
+   }
+   }
if (ap-sactive)
qc_active = readl(port_mmio + PORT_SCR_ACT);
else
Index: 2.6-git/include/linux/libata.h
===
--- 2.6-git.orig/include/linux/libata.h
+++ 2.6-git/include/linux/libata.h
@@ -737,6 +737,7 @@ extern void ata_host_init(struct ata_hos
 extern int ata_scsi_detect(struct scsi_host_template *sht);
 extern int ata_scsi_ioctl(struct scsi_device *dev, int cmd, void __user *arg);
 extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct 
scsi_cmnd *));
+extern void ata_scsi_media_change_notify(struct ata_device *atadev);
 extern void ata_sas_port_destroy(struct ata_port *);
 extern struct ata_port *ata_sas_port_alloc(struct ata_host *,
   struct ata_port_info *, struct 
Scsi_Host *);
Index: 2.6-git/drivers/ata/libata-scsi.c
===
--- 2.6-git.orig/drivers/ata/libata-scsi.c
+++ 2.6-git/drivers/ata/libata-scsi.c
@@ -3057,6 +3057,22 @@ static void ata_scsi_remove_dev(struct a
 }
 
 /**
+ * ata_scsi_media_change_notify - send media change event
+ * @atadev: Pointer to the disk device with media change event
+ *
+ * Tell the block layer to send a media change notification
+ * event.
+ *
+ * LOCKING:
+ * interrupt context, may not sleep.
+ */
+void ata_scsi_media_change_notify(struct ata_device *atadev)
+{
+   genhd_media_change_notify(atadev-sdev-disk);
+}
+EXPORT_SYMBOL_GPL(ata_scsi_media_change_notify);
+
+/**
  * ata_scsi_hotplug - SCSI part of hotplug
  * @work: Pointer to ATA port to perform SCSI hotplug on
  *
-
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/7] Asynchronous Notification for ATAPI devices (v2) - resend

2007-05-04 Thread James Bottomley
On Fri, 2007-05-04 at 11:12 -0700, Kristen Carlson Accardi wrote:
 This patch series implements Asynchronous Notification (AN) for SATA
 ATAPI devices as defined in SATA 2.5 and AHCI 1.1 and higher.  Drives
 which support this feature will send a notification when new media is
 inserted and removed, preventing the need for user space to poll for
 new media.  This support is exposed to user space via a flag that will
 be set in /sys/block/sr*/capability_flags.  If the flag is set, user
 space can disable polling for the new media, and the genhd driver will
 send a KOBJ_CHANGE event with the envp set to MEDIA_CHANGE_EVENT=1.
 
 Note that this patch only implements support for directly attached
 drives - AN with drives attached to a port multiplier requires 
 additional changes.

I seem to remember when this came up before, the observation was made
that AENs occur for many more things than simple media change notices,
so we should probably have a more generic AEN handling mechanism.  Is
there any plan to move in this direction

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: [patch 6/7] SCSI: save disk in scsi_device - resend

2007-05-04 Thread James Bottomley
On Fri, 2007-05-04 at 11:17 -0700, Kristen Carlson Accardi wrote:
 Give anyone who has access to scsi_device access to the genhd struct as well.
 
 Signed-off-by: Kristen Carlson Accardi [EMAIL PROTECTED]
 Index: 2.6-git/drivers/scsi/sd.c
 ===
 --- 2.6-git.orig/drivers/scsi/sd.c
 +++ 2.6-git/drivers/scsi/sd.c
 @@ -1711,6 +1711,7 @@ static int sd_probe(struct device *dev)
  
   dev_set_drvdata(dev, sdkp);
   add_disk(gd);
 + sdp-disk = gd;
  
   sdev_printk(KERN_NOTICE, sdp, Attached scsi %sdisk %s\n,
   sdp-removable ? removable  : , gd-disk_name);
 Index: 2.6-git/drivers/scsi/sr.c
 ===
 --- 2.6-git.orig/drivers/scsi/sr.c
 +++ 2.6-git/drivers/scsi/sr.c
 @@ -604,6 +604,7 @@ static int sr_probe(struct device *dev)
   if (sdev-media_change_notify)
   disk-flags |= GENHD_FL_MEDIA_CHANGE_NOTIFY;
   add_disk(disk);
 + sdev-disk = disk;
  
   sdev_printk(KERN_DEBUG, sdev,
   Attached scsi CD-ROM %s\n, cd-cdi.name);
 Index: 2.6-git/include/scsi/scsi_device.h
 ===
 --- 2.6-git.orig/include/scsi/scsi_device.h
 +++ 2.6-git/include/scsi/scsi_device.h
 @@ -138,7 +138,7 @@ struct scsi_device {
  
   struct device   sdev_gendev;
   struct class_device sdev_classdev;
 -
 + struct gendisk  *disk;
   struct execute_work ew; /* used to get process context on put */
  
   enum scsi_device_state sdev_state;

If you're going to do this, you need to take on board removing the
struct gendisk from all the ULD structures (since it's now become
generic).

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 8426] New: massive slowdown on SCSI CD/DVDdrive connected to mptspi driver

2007-05-04 Thread Moore, Eric
On Thursday, May 03, 2007 9:50 PM,  Doug Chapman wrote:
 
 ACK, tested this on my system where I originally found the problem and
 all is well with this.
 
 Ignore my earlier comment about the original patch adding the new
 function mptspi_initTarget.  After looking at what is going 
 on I realize
 that it didn't add this, it was just renamed from mptscsih_initTarget.
 

Are you still having issues?   I'm not clear with the above ACK email.

AFAIK, that patch your refering to which I submitted is only moving
code, not actually changing any functionality.   If your having a
problem with speed, then its most likely a domain validation problem.
In this driver, the domain validation is done from the spi transport
layer.When you load the driver, there should be some messages
displayed along with the inquiry info during device scan, that would
provide the negotiation rates. Search your /var/log/messages or dmesg.
You can also look in the SysFS, and all the info is there as well.   If
your device is host_W:Channel_X:Target_Y:Lun_Z, then you would look in
/sys/class/spi_transport_targetW:X:Y:Z/ , in this folder will be period.
The period is found below at the end of the each line in nano seconds
units.

factor:0x08   Ultra320 (160 Mega-transfers / second) (6.25 ns)
factor:0x09   Ultra160 ( 80 Mega-transfers / second) (12.5 ns)
factor:0x0A   Ultra2   ( 40 Mega-transfers / second) (25 ns)
factor:0x0B   Ultra2   ( 40 Mega-transfers / second) (30.3 ns)
factor:0x0C   Ultra( 20 Mega-transfers / second) (50 ns)
factor:0x19   FAST ( 10 Mega-transfers / second)
factor:0x32   SCSI (  5 Mega-transfers / second)
factor:0xFF   5 Mega-trasfers/second and asynchronous


Also, in the mpt fusion, I have some debug you could enable, which will
dump all the negotiation parameters as they are written and read from
via the driver.  The spi transport layer calls these entry points when
it wants to change the negotiation parameter for each test it runs.  In
the mpt fusion driver Makefile, you need to uncomment the line
MPT_DEBUG_DV.   When you do that, then mptspi_print_read_nego and
mptspi_print_write_nego would be called.

I would like to point out that around the same time I supplied that mpt
fusion patch, there were changes in scsi_transport_spi.c, that would
effect negotitaion with regards to the starting min sync rate value.
This file is in /usr/src/linux/drivers/scsi.  You could diff between
your kernels to see the changes.

Eric Moore 
LSI
-
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/7] Asynchronous Notification for ATAPI devices (v2) - resend

2007-05-04 Thread Kristen Carlson Accardi
On Fri, 04 May 2007 15:30:03 -0500
James Bottomley [EMAIL PROTECTED] wrote:

 On Fri, 2007-05-04 at 11:12 -0700, Kristen Carlson Accardi wrote:
  This patch series implements Asynchronous Notification (AN) for SATA
  ATAPI devices as defined in SATA 2.5 and AHCI 1.1 and higher.  Drives
  which support this feature will send a notification when new media is
  inserted and removed, preventing the need for user space to poll for
  new media.  This support is exposed to user space via a flag that will
  be set in /sys/block/sr*/capability_flags.  If the flag is set, user
  space can disable polling for the new media, and the genhd driver will
  send a KOBJ_CHANGE event with the envp set to MEDIA_CHANGE_EVENT=1.
  
  Note that this patch only implements support for directly attached
  drives - AN with drives attached to a port multiplier requires 
  additional changes.
 
 I seem to remember when this came up before, the observation was made
 that AENs occur for many more things than simple media change notices,
 so we should probably have a more generic AEN handling mechanism.  Is
 there any plan to move in this direction
 
 James
 
In this implementation, we use kobject_uevent_env (vs. just 
kobject_uevent in the original implementation) to send a KOBJ_CHANGE
with the enviroment value of MEDIA_CHANGE=1.  For other asynchronous
events, you could still use KOBJ_CHANGE with a different env value.
-
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/3] remove long dead DMA_INT

2007-05-04 Thread Guennadi Liakhovetski
DMA_INT code is disabled since 1998, remove it to prepare
for further cleanup.

Signed-off-by: G. Liakhovetski [EMAIL PROTECTED]

diff --git a/drivers/scsi/tmscsim.c b/drivers/scsi/tmscsim.c
index a583e89..d0e171c 100644
--- a/drivers/scsi/tmscsim.c
+++ b/drivers/scsi/tmscsim.c
@@ -625,70 +625,6 @@ dc390_StartSCSI( struct dc390_acb* pACB, struct dc390_dcb* 
pDCB, struct dc390_sr
 return 0;
 }
 
-//#define DMA_INT EN_DMA_INT /*| EN_PAGE_INT*/
-#define DMA_INT 0
-
-#if DMA_INT
-/* This is similar to AM53C974.c ... */
-static u8 
-dc390_dma_intr (struct dc390_acb* pACB)
-{
-  struct dc390_srb* pSRB;
-  u8 dstate;
-  DEBUG0(u16 pstate; struct pci_dev *pdev = pACB-pdev);
-  
-  DEBUG0(pci_read_config_word(pdev, PCI_STATUS, pstate));
-  DEBUG0(if (pstate  (PCI_STATUS_SIG_SYSTEM_ERROR | 
PCI_STATUS_DETECTED_PARITY))\
-   { printk(KERN_WARNING DC390: PCI state = %04x!\n, pstate); \
- pci_write_config_word(pdev, PCI_STATUS, (PCI_STATUS_SIG_SYSTEM_ERROR 
| PCI_STATUS_DETECTED_PARITY));});
-
-  dstate = DC390_read8 (DMA_Status); 
-
-  if (! pACB-pActiveDCB || ! pACB-pActiveDCB-pActiveSRB) return dstate;
-  else pSRB  = pACB-pActiveDCB-pActiveSRB;
-  
-  if (dstate  (DMA_XFER_ABORT | DMA_XFER_ERROR | POWER_DOWN | PCI_MS_ABORT))
-{
-   printk (KERN_ERR DC390: DMA error (%02x)!\n, dstate);
-   return dstate;
-}
-  if (dstate  DMA_XFER_DONE)
-{
-   u32 residual, xferCnt; int ctr = 600;
-   if (! (DC390_read8 (DMA_Cmd)  READ_DIRECTION))
- {
-   do
- {
-   DEBUG1(printk (KERN_DEBUG DC390: read residual bytes ... \n));
-   dstate = DC390_read8 (DMA_Status);
-   residual = DC390_read8 (CtcReg_Low) | DC390_read8 (CtcReg_Mid) 
 8 |
- DC390_read8 (CtcReg_High)  16;
-   residual += DC390_read8 (Current_Fifo)  0x1f;
- } while (residual  ! (dstate  SCSI_INTERRUPT)  --ctr);
-   if (!ctr) printk (KERN_CRIT DC390: dma_intr: DMA aborted 
unfinished: %06x bytes remain!!\n, DC390_read32 (DMA_Wk_ByteCntr));
-   /* residual =  ... */
- }
-   else
-   residual = 0;
-   
-   /* ??? */
-   
-   xferCnt = pSRB-SGToBeXferLen - residual;
-   pSRB-SGBusAddr += xferCnt;
-   pSRB-TotalXferredLen += xferCnt;
-   pSRB-SGToBeXferLen = residual;
-# ifdef DC390_DEBUG0
-   printk (KERN_INFO DC390: DMA: residual = %i, xfer = %i\n, 
-   (unsigned int)residual, (unsigned int)xferCnt);
-# endif
-   
-   DC390_write8 (DMA_Cmd, DMA_IDLE_CMD);
-}
-  dc390_laststatus = ~0xff00; dc390_laststatus |= dstate  24;
-  return dstate;
-}
-#endif
-
 
 static void __inline__
 dc390_InvalidCmd(struct dc390_acb* pACB)
@@ -708,9 +644,6 @@ DC390_Interrupt(void *dev_id)
 u8  phase;
 void   (*stateV)( struct dc390_acb*, struct dc390_srb*, u8 *);
 u8  istate, istatus;
-#if DMA_INT
-u8  dstatus;
-#endif
 
 sstatus = DC390_read8 (Scsi_Status);
 if( !(sstatus  INTERRUPT) )
@@ -718,22 +651,9 @@ DC390_Interrupt(void *dev_id)
 
 DEBUG1(printk (KERN_DEBUG sstatus=%02x,, sstatus));
 
-#if DMA_INT
-spin_lock_irq(pACB-pScsiHost-host_lock);
-dstatus = dc390_dma_intr (pACB);
-spin_unlock_irq(pACB-pScsiHost-host_lock);
-
-DEBUG1(printk (KERN_DEBUG dstatus=%02x,, dstatus));
-if (! (dstatus  SCSI_INTERRUPT))
-  {
-   DEBUG0(printk (KERN_WARNING DC390 Int w/o SCSI actions (only 
DMA?)\n));
-   return IRQ_NONE;
-  }
-#else
 //DC390_write32 (DMA_ScsiBusCtrl, WRT_ERASE_DMA_STAT | 
EN_INT_ON_PCI_ABORT);
 //dstatus = DC390_read8 (DMA_Status);
 //DC390_write32 (DMA_ScsiBusCtrl, EN_INT_ON_PCI_ABORT);
-#endif
 
 spin_lock_irq(pACB-pScsiHost-host_lock);
 
@@ -879,7 +799,7 @@ dc390_DataOut_0( struct dc390_acb* pACB, struct dc390_srb* 
pSRB, u8 *psstatus)
 }
 if ((*psstatus  7) != SCSI_DATA_OUT)
 {
-   DC390_write8 (DMA_Cmd, WRITE_DIRECTION+DMA_IDLE_CMD); /* | DMA_INT 
*/
+   DC390_write8 (DMA_Cmd, WRITE_DIRECTION+DMA_IDLE_CMD);
DC390_write8 (ScsiCmd, CLEAR_FIFO_CMD);
 }  
 }
@@ -924,7 +844,7 @@ dc390_DataIn_0( struct dc390_acb* pACB, struct dc390_srb* 
pSRB, u8 *psstatus)
+ ((unsigned long) DC390_read8 (CtcReg_Low)));
DEBUG1(printk (KERN_DEBUG Count_2_Zero 
(ResidCnt=%i,ToBeXfer=%li),, ResidCnt, pSRB-SGToBeXferLen));
 
-   DC390_write8 (DMA_Cmd, READ_DIRECTION+DMA_IDLE_CMD); /* | DMA_INT */
+   DC390_write8 (DMA_Cmd, READ_DIRECTION+DMA_IDLE_CMD);
 
pSRB-TotalXferredLen += pSRB-SGToBeXferLen;
pSRB-SGIndex++;
@@ -973,7 +893,7 @@ din_1:
}
/* It seems a DMA Blast abort isn't that bad ... */
if (!i) printk (KERN_ERR DC390: DMA Blast aborted unfinished!\n);
-   //DC390_write8 (DMA_Cmd, READ_DIRECTION+DMA_IDLE_CMD); /* | DMA_INT 
*/
+   //DC390_write8 (DMA_Cmd, READ_DIRECTION+DMA_IDLE_CMD);
dc390_laststatus = 

[PATCH 2/3] tmscsim: remove bogus endianness conversions

2007-05-04 Thread Guennadi Liakhovetski
cpu_to_le32 endianness conversions in tmscsim.c, followed by
arithmetic operations don't look correct. Besides, {in,out}[wl]
already perform the necessary conversions. Further, bus addresses
of request buffers are guaranteed to be (mapped) under 4G by
current scsi- and block-layer defaults. This could be explicitly
enforced by using blk_queue_bounce_limit(), which, however,
doesn't seem to be the common practice among SCSI drivers.

Signed-off-by: G. Liakhovetski [EMAIL PROTECTED]

diff --git a/drivers/scsi/tmscsim.c b/drivers/scsi/tmscsim.c
index d0e171c..be869d0 100644
--- a/drivers/scsi/tmscsim.c
+++ b/drivers/scsi/tmscsim.c
@@ -778,8 +778,8 @@ dc390_DataOut_0( struct dc390_acb* pACB, struct dc390_srb* 
pSRB, u8 *psstatus)
pSRB-pSegmentList++;
psgl = pSRB-pSegmentList;
 
-   pSRB-SGBusAddr = 
cpu_to_le32(pci_dma_lo32(sg_dma_address(psgl)));
-   pSRB-SGToBeXferLen = cpu_to_le32(sg_dma_len(psgl));
+   pSRB-SGBusAddr = sg_dma_address(psgl);
+   pSRB-SGToBeXferLen = sg_dma_len(psgl);
}
else
pSRB-SGToBeXferLen = 0;
@@ -842,7 +842,7 @@ dc390_DataIn_0( struct dc390_acb* pACB, struct dc390_srb* 
pSRB, u8 *psstatus)
DEBUG1(ResidCnt = ((unsigned long) DC390_read8 (CtcReg_High)  16) 
\
+ ((unsigned long) DC390_read8 (CtcReg_Mid)  8)   
\
+ ((unsigned long) DC390_read8 (CtcReg_Low)));
-   DEBUG1(printk (KERN_DEBUG Count_2_Zero 
(ResidCnt=%i,ToBeXfer=%li),, ResidCnt, pSRB-SGToBeXferLen));
+   DEBUG1(printk (KERN_DEBUG Count_2_Zero 
(ResidCnt=%u,ToBeXfer=%lu),, ResidCnt, pSRB-SGToBeXferLen));
 
DC390_write8 (DMA_Cmd, READ_DIRECTION+DMA_IDLE_CMD);
 
@@ -853,8 +853,8 @@ dc390_DataIn_0( struct dc390_acb* pACB, struct dc390_srb* 
pSRB, u8 *psstatus)
pSRB-pSegmentList++;
psgl = pSRB-pSegmentList;
 
-   pSRB-SGBusAddr = 
cpu_to_le32(pci_dma_lo32(sg_dma_address(psgl)));
-   pSRB-SGToBeXferLen = cpu_to_le32(sg_dma_len(psgl));
+   pSRB-SGBusAddr = sg_dma_address(psgl);
+   pSRB-SGToBeXferLen = sg_dma_len(psgl);
}
else
pSRB-SGToBeXferLen = 0;
@@ -921,11 +921,12 @@ din_1:
 
ptr = (u8 *) bus_to_virt( pSRB-SGBusAddr );
*ptr = bval;
-   pSRB-SGBusAddr++; xferCnt++;
+   pSRB-SGBusAddr++;
+   xferCnt++;
pSRB-TotalXferredLen++;
pSRB-SGToBeXferLen--;
}
-   DEBUG1(printk (KERN_DEBUG Xfered: %li, Total: %li, Remaining: 
%li\n, xferCnt,\
+   DEBUG1(printk (KERN_DEBUG Xfered: %lu, Total: %lu, Remaining: 
%lu\n, xferCnt,\
   pSRB-TotalXferredLen, pSRB-SGToBeXferLen));
 
}
@@ -1157,14 +1158,14 @@ dc390_restore_ptr (struct dc390_acb* pACB, struct 
dc390_srb* pSRB)
{
pSRB-pSegmentList++;
psgl = pSRB-pSegmentList;
-   pSRB-SGBusAddr = 
cpu_to_le32(pci_dma_lo32(sg_dma_address(psgl)));
-   pSRB-SGToBeXferLen = cpu_to_le32(sg_dma_len(psgl));
+   pSRB-SGBusAddr = sg_dma_address(psgl);
+   pSRB-SGToBeXferLen = sg_dma_len(psgl);
}
else
pSRB-SGToBeXferLen = 0;
}
-   pSRB-SGToBeXferLen -= (pSRB-Saved_Ptr - pSRB-TotalXferredLen);
-   pSRB-SGBusAddr += (pSRB-Saved_Ptr - pSRB-TotalXferredLen);
+   pSRB-SGToBeXferLen -= pSRB-Saved_Ptr - pSRB-TotalXferredLen;
+   pSRB-SGBusAddr += pSRB-Saved_Ptr - pSRB-TotalXferredLen;
printk (KERN_INFO DC390: Pointer restored. Segment %i, Total %li, Bus 
%08lx\n,
pSRB-SGIndex, pSRB-Saved_Ptr, pSRB-SGBusAddr);
 
@@ -1315,8 +1316,8 @@ dc390_DataIO_Comm( struct dc390_acb* pACB, struct 
dc390_srb* pSRB, u8 ioDir)
if( !pSRB-SGToBeXferLen )
{
psgl = pSRB-pSegmentList;
-   pSRB-SGBusAddr = cpu_to_le32(pci_dma_lo32(sg_dma_address(psgl)));
-   pSRB-SGToBeXferLen = cpu_to_le32(sg_dma_len(psgl));
+   pSRB-SGBusAddr = sg_dma_address(psgl);
+   pSRB-SGToBeXferLen = sg_dma_len(psgl);
DEBUG1(printk (KERN_DEBUG  DC390: Next SG segment.));
}
lval = pSRB-SGToBeXferLen;
diff --git a/drivers/scsi/tmscsim.h b/drivers/scsi/tmscsim.h
index 9b66fa8..c3d8c80 100644
--- a/drivers/scsi/tmscsim.h
+++ b/drivers/scsi/tmscsim.h
@@ -19,14 +19,6 @@
 
 #define SEL_TIMEOUT153 /* 250 ms selection timeout (@ 40 MHz) 
*/
 
-#define pci_dma_lo32(a)(a  0x)
-
-typedef u8 UCHAR;  /*  8 bits */
-typedef u16USHORT; /* 16 bits */
-typedef u32UINT;   /* 32 bits */
-typedef unsigned long  ULONG;  /* 32/64 bits */
-
-
 /*
 ;---
 ; SCSI Request Block
@@ -43,7 +35,9 @@ struct 

[PATCH 3/3] tmscsim: Remove the last bus_to_virt()

2007-05-04 Thread Guennadi Liakhovetski
Dynamically map the buffer for PIO for the residue byte.

Signed-off-by: G. Liakhovetski [EMAIL PROTECTED]

diff --git a/drivers/scsi/tmscsim.c b/drivers/scsi/tmscsim.c
index be869d0..aec63ef 100644
--- a/drivers/scsi/tmscsim.c
+++ b/drivers/scsi/tmscsim.c
@@ -351,6 +351,27 @@ static u8  dc390_clock_speed[] = {100,80,67,57,50, 40, 31, 
20};
  * (DCBs, SRBs, Queueing)
  *
  **/
+static void inline dc390_start_segment(struct dc390_srb* pSRB)
+{
+   struct scatterlist *psgl = pSRB-pSegmentList;
+
+   /* start new sg segment */
+   pSRB-SGBusAddr = sg_dma_address(psgl);
+   pSRB-SGToBeXferLen = sg_dma_len(psgl);
+}
+
+static unsigned long inline dc390_advance_segment(struct dc390_srb* pSRB, u32 
residue)
+{
+   unsigned long xfer = pSRB-SGToBeXferLen - residue;
+
+   /* xfer more bytes transferred */
+   pSRB-SGBusAddr += xfer;
+   pSRB-TotalXferredLen += xfer;
+   pSRB-SGToBeXferLen = residue;
+
+   return xfer;
+}
+
 static struct dc390_dcb __inline__ *dc390_findDCB ( struct dc390_acb* pACB, u8 
id, u8 lun)
 {
struct dc390_dcb* pDCB = pACB-pLinkDCB; if (!pDCB) return NULL;
@@ -741,11 +762,10 @@ static irqreturn_t do_DC390_Interrupt(int irq, void 
*dev_id)
 }
 
 static void
-dc390_DataOut_0( struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 *psstatus)
+dc390_DataOut_0(struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 *psstatus)
 {
 u8   sstatus;
-struct scatterlist *psgl;
-u32ResidCnt, xferCnt;
+u32  ResidCnt;
 u8   dstate = 0;
 
 sstatus = *psstatus;
@@ -776,25 +796,20 @@ dc390_DataOut_0( struct dc390_acb* pACB, struct 
dc390_srb* pSRB, u8 *psstatus)
if( pSRB-SGIndex  pSRB-SGcount )
{
pSRB-pSegmentList++;
-   psgl = pSRB-pSegmentList;
 
-   pSRB-SGBusAddr = sg_dma_address(psgl);
-   pSRB-SGToBeXferLen = sg_dma_len(psgl);
+   dc390_start_segment(pSRB);
}
else
pSRB-SGToBeXferLen = 0;
}
else
{
-   ResidCnt  = (u32) DC390_read8 (Current_Fifo)  0x1f;
-   ResidCnt |= (u32) DC390_read8 (CtcReg_High)  16;
-   ResidCnt |= (u32) DC390_read8 (CtcReg_Mid)  8; 
-   ResidCnt += (u32) DC390_read8 (CtcReg_Low);
-
-   xferCnt = pSRB-SGToBeXferLen - ResidCnt;
-   pSRB-SGBusAddr += xferCnt;
-   pSRB-TotalXferredLen += xferCnt;
-   pSRB-SGToBeXferLen = ResidCnt;
+   ResidCnt = ((u32) DC390_read8 (Current_Fifo)  0x1f) +
+   (((u32) DC390_read8 (CtcReg_High)  16) |
+((u32) DC390_read8 (CtcReg_Mid)  8) |
+(u32) DC390_read8 (CtcReg_Low));
+
+   dc390_advance_segment(pSRB, ResidCnt);
}
 }
 if ((*psstatus  7) != SCSI_DATA_OUT)
@@ -805,13 +820,11 @@ dc390_DataOut_0( struct dc390_acb* pACB, struct 
dc390_srb* pSRB, u8 *psstatus)
 }
 
 static void
-dc390_DataIn_0( struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 *psstatus)
+dc390_DataIn_0(struct dc390_acb* pACB, struct dc390_srb* pSRB, u8 *psstatus)
 {
 u8   sstatus, residual, bval;
-struct scatterlist *psgl;
-u32ResidCnt, i;
+u32  ResidCnt, i;
 unsigned long   xferCnt;
-u8  *ptr;
 
 sstatus = *psstatus;
 
@@ -851,10 +864,8 @@ dc390_DataIn_0( struct dc390_acb* pACB, struct dc390_srb* 
pSRB, u8 *psstatus)
if( pSRB-SGIndex  pSRB-SGcount )
{
pSRB-pSegmentList++;
-   psgl = pSRB-pSegmentList;
 
-   pSRB-SGBusAddr = sg_dma_address(psgl);
-   pSRB-SGToBeXferLen = sg_dma_len(psgl);
+   dc390_start_segment(pSRB);
}
else
pSRB-SGToBeXferLen = 0;
@@ -894,41 +905,38 @@ din_1:
/* It seems a DMA Blast abort isn't that bad ... */
if (!i) printk (KERN_ERR DC390: DMA Blast aborted unfinished!\n);
//DC390_write8 (DMA_Cmd, READ_DIRECTION+DMA_IDLE_CMD);
-   dc390_laststatus = ~0xff00; dc390_laststatus |= bval  24;
+   dc390_laststatus = ~0xff00;
+   dc390_laststatus |= bval  24;
 
DEBUG1(printk (KERN_DEBUG Blast: Read %i times DMA_Status %02x, 
0xa000-i, bval));
-   ResidCnt = (u32) DC390_read8 (CtcReg_High);
-   ResidCnt = 8;
-   ResidCnt |= (u32) DC390_read8 (CtcReg_Mid);
-   ResidCnt = 8;
-   ResidCnt |= (u32) DC390_read8 (CtcReg_Low);
-
-   xferCnt = pSRB-SGToBeXferLen - ResidCnt;
-   pSRB-SGBusAddr += xferCnt;
-   pSRB-TotalXferredLen += xferCnt;
-   pSRB-SGToBeXferLen = ResidCnt;
-
-   if( residual )
-   {
-   static int feedback_requested;
+   ResidCnt = (((u32) DC390_read8 (CtcReg_High)  16) |
+   ((u32) DC390_read8 (CtcReg_Mid)  8)) |
+   (u32) DC390_read8 (CtcReg_Low);
+
+

RE: [Bugme-new] [Bug 8426] New: massive slowdown on SCSI CD/DVDdrive connected to mptspi driver

2007-05-04 Thread Doug Chapman
On Fri, 2007-05-04 at 14:34 -0600, Moore, Eric wrote:
 On Thursday, May 03, 2007 9:50 PM,  Doug Chapman wrote:
  
  ACK, tested this on my system where I originally found the problem and
  all is well with this.
  
  Ignore my earlier comment about the original patch adding the new
  function mptspi_initTarget.  After looking at what is going 
  on I realize
  that it didn't add this, it was just renamed from mptscsih_initTarget.
  
 
 Are you still having issues?   I'm not clear with the above ACK email.

I was ACKing Andrew's patch as it fixes the issue for me.  Without the
backup patch it is still broken even in the latest git tree.  (Linus's
tree).

 
 AFAIK, that patch your refering to which I submitted is only moving
 code, not actually changing any functionality.   If your having a
 problem with speed, then its most likely a domain validation problem.

I agree it looks that way.  In fact it took me longer to narrow this
down because I didn't suspect that patch.  But, I tested this multiple
times backing out just that specific patch and it _does_ make the
difference.  It is rather dramatic, takes about 10 minutes to read a
kernel.rpm file from a DVD (takes 2 to 4 seconds normally).

 In this driver, the domain validation is done from the spi transport
 layer.When you load the driver, there should be some messages
 displayed along with the inquiry info during device scan, that would
 provide the negotiation rates. Search your /var/log/messages or dmesg.
 You can also look in the SysFS, and all the info is there as well.   If
 your device is host_W:Channel_X:Target_Y:Lun_Z, then you would look in
 /sys/class/spi_transport_targetW:X:Y:Z/ , in this folder will be period.
 The period is found below at the end of the each line in nano seconds
 units.
 
 factor:0x08   Ultra320 (160 Mega-transfers / second) (6.25 ns)
 factor:0x09   Ultra160 ( 80 Mega-transfers / second) (12.5 ns)
 factor:0x0A   Ultra2   ( 40 Mega-transfers / second) (25 ns)
 factor:0x0B   Ultra2   ( 40 Mega-transfers / second) (30.3 ns)
 factor:0x0C   Ultra( 20 Mega-transfers / second) (50 ns)
 factor:0x19   FAST ( 10 Mega-transfers / second)
 factor:0x32   SCSI (  5 Mega-transfers / second)
 factor:0xFF   5 Mega-trasfers/second and asynchronous
 

/sys/class/spi_transport/target5:0:2/period is 50 with our without the
patch in question.

 
 Also, in the mpt fusion, I have some debug you could enable, which will
 dump all the negotiation parameters as they are written and read from
 via the driver.  The spi transport layer calls these entry points when
 it wants to change the negotiation parameter for each test it runs.  In
 the mpt fusion driver Makefile, you need to uncomment the line
 MPT_DEBUG_DV.   When you do that, then mptspi_print_read_nego and
 mptspi_print_write_nego would be called.

Perhaps I can look into this monday.

 
 I would like to point out that around the same time I supplied that mpt
 fusion patch, there were changes in scsi_transport_spi.c, that would
 effect negotitaion with regards to the starting min sync rate value.
 This file is in /usr/src/linux/drivers/scsi.  You could diff between
 your kernels to see the changes.

I am applying/removing _only_ your patch and the problem goes away with
just removing it.

- Doug


-
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/1] ipr: Fix ipr ata_do_eh API compile warning

2007-05-04 Thread Brian King

This patch fixes the following compile warning:

drivers/scsi/ipr.c: In function '__ipr_eh_dev_reset':
drivers/scsi/ipr.c:3955: warning: passing argument 4 of 'ata_do_eh' from 
incompatible pointer type

This patch reverts the following commit, which looks to have been pushed
before the ata_do_eh API change got pushed.

http://git.kernel.org/gitweb.cgi?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=120bda35ff8514c937dac6d4e5c7dc6c01c699ac;hp=771b8dad9653d2659e0ffcc237184cb16c317788

Signed-off-by: Brian King [EMAIL PROTECTED]
---

 linux-2.6-bjking1/drivers/scsi/ipr.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff -puN drivers/scsi/ipr.c~ipr_ata_do_eh_fix drivers/scsi/ipr.c
--- linux-2.6/drivers/scsi/ipr.c~ipr_ata_do_eh_fix  2007-05-04 
15:13:08.0 -0500
+++ linux-2.6-bjking1/drivers/scsi/ipr.c2007-05-04 17:07:34.0 
-0500
@@ -3857,8 +3857,7 @@ static int ipr_device_reset(struct ipr_i
  * Return value:
  * 0 on success / non-zero on failure
  **/
-static int ipr_sata_reset(struct ata_port *ap, unsigned int *classes,
-   unsigned long deadline)
+static int ipr_sata_reset(struct ata_port *ap, unsigned int *classes)
 {
struct ipr_sata_port *sata_port = ap-private_data;
struct ipr_ioa_cfg *ioa_cfg = sata_port-ioa_cfg;
_
-
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 8426] New: massive slowdown on SCSI CD/DVDdrive connected to mptspi driver

2007-05-04 Thread James Bottomley
On Fri, 2007-05-04 at 17:56 -0400, Doug Chapman wrote:
 I am applying/removing _only_ your patch and the problem goes away with
 just removing it.

What id and channel is this DVD drive on?  There is a potential bug in
the move:

-mptscsih_writeIOCPage4(MPT_SCSI_HOST *hd, int channel, int id)
+mptspi_writeIOCPage4(MPT_SCSI_HOST *hd, u8 channel , u8 id)

Note int became u8, but later we have:


pReq-PageAddress = cpu_to_le32(id | (channel  8 ));

channel  8 is always zero as a u8 entity (unless something promotes
the arithmetic beyond u8).  So if the DVD is on a non-zero channel, we
might have our cause.

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