Re: [PATCH] libata: eliminate the home grown dma padding in favour of that provided by the block layer

2008-01-03 Thread FUJITA Tomonori
On Mon, 31 Dec 2007 15:56:08 -0600
James Bottomley [EMAIL PROTECTED] wrote:

 ATA requires that all DMA transfers begin and end on word boundaries.
 Because of this, a large amount of machinery grew up in ide to adjust
 scatterlists on this basis.  However, as of 2.5, the block layer has a
 dma_alignment variable which ensures both the beginning and length of a
 DMA transfer are aligned on the dma_alignment boundary.  Although the
 block layer does adjust the beginning of the transfer to ensure this
 happens, it doesn't actually adjust the length, it merely makes sure
 that space is allocated for transfers beyond the declared length.  The
 upshot of this is that scatterlists may be padded to any size between
 the actual length and the length adjusted to the dma_alignment safely
 knowing that memory is allocated in this region.

Great!


 diff --git a/include/linux/libata.h b/include/linux/libata.h
 index 124033c..2f40d57 100644
 --- a/include/linux/libata.h
 +++ b/include/linux/libata.h
 @@ -282,7 +282,7 @@ enum {
  
   /* size of buffer to pad xfers ending on unaligned boundaries */
   ATA_DMA_PAD_SZ  = 4,
 - ATA_DMA_PAD_BUF_SZ  = ATA_DMA_PAD_SZ * ATA_MAX_QUEUE,
 + ATA_DMA_PAD_MASK= ATA_DMA_PAD_SZ - 1,
  
   /* ering size */
   ATA_ERING_SIZE  = 32,
 @@ -446,12 +446,9 @@ struct ata_queued_cmd {
   unsigned long   flags;  /* ATA_QCFLAG_xxx */
   unsigned inttag;
   unsigned intn_elem;
 - unsigned intn_iter;
 - unsigned intorig_n_elem;
  
   int dma_dir;
  
 - unsigned intpad_len;
   unsigned intsect_size;
  
   unsigned intnbytes;
 @@ -461,7 +458,6 @@ struct ata_queued_cmd {
   unsigned intcursg_ofs;
  
   struct scatterlist  sgent;
 - struct scatterlist  pad_sgent;
   void*buf_virt;
  
   /* DO NOT iterate over __sg manually, use ata_for_each_sg() */
 @@ -606,9 +602,6 @@ struct ata_port {
   struct ata_prd  *prd;/* our SG list */
   dma_addr_t  prd_dma; /* and its DMA mapping */
  
 - void*pad;   /* array of DMA pad buffers */
 - dma_addr_t  pad_dma;
 -
   struct ata_ioports  ioaddr; /* ATA cmd/ctl/dma register blocks */
  
   u8  ctl;/* cache of ATA control register */
 @@ -1080,24 +1073,15 @@ extern void ata_port_pbar_desc(struct ata_port *ap, 
 int bar, ssize_t offset,
  static inline struct scatterlist *
  ata_qc_first_sg(struct ata_queued_cmd *qc)
  {
 - qc-n_iter = 0;
   if (qc-n_elem)
   return qc-__sg;
 - if (qc-pad_len)
 - return qc-pad_sgent;
   return NULL;
  }
  
  static inline struct scatterlist *
  ata_qc_next_sg(struct scatterlist *sg, struct ata_queued_cmd *qc)
  {
 - if (sg == qc-pad_sgent)
 - return NULL;
 - if (++qc-n_iter  qc-n_elem)
 - return sg_next(sg);
 - if (qc-pad_len)
 - return qc-pad_sgent;
 - return NULL;
 + return sg_next(sg);
  }
  
  #define ata_for_each_sg(sg, qc) \

How about removing ata_qc_first_sg and ata_qc_next_sg completely?

Now we can just replace ata_qc_next_sg with sg_next. qc-__sg seems to
be always initialized to NULL so we can remove ata_qc_first_sg too.


diff --git a/include/linux/libata.h b/include/linux/libata.h
index 4f6404c..2774882 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -1054,25 +1054,8 @@ extern void ata_port_pbar_desc(struct ata_port *ap, int 
bar, ssize_t offset,
   const char *name);
 #endif
 
-/*
- * qc helpers
- */
-static inline struct scatterlist *
-ata_qc_first_sg(struct ata_queued_cmd *qc)
-{
-   if (qc-n_elem)
-   return qc-__sg;
-   return NULL;
-}
-
-static inline struct scatterlist *
-ata_qc_next_sg(struct scatterlist *sg, struct ata_queued_cmd *qc)
-{
-   return sg_next(sg);
-}
-
 #define ata_for_each_sg(sg, qc) \
-   for (sg = ata_qc_first_sg(qc); sg; sg = ata_qc_next_sg(sg, qc))
+   for (sg = qc-__sg; sg; sg = sg_next(sg))
 
 static inline unsigned int ata_tag_valid(unsigned int tag)
 {
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: SATA kernel-buffered read VERY slow (not raid, Promise TX300 card); 2.6.23.1(vanilla)

2008-01-03 Thread Mikael Pettersson
Linda Walsh writes:
  Robert Hancock wrote:
   Linda Walsh wrote:
   Alan Cox wrote:
   rate began falling; at 128k block-reads-at-a-time or larger, it 
   drops below
   20MB/s (only on buffered SATA).
   Try disabling NCQ - see if you've got a drive with the 'NCQ = no
   readahead' flaw.
   http://linux-ata.org/faq.html#ncq
  ---
  When drive initializes, dmesg says it has NCQ (depth 0/32)
  Reading the queue_depth under /sys, shows a queuedepth of 1.
  
  But more importantly -- I notice a chronic error message associate
  with this drive that may be causing some or all of the problem:
  ---
  Jan  2 20:06:10 Ishtar kernel: ata1.00: exception Emask 0x0 SAct 0x0 
  SErr 0x0 action 0x2
  Jan  2 20:06:10 Ishtar kernel: ata1.00: port_status 0x2008
  Jan  2 20:06:10 Ishtar kernel: ata1.00: cmd 
  c8/00:10:30:06:03/00:00:00:00:00/e0 tag 0 cdb 0x0 data 8192 in
  Jan  2 20:06:10 Ishtar kernel:  res 
  50/00:00:3f:06:03/00:00:00:00:00/e0 Emask 0x2 (HSM violation)
  Jan  2 20:06:13 Ishtar kernel: ata1: limiting SATA link speed to 1.5 Gbps
  Jan  2 20:06:13 Ishtar kernel: ata1.00: exception Emask 0x0 SAct 0x0 
  SErr 0x0 action 0x6
  Jan  2 20:06:13 Ishtar kernel: ata1.00: port_status 0x2008
  Jan  2 20:06:13 Ishtar kernel: ata1.00: cmd 
  c8/00:10:00:8b:04/00:00:00:00:00/e0 tag 0 cdb 0x0 data 8192 in
  Jan  2 20:06:13 Ishtar kernel:  res 
  50/00:00:0f:8b:04/00:00:00:00:00/e0 Emask 0x2 (HSM violation)
  Jan  2 20:06:14 Ishtar kernel: ata1: exception Emask 0x10 SAct 0x0 SErr 
  0x0 action 0x3
  Jan  2 20:06:14 Ishtar kernel: ata1: hotplug_status 0x80
  Jan  2 20:06:15 Ishtar kernel: ata1: exception Emask 0x10 SAct 0x0 SErr 
  0x0 action 0x3
  Jan  2 20:06:15 Ishtar kernel: ata1: hotplug_status 0x80
  ---
  What da heck?

Looks like the Promise ASIC SG bug. Apply
http://user.it.uu.se/~mikpe/linux/patches/sata_promise/patch-sata_promise-1-asic-sg-bug-fix-v3-2.6.23
and let us know if things improve.

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


[RESEND PATCH 0/10] ide-floppy redux p1

2008-01-03 Thread Borislav Petkov

Hi Bart,

here's the unfinished redux of ide-floppy which i'm REsending now so that we 
could
sinchronize trees. The original send got busted in vger's filters due to syntax
error in the Message-ID tag.

 Documentation/ide/ChangeLog.ide-floppy.1996-2002 |   64 ++
 drivers/ide/ide-floppy.c | 1248 +++---
 drivers/ide/ide-floppy.h |  351 ++
 include/linux/cdrom.h|1 +
 4 files changed, 819 insertions(+), 845 deletions(-)

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


[RESEND PATCH 05/10] ide-floppy: factor out ioctl handlers from idefloppy_ioctl()

2008-01-03 Thread Borislav Petkov
There should be no functional change resulting from this patch.

Signed-off-by: Borislav Petkov [EMAIL PROTECTED]
---
 drivers/ide/ide-floppy.c |   90 +-
 1 files changed, 57 insertions(+), 33 deletions(-)

diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 196a697..7823447 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -1600,6 +1600,58 @@ static int idefloppy_getgeo(struct block_device *bdev, 
struct hd_geometry *geo)
return 0;
 }
 
+static int idefloppy_lockdoor(struct inode *inode, idefloppy_pc_t *pc,
+   int event, unsigned int cmd)
+{
+   struct block_device *bdev = inode-i_bdev;
+   struct ide_floppy_obj *floppy = ide_floppy_g(bdev-bd_disk);
+   ide_drive_t *drive = floppy-drive;
+
+   if (floppy-openers  1)
+   return -EBUSY;
+
+   /* The IOMEGA Clik! Drive doesn't support this command -
+* no room for an eject mechanism */
+   if (!test_bit(IDEFLOPPY_CLIK_DRIVE, floppy-flags)) {
+   idefloppy_create_prevent_cmd(pc, event);
+   (void) idefloppy_queue_pc_tail(drive, pc);
+   }
+
+   if (cmd == CDROMEJECT) {
+   idefloppy_create_start_stop_cmd(pc, 2);
+   (void) idefloppy_queue_pc_tail(drive, pc);
+   }
+
+   return 0;
+}
+
+static
+int idefloppy_format_start(struct file *file, struct inode *inode,
+   void __user *argp)
+{
+   struct block_device *bdev = inode-i_bdev;
+   struct ide_floppy_obj *floppy = ide_floppy_g(bdev-bd_disk);
+   ide_drive_t *drive = floppy-drive;
+   int err;
+
+   if (!(file-f_mode  2))
+   return -EPERM;
+
+   if (floppy-openers  1) {
+   /* Don't format if someone is using the disk */
+   clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, floppy-flags);
+   return -EBUSY;
+   }
+
+   set_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, floppy-flags);
+
+   err = idefloppy_begin_format(drive, argp);
+   if (err)
+   clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, floppy-flags);
+
+   return err;
+}
+
 static int idefloppy_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
 {
@@ -1612,47 +1664,19 @@ static int idefloppy_ioctl(struct inode *inode, struct 
file *file,
idefloppy_pc_t pc;
 
switch (cmd) {
+
case CDROMEJECT:
prevent = 0;
/* fall through */
-   case CDROM_LOCKDOOR:
-   if (floppy-openers  1)
-   return -EBUSY;
 
-   /* The IOMEGA Clik! Drive doesn't support this command -
-* no room for an eject mechanism */
-if (!test_bit(IDEFLOPPY_CLIK_DRIVE, floppy-flags)) {
-   idefloppy_create_prevent_cmd(pc, prevent);
-   (void) idefloppy_queue_pc_tail(drive, pc);
-   }
-   if (cmd == CDROMEJECT) {
-   idefloppy_create_start_stop_cmd(pc, 2);
-   (void) idefloppy_queue_pc_tail(drive, pc);
-   }
-   return 0;
+   case CDROM_LOCKDOOR:
+   return idefloppy_lockdoor(inode, pc, prevent, cmd);
case IDEFLOPPY_IOCTL_FORMAT_SUPPORTED:
return 0;
case IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY:
return idefloppy_get_format_capacities(drive, argp);
case IDEFLOPPY_IOCTL_FORMAT_START:
-
-   if (!(file-f_mode  2))
-   return -EPERM;
-
-   if (floppy-openers  1) {
-
-   /* Don't format if someone is using the disk */
-   clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS,
- floppy-flags);
-   return -EBUSY;
-   }
-
-   set_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, floppy-flags);
-
-   err = idefloppy_begin_format(drive, argp);
-   if (err)
-   clear_bit(IDEFLOPPY_FORMAT_IN_PROGRESS, floppy-flags);
-   return err;
+   return idefloppy_format_start(file, inode, argp);
/*
 * Note, the bit will be cleared when the device is
 * closed.  This is the cleanest way to handle the
@@ -1669,7 +1693,7 @@ static int idefloppy_ioctl(struct inode *inode, struct 
file *file,
 */
if (cmd != CDROM_SEND_PACKET  cmd != SCSI_IOCTL_SEND_COMMAND)
err = scsi_cmd_ioctl(file, bdev-bd_disk-queue,
-   bdev-bd_disk, cmd, argp);
+   bdev-bd_disk, cmd, argp);
else
err = -ENOTTY;
 
-- 
1.5.3.7

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


[RESEND PATCH 03/10] ide-floppy: convert to generic packet commands

2008-01-03 Thread Borislav Petkov
Replace the ide-floppy packet commands opcode defines with the generic ones.
Add a missing GPCMD_WRITE_12 (opcode 0xaa) to the generic ones in cdrom.h. The
last one can be found in the current version of INF-8090, p.905.

CC: Jens Axboe [EMAIL PROTECTED]
Signed-off-by: Borislav Petkov [EMAIL PROTECTED]
---
 drivers/ide/ide-floppy.c |   26 +-
 drivers/ide/ide-floppy.h |   21 -
 include/linux/cdrom.h|1 +
 3 files changed, 14 insertions(+), 34 deletions(-)

diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 52d09c1..4fb6128 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -313,7 +313,7 @@ static void idefloppy_init_pc (idefloppy_pc_t *pc)
 static void idefloppy_create_request_sense_cmd (idefloppy_pc_t *pc)
 {
idefloppy_init_pc(pc);
-   pc-c[0] = IDEFLOPPY_REQUEST_SENSE_CMD;
+   pc-c[0] = GPCMD_REQUEST_SENSE;
pc-c[4] = 255;
pc-request_transfer = 18;
pc-callback = idefloppy_request_sense_callback;
@@ -379,7 +379,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t 
*drive)
debug_log(KERN_INFO ide-floppy: %s: I/O error\n,
drive-name);
rq-errors++;
-   if (pc-c[0] == IDEFLOPPY_REQUEST_SENSE_CMD) {
+   if (pc-c[0] == GPCMD_REQUEST_SENSE) {
printk(KERN_ERR ide-floppy: I/O error in 
request sense command\n);
return ide_do_reset(drive);
@@ -586,8 +586,8 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t 
*drive, idefloppy_pc_t *p
  and have lived on another thread's stack; that stack may have become
  unmapped meanwhile (CONFIG_DEBUG_PAGEALLOC). */
 #if IDEFLOPPY_DEBUG_BUGS
-   if (floppy-pc-c[0] == IDEFLOPPY_REQUEST_SENSE_CMD 
-   pc-c[0] == IDEFLOPPY_REQUEST_SENSE_CMD) {
+   if (floppy-pc-c[0] == GPCMD_REQUEST_SENSE 
+   pc-c[0] == GPCMD_REQUEST_SENSE) {
printk(KERN_ERR ide-floppy: possible ide-floppy.c bug - 
Two request sense in serial were issued\n);
}
@@ -595,7 +595,7 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t 
*drive, idefloppy_pc_t *p
 #endif
 
if (floppy-failed_pc == NULL 
-   pc-c[0] != IDEFLOPPY_REQUEST_SENSE_CMD)
+   pc-c[0] != GPCMD_REQUEST_SENSE)
floppy-failed_pc = pc;
/* Set the current packet command */
floppy-pc = pc;
@@ -690,14 +690,14 @@ static void idefloppy_create_prevent_cmd (idefloppy_pc_t 
*pc, int prevent)
prevent = %d\n, prevent);
 
idefloppy_init_pc(pc);
-   pc-c[0] = IDEFLOPPY_PREVENT_REMOVAL_CMD;
+   pc-c[0] = GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL;
pc-c[4] = prevent;
 }
 
 static void idefloppy_create_read_capacity_cmd (idefloppy_pc_t *pc)
 {
idefloppy_init_pc(pc);
-   pc-c[0] = IDEFLOPPY_READ_CAPACITY_CMD;
+   pc-c[0] = GPCMD_READ_FORMAT_CAPACITIES;
pc-c[7] = 255;
pc-c[8] = 255;
pc-request_transfer = 255;
@@ -707,7 +707,7 @@ static void idefloppy_create_format_unit_cmd 
(idefloppy_pc_t *pc, int b, int l,
  int flags)
 {
idefloppy_init_pc(pc);
-   pc-c[0] = IDEFLOPPY_FORMAT_UNIT_CMD;
+   pc-c[0] = GPCMD_FORMAT_UNIT;
pc-c[1] = 0x17;
 
memset(pc-buffer, 0, 12);
@@ -733,7 +733,7 @@ static void idefloppy_create_mode_sense_cmd (idefloppy_pc_t 
*pc, u8 page_code,
u16 length = sizeof(idefloppy_mode_par_hdr_t);
 
idefloppy_init_pc(pc);
-   pc-c[0] = IDEFLOPPY_MODE_SENSE_CMD;
+   pc-c[0] = GPCMD_MODE_SENSE_10;
pc-c[1] = 0;
pc-c[2] = page_code + (type  6);
 
@@ -755,14 +755,14 @@ static void idefloppy_create_mode_sense_cmd 
(idefloppy_pc_t *pc, u8 page_code,
 static void idefloppy_create_start_stop_cmd (idefloppy_pc_t *pc, int start)
 {
idefloppy_init_pc(pc);
-   pc-c[0] = IDEFLOPPY_START_STOP_CMD;
+   pc-c[0] = GPCMD_START_STOP_UNIT;
pc-c[4] = start;
 }
 
 static void idefloppy_create_test_unit_ready_cmd(idefloppy_pc_t *pc)
 {
idefloppy_init_pc(pc);
-   pc-c[0] = IDEFLOPPY_TEST_UNIT_READY_CMD;
+   pc-c[0] = GPCMD_TEST_UNIT_READY;
 }
 
 static void idefloppy_create_rw_cmd (idefloppy_t *floppy, idefloppy_pc_t *pc,
@@ -778,10 +778,10 @@ static void idefloppy_create_rw_cmd (idefloppy_t *floppy, 
idefloppy_pc_t *pc,
 
idefloppy_init_pc(pc);
if (test_bit(IDEFLOPPY_USE_READ12, floppy-flags)) {
-   pc-c[0] = cmd == READ ? IDEFLOPPY_READ12_CMD : 
IDEFLOPPY_WRITE12_CMD;
+   pc-c[0] = cmd == READ ? GPCMD_READ_12 : GPCMD_WRITE_12;
put_unaligned(htonl(blocks), (unsigned int *) pc-c[6]);
} else {
-   pc-c[0] = cmd == READ ? IDEFLOPPY_READ10_CMD : 
IDEFLOPPY_WRITE10_CMD;
+   

[RESEND PATCH 01/10] move ide-floppy historical changelog to Documentation/ide/ChangeLog.ide-floppy.1996-2002;

2008-01-03 Thread Borislav Petkov
Signed-off-by: Borislav Petkov [EMAIL PROTECTED]
---
 Documentation/ide/ChangeLog.ide-floppy.1996-2002 |   64 
 drivers/ide/ide-floppy.c |   69 +-
 2 files changed, 67 insertions(+), 66 deletions(-)

diff --git a/Documentation/ide/ChangeLog.ide-floppy.1996-2002 
b/Documentation/ide/ChangeLog.ide-floppy.1996-2002
new file mode 100644
index 000..70166f3
--- /dev/null
+++ b/Documentation/ide/ChangeLog.ide-floppy.1996-2002
@@ -0,0 +1,64 @@
+/*
+ * Many thanks to Lode Leroy [EMAIL PROTECTED], who tested so many
+ * ALPHA patches to this driver on an EASYSTOR LS-120 ATAPI floppy drive.
+ *
+ * Ver 0.1   Oct 17 96   Initial test version, mostly based on ide-tape.c.
+ * Ver 0.2   Oct 31 96   Minor changes.
+ * Ver 0.3   Dec  2 96   Fixed error recovery bug.
+ * Ver 0.4   Jan 26 97   Add support for the HDIO_GETGEO ioctl.
+ * Ver 0.5   Feb 21 97   Add partitions support.
+ *   Use the minimum of the LBA and CHS capacities.
+ *   Avoid hwgroup-rq == NULL on the last irq.
+ *   Fix potential null dereferencing with DEBUG_LOG.
+ * Ver 0.8   Dec  7 97   Increase irq timeout from 10 to 50 seconds.
+ *   Add media write-protect detection.
+ *   Issue START command only if TEST UNIT READY fails.
+ *   Add work-around for IOMEGA ZIP revision 21.D.
+ *   Remove idefloppy_get_capabilities().
+ * Ver 0.9   Jul  4 99   Fix a bug which might have caused the number of
+ *bytes requested on each interrupt to be zero.
+ *Thanks to [EMAIL PROTECTED] for pointing this out.
+ * Ver 0.9.sv Jan 6 01   Sam Varshavchik [EMAIL PROTECTED]
+ *   Implement low level formatting.  Reimplemented
+ *   IDEFLOPPY_CAPABILITIES_PAGE, since we need the srfp
+ *   bit.  My LS-120 drive barfs on
+ *   IDEFLOPPY_CAPABILITIES_PAGE, but maybe it's just me.
+ *   Compromise by not reporting a failure to get this
+ *   mode page.  Implemented four IOCTLs in order to
+ *   implement formatting.  IOCTls begin with 0x4600,
+ *   0x46 is 'F' as in Format.
+ *Jan 9 01   Userland option to select format verify.
+ *   Added PC_SUPPRESS_ERROR flag - some idefloppy drives
+ *   do not implement IDEFLOPPY_CAPABILITIES_PAGE, and
+ *   return a sense error.  Suppress error reporting in
+ *   this particular case in order to avoid spurious
+ *   errors in syslog.  The culprit is
+ *   idefloppy_get_capability_page(), so move it to
+ *   idefloppy_begin_format() so that it's not used
+ *   unless absolutely necessary.
+ *   If drive does not support format progress indication
+ *   monitor the dsc bit in the status register.
+ *   Also, O_NDELAY on open will allow the device to be
+ *   opened without a disk available.  This can be used to
+ *   open an unformatted disk, or get the device capacity.
+ * Ver 0.91  Dec 11 99   Added IOMEGA Clik! drive support by 
+ *[EMAIL PROTECTED]
+ * Ver 0.92  Oct 22 00   Paul Bristow became official maintainer for this 
+ *driver.  Included Powerbook internal zip kludge.
+ * Ver 0.93  Oct 24 00   Fixed bugs for Clik! drive
+ *no disk on insert and disk change now works
+ * Ver 0.94  Oct 27 00   Tidied up to remove strstr(Clik) everywhere
+ * Ver 0.95  Nov  7 00   Brought across to kernel 2.4
+ * Ver 0.96  Jan  7 01   Actually in line with release version of 2.4.0
+ *   including set_bit patch from Rusty Russell
+ * Ver 0.97  Jul 22 01   Merge 0.91-0.96 onto 0.9.sv for ac series
+ * Ver 0.97.sv Aug 3 01  Backported from 2.4.7-ac3
+ * Ver 0.98  Oct 26 01   Split idefloppy_transfer_pc into two pieces to
+ *fix a lost interrupt problem. It appears the busy
+ *bit was being deasserted by my IOMEGA ATAPI ZIP 100
+ *drive before the drive was actually ready.
+ * Ver 0.98a Oct 29 01   Expose delay value so we can play.
+ * Ver 0.99  Feb 24 02   Remove duplicate code, modify clik! detection code 
+ *to support new PocketZip drives 
+ */
+
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 04a3578..785fbde 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -1,12 +1,8 @@
 /*
- * linux/drivers/ide/ide-floppy.c  Version 0.99Feb 24 2002
+ * IDE ATAPI floppy driver.
  *
  * Copyright (C) 1996 - 1999 Gadi Oxman [EMAIL PROTECTED]
  * Copyright 

[RESEND PATCH 02/10] ide-floppy: move ide-floppy struct and macro defs into its own header. While at it

2008-01-03 Thread Borislav Petkov
- do a white-space cleanup
- remove old crufty code untouched since at least 2005
- shorten lines longer than 80ish columns
- shorten some LAAARGE typenames.

There should be no functional changes resulting from this patch.

Signed-off-by: Borislav Petkov [EMAIL PROTECTED]
---
 drivers/ide/ide-floppy.c |  763 --
 drivers/ide/ide-floppy.h |  382 +++
 2 files changed, 581 insertions(+), 564 deletions(-)

diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 785fbde..52d09c1 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -44,418 +44,7 @@
 #include asm/io.h
 #include asm/unaligned.h
 
-/*
- * The following are used to debug the driver.
- */
-#define IDEFLOPPY_DEBUG_LOG0
-#define IDEFLOPPY_DEBUG_INFO   0
-#define IDEFLOPPY_DEBUG_BUGS   1
-
-/* #define IDEFLOPPY_DEBUG(fmt, args...) printk(KERN_INFO fmt, ## args) */
-#define IDEFLOPPY_DEBUG( fmt, args... )
-
-#if IDEFLOPPY_DEBUG_LOG
-#define debug_log printk
-#else
-#define debug_log(fmt, args... ) do {} while(0)
-#endif
-
-
-/*
- * Some drives require a longer irq timeout.
- */
-#define IDEFLOPPY_WAIT_CMD (5 * WAIT_CMD)
-
-/*
- * After each failed packet command we issue a request sense command
- * and retry the packet command IDEFLOPPY_MAX_PC_RETRIES times.
- */
-#define IDEFLOPPY_MAX_PC_RETRIES   3
-
-/*
- * With each packet command, we allocate a buffer of
- * IDEFLOPPY_PC_BUFFER_SIZE bytes.
- */
-#define IDEFLOPPY_PC_BUFFER_SIZE   256
-
-/*
- * In various places in the driver, we need to allocate storage
- * for packet commands and requests, which will remain valid while
- * we leave the driver to wait for an interrupt or a timeout event.
- */
-#define IDEFLOPPY_PC_STACK (10 + IDEFLOPPY_MAX_PC_RETRIES)
-
-/*
- * Our view of a packet command.
- */
-typedef struct idefloppy_packet_command_s {
-   u8 c[12];   /* Actual packet bytes */
-   int retries;/* On each retry, we increment 
retries */
-   int error;  /* Error code */
-   int request_transfer;   /* Bytes to transfer */
-   int actually_transferred;   /* Bytes actually transferred */
-   int buffer_size;/* Size of our data buffer */
-   int b_count;/* Missing/Available data on 
the current buffer */
-   struct request *rq; /* The corresponding request */
-   u8 *buffer; /* Data buffer */
-   u8 *current_position;   /* Pointer into the above 
buffer */
-   void (*callback) (ide_drive_t *);   /* Called when this packet 
command is completed */
-   u8 pc_buffer[IDEFLOPPY_PC_BUFFER_SIZE]; /* Temporary buffer */
-   unsigned long flags;/* Status/Action bit flags: 
long for set_bit */
-} idefloppy_pc_t;
-
-/*
- * Packet command flag bits.
- */
-#definePC_ABORT0   /* Set when an error is 
considered normal - We won't retry */
-#define PC_DMA_RECOMMENDED 2   /* 1 when we prefer to use DMA 
if possible */
-#definePC_DMA_IN_PROGRESS  3   /* 1 while DMA in 
progress */
-#definePC_DMA_ERROR4   /* 1 when encountered 
problem during DMA */
-#definePC_WRITING  5   /* Data direction */
-
-#definePC_SUPPRESS_ERROR   6   /* Suppress error 
reporting */
-
-/*
- * Removable Block Access Capabilities Page
- */
-typedef struct {
-#if defined(__LITTLE_ENDIAN_BITFIELD)
-   unsignedpage_code   :6; /* Page code - Should be 0x1b */
-   unsignedreserved1_6 :1; /* Reserved */
-   unsignedps  :1; /* Should be 0 */
-#elif defined(__BIG_ENDIAN_BITFIELD)
-   unsignedps  :1; /* Should be 0 */
-   unsignedreserved1_6 :1; /* Reserved */
-   unsignedpage_code   :6; /* Page code - Should be 0x1b */
-#else
-#error Bitfield endianness not defined! Check your byteorder.h
-#endif
-   u8  page_length;/* Page Length - Should be 0xa 
*/
-#if defined(__LITTLE_ENDIAN_BITFIELD)
-   unsignedreserved2   :6;
-   unsignedsrfp:1; /* Supports reporting progress 
of format */
-   unsignedsflp:1; /* System floppy type device */
-   unsignedtlun:3; /* Total logical units 
supported by the device */
-   unsignedreserved3   :3;
-   unsignedsml :1; /* Single / Multiple lun 
supported */
-   unsignedncd :1; /* Non cd optical device */
-#elif 

[RESEND PATCH 07/10] ide-floppy: remove unnecessary -handler != NULL check

2008-01-03 Thread Borislav Petkov
This BUG_ON is unneeded since the -handler != NULL check is performed in
ide_set_handler().

Signed-off-by: Borislav Petkov [EMAIL PROTECTED]
---
 drivers/ide/ide-floppy.c |8 +++-
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 5d0fd1f..2c139e7 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -421,7 +421,7 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive)
to send us more data than expected 
- discarding data\n);
idefloppy_discard_data(drive,bcount.all);
-   BUG_ON(HWGROUP(drive)-handler != NULL);
+
ide_set_handler(drive,
idefloppy_pc_intr,
IDEFLOPPY_WAIT_CMD,
@@ -453,8 +453,6 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive)
pc-actually_transferred += bcount.all;
pc-current_position += bcount.all;
 
-   BUG_ON(HWGROUP(drive)-handler != NULL);
-
/* And set the interrupt handler again */
ide_set_handler(drive, idefloppy_pc_intr, IDEFLOPPY_WAIT_CMD, NULL);
return ide_started;
@@ -482,7 +480,7 @@ static ide_startstop_t idefloppy_transfer_pc(ide_drive_t 
*drive)
issuing a packet command\n);
return ide_do_reset(drive);
}
-   BUG_ON(HWGROUP(drive)-handler != NULL);
+
/* Set the interrupt routine */
ide_set_handler(drive, idefloppy_pc_intr, IDEFLOPPY_WAIT_CMD, NULL);
/* Send the actual packet */
@@ -537,7 +535,7 @@ static ide_startstop_t idefloppy_transfer_pc1(ide_drive_t 
*drive)
 * 40 and 50msec work well. idefloppy_pc_intr will not be actually
 * used until after the packet is moved in about 50 msec.
 */
-   BUG_ON(HWGROUP(drive)-handler != NULL);
+
ide_set_handler(drive,
  idefloppy_pc_intr,   /* service routine for packet command */
  floppy-ticks,/* wait this long before failing */
-- 
1.5.3.7

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


[RESEND PATCH 09/10] ide-floppy: use test_bit wrappers for testing flags

2008-01-03 Thread Borislav Petkov
also, fix header comments and remove superfluous ones. There should be no
functionality change resulting from this patch.

Signed-off-by: Borislav Petkov [EMAIL PROTECTED]
---
 drivers/ide/ide-floppy.c |   45 -
 drivers/ide/ide-floppy.h |  127 +-
 2 files changed, 79 insertions(+), 93 deletions(-)

diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index fd5fe7b..6c29b5f 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -337,7 +337,7 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive)
 
debug_log(Reached %s interrupt handler\n, __FUNCTION__);
 
-   if (test_bit(PC_DMA_IN_PROGRESS, pc-flags)) {
+   if (idefl_dma_ongoing(pc)) {
 
dma_error = HWIF(drive)-ide_dma_end(drive);
if (dma_error) {
@@ -365,7 +365,7 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive)
 
local_irq_enable_in_hardirq();
 
-   if (status.b.check || test_bit(PC_DMA_ERROR, pc-flags)) {
+   if (status.b.check || idefl_dma_err(pc)) {
/* Error detected */
debug_log(%s: I/O error\n, drive-name);
rq-errors++;
@@ -404,7 +404,7 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive)
printk(KERN_ERR ide-floppy: CoD != 0 in idefloppy_pc_intr\n);
return ide_do_reset(drive);
}
-   if (ireason.b.io == test_bit(PC_WRITING, pc-flags)) {
+   if (ireason.b.io == idefl_data_dir(pc)) {
/* Hopefully, we will never get here */
printk(KERN_ERR ide-floppy: We wanted to %s, ,
ireason.b.io ? Write:Read);
@@ -412,7 +412,7 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive)
ireason.b.io ? Read:Write);
return ide_do_reset(drive);
}
-   if (!test_bit(PC_WRITING, pc-flags)) {
+   if (!idefl_data_dir(pc)) {
/* Reading - Check that we have enough space */
temp = pc-actually_transferred + bcount.all;
if (temp  pc-request_transfer) {
@@ -432,7 +432,7 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive)
expected - allowing transfer\n);
}
}
-   if (test_bit(PC_WRITING, pc-flags)) {
+   if (idefl_data_dir(pc)) {
if (pc-buffer != NULL)
/* Write the current buffer */
HWIF(drive)-atapi_output_bytes(drive,
@@ -579,14 +579,13 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t 
*drive, idefloppy_pc_t *pc
/* Set the current packet command */
floppy-pc = pc;
 
-   if (pc-retries  IDEFLOPPY_MAX_PC_RETRIES ||
-   test_bit(PC_ABORT, pc-flags)) {
+   if (pc-retries  IDEFLOPPY_MAX_PC_RETRIES || idefl_abort(pc)) {
/*
-*  We will abort retrying a packet command in case
-*  a legitimate error code was received.
+* We will abort retrying a packet command in case a
+* legitimate error code was received.
 */
-   if (!test_bit(PC_ABORT, pc-flags)) {
-   if (!test_bit(PC_SUPPRESS_ERROR, pc-flags)) {
+   if (!idefl_abort(pc)) {
+   if (!idefl_supp_err(pc)) {
if (idefloppy_report_error(floppy))
printk(KERN_ERR ide-floppy: %s: I/O 
error, 
   pc = %2x, key = %2x, 
@@ -616,7 +615,7 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t 
*drive, idefloppy_pc_t *pc
 
feature.all = 0;
 
-   if (test_bit(PC_DMA_RECOMMENDED, pc-flags)  drive-using_dma)
+   if (idefl_dma_prefd(pc)  drive-using_dma)
feature.b.dma = !hwif-dma_setup(drive);
 
if (IDE_CONTROL_REG)
@@ -633,7 +632,7 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t 
*drive, idefloppy_pc_t *pc
}
 
/* Can we transfer the packet when we get the interrupt or wait? */
-   if (test_bit(IDEFLOPPY_ZIP_DRIVE, floppy-flags)) {
+   if (idefl_zip_drive(floppy)) {
/* wait */
pkt_xfer_routine = idefloppy_transfer_pc1;
} else {
@@ -641,7 +640,7 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t 
*drive, idefloppy_pc_t *pc
pkt_xfer_routine = idefloppy_transfer_pc;
}
 
-   if (test_bit(IDEFLOPPY_DRQ_INTERRUPT, floppy-flags)) {
+   if (idefl_drq_intr(floppy)) {
/* Issue the packet command */
ide_execute_command(drive, WIN_PACKETCMD,
pkt_xfer_routine,
@@ -749,11 +748,10 @@ static void idefloppy_create_rw_cmd(idefloppy_t *floppy, 
idefloppy_pc_t *pc,
int cmd = rq_data_dir(rq);
 

[RESEND PATCH 04/10] ide-floppy: cleanup debugging macros

2008-01-03 Thread Borislav Petkov
There should be no functional change resulting from this patch.

Signed-off-by: Borislav Petkov [EMAIL PROTECTED]
---
 drivers/ide/ide-floppy.c |   58 +
 drivers/ide/ide-floppy.h |3 +-
 2 files changed, 29 insertions(+), 32 deletions(-)

diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 4fb6128..196a697 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -105,7 +105,7 @@ static int idefloppy_do_end_request(ide_drive_t *drive, int 
uptodate, int nsecs)
struct request *rq = HWGROUP(drive)-rq;
int error;
 
-   debug_log(KERN_INFO Reached idefloppy_end_request\n);
+   debug_log(Reached %s\n, __FUNCTION__);
 
switch (uptodate) {
case 0: error = IDEFLOPPY_ERROR_GENERAL; break;
@@ -257,13 +257,12 @@ static void idefloppy_analyze_error (ide_drive_t *drive,
floppy-progress_indication = result-sksv[0]  0x80 ?
(u16)get_unaligned((u16 *)(result-sksv+1)):0x1;
if (floppy-failed_pc)
-   debug_log(KERN_INFO ide-floppy: pc = %x, sense key = %x, 
-   asc = %x, ascq = %x\n, floppy-failed_pc-c[0],
-   result-sense_key, result-asc, result-ascq);
+   debug_log(pc = %x, sense key = %x, asc = %x, ascq = %x\n,
+   floppy-failed_pc-c[0], result-sense_key,
+   result-asc, result-ascq);
else
-   debug_log(KERN_INFO ide-floppy: sense key = %x, asc = %x, 
-   ascq = %x\n, result-sense_key,
-   result-asc, result-ascq);
+   debug_log(sense key = %x, asc = %x, ascq = %x\n,
+   result-sense_key, result-asc, result-ascq);
 }
 
 static void idefloppy_request_sense_callback (ide_drive_t *drive)
@@ -271,7 +270,7 @@ static void idefloppy_request_sense_callback (ide_drive_t 
*drive)
idefloppy_t *floppy = drive-driver_data;
u8 *buf = floppy-pc-buffer;
 
-   debug_log(KERN_INFO ide-floppy: Reached %s\n, __FUNCTION__);
+   debug_log(Reached %s\n, __FUNCTION__);
 
if (!floppy-pc-error) {
idefloppy_analyze_error(drive, (rq_sense_res_t *) buf);
@@ -291,7 +290,7 @@ static void idefloppy_pc_callback (ide_drive_t *drive)
 {
idefloppy_t *floppy = drive-driver_data;
 
-   debug_log(KERN_INFO ide-floppy: Reached %s\n, __FUNCTION__);
+   debug_log(Reached %s\n, __FUNCTION__);
 
idefloppy_do_end_request(drive, floppy-pc-error ? 0 : 1, 0);
 }
@@ -351,8 +350,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t 
*drive)
struct request *rq = pc-rq;
unsigned int temp;
 
-   debug_log(KERN_INFO ide-floppy: Reached %s interrupt handler\n,
-   __FUNCTION__);
+   debug_log(Reached %s interrupt handler\n, __FUNCTION__);
 
if (test_bit(PC_DMA_IN_PROGRESS, pc-flags)) {
if (HWIF(drive)-ide_dma_end(drive)) {
@@ -361,23 +359,23 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t 
*drive)
pc-actually_transferred = pc-request_transfer;
idefloppy_update_buffers(drive, pc);
}
-   debug_log(KERN_INFO ide-floppy: DMA finished\n);
+   debug_log(%s: DMA finished\n, __FUNCTION__);
}
 
/* Clear the interrupt */
status.all = HWIF(drive)-INB(IDE_STATUS_REG);
 
if (!status.b.drq) {/* No more interrupts */
-   debug_log(KERN_INFO Packet command completed, %d bytes 
-   transferred\n, pc-actually_transferred);
+   debug_log(Packet command completed, %d bytes transferred\n,
+   pc-actually_transferred);
+
clear_bit(PC_DMA_IN_PROGRESS, pc-flags);
 
local_irq_enable_in_hardirq();
 
if (status.b.check || test_bit(PC_DMA_ERROR, pc-flags)) {
/* Error detected */
-   debug_log(KERN_INFO ide-floppy: %s: I/O error\n,
-   drive-name);
+   debug_log(%s: I/O error\n, drive-name);
rq-errors++;
if (pc-c[0] == GPCMD_REQUEST_SENSE) {
printk(KERN_ERR ide-floppy: I/O error in 
@@ -438,9 +436,8 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t 
*drive)
NULL);
return ide_started;
}
-   debug_log(KERN_NOTICE ide-floppy: The floppy wants to 
-   send us more data than expected - 
-   allowing transfer\n);
+   debug_log(The floppy wants to send us more data than
+   expected - allowing transfer\n);
}
  

[RESEND PATCH 08/10] ide-floppy: mv idefloppy_{should_,}report_error

2008-01-03 Thread Borislav Petkov
Signed-off-by: Borislav Petkov [EMAIL PROTECTED]
---
 drivers/ide/ide-floppy.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 2c139e7..fd5fe7b 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -544,7 +544,7 @@ static ide_startstop_t idefloppy_transfer_pc1(ide_drive_t 
*drive)
 }
 
 /* Supresses error messages resulting from Medium not present */
-static inline int idefloppy_should_report_error(idefloppy_t *floppy)
+static inline int idefloppy_report_error(idefloppy_t *floppy)
 {
if (floppy-sense_key == 0x02 
floppy-asc   == 0x3a 
@@ -587,7 +587,7 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t 
*drive, idefloppy_pc_t *pc
 */
if (!test_bit(PC_ABORT, pc-flags)) {
if (!test_bit(PC_SUPPRESS_ERROR, pc-flags)) {
-   if (idefloppy_should_report_error(floppy))
+   if (idefloppy_report_error(floppy))
printk(KERN_ERR ide-floppy: %s: I/O 
error, 
   pc = %2x, key = %2x, 
   asc = %2x, ascq = %2x\n,
@@ -809,7 +809,7 @@ static ide_startstop_t idefloppy_do_request(ide_drive_t 
*drive,
 
if (rq-errors = ERROR_MAX) {
if (floppy-failed_pc != NULL) {
-   if (idefloppy_should_report_error(floppy))
+   if (idefloppy_report_error(floppy))
printk(KERN_ERR ide-floppy: %s: I/O error,
 pc = %2x, key = %2x, asc = %2x,
 ascq = %2x\n,
-- 
1.5.3.7

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


[RESEND PATCH 06/10] ide-floppy: report DMA handling in idefloppy_pc_intr() properly

2008-01-03 Thread Borislav Petkov
while at it:
-cleanup small issues raised by scripts/checkpatch.pl
-remove redundant and shorten some comments

There should be no functionality change resulting from this patch

Signed-off-by: Borislav Petkov [EMAIL PROTECTED]
---
 drivers/ide/ide-floppy.c |  195 --
 1 files changed, 83 insertions(+), 112 deletions(-)

diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 7823447..5d0fd1f 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -5,9 +5,7 @@
  * Copyright (C) 2000 - 2002 Paul Bristow [EMAIL PROTECTED]
  *
  * The driver currently doesn't have any fancy features, just the bare
- * minimum read/write support.
- *
- * This driver supports the following IDE floppy drives:
+ * minimum read/write support. It supports the following IDE floppy drives:
  *
  * LS-120/240 SuperDisk
  * Iomega Zip 100/250
@@ -75,8 +73,8 @@ static void ide_floppy_put(struct ide_floppy_obj *floppy)
 }
 
 /*
- * Too bad. The drive wants to send us data which we are not ready to 
accept.
- * Just throw it away.
+ * Too bad. The drive wants to send us data which we are not ready to accept.
+ * Just throw it away.
  */
 static void idefloppy_discard_data (ide_drive_t *drive, unsigned int bcount)
 {
@@ -94,10 +92,8 @@ static void idefloppy_write_zeros (ide_drive_t *drive, 
unsigned int bcount)
 
 
 /*
- * idefloppy_do_end_request is used to finish servicing a request.
- *
- * For read/write requests, we will call ide_end_request to pass to the
- * next buffer.
+ * Used to finish servicing a request. For read/write requests, we will call
+ * ide_end_request to pass to the next buffer.
  */
 static int idefloppy_do_end_request(ide_drive_t *drive, int uptodate, int 
nsecs)
 {
@@ -128,7 +124,7 @@ static int idefloppy_do_end_request(ide_drive_t *drive, int 
uptodate, int nsecs)
return 0;
 }
 
-static void idefloppy_input_buffers (ide_drive_t *drive, idefloppy_pc_t *pc,
+static void idefloppy_input_buffers(ide_drive_t *drive, idefloppy_pc_t *pc,
unsigned int bcount)
 {
struct request *rq = pc-rq;
@@ -162,7 +158,7 @@ static void idefloppy_input_buffers (ide_drive_t *drive, 
idefloppy_pc_t *pc,
}
 }
 
-static void idefloppy_output_buffers (ide_drive_t *drive, idefloppy_pc_t *pc,
+static void idefloppy_output_buffers(ide_drive_t *drive, idefloppy_pc_t *pc,
unsigned int bcount)
 {
struct request *rq = pc-rq;
@@ -198,7 +194,7 @@ static void idefloppy_output_buffers (ide_drive_t *drive, 
idefloppy_pc_t *pc,
 #endif
 }
 
-static void idefloppy_update_buffers (ide_drive_t *drive, idefloppy_pc_t *pc)
+static void idefloppy_update_buffers(ide_drive_t *drive, idefloppy_pc_t *pc)
 {
struct request *rq = pc-rq;
struct bio *bio = rq-bio;
@@ -208,11 +204,11 @@ static void idefloppy_update_buffers (ide_drive_t *drive, 
idefloppy_pc_t *pc)
 }
 
 /*
- * idefloppy_queue_pc_head generates a new packet command request in front
- * of the request queue, before the current request, so that it will be
- * processed immediately, on the next pass through the driver.
+ * Generates a new packet command request in front
+ * of the request queue, before the current request, so that it will be
+ * processed immediately, on the next pass through the driver.
  */
-static void idefloppy_queue_pc_head (ide_drive_t *drive,idefloppy_pc_t *pc,
+static void idefloppy_queue_pc_head(ide_drive_t *drive, idefloppy_pc_t *pc,
struct request *rq)
 {
struct ide_floppy_obj *floppy = drive-driver_data;
@@ -224,7 +220,7 @@ static void idefloppy_queue_pc_head (ide_drive_t 
*drive,idefloppy_pc_t *pc,
(void) ide_do_drive_cmd(drive, rq, ide_preempt);
 }
 
-static idefloppy_pc_t *idefloppy_next_pc_storage (ide_drive_t *drive)
+static idefloppy_pc_t *idefloppy_next_pc_storage(ide_drive_t *drive)
 {
idefloppy_t *floppy = drive-driver_data;
 
@@ -233,7 +229,7 @@ static idefloppy_pc_t *idefloppy_next_pc_storage 
(ide_drive_t *drive)
return (floppy-pc_stack[floppy-pc_stack_index++]);
 }
 
-static struct request *idefloppy_next_rq_storage (ide_drive_t *drive)
+static struct request *idefloppy_next_rq_storage(ide_drive_t *drive)
 {
idefloppy_t *floppy = drive-driver_data;
 
@@ -242,11 +238,8 @@ static struct request *idefloppy_next_rq_storage 
(ide_drive_t *drive)
return (floppy-rq_stack[floppy-rq_stack_index++]);
 }
 
-/*
- * idefloppy_analyze_error is called on each failed packet command retry
- * to analyze the request sense.
- */
-static void idefloppy_analyze_error (ide_drive_t *drive,
+/* Called on each failed packet command retry to analyze the request sense. */
+static void idefloppy_analyze_error(ide_drive_t *drive,
rq_sense_res_t *result)
 {
idefloppy_t *floppy = drive-driver_data;
@@ -265,7 +258,7 @@ static void idefloppy_analyze_error (ide_drive_t *drive,

Re: sata_nv + ADMA + Samsung disk problem

2008-01-03 Thread Mark Lord

Robert Hancock wrote:

Mark Lord wrote:

Robert Hancock wrote:
..
 From some of the traces I took previously (posted on LKML as 
sata_nv ADMA controller lockup investigation way back in Feb 07), 
what seems to occur is that when the second command is issued very 
rapidly (within less than 20 microseconds, or potentially longer) 
after the previous command's completion, the ADMA status changes from 
0x500 (STOPPED and IDLE) to 0x400 (just IDLE) as it typically does, 
but then it sticks there, no interrupt is ever raised, and CPB 
response flags remain at 0.

..

Assuming that NVidia got their ADMA core logic from Pacific Digital
(the inventors), then it may have some of the same bugs as the original.

One of those bugs is that the aGO trigger is sampled in a racey way,
such that it sometimes may miss a recent addition to the ring.

The *only* way to guarantee things with the original Pacific Digital core
was to (1) always retrigger aGO for a full ring scan with each new 
addition,

and (2) poll periodically (every half second or so) rather than relying
exclusively on the IRQ actually working..

Dunno about the NVidia version.


Theirs works rather differently - the GO bit is there, but there's 
another append register which is used to tell the controller that a new 
tag has been added to the CPB list.

..

The PacDigi core uses a search count register for that purpose,
but the buggy nature of the core required that it always be set
to 2 * ring_size to ensure nothing got missed.

Here's some comments from the original ADMA driver.
Maybe something from here might help with the NV stuff, too.

  // There is a chance that the chip will skip over a CPB if a SERVICE 
interrupt
   // occurs while it's reading the CPB header.  This won't cause us to get
   // stuck anywhere, but it might slow down execution of the new CPB if
   // it has to wait for the next time we hit aGO.  So.. Dxxx/Dxxx suggest
   // that all we need to do is tell the chip to do two passes around the 
ring
   // from an aGO instead of one pass, so that it will find the missed CPB
   // on the second pass.  This isn't as bad as it first looks.
   //
   writew(channel-num_cpbs * 2, adma_regs-cpb_search_count);

Or again, the NV stuff may be completely different (?).
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: sata_nv + ADMA + Samsung disk problem

2008-01-03 Thread Mark Lord

Mark Lord wrote:

Robert Hancock wrote:

Mark Lord wrote:

Robert Hancock wrote:
..

 From some of the traces I took previously (posted on LKML as sata_nv ADMA 
controller lockup investigation way back in Feb 07), what seems to occur is that 
when the second command is issued very rapidly (within less than 20 microseconds, or 
potentially longer) after the previous command's completion, the ADMA status changes from 
0x500 (STOPPED and IDLE) to 0x400 (just IDLE) as it typically does, but then it sticks 
there, no interrupt is ever raised, and CPB response flags remain at 0.

..

Assuming that NVidia got their ADMA core logic from Pacific Digital
(the inventors), then it may have some of the same bugs as the original.

One of those bugs is that the aGO trigger is sampled in a racey way,
such that it sometimes may miss a recent addition to the ring.

The *only* way to guarantee things with the original Pacific Digital core
was to (1) always retrigger aGO for a full ring scan with each new addition,
and (2) poll periodically (every half second or so) rather than relying
exclusively on the IRQ actually working..

Dunno about the NVidia version.


Theirs works rather differently - the GO bit is there, but there's another 
append register which is used to tell the controller that a new tag has been 
added to the CPB list.

..

The PacDigi core uses a search count register for that purpose,
but the buggy nature of the core required that it always be set
to 2 * ring_size to ensure nothing got missed.

Here's some comments from the original ADMA driver.
Maybe something from here might help with the NV stuff, too.

  // There is a chance that the chip will skip over a CPB if a SERVICE 
interrupt
   // occurs while it's reading the CPB header.  This won't cause us to get
   // stuck anywhere, but it might slow down execution of the new CPB if
   // it has to wait for the next time we hit aGO.  So.. Dxxx/Dxxx suggest
   // that all we need to do is tell the chip to do two passes around the 
ring
   // from an aGO instead of one pass, so that it will find the missed CPB
   // on the second pass.  This isn't as bad as it first looks.
   //
   writew(channel-num_cpbs * 2, adma_regs-cpb_search_count);

Or again, the NV stuff may be completely different (?).

..

Another thing about the PacDigi core:  one has to be very careful
to avoid sequential accesses to sequential PCI locations when
programming the chip -- it cannot handle merged register writes.

So for any group of sequentially laid out registers, the code has
to ensure it never writes two adjacent registers in sequence..

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


[PATCH] pata_legacy: resychronize with upstream changes and resubmit

2008-01-03 Thread Alan Cox
As requested by Jeff 

Update the legacy driver so it can handle VLB ports nicely, and has an
internal structure for nailing new ISA/VLB forms in. Anyone got an
ALI14xx and a spare day ;)

Also adds an all parameter so you can load this driver after all the PCI ones 
in a boot time kernel and tell it to grab anything ST412 compatible even if it 
is an unknown PCI device. That
allows libata to offer the same just get me a disk somehow fallback that old 
IDE did.

Signed-off-by: Alan Cox [EMAIL PROTECTED]
Obsoletes: pata_qdi

diff -u --new-file --recursive --exclude-from /usr/src/exclude 
linux.vanilla-2.6.24-rc6-mm1/drivers/ata/pata_legacy.c 
linux-2.6.24-rc6-mm1/drivers/ata/pata_legacy.c
--- linux.vanilla-2.6.24-rc6-mm1/drivers/ata/pata_legacy.c  2008-01-02 
16:04:19.0 +
+++ linux-2.6.24-rc6-mm1/drivers/ata/pata_legacy.c  2008-01-02 
16:57:25.0 +
@@ -68,8 +68,9 @@
 
 #define NR_HOST 6
 
-static int legacy_port[NR_HOST] = { 0x1f0, 0x170, 0x1e8, 0x168, 0x1e0, 0x160 };
-static int legacy_irq[NR_HOST] = { 14, 15, 11, 10, 8, 12 };
+static int all;
+module_param(all, int, 0444);
+MODULE_PARM_DESC(all, Grab all legacy port devices, even if PCI(0=off, 
1=on));
 
 struct legacy_data {
unsigned long timing;
@@ -80,21 +81,103 @@
 
 };
 
+enum controller {
+   BIOS = 0,
+   SNOOP = 1,
+   PDC20230 = 2,
+   HT6560A = 3,
+   HT6560B = 4,
+   OPTI611A = 5,
+   OPTI46X = 6,
+   QDI6500 = 7,
+   QDI6580 = 8,
+   QDI6580DP = 9,  /* Dual channel mode is different */
+
+   UNKNOWN = -1
+};
+
+
+struct legacy_probe {
+   unsigned char *name;
+   unsigned long port;
+   unsigned int irq;
+   unsigned int slot;
+   enum controller type;
+   unsigned long private;
+};
+
+struct legacy_controller {
+   const char *name;
+   struct ata_port_operations *ops;
+   unsigned int pio_mask;
+   unsigned int flags;
+   int (*setup)(struct legacy_probe *probe, struct legacy_data *data);
+};
+
+static int legacy_port[NR_HOST] = { 0x1f0, 0x170, 0x1e8, 0x168, 0x1e0, 0x160 };
+
+static struct legacy_probe probe_list[NR_HOST];
 static struct legacy_data legacy_data[NR_HOST];
 static struct ata_host *legacy_host[NR_HOST];
 static int nr_legacy_host;
 
 
-static int probe_all;  /* Set to check all ISA port ranges */
-static int ht6560a;/* HT 6560A on primary 1, secondary 2, 
both 3 */
-static int ht6560b;/* HT 6560A on primary 1, secondary 2, 
both 3 */
-static int opti82c611a;/* Opti82c611A on primary 1, 
secondary 2, both 3 */
-static int opti82c46x; /* Opti 82c465MV present (pri/sec 
autodetect) */
-static int autospeed;  /* Chip present which snoops speed 
changes */
-static int pio_mask = 0x1F;/* PIO range for autospeed devices */
+static int probe_all;  /* Set to check all ISA port ranges */
+static int ht6560a;/* HT 6560A on primary 1, second 2, both 3 */
+static int ht6560b;/* HT 6560A on primary 1, second 2, both 3 */
+static int opti82c611a;/* Opti82c611A on primary 1, sec 2, 
both 3 */
+static int opti82c46x; /* Opti 82c465MV present(pri/sec autodetect) */
+static int qdi;/* Set to probe QDI controllers */
+static int autospeed;  /* Chip present which snoops speed changes */
+static int pio_mask = 0x1F;/* PIO range for autospeed devices */
 static int iordy_mask = 0x;/* Use iordy if available */
 
 /**
+ * legacy_probe_add-   Add interface to probe list
+ * @port: Controller port
+ * @irq: IRQ number
+ * @type: Controller type
+ * @private: Controller specific info
+ *
+ * Add an entry into the probe list for ATA controllers. This is used
+ * to add the default ISA slots and then to build up the table
+ * further according to other ISA/VLB/Weird device scans
+ *
+ * An I/O port list is used to keep ordering stable and sane, as we
+ * don't have any good way to talk about ordering otherwise
+ */
+
+static int legacy_probe_add(unsigned long port, unsigned int irq,
+   enum controller type, unsigned long private)
+{
+   struct legacy_probe *lp = probe_list[0];
+   int i;
+   struct legacy_probe *free = NULL;
+
+   for (i = 0; i  NR_HOST; i++) {
+   if (lp-port == 0  free == NULL)
+   free = lp;
+   /* Matching port, or the correct slot for ordering */
+   if (lp-port == port || legacy_port[i] == port) {
+   free = lp;
+   break;
+   }
+   lp++;
+   }
+   if (free == NULL) {
+   printk(KERN_ERR pata_legacy: Too many interfaces.\n);
+   return -1;
+   }
+   /* Fill in the entry for later probing */
+   free-port = port;
+   

Re: [PATCH] pata_mpc52xx: NO_IRQ is zero

2008-01-03 Thread Michael Tokarev
Alan Cox wrote:
 Signed-off-by: Alan Cox [EMAIL PROTECTED]

The comment is misleading at best...

It doesn't matter if NO_IRQ is zero or not here, because ata_irq
is not a static/global variable, but a local one.  By removing the
initializer, here, the semantics changes.

But in this very case, it's safe to remove the initializer,
because this variable gets initialized a few lines below this
code snipped, in:

ata_irq = irq_of_parse_and_map(op-node, 0);

(and there's no other goto's before that, either).

/mjt

 diff -u --new-file --recursive --exclude-from /usr/src/exclude 
 linux.vanilla-2.6.24-rc6-mm1/drivers/ata/pata_mpc52xx.c 
 linux-2.6.24-rc6-mm1/drivers/ata/pata_mpc52xx.c
 --- linux.vanilla-2.6.24-rc6-mm1/drivers/ata/pata_mpc52xx.c   2008-01-02 
 16:03:58.0 +
 +++ linux-2.6.24-rc6-mm1/drivers/ata/pata_mpc52xx.c   2008-01-02 
 16:13:08.0 +
 @@ -364,7 +364,7 @@
  {
   unsigned int ipb_freq;
   struct resource res_mem;
 - int ata_irq = NO_IRQ;
 + int ata_irq;
   struct mpc52xx_ata __iomem *ata_regs;
   struct mpc52xx_ata_priv *priv;
   int rv;

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


[PATCH] pata_mpc52xx: NO_IRQ is zero

2008-01-03 Thread Alan Cox
Signed-off-by: Alan Cox [EMAIL PROTECTED]

diff -u --new-file --recursive --exclude-from /usr/src/exclude 
linux.vanilla-2.6.24-rc6-mm1/drivers/ata/pata_mpc52xx.c 
linux-2.6.24-rc6-mm1/drivers/ata/pata_mpc52xx.c
--- linux.vanilla-2.6.24-rc6-mm1/drivers/ata/pata_mpc52xx.c 2008-01-02 
16:03:58.0 +
+++ linux-2.6.24-rc6-mm1/drivers/ata/pata_mpc52xx.c 2008-01-02 
16:13:08.0 +
@@ -364,7 +364,7 @@
 {
unsigned int ipb_freq;
struct resource res_mem;
-   int ata_irq = NO_IRQ;
+   int ata_irq;
struct mpc52xx_ata __iomem *ata_regs;
struct mpc52xx_ata_priv *priv;
int rv;
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] RESEND #3 libata: Correct handling of TSS DVD

2008-01-03 Thread Alan Cox
Devices that misreport the validity bit for word 93 look like SATA. If
they are on the blacklist then we must not test for SATA but assume 40
wire in the 40 wire case (The TSSCorp reports 80 wire on SATA it seems!)

Signed-off-by: Alan Cox [EMAIL PROTECTED]

diff -u --new-file --recursive --exclude-from /usr/src/exclude 
linux.vanilla-2.6.24-rc6-mm1/include/linux/ata.h 
linux-2.6.24-rc6-mm1/include/linux/ata.h
--- linux.vanilla-2.6.24-rc6-mm1/include/linux/ata.h2008-01-02 
16:04:25.0 +
+++ linux-2.6.24-rc6-mm1/include/linux/ata.h2008-01-02 16:18:56.0 
+
@@ -639,8 +639,6 @@
 
 static inline int ata_drive_40wire_relaxed(const u16 *dev_id)
 {
-   if (ata_id_is_sata(dev_id))
-   return 0;   /* SATA */
if ((dev_id[93]  0x2000) == 0x2000)
return 0;   /* 80 wire */
return 1;
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] libata-sff: PCI IRQ handling fix

2008-01-03 Thread Alan Cox
It is legitimate (although annoying and silly) for a PCI IDE controller
not to be assigned an interrupt and to be polled. The libata-sff code
should therefore not try and request IRQ 0 in this case.

Signed-off-by: Alan Cox [EMAIL PROTECTED]

diff -u --new-file --recursive --exclude-from /usr/src/exclude 
linux.vanilla-2.6.24-rc6-mm1/drivers/ata/libata-sff.c 
linux-2.6.24-rc6-mm1/drivers/ata/libata-sff.c
--- linux.vanilla-2.6.24-rc6-mm1/drivers/ata/libata-sff.c   2008-01-02 
16:04:19.0 +
+++ linux-2.6.24-rc6-mm1/drivers/ata/libata-sff.c   2008-01-02 
16:12:39.0 +
@@ -808,7 +808,10 @@
if (rc)
goto err_out;
 
-   if (!legacy_mode) {
+   if (!legacy_mode  pdev-irq) {
+   /* We may have no IRQ assigned in which case we can poll. This
+  shouldn't happen on a sane system but robustness is cheap
+  in this case */
rc = devm_request_irq(dev, pdev-irq, pi-port_ops-irq_handler,
  IRQF_SHARED, DRV_NAME, host);
if (rc)
@@ -816,7 +819,7 @@
 
ata_port_desc(host-ports[0], irq %d, pdev-irq);
ata_port_desc(host-ports[1], irq %d, pdev-irq);
-   } else {
+   } else if (legacy_mode) {
if (!ata_port_is_dummy(host-ports[0])) {
rc = devm_request_irq(dev, ATA_PRIMARY_IRQ(pdev),
  pi-port_ops-irq_handler,
 
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: SATA kernel-buffered read VERY slow (not raid, Promise TX300 card); 2.6.23.1(vanilla)

2008-01-03 Thread Holger Hoffstaette

I got my Promise card and everything is up and running without problems,
using kernel 2.6.24-rc6 and the sata_promise driver out of the box:

00:0c.0 Mass storage controller: Promise Technology, Inc. PDC40775 (SATA 300 
TX2plus) (rev 02)
Subsystem: Promise Technology, Inc. PDC40775 (SATA 300 TX2plus)
Flags: bus master, 66MHz, medium devsel, latency 72, IRQ 17
I/O ports at b400 [size=128]
I/O ports at b800 [size=256]
Memory at ef025000 (32-bit, non-prefetchable) [size=4K]
Memory at ef00 (32-bit, non-prefetchable) [size=128K]
[virtual] Expansion ROM at 9802 [disabled] [size=32K]
Capabilities: [60] Power Management version 2
Kernel driver in use: sata_promise

Drive is a Samsung HD321KJ 320 GB and hdparm says the drive does ~75
MB/s; with dd it does buffered writes at ~85 MB/s and reads ~295 MB/s. So
all in all I'd say it's not the card or the driver..

hth,
Holger


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


[PATCH] pata_pdc202xx_old: Further fixups

2008-01-03 Thread Alan Cox
Turns out distros always enabled burst mode and it is pretty essential so
do the same. Also sort out the post DMA mode restore properly.

My 20263 card now seems happy but needs some four drive tests done yet
(when I've persuaded the kernel not to hang in the edd boot code if I
plug them in ..)

Signed-off-by: Alan Cox [EMAIL PROTECTED]

diff -u --new-file --recursive --exclude-from /usr/src/exclude 
linux.vanilla-2.6.24-rc6-mm1/drivers/ata/pata_pdc202xx_old.c 
linux-2.6.24-rc6-mm1/drivers/ata/pata_pdc202xx_old.c
--- linux.vanilla-2.6.24-rc6-mm1/drivers/ata/pata_pdc202xx_old.c
2008-01-02 16:04:19.0 +
+++ linux-2.6.24-rc6-mm1/drivers/ata/pata_pdc202xx_old.c2008-01-02 
16:13:14.0 +
@@ -214,8 +214,8 @@
/* Flip back to 33Mhz for PIO */
if (adev-dma_mode = XFER_UDMA_2)
iowrite8(ioread8(clock)  ~sel66, clock);
-
ata_bmdma_stop(qc);
+   pdc202xx_set_piomode(ap, adev);
 }
 
 /**
@@ -232,6 +232,17 @@
adev-max_sectors = 256;
 }
 
+static int pdc2026x_port_start(struct ata_port *ap)
+{
+   void __iomem *bmdma = ap-ioaddr.bmdma_addr;
+   if (bmdma) {
+   /* Enable burst mode */
+   u8 burst = ioread8(bmdma + 0x1f);
+   iowrite8(burst | 0x01, bmdma + 0x1f);
+   }
+   return ata_sff_port_start(ap);
+}
+
 static struct scsi_host_template pdc202xx_sht = {
.module = THIS_MODULE,
.name   = DRV_NAME,
@@ -312,7 +323,7 @@
.irq_clear  = ata_bmdma_irq_clear,
.irq_on = ata_irq_on,
 
-   .port_start = ata_sff_port_start,
+   .port_start = pdc2026x_port_start,
 };
 
 static int pdc202xx_init_one(struct pci_dev *dev, const struct pci_device_id 
*id)
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: sata_nv + ADMA + Samsung disk problem

2008-01-03 Thread Allen Martin
 
  Dunno about the NVidia version.
 
 Theirs works rather differently - the GO bit is there, but there's 
 another append register which is used to tell the controller 
 that a new 
 tag has been added to the CPB list.
 
 The only thing we currently use the GO bit for is to switch 
 between ADMA 
 and port register mode. Could be there's something we need to 
 do there, 
 though, who knows..
 

You shouldn't ever need to touch GO other than the ADMA / legacy mode
switch as you say.

The NVIDIA ADMA hw is not based on the Pacific Digital core.
---
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
---
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RESEND PATCH 01/10] move ide-floppy historical changelog to Documentation/ide/ChangeLog.ide-floppy.1996-2002;

2008-01-03 Thread Bartlomiej Zolnierkiewicz
On Thursday 03 January 2008, Borislav Petkov wrote:
 Signed-off-by: Borislav Petkov [EMAIL PROTECTED]

applied with two minor fixes (and sorry for being such a pedant ;):

* Summary line moved to patch description and ide-floppy: cleanup header
  used instead.  Please try to keep summary line within 80-columns limit,
  otherwise it makes git-log output etc ugly.

* I don't know why scripts/checkpatch.pl doesn't complain but quilt did:

  Warning: trailing whitespace in lines 44,46,61,62 of 
Documentation/ide/ChangeLog.ide-floppy.1996-2002

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


Re: [RESEND PATCH 0/10] ide-floppy redux p1

2008-01-03 Thread Bartlomiej Zolnierkiewicz

Hi,

On Thursday 03 January 2008, Borislav Petkov wrote:
 
 Hi Bart,
 
 here's the unfinished redux of ide-floppy which i'm REsending now so that we 
 could
 sinchronize trees. The original send got busted in vger's filters due to 
 syntax
 error in the Message-ID tag.
 
  Documentation/ide/ChangeLog.ide-floppy.1996-2002 |   64 ++
  drivers/ide/ide-floppy.c | 1248 
 +++---
  drivers/ide/ide-floppy.h |  351 ++
  include/linux/cdrom.h|1 +
  4 files changed, 819 insertions(+), 845 deletions(-)

I applied patch #1, patches #3, #4, #7 and #10 can be applied immediately
if you move them at the beggining of the patch series.  The rest requires
some more work but they are almost there (more comments in replies to
particular patches).

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


Re: [RESEND PATCH 03/10] ide-floppy: convert to generic packet commands

2008-01-03 Thread Bartlomiej Zolnierkiewicz
On Thursday 03 January 2008, Borislav Petkov wrote:
 Replace the ide-floppy packet commands opcode defines with the generic ones.
 Add a missing GPCMD_WRITE_12 (opcode 0xaa) to the generic ones in cdrom.h. The
 last one can be found in the current version of INF-8090, p.905.
 
 CC: Jens Axboe [EMAIL PROTECTED]
 Signed-off-by: Borislav Petkov [EMAIL PROTECTED]

please move this patch at the beggining of the patch series so it can be
applied immediately (patch #2 needs some more work)

 ---
  drivers/ide/ide-floppy.c |   26 +-
  drivers/ide/ide-floppy.h |   21 -

Please also note that patch #2 moved these defines to ide-floppy.h and now
patch #3 removes them so by re-ordering patches you can make patch #2 simpler.

[ This is a general hint for optimizing patches to make them smaller and easier
  to maintain, it also makes reviewer's job easier. ]

[...]

 --- a/include/linux/cdrom.h
 +++ b/include/linux/cdrom.h
 @@ -480,6 +480,7 @@ struct cdrom_generic_command
  #define GPCMD_TEST_UNIT_READY0x00
  #define GPCMD_VERIFY_10  0x2f
  #define GPCMD_WRITE_10   0x2a
 +#define GPCMD_WRITE_12   0xaa/* ide floppy */

0xaa is a generic SCSI opcode so the above comment is not necessary

  #define GPCMD_WRITE_AND_VERIFY_100x2e
  /* This is listed as optional in ATAPI 2.6, but is (curiously) 
   * missing from Mt. Fuji, Table 57.  It _is_ mentioned in Mt. Fuji
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RESEND PATCH 04/10] ide-floppy: cleanup debugging macros

2008-01-03 Thread Bartlomiej Zolnierkiewicz
On Thursday 03 January 2008, Borislav Petkov wrote:
 There should be no functional change resulting from this patch.

the patch is fine but the description is a bit inaccurate:

* some debug_log() calls were not using ide-floppy:  prefix

* a few used printk levels different than KERN_INFO (KERN_NOTICE
  and KERN_ERR, which is the default one if no level is given)

please fix the description and move the patch at the beggining of
the patch series

 Signed-off-by: Borislav Petkov [EMAIL PROTECTED]
 ---
  drivers/ide/ide-floppy.c |   58 +
  drivers/ide/ide-floppy.h |3 +-
  2 files changed, 29 insertions(+), 32 deletions(-)
 
 diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
 index 4fb6128..196a697 100644
 --- a/drivers/ide/ide-floppy.c
 +++ b/drivers/ide/ide-floppy.c
 @@ -105,7 +105,7 @@ static int idefloppy_do_end_request(ide_drive_t *drive, 
 int uptodate, int nsecs)
   struct request *rq = HWGROUP(drive)-rq;
   int error;
  
 - debug_log(KERN_INFO Reached idefloppy_end_request\n);
 + debug_log(Reached %s\n, __FUNCTION__);
  
   switch (uptodate) {
   case 0: error = IDEFLOPPY_ERROR_GENERAL; break;
 @@ -257,13 +257,12 @@ static void idefloppy_analyze_error (ide_drive_t *drive,
   floppy-progress_indication = result-sksv[0]  0x80 ?
   (u16)get_unaligned((u16 *)(result-sksv+1)):0x1;
   if (floppy-failed_pc)
 - debug_log(KERN_INFO ide-floppy: pc = %x, sense key = %x, 
 - asc = %x, ascq = %x\n, floppy-failed_pc-c[0],
 - result-sense_key, result-asc, result-ascq);
 + debug_log(pc = %x, sense key = %x, asc = %x, ascq = %x\n,
 + floppy-failed_pc-c[0], result-sense_key,
 + result-asc, result-ascq);
   else
 - debug_log(KERN_INFO ide-floppy: sense key = %x, asc = %x, 
 - ascq = %x\n, result-sense_key,
 - result-asc, result-ascq);
 + debug_log(sense key = %x, asc = %x, ascq = %x\n,
 + result-sense_key, result-asc, result-ascq);
  }
  
  static void idefloppy_request_sense_callback (ide_drive_t *drive)
 @@ -271,7 +270,7 @@ static void idefloppy_request_sense_callback (ide_drive_t 
 *drive)
   idefloppy_t *floppy = drive-driver_data;
   u8 *buf = floppy-pc-buffer;
  
 - debug_log(KERN_INFO ide-floppy: Reached %s\n, __FUNCTION__);
 + debug_log(Reached %s\n, __FUNCTION__);
  
   if (!floppy-pc-error) {
   idefloppy_analyze_error(drive, (rq_sense_res_t *) buf);
 @@ -291,7 +290,7 @@ static void idefloppy_pc_callback (ide_drive_t *drive)
  {
   idefloppy_t *floppy = drive-driver_data;
  
 - debug_log(KERN_INFO ide-floppy: Reached %s\n, __FUNCTION__);
 + debug_log(Reached %s\n, __FUNCTION__);
  
   idefloppy_do_end_request(drive, floppy-pc-error ? 0 : 1, 0);
  }
 @@ -351,8 +350,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t 
 *drive)
   struct request *rq = pc-rq;
   unsigned int temp;
  
 - debug_log(KERN_INFO ide-floppy: Reached %s interrupt handler\n,
 - __FUNCTION__);
 + debug_log(Reached %s interrupt handler\n, __FUNCTION__);
  
   if (test_bit(PC_DMA_IN_PROGRESS, pc-flags)) {
   if (HWIF(drive)-ide_dma_end(drive)) {
 @@ -361,23 +359,23 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t 
 *drive)
   pc-actually_transferred = pc-request_transfer;
   idefloppy_update_buffers(drive, pc);
   }
 - debug_log(KERN_INFO ide-floppy: DMA finished\n);
 + debug_log(%s: DMA finished\n, __FUNCTION__);
   }
  
   /* Clear the interrupt */
   status.all = HWIF(drive)-INB(IDE_STATUS_REG);
  
   if (!status.b.drq) {/* No more interrupts */
 - debug_log(KERN_INFO Packet command completed, %d bytes 
 - transferred\n, pc-actually_transferred);
 + debug_log(Packet command completed, %d bytes transferred\n,
 + pc-actually_transferred);
 +
   clear_bit(PC_DMA_IN_PROGRESS, pc-flags);
  
   local_irq_enable_in_hardirq();
  
   if (status.b.check || test_bit(PC_DMA_ERROR, pc-flags)) {
   /* Error detected */
 - debug_log(KERN_INFO ide-floppy: %s: I/O error\n,
 - drive-name);
 + debug_log(%s: I/O error\n, drive-name);
   rq-errors++;
   if (pc-c[0] == GPCMD_REQUEST_SENSE) {
   printk(KERN_ERR ide-floppy: I/O error in 
 @@ -438,9 +436,8 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t 
 *drive)
   NULL);
   return ide_started;
   }
 - 

Re: [RESEND PATCH 10/10] ide-floppy: replace ntoh{s,l} and hton{s,l} calls with the generic byteorder macros

2008-01-03 Thread Bartlomiej Zolnierkiewicz
On Thursday 03 January 2008, Borislav Petkov wrote:
 Signed-off-by: Borislav Petkov [EMAIL PROTECTED]

minor thing:

WARNING: line over 80 characters
#88: FILE: drivers/ide/ide-floppy.c:759:
+   put_unaligned(cpu_to_be16(blocks), (unsigned short *) 
pc-c[7]);

seems like it can be fixed by removing space between '(unsigned short *)'
and 'pc-c[7]'

otherwise looks good, please move it at the beginning of the patch series

PS I need some sleep so the rest of patches have to wait till tomorrow...
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RESEND PATCH 07/10] ide-floppy: remove unnecessary -handler != NULL check

2008-01-03 Thread Bartlomiej Zolnierkiewicz

On Thursday 03 January 2008, Borislav Petkov wrote:
 This BUG_ON is unneeded since the -handler != NULL check is performed in
 ide_set_handler().
 
 Signed-off-by: Borislav Petkov [EMAIL PROTECTED]

looks good, please move it at the beginning of the patch series
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] pata_pdc202xx_old: Further fixups

2008-01-03 Thread Bartlomiej Zolnierkiewicz
On Friday 04 January 2008, Alan Cox wrote:
 Turns out distros always enabled burst mode and it is pretty essential so

Yeah and datasheet confirms that so burst mode config option should die
(now if somebody could hit me with a patch)...

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


Re: sata_nv + ADMA + Samsung disk problem

2008-01-03 Thread Robert Hancock

Benjamin Herrenschmidt wrote:

Another thing about the PacDigi core:  one has to be very careful
to avoid sequential accesses to sequential PCI locations when
programming the chip -- it cannot handle merged register writes.

So for any group of sequentially laid out registers, the code has
to ensure it never writes two adjacent registers in sequence..


Ugh ? Write combining isn't permitted on normal registers afaik...

Ben.


Byte merging can be done by the chipset on MMIO writes (merging multiple 
8 or 16-bit writes into a single 32-bit cycle).

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


Re: SATA kernel-buffered read VERY slow (not raid, Promise TX300 card); 2.6.23.1(vanilla)

2008-01-03 Thread Robert Hancock

Linda Walsh wrote:

Robert Hancock wrote:

Linda Walsh wrote:

Alan Cox wrote:
rate began falling; at 128k block-reads-at-a-time or larger, it 
drops below

20MB/s (only on buffered SATA).

Try disabling NCQ - see if you've got a drive with the 'NCQ = no
readahead' flaw.

http://linux-ata.org/faq.html#ncq

---
   When drive initializes, dmesg says it has NCQ (depth 0/32)
   Reading the queue_depth under /sys, shows a queuedepth of 1.


Looks like your controller (or at least the Linux driver) doesn't 
actually support NCQ.



2) Drive Advanced Power Management setting(-B) (write-only):
HDIO_DRIVE_CMD failed: Input/output error
3) Drive Acoustic (-M), read =  acoustic  = not supported,
write =  HDIO_DRIVE_CMD:ACOUSTIC failed: Input/output error


Not sure about these ones.. Does anything show up in dmesg when you do 
this?

---
   Yes:
   (for -B, power-management)
ata1.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0
ata1.00: port_status 0x2020
ata1.00: cmd ef/05:fe:00:00:00/00:00:00:00:00/40 tag 0 cdb 0x0 data 0
res 51/04:fe:00:00:00/00:00:00:00:00/40 Emask 0x1 (device error)
ata1.00: configured for UDMA/133
ata1: EH complete
sd 1:0:0:0: [sdb] 1465149168 512-byte hardware sectors (750156 MB)
sd 1:0:0:0: [sdb] Write Protect is off
sd 1:0:0:0: [sdb] Mode Sense: 00 3a 00 00
sd 1:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't 
support DPO or FUA


  (for -M acoustic management):
ata1.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0
ata1.00: port_status 0x2020
ata1.00: cmd ef/42:fe:00:00:00/00:00:00:00:00/40 tag 0 cdb 0x0 data 0
res 51/04:fe:00:00:00/00:00:00:00:00/40 Emask 0x1 (device error)
ata1.00: configured for UDMA/133
ata1: EH complete
sd 1:0:0:0: [sdb] 1465149168 512-byte hardware sectors (750156 MB)
sd 1:0:0:0: [sdb] Write Protect is off
sd 1:0:0:0: [sdb] Mode Sense: 00 3a 00 00
sd 1:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't 
support DPO or FUA


Looks like the drive reports ERR/ABRT (command aborted), meaning it 
likely doesn't support those commands.


--
Robert Hancock  Saskatoon, SK, Canada
To email, remove nospam from [EMAIL PROTECTED]
Home Page: http://www.roberthancock.com/

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


Re:Believed resolved: SATA kern-buffRd read slow: based on promise driver bug

2008-01-03 Thread Linda Walsh

Mikael Pettersson wrote:

Linda Walsh writes:
  Robert Hancock wrote:
   Linda Walsh wrote:
   read rate began falling; at 128k block-reads-at-a-time or larger, it 
   drops below 20MB/s (only on buffered SATA).
  
  But more importantly -- I notice a chronic error message associate

  with this drive that may be causing some or all of the problem:
  ---
  ata1.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x2
  ata1.00: port_status 0x2008
  ata1.00: cmd c8/00:10:30:06:03/00:00:00:00:00/e0 tag 0 cdb 0x0 data 8192 in
   res 50/00:00:3f:06:03/00:00:00:00:00/e0 Emask 0x2 (HSM violation)
  ata1: limiting SATA link speed to 1.5 Gbps


Looks like the Promise ASIC SG bug. Apply
http://user.it.uu.se/~mikpe/linux/patches/sata_promise/patch-sata_promise-1-asic-sg-bug-fix-v3-2.6.23
and let us know if things improve.

/Mikael
  

---
   Yep!  Hope that's making it into a patch soon or, at least 2.6.24.
   Kernel buffered

   I seem to remember reading about some problems with Promise SATA  ACPI.
Does this address that or is that a separate issue?  (Am using no-acpi for
now, but would like to try acpi again if it may be fixed (last time I tried
it with this card, sdb went offline (once it unmounted itself and
refused to be remounted (no error...just nothing), and another it stayed
mounted, but gave an I/O Error...so have been using no-acpi since).
An ACPI error in bootup said:
ACPI Exception (utmutex-0263): AE_BAD_PARAMETER, Thread EFFC2000 could 
not acquire Mutex [3] [20070126]


   Is the above bug mentioned/discussed in the linux-ide archives?  That
and I'd like to find out why TCQ/NCQ doesn't work with the Seagate drives --
my guess, since they say queuedepth of 0/32, is that they are blacklisted
as being drives that don't follow normal protocol or implement their
own proprietary extensions?  Sigh.  Really a lame move (if that's the case)
for Seagate, considering they usage they could likely get in server
configs.  Maybe they want to push their SCSI/SAS drives?

   BTW, can SATA have DPO or FUA or are those limited to SCSI?
Would it be a desirable future addition to remove the
doesn't support DPO or FUA error message on SATA drives if they are
specific to SCSI?





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


Re: SATA kernel-buffered read VERY slow (not raid, Promise TX300 card); 2.6.23.1(vanilla)

2008-01-03 Thread Linda Walsh

Robert Hancock wrote:


Looks like the drive reports ERR/ABRT (command aborted), meaning it 
likely doesn't support those commands.



---
   Except the PATA version of the drive does (same capacity,  other 
specs).  Seagate would
disable advanced features for SATA but leave them for the older 
technology?  Possible,

but doesn't seem likely.


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


Re: Believed resolved: SATA kern-buffRd read slow: based on promise driver bug

2008-01-03 Thread Robert Hancock

Linda Walsh wrote:

   I seem to remember reading about some problems with Promise SATA  ACPI.
Does this address that or is that a separate issue?  (Am using no-acpi for
now, but would like to try acpi again if it may be fixed (last time I tried
it with this card, sdb went offline (once it unmounted itself and
refused to be remounted (no error...just nothing), and another it stayed
mounted, but gave an I/O Error...so have been using no-acpi since).
An ACPI error in bootup said:
ACPI Exception (utmutex-0263): AE_BAD_PARAMETER, Thread EFFC2000 could 
not acquire Mutex [3] [20070126]


Have you tried 2.6.24-rc6? If the problem still occurs there, you should 
post the full bootup log.




   Is the above bug mentioned/discussed in the linux-ide archives?  That
and I'd like to find out why TCQ/NCQ doesn't work with the Seagate 
drives --

my guess, since they say queuedepth of 0/32, is that they are blacklisted
as being drives that don't follow normal protocol or implement their
own proprietary extensions?  Sigh.  Really a lame move (if that's the case)
for Seagate, considering they usage they could likely get in server
configs.  Maybe they want to push their SCSI/SAS drives?


Queue depth 0/32 means the drive supports a queue depth of 32 but the 
controller/driver don't support NCQ.



   BTW, can SATA have DPO or FUA or are those limited to SCSI?
Would it be a desirable future addition to remove the
doesn't support DPO or FUA error message on SATA drives if they are
specific to SCSI?


ATA disks can have FUA support, but the support is disabled in libata by 
default. (There's a fua parameter on libata module to enable it I believe.)

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


Re: sata_nv + ADMA + Samsung disk problem

2008-01-03 Thread Robert Hancock

Allen Martin wrote:
 

Dunno about the NVidia version.
Theirs works rather differently - the GO bit is there, but there's 
another append register which is used to tell the controller 
that a new 
tag has been added to the CPB list.


The only thing we currently use the GO bit for is to switch 
between ADMA 
and port register mode. Could be there's something we need to 
do there, 
though, who knows..




You shouldn't ever need to touch GO other than the ADMA / legacy mode
switch as you say.

The NVIDIA ADMA hw is not based on the Pacific Digital core.


That answers that question, I guess. Still guessing at why the 
controller would get stuck in IDLE state with no interrupt raised, then..

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


Re: SATA kernel-buffered read VERY slow (not raid, Promise TX300 card); 2.6.23.1(vanilla)

2008-01-03 Thread Robert Hancock

Linda Walsh wrote:

Robert Hancock wrote:


Looks like the drive reports ERR/ABRT (command aborted), meaning it 
likely doesn't support those commands.



---
   Except the PATA version of the drive does (same capacity,  other 
specs).  Seagate would
disable advanced features for SATA but leave them for the older 
technology?  Possible,

but doesn't seem likely.


If this is a Seagate, I believe that they don't have AAM enabled on any 
of their newer drives (something about a lawsuit for patent infringement 
on that feature, or something). Quite likely they don't support that 
power management command, either.

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


Re: sata_nv + ADMA + Samsung disk problem

2008-01-03 Thread Benjamin Herrenschmidt

On Thu, 2008-01-03 at 19:43 -0600, Robert Hancock wrote:
 Benjamin Herrenschmidt wrote:
  Another thing about the PacDigi core:  one has to be very careful
  to avoid sequential accesses to sequential PCI locations when
  programming the chip -- it cannot handle merged register writes.
 
  So for any group of sequentially laid out registers, the code has
  to ensure it never writes two adjacent registers in sequence..
  
  Ugh ? Write combining isn't permitted on normal registers afaik...
  
  Ben.
 
 Byte merging can be done by the chipset on MMIO writes (merging multiple 
 8 or 16-bit writes into a single 32-bit cycle).

That is true, if they are consecutive. You mean that this HW is f*cked
up enough to actually have separate 8/16 bits registers that are
contiguous ? Yuck... I'm afraid you -have- to add reads in between to
guarantee that no merging will occur.

Cheers,

Ben.


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