Re: IDE cdrom problem with PLEXTOR DVDR PX-608AL

2008-02-26 Thread Borislav Petkov
On Tue, Feb 26, 2008 at 06:32:41PM +1000, Brad Rosser wrote:
Hi Brad,

> Hello Boris, Bart,
> 
> On Tue, Feb 26, 2008 at 12:45 AM, Borislav Petkov
> <[EMAIL PROTECTED]> wrote:
> >
> > On Mon, Feb 25, 2008 at 03:57:06PM +1000, Brad Rosser wrote:
> > >
> > > ... it would suggest the option 'hda=noprobe' was entered correctly?
> >
> >  ok, let's try something else: change the line "#if 0" to "#if 1" at the
> >  beginning of kernel/params.c, it looks like:
> >
> >  #if 0
> >  #define DEBUGP printk
> >  #else
> >  #define DEBUGP(fmt, a...)
> >  #endif
> >
> >  rebuild your kernel, and reboot with it. Then, please send me that boot 
> > log to
> >  see whether the kernel command line is being received from the boot loader 
> > and
> >  what exactly is getting parsed. Thanks.
> 
> Boris,  I've done that; the output is in attached file dmesg.debug.out.

it seems that your boot loader is not supplying the kernel with the boot params
properly as can be seen from the excerpt below:

...
Kernel command line: BOOT_IMAGE=linux_2.6.25rc2 ro root=900 
md=0,/dev/sda5,/dev/sdb5 hda=noprobe
Parsing ARGS: BOOT_IMAGE=linux_2.6.25rc2 ro root=900 md=0,/dev/sda5,/dev/sdb5 
hda=noprobe
Unknown argument: calling c03670ce
Unknown argument: calling c03670ce
Unknown argument: calling c03670ce
Unknown argument: calling c03670ce
md: Will configure md0 (super-block) from /dev/sda5,/dev/sdb5, below.
Unknown argument: calling c03670ce
...

and, as a result, the probing of hda still takes place.

> It looks to me that the kernel still found the IDE DVD drive (hda) ...
> in addition
> to the system messages when the system was up I found the ide_cd_mod
> module loaded on top of 'cdrom' as normal.
> 
> >  Please see whether you can apply the patch Bart just sent and if that 
> > still gets
> >  mangled and cannot be applied, consider making those changes to ide-cd.c 
> > by hand
> >  - after all, there are only several lines that need to be changed so it 
> > won't
> >  take that long.
> 
> Bart, I was able to apply that patch file you attached with no problems, and 
> the
> behaviour of the patched kernel changed as follows:
> 
> - no more 'confused' messages, nor the rush of other critical messages
> that accompanied a system hang on one out of four tests yesterday.
> 
> - However, a new message that popped up twice; once after a few seconds
> of network activity, and then about 15-20 seconds afterwards:
> 
> hda: ide_cd_check_ireason: wrong transfer direction!
> hda: ide_cd_check_ireason: wrong transfer direction!

Bart, can we assume here that some of the nic interrupts somehow get handled by
ide-cd or something gets mixed up there?

> - also, I'm pretty sure that performance of both network and DVD drive 
> suffered.
> 
> As to the last ... my new PC, on which I'm doing all this testing, has a 
> gigabit
> Realtek NIC.  It's hooked up via null UTP cable to my older machine which has
> a 100Mb/s card.  ethtool shows that they both auto-negotiate to run at 100Mb/s
> full duplex.  When I run my network test (pumping through /dev/zero across ssh
> from the old machine to the new) the network stats tell me that I'm getting
> 10MB/s out of the link, which is what I would expect.
> 
> With the patched 2.6.25-rc2 kernel running with no activity reading the DVD
> but the network going flat out (on the old PC's end) I noted that I was only
> getting only 8.0 or 8.1 MB/sec, rather than the 10 MB/sec I've seen in the 
> other
> tests..  There was no other network traffic or cpu load on the machine(s).
> 
> Then, when I mounted a DVD disc and did a 'wc /mnt/*' of its contents
> an iostat showed me that I was getting only about 6MB/sec out of the DVD
> drive, which is less than I'd expect.  As soon as I killed the network send
> iostat's report zoomed up to roughly 10MB/sec.  So it seemed to me that,
> in addition to the 'wrong direction' messages, I was losing some performance
> on both the NIC and the DVD drive.


-- 
Regards/Gruß,
Boris.
-
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] ide-cd: fix some codestyle and most of the checkpatch.pl issues

2008-02-25 Thread Borislav Petkov
Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-cd.c |  634 +
 1 files changed, 323 insertions(+), 311 deletions(-)

diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 3600648..3853eb5 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -13,8 +13,8 @@
  *
  * Suggestions are welcome. Patches that work are more welcome though. ;-)
  * For those wishing to work on this driver, please be sure you download
- * and comply with the latest Mt. Fuji (SFF8090 version 4) and ATAPI 
- * (SFF-8020i rev 2.6) standards. These documents can be obtained by 
+ * and comply with the latest Mt. Fuji (SFF8090 version 4) and ATAPI
+ * (SFF-8020i rev 2.6) standards. These documents can be obtained by
  * anonymous ftp from:
  * 
ftp://fission.dt.wdc.com/pub/standards/SFF_atapi/spec/SFF8020-r2.6/PS/8020r26.ps
  * ftp://ftp.avc-pioneer.com/Mtfuji4/Spec/Fuji4r10.pdf
@@ -41,17 +41,17 @@
 
 #include  /* For SCSI -> ATAPI command conversion */
 
-#include 
-#include 
+#include 
+#include 
 #include 
-#include 
+#include 
 #include 
 
 #include "ide-cd.h"
 
 static DEFINE_MUTEX(idecd_ref_mutex);
 
-#define to_ide_cd(obj) container_of(obj, struct cdrom_info, kref) 
+#define to_ide_cd(obj) container_of(obj, struct cdrom_info, kref)
 
 #define ide_cd_g(disk) \
container_of((disk)->private_data, struct cdrom_info, driver)
@@ -77,13 +77,12 @@ static void ide_cd_put(struct cdrom_info *cd)
mutex_unlock(&idecd_ref_mutex);
 }
 
-/
+/*
  * Generic packet command support and error handling routines.
  */
 
-/* Mark that we've seen a media change, and invalidate our internal
-   buffers. */
-static void cdrom_saw_media_change (ide_drive_t *drive)
+/* Mark that we've seen a media change, and invalidate our internal buffers. */
+static void cdrom_saw_media_change(ide_drive_t *drive)
 {
struct cdrom_info *cd = drive->driver_data;
 
@@ -100,46 +99,45 @@ static int cdrom_log_sense(ide_drive_t *drive, struct 
request *rq,
return 0;
 
switch (sense->sense_key) {
-   case NO_SENSE: case RECOVERED_ERROR:
-   break;
-   case NOT_READY:
-   /*
-* don't care about tray state messages for
-* e.g. capacity commands or in-progress or
-* becoming ready
-*/
-   if (sense->asc == 0x3a || sense->asc == 0x04)
-   break;
-   log = 1;
-   break;
-   case ILLEGAL_REQUEST:
-   /*
-* don't log START_STOP unit with LoEj set, since
-* we cannot reliably check if drive can auto-close
-*/
-   if (rq->cmd[0] == GPCMD_START_STOP_UNIT && sense->asc 
== 0x24)
-   break;
-   log = 1;
-   break;
-   case UNIT_ATTENTION:
-   /*
-* Make good and sure we've seen this potential media
-* change. Some drives (i.e. Creative) fail to present
-* the correct sense key in the error register.
-*/
-   cdrom_saw_media_change(drive);
+   case NO_SENSE: case RECOVERED_ERROR:
+   break;
+   case NOT_READY:
+   /*
+* don't care about tray state messages for
+* e.g. capacity commands or in-progress or
+* becoming ready
+*/
+   if (sense->asc == 0x3a || sense->asc == 0x04)
break;
-   default:
-   log = 1;
+   log = 1;
+   break;
+   case ILLEGAL_REQUEST:
+   /*
+* don't log START_STOP unit with LoEj set, since
+* we cannot reliably check if drive can auto-close
+*/
+   if (rq->cmd[0] == GPCMD_START_STOP_UNIT &&
+   sense->asc == 0x24)
break;
+   log = 1;
+   break;
+   case UNIT_ATTENTION:
+   /*
+* Make good and sure we've seen this potential media
+* change. Some drives (i.e. Creative) fail to present
+* the correct sense key in the error register.
+*/
+   cdrom_saw_media_change(drive);
+   break;
+   default:
+   log = 1;
+   break;
}
return log;
 }
 
-static
-void cdrom_analyze_sense_data(ide_drive_t *drive,

ide-cd: trivial fixes

2008-02-25 Thread Borislav Petkov
Hi Bart,

here some trivial fixes that i wanted to get out the door.
-
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] ide-cd: put proc-related functions together under single ifdef

2008-02-25 Thread Borislav Petkov
Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-cd.c |   29 +
 1 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 546f436..3600648 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1894,19 +1894,6 @@ int ide_cdrom_setup (ide_drive_t *drive)
return 0;
 }
 
-#ifdef CONFIG_IDE_PROC_FS
-static
-sector_t ide_cdrom_capacity (ide_drive_t *drive)
-{
-   unsigned long capacity, sectors_per_frame;
-
-   if (cdrom_read_capacity(drive, &capacity, §ors_per_frame, NULL))
-   return 0;
-
-   return capacity * sectors_per_frame;
-}
-#endif
-
 static void ide_cd_remove(ide_drive_t *drive)
 {
struct cdrom_info *info = drive->driver_data;
@@ -1940,14 +1927,24 @@ static void ide_cd_release(struct kref *kref)
 static int ide_cd_probe(ide_drive_t *);
 
 #ifdef CONFIG_IDE_PROC_FS
-static int proc_idecd_read_capacity
-   (char *page, char **start, off_t off, int count, int *eof, void *data)
+static sector_t ide_cdrom_capacity(ide_drive_t *drive)
+{
+   unsigned long capacity, sectors_per_frame;
+
+   if (cdrom_read_capacity(drive, &capacity, §ors_per_frame, NULL))
+   return 0;
+
+   return capacity * sectors_per_frame;
+}
+
+static int proc_idecd_read_capacity(char *page, char **start, off_t off,
+   int count, int *eof, void *data)
 {
ide_drive_t *drive = data;
int len;
 
len = sprintf(page,"%llu\n", (long long)ide_cdrom_capacity(drive));
-   PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
+   PROC_IDE_READ_RETURN(page, start, off, count, eof, len);
 }
 
 static ide_proc_entry_t idecd_proc[] = {
-- 
1.5.4.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


Re: IDE cdrom problem with PLEXTOR DVDR PX-608AL

2008-02-25 Thread Borislav Petkov
On Mon, Feb 25, 2008 at 03:57:06PM +1000, Brad Rosser wrote:
> Hi Boris,
> 
> >  Well, this sounds strange. Are you sure you're entering the boot options
> >  correctly on the kernel command line? Which is your boot loader? I just 
> > booted
> >  my machine with 'hdc=noprobe'  (hdc is my cdrom drive) and here's what i 
> > get:
> >
> >  ...
> >  [0.304774] Probing IDE interface ide0...
> >  [0.569359] hdb: SAMSUNG SP2014N, ATA DISK drive
> >  [0.613977] Switched to NOHz mode on CPU #1
> >  [0.773368] Switched to NOHz mode on CPU #0
> >  [0.874486] hda: QUANTUM FIREBALLlct10 20, ATA DISK drive
> >  [0.874506] hda: host max PIO4 wanted PIO255(auto-tune) selected PIO4
> >  [0.874506] hda: drive side 80-wire cable detection failed, limiting 
> > max speed to UDMA33
> >  [0.874506] hda: UDMA/33 mode selected
> >  [0.874533] hdb: host max PIO4 wanted PIO255(auto-tune) selected PIO4
> >  [0.874620] hdb: UDMA/100 mode selected
> >  [0.874744] Probing IDE interface ide1...
> 
> >  so it seems you should check whether your kernel is receiving the 
> > 'hda=noprobe'
> >  boot option at all, or something along that path is going wrong...
> 
> I'm entering the option 'hda=noprobe' (as one example) right after my boot
> label in LILO.  The dmesg output I attached last time was a boot of straight
> 2.6.25-rc2 without any options; I've attached 'dmesg.noprobe.out' which is
> the result of a boot with 'hda=noprobe'.
> 
> I must have done something stupid, but I can't see what; if you look at this
> line from the dmesg output:
> 
> Kernel command line: BOOT_IMAGE=linux_2.6.25rc2 ro root=900
> md=0,/dev/sda5,/dev/sdb5 hda=noprobe
> 
> ... it would suggest the option 'hda=noprobe' was entered correctly?

ok, let's try something else: change the line "#if 0" to "#if 1" at the
beginning of kernel/params.c, it looks like:

#if 0
#define DEBUGP printk
#else
#define DEBUGP(fmt, a...)
#endif

rebuild your kernel, and reboot with it. Then, please send me that boot log to
see whether the kernel command line is being received from the boot loader and
what exactly is getting parsed. Thanks.

> >  > I tried to apply the patch but failed; I probably did something wrong.
> >  > I deleted everything in your message above 'Index: 
> > b/drivers/ide/ide-cd.c'
> >  > and ran 'patch --dry-run -b -p1 < ../bart_patch'.  This is part of my 
> > script
> >  > log:
> >
> >  are you sure you're _really_ using 2.6.25-rc2? Applying the patch against 
> > that
> >  kernel works just fine, no fuzziness or even rejects. Care to try out on a 
> > fresh
> >  kernel source tarball? After all, building a kernel with your quad core 
> > cpu won't
> >  take that long :-) when using make -j8 or something in that order.
> 
> Heh.  This is my first new machine in 8 years, and I couldn't wait to start
> using multiple cores.  I was quick to discover the '-j' option ... but I only
> do '-j 4'.  Anyway ... I'd downloaded the full baseline linux-2.6.24.tar.bz2,
> unpacked it, and then ran the patch patch-2.6.25-rc2.bz2 against it.  That
> patch ran perfectly.  And I was in the right directory when I ran Bart's 
> patch,
> as I listed in my earlier e-mail!  All indications were that I was running the
> 2.6.25-rc2 kernel as required, I thought.
> 
> Well, I see that rc3 is out; maybe I'll give that a shot.

Please see whether you can apply the patch Bart just sent and if that still gets
mangled and cannot be applied, consider making those changes to ide-cd.c by hand
- after all, there are only several lines that need to be changed so it won't
take that long.

Thanks.

-- 
Regards/Gruß,
Boris.
-
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: IDE cdrom problem with PLEXTOR DVDR PX-608AL

2008-02-24 Thread Borislav Petkov
On Mon, Feb 25, 2008 at 11:58:57AM +1000, Brad Rosser wrote:
> On Mon, Feb 25, 2008 at 3:34 AM, Borislav Petkov
> <[EMAIL PROTECTED]> wrote:
> > On Sun, Feb 24, 2008 at 03:38:34PM +1000, Brad Rosser wrote:
> > >
> > > There's nothing in the bios that allows me to move one away from
> > > the other.  I can 'reserve' or block IRQs, but that only shifts them
> > > both to another interrupt.
> >
> >  well the driver probes the bios for that data and assigns the irq line it 
> > gets
> >  from it.
> 
> Oh.  I thought from all the 'IRQ routing/balancing' and the like in the
> kernel there might be a way to switch things around, give the
> Realtek driver a different IRQ than the one being used by the ide driver.
> Just my crossed-fingers hope.
> 
> >  Can you please send me your whole boot log of 2.6.25-rc2? Thanks.
> 
> It's attached as file 'dmesg.bug.out'.
> 
> >  since your cdrom seems to be hda from what i've seen above, try booting 
> > with
> >  'hda=noprobe' or maybe 'hda=none' to see which one turns the probing off 
> > for
> >  you. See Documentation/ide.txt for details.
> 
> I tried both options, but in both cases there was no difference; the 
> ide_cd_mod
> module was still loaded and the 'confused' message still popped up.
> 
> I did four boots/tests of the 2.6.25-rc2 kernel, with and without those
> boot parameters ... on all four I had the 'confused' message several times:
> 
> hda: cdrom_newpc_intr: The drive appears confused (ireason = 0x01).
> Trying to recover by ending request.

Well, this sounds strange. Are you sure you're entering the boot options
correctly on the kernel command line? Which is your boot loader? I just booted
my machine with 'hdc=noprobe'  (hdc is my cdrom drive) and here's what i get:

...
[0.304774] Probing IDE interface ide0...
[0.569359] hdb: SAMSUNG SP2014N, ATA DISK drive
[0.613977] Switched to NOHz mode on CPU #1
[0.773368] Switched to NOHz mode on CPU #0
[0.874486] hda: QUANTUM FIREBALLlct10 20, ATA DISK drive
[0.874506] hda: host max PIO4 wanted PIO255(auto-tune) selected PIO4
[0.874506] hda: drive side 80-wire cable detection failed, limiting max 
speed to UDMA33
[0.874506] hda: UDMA/33 mode selected
[0.874533] hdb: host max PIO4 wanted PIO255(auto-tune) selected PIO4
[0.874620] hdb: UDMA/100 mode selected
[0.874744] Probing IDE interface ide1...
-->
[0.877750] hdc: ide_wait_not_busy() skipped
-->
[1.136180] hdd: IC35L120AVV207-0, ATA DISK drive
[1.186959] hdd: host max PIO4 wanted PIO255(auto-tune) selected PIO4
[1.186959] hdd: host side 80-wire cable detection failed, limiting max 
speed to UDMA33
[1.186959] hdd: UDMA/33 mode selected
[1.186959] ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
[1.194971] ide1 at 0x170-0x177,0x376 on irq 15
[1.206876] Probing IDE interface ide2...
[1.720661] Probing IDE interface ide3...
[2.233564] Probing IDE interface ide4...
[2.746462] Probing IDE interface ide5...
[3.259395] hda: max request size: 128KiB
[3.259571] hda: 39876480 sectors (20416 MB) w/418KiB Cache, CHS=39560/16/63
[3.259571] hda: cache flushes not supported
[3.259571]  hda: hda1 hda2 hda3
[3.269291] hdb: max request size: 512KiB
[3.269511] hdb: 390721968 sectors (200049 MB) w/8192KiB Cache, 
CHS=24321/255/63
[3.269962] hdb: cache flushes supported
[3.270078]  hdb: hdb1
[3.280914] hdd: max request size: 512KiB
[3.281247] hdd: 241254720 sectors (123522 MB) w/1821KiB Cache, 
CHS=16383/255/63
[3.281729] hdd: cache flushes supported
[3.281729]  hdd: hdd1
[3.296760] PNP: PS/2 Controller [PNP0303:PS2K,PNP0f13:PS2M] at 0x60,0x64 
irq 1,12
...

so it seems you should check whether your kernel is receiving the 'hda=noprobe'
boot option at all, or something along that path is going wrong...

[...]

> I tried to apply the patch but failed; I probably did something wrong.
> I deleted everything in your message above 'Index: b/drivers/ide/ide-cd.c'
> and ran 'patch --dry-run -b -p1 < ../bart_patch'.  This is part of my script
> log:
> 
> root:/usr/src/linux-2.6.25-rc2# pwd
> /usr/src/linux-2.6.25-rc2
> root:/usr/src/linux-2.6.25-rc2# cat ../bart_patch
> Index: b/drivers/ide/ide-cd.c
> ===
> --- a/drivers/ide/ide-cd.c
> +++ b/drivers/ide/ide-cd.c
> @@ -670,8 +670,8 @@ static void cdrom_buffer_sectors (ide_dr
>  * and attempt to recover if there are problems.  Returns  0 if everything's
> ...
> ...
> root:/usr/src/linux-2.6.25-rc2# patch --dry-run -b -p1 < ../bart_patch
> patching file drivers/ide/ide-cd.c
> Hu

Re: IDE cdrom problem with PLEXTOR DVDR PX-608AL

2008-02-24 Thread Borislav Petkov
On Sun, Feb 24, 2008 at 03:38:34PM +1000, Brad Rosser wrote:

[ Added Bart to CC: ]

Hi Brad,

> Borislav Petkov wrote:
> 
> > > Feb 14 00:18:18 kernel: hde: cdrom_pc_intr: The drive appears confused 
> > > (ireason = 0x01).
> > > Trying to recover by ending request.
> > > Feb 14 00:27:27 kernel: hdc: cdrom_pc_intr: The drive appears confused 
> > > (ireason = 0x01).
> > > Trying to recover by ending request.
> > >
> > > ~> uname -a
> > > Linux xrated 2.6.24.1-35-pae #1 SMP 2008/02/12 01:00:18 UTC i686 athlon 
> > > i386 GNU/Linux
> >
> > Actually the interrupt handler in ide-cd got rewritten and you're still 
> > using the
> > old one (cdrom_pc_intr vs cdrom_newpc_intr). Those changes went into 
> > mainline before
> > the 2.6.25-rc1 so we'll be able to test the new one only when you try out 
> > 2.6.25-rc1
> > or wait until 2.6.25 is released in case you don't want to try hazardous 
> > materials
> > such as an -rc kernel[*] :).
> 
> I have exactly the same problem.  I have a two-month old PC with a
> Gigabyte P35-DS4
> motherboard, which has the Intel P35 chipset with ICH10 south bridge and
> additional JMicron IDE/SATA controller.  I have two SATA-II hard disks
> and a sole
> IDE device, a Pioneer DVR-115D DVD-ROM, hooked up to the JMicron IDE port.
> The motherboard also has an embedded Realtek RTL8111/8168B gigabit
> ethernet controller.
> 
> The motherboard/bios assigns both the JMicron IDE controller and the Realtek
> controller to the same interrupt - typically '15'.  There's nothing in
> the bios that
> allows me to move one away from the other.  I can 'reserve' or block IRQs, but
> that only shifts them both to another interrupt.

well the driver probes the bios for that data and assigns the irq line it gets
from it.

> Similarly, no matter what I do with the Linux kernel, using boot parameters 
> such
> as 'acpi=off', 'noapic', 'nolapic' and the like, I can never get the
> kernel to use
> different interrupts for these two controllers.  A 'cat
> /proc/interrupts' always shows
> them sharing their IRQ:
> 
>   # grep ide /proc/interrupts
>   17:   58077   4   98999   129160   IO-APIC-fasteoi   ide0, eth0
> 
> With the IDE driver compiled into the kernel any access to the DVD is fine
> until I start using the network.  Upon any network activity I get the 
> 'confused'
> messages and more:
> 
> kernel: hda: cdrom_pc_intr: The drive appears confused (ireason =
> 0x01). Trying to recover by ending request.
> last message repeated 3 times
> kernel: ide: failed opcode was: unknown
> kernel: hda: drive not ready for command
> kernel: hda: status error: status=0x58 { DriveReady SeekComplete DataRequest }
> 
> KDE even kindly pops up a window telling me that someone has inserted a 
> (ghost)
> DVD disc, would I care to play it?  :-(
> 
> I know nothing of modern/PCI hardware and their interrupt magic, but it seemed
> to me that the IDE driver was erroneously picking up the interrupts destined 
> for
> the Realtek NIC and thinking they were for it.  Unfortunately there seemed to 
> be
> no way for me to separate the two or get the IDE driver its own IRQ, either 
> via
> the PC's bios or linux kernel boot parameters.
> 
> When I saw the recent message from Hans-Peter Jansen about this exact
> problem, and Boris's comment that something in interrupt land for the
> CD driver had been fixed, I thought the latest version of the kernel would
> rectify matters.  I installed the 2.6.25-rc2 kernel from kernel.org
> but the problem
> is still there.

Can you please send me your whole boot log of 2.6.25-rc2? Thanks.

> 
> As a workaround I've disabled IDE entirely in my kernel build and am using
> sr_mod to present the DVD as /dev/sr0.
> 
> As a result of all this I've got several novice questions relating to
> this matter.
> I don't know if this mailing list is an appropriate place to ask them
> .. my apologies
> if not.  Any quick references to reference material would be appreciated.
> 
> Given all the kernel parameters to change IRQ routing and turn ACPI actions
> up, down and sideways, is there any way to tell it to assign an explicit
> IRQ to a device?  Or have it that the IDE driver doesn't share?  I thought
> CONFIG_IDEPCI_SHARE_IRQ might have something to do with it, but fiddling
> the value for that had no effect.  It 'feels' to me that all these IRQs seem 
> to
> be highly adjustable by the kernel, so I was hoping there'd be a way to
> let the IDE driver have one to itself.
> 
> Is there an

[PATCH] ide-cd: remove the internal 64k buffer

2008-02-19 Thread Borislav Petkov
Hi Bart,

here's one more item from my TODO list. The removal is straight forward, after
testing it with all my cdrom drives they all seem even to rotate quieter due to
the automatic speed adjustment of the drive to the continuous data stream
bandwidth in contrast to the buffer-mode in which recurring buffer-fill speedups
caused the drive's read speeed to spike in order to keep the buffer filled up
constantly.

Still, i'd keep this a bit longer in -mm to see whether there are some
other issues with it and with all the different workloads.


commit a855bd5d94ddac678cf90b4b8f20dbd3ac8ea29a
Author: Borislav Petkov <[EMAIL PROTECTED]>
Date:   Tue Feb 19 14:25:09 2008 +0100

ide-cd: remove the internal 64k buffer

This removes the internal ide-cd buffer and falls back to read-ahead block 
layer
capabilities. Thorough testing (cd burning, dvd read, raw read) gives with 
the
bufferless mode marginally better performance in addition to simplified 
code.

bufferless:

dd: reading `/dev/hdc': Input/output error
6238+0 records in
6238+0 records out
204406784 bytes (204 MB) copied, 259.891 s, 787 kB/s

real4m21.598s
user0m0.014s
sys 0m0.744s

with the old buffer (2.6.25-rc1):

dd: reading `/dev/hdc': Input/output error
6238+0 records in
6238+0 records out
204406784 bytes (204 MB) copied, 262.893 s, 778 kB/s

real4m22.938s
user0m0.009s
sys 0m0.771s
    
    Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>

diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index b21da31..f1cb85c 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -89,7 +89,6 @@ static void cdrom_saw_media_change (ide_drive_t *drive)
 
cd->cd_flags |= IDE_CD_FLAG_MEDIA_CHANGED;
cd->cd_flags &= ~IDE_CD_FLAG_TOC_VALID;
-   cd->nsectors_buffered = 0;
 }
 
 static int cdrom_log_sense(ide_drive_t *drive, struct request *rq,
@@ -626,47 +625,6 @@ static void ide_cd_drain_data(ide_drive_t *drive, int 
nsects)
 }
 
 /*
- * Buffer up to SECTORS_TO_TRANSFER sectors from the drive in our sector
- * buffer.  Once the first sector is added, any subsequent sectors are
- * assumed to be continuous (until the buffer is cleared).  For the first
- * sector added, SECTOR is its sector number.  (SECTOR is then ignored until
- * the buffer is cleared.)
- */
-static void cdrom_buffer_sectors (ide_drive_t *drive, unsigned long sector,
-  int sectors_to_transfer)
-{
-   struct cdrom_info *info = drive->driver_data;
-
-   /* Number of sectors to read into the buffer. */
-   int sectors_to_buffer = min_t(int, sectors_to_transfer,
-(SECTOR_BUFFER_SIZE >> SECTOR_BITS) -
-  info->nsectors_buffered);
-
-   char *dest;
-
-   /* If we couldn't get a buffer, don't try to buffer anything... */
-   if (info->buffer == NULL)
-   sectors_to_buffer = 0;
-
-   /* If this is the first sector in the buffer, remember its number. */
-   if (info->nsectors_buffered == 0)
-   info->sector_buffered = sector;
-
-   /* Read the data into the buffer. */
-   dest = info->buffer + info->nsectors_buffered * SECTOR_SIZE;
-   while (sectors_to_buffer > 0) {
-   HWIF(drive)->atapi_input_bytes(drive, dest, SECTOR_SIZE);
-   --sectors_to_buffer;
-   --sectors_to_transfer;
-   ++info->nsectors_buffered;
-   dest += SECTOR_SIZE;
-   }
-
-   /* Throw away any remaining data. */
-   ide_cd_drain_data(drive, sectors_to_transfer);
-}
-
-/*
  * Check the contents of the interrupt reason register from the cdrom
  * and attempt to recover if there are problems.  Returns  0 if everything's
  * ok; nonzero if the request has been terminated.
@@ -731,65 +689,6 @@ static int ide_cd_check_transfer_size(ide_drive_t *drive, 
int len)
return 1;
 }
 
-/*
- * Try to satisfy some of the current read request from our cached data.
- * Returns nonzero if the request has been completed, zero otherwise.
- */
-static int cdrom_read_from_buffer (ide_drive_t *drive)
-{
-   struct cdrom_info *info = drive->driver_data;
-   struct request *rq = HWGROUP(drive)->rq;
-   unsigned short sectors_per_frame;
-
-   sectors_per_frame = queue_hardsect_size(drive->queue) >> SECTOR_BITS;
-
-   /* Can't do anything if there's no buffer. */
-   if (info->buffer == NULL) return 0;
-
-   /* Loop while this request needs data and the next block is present
-  in our cache. */
-   while (rq->nr_sectors > 0 &&
-  rq->sector >= info->sector_buffered &&
-  rq->sector < info->sector_buffere

Re: Optiarc DVD RW AD-5200A audio playing

2008-02-18 Thread Borislav Petkov
On Tue, Feb 19, 2008 at 12:18:48AM +0100, Bartlomiej Zolnierkiewicz wrote:
> On Monday 18 February 2008, Stefan Bader wrote:
> > Borislav Petkov wrote:
> > > On Sat, Feb 16, 2008 at 04:24:01PM +0100, Bartlomiej Zolnierkiewicz wrote:
> > >> Hi,
> > >>
> > >> On Saturday 16 February 2008, Borislav Petkov wrote:
> > >>> On Fri, Feb 15, 2008 at 02:53:27PM -0500, Stefan Bader wrote:
> > >>>> Hello Borislav,
> > >>>>
> > >>>> I worked on a problem with an DVD driver (model=Optiarc DVD RW 
> > >>>> AD-5200A)
> > >>>> which obviously has the same problem as some Matshita drives. The
> > >>>> following patch was reported to enabled audio playing on this drive.
> > >>>> Would this approach be suitable for upstream or are there other
> > >>>> solutions to this problem?
> > >>>>
> > >>>> Regards,
> > >>>> Stefan
> > >>>>
> > >>>> --- a/drivers/ide/ide-cd.c
> > >>>> +++ b/drivers/ide/ide-cd.c
> > >>>> @@ -2988,7 +2988,8 @@ int ide_cdrom_probe_capabilities (ide_drive_t 
> > >>>> *drive)
> > >>>>if (strcmp(drive->id->model, "MATSHITADVD-ROM SR-8187") == 0 ||
> > >>>>strcmp(drive->id->model, "MATSHITADVD-ROM SR-8186") == 0 ||
> > >>>>strcmp(drive->id->model, "MATSHITADVD-ROM SR-8176") == 0 ||
> > >>>> -  strcmp(drive->id->model, "MATSHITADVD-ROM SR-8174") == 0)
> > >>>> +  strcmp(drive->id->model, "MATSHITADVD-ROM SR-8174") == 0 ||
> > >>>> +  strcmp(drive->id->model, "Optiarc DVD RW AD-5200A") == 0)
> > >>>>CDROM_CONFIG_FLAGS(drive)->audio_play = 1;
> > >>>>
> > >>>>  #if ! STANDARD_ATAPI
> > >>> Hi Stefan,
> > >>>
> > >>> just to make sure that the audioplay bit is not set in the capabilities 
> > >>> page,
> > >>> can you please try the following patch applied against 2.6.25-rc2 and 
> > >>> send me
> > >>> the output. Thanks!
> > >>>
> > >>> @Bart: by the way, this cdi->mask thingy is kinda unintuitive doing 
> > >>> double
> > >>> negation to check whether a feature is supported or not. Yeah, this 
> > >>> comes from
> > >>> "above," i.e. uniform cdrom layer. But still, shouldn't we use a 
> > >>> cdi->caps_flags
> > >>> or something similar instead, which mirrors the caps page bits setting?
> > >> It seems so (at least having negative flags is very unintuitive) but they
> > >> might be some reason for this ugliness, Jens?
> > >>
> > >> [ Please also remember that since cdrom layer is _uniform_ it may be not
> > >>   possible and/or desirable to have 1-1 mapping between caps page bits
> > >>   and the future cdi->caps_flags. ]
> > >>
> > >>> commit 435f0f4496a1b32af2d542f43b2370a890fe2f83
> > >>> Author: Borislav Petkov <[EMAIL PROTECTED]>
> > >>> Date:   Sat Feb 16 09:56:36 2008 +0100
> > >>>
> > >>> ide-cd: Enable audio play quirk for Optiarc DVD RW AD-5200A drive
> > >>> 
> > >>> Reported-by: Stefan Bader <[EMAIL PROTECTED]>
> > >>> Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
> > >>>
> > >>> diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
> > >>> index f77db6b..2c9d06e 100644
> > >>> --- a/drivers/ide/ide-cd.c
> > >>> +++ b/drivers/ide/ide-cd.c
> > >>> @@ -1750,6 +1750,10 @@ int ide_cdrom_probe_capabilities (ide_drive_t 
> > >>> *drive)
> > >>> cdi->mask &= ~(CDC_DVD_RAM | CDC_RAM);
> > >>> if (buf[8 + 3] & 0x10)
> > >>> cdi->mask &= ~CDC_DVD_R;
> > >>> +   if (!(buf[8 + 4] & 0x01)) {
> > >> Hmm, shouldn't there be '&& (cd->cd_flags & IDE_CD_FLAG_PLAY_AUDIO_OK)'
> > >> to prevent false positives?
> > > 
> > > I wanted to see whether the caps page reports the audioplay bit off...
> > > 
> > >>> +   printk(K

Re: IDE cdrom problem

2008-02-17 Thread Borislav Petkov
On Sun, Feb 17, 2008 at 03:16:42PM +0100, WaVeR wrote:
> Hi all,
> 
> Le samedi 16 février 2008 à 21:23 +0100, Borislav Petkov a écrit :
> > > Do you want me to try the 2.6.25-rc2 ? and give my feedback
> > 
> > Yes, please.
> 
> Until now, there's no prob with the kernel 2.6.25-rc2. 

Cool, let me know should something show up in the logs after all.

Thanks.

> 
> 15:14 [EMAIL PROTECTED] ~% uname -a
> Linux Jupiter 2.6.25-rc2.waver.1 #1 Sun Feb 17 14:31:07 CET 2008 i686
> GNU/Linux
> 
> 
> Regards,
> 
> ---
> Hassan

-- 
Regards/Gruß,
Boris.
-
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: IDE cdrom problem

2008-02-16 Thread Borislav Petkov
On Sat, Feb 16, 2008 at 08:27:21PM +0100, WaVeR wrote:
> Hi,
> 
> 
> Le samedi 16 février 2008 à 19:09 +0100, Borislav Petkov a écrit :
> > On Sat, Feb 16, 2008 at 06:40:08PM +0100, Bartlomiej Zolnierkiewicz wrote:
> > > On Saturday 16 February 2008, Borislav Petkov wrote:
> > > > On Sat, Feb 16, 2008 at 04:24:46PM +0100, Bartlomiej Zolnierkiewicz 
> > > > wrote:
> > > > > 
> > > > > [ added Borislav (ide-cd maintainer) to cc: ]
> > > > > 
> > > > > Hi,
> > > > > 
> > > > > Unless there are some very important reasons to keep the discussion 
> > > > > private
> > > > > please always cc: linux-ide@ and/or linux-kernel@ ML when reporting 
> > > > > problems.
> > > > > 
> > > > > Othewise your mail misses many knowledgeable people and is left on 
> > > > > mercy
> > > > > of clueless IDE maintainer... ;-)
> 
> 
> As I mentioned, the reason why I wrote to you directly is i'm not on the
> linux-ide mailing list.

That doesn't matter. What Bart ment is that if you cc the mailing list, more
people are going to see your bug report and the chance of the bug getting fixed
is bigger.

> 
> 
> Do you want me to try the 2.6.25-rc2 ? and give my feedback

Yes, please.

> > > > > 
> > > > > --  Forwarded Message  --
> > > > > 
> > > > > Subject: IDE cdrom problem
> > > > > Date: Saturday 16 February 2008
> > > > > From: WaVeR <[EMAIL PROTECTED]>
> > > > > To: [EMAIL PROTECTED]
> > > > > 
> > > > > Hello Bart,
> > > > > 
> > > > > Sorry to distrub you, but I have a similar problem like this post
> > > > > http://lkml.org/lkml/2008/2/12/97
> > > > > 
> > > > > I'm not subscribed to linux ML, so I decide to write you directly.
> > > > > 
> > > > > 
> > > > > >From my dmesg, I get this error:
> > > > > 
> > > > > Feb 16 08:01:58 Jupiter kernel: hdc: cdrom_pc_intr: The drive appears
> > > > > confused (ireason = 0x01). Trying to recover by ending request.
> > > > > Feb 16 08:06:16 Jupiter kernel: hdc: cdrom_pc_intr: The drive appears
> > > > > confused (ireason = 0x01). Trying to recover by ending request.
> > > > > Feb 16 08:10:45 Jupiter kernel: hdd: cdrom_pc_intr: The drive appears
> > > > > confused (ireason = 0x01). Trying to recover by ending request.
> > > > > Feb 16 08:37:41 Jupiter kernel: hdd: cdrom_pc_intr: The drive appears
> > > > > confused (ireason = 0x01). Trying to recover by ending request.
> > > > > Feb 16 08:42:10 Jupiter kernel: hdc: cdrom_pc_intr: The drive appears
> > > > > confused (ireason = 0x01). Trying to recover by ending request.
> > > > > Feb 16 09:00:07 Jupiter kernel: hdd: cdrom_pc_intr: The drive appears
> > > > > confused (ireason = 0x01). Trying to recover by ending request.
> > > > 
> > > > Yeah, this is kinda funny, i think i've seen that somewhere :) But 
> > > > seriously,
> > > 
> > > Yep, this looks to be the identical problem as discussed recently:
> > > 
> > > http://www.mail-archive.com/linux-ide@vger.kernel.org/msg16131.html
> > > 
> > > [ + IIRC the similar issue might be already in the kernel bugzilla... ]
> > > 
> > > > can you try 2.6.25-rc2 - this one should be stable enough and it has 
> > > > the ide-cd
> > > > rewrite in there and it would be interesting to see whether the new 
> > > > interrupt
> > > > handler shows the same behaviour.
> > > > 
> > > > Bart, since this starts to occur often, i'm thinking of adding a 
> > > > debugging macro
> > > > similar to the ones we rewrote in ide-floppy and ide-tape besides the
> > > > CONFIG_BLK_DEV_IDECD_VERBOSE_ERRORS facility in ide-cd. What are your 
> > > > thoughts
> > > > on the matter?
> > > 
> > > I would rather prefer to see more code removal/unification in ide-cd.
> > 
> > Yep, this is underway. Am working on removing the ide-cd internal buffer and
> > will get back to you after testing it... Ide floppy will have to wait.
> > > 
> > > [ If the code is simple/clean enough and have informative printk()-s for
> > >   error conditions there shouldn't be a frequ

Re: Optiarc DVD RW AD-5200A audio playing

2008-02-16 Thread Borislav Petkov
On Sat, Feb 16, 2008 at 07:23:58PM +0100, Bartlomiej Zolnierkiewicz wrote:
> On Saturday 16 February 2008, Borislav Petkov wrote:
> > On Sat, Feb 16, 2008 at 06:48:24PM +0100, Bartlomiej Zolnierkiewicz wrote:
> > > On Saturday 16 February 2008, Borislav Petkov wrote:
> > > > On Sat, Feb 16, 2008 at 04:24:01PM +0100, Bartlomiej Zolnierkiewicz 
> > > > wrote:
> > > > > 
> > > > > Hi,
> > > > > 
> > > > > On Saturday 16 February 2008, Borislav Petkov wrote:
> > > > > > On Fri, Feb 15, 2008 at 02:53:27PM -0500, Stefan Bader wrote:
> > > > > > > Hello Borislav,
> > > > > > > 
> > > > > > > I worked on a problem with an DVD driver (model=Optiarc DVD RW 
> > > > > > > AD-5200A)
> > > > > > > which obviously has the same problem as some Matshita drives. The
> > > > > > > following patch was reported to enabled audio playing on this 
> > > > > > > drive.
> > > > > > > Would this approach be suitable for upstream or are there other
> > > > > > > solutions to this problem?
> > > > > > > 
> > > > > > > Regards,
> > > > > > > Stefan
> > > > > > > 
> > > > > > > --- a/drivers/ide/ide-cd.c
> > > > > > > +++ b/drivers/ide/ide-cd.c
> > > > > > > @@ -2988,7 +2988,8 @@ int ide_cdrom_probe_capabilities 
> > > > > > > (ide_drive_t *drive)
> > > > > > >   if (strcmp(drive->id->model, "MATSHITADVD-ROM SR-8187") == 0 ||
> > > > > > >   strcmp(drive->id->model, "MATSHITADVD-ROM SR-8186") == 0 ||
> > > > > > >   strcmp(drive->id->model, "MATSHITADVD-ROM SR-8176") == 0 ||
> > > > > > > - strcmp(drive->id->model, "MATSHITADVD-ROM SR-8174") == 0)
> > > > > > > + strcmp(drive->id->model, "MATSHITADVD-ROM SR-8174") == 0 ||
> > > > > > > + strcmp(drive->id->model, "Optiarc DVD RW AD-5200A") == 0)
> > > > > > >   CDROM_CONFIG_FLAGS(drive)->audio_play = 1;
> > > > > > > 
> > > > > > >  #if ! STANDARD_ATAPI
> > > > > > 
> > > > > > Hi Stefan,
> > > > > > 
> > > > > > just to make sure that the audioplay bit is not set in the 
> > > > > > capabilities page,
> > > > > > can you please try the following patch applied against 2.6.25-rc2 
> > > > > > and send me
> > > > > > the output. Thanks!
> > > > > > 
> > > > > > @Bart: by the way, this cdi->mask thingy is kinda unintuitive doing 
> > > > > > double
> > > > > > negation to check whether a feature is supported or not. Yeah, this 
> > > > > > comes from
> > > > > > "above," i.e. uniform cdrom layer. But still, shouldn't we use a 
> > > > > > cdi->caps_flags
> > > > > > or something similar instead, which mirrors the caps page bits 
> > > > > > setting?
> > > > > 
> > > > > It seems so (at least having negative flags is very unintuitive) but 
> > > > > they
> > > > > might be some reason for this ugliness, Jens?
> > > > > 
> > > > > [ Please also remember that since cdrom layer is _uniform_ it may be 
> > > > > not
> > > > >   possible and/or desirable to have 1-1 mapping between caps page bits
> > > > >   and the future cdi->caps_flags. ]
> > > > > 
> > > > > > commit 435f0f4496a1b32af2d542f43b2370a890fe2f83
> > > > > > Author: Borislav Petkov <[EMAIL PROTECTED]>
> > > > > > Date:   Sat Feb 16 09:56:36 2008 +0100
> > > > > > 
> > > > > > ide-cd: Enable audio play quirk for Optiarc DVD RW AD-5200A 
> > > > > > drive
> > > > > > 
> > > > > > Reported-by: Stefan Bader <[EMAIL PROTECTED]>
> > > > > > Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
> > > > > > 
> > > > > > diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
> > > > > > index f77db6b..2c9d06e 100644
> > > > > &

Re: IDE cdrom problem

2008-02-16 Thread Borislav Petkov
On Sat, Feb 16, 2008 at 06:40:08PM +0100, Bartlomiej Zolnierkiewicz wrote:
> On Saturday 16 February 2008, Borislav Petkov wrote:
> > On Sat, Feb 16, 2008 at 04:24:46PM +0100, Bartlomiej Zolnierkiewicz wrote:
> > > 
> > > [ added Borislav (ide-cd maintainer) to cc: ]
> > > 
> > > Hi,
> > > 
> > > Unless there are some very important reasons to keep the discussion 
> > > private
> > > please always cc: linux-ide@ and/or linux-kernel@ ML when reporting 
> > > problems.
> > > 
> > > Othewise your mail misses many knowledgeable people and is left on mercy
> > > of clueless IDE maintainer... ;-)
> > > 
> > > --  Forwarded Message  --
> > > 
> > > Subject: IDE cdrom problem
> > > Date: Saturday 16 February 2008
> > > From: WaVeR <[EMAIL PROTECTED]>
> > > To: [EMAIL PROTECTED]
> > > 
> > > Hello Bart,
> > > 
> > > Sorry to distrub you, but I have a similar problem like this post
> > > http://lkml.org/lkml/2008/2/12/97
> > > 
> > > I'm not subscribed to linux ML, so I decide to write you directly.
> > > 
> > > 
> > > >From my dmesg, I get this error:
> > > 
> > > Feb 16 08:01:58 Jupiter kernel: hdc: cdrom_pc_intr: The drive appears
> > > confused (ireason = 0x01). Trying to recover by ending request.
> > > Feb 16 08:06:16 Jupiter kernel: hdc: cdrom_pc_intr: The drive appears
> > > confused (ireason = 0x01). Trying to recover by ending request.
> > > Feb 16 08:10:45 Jupiter kernel: hdd: cdrom_pc_intr: The drive appears
> > > confused (ireason = 0x01). Trying to recover by ending request.
> > > Feb 16 08:37:41 Jupiter kernel: hdd: cdrom_pc_intr: The drive appears
> > > confused (ireason = 0x01). Trying to recover by ending request.
> > > Feb 16 08:42:10 Jupiter kernel: hdc: cdrom_pc_intr: The drive appears
> > > confused (ireason = 0x01). Trying to recover by ending request.
> > > Feb 16 09:00:07 Jupiter kernel: hdd: cdrom_pc_intr: The drive appears
> > > confused (ireason = 0x01). Trying to recover by ending request.
> > 
> > Yeah, this is kinda funny, i think i've seen that somewhere :) But 
> > seriously,
> 
> Yep, this looks to be the identical problem as discussed recently:
> 
> http://www.mail-archive.com/linux-ide@vger.kernel.org/msg16131.html
> 
> [ + IIRC the similar issue might be already in the kernel bugzilla... ]
> 
> > can you try 2.6.25-rc2 - this one should be stable enough and it has the 
> > ide-cd
> > rewrite in there and it would be interesting to see whether the new 
> > interrupt
> > handler shows the same behaviour.
> > 
> > Bart, since this starts to occur often, i'm thinking of adding a debugging 
> > macro
> > similar to the ones we rewrote in ide-floppy and ide-tape besides the
> > CONFIG_BLK_DEV_IDECD_VERBOSE_ERRORS facility in ide-cd. What are your 
> > thoughts
> > on the matter?
> 
> I would rather prefer to see more code removal/unification in ide-cd.

Yep, this is underway. Am working on removing the ide-cd internal buffer and
will get back to you after testing it... Ide floppy will have to wait.
> 
> [ If the code is simple/clean enough and have informative printk()-s for
>   error conditions there shouldn't be a frequent need for an extra debugging
>   information. ]
> 
> > > As you can see on the atached file. It's a simple IDE dvdrom and a cd
> > > burner.
> > > 
> > > I dont have this problem with the kernel 2.6.21.3
> > > 
> > > My actual kernel is:
> > > 9:28 [EMAIL PROTECTED] ~% uname -a
> > > Linux Jupiter 2.6.24.2-waver.1 #1 Wed Feb 13 23:53:31 CET 2008 i686
> > > GNU/Linux
> 
> It would also help us if it can be narrowed down to the specific commit.
> Please install git package, get kernel git tree from kernel.org, and do:
> 
> git bisect start
> git bisect good 2.6.21
> git bisect bad 2.6.24

What would decrease the number of bisection iterations would be specifying the
path for bisection, like so:

git bisect start -- drivers/ide

and then we'll nail down the evildoer significantly faster, imho.
> 
> It will select the kernel to test - compile and boot it to see if the problem
> is still there.  If so do "git bisect bad" which will give you new kernel
> to test.  If the kernel works fine do "git bisect good" instead.  After few
> iterations you should find the exact commit which introduced the bug.
> 
> Thanks,
> Bart

-- 
Regards/Gruß,
Boris.
-
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: Optiarc DVD RW AD-5200A audio playing

2008-02-16 Thread Borislav Petkov
On Sat, Feb 16, 2008 at 06:48:24PM +0100, Bartlomiej Zolnierkiewicz wrote:
> On Saturday 16 February 2008, Borislav Petkov wrote:
> > On Sat, Feb 16, 2008 at 04:24:01PM +0100, Bartlomiej Zolnierkiewicz wrote:
> > > 
> > > Hi,
> > > 
> > > On Saturday 16 February 2008, Borislav Petkov wrote:
> > > > On Fri, Feb 15, 2008 at 02:53:27PM -0500, Stefan Bader wrote:
> > > > > Hello Borislav,
> > > > > 
> > > > > I worked on a problem with an DVD driver (model=Optiarc DVD RW 
> > > > > AD-5200A)
> > > > > which obviously has the same problem as some Matshita drives. The
> > > > > following patch was reported to enabled audio playing on this drive.
> > > > > Would this approach be suitable for upstream or are there other
> > > > > solutions to this problem?
> > > > > 
> > > > > Regards,
> > > > > Stefan
> > > > > 
> > > > > --- a/drivers/ide/ide-cd.c
> > > > > +++ b/drivers/ide/ide-cd.c
> > > > > @@ -2988,7 +2988,8 @@ int ide_cdrom_probe_capabilities (ide_drive_t 
> > > > > *drive)
> > > > >   if (strcmp(drive->id->model, "MATSHITADVD-ROM SR-8187") == 0 ||
> > > > >   strcmp(drive->id->model, "MATSHITADVD-ROM SR-8186") == 0 ||
> > > > >   strcmp(drive->id->model, "MATSHITADVD-ROM SR-8176") == 0 ||
> > > > > - strcmp(drive->id->model, "MATSHITADVD-ROM SR-8174") == 0)
> > > > > + strcmp(drive->id->model, "MATSHITADVD-ROM SR-8174") == 0 ||
> > > > > + strcmp(drive->id->model, "Optiarc DVD RW AD-5200A") == 0)
> > > > >   CDROM_CONFIG_FLAGS(drive)->audio_play = 1;
> > > > > 
> > > > >  #if ! STANDARD_ATAPI
> > > > 
> > > > Hi Stefan,
> > > > 
> > > > just to make sure that the audioplay bit is not set in the capabilities 
> > > > page,
> > > > can you please try the following patch applied against 2.6.25-rc2 and 
> > > > send me
> > > > the output. Thanks!
> > > > 
> > > > @Bart: by the way, this cdi->mask thingy is kinda unintuitive doing 
> > > > double
> > > > negation to check whether a feature is supported or not. Yeah, this 
> > > > comes from
> > > > "above," i.e. uniform cdrom layer. But still, shouldn't we use a 
> > > > cdi->caps_flags
> > > > or something similar instead, which mirrors the caps page bits setting?
> > > 
> > > It seems so (at least having negative flags is very unintuitive) but they
> > > might be some reason for this ugliness, Jens?
> > > 
> > > [ Please also remember that since cdrom layer is _uniform_ it may be not
> > >   possible and/or desirable to have 1-1 mapping between caps page bits
> > >   and the future cdi->caps_flags. ]
> > > 
> > > > commit 435f0f4496a1b32af2d542f43b2370a890fe2f83
> > > > Author: Borislav Petkov <[EMAIL PROTECTED]>
> > > > Date:   Sat Feb 16 09:56:36 2008 +0100
> > > > 
> > > > ide-cd: Enable audio play quirk for Optiarc DVD RW AD-5200A drive
> > > > 
> > > > Reported-by: Stefan Bader <[EMAIL PROTECTED]>
> > > > Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
> > > > 
> > > > diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
> > > > index f77db6b..2c9d06e 100644
> > > > --- a/drivers/ide/ide-cd.c
> > > > +++ b/drivers/ide/ide-cd.c
> > > > @@ -1750,6 +1750,10 @@ int ide_cdrom_probe_capabilities (ide_drive_t 
> > > > *drive)
> > > > cdi->mask &= ~(CDC_DVD_RAM | CDC_RAM);
> > > > if (buf[8 + 3] & 0x10)
> > > >         cdi->mask &= ~CDC_DVD_R;
> > > > +   if (!(buf[8 + 4] & 0x01)) {
> > > 
> > > Hmm, shouldn't there be '&& (cd->cd_flags & IDE_CD_FLAG_PLAY_AUDIO_OK)'
> > > to prevent false positives?
> > 
> > I wanted to see whether the caps page reports the audioplay bit off...
> 
> we still need IDE_CD_FLAG_PLAY_AUDIO_OK flag to be _set_ to enable the quirk
> 
> > > 
> > > > +   printk(KERN_INFO "ide-cd: audio play not advertised in 
> > &g

Re: Optiarc DVD RW AD-5200A audio playing

2008-02-16 Thread Borislav Petkov
On Sat, Feb 16, 2008 at 04:24:01PM +0100, Bartlomiej Zolnierkiewicz wrote:
> 
> Hi,
> 
> On Saturday 16 February 2008, Borislav Petkov wrote:
> > On Fri, Feb 15, 2008 at 02:53:27PM -0500, Stefan Bader wrote:
> > > Hello Borislav,
> > > 
> > > I worked on a problem with an DVD driver (model=Optiarc DVD RW AD-5200A)
> > > which obviously has the same problem as some Matshita drives. The
> > > following patch was reported to enabled audio playing on this drive.
> > > Would this approach be suitable for upstream or are there other
> > > solutions to this problem?
> > > 
> > > Regards,
> > > Stefan
> > > 
> > > --- a/drivers/ide/ide-cd.c
> > > +++ b/drivers/ide/ide-cd.c
> > > @@ -2988,7 +2988,8 @@ int ide_cdrom_probe_capabilities (ide_drive_t 
> > > *drive)
> > >   if (strcmp(drive->id->model, "MATSHITADVD-ROM SR-8187") == 0 ||
> > >   strcmp(drive->id->model, "MATSHITADVD-ROM SR-8186") == 0 ||
> > >   strcmp(drive->id->model, "MATSHITADVD-ROM SR-8176") == 0 ||
> > > - strcmp(drive->id->model, "MATSHITADVD-ROM SR-8174") == 0)
> > > + strcmp(drive->id->model, "MATSHITADVD-ROM SR-8174") == 0 ||
> > > + strcmp(drive->id->model, "Optiarc DVD RW AD-5200A") == 0)
> > >   CDROM_CONFIG_FLAGS(drive)->audio_play = 1;
> > > 
> > >  #if ! STANDARD_ATAPI
> > 
> > Hi Stefan,
> > 
> > just to make sure that the audioplay bit is not set in the capabilities 
> > page,
> > can you please try the following patch applied against 2.6.25-rc2 and send 
> > me
> > the output. Thanks!
> > 
> > @Bart: by the way, this cdi->mask thingy is kinda unintuitive doing double
> > negation to check whether a feature is supported or not. Yeah, this comes 
> > from
> > "above," i.e. uniform cdrom layer. But still, shouldn't we use a 
> > cdi->caps_flags
> > or something similar instead, which mirrors the caps page bits setting?
> 
> It seems so (at least having negative flags is very unintuitive) but they
> might be some reason for this ugliness, Jens?
> 
> [ Please also remember that since cdrom layer is _uniform_ it may be not
>   possible and/or desirable to have 1-1 mapping between caps page bits
>   and the future cdi->caps_flags. ]
> 
> > commit 435f0f4496a1b32af2d542f43b2370a890fe2f83
> > Author: Borislav Petkov <[EMAIL PROTECTED]>
> > Date:   Sat Feb 16 09:56:36 2008 +0100
> > 
> > ide-cd: Enable audio play quirk for Optiarc DVD RW AD-5200A drive
> > 
> > Reported-by: Stefan Bader <[EMAIL PROTECTED]>
> > Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
> > 
> > diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
> > index f77db6b..2c9d06e 100644
> > --- a/drivers/ide/ide-cd.c
> > +++ b/drivers/ide/ide-cd.c
> > @@ -1750,6 +1750,10 @@ int ide_cdrom_probe_capabilities (ide_drive_t *drive)
> > cdi->mask &= ~(CDC_DVD_RAM | CDC_RAM);
> > if (buf[8 + 3] & 0x10)
> > cdi->mask &= ~CDC_DVD_R;
> > +   if (!(buf[8 + 4] & 0x01)) {
> 
> Hmm, shouldn't there be '&& (cd->cd_flags & IDE_CD_FLAG_PLAY_AUDIO_OK)'
> to prevent false positives?

I wanted to see whether the caps page reports the audioplay bit off...

> 
> > +   printk(KERN_INFO "ide-cd: audio play not advertised in caps 
> > page,"
> 
> Would be nice to also printk() the device name.

... but printing the device model is actually a good idea and this will rule out
false positives, so Stefan, please drop the previous patch and test the updated
one below. Thanks.


commit 6cc44b0ce5c9270b15d456eb9ffa91b855e4e0d0
Author: Borislav Petkov <[EMAIL PROTECTED]>
Date:   Sat Feb 16 09:56:36 2008 +0100

ide-cd: Enable audio play quirk for Optiarc DVD RW AD-5200A drive

Reported-by: Stefan Bader <[EMAIL PROTECTED]>
Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>

diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index f77db6b..4c9984f 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1750,6 +1750,11 @@ int ide_cdrom_probe_capabilities (ide_drive_t *drive)
cdi->mask &= ~(CDC_DVD_RAM | CDC_RAM);
if (buf[8 + 3] & 0x10)
cdi->mask &= ~CDC_DVD_R;
+   if (!(buf[8 + 4] & 0x01)) {
+   printk(KERN_INFO "ide-cd: audio play not advertised in caps "
+   "page for drive model [%s], 

Re: Optiarc DVD RW AD-5200A audio playing

2008-02-16 Thread Borislav Petkov
On Fri, Feb 15, 2008 at 02:53:27PM -0500, Stefan Bader wrote:
> Hello Borislav,
> 
> I worked on a problem with an DVD driver (model=Optiarc DVD RW AD-5200A)
> which obviously has the same problem as some Matshita drives. The
> following patch was reported to enabled audio playing on this drive.
> Would this approach be suitable for upstream or are there other
> solutions to this problem?
> 
> Regards,
> Stefan
> 
> --- a/drivers/ide/ide-cd.c
> +++ b/drivers/ide/ide-cd.c
> @@ -2988,7 +2988,8 @@ int ide_cdrom_probe_capabilities (ide_drive_t *drive)
>   if (strcmp(drive->id->model, "MATSHITADVD-ROM SR-8187") == 0 ||
>   strcmp(drive->id->model, "MATSHITADVD-ROM SR-8186") == 0 ||
>   strcmp(drive->id->model, "MATSHITADVD-ROM SR-8176") == 0 ||
> - strcmp(drive->id->model, "MATSHITADVD-ROM SR-8174") == 0)
> + strcmp(drive->id->model, "MATSHITADVD-ROM SR-8174") == 0 ||
> + strcmp(drive->id->model, "Optiarc DVD RW AD-5200A") == 0)
>   CDROM_CONFIG_FLAGS(drive)->audio_play = 1;
> 
>  #if ! STANDARD_ATAPI

Hi Stefan,

just to make sure that the audioplay bit is not set in the capabilities page,
can you please try the following patch applied against 2.6.25-rc2 and send me
the output. Thanks!

@Bart: by the way, this cdi->mask thingy is kinda unintuitive doing double
negation to check whether a feature is supported or not. Yeah, this comes from
"above," i.e. uniform cdrom layer. But still, shouldn't we use a cdi->caps_flags
or something similar instead, which mirrors the caps page bits setting?

commit 435f0f4496a1b32af2d542f43b2370a890fe2f83
Author: Borislav Petkov <[EMAIL PROTECTED]>
Date:   Sat Feb 16 09:56:36 2008 +0100

ide-cd: Enable audio play quirk for Optiarc DVD RW AD-5200A drive

Reported-by: Stefan Bader <[EMAIL PROTECTED]>
Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>

diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index f77db6b..2c9d06e 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1750,6 +1750,10 @@ int ide_cdrom_probe_capabilities (ide_drive_t *drive)
cdi->mask &= ~(CDC_DVD_RAM | CDC_RAM);
if (buf[8 + 3] & 0x10)
cdi->mask &= ~CDC_DVD_R;
+   if (!(buf[8 + 4] & 0x01)) {
+   printk(KERN_INFO "ide-cd: audio play not advertised in caps 
page,"
+" enabling quirk.\n");
+   }
if ((buf[8 + 4] & 0x01) || (cd->cd_flags & IDE_CD_FLAG_PLAY_AUDIO_OK))
cdi->mask &= ~CDC_PLAY_AUDIO;
 
@@ -1929,6 +1933,7 @@ static const struct cd_list_entry ide_cd_quirks_list[] = {
{ "MATSHITADVD-ROM SR-8186", NULL,   IDE_CD_FLAG_PLAY_AUDIO_OK  },
{ "MATSHITADVD-ROM SR-8176", NULL,   IDE_CD_FLAG_PLAY_AUDIO_OK  },
{ "MATSHITADVD-ROM SR-8174", NULL,   IDE_CD_FLAG_PLAY_AUDIO_OK  },
+   { "Optiarc DVD RW AD-5200A", NULL,   IDE_CD_FLAG_PLAY_AUDIO_OK  },
{ NULL, NULL, 0 }
 };
 

-- 
Regards/Gruß,
Boris.
-
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] MAINTAINERS: update ide-cd maintainer's email address

2008-02-16 Thread Borislav Petkov
commit c65b97fdbb9f3075a37f711aa6b388a48a27d3f4
Author: Borislav Petkov <[EMAIL PROTECTED]>
Date:   Sat Feb 16 09:10:46 2008 +0100

MAINTAINERS: update ide-cd maintainer's email address

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>

diff --git a/MAINTAINERS b/MAINTAINERS
index 1d2edb4..082d1ee 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1924,7 +1924,7 @@ S:Maintained
 
 IDE/ATAPI CDROM DRIVER
 P:     Borislav Petkov
-M: [EMAIL PROTECTED]
+M: [EMAIL PROTECTED]
 L: linux-ide@vger.kernel.org
 S: Maintained
 

-- 
Regards/Gruß,
Boris.
-
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: IDE cdrom problem with PLEXTOR DVDR PX-608AL

2008-02-15 Thread Borislav Petkov
On Thu, Feb 14, 2008 at 02:42:58PM +0100, Boris Petkov wrote:
> On 2/14/08, Bartlomiej Zolnierkiewicz <[EMAIL PROTECTED]> wrote:
> > On Thursday 14 February 2008, Borislav Petkov wrote:
> > > On Thu, Feb 14, 2008 at 12:37:50AM +0100, Hans-Peter Jansen wrote:
> > >
> > > [Added Bart to CC]
> > >
> > > > Am Dienstag, 12. Februar 2008 schrieb Borislav Petkov:
> > > > > On Tue, Feb 12, 2008 at 10:26:17AM +0100, Hans-Peter Jansen wrote:
> > > > > > Hi,
> > > > > >
> > > > > > I suffer from unreliable cdrom operations (failing DAE and burn
> > > > > > sessions) with the openSUSE 2.6.18.8-0.7-bigsmp kernel.
> > > > >
> > > > >   
> > > > > Hi,
> > > > >
> > > > > can please you test this with a more recent kernel. Yours is almost
> > > > > ancient - from Sep. 2006.
> > > >
> > > > Sure, sorry. Here we go:
> > > >
> > > > Feb 14 00:18:18 kernel: hde: cdrom_pc_intr: The drive appears confused 
> > > > (ireason = 0x01).
> > > >  Trying to recover by ending request.
> > > > Feb 14 00:27:27 kernel: hdc: cdrom_pc_intr: The drive appears confused 
> > > > (ireason = 0x01).
> > > >  Trying to recover by ending request.
> > > >
> > > > ~> uname -a
> > > > Linux xrated 2.6.24.1-35-pae #1 SMP 2008/02/12 01:00:18 UTC i686 athlon 
> > > > i386 GNU/Linux
> > >
> > > Actually the interrupt handler in ide-cd got rewritten and you're still 
> > > using the
> > > old one (cdrom_pc_intr vs cdrom_newpc_intr). Those changes went into 
> > > mainline before
> > > the 2.6.25-rc1 so we'll be able to test the new one only when you try out 
> > > 2.6.25-rc1
> > > or wait until 2.6.25 is released in case you don't want to try hazardous 
> > > materials
> > > such as an -rc kernel[*] :).
> > >
> > > Bart?
> > >
> > > *. As a matter of fact it runs quite smoothly on my machines.
> >
> > 2.6.25-rc1-git1 if you are using IDE.
> >
> > however it may still have this problem
> >
> >if (ireason == 0) {
> >write = 1;
> >xferfunc = HWIF(drive)->atapi_output_bytes;
> >} else if (ireason == 2 || (ireason == 1 &&
> >   (blk_fs_request(rq) || blk_pc_request(rq {
> >
> > we problably need to call ide_cd_check_ireason() also for REQ_TYPE_ATA_PC
> > requests and remove (blk_fs_request(rq) || blk_pc_request(rq) here
> >
> >write = 0;
> >xferfunc = HWIF(drive)->atapi_input_bytes;
> >} else {
> >printk(KERN_ERR "%s: %s: The drive "
> >"appears confused (ireason = 0x%02x). "
> >"Trying to recover by ending request.\n",
> >drive->name, __FUNCTION__, ireason);
> >goto end_request;
> >}
> >
> > Bart
> >
> Hans-Peter,
> 
> i will prepare a patch against 2.6.24 for you to try later.
Hi,

i thought that backporting ide-cd to 2.6.24 would be self-contained but the
problem is that it pulls in changes made in the block layer (ll_rw_blk.c 
splitup)
and if i pull those also in the patch, i can't guarantee the stability of your
system. Besides, this turns pretty fast into a chained pulling which will result
into a subset of 2.6.25-rc1 applied ontop of your 2.6.24.1 kernel so the only
alternative is to wait after 2.6.25 has been released and tackle the problem 
then.

-- 
Regards/Gruß,
Boris.
-
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] ide-floppy: merge callbacks

2008-02-13 Thread Borislav Petkov
On Wed, Feb 13, 2008 at 11:04:23PM +0100, Bartlomiej Zolnierkiewicz wrote:
> On Wednesday 13 February 2008, Borislav Petkov wrote:
> > commit d1f1f84f413ab00cb2fec48170d022fcd900e214
> > Author: Borislav Petkov <[EMAIL PROTECTED]>
> > Date:   Wed Feb 13 20:26:56 2008 +0100
> > 
> > ide-floppy: merge callbacks
> > 
> > The appropriate functionality of the callback is established through 
> > querying
> > the ATAPI packet command in pc->c[0].
> > 
> > While at it, simplify if (floppy->failed_pc)-branch to be found in the 
> > original
> > idefloppy_request_sense_callback().
> > 
> > Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
> > 
> > diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
> > index 5f133df..1365310 100644
> > --- a/drivers/ide/ide-floppy.c
> > +++ b/drivers/ide/ide-floppy.c
> > @@ -313,50 +313,39 @@ static struct request 
> > *idefloppy_next_rq_storage(ide_drive_t *drive)
> > return (&floppy->rq_stack[floppy->rq_stack_index++]);
> >  }
> >  
> > -static void idefloppy_request_sense_callback(ide_drive_t *drive)
> > +static void ide_floppy_callback(ide_drive_t *drive)
> >  {
> > idefloppy_floppy_t *floppy = drive->driver_data;
> > -   u8 *buf = floppy->pc->buf;
> >  
> > debug_log("Reached %s\n", __func__);
> >  
> > -   if (!floppy->pc->error) {
> > -   floppy->sense_key = buf[2] & 0x0F;
> > -   floppy->asc = buf[12];
> > -   floppy->ascq = buf[13];
> > -   floppy->progress_indication = buf[15] & 0x80 ?
> > -   (u16)get_unaligned((u16 *)&buf[16]) : 0x1;
> > +   if (floppy->pc->c[0] == GPCMD_REQUEST_SENSE) {
> > +   u8 *buf = floppy->pc->buf;
> >  
> > -   if (floppy->failed_pc)
> > -   debug_log("pc = %x, sense key = %x, asc = %x,"
> > -   " ascq = %x\n",
> > -   floppy->failed_pc->c[0],
> > -   floppy->sense_key,
> > -   floppy->asc,
> > -   floppy->ascq);
> > -   else
> > -   debug_log("sense key = %x, asc = %x, ascq = %x\n",
> > -   floppy->sense_key,
> > -   floppy->asc,
> > -   floppy->ascq);
> > -
> > -
> > -   idefloppy_end_request(drive, 1, 0);
> > -   } else {
> > -   printk(KERN_ERR "Error in REQUEST SENSE itself - Aborting"
> > -   " request!\n");
> > -   idefloppy_end_request(drive, 0, 0);
> > -   }
> > -}
> > +   if (!floppy->pc->error) {
> > +   floppy->sense_key = buf[2] & 0x0F;
> > +   floppy->asc = buf[12];
> > +   floppy->ascq = buf[13];
> > +   floppy->progress_indication = buf[15] & 0x80 ?
> > +   (u16)get_unaligned((u16 *)&buf[16]) : 0x1;
> >  
> > -/* General packet command callback function. */
> > -static void idefloppy_pc_callback(ide_drive_t *drive)
> > -{
> > -   idefloppy_floppy_t *floppy = drive->driver_data;
> > +   if (floppy->failed_pc)
> > +   debug_log("pc = %x, ", floppy->failed_pc->c[0]);
> >  
> > -   debug_log("Reached %s\n", __func__);
> > +   debug_log("sense key = %x, asc = %x, ascq = %x\n",
> > +   floppy->sense_key, floppy->asc, floppy->ascq);
> >  
> > -   idefloppy_end_request(drive, floppy->pc->error ? 0 : 1, 0);
> > +   idefloppy_end_request(drive, 1, 0);
> > +   } else {
> > +   printk(KERN_ERR "Error in REQUEST SENSE itself - "
> > +   "Aborting request!\n");
> > +   idefloppy_end_request(drive, 0, 0);
> > +   }
> > +   } else if (floppy->pc->c[0] == GPCMD_READ_10 ||
> > +   floppy->pc->c[0] == GPCMD_WRITE_10)
> > +   idefloppy_end_request(drive, 1, 0);
> > +   else
> > +   idefloppy_end_request(drive, floppy->pc-&

Re: IDE cdrom problem with PLEXTOR DVDR PX-608AL

2008-02-13 Thread Borislav Petkov
On Thu, Feb 14, 2008 at 12:37:50AM +0100, Hans-Peter Jansen wrote:

[Added Bart to CC]

> Am Dienstag, 12. Februar 2008 schrieb Borislav Petkov:
> > On Tue, Feb 12, 2008 at 10:26:17AM +0100, Hans-Peter Jansen wrote:
> > > Hi,
> > >
> > > I suffer from unreliable cdrom operations (failing DAE and burn
> > > sessions) with the openSUSE 2.6.18.8-0.7-bigsmp kernel.
> >
> > 
> > Hi,
> >
> > can please you test this with a more recent kernel. Yours is almost
> > ancient - from Sep. 2006.
> 
> Sure, sorry. Here we go:
> 
> Feb 14 00:18:18 kernel: hde: cdrom_pc_intr: The drive appears confused 
> (ireason = 0x01).
>  Trying to recover by ending request.
> Feb 14 00:27:27 kernel: hdc: cdrom_pc_intr: The drive appears confused 
> (ireason = 0x01). 
>  Trying to recover by ending request.
> 
> ~> uname -a
> Linux xrated 2.6.24.1-35-pae #1 SMP 2008/02/12 01:00:18 UTC i686 athlon i386 
> GNU/Linux

Actually the interrupt handler in ide-cd got rewritten and you're still using 
the
old one (cdrom_pc_intr vs cdrom_newpc_intr). Those changes went into mainline 
before
the 2.6.25-rc1 so we'll be able to test the new one only when you try out 
2.6.25-rc1
or wait until 2.6.25 is released in case you don't want to try hazardous 
materials
such as an -rc kernel[*] :).

Bart?

*. As a matter of fact it runs quite smoothly on my machines.

-- 
Regards/Gruß,
Boris.
-
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] ide-floppy: merge callbacks

2008-02-13 Thread Borislav Petkov
commit d1f1f84f413ab00cb2fec48170d022fcd900e214
Author: Borislav Petkov <[EMAIL PROTECTED]>
Date:   Wed Feb 13 20:26:56 2008 +0100

ide-floppy: merge callbacks

The appropriate functionality of the callback is established through 
querying
the ATAPI packet command in pc->c[0].

While at it, simplify if (floppy->failed_pc)-branch to be found in the 
original
idefloppy_request_sense_callback().

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>

diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 5f133df..1365310 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -313,50 +313,39 @@ static struct request 
*idefloppy_next_rq_storage(ide_drive_t *drive)
return (&floppy->rq_stack[floppy->rq_stack_index++]);
 }
 
-static void idefloppy_request_sense_callback(ide_drive_t *drive)
+static void ide_floppy_callback(ide_drive_t *drive)
 {
idefloppy_floppy_t *floppy = drive->driver_data;
-   u8 *buf = floppy->pc->buf;
 
debug_log("Reached %s\n", __func__);
 
-   if (!floppy->pc->error) {
-   floppy->sense_key = buf[2] & 0x0F;
-   floppy->asc = buf[12];
-   floppy->ascq = buf[13];
-   floppy->progress_indication = buf[15] & 0x80 ?
-   (u16)get_unaligned((u16 *)&buf[16]) : 0x1;
+   if (floppy->pc->c[0] == GPCMD_REQUEST_SENSE) {
+   u8 *buf = floppy->pc->buf;
 
-   if (floppy->failed_pc)
-   debug_log("pc = %x, sense key = %x, asc = %x,"
-   " ascq = %x\n",
-   floppy->failed_pc->c[0],
-   floppy->sense_key,
-   floppy->asc,
-   floppy->ascq);
-   else
-   debug_log("sense key = %x, asc = %x, ascq = %x\n",
-   floppy->sense_key,
-   floppy->asc,
-   floppy->ascq);
-
-
-   idefloppy_end_request(drive, 1, 0);
-   } else {
-   printk(KERN_ERR "Error in REQUEST SENSE itself - Aborting"
-   " request!\n");
-   idefloppy_end_request(drive, 0, 0);
-   }
-}
+   if (!floppy->pc->error) {
+   floppy->sense_key = buf[2] & 0x0F;
+   floppy->asc = buf[12];
+   floppy->ascq = buf[13];
+   floppy->progress_indication = buf[15] & 0x80 ?
+   (u16)get_unaligned((u16 *)&buf[16]) : 0x1;
 
-/* General packet command callback function. */
-static void idefloppy_pc_callback(ide_drive_t *drive)
-{
-   idefloppy_floppy_t *floppy = drive->driver_data;
+   if (floppy->failed_pc)
+   debug_log("pc = %x, ", floppy->failed_pc->c[0]);
 
-   debug_log("Reached %s\n", __func__);
+   debug_log("sense key = %x, asc = %x, ascq = %x\n",
+   floppy->sense_key, floppy->asc, floppy->ascq);
 
-   idefloppy_end_request(drive, floppy->pc->error ? 0 : 1, 0);
+   idefloppy_end_request(drive, 1, 0);
+   } else {
+   printk(KERN_ERR "Error in REQUEST SENSE itself - "
+   "Aborting request!\n");
+   idefloppy_end_request(drive, 0, 0);
+   }
+   } else if (floppy->pc->c[0] == GPCMD_READ_10 ||
+   floppy->pc->c[0] == GPCMD_WRITE_10)
+   idefloppy_end_request(drive, 1, 0);
+   else
+   idefloppy_end_request(drive, floppy->pc->error ? 0 : 1, 0);
 }
 
 static void idefloppy_init_pc(struct ide_atapi_pc *pc)
@@ -367,7 +356,7 @@ static void idefloppy_init_pc(struct ide_atapi_pc *pc)
pc->req_xfer = 0;
pc->buf = pc->pc_buf;
pc->buf_size = IDEFLOPPY_PC_BUFFER_SIZE;
-   pc->idefloppy_callback = &idefloppy_pc_callback;
+   pc->idefloppy_callback = &ide_floppy_callback;
 }
 
 static void idefloppy_create_request_sense_cmd(struct ide_atapi_pc *pc)
@@ -376,7 +365,6 @@ static void idefloppy_create_request_sense_cmd(struct 
ide_atapi_pc *pc)
pc->c[0] = GPCMD_REQUEST_SENSE;
pc->c[4] = 255;
pc->req_xfer = 18;
-   pc->idefloppy_callback = &idefloppy_request_sense_callback;
 }
 
 /*
@@ -697,14 +685,6 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t 
*drive,
}
 }
 
-static void idefloppy_rw_

[PATCH 2/2] ide-scsi: do non-atomic pc->flags testing

2008-02-13 Thread Borislav Petkov
...also, convert ide-scsi to using the generic pc->flags defines.

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/scsi/ide-scsi.c |   37 -
 1 files changed, 16 insertions(+), 21 deletions(-)

diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index 5ec421c..93c3fc2 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -61,14 +61,6 @@
 #define IDESCSI_DEBUG_LOG  0
 
 /*
- * Packet command status bits.
- */
-#define PC_DMA_IN_PROGRESS 0   /* 1 while DMA in progress */
-#define PC_WRITING 1   /* Data direction */
-#define PC_TIMEDOUT3   /* command timed out */
-#define PC_DMA_OK  4   /* Use DMA */
-
-/*
  * SCSI command transformation layer
  */
 #define IDESCSI_SG_TRANSFORM   1   /* /dev/sg transformation */
@@ -319,8 +311,10 @@ static int idescsi_end_request (ide_drive_t *drive, int 
uptodate, int nrsecs)
pc = opc;
rq = pc->rq;
pc->scsi_cmd->result = (CHECK_CONDITION << 1) |
-   ((test_bit(PC_TIMEDOUT, 
&pc->flags)?DID_TIME_OUT:DID_OK) << 16);
-   } else if (test_bit(PC_TIMEDOUT, &pc->flags)) {
+   (((pc->flags & PC_FLAG_TIMEDOUT) ?
+ DID_TIME_OUT :
+ DID_OK) << 16);
+   } else if (pc->flags & PC_FLAG_TIMEDOUT) {
if (log)
printk (KERN_WARNING "ide-scsi: %s: timed out for 
%lu\n",
drive->name, 
pc->scsi_cmd->serial_number);
@@ -362,7 +356,7 @@ static int idescsi_expiry(ide_drive_t *drive)
 #if IDESCSI_DEBUG_LOG
printk(KERN_WARNING "idescsi_expiry called for %lu at %lu\n", 
pc->scsi_cmd->serial_number, jiffies);
 #endif
-   set_bit(PC_TIMEDOUT, &pc->flags);
+   pc->flags |= PC_FLAG_TIMEDOUT;
 
return 0;   /* we do not want the 
ide subsystem to retry */
 }
@@ -384,7 +378,7 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
printk (KERN_INFO "ide-scsi: Reached idescsi_pc_intr interrupt 
handler\n");
 #endif /* IDESCSI_DEBUG_LOG */
 
-   if (test_bit(PC_TIMEDOUT, &pc->flags)){
+   if (pc->flags & PC_FLAG_TIMEDOUT) {
 #if IDESCSI_DEBUG_LOG
printk(KERN_WARNING "idescsi_pc_intr: got timed out packet  %lu 
at %lu\n",
pc->scsi_cmd->serial_number, jiffies);
@@ -393,7 +387,8 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
idescsi_end_request (drive, 1, 0);
return ide_stopped;
}
-   if (test_and_clear_bit (PC_DMA_IN_PROGRESS, &pc->flags)) {
+   if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) {
+   pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS;
 #if IDESCSI_DEBUG_LOG
printk ("ide-scsi: %s: DMA complete\n", drive->name);
 #endif /* IDESCSI_DEBUG_LOG */
@@ -432,7 +427,7 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
"- discarding data\n");
temp = pc->buf_size - pc->xferred;
if (temp) {
-   clear_bit(PC_WRITING, &pc->flags);
+   pc->flags &= ~PC_FLAG_WRITING;
if (pc->sg)
idescsi_input_buffers(drive, pc,
temp);
@@ -454,14 +449,14 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t 
*drive)
}
}
if (ireason & IO) {
-   clear_bit(PC_WRITING, &pc->flags);
+   pc->flags &= ~PC_FLAG_WRITING;
if (pc->sg)
idescsi_input_buffers(drive, pc, bcount);
else
hwif->atapi_input_bytes(drive, pc->cur_pos,
bcount);
} else {
-   set_bit(PC_WRITING, &pc->flags);
+   pc->flags |= PC_FLAG_WRITING;
if (pc->sg)
idescsi_output_buffers(drive, pc, bcount);
else
@@ -501,8 +496,8 @@ static ide_startstop_t idescsi_transfer_pc(ide_drive_t 
*drive)
ide_set_handler(drive, &idescsi_pc_intr, get_timeout(pc), 
idescsi_expiry);
/* Send the actual packet */
drive->hwif->atapi_output_bytes(drive, scsi->pc->c, 12);
-   if (test_bit (PC_DMA_OK, &pc->flags)) {
-   set_b

[PATCH 1/2] ide: use generic ATAPI packet command flags in ide-{floppy,tape}

2008-02-13 Thread Borislav Petkov
Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-floppy.c |   14 --
 drivers/ide/ide-tape.c   |   16 
 include/linux/ide.h  |   15 +++
 3 files changed, 15 insertions(+), 30 deletions(-)

diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index bf1ef60..5f133df 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -78,20 +78,6 @@
  */
 #define IDEFLOPPY_PC_STACK (10 + IDEFLOPPY_MAX_PC_RETRIES)
 
-/* Packet command flag bits. */
-enum {
-   /* 1 when we prefer to use DMA if possible */
-   PC_FLAG_DMA_RECOMMENDED = (1 << 0),
-   /* 1 while DMA in progress */
-   PC_FLAG_DMA_IN_PROGRESS = (1 << 1),
-   /* 1 when encountered problem during DMA */
-   PC_FLAG_DMA_ERROR   = (1 << 2),
-   /* Data direction */
-   PC_FLAG_WRITING = (1 << 3),
-   /* Suppress error reporting */
-   PC_FLAG_SUPPRESS_ERROR  = (1 << 4),
-};
-
 /* format capacities descriptor codes */
 #define CAPACITY_INVALID   0x00
 #define CAPACITY_UNFORMATTED   0x01
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 3a10208..3f9fbd8 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -181,22 +181,6 @@ struct idetape_bh {
char *b_data;
 };
 
-/* Packet command flag bits. */
-enum {
-   /* Set when an error is considered normal - We won't retry */
-   PC_FLAG_ABORT   = (1 << 0),
-   /* 1 When polling for DSC on a media access command */
-   PC_FLAG_WAIT_FOR_DSC= (1 << 1),
-   /* 1 when we prefer to use DMA if possible */
-   PC_FLAG_DMA_RECOMMENDED = (1 << 2),
-   /* 1 while DMA in progress */
-   PC_FLAG_DMA_IN_PROGRESS = (1 << 3),
-   /* 1 when encountered problem during DMA */
-   PC_FLAG_DMA_ERROR   = (1 << 4),
-   /* Data direction */
-   PC_FLAG_WRITING = (1 << 5),
-};
-
 /* Tape door status */
 #define DOOR_UNLOCKED  0
 #define DOOR_LOCKED1
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 509d806..0e5f09b 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -629,6 +629,21 @@ typedef struct ide_settings_s {
 
 int ide_add_setting(ide_drive_t *, const char *, int, int, int, int, int, int, 
void *, ide_procset_t *set);
 
+/* ATAPI packet command flags */
+enum {
+   /* set when an error is considered normal - no retry (ide-tape) */
+   PC_FLAG_ABORT   = (1 << 0),
+   PC_FLAG_SUPPRESS_ERROR  = (1 << 1),
+   PC_FLAG_WAIT_FOR_DSC= (1 << 2),
+   PC_FLAG_DMA_OK  = (1 << 3),
+   PC_FLAG_DMA_RECOMMENDED = (1 << 4),
+   PC_FLAG_DMA_IN_PROGRESS = (1 << 5),
+   PC_FLAG_DMA_ERROR   = (1 << 6),
+   PC_FLAG_WRITING = (1 << 7),
+   /* command timed out */
+   PC_FLAG_TIMEDOUT= (1 << 8),
+};
+
 struct ide_atapi_pc {
/* actual packet bytes */
u8 c[12];
-- 
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


[PATCH 2/2] ide-scsi: do non-atomic pc->flags testing

2008-02-13 Thread Borislav Petkov
Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/scsi/ide-scsi.c |   27 ++-
 1 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index d46c81c..93c3fc2 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -311,10 +311,10 @@ static int idescsi_end_request (ide_drive_t *drive, int 
uptodate, int nrsecs)
pc = opc;
rq = pc->rq;
pc->scsi_cmd->result = (CHECK_CONDITION << 1) |
-   ((test_bit(PC_FLAG_TIMEDOUT, &pc->flags) ?
+   (((pc->flags & PC_FLAG_TIMEDOUT) ?
  DID_TIME_OUT :
  DID_OK) << 16);
-   } else if (test_bit(PC_FLAG_TIMEDOUT, &pc->flags)) {
+   } else if (pc->flags & PC_FLAG_TIMEDOUT) {
if (log)
printk (KERN_WARNING "ide-scsi: %s: timed out for 
%lu\n",
drive->name, 
pc->scsi_cmd->serial_number);
@@ -356,7 +356,7 @@ static int idescsi_expiry(ide_drive_t *drive)
 #if IDESCSI_DEBUG_LOG
printk(KERN_WARNING "idescsi_expiry called for %lu at %lu\n", 
pc->scsi_cmd->serial_number, jiffies);
 #endif
-   set_bit(PC_FLAG_TIMEDOUT, &pc->flags);
+   pc->flags |= PC_FLAG_TIMEDOUT;
 
return 0;   /* we do not want the 
ide subsystem to retry */
 }
@@ -378,7 +378,7 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
printk (KERN_INFO "ide-scsi: Reached idescsi_pc_intr interrupt 
handler\n");
 #endif /* IDESCSI_DEBUG_LOG */
 
-   if (test_bit(PC_FLAG_TIMEDOUT, &pc->flags)) {
+   if (pc->flags & PC_FLAG_TIMEDOUT) {
 #if IDESCSI_DEBUG_LOG
printk(KERN_WARNING "idescsi_pc_intr: got timed out packet  %lu 
at %lu\n",
pc->scsi_cmd->serial_number, jiffies);
@@ -387,7 +387,8 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
idescsi_end_request (drive, 1, 0);
return ide_stopped;
}
-   if (test_and_clear_bit(PC_FLAG_DMA_IN_PROGRESS, &pc->flags)) {
+   if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) {
+   pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS;
 #if IDESCSI_DEBUG_LOG
printk ("ide-scsi: %s: DMA complete\n", drive->name);
 #endif /* IDESCSI_DEBUG_LOG */
@@ -426,7 +427,7 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
"- discarding data\n");
temp = pc->buf_size - pc->xferred;
if (temp) {
-   clear_bit(PC_FLAG_WRITING, &pc->flags);
+   pc->flags &= ~PC_FLAG_WRITING;
if (pc->sg)
idescsi_input_buffers(drive, pc,
temp);
@@ -448,14 +449,14 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t 
*drive)
}
}
if (ireason & IO) {
-   clear_bit(PC_FLAG_WRITING, &pc->flags);
+   pc->flags &= ~PC_FLAG_WRITING;
if (pc->sg)
idescsi_input_buffers(drive, pc, bcount);
else
hwif->atapi_input_bytes(drive, pc->cur_pos,
bcount);
} else {
-   set_bit(PC_FLAG_WRITING, &pc->flags);
+   pc->flags |= PC_FLAG_WRITING;
if (pc->sg)
idescsi_output_buffers(drive, pc, bcount);
else
@@ -495,8 +496,8 @@ static ide_startstop_t idescsi_transfer_pc(ide_drive_t 
*drive)
ide_set_handler(drive, &idescsi_pc_intr, get_timeout(pc), 
idescsi_expiry);
/* Send the actual packet */
drive->hwif->atapi_output_bytes(drive, scsi->pc->c, 12);
-   if (test_bit(PC_FLAG_DMA_OK, &pc->flags)) {
-   set_bit(PC_FLAG_DMA_IN_PROGRESS, &pc->flags);
+   if (pc->flags & PC_FLAG_DMA_OK) {
+   pc->flags |= PC_FLAG_DMA_IN_PROGRESS;
hwif->dma_start(drive);
}
return ide_started;
@@ -506,10 +507,10 @@ static inline int idescsi_set_direction(struct 
ide_atapi_pc *pc)
 {
switch (pc->c[0]) {
case READ_6: case READ_10: case READ_12:
-   clear_bit(PC_FLAG_WRITING, &pc->flags);
+   pc->flags &= ~PC_FLAG_WRITING;
return 0;

[PATCH 1/2] ide: use generic ATAPI packet command flags in ide-{floppy,tape,scsi}

2008-02-13 Thread Borislav Petkov
This is done in one single patch in order not to cause git breakage.

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-floppy.c |   14 --
 drivers/ide/ide-tape.c   |   16 
 drivers/scsi/ide-scsi.c  |   36 +++-
 include/linux/ide.h  |   15 +++
 4 files changed, 30 insertions(+), 51 deletions(-)

diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index bf1ef60..5f133df 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -78,20 +78,6 @@
  */
 #define IDEFLOPPY_PC_STACK (10 + IDEFLOPPY_MAX_PC_RETRIES)
 
-/* Packet command flag bits. */
-enum {
-   /* 1 when we prefer to use DMA if possible */
-   PC_FLAG_DMA_RECOMMENDED = (1 << 0),
-   /* 1 while DMA in progress */
-   PC_FLAG_DMA_IN_PROGRESS = (1 << 1),
-   /* 1 when encountered problem during DMA */
-   PC_FLAG_DMA_ERROR   = (1 << 2),
-   /* Data direction */
-   PC_FLAG_WRITING = (1 << 3),
-   /* Suppress error reporting */
-   PC_FLAG_SUPPRESS_ERROR  = (1 << 4),
-};
-
 /* format capacities descriptor codes */
 #define CAPACITY_INVALID   0x00
 #define CAPACITY_UNFORMATTED   0x01
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 3a10208..3f9fbd8 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -181,22 +181,6 @@ struct idetape_bh {
char *b_data;
 };
 
-/* Packet command flag bits. */
-enum {
-   /* Set when an error is considered normal - We won't retry */
-   PC_FLAG_ABORT   = (1 << 0),
-   /* 1 When polling for DSC on a media access command */
-   PC_FLAG_WAIT_FOR_DSC= (1 << 1),
-   /* 1 when we prefer to use DMA if possible */
-   PC_FLAG_DMA_RECOMMENDED = (1 << 2),
-   /* 1 while DMA in progress */
-   PC_FLAG_DMA_IN_PROGRESS = (1 << 3),
-   /* 1 when encountered problem during DMA */
-   PC_FLAG_DMA_ERROR   = (1 << 4),
-   /* Data direction */
-   PC_FLAG_WRITING = (1 << 5),
-};
-
 /* Tape door status */
 #define DOOR_UNLOCKED  0
 #define DOOR_LOCKED1
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index 5ec421c..d46c81c 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -61,14 +61,6 @@
 #define IDESCSI_DEBUG_LOG  0
 
 /*
- * Packet command status bits.
- */
-#define PC_DMA_IN_PROGRESS 0   /* 1 while DMA in progress */
-#define PC_WRITING 1   /* Data direction */
-#define PC_TIMEDOUT3   /* command timed out */
-#define PC_DMA_OK  4   /* Use DMA */
-
-/*
  * SCSI command transformation layer
  */
 #define IDESCSI_SG_TRANSFORM   1   /* /dev/sg transformation */
@@ -319,8 +311,10 @@ static int idescsi_end_request (ide_drive_t *drive, int 
uptodate, int nrsecs)
pc = opc;
rq = pc->rq;
pc->scsi_cmd->result = (CHECK_CONDITION << 1) |
-   ((test_bit(PC_TIMEDOUT, 
&pc->flags)?DID_TIME_OUT:DID_OK) << 16);
-   } else if (test_bit(PC_TIMEDOUT, &pc->flags)) {
+   ((test_bit(PC_FLAG_TIMEDOUT, &pc->flags) ?
+ DID_TIME_OUT :
+ DID_OK) << 16);
+   } else if (test_bit(PC_FLAG_TIMEDOUT, &pc->flags)) {
if (log)
printk (KERN_WARNING "ide-scsi: %s: timed out for 
%lu\n",
drive->name, 
pc->scsi_cmd->serial_number);
@@ -362,7 +356,7 @@ static int idescsi_expiry(ide_drive_t *drive)
 #if IDESCSI_DEBUG_LOG
printk(KERN_WARNING "idescsi_expiry called for %lu at %lu\n", 
pc->scsi_cmd->serial_number, jiffies);
 #endif
-   set_bit(PC_TIMEDOUT, &pc->flags);
+   set_bit(PC_FLAG_TIMEDOUT, &pc->flags);
 
return 0;   /* we do not want the 
ide subsystem to retry */
 }
@@ -384,7 +378,7 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
printk (KERN_INFO "ide-scsi: Reached idescsi_pc_intr interrupt 
handler\n");
 #endif /* IDESCSI_DEBUG_LOG */
 
-   if (test_bit(PC_TIMEDOUT, &pc->flags)){
+   if (test_bit(PC_FLAG_TIMEDOUT, &pc->flags)) {
 #if IDESCSI_DEBUG_LOG
printk(KERN_WARNING "idescsi_pc_intr: got timed out packet  %lu 
at %lu\n",
pc->scsi_cmd->serial_number, jiffies);
@@ -393,7 +387,7 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
idescsi_end_request (drive, 1, 0);
return ide_stopped;
}
-   if (test_and_clear_bit (PC_DMA

Re: [RFC PATCH] ide-floppy: use rq->cmd for preparing and sending packet cmds to the drive

2008-02-13 Thread Borislav Petkov
On Tue, Feb 12, 2008 at 10:39:22PM +0100, Bartlomiej Zolnierkiewicz wrote:

Hi Bart,

> I think that this _really_ should be done _after_ unifying ATAPI handling [*].
> Otherwise you will be making some of the same changes to the _three_ copies
> of (more or less) identical code and more importantly we will have to delay
> unification after _all_ drivers are converted to rq->cmd[] (+ lets not forget
> that I'll have more changes to review ;).
> 
> (*) please take a closer look at *_issue_pc(), *_transfer_pc() and *_pc_intr()
> in ide-{floppy,tape,scsi} (the useful hint is that after making these
> functions free of references to device driver specific objects/functions
> we can use drive->media == ide_{floppy,tape,scsi} checks for handling
> not yet fully unified / media type specific code).

I started working on probably the easiest unification we could do: unify all the
pc->flags defines and move them in a header where all drivers can use them. This
raises an architectural design question: The way i see it, the generic ATAPI 
handling
is going to be sort of "serving" functionality to the drivers using ATAPI. Do 
we want
all this functionality to go to ide.{h,c} or we want specific atapi.{h,c} files 
that
contain only this unified functionality, or whatever else. In general, how is 
this
generic layer going to be distributed among headers/.c files and what do we 
want there?

/me tends to think that special headers/files, small and easy to manage and
modular, have more advantages in this case but this is just me. After we've
decided on that, the rest of the issues will resolve by themselves/get easier to
tackle.

Thanks.

-- 
Regards/Gruß,
Boris.
-
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: IDE cdrom problem with PLEXTOR DVDR PX-608AL

2008-02-12 Thread Borislav Petkov
On Tue, Feb 12, 2008 at 10:26:17AM +0100, Hans-Peter Jansen wrote:
> Hi, 
> 
> I suffer from unreliable cdrom operations (failing DAE and burn sessions) 
> with the openSUSE 2.6.18.8-0.7-bigsmp kernel.

Hi,

can please you test this with a more recent kernel. Yours is almost ancient -
from Sep. 2006.

Thanks.

-- 
Regards/Gruß,
Boris.
-
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] ide-scsi: do non-atomic pc->flags testing

2008-02-12 Thread Borislav Petkov
commit 272976f0f5754707f9e41da315717a6eb8d9d536
Author: Borislav Petkov <[EMAIL PROTECTED]>
Date:   Tue Feb 12 16:22:44 2008 +0100

ide-scsi: do non-atomic pc->flags testing

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>

diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index 5ec421c..eb84cdc 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -319,8 +319,10 @@ static int idescsi_end_request (ide_drive_t *drive, int 
uptodate, int nrsecs)
pc = opc;
rq = pc->rq;
pc->scsi_cmd->result = (CHECK_CONDITION << 1) |
-   ((test_bit(PC_TIMEDOUT, 
&pc->flags)?DID_TIME_OUT:DID_OK) << 16);
-   } else if (test_bit(PC_TIMEDOUT, &pc->flags)) {
+   (((pc->flags & PC_TIMEDOUT) ?
+ DID_TIME_OUT :
+ DID_OK) << 16);
+   } else if (pc->flags & PC_TIMEDOUT) {
if (log)
printk (KERN_WARNING "ide-scsi: %s: timed out for 
%lu\n",
drive->name, 
pc->scsi_cmd->serial_number);
@@ -362,7 +364,7 @@ static int idescsi_expiry(ide_drive_t *drive)
 #if IDESCSI_DEBUG_LOG
printk(KERN_WARNING "idescsi_expiry called for %lu at %lu\n", 
pc->scsi_cmd->serial_number, jiffies);
 #endif
-   set_bit(PC_TIMEDOUT, &pc->flags);
+   pc->flags |= PC_TIMEDOUT;
 
return 0;   /* we do not want the 
ide subsystem to retry */
 }
@@ -384,7 +386,7 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
printk (KERN_INFO "ide-scsi: Reached idescsi_pc_intr interrupt 
handler\n");
 #endif /* IDESCSI_DEBUG_LOG */
 
-   if (test_bit(PC_TIMEDOUT, &pc->flags)){
+   if (pc->flags & PC_TIMEDOUT) {
 #if IDESCSI_DEBUG_LOG
printk(KERN_WARNING "idescsi_pc_intr: got timed out packet  %lu 
at %lu\n",
pc->scsi_cmd->serial_number, jiffies);
@@ -393,7 +395,8 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
idescsi_end_request (drive, 1, 0);
return ide_stopped;
}
-   if (test_and_clear_bit (PC_DMA_IN_PROGRESS, &pc->flags)) {
+   if (pc->flags & PC_DMA_IN_PROGRESS) {
+   pc->flags &= ~PC_DMA_IN_PROGRESS;
 #if IDESCSI_DEBUG_LOG
printk ("ide-scsi: %s: DMA complete\n", drive->name);
 #endif /* IDESCSI_DEBUG_LOG */
@@ -432,7 +435,7 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
"- discarding data\n");
temp = pc->buf_size - pc->xferred;
if (temp) {
-   clear_bit(PC_WRITING, &pc->flags);
+   pc->flags &= ~PC_WRITING;
if (pc->sg)
idescsi_input_buffers(drive, pc,
temp);
@@ -454,14 +457,14 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t 
*drive)
}
}
if (ireason & IO) {
-   clear_bit(PC_WRITING, &pc->flags);
+   pc->flags &= ~PC_WRITING;
if (pc->sg)
idescsi_input_buffers(drive, pc, bcount);
else
hwif->atapi_input_bytes(drive, pc->cur_pos,
bcount);
} else {
-   set_bit(PC_WRITING, &pc->flags);
+   pc->flags |= PC_WRITING;
if (pc->sg)
idescsi_output_buffers(drive, pc, bcount);
else
@@ -501,8 +504,8 @@ static ide_startstop_t idescsi_transfer_pc(ide_drive_t 
*drive)
ide_set_handler(drive, &idescsi_pc_intr, get_timeout(pc), 
idescsi_expiry);
/* Send the actual packet */
drive->hwif->atapi_output_bytes(drive, scsi->pc->c, 12);
-   if (test_bit (PC_DMA_OK, &pc->flags)) {
-   set_bit (PC_DMA_IN_PROGRESS, &pc->flags);
+   if (pc->flags & PC_DMA_OK) {
+   pc->flags |= PC_DMA_IN_PROGRESS;
hwif->dma_start(drive);
}
return ide_started;
@@ -512,10 +515,10 @@ static inline int idescsi_set_direction(struct 
ide_atapi_pc *pc)
 {
switch (pc->c[0]) {
case READ_6: case READ_10: case READ_12:
-   clear_bit(PC_WRITING, &pc->flags);
+   pc->flags &= 

[RFC PATCH] ide-floppy: use rq->cmd for preparing and sending packet cmds to the drive

2008-02-12 Thread Borislav Petkov
Hi Bart,

here's a first go at converting ide-floppy to using rq->cmd for packet commands.
The code below is pretty rough and from what i can tell needs to be hammered a
lot more, for it raises a lot of issues:

1. The command control (pc->callback, request type, etc) is still done using 
the pc
pointer passed to all the functions prior to issuing the command. This, imho, 
can be
done a lot cleaner and easier. What is the rationale here, do we want 
ide_atapi_pc
removed in the long run and get by only with rq's as is the case with ide-cd?

2. I end up allocating all the requests on the stack just like the respective
ide_atapi_pc structs and don't use the heap allocation facilities. I guess this 
will
get resolved after we've decided on allocation scheme for the rq structs... In 
the
meantime, the stack is probably gonna blow with additional sizeof(struct 
request).

3. idefloppy_queue_pc_{head,tail} turn into simple wrappers which begs for
merging them but this is trivial.

4.Made rq->cmd_type = REQ_TYPE_ATA_PC from REQ_TYPE_SPECIAL but i guess the
final goal is REQ_TYPE_BLOCK_PC. Will have to see how is this handled in the
block layer and whether we're ready to do that.

5. This change is less intrusive but begs for a lot of simplification afterwards
similar to ide-cd, which will probably get rid of all those create_.*_cmd()
helpers.

6. Only compile-tested. Proper testing follows...

--
commit 8359f6f7122e87c30467ff73895399b82610b835
Author: Borislav Petkov <[EMAIL PROTECTED]>
Date:   Tue Feb 12 10:06:55 2008 +0100

ide-floppy: use rq->cmd for preparing and sending packet cmds to the drive

... similar to the way it is done in ide-cd.

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>

diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index bf1ef60..ab125ad 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -297,16 +297,9 @@ static void idefloppy_update_buffers(ide_drive_t *drive,
  * 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, struct ide_atapi_pc 
*pc,
-   struct request *rq)
+static void idefloppy_queue_pc_head(ide_drive_t *drive, struct ide_atapi_pc 
*pc)
 {
-   struct ide_floppy_obj *floppy = drive->driver_data;
-
-   ide_init_drive_cmd(rq);
-   rq->buffer = (char *) pc;
-   rq->cmd_type = REQ_TYPE_SPECIAL;
-   rq->rq_disk = floppy->disk;
-   (void) ide_do_drive_cmd(drive, rq, ide_preempt);
+   (void)ide_do_drive_cmd(drive, pc->rq, ide_preempt);
 }
 
 static struct ide_atapi_pc *idefloppy_next_pc_storage(ide_drive_t *drive)
@@ -344,7 +337,7 @@ static void idefloppy_request_sense_callback(ide_drive_t 
*drive)
if (floppy->failed_pc)
debug_log("pc = %x, sense key = %x, asc = %x,"
" ascq = %x\n",
-   floppy->failed_pc->c[0],
+   floppy->failed_pc->rq->cmd[0],
floppy->sense_key,
floppy->asc,
floppy->ascq);
@@ -375,7 +368,6 @@ static void idefloppy_pc_callback(ide_drive_t *drive)
 
 static void idefloppy_init_pc(struct ide_atapi_pc *pc)
 {
-   memset(pc->c, 0, 12);
pc->retries = 0;
pc->flags = 0;
pc->req_xfer = 0;
@@ -384,11 +376,25 @@ static void idefloppy_init_pc(struct ide_atapi_pc *pc)
pc->idefloppy_callback = &idefloppy_pc_callback;
 }
 
-static void idefloppy_create_request_sense_cmd(struct ide_atapi_pc *pc)
+void ide_floppy_init_rq(ide_drive_t *drive, struct request *rq)
+{
+   struct ide_floppy_obj *floppy = drive->driver_data;
+
+   ide_init_drive_cmd(rq);
+   rq->cmd_type = REQ_TYPE_ATA_PC;
+   rq->rq_disk = floppy->disk;
+}
+
+static void idefloppy_create_request_sense_cmd(ide_drive_t *drive,
+   struct ide_atapi_pc *pc)
 {
+   struct request *rq = pc->rq;
+
idefloppy_init_pc(pc);
-   pc->c[0] = GPCMD_REQUEST_SENSE;
-   pc->c[4] = 255;
+   ide_floppy_init_rq(drive, rq);
+
+   rq->cmd[0] = GPCMD_REQUEST_SENSE;
+   rq->cmd[4] = 255;
pc->req_xfer = 18;
pc->idefloppy_callback = &idefloppy_request_sense_callback;
 }
@@ -405,8 +411,8 @@ static void idefloppy_retry_pc(ide_drive_t *drive)
(void)ide_read_error(drive);
pc = idefloppy_next_pc_storage(drive);
rq = idefloppy_next_rq_storage(drive);
-   idefloppy_create_request_sense_cmd(pc);
-   idefloppy_queue_pc_head(drive, pc, rq);
+   idefloppy_create_request_sense_cmd(drive, pc);
+   idefloppy_queue_pc_head(drive, pc);
 }
 
 /* The usual interru

[PATCH] ide-floppy: rename end_request handler properly

2008-02-12 Thread Borislav Petkov
commit 48f9b88d491aa478ffcf21e2f523e3665db0770b
Author: Borislav Petkov <[EMAIL PROTECTED]>
Date:   Tue Feb 12 09:42:19 2008 +0100

ide-floppy: rename end_request handler properly

mv idefloppy_do_end_request -> idefloppy_end_request as is the case with 
ide-cd

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>

diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 7e62dfc..bf1ef60 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -213,7 +213,7 @@ static void ide_floppy_put(struct ide_floppy_obj *floppy)
  * 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)
+static int idefloppy_end_request(ide_drive_t *drive, int uptodate, int nsecs)
 {
idefloppy_floppy_t *floppy = drive->driver_data;
struct request *rq = HWGROUP(drive)->rq;
@@ -270,7 +270,7 @@ static void ide_floppy_io_buffers(ide_drive_t *drive, 
struct ide_atapi_pc *pc,
done += count;
}
 
-   idefloppy_do_end_request(drive, 1, done >> 9);
+   idefloppy_end_request(drive, 1, done >> 9);
 
if (bcount) {
printk(KERN_ERR "%s: leftover data in %s, bcount == %d\n",
@@ -289,7 +289,7 @@ static void idefloppy_update_buffers(ide_drive_t *drive,
struct bio *bio = rq->bio;
 
while ((bio = rq->bio) != NULL)
-   idefloppy_do_end_request(drive, 1, 0);
+   idefloppy_end_request(drive, 1, 0);
 }
 
 /*
@@ -355,11 +355,11 @@ static void idefloppy_request_sense_callback(ide_drive_t 
*drive)
floppy->ascq);
 
 
-   idefloppy_do_end_request(drive, 1, 0);
+   idefloppy_end_request(drive, 1, 0);
} else {
printk(KERN_ERR "Error in REQUEST SENSE itself - Aborting"
" request!\n");
-   idefloppy_do_end_request(drive, 0, 0);
+   idefloppy_end_request(drive, 0, 0);
}
 }
 
@@ -370,7 +370,7 @@ static void idefloppy_pc_callback(ide_drive_t *drive)
 
debug_log("Reached %s\n", __func__);
 
-   idefloppy_do_end_request(drive, floppy->pc->error ? 0 : 1, 0);
+   idefloppy_end_request(drive, floppy->pc->error ? 0 : 1, 0);
 }
 
 static void idefloppy_init_pc(struct ide_atapi_pc *pc)
@@ -715,7 +715,7 @@ static void idefloppy_rw_callback(ide_drive_t *drive)
 {
debug_log("Reached %s\n", __func__);
 
-   idefloppy_do_end_request(drive, 1, 0);
+   idefloppy_end_request(drive, 1, 0);
return;
 }
 
@@ -863,7 +863,7 @@ static ide_startstop_t idefloppy_do_request(ide_drive_t 
*drive,
else
printk(KERN_ERR "ide-floppy: %s: I/O error\n",
drive->name);
-   idefloppy_do_end_request(drive, 0, 0);
+   idefloppy_end_request(drive, 0, 0);
return ide_stopped;
}
if (blk_fs_request(rq)) {
@@ -871,7 +871,7 @@ static ide_startstop_t idefloppy_do_request(ide_drive_t 
*drive,
(rq->nr_sectors % floppy->bs_factor)) {
printk(KERN_ERR "%s: unsupported r/w request size\n",
drive->name);
-   idefloppy_do_end_request(drive, 0, 0);
+   idefloppy_end_request(drive, 0, 0);
return ide_stopped;
}
pc = idefloppy_next_pc_storage(drive);
@@ -884,7 +884,7 @@ static ide_startstop_t idefloppy_do_request(ide_drive_t 
*drive,
} else {
blk_dump_rq_flags(rq,
"ide-floppy: unsupported command in queue");
-   idefloppy_do_end_request(drive, 0, 0);
+   idefloppy_end_request(drive, 0, 0);
return ide_stopped;
}
 
@@ -1359,7 +1359,7 @@ static ide_driver_t idefloppy_driver = {
.media  = ide_floppy,
.supports_dsc_overlap   = 0,
.do_request = idefloppy_do_request,
-   .end_request= idefloppy_do_end_request,
+   .end_request= idefloppy_end_request,
.error  = __ide_error,
.abort  = __ide_abort,
 #ifdef CONFIG_IDE_PROC_FS
-- 
Regards/Gruß,
Boris.
-
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 0/4] ide: generic packet command representation

2008-02-11 Thread Borislav Petkov
On Tue, Feb 12, 2008 at 01:09:24AM +0100, Bartlomiej Zolnierkiewicz wrote:
> 
> On Monday 11 February 2008, Borislav Petkov wrote:
> > Hi Bart,
> > 
> > here's the ide_atapi_pc unification series. It all went pretty smoothly 
> > along
> > the search & replace line. Using driver-specific members in ide_atapi_pc 
> > like
> > idefloppy_callback and idetape_callback is kinda dumb but this approach 
> > seemed
> > the fastest versus unnecessary callback function signature change that will
> > touch stuff all over the place. Besides, ide-tape might be gone soon so that
> > would alleviate the problem.
> 
> applied all four patches, thanks!
> 
> > On a different note, i noticed ide-scsi might also need a cleanup similar 
> > to the
> > other drivers. It is next on my TODO list in case you don't have anything 
> > with a
> > higher prio.
> 
> I was actually hoping that you'll continue unifying ATAPI handling...

yeah, sure. ide-scsi simply will wander down the prio stack pushed by the other
stuff :)

> [ ide-scsi is orphaned and has (probably) unfixable problems (because of 
> having

does this mean it might have a similar to idetape's destiny...?

-- 
Regards/Gruß,
Boris.
-
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 3/4] ide-tape: convert driver to using generic ide_atapi_pc

2008-02-11 Thread Borislav Petkov
Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |  251 ++--
 1 files changed, 114 insertions(+), 137 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 09ff9b0..aefbb47 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -181,34 +181,6 @@ struct idetape_bh {
char *b_data;
 };
 
-typedef struct idetape_packet_command_s {
-   /* Actual packet bytes */
-   u8 c[12];
-   /* On each retry, we increment retries */
-   int retries;
-   /* Error code */
-   int error;
-   /* Bytes to transfer */
-   int request_transfer;
-   /* Bytes actually transferred */
-   int actually_transferred;
-   /* Size of our data buffer */
-   int buffer_size;
-   struct idetape_bh *bh;
-   char *b_data;
-   int b_count;
-   /* Data buffer */
-   u8 *buffer;
-   /* Pointer into the above buffer */
-   u8 *current_position;
-   /* Called when this packet command is completed */
-   ide_startstop_t (*callback) (ide_drive_t *);
-   /* Temporary buffer */
-   u8 pc_buffer[IDETAPE_PC_BUFFER_SIZE];
-   /* Status/Action bit flags: long for set_bit */
-   unsigned long flags;
-} idetape_pc_t;
-
 /* Packet command flag bits. */
 enum {
/* Set when an error is considered normal - We won't retry */
@@ -316,11 +288,11 @@ typedef struct ide_tape_obj {
 *  retry, to get detailed information on what went wrong.
 */
/* Current packet command */
-   idetape_pc_t *pc;
+   struct ide_atapi_pc *pc;
/* Last failed packet command */
-   idetape_pc_t *failed_pc;
+   struct ide_atapi_pc *failed_pc;
/* Packet command stack */
-   idetape_pc_t pc_stack[IDETAPE_PC_STACK];
+   struct ide_atapi_pc pc_stack[IDETAPE_PC_STACK];
/* Next free packet command storage space */
int pc_stack_index;
struct request rq_stack[IDETAPE_PC_STACK];
@@ -524,7 +496,7 @@ static struct ide_tape_obj *ide_tape_chrdev_get(unsigned 
int i)
return tape;
 }
 
-static void idetape_input_buffers(ide_drive_t *drive, idetape_pc_t *pc,
+static void idetape_input_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
  unsigned int bcount)
 {
struct idetape_bh *bh = pc->bh;
@@ -553,7 +525,7 @@ static void idetape_input_buffers(ide_drive_t *drive, 
idetape_pc_t *pc,
pc->bh = bh;
 }
 
-static void idetape_output_buffers(ide_drive_t *drive, idetape_pc_t *pc,
+static void idetape_output_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
   unsigned int bcount)
 {
struct idetape_bh *bh = pc->bh;
@@ -581,11 +553,11 @@ static void idetape_output_buffers(ide_drive_t *drive, 
idetape_pc_t *pc,
}
 }
 
-static void idetape_update_buffers(idetape_pc_t *pc)
+static void idetape_update_buffers(struct ide_atapi_pc *pc)
 {
struct idetape_bh *bh = pc->bh;
int count;
-   unsigned int bcount = pc->actually_transferred;
+   unsigned int bcount = pc->xferred;
 
if (pc->flags & PC_FLAG_WRITING)
return;
@@ -610,7 +582,7 @@ static void idetape_update_buffers(idetape_pc_t *pc)
  * driver. A storage space for a maximum of IDETAPE_PC_STACK packet
  * commands is allocated at initialization time.
  */
-static idetape_pc_t *idetape_next_pc_storage(ide_drive_t *drive)
+static struct ide_atapi_pc *idetape_next_pc_storage(ide_drive_t *drive)
 {
idetape_tape_t *tape = drive->driver_data;
 
@@ -645,14 +617,14 @@ static struct request 
*idetape_next_rq_storage(ide_drive_t *drive)
return (&tape->rq_stack[tape->rq_stack_index++]);
 }
 
-static void idetape_init_pc(idetape_pc_t *pc)
+static void idetape_init_pc(struct ide_atapi_pc *pc)
 {
memset(pc->c, 0, 12);
pc->retries = 0;
pc->flags = 0;
-   pc->request_transfer = 0;
-   pc->buffer = pc->pc_buffer;
-   pc->buffer_size = IDETAPE_PC_BUFFER_SIZE;
+   pc->req_xfer = 0;
+   pc->buf = pc->pc_buf;
+   pc->buf_size = IDETAPE_PC_BUFFER_SIZE;
pc->bh = NULL;
pc->b_data = NULL;
 }
@@ -664,7 +636,7 @@ static void idetape_init_pc(idetape_pc_t *pc)
 static void idetape_analyze_error(ide_drive_t *drive, u8 *sense)
 {
idetape_tape_t *tape = drive->driver_data;
-   idetape_pc_t *pc = tape->failed_pc;
+   struct ide_atapi_pc *pc = tape->failed_pc;
 
tape->sense_key = sense[2] & 0xF;
tape->asc   = sense[12];
@@ -673,9 +645,9 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 
*sense)
debug_log(DBG_ERR, "pc = %x, sense key = %x, asc = %x, ascq = %x\n",
 pc->c[0], tape->sense_key, tape->asc, tape->ascq);
 
-   /* Correct pc->actually_trans

[PATCH 4/4] ide-scsi: convert driver to using generic ide_atapi_pc

2008-02-11 Thread Borislav Petkov
Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/scsi/ide-scsi.c |  133 ++-
 1 files changed, 62 insertions(+), 71 deletions(-)

diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index 7fea769..5ec421c 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -60,23 +60,6 @@
 
 #define IDESCSI_DEBUG_LOG  0
 
-typedef struct idescsi_pc_s {
-   u8 c[12];   /* Actual packet bytes */
-   int request_transfer;   /* Bytes to transfer */
-   int actually_transferred;   /* Bytes actually transferred */
-   int buffer_size;/* Size of our data buffer */
-   struct request *rq; /* The corresponding request */
-   u8 *buffer; /* Data buffer */
-   u8 *current_position;   /* Pointer into the above 
buffer */
-   struct scatterlist *sg; /* Scatter gather table */
-   unsigned int sg_cnt;/* Number of entries in sg */
-   int b_count;/* Bytes transferred from 
current entry */
-   struct scsi_cmnd *scsi_cmd; /* SCSI command */
-   void (*done)(struct scsi_cmnd *);   /* Scsi completion routine */
-   unsigned long flags;/* Status/Action flags */
-   unsigned long timeout;  /* Command timeout */
-} idescsi_pc_t;
-
 /*
  * Packet command status bits.
  */
@@ -101,14 +84,15 @@ typedef struct ide_scsi_obj {
struct gendisk  *disk;
struct Scsi_Host*host;
 
-   idescsi_pc_t *pc;   /* Current packet command */
+   struct ide_atapi_pc *pc;/* Current packet command */
unsigned long flags;/* Status/Action flags */
unsigned long transform;/* SCSI cmd translation layer */
unsigned long log;  /* log flags */
 } idescsi_scsi_t;
 
 static DEFINE_MUTEX(idescsi_ref_mutex);
-static int idescsi_nocd;   /* Set by module param to skip 
cd */
+/* Set by module param to skip cd */
+static int idescsi_nocd;
 
 #define ide_scsi_g(disk) \
container_of((disk)->private_data, struct ide_scsi_obj, driver)
@@ -155,7 +139,8 @@ static inline idescsi_scsi_t *drive_to_idescsi(ide_drive_t 
*ide_drive)
 /*
  * PIO data transfer routines using the scatter gather table.
  */
-static void idescsi_input_buffers (ide_drive_t *drive, idescsi_pc_t *pc, 
unsigned int bcount)
+static void idescsi_input_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
+   unsigned int bcount)
 {
int count;
char *buf;
@@ -192,7 +177,8 @@ static void idescsi_input_buffers (ide_drive_t *drive, 
idescsi_pc_t *pc, unsigne
}
 }
 
-static void idescsi_output_buffers (ide_drive_t *drive, idescsi_pc_t *pc, 
unsigned int bcount)
+static void idescsi_output_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
+   unsigned int bcount)
 {
int count;
char *buf;
@@ -234,15 +220,16 @@ static void ide_scsi_hex_dump(u8 *data, int len)
print_hex_dump(KERN_CONT, "", DUMP_PREFIX_NONE, 16, 1, data, len, 0);
 }
 
-static int idescsi_check_condition(ide_drive_t *drive, struct request 
*failed_command)
+static int idescsi_check_condition(ide_drive_t *drive,
+   struct request *failed_cmd)
 {
idescsi_scsi_t *scsi = drive_to_idescsi(drive);
-   idescsi_pc_t   *pc;
+   struct ide_atapi_pc   *pc;
struct request *rq;
u8 *buf;
 
/* stuff a sense request in front of our current request */
-   pc = kzalloc(sizeof(idescsi_pc_t), GFP_ATOMIC);
+   pc = kzalloc(sizeof(struct ide_atapi_pc), GFP_ATOMIC);
rq = kmalloc(sizeof(struct request), GFP_ATOMIC);
buf = kzalloc(SCSI_SENSE_BUFFERSIZE, GFP_ATOMIC);
if (!pc || !rq || !buf) {
@@ -254,14 +241,14 @@ static int idescsi_check_condition(ide_drive_t *drive, 
struct request *failed_co
ide_init_drive_cmd(rq);
rq->special = (char *) pc;
pc->rq = rq;
-   pc->buffer = buf;
+   pc->buf = buf;
pc->c[0] = REQUEST_SENSE;
-   pc->c[4] = pc->request_transfer = pc->buffer_size = 
SCSI_SENSE_BUFFERSIZE;
+   pc->c[4] = pc->req_xfer = pc->buf_size = SCSI_SENSE_BUFFERSIZE;
rq->cmd_type = REQ_TYPE_SENSE;
pc->timeout = jiffies + WAIT_READY;
/* NOTE! Save the failed packet command in "rq->buffer" */
-   rq->buffer = (void *) failed_command->special;
-   pc->scsi_cmd = ((idescsi_pc_t *) failed_command->special)->scsi_cmd;
+   rq->buffer = (void *) failed_cmd->special;
+   pc->scsi_cmd = ((struct ide_atapi_pc *) failed_cmd->special)->scsi_cmd;

[PATCH 1/4] ide: add generic packet command representation ide_atapi_pc

2008-02-11 Thread Borislav Petkov
This new struct unifies ide{-floppy,-tape,-scsi}'s view of a packet command. 
For now,
it represents the common denominator between the three drivers while adding 
driver-
specific members at the end of the struct which will be merged/simplified into 
the
generic ATAPI handling code in later steps, or removed completely.

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 include/linux/ide.h |   47 +++
 1 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/include/linux/ide.h b/include/linux/ide.h
index e4eddd4..aae98d7 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -629,6 +629,53 @@ typedef struct ide_settings_s {
 
 int ide_add_setting(ide_drive_t *, const char *, int, int, int, int, int, int, 
void *, ide_procset_t *set);
 
+struct ide_atapi_pc {
+   /* actual packet bytes */
+   u8 c[12];
+   /* incremented on each retry */
+   int retries;
+   int error;
+
+   /* bytes to transfer */
+   int req_xfer;
+   /* bytes actually transferred */
+   int xferred;
+
+   /* data buffer */
+   u8 *buf;
+   /* current buffer position */
+   u8 *cur_pos;
+   int buf_size;
+   /* missing/available data on the current buffer */
+   int b_count;
+
+   /* the corresponding request */
+   struct request *rq;
+
+   unsigned long flags;
+
+   /*
+* those are more or less driver-specific and some of them are subject
+* to change/removal later.
+*/
+   u8 pc_buf[256];
+   void (*idefloppy_callback) (ide_drive_t *);
+   ide_startstop_t (*idetape_callback) (ide_drive_t *);
+
+   /* idetape only */
+   struct idetape_bh *bh;
+   char *b_data;
+
+   /* idescsi only for now */
+   struct scatterlist *sg;
+   unsigned int sg_cnt;
+
+   struct scsi_cmnd *scsi_cmd;
+   void (*done) (struct scsi_cmnd *);
+
+   unsigned long timeout;
+};
+
 /*
  * /proc/ide interface
  */
-- 
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


[PATCH 2/4] ide-floppy: convert driver to using generic ide_atapi_pc

2008-02-11 Thread Borislav Petkov
Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-floppy.c |  205 +-
 1 files changed, 93 insertions(+), 112 deletions(-)

diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 4ce67bd..7e62dfc 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -78,26 +78,6 @@
  */
 #define IDEFLOPPY_PC_STACK (10 + IDEFLOPPY_MAX_PC_RETRIES)
 
-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 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. */
 enum {
/* 1 when we prefer to use DMA if possible */
@@ -131,11 +111,11 @@ typedef struct ide_floppy_obj {
unsigned intopeners;/* protected by BKL for now */
 
/* Current packet command */
-   idefloppy_pc_t *pc;
+   struct ide_atapi_pc *pc;
/* Last failed packet command */
-   idefloppy_pc_t *failed_pc;
+   struct ide_atapi_pc *failed_pc;
/* Packet command stack */
-   idefloppy_pc_t pc_stack[IDEFLOPPY_PC_STACK];
+   struct ide_atapi_pc pc_stack[IDEFLOPPY_PC_STACK];
/* Next free packet command storage space */
int pc_stack_index;
struct request rq_stack[IDEFLOPPY_PC_STACK];
@@ -262,7 +242,7 @@ static int idefloppy_do_end_request(ide_drive_t *drive, int 
uptodate, int nsecs)
return 0;
 }
 
-static void ide_floppy_io_buffers(ide_drive_t *drive, idefloppy_pc_t *pc,
+static void ide_floppy_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
  unsigned int bcount, int direction)
 {
struct request *rq = pc->rq;
@@ -302,7 +282,8 @@ static void ide_floppy_io_buffers(ide_drive_t *drive, 
idefloppy_pc_t *pc,
}
 }
 
-static void idefloppy_update_buffers(ide_drive_t *drive, idefloppy_pc_t *pc)
+static void idefloppy_update_buffers(ide_drive_t *drive,
+   struct ide_atapi_pc *pc)
 {
struct request *rq = pc->rq;
struct bio *bio = rq->bio;
@@ -316,7 +297,7 @@ static void idefloppy_update_buffers(ide_drive_t *drive, 
idefloppy_pc_t *pc)
  * 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, struct ide_atapi_pc 
*pc,
struct request *rq)
 {
struct ide_floppy_obj *floppy = drive->driver_data;
@@ -328,7 +309,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 struct ide_atapi_pc *idefloppy_next_pc_storage(ide_drive_t *drive)
 {
idefloppy_floppy_t *floppy = drive->driver_data;
 
@@ -349,7 +330,7 @@ static struct request 
*idefloppy_next_rq_storage(ide_drive_t *drive)
 static void idefloppy_request_sense_callback(ide_drive_t *drive)
 {
idefloppy_floppy_t *floppy = drive->driver_data;
-   u8 *buf = floppy->pc->buffer;
+   u8 *buf = floppy->pc->buf;
 
debug_log("Reached %s\n", __func__);
 
@@ -392,24 +373,24 @@ static void idefloppy_pc_callback(ide_drive_t *drive)
idefloppy_do_end_request(drive, floppy->pc->error ? 0 : 1, 0);
 }
 
-static void idefloppy_init_pc(idefloppy_pc_t *pc)
+static void idefloppy_init_pc(struct ide_atapi_pc *pc)
 {
memset(pc->c, 0, 12);
pc->retries = 0;
pc->flags = 0;
-   pc->request_transfer = 0;
-   pc->buffer = pc->pc_buffer;
-   pc->buffer_size = IDEFLOPPY_PC_BUFFER_SIZE;
-   pc->callback = &idefloppy

[PATCH 0/4] ide: generic packet command representation

2008-02-11 Thread Borislav Petkov
Hi Bart,

here's the ide_atapi_pc unification series. It all went pretty smoothly along
the search & replace line. Using driver-specific members in ide_atapi_pc like
idefloppy_callback and idetape_callback is kinda dumb but this approach seemed
the fastest versus unnecessary callback function signature change that will
touch stuff all over the place. Besides, ide-tape might be gone soon so that
would alleviate the problem.

On a different note, i noticed ide-scsi might also need a cleanup similar to the
other drivers. It is next on my TODO list in case you don't have anything with a
higher prio.


 drivers/ide/ide-floppy.c |  205 +
 drivers/ide/ide-tape.c   |  251 +-
 drivers/scsi/ide-scsi.c  |  133 +++-
 include/linux/ide.h  |   47 +
 4 files changed, 316 insertions(+), 320 deletions(-)

-- 
Thanks,
Boris.
-
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 2/2] ide-tape: remove atomic test/set macros for packet commands

2008-02-09 Thread Borislav Petkov
>From 92dd5c1cfb27c0945894a3a055098290047d1ff0 Mon Sep 17 00:00:00 2001
From: Borislav Petkov <[EMAIL PROTECTED]>
Date: Sat, 9 Feb 2008 20:33:48 +0100
Subject: [PATCH 2/2] ide-tape: remove atomic test/set macros for packet commands

Removing the atomic tests for pc's is unobjectionable. Since this driver will
probably go to /dev/null soon, the atomic tests for tape->flags are left in
place for there are some situations where they're needed (chrdev DSC handling,
low level pipeline operation and so on). While at it, rename all test/set flag
bit defines explicitly to *_FLAG_* for clarity.

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |  208 +---
 1 files changed, 109 insertions(+), 99 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 1fff560..09ff9b0 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -209,44 +209,47 @@ typedef struct idetape_packet_command_s {
unsigned long flags;
 } idetape_pc_t;
 
-/*
- * Packet command flag bits.
- */
-/* Set when an error is considered normal - We won't retry */
-#definePC_ABORT0
-/* 1 When polling for DSC on a media access command */
-#define PC_WAIT_FOR_DSC1
-/* 1 when we prefer to use DMA if possible */
-#define PC_DMA_RECOMMENDED 2
-/* 1 while DMA in progress */
-#definePC_DMA_IN_PROGRESS  3
-/* 1 when encountered problem during DMA */
-#definePC_DMA_ERROR4
-/* Data direction */
-#definePC_WRITING  5
+/* Packet command flag bits. */
+enum {
+   /* Set when an error is considered normal - We won't retry */
+   PC_FLAG_ABORT   = (1 << 0),
+   /* 1 When polling for DSC on a media access command */
+   PC_FLAG_WAIT_FOR_DSC= (1 << 1),
+   /* 1 when we prefer to use DMA if possible */
+   PC_FLAG_DMA_RECOMMENDED = (1 << 2),
+   /* 1 while DMA in progress */
+   PC_FLAG_DMA_IN_PROGRESS = (1 << 3),
+   /* 1 when encountered problem during DMA */
+   PC_FLAG_DMA_ERROR   = (1 << 4),
+   /* Data direction */
+   PC_FLAG_WRITING = (1 << 5),
+};
 
 /* Tape door status */
 #define DOOR_UNLOCKED  0
 #define DOOR_LOCKED1
 #define DOOR_EXPLICITLY_LOCKED 2
 
-/*
- * Tape flag bits values.
- */
-#define IDETAPE_IGNORE_DSC 0
-/* 0 When the tape position is unknown */
-#define IDETAPE_ADDRESS_VALID  1
-#define IDETAPE_BUSY   2   /* Device already opened */
-/* Error detected in a pipeline stage */
-#define IDETAPE_PIPELINE_ERROR 3
-/* Attempt to auto-detect the current user block size */
-#define IDETAPE_DETECT_BS  4
-#define IDETAPE_FILEMARK   5   /* Currently on a filemark */
-#define IDETAPE_DRQ_INTERRUPT  6   /* DRQ interrupt device */
-#define IDETAPE_READ_ERROR 7
-#define IDETAPE_PIPELINE_ACTIVE8   /* pipeline active */
-/* 0 = no tape is loaded, so we don't rewind after ejecting */
-#define IDETAPE_MEDIUM_PRESENT 9
+/* Tape flag bits values. */
+enum {
+   IDETAPE_FLAG_IGNORE_DSC = (1 << 0),
+   /* 0 When the tape position is unknown */
+   IDETAPE_FLAG_ADDRESS_VALID  = (1 << 1),
+   /* Device already opened */
+   IDETAPE_FLAG_BUSY   = (1 << 2),
+   /* Error detected in a pipeline stage */
+   IDETAPE_FLAG_PIPELINE_ERR   = (1 << 3),
+   /* Attempt to auto-detect the current user block size */
+   IDETAPE_FLAG_DETECT_BS  = (1 << 4),
+   /* Currently on a filemark */
+   IDETAPE_FLAG_FILEMARK   = (1 << 5),
+   /* DRQ interrupt device */
+   IDETAPE_FLAG_DRQ_INTERRUPT  = (1 << 6),
+   /* pipeline active */
+   IDETAPE_FLAG_PIPELINE_ACTIVE= (1 << 7),
+   /* 0 = no tape is loaded, so we don't rewind after ejecting */
+   IDETAPE_FLAG_MEDIUM_PRESENT = (1 << 8),
+};
 
 /* Some defines for the SPACE command */
 #define IDETAPE_SPACE_OVER_FILEMARK1
@@ -584,7 +587,7 @@ static void idetape_update_buffers(idetape_pc_t *pc)
int count;
unsigned int bcount = pc->actually_transferred;
 
-   if (test_bit(PC_WRITING, &pc->flags))
+   if (pc->flags & PC_FLAG_WRITING)
return;
while (bcount) {
if (bh == NULL) {
@@ -671,7 +674,7 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 
*sense)
 pc->c[0], tape->sense_key, tape->asc, tape->ascq);
 
/* Correct pc->actually_transferred by asking the tape.  */
-   if (test_bit(PC_DMA_ERROR, &pc->flags)) {
+   if

[PATCH 1/2] ide-tape: move all struct and other defs at the top

2008-02-09 Thread Borislav Petkov
Hi Bart,

thanks for the update earlier. I'll look into blk_{get,put}_request later and
try it on idefloppy. In the meantime, here are the patches as requested:

---
>From 0d91862fc802d6f5aa79947b2685de6c209236f2 Mon Sep 17 00:00:00 2001
From: Borislav Petkov <[EMAIL PROTECTED]>
Date: Sat, 9 Feb 2008 19:48:13 +0100
Subject: [PATCH 1/2] ide-tape: move all struct and other defs at the top

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |  107 ---
 1 files changed, 55 insertions(+), 52 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index b3269d7..1fff560 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -225,6 +225,61 @@ typedef struct idetape_packet_command_s {
 /* Data direction */
 #definePC_WRITING  5
 
+/* Tape door status */
+#define DOOR_UNLOCKED  0
+#define DOOR_LOCKED1
+#define DOOR_EXPLICITLY_LOCKED 2
+
+/*
+ * Tape flag bits values.
+ */
+#define IDETAPE_IGNORE_DSC 0
+/* 0 When the tape position is unknown */
+#define IDETAPE_ADDRESS_VALID  1
+#define IDETAPE_BUSY   2   /* Device already opened */
+/* Error detected in a pipeline stage */
+#define IDETAPE_PIPELINE_ERROR 3
+/* Attempt to auto-detect the current user block size */
+#define IDETAPE_DETECT_BS  4
+#define IDETAPE_FILEMARK   5   /* Currently on a filemark */
+#define IDETAPE_DRQ_INTERRUPT  6   /* DRQ interrupt device */
+#define IDETAPE_READ_ERROR 7
+#define IDETAPE_PIPELINE_ACTIVE8   /* pipeline active */
+/* 0 = no tape is loaded, so we don't rewind after ejecting */
+#define IDETAPE_MEDIUM_PRESENT 9
+
+/* Some defines for the SPACE command */
+#define IDETAPE_SPACE_OVER_FILEMARK1
+#define IDETAPE_SPACE_TO_EOD   3
+
+/* Some defines for the LOAD UNLOAD command */
+#define IDETAPE_LU_LOAD_MASK   1
+#define IDETAPE_LU_RETENSION_MASK  2
+#define IDETAPE_LU_EOT_MASK4
+
+/*
+ * Special requests for our block device strategy routine.
+ *
+ * In order to service a character device command, we add special requests to
+ * the tail of our block device request queue and wait for their completion.
+ */
+
+enum {
+   REQ_IDETAPE_PC1 = (1 << 0), /* packet command (first stage) */
+   REQ_IDETAPE_PC2 = (1 << 1), /* packet command (second stage) */
+   REQ_IDETAPE_READ= (1 << 2),
+   REQ_IDETAPE_WRITE   = (1 << 3),
+};
+
+/* Error codes returned in rq->errors to the higher part of the driver. */
+#defineIDETAPE_ERROR_GENERAL   101
+#defineIDETAPE_ERROR_FILEMARK  102
+#defineIDETAPE_ERROR_EOD   103
+
+/* Structures related to the SELECT SENSE / MODE SENSE packet commands. */
+#define IDETAPE_BLOCK_DESCRIPTOR   0
+#defineIDETAPE_CAPABILITIES_PAGE   0x2a
+
 /* A pipeline stage. */
 typedef struct idetape_stage_s {
struct request rq;  /* The corresponding request */
@@ -446,58 +501,6 @@ static void ide_tape_put(struct ide_tape_obj *tape)
mutex_unlock(&idetape_ref_mutex);
 }
 
-/* Tape door status */
-#define DOOR_UNLOCKED  0
-#define DOOR_LOCKED1
-#define DOOR_EXPLICITLY_LOCKED 2
-
-/*
- * Tape flag bits values.
- */
-#define IDETAPE_IGNORE_DSC 0
-#define IDETAPE_ADDRESS_VALID  1   /* 0 When the tape position is 
unknown */
-#define IDETAPE_BUSY   2   /* Device already opened */
-#define IDETAPE_PIPELINE_ERROR 3   /* Error detected in a pipeline 
stage */
-#define IDETAPE_DETECT_BS  4   /* Attempt to auto-detect the 
current user block size */
-#define IDETAPE_FILEMARK   5   /* Currently on a filemark */
-#define IDETAPE_DRQ_INTERRUPT  6   /* DRQ interrupt device */
-#define IDETAPE_READ_ERROR 7
-#define IDETAPE_PIPELINE_ACTIVE8   /* pipeline active */
-/* 0 = no tape is loaded, so we don't rewind after ejecting */
-#define IDETAPE_MEDIUM_PRESENT 9
-
-/* Some defines for the SPACE command */
-#define IDETAPE_SPACE_OVER_FILEMARK1
-#define IDETAPE_SPACE_TO_EOD   3
-
-/* Some defines for the LOAD UNLOAD command */
-#define IDETAPE_LU_LOAD_MASK   1
-#define IDETAPE_LU_RETENSION_MASK  2
-#define IDETAPE_LU_EOT_MASK4
-
-/*
- * Special requests for our block device strategy routine.
- *
- * In order to service a character device command, we add special requests to
- * the tail of our block device request queue and wait for their completion.
- */
-
-enum {
-   REQ_IDETAPE_PC1 = (1 << 0), /* packet command (first stage) */
-   REQ_IDETAPE_PC2 = (1 

[PATCH] ide-floppy: remove struct idefloppy_id_gcw

2008-02-09 Thread Borislav Petkov
commit a6aaf3dd3e88d1bd1e85fb4329042ecb9247e0eb
Author: Borislav Petkov <[EMAIL PROTECTED]>
Date:   Fri Feb 8 18:21:47 2008 +0100

ide-floppy: remove struct idefloppy_id_gcw

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>

diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index faf22d7..5d5bde8 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -195,32 +195,6 @@ enum {
 #defineIDEFLOPPY_ERROR_GENERAL 101
 
 /*
- * The following is used to format the general configuration word of the
- * ATAPI IDENTIFY DEVICE command.
- */
-struct idefloppy_id_gcw {
-#if defined(__LITTLE_ENDIAN_BITFIELD)
-   unsigned packet_size:2; /* Packet Size */
-   unsigned reserved234:3; /* Reserved */
-   unsigned drq_type   :2; /* Command packet DRQ type */
-   unsigned removable  :1; /* Removable media */
-   unsigned device_type:5; /* Device type */
-   unsigned reserved13 :1; /* Reserved */
-   unsigned protocol   :2; /* Protocol type */
-#elif defined(__BIG_ENDIAN_BITFIELD)
-   unsigned protocol   :2; /* Protocol type */
-   unsigned reserved13 :1; /* Reserved */
-   unsigned device_type:5; /* Device type */
-   unsigned removable  :1; /* Removable media */
-   unsigned drq_type   :2; /* Command packet DRQ type */
-   unsigned reserved234:3; /* Reserved */
-   unsigned packet_size:2; /* Packet Size */
-#else
-#error "Bitfield endianness not defined! Check your byteorder.h"
-#endif
-};
-
-/*
  * Pages of the SELECT SENSE / MODE SENSE packet commands.
  * See SFF-8070i spec.
  */
@@ -1271,32 +1245,40 @@ static sector_t idefloppy_capacity(ide_drive_t *drive)
  */
 static int idefloppy_identify_device(ide_drive_t *drive, struct hd_driveid *id)
 {
-   struct idefloppy_id_gcw gcw;
+   u8 gcw[2];
+   u8 device_type, protocol, removable, drq_type, packet_size;
 
*((u16 *) &gcw) = id->config;
 
+   device_type =  gcw[1] & 0x1F;
+   removable   = (gcw[0] & 0x80) >> 7;
+   protocol= (gcw[1] & 0xC0) >> 6;
+   drq_type= (gcw[0] & 0x60) >> 5;
+   packet_size =  gcw[0] & 0x03;
+
 #ifdef CONFIG_PPC
/* kludge for Apple PowerBook internal zip */
-   if ((gcw.device_type == 5) &&
-   !strstr(id->model, "CD-ROM") &&
-   strstr(id->model, "ZIP"))
-   gcw.device_type = 0;
+   if ((device_type == 5) &&
+   trstr(id->model, "CD-ROM") &&
+   strstr(id->model, "ZIP"))
+   device_type = 0;
 #endif
 
-   if (gcw.protocol != 2)
+   if (protocol != 2)
printk(KERN_ERR "ide-floppy: Protocol (0x%02x) is not ATAPI\n",
-   gcw.protocol);
-   else if (gcw.device_type != 0)
+   protocol);
+   else if (device_type != 0)
printk(KERN_ERR "ide-floppy: Device type (0x%02x) is not set "
-   "to floppy\n", gcw.device_type);
-   else if (!gcw.removable)
-   printk(KERN_ERR "ide-floppy: The removable flag is not set\n");
-   else if (gcw.drq_type == 3) {
+   "to floppy\n", device_type);
+   else if (!removable)
+   printk(KERN_ERR "ide-floppy: The removable flag (0x%02x) is not"
+   " set\n", removable);
+   else if (drq_type == 3) {
printk(KERN_ERR "ide-floppy: Sorry, DRQ type (0x%02x) not "
-   "supported\n", gcw.drq_type);
-   } else if (gcw.packet_size != 0) {
+   "supported\n", drq_type);
+   } else if (packet_size != 0) {
printk(KERN_ERR "ide-floppy: Packet size (0x%02x) is not 12 "
-   "bytes long\n", gcw.packet_size);
+   "bytes\n", packet_size);
} else
return 1;
return 0;
@@ -1322,11 +1304,12 @@ static inline void idefloppy_add_settings(ide_drive_t 
*drive) { ; }
 
 static void idefloppy_setup(ide_drive_t *drive, idefloppy_floppy_t *floppy)
 {
-   struct idefloppy_id_gcw gcw;
+   u8 gcw[2];
 
*((u16 *) &gcw) = drive->id->config;
floppy->pc = floppy->pc_stack;
-   if (gcw.drq_type == 1)
+
+   if (((gcw[0] & 0x60) >> 5) == 1)
floppy->flags |= IDEFLOPPY_FLAG_DRQ_INTERRUPT;
/*
 * We used to check revisions here. At this point however I'm giving up.

-- 
Regards/Gruß,
Boris.
-
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] ide-cd: replace ntohs with generic byteorder macro be16_to_cpu

2008-02-07 Thread Borislav Petkov
commit d41c6bc739e7ea7880f7f5983a9694f2e0214d92
Author: Borislav Petkov <[EMAIL PROTECTED]>
Date:   Fri Feb 8 07:25:44 2008 +0100

ide-cd: replace ntohs with generic byteorder macro be16_to_cpu

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>

diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 5e42c19..354c91d 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1555,7 +1555,7 @@ int ide_cd_read_toc(ide_drive_t *drive, struct 
request_sense *sense)
if (stat)
return stat;
 
-   toc->hdr.toc_length = ntohs (toc->hdr.toc_length);
+   toc->hdr.toc_length = be16_to_cpu(toc->hdr.toc_length);
 
if (info->cd_flags & IDE_CD_FLAG_TOCTRACKS_AS_BCD) {
toc->hdr.first_track = BCD2BIN(toc->hdr.first_track);
-- 
Regards/Gruß,
Boris.
-
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: ide-tape redux (was: Re:)

2008-02-05 Thread Borislav Petkov
... and while we're at it ...

commit c824f79fe4040f7541d7e35c546bb57a22d2fe11
Author: Borislav Petkov <[EMAIL PROTECTED]>
Date:   Wed Feb 6 06:23:10 2008 +0100

ide-tape: move all struct and other defs to the top

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 9455ce4..398aea8 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -225,6 +225,69 @@ enum {
PC_FL_WRITING   = (1 << 5),
 };
 
+/* Tape door status */
+#define DOOR_UNLOCKED  0
+#define DOOR_LOCKED1
+#define DOOR_EXPLICITLY_LOCKED 2
+
+/* Tape flag bits values. */
+enum {
+   IDETAPE_FL_IGNORE_DSC   = (1 << 0),
+   /* 0 When the tape position is unknown */
+   IDETAPE_FL_ADDRESS_VALID= (1 << 1),
+   /* Device already opened */
+   IDETAPE_FL_BUSY = (1 << 2),
+   /* Error detected in a pipeline stage */
+   IDETAPE_FL_PIPELINE_ERR = (1 << 3),
+   /* Attempt to auto-detect the current user block size */
+   IDETAPE_FL_DETECT_BS= (1 << 4),
+   /* Currently on a filemark */
+   IDETAPE_FL_FILEMARK = (1 << 5),
+   /* DRQ interrupt device */
+   IDETAPE_FL_DRQ_INTERRUPT= (1 << 6),
+   /* pipeline active */
+   IDETAPE_FL_PIPELINE_ACTIVE  = (1 << 7),
+   /* 0 = no tape is loaded, so we don't rewind after ejecting */
+   IDETAPE_FL_MEDIUM_PRESENT   = (1 << 8),
+};
+
+/* A define for the READ BUFFER command */
+#define IDETAPE_RETRIEVE_FAULTY_BLOCK  6
+
+/* Some defines for the SPACE command */
+#define IDETAPE_SPACE_OVER_FILEMARK1
+#define IDETAPE_SPACE_TO_EOD   3
+
+/* Some defines for the LOAD UNLOAD command */
+#define IDETAPE_LU_LOAD_MASK   1
+#define IDETAPE_LU_RETENSION_MASK  2
+#define IDETAPE_LU_EOT_MASK4
+
+/*
+ * Special requests for our block device strategy routine.
+ *
+ * In order to service a character device command, we add special requests to
+ * the tail of our block device request queue and wait for their completion.
+ */
+
+enum {
+   REQ_IDETAPE_PC1 = (1 << 0), /* packet command (first stage) */
+   REQ_IDETAPE_PC2 = (1 << 1), /* packet command (second stage) */
+   REQ_IDETAPE_READ= (1 << 2),
+   REQ_IDETAPE_WRITE   = (1 << 3),
+   REQ_IDETAPE_READ_BUFFER = (1 << 4),
+};
+
+/* Error codes returned in rq->errors to the higher part of the driver. */
+#defineIDETAPE_ERROR_GENERAL   101
+#defineIDETAPE_ERROR_FILEMARK  102
+#defineIDETAPE_ERROR_EOD   103
+
+/* Structures related to the SELECT SENSE / MODE SENSE packet commands. */
+#define IDETAPE_BLOCK_DESCRIPTOR   0
+#defineIDETAPE_CAPABILITIES_PAGE   0x2a
+
+
 /* A pipeline stage. */
 typedef struct idetape_stage_s {
struct request rq;  /* The corresponding request */
@@ -445,68 +508,6 @@ static void ide_tape_put(struct ide_tape_obj *tape)
mutex_unlock(&idetape_ref_mutex);
 }
 
-/* Tape door status */
-#define DOOR_UNLOCKED  0
-#define DOOR_LOCKED1
-#define DOOR_EXPLICITLY_LOCKED 2
-
-/* Tape flag bits values. */
-enum {
-   IDETAPE_FL_IGNORE_DSC   = (1 << 0),
-   /* 0 When the tape position is unknown */
-   IDETAPE_FL_ADDRESS_VALID= (1 << 1),
-   /* Device already opened */
-   IDETAPE_FL_BUSY = (1 << 2),
-   /* Error detected in a pipeline stage */
-   IDETAPE_FL_PIPELINE_ERR = (1 << 3),
-   /* Attempt to auto-detect the current user block size */
-   IDETAPE_FL_DETECT_BS= (1 << 4),
-   /* Currently on a filemark */
-   IDETAPE_FL_FILEMARK = (1 << 5),
-   /* DRQ interrupt device */
-   IDETAPE_FL_DRQ_INTERRUPT= (1 << 6),
-   /* pipeline active */
-   IDETAPE_FL_PIPELINE_ACTIVE  = (1 << 7),
-   /* 0 = no tape is loaded, so we don't rewind after ejecting */
-   IDETAPE_FL_MEDIUM_PRESENT   = (1 << 8),
-};
-
-/* A define for the READ BUFFER command */
-#define IDETAPE_RETRIEVE_FAULTY_BLOCK  6
-
-/* Some defines for the SPACE command */
-#define IDETAPE_SPACE_OVER_FILEMARK1
-#define IDETAPE_SPACE_TO_EOD   3
-
-/* Some defines for the LOAD UNLOAD command */
-#define IDETAPE_LU_LOAD_MASK   1
-#define IDETAPE_LU_RETENSION_MASK  2
-#define IDETAPE_LU_EOT_MASK4
-
-/*
- * Special requests for our block device strategy routine.
- *
- * In order to service a character device command, we add special requests to
- * the tail of our block device request queue and wait for their completion.
- */
-
-enum {
-   REQ_IDETAPE_PC

Re: ide-tape redux (was: Re:)

2008-02-05 Thread Borislav Petkov
On Tue, Feb 05, 2008 at 02:20:22AM +0100, Bartlomiej Zolnierkiewicz wrote:

[...]

> w.r.t. #11 ide-tape uses char devices and supports DSC so it is not as obvious
> as in ide-floppy case that all atomic bitops can be just removed (extra audit
> and some time -mm are required) so please resync/resubmit

Ok, here's what i think we should do here: There are two flags that handle DSC:
PC_FL_WAIT_FOR_DSC and IDETAPE_FL_IGNORE_DSC. The first one is per pc and is 
set in
all the packet command init functions ..create_bla_cmd() after their callers 
have
created a pc on the stack and reached its ptr down for initialization. This case
is carefree since the bit will be tested first in the interrupt handler and this
happens only after the pc is queued (ide_do_drive_cmd()) into the request 
buffer.

The other flag, IDETAPE_FL_IGNORE_DSC, is polled for in the request handler and
can be set when a pc is being retried and we should leave only those atomic
tests intact, imho, but i'm definitely gonna need a second opinion here.

---

commit 1ed8ae92249d5dff7af4ee88710ea08ff3f3356f
Author: Borislav Petkov <[EMAIL PROTECTED]>
Date:   Tue Feb 5 08:05:35 2008 +0100

ide-tape: remove atomic test/set macros

Also, since the driver supports DSC, leave the atomic tests
for the IDETAPE_FL_IGNORE_DSC bit untouched because this is polled
for in the request handler and can be set in the interrupt
handler through idetape_retry_pc() after enabling interrupts.

Finally, remove flag IDETAPE_READ_ERROR since it is unused.

    Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index e59e49e..9455ce4 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -206,24 +206,24 @@ typedef struct idetape_packet_command_s {
/* Temporary buffer */
u8 pc_buffer[IDETAPE_PC_BUFFER_SIZE];
/* Status/Action bit flags: long for set_bit */
-   unsigned long flags;
+   unsigned int flags;
 } idetape_pc_t;
 
-/*
- * Packet command flag bits.
- */
-/* Set when an error is considered normal - We won't retry */
-#definePC_ABORT0
-/* 1 When polling for DSC on a media access command */
-#define PC_WAIT_FOR_DSC1
-/* 1 when we prefer to use DMA if possible */
-#define PC_DMA_RECOMMENDED 2
-/* 1 while DMA in progress */
-#definePC_DMA_IN_PROGRESS  3
-/* 1 when encountered problem during DMA */
-#definePC_DMA_ERROR4
-/* Data direction */
-#definePC_WRITING  5
+/* Packet command flag bits. */
+enum {
+   /* Set when an error is considered normal - We won't retry */
+   PC_FL_ABORT = (1 << 0),
+   /* 1 When polling for DSC on a media access command */
+   PC_FL_WAIT_FOR_DSC  = (1 << 1),
+   /* 1 when we prefer to use DMA if possible */
+   PC_FL_DMA_RECOMMENDED   = (1 << 2),
+   /* 1 while DMA in progress */
+   PC_FL_DMA_IN_PROGRESS   = (1 << 3),
+   /* 1 when encountered problem during DMA */
+   PC_FL_DMA_ERROR = (1 << 4),
+   /* Data direction */
+   PC_FL_WRITING   = (1 << 5),
+};
 
 /* A pipeline stage. */
 typedef struct idetape_stage_s {
@@ -357,8 +357,7 @@ typedef struct ide_tape_obj {
/* Wasted space in each stage */
int excess_bh_size;
 
-   /* Status/Action flags: long for set_bit */
-   unsigned long flags;
+   unsigned int flags;
/* protects the ide-tape queue */
spinlock_t lock;
 
@@ -451,20 +450,26 @@ static void ide_tape_put(struct ide_tape_obj *tape)
 #define DOOR_LOCKED1
 #define DOOR_EXPLICITLY_LOCKED 2
 
-/*
- * Tape flag bits values.
- */
-#define IDETAPE_IGNORE_DSC 0
-#define IDETAPE_ADDRESS_VALID  1   /* 0 When the tape position is 
unknown */
-#define IDETAPE_BUSY   2   /* Device already opened */
-#define IDETAPE_PIPELINE_ERROR 3   /* Error detected in a pipeline 
stage */
-#define IDETAPE_DETECT_BS  4   /* Attempt to auto-detect the 
current user block size */
-#define IDETAPE_FILEMARK   5   /* Currently on a filemark */
-#define IDETAPE_DRQ_INTERRUPT  6   /* DRQ interrupt device */
-#define IDETAPE_READ_ERROR 7
-#define IDETAPE_PIPELINE_ACTIVE8   /* pipeline active */
-/* 0 = no tape is loaded, so we don't rewind after ejecting */
-#define IDETAPE_MEDIUM_PRESENT 9
+/* Tape flag bits values. */
+enum {
+   IDETAPE_FL_IGNORE_DSC   = (1 << 0),
+   /* 0 When the tape position is unknown */
+   IDETAPE_FL_ADDRESS_VALID= (1 << 1),
+   /* Device already opened */
+   IDETAPE_FL_BUSY = (1 << 2),
+   /* Error detected in a

Re: [PATCH] ide: another possible ide panic fix for blk-end-request

2008-02-04 Thread Borislav Petkov
On Mon, Feb 04, 2008 at 02:53:12PM -0500, Kiyoshi Ueda wrote:
> Hi Jens, Bart, Boris,
> 
> I have reviewed all blk-end-request patches again to confirm whether
> there are any similar problems with the last week's ide-cd panic:
> http://lkml.org/lkml/2008/1/29/140
> 
> And I found a possible similar bug in ide-io change:
> ide_end_drive_cmd() could be called for blk_pc_request() which could
> have bios.

You mean ide_abort() and ide_error(), right? Because ide{-tape,-floppy,-scsi}
do call already ide_end_request() for non-special rq's
(!blk_special_request()), except ide-scsi filters also on !blk_sense_request().

> To complete such requests correctly, we need to pass
> the actual size of the request.
> Otherwise, __blk_end_request() returns 1 because the request still has
> bios, and the system will BUG() unnecessarily.
> 
> The following patch fixes the bug and should be applied on top of
> Linus' git.
> Please review and apply.
> 
> 
> Cc: Bartlomiej Zolnierkiewicz <[EMAIL PROTECTED]>
> Cc: Borislav Petkov <[EMAIL PROTECTED]>
> Signed-off-by: Kiyoshi Ueda <[EMAIL PROTECTED]>
> Signed-off-by: Jun'ichi Nomura <[EMAIL PROTECTED]>
> ---
>  drivers/ide/ide-io.c |3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> --- a/drivers/ide/ide-io.c2008-02-01 18:20:02.0 -0500
> +++ b/drivers/ide/ide-io.c2008-02-01 18:21:50.0 -0500
> @@ -388,7 +388,8 @@ void ide_end_drive_cmd (ide_drive_t *dri
>   spin_lock_irqsave(&ide_lock, flags);
>   HWGROUP(drive)->rq = NULL;
>   rq->errors = err;
> - if (__blk_end_request(rq, (rq->errors ? -EIO : 0), 0))
> + if (unlikely(__blk_end_request(rq, (rq->errors ? -EIO : 0),
> +blk_rq_bytes(rq
>   BUG();
>   spin_unlock_irqrestore(&ide_lock, flags);
>  }
> 
> Thanks,
> Kiyoshi Ueda

-- 
Regards/Gruß,
Boris.
-
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 07/22] ide-tape: struct idetape_tape_t: shorten member names v2

2008-02-04 Thread Borislav Petkov
On Tue, Feb 05, 2008 at 02:23:21AM +0100, Bartlomiej Zolnierkiewicz wrote:
> On Monday 04 February 2008, Borislav Petkov wrote:
> > Shorten some member names not too aggressively since this driver might be 
> > gone
> > anyway soon.
> > 
> > Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
> > ---
> >  drivers/ide/ide-tape.c |  210 
> > ++--
> >  1 files changed, 113 insertions(+), 97 deletions(-)
> > 
> > diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
> > index 126e8a9..0b5ccce 100644
> > --- a/drivers/ide/ide-tape.c
> > +++ b/drivers/ide/ide-tape.c
> 
> [...]
> 
> > @@ -1583,7 +1579,8 @@ static void idetape_create_read_cmd(idetape_tape_t 
> > *tape, idetape_pc_t *pc, unsi
> > pc->bh = bh;
> > atomic_set(&bh->b_count, 0);
> > pc->buffer = NULL;
> > -   pc->request_transfer = pc->buffer_size = length * tape->tape_block_size;
> > +   pc->buffer_size = length * tape->blk_size;
> > +   pc->request_transfer= length * tape->blk_size;
> > if (pc->request_transfer == tape->stage_size)
> > set_bit(PC_DMA_RECOMMENDED, &pc->flags);
> >  }
> > @@ -1621,7 +1618,8 @@ static void idetape_create_write_cmd(idetape_tape_t 
> > *tape, idetape_pc_t *pc, uns
> > pc->b_data = bh->b_data;
> > pc->b_count = atomic_read(&bh->b_count);
> > pc->buffer = NULL;
> > -   pc->request_transfer = pc->buffer_size = length * tape->tape_block_size;
> > +   pc->request_transfer= length * tape->blk_size;
> > +   pc->buffer_size = length * tape->blk_size;
> > if (pc->request_transfer == tape->stage_size)
> > set_bit(PC_DMA_RECOMMENDED, &pc->flags);
> >  }
> 
> for some reason gcc doesn't seem to optimize the new code as well as
> the old one (=> driver size goes up instead of staying unchanged)
> 
> interdiff between original patch and merged version:
> 
> diff -u b/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
> --- b/drivers/ide/ide-tape.c
> +++ b/drivers/ide/ide-tape.c
> @@ -324,7 +324,7 @@
>   /* Current character device data transfer direction */
>   u8 chrdev_dir;
>  
> - /* tape block size, usu. 512 or 1024 bytes */
> + /* tape block size, usually 512 or 1024 bytes */
>   unsigned short blk_size;
>   int user_bs_factor;
>  
> @@ -1580,8 +1580,8 @@
>   pc->bh = bh;
>   atomic_set(&bh->b_count, 0);
>   pc->buffer = NULL;
> - pc->buffer_size = length * tape->blk_size;
> - pc->request_transfer= length * tape->blk_size;
> + pc->buffer_size = length * tape->blk_size;
> + pc->request_transfer = pc->buffer_size;
>   if (pc->request_transfer == tape->stage_size)
>   set_bit(PC_DMA_RECOMMENDED, &pc->flags);
>  }
> @@ -1619,8 +1619,8 @@
>   pc->b_data = bh->b_data;
>   pc->b_count = atomic_read(&bh->b_count);
>   pc->buffer = NULL;
> - pc->request_transfer= length * tape->blk_size;
> - pc->buffer_size = length * tape->blk_size;
> + pc->buffer_size = length * tape->blk_size;
> + pc->request_transfer = pc->buffer_size;
>   if (pc->request_transfer == tape->stage_size)
>   set_bit(PC_DMA_RECOMMENDED, &pc->flags);
>  }

Yeah, i did that only because checkpatch.pl complained that multiple assignments
should be avoided. Now it looks kinda dumb that way besides improving 
readability
so converting it to the best form w.r.t generating smaller binary would be a 
reason
good enough to ignore checkpatch.pl in that case.

-- 
Regards/Gruß,
Boris.
-
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: (fwd) Bug#11922: I/O error on blank tapes

2008-02-04 Thread Borislav Petkov
On Mon, Feb 04, 2008 at 03:22:06PM +0100, maximilian attems wrote:

(Added Bart to CC)

> hello borislav,
> 
> may i forward you that *old* Debian kernel bug,
> have seen you working on ide-tape:
> http://bugs.debian.org/11922
> no we don't carry any ide patches anymore.
> 
> maybe you've already fixed it in latest?
> 
> thanks
> 
> -- 
> maks
> 
> - Forwarded message from Stephen Kitt <[EMAIL PROTECTED]> -
> 
> Subject: Bug#11922: I/O error on blank tapes
> Date: Sat, 1 Dec 2007 19:06:18 +0100
> From: Stephen Kitt <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> 
> Hi,
> 
> This does still occur with 2.6.22; with a blank tape in my HP DDS-4 drive:
> 
> $ tar tzvf /dev/nst0
> tar: /dev/nst0: Cannot read: Input/output error
> tar: At beginning of tape, quitting now
> tar: Error is not recoverable: exiting now
> 
> gzip: stdin: unexpected end of file
> tar: Child returned status 2
> tar: Error exit delayed from previous errors
> 
> Nothing gets logged anywhere, which fits the original bug description.
> 
> This is a well-known issue: see for example
> http://www.sibbald.com/bacula/html-manual/Bacula_Console.html (search for
> "blank tape").
> 
> Regards,
> 
> Stephen
> 
> 
> 
> -- 
> To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
> 
> 
> - End forwarded message -

Hi Maks,

we're currently in the process of aggressively cleaning up ide-tape. However,
this brings (almost) no functional changes to the driver and we haven't looked
at any bugs that might exist. Actually, I wanted to probe the community to see
whether anyone is using ide-tape at all, and if not, to remove it completely.

Since i don't have the hardware, i'm gonna have to ask you (or Stephen) to wait
until all changes have entered mainline and then to try to reproduce the bug 
again
after having enabled debugging (IDETAPE_DEBUG_LOG) and send me the syslog
output.

Thanks.

-- 
Regards/Gruß,
Boris.
-
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


[no subject]

2008-02-04 Thread Borislav Petkov
Hi Bart,

here are the pending ide-tape patches reworked which incorporate all review
points raised so far. Several new patches are appended to the original series
which i thought would be reasonable to sumbit along with the others. Also,
i've applied "ide-tape: dump gcw fields on error in idetape_identify_device()"
which is #12 and which you can simply ignore. Furthermore, #32 from the original
series got split up into the different logical changes it dealt with, as you
requested.


 Documentation/feature-removal-schedule.txt |   14 +-
 drivers/ide/ide-tape.c | 2764 +---
 2 files changed, 1325 insertions(+), 1453 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


[PATCH 10/22] ide-tape: shorten some function names

2008-02-04 Thread Borislav Petkov
Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |   32 +++-
 1 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index ae2c76d..4fee160 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -1053,7 +1053,7 @@ static void idetape_postpone_request (ide_drive_t *drive)
  * command. We will transfer some of the data (as requested by the drive) and
  * will re-point interrupt handler to us. When data transfer is finished, we
  * will act according to the algorithm described before
- * idetape_issue_packet_command.
+ * idetape_issue_pc.
  */
 
 typedef void idetape_io_buf(ide_drive_t *, idetape_pc_t *, unsigned int);
@@ -1233,7 +1233,7 @@ static ide_startstop_t idetape_pc_intr(ide_drive_t *drive)
  *
  * The handling will be done in three stages:
  *
- * 1.  idetape_issue_packet_command will send the packet command to the
+ * 1.  idetape_issue_pc will send the packet command to the
  * drive, and will set the interrupt handler to idetape_pc_intr.
  *
  * 2.  On each interrupt, idetape_pc_intr will be called. This step
@@ -1308,7 +1308,7 @@ static ide_startstop_t idetape_transfer_pc(ide_drive_t 
*drive)
return ide_started;
 }
 
-static ide_startstop_t idetape_issue_packet_command (ide_drive_t *drive, 
idetape_pc_t *pc)
+static ide_startstop_t idetape_issue_pc(ide_drive_t *drive, idetape_pc_t *pc)
 {
ide_hwif_t *hwif = drive->hwif;
idetape_tape_t *tape = drive->driver_data;
@@ -1614,7 +1614,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t 
*drive,
 */
if (tape->failed_pc != NULL &&
tape->pc->c[0] == REQUEST_SENSE) {
-   return idetape_issue_packet_command(drive, tape->failed_pc);
+   return idetape_issue_pc(drive, tape->failed_pc);
}
if (postponed_rq != NULL)
if (rq != postponed_rq) {
@@ -1707,7 +1707,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t 
*drive,
}
BUG();
 out:
-   return idetape_issue_packet_command(drive, pc);
+   return idetape_issue_pc(drive, pc);
 
 err:
printk(KERN_ERR "ide-tape: Error processing request %u\n", rq->cmd[0]);
@@ -2263,11 +2263,8 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int 
cmd, int blocks, struct
return (tape->blk_size * (blocks-rq.current_nr_sectors));
 }
 
-/*
- * idetape_insert_pipeline_into_queue is used to start servicing the
- * pipeline stages, starting from tape->next_stage.
- */
-static void idetape_insert_pipeline_into_queue (ide_drive_t *drive)
+/* start servicing the pipeline stages, starting from tape->next_stage. */
+static void idetape_plug_pipeline(ide_drive_t *drive)
 {
idetape_tape_t *tape = drive->driver_data;
 
@@ -2359,7 +2356,7 @@ static int idetape_add_chrdev_write_request (ide_drive_t 
*drive, int blocks)
spin_unlock_irqrestore(&tape->lock, flags);
} else {
spin_unlock_irqrestore(&tape->lock, flags);
-   idetape_insert_pipeline_into_queue(drive);
+   idetape_plug_pipeline(drive);
if (idetape_pipeline_active(tape))
continue;
/*
@@ -2396,7 +2393,7 @@ static int idetape_add_chrdev_write_request (ide_drive_t 
*drive, int blocks)
tape->insert_time = jiffies;
tape->insert_size = 0;
tape->insert_speed = 0;
-   idetape_insert_pipeline_into_queue(drive);
+   idetape_plug_pipeline(drive);
}
}
if (test_and_clear_bit(IDETAPE_PIPELINE_ERROR, &tape->flags))
@@ -2415,7 +2412,7 @@ static void idetape_wait_for_pipeline (ide_drive_t *drive)
unsigned long flags;
 
while (tape->next_stage || idetape_pipeline_active(tape)) {
-   idetape_insert_pipeline_into_queue(drive);
+   idetape_plug_pipeline(drive);
spin_lock_irqsave(&tape->lock, flags);
if (idetape_pipeline_active(tape))
idetape_wait_for_request(drive, tape->active_data_rq);
@@ -2508,7 +2505,7 @@ static void idetape_restart_speed_control (ide_drive_t 
*drive)
tape->controlled_previous_head_time = 
tape->uncontrolled_previous_head_time = jiffies;
 }
 
-static int idetape_initiate_read (ide_drive_t *drive, int max_stages)
+static int idetape_init_read(ide_drive_t *drive, int max_stages)
 {
idetape_tape_t *tape = drive->driver_data;
idetape_stage_t *new_stage;
@@ -2569,7 +2566,7 @@ static int idetape_initiate_read (ide_drive_t *drive, int 
max_stages)
tape->i

[PATCH 13/22] ide-tape: remove struct idetape_id_gcw

2008-02-04 Thread Borislav Petkov
Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |   58 ---
 1 files changed, 25 insertions(+), 33 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 712c5df..175d507 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -520,20 +520,6 @@ enum {
 #defineIDETAPE_ERROR_FILEMARK  102
 #defineIDETAPE_ERROR_EOD   103
 
-/*
- * The following is used to format the general configuration word of
- * the ATAPI IDENTIFY DEVICE command.
- */
-struct idetape_id_gcw {
-   unsigned packet_size:2; /* Packet Size */
-   unsigned reserved234:3; /* Reserved */
-   unsigned drq_type   :2; /* Command packet DRQ type */
-   unsigned removable  :1; /* Removable media */
-   unsigned device_type:5; /* Device type */
-   unsigned reserved13 :1; /* Reserved */
-   unsigned protocol   :2; /* Protocol type */
-};
-
 /* Structures related to the SELECT SENSE / MODE SENSE packet commands. */
 #define IDETAPE_BLOCK_DESCRIPTOR   0
 #defineIDETAPE_CAPABILITIES_PAGE   0x2a
@@ -3382,37 +3368,41 @@ static int idetape_chrdev_release (struct inode *inode, 
struct file *filp)
 }
 
 /*
- * idetape_identify_device is called to check the contents of the
- * ATAPI IDENTIFY command results. We return:
+ * check the contents of the ATAPI IDENTIFY command results. We return:
  *
- * 1   If the tape can be supported by us, based on the information
- * we have so far.
+ * 1 - If the tape can be supported by us, based on the information we have so
+ * far.
  *
- * 0   If this tape driver is not currently supported by us.
+ * 0 - If this tape driver is not currently supported by us.
  */
-static int idetape_identify_device (ide_drive_t *drive)
+static int idetape_identify_device(ide_drive_t *drive)
 {
-   struct idetape_id_gcw gcw;
-   struct hd_driveid *id = drive->id;
+
+   u8 gcw[2];
+   u8 protocol, device_type, removable, packet_size;
 
if (drive->id_read == 0)
return 1;
 
-   *((unsigned short *) &gcw) = id->config;
+   *((unsigned short *) &gcw) = drive->id->config;
 
-   /* Check that we can support this device */
+   protocol=   (gcw[1] & 0xC0) >> 6;
+   device_type =gcw[1] & 0x1F;
+   removable   = !!(gcw[0] & 0x80);
+   packet_size =gcw[0] & 0x3;
 
-   if (gcw.protocol != 2)
+   /* Check that we can support this device */
+   if (protocol != 2)
printk(KERN_ERR "ide-tape: Protocol (0x%02x) is not ATAPI\n",
-   gcw.protocol);
-   else if (gcw.device_type != 1)
+   protocol);
+   else if (device_type != 1)
printk(KERN_ERR "ide-tape: Device type (0x%02x) is not set "
-   "to tape\n", gcw.device_type);
-   else if (!gcw.removable)
+   "to tape\n", device_type);
+   else if (!removable)
printk(KERN_ERR "ide-tape: The removable flag is not set\n");
-   else if (gcw.packet_size != 0) {
+   else if (packet_size != 0) {
printk(KERN_ERR "ide-tape: Packet size (0x%02x) is not 12 "
-   "bytes long\n", gcw.packet_size);
+   "bytes long\n", packet_size);
} else
return 1;
return 0;
@@ -3541,8 +3531,8 @@ static void idetape_setup (ide_drive_t *drive, 
idetape_tape_t *tape, int minor)
 {
unsigned long t1, tmid, tn, t;
int speed;
-   struct idetape_id_gcw gcw;
int stage_size;
+   u8 gcw[2];
struct sysinfo si;
u16 *ctl = (u16 *)&tape->caps[12];
 
@@ -3564,7 +3554,9 @@ static void idetape_setup (ide_drive_t *drive, 
idetape_tape_t *tape, int minor)
tape->max_insert_speed = 1;
tape->speed_control = 1;
*((unsigned short *) &gcw) = drive->id->config;
-   if (gcw.drq_type == 1)
+
+   /* Command packet DRQ type */
+   if (((gcw[0] & 0x60) >> 5) == 1)
tape->flags |= IDETAPE_FL_DRQ_INTERRUPT;
 
tape->min_pipeline = tape->max_pipeline = tape->max_stages = 10;
-- 
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


[PATCH 18/22] ide-tape: remove leftover OnStream support warning

2008-02-04 Thread Borislav Petkov
Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |4 
 1 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index cfcf5b0..4a12c0b 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -3629,10 +3629,6 @@ static int ide_tape_probe(ide_drive_t *drive)
printk("ide-tape: passing drive %s to ide-scsi emulation.\n", 
drive->name);
goto failed;
}
-   if (strstr(drive->id->model, "OnStream DI-")) {
-   printk(KERN_WARNING "ide-tape: Use drive %s with ide-scsi 
emulation and osst.\n", drive->name);
-   printk(KERN_WARNING "ide-tape: OnStream support will be removed 
soon from ide-tape!\n");
-   }
tape = kzalloc(sizeof (idetape_tape_t), GFP_KERNEL);
if (tape == NULL) {
printk(KERN_ERR "ide-tape: %s: Can't allocate a tape 
structure\n", drive->name);
-- 
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


[PATCH 07/22] ide-tape: struct idetape_tape_t: shorten member names v2

2008-02-04 Thread Borislav Petkov
Shorten some member names not too aggressively since this driver might be gone
anyway soon.

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |  210 ++--
 1 files changed, 113 insertions(+), 97 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 126e8a9..0b5ccce 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -299,10 +299,8 @@ typedef struct ide_tape_obj {
/* Timer used to poll for dsc */
struct timer_list dsc_timer;
/* Read/Write dsc polling frequency */
-   unsigned long best_dsc_rw_frequency;
-   /* The current polling frequency */
-   unsigned long dsc_polling_frequency;
-   /* Maximum waiting time */
+   unsigned long best_dsc_rw_freq;
+   unsigned long dsc_poll_freq;
unsigned long dsc_timeout;
 
/*
@@ -310,7 +308,7 @@ typedef struct ide_tape_obj {
 */
u8 partition;
/* Current block */
-   unsigned int first_frame_position;
+   unsigned int first_frame;
 
/*
 *  Last error information
@@ -326,11 +324,8 @@ typedef struct ide_tape_obj {
/* Current character device data transfer direction */
u8 chrdev_dir;
 
-   /*
-*  Device information
-*/
-   /* Usually 512 or 1024 bytes */
-   unsigned short tape_block_size;
+   /* tape block size, usu. 512 or 1024 bytes */
+   unsigned short blk_size;
int user_bs_factor;
 
/* Copy of the tape's Capabilities and Mechanical Page */
@@ -349,8 +344,8 @@ typedef struct ide_tape_obj {
 *  The data buffer size is chosen based on the tape's
 *  recommendation.
 */
-   /* Pointer to the request which is waiting in the device request queue 
*/
-   struct request *active_data_request;
+   /* Ptr to the request which is waiting in the device request queue */
+   struct request *active_data_rq;
/* Data buffer size (chosen based on the tape's recommendation */
int stage_size;
idetape_stage_t *merge_stage;
@@ -388,7 +383,7 @@ typedef struct ide_tape_obj {
/* Status/Action flags: long for set_bit */
unsigned long flags;
/* protects the ide-tape queue */
-   spinlock_t spinlock;
+   spinlock_t lock;
 
/*
 * Measures average tape speed
@@ -750,7 +745,7 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 
*sense)
/* Correct pc->actually_transferred by asking the tape.  */
if (test_bit(PC_DMA_ERROR, &pc->flags)) {
pc->actually_transferred = pc->request_transfer -
-   tape->tape_block_size *
+   tape->blk_size *
be32_to_cpu(get_unaligned((u32 *)&sense[3]));
idetape_update_buffers(pc);
}
@@ -809,7 +804,7 @@ static void idetape_activate_next_stage(ide_drive_t *drive)
rq->rq_disk = tape->disk;
rq->buffer = NULL;
rq->special = (void *)stage->bh;
-   tape->active_data_request = rq;
+   tape->active_data_rq = rq;
tape->active_stage = stage;
tape->next_stage = stage->next;
 }
@@ -951,13 +946,13 @@ static int idetape_end_request(ide_drive_t *drive, int 
uptodate, int nr_sects)
return 0;
}
 
-   spin_lock_irqsave(&tape->spinlock, flags);
+   spin_lock_irqsave(&tape->lock, flags);
 
/* The request was a pipelined data transfer request */
-   if (tape->active_data_request == rq) {
+   if (tape->active_data_rq == rq) {
active_stage = tape->active_stage;
tape->active_stage = NULL;
-   tape->active_data_request = NULL;
+   tape->active_data_rq = NULL;
tape->nr_pending_stages--;
if (rq->cmd[0] & REQ_IDETAPE_WRITE) {
remove_stage = 1;
@@ -978,7 +973,8 @@ static int idetape_end_request(ide_drive_t *drive, int 
uptodate, int nr_sects)
/*
 * Insert the next request into the request queue.
 */
-   (void) ide_do_drive_cmd(drive, 
tape->active_data_request, ide_end);
+   (void)ide_do_drive_cmd(drive, tape->active_data_rq,
+   ide_end);
} else if (!error) {
idetape_increase_max_pipeline_stages(drive);
}
@@ -990,9 +986,9 @@ static int idetape_end_request(ide_drive_t *drive, int 
uptodate, int nr_sects)
 
if (remove_stage)
idetape_remove_stage_head(drive);
-   if (tape->active_data_request == NULL)
+   if (tape->active_data_rq == NULL)
clear_bit(IDETAPE_PIPELI

[PATCH 21/22] ide-tape: bump minor driver version

2008-02-04 Thread Borislav Petkov
Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 5c5..2e6198f 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -15,7 +15,7 @@
  * Documentation/ide/ChangeLog.ide-tape.1995-2002
  */
 
-#define IDETAPE_VERSION "1.19"
+#define IDETAPE_VERSION "1.20"
 
 #include 
 #include 
-- 
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


[PATCH 14/22] ide-tape: cleanup and fix comments

2008-02-04 Thread Borislav Petkov
Also, remove redundant ones and cleanup whitespace.

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |  725 +++
 1 files changed, 293 insertions(+), 432 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 175d507..a80f8d9 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -73,37 +73,34 @@ enum {
 
 
 /*
- * Pipelined mode parameters.
+ * Pipelined mode parameters.
  *
- * We try to use the minimum number of stages which is enough to
- * keep the tape constantly streaming. To accomplish that, we implement
- * a feedback loop around the maximum number of stages:
+ * We try to use the minimum number of stages which is enough to keep the tape
+ * constantly streaming. To accomplish that, we implement a feedback loop 
around
+ * the maximum number of stages:
  *
- * We start from MIN maximum stages (we will not even use MIN stages
- *  if we don't need them), increment it by RATE*(MAX-MIN)
- * whenever we sense that the pipeline is empty, until we reach
- * the optimum value or until we reach MAX.
+ * We start from MIN maximum stages (we will not even use MIN stages if we 
don't
+ * need them), increment it by RATE*(MAX-MIN) whenever we sense that the
+ * pipeline is empty, until we reach the optimum value or until we reach MAX.
  *
- * Setting the following parameter to 0 is illegal: the pipelined mode
- * cannot be disabled (idetape_calculate_speeds() divides by
- * tape->max_stages.)
+ * Setting the following parameter to 0 is illegal: the pipelined mode cannot 
be
+ * disabled (idetape_calculate_speeds() divides by tape->max_stages.)
  */
 #define IDETAPE_MIN_PIPELINE_STAGES  1
 #define IDETAPE_MAX_PIPELINE_STAGES400
 #define IDETAPE_INCREASE_STAGES_RATE20
 
 /*
- * After each failed packet command we issue a request sense command
- * and retry the packet command IDETAPE_MAX_PC_RETRIES times.
+ * After each failed packet command we issue a request sense command and retry
+ * the packet command IDETAPE_MAX_PC_RETRIES times.
  *
- * Setting IDETAPE_MAX_PC_RETRIES to 0 will disable retries.
+ * Setting IDETAPE_MAX_PC_RETRIES to 0 will disable retries.
  */
 #define IDETAPE_MAX_PC_RETRIES 3
 
 /*
- * With each packet command, we allocate a buffer of
- * IDETAPE_PC_BUFFER_SIZE bytes. This is used for several packet
- * commands (Not for READ/WRITE commands).
+ * With each packet command, we allocate a buffer of IDETAPE_PC_BUFFER_SIZE
+ * bytes. This is used for several packet commands (Not for READ/WRITE 
commands)
  */
 #define IDETAPE_PC_BUFFER_SIZE 256
 
@@ -115,48 +112,41 @@ enum {
 #define IDETAPE_WAIT_CMD   (900*HZ)
 
 /*
- * The following parameter is used to select the point in the internal
- * tape fifo in which we will start to refill the buffer. Decreasing
- * the following parameter will improve the system's latency and
- * interactive response, while using a high value might improve system
- * throughput.
+ * The following parameter is used to select the point in the internal tape 
fifo
+ * in which we will start to refill the buffer. Decreasing the following
+ * parameter will improve the system's latency and interactive response, while
+ * using a high value might improve system throughput.
  */
-#define IDETAPE_FIFO_THRESHOLD 2
+#define IDETAPE_FIFO_THRESHOLD 2
 
 /*
- * DSC polling parameters.
+ * DSC polling parameters.
  *
- * Polling for DSC (a single bit in the status register) is a very
- * important function in ide-tape. There are two cases in which we
- * poll for DSC:
+ * Polling for DSC (a single bit in the status register) is a very important
+ * function in ide-tape. There are two cases in which we poll for DSC:
  *
- * 1.  Before a read/write packet command, to ensure that we
- * can transfer data from/to the tape's data buffers, without
- * causing an actual media access. In case the tape is not
- * ready yet, we take out our request from the device
- * request queue, so that ide.c will service requests from
- * the other device on the same interface meanwhile.
  *
- * 2.  After the successful initialization of a "media access
- * packet command", which is a command which can take a long
- * time to complete (it can be several seconds or even an hour).
+ * 1. Before a read/write packet command, to ensure that we can transfer data
+ *from/to the tape's data buffers, without causing an actual media access.
+ *In case the tape is not ready yet, we take out our request from the 
device
+ *request queue, so that ide.c could service requests from the other device
+ *on the same interface in the meantime.
  *
- * Again, w

[PATCH 22/22] ide-tape: schedule driver for removal after 6 months in case it turns out

2008-02-04 Thread Borislav Petkov
Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 Documentation/feature-removal-schedule.txt |   14 --
 drivers/ide/ide-tape.c |5 +
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/Documentation/feature-removal-schedule.txt 
b/Documentation/feature-removal-schedule.txt
index a7d9d17..147bb63 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -264,8 +264,6 @@ Who:Thomas Gleixner <[EMAIL PROTECTED]>
 
 ---
 

-
 What:  i2c-i810, i2c-prosavage and i2c-savage4
 When:  May 2008
 Why:   These drivers are superseded by i810fb, intelfb and savagefb.
@@ -338,3 +336,15 @@ Why:   The support code for the old firmware hurts 
code readability/maintainabilit
and slightly hurts runtime performance. Bugfixes for the old firmware
are not provided by Broadcom anymore.
 Who:   Michael Buesch <[EMAIL PROTECTED]>
+
+---
+
+What:  ide-tape driver
+When:  July 2008
+Files: drivers/ide/ide-tape.c
+Why:   This driver might not have any users anymore and maintaining it for no
+   reason is an effort no one wants to make.
+Who:   Bartlomiej Zolnierkiewicz <[EMAIL PROTECTED]>, Borislav Petkov
+   <[EMAIL PROTECTED]>
+
+---
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 2e6198f..86f206b 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -3803,6 +3803,11 @@ static int ide_tape_probe(ide_drive_t *drive)
g->fops = &idetape_block_ops;
ide_register_region(g);
 
+   printk(KERN_WARNING "It is possible that this driver does not have any"
+   " users anymore and, as a result, it will be REMOVED soon."
+   " Please notify Bart <[EMAIL PROTECTED]> or Boris"
+   " <[EMAIL PROTECTED]> in case you still need it.\n");
+
return 0;
 
 out_free_tape:
-- 
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


[PATCH 16/22] ide-tape: include proper headers

2008-02-04 Thread Borislav Petkov
Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 342ec50..24f048f 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -39,9 +39,9 @@
 #include 
 
 #include 
-#include 
-#include 
-#include 
+#include 
+#include 
+#include 
 #include 
 #include 
 
-- 
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


[PATCH 15/22] ide-tape: remove unused "length" arg from idetape_create_read_buffer_cmd()

2008-02-04 Thread Borislav Petkov
Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |8 +---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index a80f8d9..342ec50 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -1468,7 +1468,8 @@ static void idetape_create_read_cmd(idetape_tape_t *tape, 
idetape_pc_t *pc, unsi
pc->flags |= PC_FL_DMA_RECOMMENDED;
 }
 
-static void idetape_create_read_buffer_cmd(idetape_tape_t *tape, idetape_pc_t 
*pc, unsigned int length, struct idetape_bh *bh)
+static void idetape_create_read_buffer_cmd(idetape_tape_t *tape,
+   idetape_pc_t *pc, struct idetape_bh *bh)
 {
int size = 32768;
struct idetape_bh *p = bh;
@@ -1486,7 +1487,8 @@ static void idetape_create_read_buffer_cmd(idetape_tape_t 
*tape, idetape_pc_t *p
atomic_set(&p->b_count, 0);
p = p->b_reqnext;
}
-   pc->request_transfer = pc->buffer_size = size;
+   pc->request_transfer = size;
+   pc->buffer_size = size;
 }
 
 static void idetape_create_write_cmd(idetape_tape_t *tape, idetape_pc_t *pc, 
unsigned int length, struct idetape_bh *bh)
@@ -1607,7 +1609,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t 
*drive,
if (!pc)
goto err;
 
-   idetape_create_read_buffer_cmd(tape, pc, rq->current_nr_sectors,
+   idetape_create_read_buffer_cmd(tape, pc,
(struct idetape_bh *)rq->special);
goto out;
}
-- 
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


[PATCH 11/22] ide-tape: remove atomic test/set macros

2008-02-04 Thread Borislav Petkov
Also remove flag IDETAPE_READ_ERROR since it is unused.

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |  226 +--
 1 files changed, 120 insertions(+), 106 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 4fee160..1c4f94c 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -207,24 +207,24 @@ typedef struct idetape_packet_command_s {
u8 *current_position;   /* Pointer into the above 
buffer */
ide_startstop_t (*callback) (ide_drive_t *);/* Called when this 
packet command is completed */
u8 pc_buffer[IDETAPE_PC_BUFFER_SIZE];   /* Temporary buffer */
-   unsigned long flags;/* Status/Action bit flags: 
long for set_bit */
+   unsigned int flags;
 } idetape_pc_t;
 
-/*
- * Packet command flag bits.
- */
-/* Set when an error is considered normal - We won't retry */
-#definePC_ABORT0
-/* 1 When polling for DSC on a media access command */
-#define PC_WAIT_FOR_DSC1
-/* 1 when we prefer to use DMA if possible */
-#define PC_DMA_RECOMMENDED 2
-/* 1 while DMA in progress */
-#definePC_DMA_IN_PROGRESS  3
-/* 1 when encountered problem during DMA */
-#definePC_DMA_ERROR4
-/* Data direction */
-#definePC_WRITING  5
+/* Packet command flag bits. */
+enum {
+   /* Set when an error is considered normal - We won't retry */
+   PC_FL_ABORT = (1 << 0),
+   /* 1 When polling for DSC on a media access command */
+   PC_FL_WAIT_FOR_DSC  = (1 << 1),
+   /* 1 when we prefer to use DMA if possible */
+   PC_FL_DMA_RECOMMENDED   = (1 << 2),
+   /* 1 while DMA in progress */
+   PC_FL_DMA_IN_PROGRESS   = (1 << 3),
+   /* 1 when encountered problem during DMA */
+   PC_FL_DMA_ERROR = (1 << 4),
+   /* Data direction */
+   PC_FL_WRITING   = (1 << 5),
+};
 
 /*
  * A pipeline stage.
@@ -354,8 +354,7 @@ typedef struct ide_tape_obj {
/* Wasted space in each stage */
int excess_bh_size;
 
-   /* Status/Action flags: long for set_bit */
-   unsigned long flags;
+   unsigned int flags;
/* protects the ide-tape queue */
spinlock_t lock;
 
@@ -458,20 +457,26 @@ static void ide_tape_put(struct ide_tape_obj *tape)
 #define DOOR_LOCKED1
 #define DOOR_EXPLICITLY_LOCKED 2
 
-/*
- * Tape flag bits values.
- */
-#define IDETAPE_IGNORE_DSC 0
-#define IDETAPE_ADDRESS_VALID  1   /* 0 When the tape position is 
unknown */
-#define IDETAPE_BUSY   2   /* Device already opened */
-#define IDETAPE_PIPELINE_ERROR 3   /* Error detected in a pipeline 
stage */
-#define IDETAPE_DETECT_BS  4   /* Attempt to auto-detect the 
current user block size */
-#define IDETAPE_FILEMARK   5   /* Currently on a filemark */
-#define IDETAPE_DRQ_INTERRUPT  6   /* DRQ interrupt device */
-#define IDETAPE_READ_ERROR 7
-#define IDETAPE_PIPELINE_ACTIVE8   /* pipeline active */
-/* 0 = no tape is loaded, so we don't rewind after ejecting */
-#define IDETAPE_MEDIUM_PRESENT 9
+/* Tape flag bits values. */
+enum {
+   IDETAPE_FL_IGNORE_DSC   = (1 << 0),
+   /* 0 When the tape position is unknown */
+   IDETAPE_FL_ADDRESS_VALID= (1 << 1),
+   /* Device already opened */
+   IDETAPE_FL_BUSY = (1 << 2),
+   /* Error detected in a pipeline stage */
+   IDETAPE_FL_PIPELINE_ERR = (1 << 3),
+   /* Attempt to auto-detect the current user block size */
+   IDETAPE_FL_DETECT_BS= (1 << 4),
+   /* Currently on a filemark */
+   IDETAPE_FL_FILEMARK = (1 << 5),
+   /* DRQ interrupt device */
+   IDETAPE_FL_DRQ_INTERRUPT= (1 << 6),
+   /* pipeline active */
+   IDETAPE_FL_PIPELINE_ACTIVE  = (1 << 7),
+   /* 0 = no tape is loaded, so we don't rewind after ejecting */
+   IDETAPE_FL_MEDIUM_PRESENT   = (1 << 8),
+};
 
 /*
  * Some defines for the READ BUFFER command
@@ -627,7 +632,7 @@ static void idetape_update_buffers (idetape_pc_t *pc)
int count;
unsigned int bcount = pc->actually_transferred;
 
-   if (test_bit(PC_WRITING, &pc->flags))
+   if (pc->flags & PC_FL_WRITING)
return;
while (bcount) {
if (bh == NULL) {
@@ -703,8 +708,8 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 
*sense)
debug_log(DBG_ERR, "pc = %x, sense key = %x, asc = %x, ascq = %x\n",
 pc->c[0], tape->s

[PATCH 03/22] ide-tape: remove unreachable code chunk

2008-02-04 Thread Borislav Petkov
tape->speed_control is set to 1 in idetape_setup(), but, in calculate_speeds()
its value is tested for being 0, 1, or 2. Remove the if-branches where
tape->speed_control != 1 since they are never executed. Also, rename
calculate_speeds() by adding driver's prefix as is with the other function 
names.

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |   22 ++
 1 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index c8c57ab..b15dd17 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -87,7 +87,8 @@ enum {
  * the optimum value or until we reach MAX.
  *
  * Setting the following parameter to 0 is illegal: the pipelined mode
- * cannot be disabled (calculate_speeds() divides by tape->max_stages.)
+ * cannot be disabled (idetape_calculate_speeds() divides by
+ * tape->max_stages.)
  */
 #define IDETAPE_MIN_PIPELINE_STAGES  1
 #define IDETAPE_MAX_PIPELINE_STAGES400
@@ -1475,10 +1476,9 @@ static void idetape_create_mode_sense_cmd (idetape_pc_t 
*pc, u8 page_code)
pc->callback = &idetape_pc_callback;
 }
 
-static void calculate_speeds(ide_drive_t *drive)
+static void idetape_calculate_speeds(ide_drive_t *drive)
 {
idetape_tape_t *tape = drive->driver_data;
-   int full = 125, empty = 75;
 
if (time_after(jiffies, tape->controlled_pipeline_head_time + 120 * 
HZ)) {
tape->controlled_previous_pipeline_head = 
tape->controlled_last_pipeline_head;
@@ -1505,22 +1505,20 @@ static void calculate_speeds(ide_drive_t *drive)
}
}
tape->pipeline_head_speed = max(tape->uncontrolled_pipeline_head_speed, 
tape->controlled_pipeline_head_speed);
-   if (tape->speed_control == 0) {
-   tape->max_insert_speed = 5000;
-   } else if (tape->speed_control == 1) {
+
+   if (tape->speed_control == 1) {
if (tape->nr_pending_stages >= tape->max_stages / 2)
tape->max_insert_speed = tape->pipeline_head_speed +
(1100 - tape->pipeline_head_speed) * 2 * 
(tape->nr_pending_stages - tape->max_stages / 2) / tape->max_stages;
else
tape->max_insert_speed = 500 +
(tape->pipeline_head_speed - 500) * 2 * 
tape->nr_pending_stages / tape->max_stages;
+
if (tape->nr_pending_stages >= tape->max_stages * 99 / 100)
tape->max_insert_speed = 5000;
-   } else if (tape->speed_control == 2) {
-   tape->max_insert_speed = tape->pipeline_head_speed * empty / 
100 +
-   (tape->pipeline_head_speed * full / 100 - 
tape->pipeline_head_speed * empty / 100) * tape->nr_pending_stages / 
tape->max_stages;
} else
tape->max_insert_speed = tape->speed_control;
+
tape->max_insert_speed = max(tape->max_insert_speed, 500);
 }
 
@@ -1697,7 +1695,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t 
*drive,
tape->measure_insert_time = 1;
if (time_after(jiffies, tape->insert_time))
tape->insert_speed = tape->insert_size / 1024 * HZ / (jiffies - 
tape->insert_time);
-   calculate_speeds(drive);
+   idetape_calculate_speeds(drive);
if (!test_and_clear_bit(IDETAPE_IGNORE_DSC, &tape->flags) &&
(stat & SEEK_STAT) == 0) {
if (postponed_rq == NULL) {
@@ -2419,7 +2417,7 @@ static int idetape_add_chrdev_write_request (ide_drive_t 
*drive, int blocks)
idetape_switch_buffers(tape, new_stage);
idetape_add_stage_tail(drive, new_stage);
tape->pipeline_head++;
-   calculate_speeds(drive);
+   idetape_calculate_speeds(drive);
 
/*
 *  Estimate whether the tape has stopped writing by checking
@@ -2659,7 +2657,7 @@ static int idetape_add_chrdev_read_request (ide_drive_t 
*drive,int blocks)
idetape_remove_stage_head(drive);
spin_unlock_irqrestore(&tape->spinlock, flags);
tape->pipeline_head++;
-   calculate_speeds(drive);
+   idetape_calculate_speeds(drive);
}
if (bytes_read > blocks * tape->tape_block_size) {
printk(KERN_ERR "ide-tape: bug: trying to return more bytes 
than requested\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


[PATCH 17/22] ide-tape: collect module-related macro calls at the end

2008-02-04 Thread Borislav Petkov
Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 24f048f..cfcf5b0 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -3681,9 +3681,6 @@ failed:
return -ENODEV;
 }
 
-MODULE_DESCRIPTION("ATAPI Streaming TAPE Driver");
-MODULE_LICENSE("GPL");
-
 static void __exit idetape_exit (void)
 {
driver_unregister(&idetape_driver.gen_driver);
@@ -3726,3 +3723,5 @@ MODULE_ALIAS("ide:*m-tape*");
 module_init(idetape_init);
 module_exit(idetape_exit);
 MODULE_ALIAS_CHARDEV_MAJOR(IDETAPE_MAJOR);
+MODULE_DESCRIPTION("ATAPI Streaming TAPE Driver");
+MODULE_LICENSE("GPL");
-- 
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


[PATCH 09/22] ide-tape: remove idetape_increase_max_pipeline_stages()

2008-02-04 Thread Borislav Petkov
This function was being used only at one place so fold it in there.

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |   36 
 1 files changed, 16 insertions(+), 20 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index b4944ef..ae2c76d 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -771,25 +771,6 @@ static void idetape_activate_next_stage(ide_drive_t *drive)
 }
 
 /*
- * idetape_increase_max_pipeline_stages is a part of the feedback
- * loop which tries to find the optimum number of stages. In the
- * feedback loop, we are starting from a minimum maximum number of
- * stages, and if we sense that the pipeline is empty, we try to
- * increase it, until we reach the user compile time memory limit.
- */
-static void idetape_increase_max_pipeline_stages (ide_drive_t *drive)
-{
-   idetape_tape_t *tape = drive->driver_data;
-   int increase = (tape->max_pipeline - tape->min_pipeline) / 10;
-
-   debug_log(DBG_PROCS, "Enter %s\n", __func__);
-
-   tape->max_stages += max(increase, 1);
-   tape->max_stages = max(tape->max_stages, tape->min_pipeline);
-   tape->max_stages = min(tape->max_stages, tape->max_pipeline);
-}
-
-/*
  * idetape_kfree_stage calls kfree to completely free a stage, along with
  * its related buffers.
  */
@@ -937,7 +918,22 @@ static int idetape_end_request(ide_drive_t *drive, int 
uptodate, int nr_sects)
(void)ide_do_drive_cmd(drive, tape->active_data_rq,
ide_end);
} else if (!error) {
-   idetape_increase_max_pipeline_stages(drive);
+   /*
+* This is a part of the feedback loop which tries to
+* find the optimum number of stages. We are starting
+* from a minimum maximum number of stages, and if we
+* sense that the pipeline is empty, we try to increase
+* it, until we reach the user compile time memory
+* limit.
+*/
+   int i = (tape->max_pipeline - tape->min_pipeline) / 10;
+
+   tape->max_stages += max(i, 1);
+   tape->max_stages = max(tape->max_stages,
+   tape->min_pipeline);
+   tape->max_stages = min(tape->max_stages,
+   tape->max_pipeline);
+
}
}
ide_end_drive_cmd(drive, 0, 0);
-- 
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


[PATCH 19/22] ide-tape: fix syntax error in idetape_identify_device()

2008-02-04 Thread Borislav Petkov
Spotted by Sergei Shtylyov.

CC: Sergei Shtylyov <[EMAIL PROTECTED]>
Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 4a12c0b..7e998c4 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -3273,8 +3273,8 @@ static int idetape_identify_device(ide_drive_t *drive)
else if (!removable)
printk(KERN_ERR "ide-tape: The removable flag is not set\n");
else if (packet_size != 0) {
-   printk(KERN_ERR "ide-tape: Packet size (0x%02x) is not 12 "
-   "bytes long\n", packet_size);
+   printk(KERN_ERR "ide-tape: Packet size (0x%02x) is not 12"
+   " bytes\n", packet_size);
} else
return 1;
return 0;
-- 
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


[PATCH 12/22] ide-tape: dump gcw fields on error in idetape_identify_device()

2008-02-04 Thread Borislav Petkov
goes before "ide-tape: remove IDETAPE_DEBUG_INFO" patch in IDE quilt tree

Cc: Borislav Petkov <[EMAIL PROTECTED]>
Signed-off-by: Bartlomiej Zolnierkiewicz <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |   13 +++--
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 1c4f94c..712c5df 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -3402,16 +3402,17 @@ static int idetape_identify_device (ide_drive_t *drive)
 
/* Check that we can support this device */
 
-   if (gcw.protocol !=2 )
-   printk(KERN_ERR "ide-tape: Protocol is not ATAPI\n");
+   if (gcw.protocol != 2)
+   printk(KERN_ERR "ide-tape: Protocol (0x%02x) is not ATAPI\n",
+   gcw.protocol);
else if (gcw.device_type != 1)
-   printk(KERN_ERR "ide-tape: Device type is not set to tape\n");
+   printk(KERN_ERR "ide-tape: Device type (0x%02x) is not set "
+   "to tape\n", gcw.device_type);
else if (!gcw.removable)
printk(KERN_ERR "ide-tape: The removable flag is not set\n");
else if (gcw.packet_size != 0) {
-   printk(KERN_ERR "ide-tape: Packet size is not 12 bytes long\n");
-   if (gcw.packet_size == 1)
-   printk(KERN_ERR "ide-tape: Sorry, padding to 16 bytes 
is still not supported\n");
+   printk(KERN_ERR "ide-tape: Packet size (0x%02x) is not 12 "
+   "bytes long\n", gcw.packet_size);
} else
return 1;
return 0;
-- 
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


[PATCH 04/22] ide-tape: simplify code branching in the interrupt handler

2008-02-04 Thread Borislav Petkov
... by adding a new typedef function pointer idetape_io_buf in order to call
the proper buffer i/o handler depending on the data direction.

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |   55 +--
 1 files changed, 29 insertions(+), 26 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index b15dd17..2857965 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -1105,18 +1105,22 @@ static void idetape_postpone_request (ide_drive_t 
*drive)
 }
 
 /*
- * idetape_pc_intr is the usual interrupt handler which will be called
- * during a packet command. We will transfer some of the data (as
- * requested by the drive) and will re-point interrupt handler to us.
- * When data transfer is finished, we will act according to the
- * algorithm described before idetape_issue_packet_command.
- *
+ * This is the usual interrupt handler which will be called during a packet
+ * command. We will transfer some of the data (as requested by the drive) and
+ * will re-point interrupt handler to us. When data transfer is finished, we
+ * will act according to the algorithm described before
+ * idetape_issue_packet_command.
  */
-static ide_startstop_t idetape_pc_intr (ide_drive_t *drive)
+
+typedef void idetape_io_buf(ide_drive_t *, idetape_pc_t *, unsigned int);
+
+static ide_startstop_t idetape_pc_intr(ide_drive_t *drive)
 {
ide_hwif_t *hwif = drive->hwif;
idetape_tape_t *tape = drive->driver_data;
idetape_pc_t *pc = tape->pc;
+   xfer_func_t *xferfunc;
+   idetape_io_buf *iobuf;
unsigned int temp;
 #if SIMULATE_ERRORS
static int error_sim_count = 0;
@@ -1184,7 +1188,8 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t 
*drive)
debug_log(DBG_ERR, "%s: I/O error\n", tape->name);
 
if (pc->c[0] == REQUEST_SENSE) {
-   printk(KERN_ERR "ide-tape: I/O error in request 
sense command\n");
+   printk(KERN_ERR "ide-tape: I/O error in request"
+   " sense command\n");
return ide_do_reset(drive);
}
debug_log(DBG_ERR, "[cmd %x]: check condition\n",
@@ -1223,7 +1228,7 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t 
*drive)
ireason = hwif->INB(IDE_IREASON_REG);
 
if (ireason & CD) {
-   printk(KERN_ERR "ide-tape: CoD != 0 in idetape_pc_intr\n");
+   printk(KERN_ERR "ide-tape: CoD != 0 in %s\n", __func__);
return ide_do_reset(drive);
}
if (((ireason & IO) == IO) == test_bit(PC_WRITING, &pc->flags)) {
@@ -1239,31 +1244,29 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t 
*drive)
temp = pc->actually_transferred + bcount;
if (temp > pc->request_transfer) {
if (temp > pc->buffer_size) {
-   printk(KERN_ERR "ide-tape: The tape wants to 
send us more data than expected - discarding data\n");
+   printk(KERN_ERR "ide-tape: The tape wants to "
+   "send us more data than expected "
+   "- discarding data\n");
idetape_discard_data(drive, bcount);
-   ide_set_handler(drive, &idetape_pc_intr, 
IDETAPE_WAIT_CMD, NULL);
+   ide_set_handler(drive, &idetape_pc_intr,
+   IDETAPE_WAIT_CMD, NULL);
return ide_started;
}
debug_log(DBG_SENSE, "The tape wants to send us more "
"data than expected - allowing transfer\n");
-
}
-   }
-   if (test_bit(PC_WRITING, &pc->flags)) {
-   if (pc->bh != NULL)
-   idetape_output_buffers(drive, pc, bcount);
-   else
-   /* Write the current buffer */
-   hwif->atapi_output_bytes(drive, pc->current_position,
-bcount);
+   iobuf = &idetape_input_buffers;
+   xferfunc = hwif->atapi_input_bytes;
} else {
-   if (pc->bh != NULL)
-   idetape_input_buffers(drive, pc, bcount);
-   else
-   /* Read the current buffer */
-   hwif->atapi_input_bytes(drive, pc->current_position,
-   bcount);

[PATCH 06/22] ide-tape: struct idetape_tape_t: remove unused members

2008-02-04 Thread Borislav Petkov
- last_frame_position: only being written to once
- firmware_revision, product_id, vendor_id: used once, remove from struct
  idetape_tape_t and deal with them locally
- firmware_revision_num: only written to once
- tape_still_time_begin: completely unused
- tape_still_time: never written to; remove corresponding code chunk
- uncontrolled_last_pipeline_head: only once written to
- blocks_in_buffer: only written to

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |   45 +++--
 1 files changed, 11 insertions(+), 34 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index e0e8184..126e8a9 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -311,8 +311,6 @@ typedef struct ide_tape_obj {
u8 partition;
/* Current block */
unsigned int first_frame_position;
-   unsigned int last_frame_position;
-   unsigned int blocks_in_buffer;
 
/*
 *  Last error information
@@ -399,11 +397,6 @@ typedef struct ide_tape_obj {
int avg_size;
int avg_speed;
 
-   char vendor_id[10];
-   char product_id[18];
-   char firmware_revision[6];
-   int firmware_revision_num;
-
/* the door is currently locked */
int door_locked;
/* the tape hardware is write protected */
@@ -441,12 +434,6 @@ typedef struct ide_tape_obj {
int measure_insert_time;
 
/*
-* Measure tape still time, in milliseconds
-*/
-   unsigned long tape_still_time_begin;
-   int tape_still_time;
-
-   /*
 * Speed regulation negative feedback loop
 */
int speed_control;
@@ -454,7 +441,6 @@ typedef struct ide_tape_obj {
int controlled_pipeline_head_speed;
int uncontrolled_pipeline_head_speed;
int controlled_last_pipeline_head;
-   int uncontrolled_last_pipeline_head;
unsigned long uncontrolled_pipeline_head_time;
unsigned long controlled_pipeline_head_time;
int controlled_previous_pipeline_head;
@@ -1696,8 +1682,6 @@ static ide_startstop_t idetape_do_request(ide_drive_t 
*drive,
drive->post_reset = 0;
}
 
-   if (tape->tape_still_time > 100 && tape->tape_still_time < 200)
-   tape->measure_insert_time = 1;
if (time_after(jiffies, tape->insert_time))
tape->insert_speed = tape->insert_size / 1024 * HZ / (jiffies - 
tape->insert_time);
idetape_calculate_speeds(drive);
@@ -2010,9 +1994,6 @@ static ide_startstop_t 
idetape_read_position_callback(ide_drive_t *drive)
tape->partition = readpos[1];
tape->first_frame_position =
be32_to_cpu(*(u32 *)&readpos[4]);
-   tape->last_frame_position =
-   be32_to_cpu(*(u32 *)&readpos[8]);
-   tape->blocks_in_buffer = readpos[15];
set_bit(IDETAPE_ADDRESS_VALID, &tape->flags);
idetape_end_request(drive, 1, 0);
}
@@ -2541,7 +2522,7 @@ static void idetape_restart_speed_control (ide_drive_t 
*drive)
 
tape->restart_speed_control_req = 0;
tape->pipeline_head = 0;
-   tape->controlled_last_pipeline_head = 
tape->uncontrolled_last_pipeline_head = 0;
+   tape->controlled_last_pipeline_head = 0;
tape->controlled_previous_pipeline_head = 
tape->uncontrolled_previous_pipeline_head = 0;
tape->pipeline_head_speed = tape->controlled_pipeline_head_speed = 5000;
tape->uncontrolled_pipeline_head_speed = 0;
@@ -3438,9 +3419,9 @@ static int idetape_identify_device (ide_drive_t *drive)
 
 static void idetape_get_inquiry_results(ide_drive_t *drive)
 {
-   char *r;
idetape_tape_t *tape = drive->driver_data;
idetape_pc_t pc;
+   char fw_rev[6], vendor_id[10], product_id[18];
 
idetape_create_inquiry_cmd(&pc);
if (idetape_queue_pc_tail(drive, &pc)) {
@@ -3448,20 +3429,16 @@ static void idetape_get_inquiry_results(ide_drive_t 
*drive)
tape->name);
return;
}
-   memcpy(tape->vendor_id, &pc.buffer[8], 8);
-   memcpy(tape->product_id, &pc.buffer[16], 16);
-   memcpy(tape->firmware_revision, &pc.buffer[32], 4);
-
-   ide_fixstring(tape->vendor_id, 10, 0);
-   ide_fixstring(tape->product_id, 18, 0);
-   ide_fixstring(tape->firmware_revision, 6, 0);
-   r = tape->firmware_revision;
-   if (*(r + 1) == '.')
-   tape->firmware_revision_num = (*r - '0') * 100 +
-   (*(r + 2) - '0') * 10 + *(r + 3) - '0';
+   memcpy(vendor_id, &pc.buffer[8], 8);
+   memcpy(

[PATCH 05/22] ide-tape: remove typedef idetape_chrdev_direction_t

2008-02-04 Thread Borislav Petkov
.. and replace it with plain enums.

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |   62 ---
 1 files changed, 32 insertions(+), 30 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 2857965..e0e8184 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -184,11 +184,13 @@ enum {
 /*
  * For general magnetic tape device compatibility.
  */
-typedef enum {
-   idetape_direction_none,
-   idetape_direction_read,
-   idetape_direction_write
-} idetape_chrdev_direction_t;
+
+/* tape directions */
+enum {
+   IDETAPE_DIR_NONE  = (1 << 0),
+   IDETAPE_DIR_READ  = (1 << 1),
+   IDETAPE_DIR_WRITE = (1 << 2),
+};
 
 struct idetape_bh {
u32 b_size;
@@ -324,7 +326,7 @@ typedef struct ide_tape_obj {
/* device name */
char name[4];
/* Current character device data transfer direction */
-   idetape_chrdev_direction_t chrdev_direction;
+   u8 chrdev_dir;
 
/*
 *  Device information
@@ -1916,7 +1918,7 @@ static void idetape_init_merge_stage (idetape_tape_t 
*tape)
struct idetape_bh *bh = tape->merge_stage->bh;

tape->bh = bh;
-   if (tape->chrdev_direction == idetape_direction_write)
+   if (tape->chrdev_dir == IDETAPE_DIR_WRITE)
atomic_set(&bh->b_count, 0);
else {
tape->b_data = bh->b_data;
@@ -2187,7 +2189,7 @@ static int __idetape_discard_read_pipeline (ide_drive_t 
*drive)
unsigned long flags;
int cnt;
 
-   if (tape->chrdev_direction != idetape_direction_read)
+   if (tape->chrdev_dir != IDETAPE_DIR_READ)
return 0;
 
/* Remove merge stage. */
@@ -2202,7 +2204,7 @@ static int __idetape_discard_read_pipeline (ide_drive_t 
*drive)
 
/* Clear pipeline flags. */
clear_bit(IDETAPE_PIPELINE_ERROR, &tape->flags);
-   tape->chrdev_direction = idetape_direction_none;
+   tape->chrdev_dir = IDETAPE_DIR_NONE;
 
/* Remove pipeline stages. */
if (tape->first_stage == NULL)
@@ -2242,7 +2244,7 @@ static int idetape_position_tape (ide_drive_t *drive, 
unsigned int block, u8 par
int retval;
idetape_pc_t pc;
 
-   if (tape->chrdev_direction == idetape_direction_read)
+   if (tape->chrdev_dir == IDETAPE_DIR_READ)
__idetape_discard_read_pipeline(drive);
idetape_wait_ready(drive, 60 * 5 * HZ);
idetape_create_locate_cmd(drive, &pc, block, partition, skip);
@@ -2469,7 +2471,7 @@ static void idetape_empty_write_pipeline (ide_drive_t 
*drive)
int blocks, min;
struct idetape_bh *bh;
 
-   if (tape->chrdev_direction != idetape_direction_write) {
+   if (tape->chrdev_dir != IDETAPE_DIR_WRITE) {
printk(KERN_ERR "ide-tape: bug: Trying to empty write pipeline, 
but we are not writing.\n");
return;
}
@@ -2512,7 +2514,7 @@ static void idetape_empty_write_pipeline (ide_drive_t 
*drive)
tape->merge_stage = NULL;
}
clear_bit(IDETAPE_PIPELINE_ERROR, &tape->flags);
-   tape->chrdev_direction = idetape_direction_none;
+   tape->chrdev_dir = IDETAPE_DIR_NONE;
 
/*
 *  On the next backup, perform the feedback loop again.
@@ -2556,8 +2558,8 @@ static int idetape_initiate_read (ide_drive_t *drive, int 
max_stages)
u16 blocks = *(u16 *)&tape->caps[12];
 
/* Initialize read operation */
-   if (tape->chrdev_direction != idetape_direction_read) {
-   if (tape->chrdev_direction == idetape_direction_write) {
+   if (tape->chrdev_dir != IDETAPE_DIR_READ) {
+   if (tape->chrdev_dir == IDETAPE_DIR_WRITE) {
idetape_empty_write_pipeline(drive);
idetape_flush_tape_buffers(drive);
}
@@ -2567,7 +2569,7 @@ static int idetape_initiate_read (ide_drive_t *drive, int 
max_stages)
}
if ((tape->merge_stage = __idetape_kmalloc_stage(tape, 0, 0)) 
== NULL)
return -ENOMEM;
-   tape->chrdev_direction = idetape_direction_read;
+   tape->chrdev_dir = IDETAPE_DIR_READ;
 
/*
 *  Issue a read 0 command to ensure that DSC handshake
@@ -2581,7 +2583,7 @@ static int idetape_initiate_read (ide_drive_t *drive, int 
max_stages)
if (bytes_read < 0) {
__idetape_kfree_stage(tape->merge_stage);
tape->merge_stage = NULL;
-   tape->chrdev_direction = idetape_direction_none;
+   tape->chrdev_dir = IDETAPE_DIR_NONE;

[PATCH 08/22] ide-tape: remove packet command and struct request memory buffers

2008-02-04 Thread Borislav Petkov
These buffers were always statically allocated during driver initialization no
matter what. Remove them by allocating GFP_ATOMIC memory on demand. In the case
of allocation error, we only issue error msg in the *alloc_{pc,rq} thus 
postponing
the final error handling and cleanup in their callers. Packet command and
request memory is freed in idetape_end_request() which is at the end of the
request path entered from all callbacks. While at it, integrate comments above
member definitions in ide_tape_obj.

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |  146 +---
 1 files changed, 63 insertions(+), 83 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 0b5ccce..b4944ef 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -54,8 +54,6 @@ enum {
DBG_CHRDEV =(1 << 2),
/* all remaining procedures */
DBG_PROCS = (1 << 3),
-   /* buffer alloc info (pc_stack & rq_stack) */
-   DBG_PCRQ_STACK =(1 << 4),
 };
 
 /* define to see debug info */
@@ -110,13 +108,6 @@ enum {
 #define IDETAPE_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 IDETAPE_PC_STACK   (10 + IDETAPE_MAX_PC_RETRIES)
-
-/*
  * Some drives (for example, Seagate STT3401A Travan) require a very long
  * timeout, because they don't return an interrupt or clear their busy bit
  * until after the command completes (even retension commands).
@@ -255,32 +246,15 @@ typedef struct ide_tape_obj {
struct gendisk  *disk;
struct kref kref;
 
+   /* current processed packet command */
+   idetape_pc_t *pc;
/*
-*  Since a typical character device operation requires more
-*  than one packet command, we provide here enough memory
-*  for the maximum of interconnected packet commands.
-*  The packet commands are stored in the circular array pc_stack.
-*  pc_stack_index points to the last used entry, and warps around
-*  to the start when we get to the last array entry.
-*
-*  pc points to the current processed packet command.
-*
-*  failed_pc points to the last failed packet command, or contains
-*  NULL if we do not need to retry any packet command. This is
-*  required since an additional packet command is needed before the
-*  retry, to get detailed information on what went wrong.
+* last failed packet command or NULL if we do not need to retry any
+* packet command. This is required since an additional packet command
+* is needed before the retry, to get detailed information on what went
+* wrong.
 */
-   /* Current packet command */
-   idetape_pc_t *pc;
-   /* Last failed packet command */
idetape_pc_t *failed_pc;
-   /* Packet command stack */
-   idetape_pc_t pc_stack[IDETAPE_PC_STACK];
-   /* Next free packet command storage space */
-   int pc_stack_index;
-   struct request rq_stack[IDETAPE_PC_STACK];
-   /* We implement a circular array */
-   int rq_stack_index;
 
/*
 *  DSC polling variables.
@@ -670,45 +644,32 @@ static void idetape_update_buffers (idetape_pc_t *pc)
pc->bh = bh;
 }
 
-/*
- * idetape_next_pc_storage returns a pointer to a place in which we can
- * safely store a packet command, even though we intend to leave the
- * driver. A storage space for a maximum of IDETAPE_PC_STACK packet
- * commands is allocated at initialization time.
- */
-static idetape_pc_t *idetape_next_pc_storage (ide_drive_t *drive)
+static idetape_pc_t *ide_tape_alloc_pc(void)
 {
-   idetape_tape_t *tape = drive->driver_data;
+   idetape_pc_t *pc;
 
-   debug_log(DBG_PCRQ_STACK, "pc_stack_index=%d\n", tape->pc_stack_index);
+   pc = kzalloc(sizeof(idetape_pc_t), GFP_ATOMIC);
+   if (!pc)
+   printk(KERN_ERR "ide-tape: %s: memory allocation error.",
+   __func__);
 
-   if (tape->pc_stack_index == IDETAPE_PC_STACK)
-   tape->pc_stack_index=0;
-   return (&tape->pc_stack[tape->pc_stack_index++]);
+   return pc;
 }
 
 /*
- * idetape_next_rq_storage is used along with idetape_next_pc_storage.
- * Since we queue packet commands in the request queue, we need to
- * allocate a request, along with the allocation of a packet command.
+ * Since we queue packet commands in the

[PATCH 01/22] ide-tape: refactor the debug logging facility

2008-02-04 Thread Borislav Petkov
Teach the debug logging macro to differentiate between log levels based on the
type of debug level enabled specifically instead of a threshold-based one.
Thus, convert tape->debug_level to a bitmask that is written to over /proc.

Also,
- cleanup and simplify the debug macro thus removing a lot of code lines,
- get rid of unused debug levels,
- adjust the loglevel at several places where it was simply missing (e.g.
  idetape_chrdev_open())
- move the tape ptr initialization up in idetape_chrdev_open() so that we can
  use it in the debug_log macro earlier in the function.

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |  344 +---
 1 files changed, 122 insertions(+), 222 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 4168a06..442d71c 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -45,6 +45,32 @@
 #include 
 #include 
 
+enum {
+   /* output errors only */
+   DBG_ERR =   (1 << 0),
+   /* output all sense key/asc */
+   DBG_SENSE = (1 << 1),
+   /* info regarding all chrdev-related procedures */
+   DBG_CHRDEV =(1 << 2),
+   /* all remaining procedures */
+   DBG_PROCS = (1 << 3),
+   /* buffer alloc info (pc_stack & rq_stack) */
+   DBG_PCRQ_STACK =(1 << 4),
+};
+
+/* define to see debug info */
+#define IDETAPE_DEBUG_LOG  0
+
+#if IDETAPE_DEBUG_LOG
+#define debug_log(lvl, fmt, args...)   \
+{  \
+   if (tape->debug_mask & lvl) \
+   printk(KERN_INFO "ide-tape: " fmt, ## args);\
+}
+#else
+#define debug_log(lvl, fmt, args...) do {} while (0)
+#endif
+
 / Tunable parameters */
 
 
@@ -68,23 +94,6 @@
 #define IDETAPE_INCREASE_STAGES_RATE20
 
 /*
- * The following are used to debug the driver:
- *
- * Setting IDETAPE_DEBUG_LOG to 1 will log driver flow control.s
- *
- * Setting them to 0 will restore normal operation mode:
- *
- * 1.  Disable logging normal successful operations.
- * 2.  Disable self-sanity checks.
- * 3.  Errors will still be logged, of course.
- *
- * All the #if DEBUG code will be removed some day, when the driver
- * is verified to be stable enough. This will make it much more
- * esthetic.
- */
-#define IDETAPE_DEBUG_LOG  0
-
-/*
  * After each failed packet command we issue a request sense command
  * and retry the packet command IDETAPE_MAX_PC_RETRIES times.
  *
@@ -451,18 +460,7 @@ typedef struct ide_tape_obj {
unsigned long uncontrolled_previous_head_time;
int restart_speed_control_req;
 
-/*
- * Debug_level determines amount of debugging output;
- * can be changed using /proc/ide/hdx/settings
- * 0 : almost no debugging output
- * 1 : 0+output errors only
- * 2 : 1+output all sensekey/asc
- * 3 : 2+follow all chrdev related procedures
- * 4 : 3+follow all procedures
- * 5 : 4+include pc_stack rq_stack info
- * 6 : 5+USE_COUNT updates
- */
- int debug_level; 
+   u32 debug_mask;
 } idetape_tape_t;
 
 static DEFINE_MUTEX(idetape_ref_mutex);
@@ -716,11 +714,8 @@ static idetape_pc_t *idetape_next_pc_storage (ide_drive_t 
*drive)
 {
idetape_tape_t *tape = drive->driver_data;
 
-#if IDETAPE_DEBUG_LOG
-   if (tape->debug_level >= 5)
-   printk(KERN_INFO "ide-tape: pc_stack_index=%d\n",
-   tape->pc_stack_index);
-#endif /* IDETAPE_DEBUG_LOG */
+   debug_log(DBG_PCRQ_STACK, "pc_stack_index=%d\n", tape->pc_stack_index);
+
if (tape->pc_stack_index == IDETAPE_PC_STACK)
tape->pc_stack_index=0;
return (&tape->pc_stack[tape->pc_stack_index++]);
@@ -743,11 +738,8 @@ static struct request *idetape_next_rq_storage 
(ide_drive_t *drive)
 {
idetape_tape_t *tape = drive->driver_data;
 
-#if IDETAPE_DEBUG_LOG
-   if (tape->debug_level >= 5)
-   printk(KERN_INFO "ide-tape: rq_stack_index=%d\n",
-   tape->rq_stack_index);
-#endif /* IDETAPE_DEBUG_LOG */
+   debug_log(DBG_PCRQ_STACK, "rq_stack_index=%d\n", tape->rq_stack_index);
+
if (tape->rq_stack_index == IDETAPE_PC_STACK)
tape->rq_stack_index=0;
return (&tape->rq_stack[tape->rq_stack_index++]);
@@ -780,17 +772,9 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 
*sense)
tape->sense_key = sense[2] & 0xF;
tape->asc   = sense[12];
tape->ascq  = sense[13];
-#if IDETAPE_DEBUG_LOG
-  

[PATCH 02/22] ide-tape: remove struct idetape_read_position_result_t

2008-02-04 Thread Borislav Petkov
There should be no functional changes resulting from this patch.

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |   49 +--
 1 files changed, 18 insertions(+), 31 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 442d71c..c8c57ab 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -571,24 +571,6 @@ struct idetape_id_gcw {
unsigned protocol   :2; /* Protocol type */
 };
 
-/*
- * READ POSITION packet command - Data Format (From Table 6-57)
- */
-typedef struct {
-   unsignedreserved0_10:2; /* Reserved */
-   unsignedbpu :1; /* Block Position Unknown */
-   unsignedreserved0_543   :3; /* Reserved */
-   unsignedeop :1; /* End Of Partition */
-   unsignedbop :1; /* Beginning Of Partition */
-   u8  partition;  /* Partition Number */
-   u8  reserved2, reserved3;   /* Reserved */
-   u32 first_block;/* First Block Location */
-   u32 last_block; /* Last Block Location 
(Optional) */
-   u8  reserved12; /* Reserved */
-   u8  blocks_in_buffer[3];/* Blocks In Buffer - 
(Optional) */
-   u32 bytes_in_buffer;/* Bytes In Buffer (Optional) */
-} idetape_read_position_result_t;
-
 /* Structures related to the SELECT SENSE / MODE SENSE packet commands. */
 #define IDETAPE_BLOCK_DESCRIPTOR   0
 #defineIDETAPE_CAPABILITIES_PAGE   0x2a
@@ -1999,30 +1981,35 @@ static void idetape_wait_for_request (ide_drive_t 
*drive, struct request *rq)
spin_lock_irq(&tape->spinlock);
 }
 
-static ide_startstop_t idetape_read_position_callback (ide_drive_t *drive)
+static ide_startstop_t idetape_read_position_callback(ide_drive_t *drive)
 {
idetape_tape_t *tape = drive->driver_data;
-   idetape_read_position_result_t *result;
+   u8 *readpos = tape->pc->buffer;
 
debug_log(DBG_PROCS, "Enter %s\n", __func__);
 
if (!tape->pc->error) {
-   result = (idetape_read_position_result_t *) tape->pc->buffer;
-   debug_log(DBG_SENSE, "BOP - %s\n", result->bop ? "Yes" : "No");
-   debug_log(DBG_SENSE, "EOP - %s\n", result->eop ? "Yes" : "No");
+   debug_log(DBG_SENSE, "BOP - %s\n",
+   !!(readpos[0] & 0x80) ? "Yes" : "No");
+   debug_log(DBG_SENSE, "EOP - %s\n",
+   !!(readpos[0] & 0x40) ? "Yes" : "No");
+
+   if (!!(readpos[0] & 0x4)) {
+   printk(KERN_INFO "ide-tape: Block location is unknown"
+   "to the tape\n");
 
-   if (result->bpu) {
-   printk(KERN_INFO "ide-tape: Block location is unknown 
to the tape\n");
clear_bit(IDETAPE_ADDRESS_VALID, &tape->flags);
idetape_end_request(drive, 0, 0);
} else {
debug_log(DBG_SENSE, "Block Location - %u\n",
-   ntohl(result->first_block));
-
-   tape->partition = result->partition;
-   tape->first_frame_position = ntohl(result->first_block);
-   tape->last_frame_position = ntohl(result->last_block);
-   tape->blocks_in_buffer = result->blocks_in_buffer[2];
+   be32_to_cpu(*(u32 *)&readpos[4]));
+
+   tape->partition = readpos[1];
+   tape->first_frame_position =
+   be32_to_cpu(*(u32 *)&readpos[4]);
+   tape->last_frame_position =
+   be32_to_cpu(*(u32 *)&readpos[8]);
+   tape->blocks_in_buffer = readpos[15];
set_bit(IDETAPE_ADDRESS_VALID, &tape->flags);
idetape_end_request(drive, 1, 0);
}
-- 
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


Re: [PATCH] ide-tape: dump gcw fields on error in idetape_identify_device()

2008-02-04 Thread Borislav Petkov
On Sun, Feb 03, 2008 at 08:16:42PM +0300, Sergei Shtylyov wrote:
> Bartlomiej Zolnierkiewicz wrote:
>
>> Signed-off-by: Bartlomiej Zolnierkiewicz <[EMAIL PROTECTED]>
>
> Acked-by: Sergei Shtylyov <[EMAIL PROTECTED]>
>
>> Index: b/drivers/ide/ide-tape.c
>> ===
>> --- a/drivers/ide/ide-tape.c
>> +++ b/drivers/ide/ide-tape.c
>> @@ -3852,16 +3852,17 @@ static int idetape_identify_device (ide_
>>  /* Check that we can support this device */
>>  -   if (gcw.protocol !=2 )
>> -printk(KERN_ERR "ide-tape: Protocol is not ATAPI\n");
>> +if (gcw.protocol != 2)
>> +printk(KERN_ERR "ide-tape: Protocol (0x%02x) is not ATAPI\n",
>> +gcw.protocol);
>>  else if (gcw.device_type != 1)
>> -printk(KERN_ERR "ide-tape: Device type is not set to tape\n");
>> +printk(KERN_ERR "ide-tape: Device type (0x%02x) is not set "
>> +"to tape\n", gcw.device_type);
>>  else if (!gcw.removable)
>>  printk(KERN_ERR "ide-tape: The removable flag is not set\n");
>>  else if (gcw.packet_size != 0) {
>> -printk(KERN_ERR "ide-tape: Packet size is not 12 bytes long\n");
>> -if (gcw.packet_size == 1)
>> -printk(KERN_ERR "ide-tape: Sorry, padding to 16 bytes 
>> is still not supported\n");
>> +printk(KERN_ERR "ide-tape: Packet size (0x%02x) is not 12 "
>> +"bytes long\n", gcw.packet_size);
>
>Shouldn't it be either "packet size is not 12 byted" or "packet is not 
> 12 bytes long"?

I like the last one better. Will send a correction later on to Bart. Thanks.

-- 
Regards/Gruß,
Boris.
-
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 23/32] ide-tape: struct idetape_tape_t: shorten member names

2008-02-03 Thread Borislav Petkov
On Sun, Feb 03, 2008 at 12:43:22AM +0100, Bartlomiej Zolnierkiewicz wrote:

Hi,

[...]

> Even if this patch contains only trivial changes, the amount of them
> and the fact that it intermixes different logical changes (shortening
> names, dead code removal and comments beautification) makes it somehow
> non-trivial to review.
> 
> General comment:
> please have some mercy on the reviewer (in this case me ;) and spread
> the changes across more patches (it should also be easier for you since
> with more patches it is more likely that the more changes get applied
> the first time and you will have less code to recast/resubmit).
>

sorry about that, i tend to forget myself sometimes when going over the code and
wanting to fix all in one go. Concerning the shortening of the variable names -
i wanted to make them as short as possible so that i have less lines > 80 and
not have to break them and make them less readable. Will redo.

Thanks.

-- 
Regards/Gruß,
Boris.
-
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: kernel BUG at ide-cd.c:1726 in 2.6.24-03863-g0ba6c33 && -g8561b089

2008-02-01 Thread Borislav Petkov
On Fri, Feb 01, 2008 at 12:39:27PM -0500, Kiyoshi Ueda wrote:



> > > end_that_request_last() is not called when __blk_end_reuqest()
> > > returns 1.  Then, the issuer isn't waken up.
> > > So I think the BUG() or error messages should be there.
> > 
> > you mean, end_that_request_last() isn't called when 
> > __end_that_request_first()
> > returns an error and this is the case only for fs and pc requests.
> > Otherwise it _is_ called, thus simulating somewhat the previous behavior.
> > However, we never BUG()'ged on residual byte counts before and
> > this driver has been in the kernel tree for ages, so what puzzles
> > me now is how is BUG()'ing here better than before and shouldn't we
> > simply issue a warning instead of killing the interrupt handler...
> 
> The Jens' patch passes the residual byte counts to __blk_end_request(),
> so __end_that_reqeust_first() should never return 1 and we should never
> BUG() on the residual byte counts, unless inconsistency happens such as
> the size of remaining bios is bigger than the residual byte counts.

yep.

> So if __blk_end_request() returns 1 even with the Jens' patch,
> it means that the block layer or the driver really have a bug.
> And then, the request and the bios could leak or the issuer
> would wait forever because end_that_request_last() isn't called.
> 
> The previous behavior might ignore such inconsistency and leak only
> the bios because it was calling end_that_request_last() anyway.
> I would like to BUG() in such cases personally, but I don't object
> strongly if you prefer not to BUG().

BUG() is definitely what we should do here to catch this case of sizeof(bios) >
rq->data_len. Putting a brown paper bag over the issue will never get it fixed
if it really leaks bios. Thanks for clarifying that.

By the way, shouldn't we be doing a little branch prediction here:

diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 74c6087..bee05a3 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1722,7 +1722,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t 
*drive)
 */
if ((stat & DRQ_STAT) == 0) {
spin_lock_irqsave(&ide_lock, flags);
-   if (__blk_end_request(rq, 0, 0))
+   if (unlikely(__blk_end_request(rq, 0, rq->data_len)))
BUG();
HWGROUP(drive)->rq = NULL;
spin_unlock_irqrestore(&ide_lock, flags);


-- 
Regards/Gruß,
Boris.
-
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 0/32] ide-tape redux v1

2008-02-01 Thread Borislav Petkov
On Wed, Jan 30, 2008 at 01:29:55AM +0100, Bartlomiej Zolnierkiewicz wrote:
> On Monday 28 January 2008, Borislav Petkov wrote:
> > Hi Bart,
> > 
> > [...]
> > 
> > > > the BKL in idetape_write_release() with finer-grained locking etc, 
> > > > probably also
> > > > some pipeline improvements, removal of OnStream support, etc. but 
> > > > that'll come
> > > > later.
> > > 
> > > On-Stream support has been long gone but it seems that deprecation
> > > warning etc. managed to survive.
> > > 
> > > w.r.t. to the pipeline-mode: it should be pipelined into /dev/null
> > > 
> > > rationale:
> > > - it is _very_ complex
> > > - causes errors to be deferred till the next user-space access
> > > - direct I/O using blk_rq_map_user() will offer superior performance
> > > 
> > > the only question is whether to remove it...
> > 
> > Well, on the one hand, since the driver is only being maintained we should 
> > not
> > remove code that works. Also, i don't know how many users ide-tape really 
> > has
> > but, would it be worth the trouble at all? Because if nobody's using it, we
> > could just as well pipe the whole thing into /dev/null.. On the other hand, 
> > the
> 
> This may be the other alternative... [ there is always libata PATA... ]
> 
> If you want to give ide-tape removal a try, go ahead (I suggest starting
> with adding warning printk() and keeping patch in -mm for some time)...

Well, we don't have any numbers on whether someone is using the driver at all,
so i probably the best thing we should do is give it a grace period of 1/2 year
before we get rid of it. In the meantime, let's see how many souls cry out :)

---
commit 5b4566d1ed9b050d53d776285da84f8c3cc13d2c
Author: Borislav Petkov <[EMAIL PROTECTED]>
Date:   Fri Feb 1 09:12:02 2008 +0100

ide-tape: schedule driver for removal after 6 months in case it doesn't have
any users left.

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>

diff --git a/Documentation/feature-removal-schedule.txt 
b/Documentation/feature-removal-schedule.txt
index 20c4c8b..21d71a9 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -333,3 +333,13 @@ Why:   This driver has been marked obsolete for many 
years.
 Who:   Stephen Hemminger <[EMAIL PROTECTED]>
 
 ---
+
+What:  ide-tape driver
+When:  July 2008
+Files: drivers/ide/ide-tape.c
+Why:   This driver might not have any users anymore and maintaining it for no
+   reason is an effort no one wants to make.
+Who:   Bartlomiej Zolnierkiewicz <[EMAIL PROTECTED]>, Borislav Petkov
+   <[EMAIL PROTECTED]>
+
+---
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index f51712c..fd81f4c 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -3829,6 +3829,11 @@ static int ide_tape_probe(ide_drive_t *drive)
g->fops = &idetape_block_ops;
ide_register_region(g);
 
+   printk(KERN_WARNING "It is possible that this driver does not have any"
+   " users anymore and, as a result, it will be REMOVED soon."
+   " Please notify Bart <[EMAIL PROTECTED]> or Boris"
+   " <[EMAIL PROTECTED]> in case you still need it.\n");
+
return 0;
 
 out_free_tape:

-- 
Regards/Gruß,
Boris.
-
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: kernel BUG at ide-cd.c:1726 in 2.6.24-03863-g0ba6c33 && -g8561b089

2008-01-31 Thread Borislav Petkov
On Thu, Jan 31, 2008 at 05:35:56PM -0500, Kiyoshi Ueda wrote:
> Hi Boris,
> 
> Thank you for the confirmation of original behavior.
> 
> On Thu, 31 Jan 2008 22:37:40 +0100, Borislav Petkov wrote:
> > On Thu, Jan 31, 2008 at 02:05:58PM +0100, Jens Axboe wrote:
> > > On Thu, Jan 31 2008, Nai Xia wrote:
> > > > My dmesg relevant info is quite similar:
> > > > 
> > > > [6.875041] Freeing unused kernel memory: 320k freed
> > > > [8.143120] ide-cd: rq still having bio: dev hdc: type=2, flags=114c8
> > > > [8.144439]
> > > > [8.144439] sector 10824201199534213, nr/cnr 0/0
> > > > [8.144439] bio cf029280, biotail cf029280, buffer , data
> > > > , len 158
> > > > [8.144439] cdb: 12 00 00 00 fe 00 00 00 00 00 00 00 00 00 00 00
> > > > [8.144439] backup: data_len=158  bi_size=158
> > > > [8.160756] ide-cd: rq still having bio: dev hdc: type=2, flags=114c8
> > > > [8.160756]
> > > > [8.160756] sector 2669858, nr/cnr 0/0
> > > > [8.160756] bio cf029300, biotail cf029300, buffer , data
> > > > , len 158
> > > > [8.160756] cdb: 12 01 00 00 fe 00 00 00 00 00 00 00 00 00 00 00
> > > > [8.160756] backup: data_len=158  bi_size=158
> > > > [   14.851101] eth0: link up
> > > > [   27.121883] eth0: no IPv6 routers present
> > > > 
> > > > 
> > > > And by the way, Kiyoshi,
> > > > This can be reproduced in a typical setup vmware workstation 6.02 with
> > > > a vritual IDE cdrom,
> > > > in case you wanna catch that with your own eyes. :-)
> > > > Thanks for your trying hard to correct this annoying bug.
> > > 
> > > The below fix should be enough. It's perfectly legal to have leftover
> > > byte counts when the drive signals completion, happens all the time for
> > > eg user issued commands where you don't know an exact byte count.
> > 
> > Actually, this behavior has been the case even before the 
> > __blk_end_request()
> > changes. I did test plain 2.6.24 with the following
> > 
> > 
> > --- linux-2.6/drivers/ide/ide-cd.c  2008-01-31 22:18:59.0 +0100
> > +++ linux-2.6/drivers/ide/ide-cd.c-new  2008-01-31 22:18:50.0 
> > +0100
> > @@ -1711,8 +1711,12 @@ static ide_startstop_t cdrom_newpc_intr(
> > /*
> >  * If DRQ is clear, the command has completed.
> >  */
> > -   if ((stat & DRQ_STAT) == 0)
> > +   if ((stat & DRQ_STAT) == 0) {
> > +   blk_dump_rq_flags(rq, "ide-cd: rq still having bio");
> > +   printk("backup: data_len=%u  bi_size=%u\n",
> > +   rq->data_len, rq->bio->bi_size);
> > goto end_request;
> > +   }
> >  
> > /*
> >  * check which way to transfer data
> > 
> > 
> > to see whether we've been getting residual byte counts:
> > 
> > Jan 31 22:10:06 gollum kernel: [   26.702877] ide-cd: rq still having bio: 
> > dev hdc: type=2, flags=114c8
> > Jan 31 22:10:06 gollum kernel: [   26.702945]
> > Jan 31 22:10:06 gollum kernel: [   26.702946] sector 2673511, nr/cnr 0/0
> > Jan 31 22:10:06 gollum kernel: [   26.703052] bio dfa8ec40, biotail 
> > dfa8ec40, buffer , data , len 158
> > Jan 31 22:10:06 gollum kernel: [   26.703122] cdb: 12 00 00 00 fe 00 00 00 
> > 00 00 00 00 00 00 00 00
> > Jan 31 22:10:06 gollum kernel: [   26.703877] backup: data_len=158  
> > bi_size=158
> > 
> > ... so we've been simply silently ignoring this until now so i guess we 
> > don't
> > need to BUG() for something that's totally benign.

Hi Kiyoshi,
 
> end_that_request_last() is not called when __blk_end_reuqest()
> returns 1.  Then, the issuer isn't waken up.
> So I think the BUG() or error messages should be there.

you mean, end_that_request_last() isn't called when __end_that_request_first()
returns an error and this is the case only for fs and pc requests. Otherwise it
_is_ called, thus simulating somewhat the previous behavior. However, we never 
BUG()'ged
on residual byte counts before and this driver has been in the kernel tree for
ages, so what puzzles me now is how is BUG()'ing here better than before and
shouldn't we simply issue a warning instead of killing the interrupt handler...

..or am i missing something?

-- 
Regards/Gruß,
Boris.
-
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: kernel BUG at ide-cd.c:1726 in 2.6.24-03863-g0ba6c33 && -g8561b089

2008-01-31 Thread Borislav Petkov
On Thu, Jan 31, 2008 at 02:05:58PM +0100, Jens Axboe wrote:
> On Thu, Jan 31 2008, Nai Xia wrote:
> > My dmesg relevant info is quite similar:
> > 
> > [6.875041] Freeing unused kernel memory: 320k freed
> > [8.143120] ide-cd: rq still having bio: dev hdc: type=2, flags=114c8
> > [8.144439]
> > [8.144439] sector 10824201199534213, nr/cnr 0/0
> > [8.144439] bio cf029280, biotail cf029280, buffer , data
> > , len 158
> > [8.144439] cdb: 12 00 00 00 fe 00 00 00 00 00 00 00 00 00 00 00
> > [8.144439] backup: data_len=158  bi_size=158
> > [8.160756] ide-cd: rq still having bio: dev hdc: type=2, flags=114c8
> > [8.160756]
> > [8.160756] sector 2669858, nr/cnr 0/0
> > [8.160756] bio cf029300, biotail cf029300, buffer , data
> > , len 158
> > [8.160756] cdb: 12 01 00 00 fe 00 00 00 00 00 00 00 00 00 00 00
> > [8.160756] backup: data_len=158  bi_size=158
> > [   14.851101] eth0: link up
> > [   27.121883] eth0: no IPv6 routers present
> > 
> > 
> > And by the way, Kiyoshi,
> > This can be reproduced in a typical setup vmware workstation 6.02 with
> > a vritual IDE cdrom,
> > in case you wanna catch that with your own eyes. :-)
> > Thanks for your trying hard to correct this annoying bug.
> 
> The below fix should be enough. It's perfectly legal to have leftover
> byte counts when the drive signals completion, happens all the time for
> eg user issued commands where you don't know an exact byte count.

Actually, this behavior has been the case even before the __blk_end_request()
changes. I did test plain 2.6.24 with the following


--- linux-2.6/drivers/ide/ide-cd.c  2008-01-31 22:18:59.0 +0100
+++ linux-2.6/drivers/ide/ide-cd.c-new  2008-01-31 22:18:50.0 +0100
@@ -1711,8 +1711,12 @@ static ide_startstop_t cdrom_newpc_intr(
/*
 * If DRQ is clear, the command has completed.
 */
-   if ((stat & DRQ_STAT) == 0)
+   if ((stat & DRQ_STAT) == 0) {
+   blk_dump_rq_flags(rq, "ide-cd: rq still having bio");
+   printk("backup: data_len=%u  bi_size=%u\n",
+   rq->data_len, rq->bio->bi_size);
goto end_request;
+   }
 
/*
 * check which way to transfer data


to see whether we've been getting residual byte counts:

Jan 31 22:10:06 gollum kernel: [   26.702877] ide-cd: rq still having bio: dev 
hdc: type=2, flags=114c8
Jan 31 22:10:06 gollum kernel: [   26.702945]
Jan 31 22:10:06 gollum kernel: [   26.702946] sector 2673511, nr/cnr 0/0
Jan 31 22:10:06 gollum kernel: [   26.703052] bio dfa8ec40, biotail dfa8ec40, 
buffer , data , len 158
Jan 31 22:10:06 gollum kernel: [   26.703122] cdb: 12 00 00 00 fe 00 00 00 00 
00 00 00 00 00 00 00
Jan 31 22:10:06 gollum kernel: [   26.703877] backup: data_len=158  bi_size=158

... so we've been simply silently ignoring this until now so i guess we don't
need to BUG() for something that's totally benign.

-- 
Regards/Gruß,
Boris.
-
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 0/32] ide-tape redux v1

2008-01-28 Thread Borislav Petkov
Hi Bart,

[...]

> > the BKL in idetape_write_release() with finer-grained locking etc, probably 
> > also
> > some pipeline improvements, removal of OnStream support, etc. but that'll 
> > come
> > later.
> 
> On-Stream support has been long gone but it seems that deprecation
> warning etc. managed to survive.
> 
> w.r.t. to the pipeline-mode: it should be pipelined into /dev/null
> 
> rationale:
> - it is _very_ complex
> - causes errors to be deferred till the next user-space access
> - direct I/O using blk_rq_map_user() will offer superior performance
> 
> the only question is whether to remove it...

Well, on the one hand, since the driver is only being maintained we should not
remove code that works. Also, i don't know how many users ide-tape really has
but, would it be worth the trouble at all? Because if nobody's using it, we
could just as well pipe the whole thing into /dev/null.. On the other hand, the
pipelining part _is_ kinda big and, right, it is not that straightfoward to
look at it and know what it actually does - it truly is a student project :)

> >  Documentation/ide/ChangeLog.ide-tape.1995-2002 |  405 +++
> >  drivers/ide/Kconfig|3 +-
> >  drivers/ide/ide-tape.c | 4146 
> > +---
> >  3 files changed, 1991 insertions(+), 2563 deletions(-)

[...]

> BTW what happend to patch #23?

Well, it appeared in my lkml mailbox having gone over vger which means at least
somebody got it :). But, yeah, that was a real nightmare yesterday sending all
those patches in one go. See, i got a stupid umts modem behind a not so 
transparent
proxy :) whose subnet is listed in almost every spam database on the planet
and whenever i try to send more than one mail i hit all sorts of mail server
restrictions like yahoo's maximum messages per day crap.. Gmail seems a bit
smarter ?! and scans the mail message and then says all kinds of funny stuff :):

27 10:48:31 gollum postfix/smtp[4011]: F1710123BFD: 
to=, relay=vger.kernel.org[209.132.176.167]:25,
delay=10, delays=0.19/0.29/2.7/7.2, dsn=2.7.1,  status=sent (250 2.7.1 Looks 
like Linux source DIFF email.. BF:; S1753942AbYA0Js4)

what's next, probably something like:

...(250 3.x.x uh, ok, i'm gonna relay your mail but please have another coffee, 
please) ;

Anyway, resending #23 to you in a private mail.

-- 
Regards/Gruß,
Boris.
-
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 06/32] ide-tape: remove IDETAPE_DEBUG_BUGS

2008-01-27 Thread Borislav Petkov
Hi Bart,

sorry for that thread split but i had to resend those remaining patches with
gmail because yahoo have a restriction on the number of mails one can send per
day :(

-- 
Regards/Gruß,
Boris.
-
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 30/32] ide-tape: remove atomic test/set macros

2008-01-27 Thread Borislav Petkov
From: Borislav Petkov <[EMAIL PROTECTED]>

Also remove flag IDETAPE_READ_ERROR since it is unused.

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |  222 +---
 1 files changed, 117 insertions(+), 105 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index cfb26d9..c22d7f6 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -204,25 +204,24 @@ typedef struct idetape_packet_command_s {
ide_startstop_t (*callback) (ide_drive_t *);
u8 pc_buffer[IDETAPE_PC_BUFFER_SIZE];   /* Temporary buffer */
 
-   /* Status/Action bit flags: long for set_bit */
-   unsigned long flags;
+   unsigned int flags;
 } idetape_pc_t;
 
-/*
- * Packet command flag bits.
- */
-/* Set when an error is considered normal - We won't retry */
-#definePC_ABORT0
-/* 1 When polling for DSC on a media access command */
-#define PC_WAIT_FOR_DSC1
-/* 1 when we prefer to use DMA if possible */
-#define PC_DMA_RECOMMENDED 2
-/* 1 while DMA in progress */
-#definePC_DMA_IN_PROGRESS  3
-/* 1 when encountered problem during DMA */
-#definePC_DMA_ERROR4
-/* Data direction */
-#definePC_WRITING  5
+/* Packet command flag bits. */
+enum {
+   /* Set when an error is considered normal - We won't retry */
+   PC_FL_ABORT = (1 << 0),
+   /* 1 When polling for DSC on a media access command */
+   PC_FL_WAIT_FOR_DSC  = (1 << 1),
+   /* 1 when we prefer to use DMA if possible */
+   PC_FL_DMA_RECOMMENDED   = (1 << 2),
+   /* 1 while DMA in progress */
+   PC_FL_DMA_IN_PROGRESS   = (1 << 3),
+   /* 1 when encountered problem during DMA */
+   PC_FL_DMA_ERROR = (1 << 4),
+   /* Data direction */
+   PC_FL_WRITING   = (1 << 5),
+};
 
 /*
  * A pipeline stage.
@@ -350,8 +349,7 @@ typedef struct ide_tape_obj {
/* Wasted space in each stage */
int excess_bh_size;
 
-   /* Status/Action flags: long for set_bit */
-   unsigned long flags;
+   unsigned int flags;
/* protects the ide-tape queue */
spinlock_t que_lock;
 
@@ -460,20 +458,26 @@ static void ide_tape_put(struct ide_tape_obj *tape)
 #define DOOR_LOCKED1
 #define DOOR_EXPLICITLY_LOCKED 2
 
-/*
- * Tape flag bits values.
- */
-#define IDETAPE_IGNORE_DSC 0
-#define IDETAPE_ADDRESS_VALID  1   /* 0 When the tape position is 
unknown */
-#define IDETAPE_BUSY   2   /* Device already opened */
-#define IDETAPE_PIPELINE_ERROR 3   /* Error detected in a pipeline 
stage */
-#define IDETAPE_DETECT_BS  4   /* Attempt to auto-detect the 
current user block size */
-#define IDETAPE_FILEMARK   5   /* Currently on a filemark */
-#define IDETAPE_DRQ_INTERRUPT  6   /* DRQ interrupt device */
-#define IDETAPE_READ_ERROR 7
-#define IDETAPE_PIPELINE_ACTIVE8   /* pipeline active */
-/* 0 = no tape is loaded, so we don't rewind after ejecting */
-#define IDETAPE_MEDIUM_PRESENT 9
+/* Tape flag bits values. */
+enum {
+   IDETAPE_FL_IGNORE_DSC   = (1 << 0),
+   /* 0 When the tape position is unknown */
+   IDETAPE_FL_ADDRESS_VALID= (1 << 1),
+   /* Device already opened */
+   IDETAPE_FL_BUSY = (1 << 2),
+   /* Error detected in a pipeline stage */
+   IDETAPE_FL_PIPELINE_ERR = (1 << 3),
+   /* Attempt to auto-detect the current user block size */
+   IDETAPE_FL_DETECT_BS= (1 << 4),
+   /* Currently on a filemark */
+   IDETAPE_FL_FILEMARK = (1 << 5),
+   /* DRQ interrupt device */
+   IDETAPE_FL_DRQ_INTERRUPT= (1 << 6),
+   /* pipeline active */
+   IDETAPE_FL_PIPELINE_ACTIVE  = (1 << 7),
+   /* 0 = no tape is loaded, so we don't rewind after ejecting */
+   IDETAPE_FL_MEDIUM_PRESENT   = (1 << 8),
+};
 
 /*
  * Some defines for the READ BUFFER command
@@ -638,7 +642,7 @@ static void idetape_update_buffers (idetape_pc_t *pc)
int count;
unsigned int bcount = pc->xferred;
 
-   if (test_bit(PC_WRITING, &pc->flags))
+   if (pc->flags & PC_FL_WRITING)
return;
while (bcount) {
if (bh == NULL) {
@@ -715,7 +719,7 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 
*sense)
 pc->c[0], tape->sense_key, tape->asc, tape->ascq);
 
/* Correct pc->xferred by asking the tape.   */
-   if (test_bit(PC_DMA_ERROR, &pc->flags)) {
+   if (pc->flags &

[PATCH 22/32] ide-tape: struct idetape_packet_command_s: shorten member names

2008-01-27 Thread Borislav Petkov
From: Borislav Petkov <[EMAIL PROTECTED]>

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |   88 ---
 1 files changed, 45 insertions(+), 43 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index b487d56..4690f71 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -193,24 +193,25 @@ struct idetape_bh {
char *b_data;
 };
 
-/*
- * Our view of a packet command.
- */
 typedef struct idetape_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 */
+   u8 c[12];   /* Actual packet bytes */
+   int retries;/* On each retry, we increment retries */
+   int error;  /* Error code */
+   int rq_xfer;/* Request bytes to transfer */
+   int xferred;/* Bytes actually transferred */
+   int buf_size;   /* Size of our data buffer */
struct idetape_bh *bh;
char *b_data;
int b_count;
-   u8 *buffer; /* Data buffer */
-   u8 *current_position;   /* Pointer into the above 
buffer */
-   ide_startstop_t (*callback) (ide_drive_t *);/* Called when this 
packet command is completed */
+   u8 *buffer; /* Data buffer */
+   u8 *cur_pos;/* Pointer into the above buffer */
+
+   /* Called when this packet command is completed */
+   ide_startstop_t (*callback) (ide_drive_t *);
u8 pc_buffer[IDETAPE_PC_BUFFER_SIZE];   /* Temporary buffer */
-   unsigned long flags;/* Status/Action bit flags: 
long for set_bit */
+
+   /* Status/Action bit flags: long for set_bit */
+   unsigned long flags;
 } idetape_pc_t;
 
 /*
@@ -684,7 +685,7 @@ static void idetape_update_buffers (idetape_pc_t *pc)
 {
struct idetape_bh *bh = pc->bh;
int count;
-   unsigned int bcount = pc->actually_transferred;
+   unsigned int bcount = pc->xferred;
 
if (test_bit(PC_WRITING, &pc->flags))
return;
@@ -752,9 +753,9 @@ static void idetape_init_pc (idetape_pc_t *pc)
memset(pc->c, 0, 12);
pc->retries = 0;
pc->flags = 0;
-   pc->request_transfer = 0;
+   pc->rq_xfer = 0;
pc->buffer = pc->pc_buffer;
-   pc->buffer_size = IDETAPE_PC_BUFFER_SIZE;
+   pc->buf_size = IDETAPE_PC_BUFFER_SIZE;
pc->bh = NULL;
pc->b_data = NULL;
 }
@@ -775,9 +776,9 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 
*sense)
debug_log(DBG_ERR, "pc = %x, sense key = %x, asc = %x, ascq = %x\n",
 pc->c[0], tape->sense_key, tape->asc, tape->ascq);
 
-   /* Correct pc->actually_transferred by asking the tape.  */
+   /* Correct pc->xferred by asking the tape.   */
if (test_bit(PC_DMA_ERROR, &pc->flags)) {
-   pc->actually_transferred = pc->request_transfer -
+   pc->xferred = pc->rq_xfer -
tape->tape_block_size *
be32_to_cpu(get_unaligned((u32 *)&sense[3]));
idetape_update_buffers(pc);
@@ -817,7 +818,7 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 
*sense)
set_bit(PC_ABORT, &pc->flags);
}
if (!test_bit(PC_ABORT, &pc->flags) &&
-   pc->actually_transferred)
+   pc->xferred)
pc->retries = IDETAPE_MAX_PC_RETRIES + 1;
}
 }
@@ -1047,7 +1048,7 @@ static void idetape_create_request_sense_cmd 
(idetape_pc_t *pc)
idetape_init_pc(pc);
pc->c[0] = REQUEST_SENSE;
pc->c[4] = 20;
-   pc->request_transfer = 20;
+   pc->rq_xfer = 20;
pc->callback = &idetape_request_sense_callback;
 }
 
@@ -1172,7 +1173,7 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t 
*drive)
 */
set_bit(PC_DMA_ERROR, &pc->flags);
} else {
-   pc->actually_transferred = pc->request_transfer;
+   pc->xferred = pc->rq_xfer;
idetape_update_buffers(pc);
}
debug_log(DBG_PROCS, "DMA finished\n");
@@ -1182,7 +1183,7 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t 
*drive)
   

[PATCH 24/32] ide-tape: remove unreachable code chunk

2008-01-27 Thread Borislav Petkov
From: Borislav Petkov <[EMAIL PROTECTED]>

tape->speed_ctl is set to 1 in idetape_setup(), but, in calculate_speeds() its
value is tested for being 0, 1, or 2. Remove the if-branches where
tape->speed_ctl != 1 since they are never executed.

Also, rename calculate_speeds() by adding driver's prefix as is with the other
function names.

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |   23 +--
 1 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 31edb0c..eab552e 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -61,7 +61,8 @@
  * the optimum value or until we reach MAX.
  *
  * Setting the following parameter to 0 is illegal: the pipelined mode
- * cannot be disabled (calculate_speeds() divides by tape->max_stages.)
+ * cannot be disabled (idetape_calculate_speeds() divides by
+ * tape->max_stages.)
  */
 #define IDETAPE_MIN_PIPELINE_STAGES  1
 #define IDETAPE_MAX_PIPELINE_STAGES400
@@ -1462,10 +1463,9 @@ static void idetape_create_mode_sense_cmd (idetape_pc_t 
*pc, u8 page_code)
pc->callback = &idetape_pc_callback;
 }
 
-static void calculate_speeds(ide_drive_t *drive)
+static void idetape_calculate_speeds(ide_drive_t *drive)
 {
idetape_tape_t *tape = drive->driver_data;
-   int full = 125, empty = 75;
 
if (time_after(jiffies, tape->ctl_pipe_htime + 120 * HZ)) {
tape->ctl_prev_pipe_h = tape->ctl_last_pipe_h;
@@ -1497,9 +1497,8 @@ static void calculate_speeds(ide_drive_t *drive)
tape->unctl_pipe_htime = jiffies;
}
tape->pipe_hspeed = max(tape->unctl_pipe_hspeed, tape->pipe_ctl_hspeed);
-   if (tape->speed_ctl == 0) {
-   tape->max_ins_speed = 5000;
-   } else if (tape->speed_ctl == 1) {
+
+   if (tape->speed_ctl == 1) {
if (tape->nr_pending_stages >= tape->max_stages / 2)
tape->max_ins_speed = tape->pipe_hspeed +
(1100 - tape->pipe_hspeed) * 2 *
@@ -1511,13 +1510,9 @@ static void calculate_speeds(ide_drive_t *drive)
tape->nr_pending_stages / tape->max_stages;
if (tape->nr_pending_stages >= tape->max_stages * 99 / 100)
tape->max_ins_speed = 5000;
-   } else if (tape->speed_ctl == 2) {
-   tape->max_ins_speed = tape->pipe_hspeed * empty / 100 +
-   (tape->pipe_hspeed * full / 100 - tape->pipe_hspeed *
-empty / 100) * tape->nr_pending_stages
-   / tape->max_stages;
} else
tape->max_ins_speed = tape->speed_ctl;
+
tape->max_ins_speed = max(tape->max_ins_speed, 500);
 }
 
@@ -1696,7 +1691,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t 
*drive,
if (time_after(jiffies, tape->ins_time))
tape->ins_speed = tape->ins_size / 1024 * HZ /
(jiffies - tape->ins_time);
-   calculate_speeds(drive);
+   idetape_calculate_speeds(drive);
if (!test_and_clear_bit(IDETAPE_IGNORE_DSC, &tape->flags) &&
(stat & SEEK_STAT) == 0) {
if (postponed_rq == NULL) {
@@ -2416,7 +2411,7 @@ static int idetape_add_chrdev_write_request (ide_drive_t 
*drive, int blocks)
idetape_switch_buffers(tape, new_stage);
idetape_add_stage_tail(drive, new_stage);
tape->pipeline_head++;
-   calculate_speeds(drive);
+   idetape_calculate_speeds(drive);
 
/*
 *  Estimate whether the tape has stopped writing by checking
@@ -2658,7 +2653,7 @@ static int idetape_add_chrdev_read_request (ide_drive_t 
*drive,int blocks)
idetape_remove_stage_head(drive);
spin_unlock_irqrestore(&tape->que_lock, flags);
tape->pipeline_head++;
-   calculate_speeds(drive);
+   idetape_calculate_speeds(drive);
}
if (bytes_read > blocks * tape->blk_sz) {
printk(KERN_ERR "ide-tape: bug: trying to return more bytes 
than requested\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


[PATCH 23/32] ide-tape: struct idetape_tape_t: shorten member names

2008-01-27 Thread Borislav Petkov
From: Borislav Petkov <[EMAIL PROTECTED]>

Some member names are self-explanatory, so remove their respective
comments. Also, explain the exact purpose of struct members in comments
in the struct definition instead of using excessively long member names
thus replacing then with a shorter, more handy version.

Finally, remove unused members:
- last_frame_position: only being written to once
- firmware_revision: used once, remove from struct idetape_tape_t and deal with
it locally
- firmware_revision_num: only written to once
- tape_still_time_begin: completely unused
- tape_still_time: never written to; remove corresponding code chunk
- uncontrolled_last_pipeline_head: only once written to

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |  673 +++
 1 files changed, 329 insertions(+), 344 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 4690f71..31edb0c 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -240,9 +240,9 @@ typedef struct idetape_stage_s {
 } idetape_stage_t;
 
 /*
- * Most of our global data which we need to save even as we leave the
- * driver due to an interrupt or a timer event is stored in a variable
- * of type idetape_tape_t, defined below.
+ * Most of our global data which we need to save even as we leave the driver 
due
+ * to an interrupt or a timer event is stored in a variable of type
+ * idetape_tape_t, defined below.
  */
 typedef struct ide_tape_obj {
ide_drive_t *drive;
@@ -251,42 +251,41 @@ typedef struct ide_tape_obj {
struct kref kref;
 
/*
-*  Since a typical character device operation requires more
-*  than one packet command, we provide here enough memory
-*  for the maximum of interconnected packet commands.
-*  The packet commands are stored in the circular array pc_stack.
-*  pc_stack_index points to the last used entry, and warps around
-*  to the start when we get to the last array entry.
-*
-*  pc points to the current processed packet command.
-*
-*  failed_pc points to the last failed packet command, or contains
-*  NULL if we do not need to retry any packet command. This is
-*  required since an additional packet command is needed before the
-*  retry, to get detailed information on what went wrong.
+* Since a typical chrdev operation requires more than one packet
+* command, we provide here enough memory for the maximum of
+* interconnected packet commands. The packet commands are stored in the
+* circular array pc_stack. pc_stack_index points to the last used
+* entry, and warps around to the start when we get to the last array
+* entry.
 */
-   /* Current packet command */
+
+   /* current packet command */
idetape_pc_t *pc;
-   /* Last failed packet command */
+
+   /*
+* the last failed packet command, or NULL if we do not need to retry
+* any packet command. This is required since an additional packet
+* command is needed before the retry, to get detailed information on
+* what went wrong.
+*/
idetape_pc_t *failed_pc;
-   /* Packet command stack */
+
idetape_pc_t pc_stack[IDETAPE_PC_STACK];
/* Next free packet command storage space */
-   int pc_stack_index;
+   int pc_stack_idx;
struct request rq_stack[IDETAPE_PC_STACK];
/* We implement a circular array */
-   int rq_stack_index;
+   int rq_stack_idx;
 
/*
-*  DSC polling variables.
+* DSC polling variables.
 *
-*  While polling for DSC we use postponed_rq to postpone the
-*  current request so that ide.c will be able to service
-*  pending requests on the other device. Note that at most
-*  we will have only one DSC (usually data transfer) request
-*  in the device request queue. Additional requests can be
-*  queued in our internal pipeline, but they will be visible
-*  to ide.c only one at a time.
+* While polling for DSC we use postponed_rq to postpone the current
+* request so that ide.c will be able to service pending requests on the
+* other device. Note that at most we will have only one DSC (usually
+* data transfer) request in the device request queue. Additional
+* requests can be queued in our internal pipeline, but they will be
+* visible to ide.c only one at a time.
 */
struct request *postponed_rq;
/* The time in which we started polling for DSC */
@@ -294,85 +293,67 @@ typedef struct ide_tape_obj {
/* Timer used to poll for dsc */
struct timer_list dsc_timer;
/* Read/Write

[RFC PATCH 26/32] ide-tape: remove packet command and struct request memory buffers

2008-01-27 Thread Borislav Petkov
From: Borislav Petkov <[EMAIL PROTECTED]>

Bart,
this one is rather intrusive so please doublecheck it wrt to kzalloc/kfree
balancing on all the codepaths so that we don't leak memory all over the place.
I free all the alloc'd pc's and rq's in idetape_end_request() which is called
from the callback idetape_pc_callback() registered with the packet command
struct when creating the respective ATAPI cmd.

---
These buffers were always statically allocated during driver initialization no
matter what. Remove them by allocating GFP_ATOMIC memory on demand. In the case
of allocation error, we only issue error msg in the *alloc_{pc,rq} thus 
postponing
the final error handling and cleanup in their callers. Packet command and
request memory is freed in idetape_end_request() which is at the end of the
request path entered from all the callbacks.

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |  122 ++-
 1 files changed, 57 insertions(+), 65 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 041edcd..3c1a7db 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -105,13 +105,6 @@ enum {
 #define IDETAPE_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 IDETAPE_PC_STACK   (10 + IDETAPE_MAX_PC_RETRIES)
-
-/*
  * Some drives (for example, Seagate STT3401A Travan) require a very long
  * timeout, because they don't return an interrupt or clear their busy bit
  * until after the command completes (even retension commands).
@@ -271,13 +264,6 @@ typedef struct ide_tape_obj {
 */
idetape_pc_t *failed_pc;
 
-   idetape_pc_t pc_stack[IDETAPE_PC_STACK];
-   /* Next free packet command storage space */
-   int pc_stack_idx;
-   struct request rq_stack[IDETAPE_PC_STACK];
-   /* We implement a circular array */
-   int rq_stack_idx;
-
/*
 * DSC polling variables.
 *
@@ -669,45 +655,32 @@ static void idetape_update_buffers (idetape_pc_t *pc)
pc->bh = bh;
 }
 
-/*
- * idetape_next_pc_storage returns a pointer to a place in which we can
- * safely store a packet command, even though we intend to leave the
- * driver. A storage space for a maximum of IDETAPE_PC_STACK packet
- * commands is allocated at initialization time.
- */
-static idetape_pc_t *idetape_next_pc_storage (ide_drive_t *drive)
+static idetape_pc_t *ide_tape_alloc_pc(void)
 {
-   idetape_tape_t *tape = drive->driver_data;
+   idetape_pc_t *pc;
 
-   debug_log(DBG_PCRQ_STACK, "pc_stack_index=%d\n", tape->pc_stack_idx);
+   pc = kzalloc(sizeof(idetape_pc_t), GFP_ATOMIC);
+   if (!pc)
+   printk(KERN_ERR "ide-tape: %s: memory allocation error.",
+   __func__);
 
-   if (tape->pc_stack_idx == IDETAPE_PC_STACK)
-   tape->pc_stack_idx = 0;
-   return (&tape->pc_stack[tape->pc_stack_idx++]);
+   return pc;
 }
 
 /*
- * idetape_next_rq_storage is used along with idetape_next_pc_storage.
- * Since we queue packet commands in the request queue, we need to
- * allocate a request, along with the allocation of a packet command.
+ * Since we queue packet commands in the request queue, we need to allocate a
+ * request, along with a packet command.
  */
- 
-/**
- **
- *  This should get fixed to use kmalloc(.., GFP_ATOMIC)  *
- *  followed later on by kfree().   -ml   *
- **
- **/
- 
-static struct request *idetape_next_rq_storage (ide_drive_t *drive)
+static struct request *ide_tape_alloc_rq(void)
 {
-   idetape_tape_t *tape = drive->driver_data;
+   struct request *rq;
 
-   debug_log(DBG_PCRQ_STACK, "rq_stack_index=%d\n", tape->rq_stack_idx);
+   rq = kzalloc(sizeof(struct request), GFP_ATOMIC);
+   if (!rq)
+   printk(KERN_ERR "ide-tape: %s: memory allocation error.",
+   __func__);
 
-   if (tape->rq_stack_idx == IDETAPE_PC_STACK)
-   tape->rq_stack_idx = 0;
-   return (&tape->rq_stack[tape->rq_stack_idx++]);
+   return rq;
 }
 
 /*
@@ -981,9 +954,8 @@ static int idetape_end_request(ide_drive_t *drive, int 
uptodate, int nr_sects)
}
}
ide_end_drive_cmd(drive, 0, 0);
-// blkdev_dequeue_request(rq);
-// drive->rq = NULL;
-// end_that_request_la

[PATCH 27/32] ide-tape: remove idetape_increase_max_pipeline_stages()

2008-01-27 Thread Borislav Petkov
From: Borislav Petkov <[EMAIL PROTECTED]>

This function was being used only at one place so fold it in there.

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |   36 
 1 files changed, 16 insertions(+), 20 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 3c1a7db..f8a4b27 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -784,25 +784,6 @@ static void idetape_activate_next_stage(ide_drive_t *drive)
 }
 
 /*
- * idetape_increase_max_pipeline_stages is a part of the feedback
- * loop which tries to find the optimum number of stages. In the
- * feedback loop, we are starting from a minimum maximum number of
- * stages, and if we sense that the pipeline is empty, we try to
- * increase it, until we reach the user compile time memory limit.
- */
-static void idetape_increase_max_pipeline_stages (ide_drive_t *drive)
-{
-   idetape_tape_t *tape = drive->driver_data;
-   int increase = (tape->max_pipeline - tape->min_pipeline) / 10;
-
-   debug_log(DBG_PROCS, "Enter %s\n", __func__);
-
-   tape->max_stages += max(increase, 1);
-   tape->max_stages = max(tape->max_stages, tape->min_pipeline);
-   tape->max_stages = min(tape->max_stages, tape->max_pipeline);
-}
-
-/*
  * idetape_kfree_stage calls kfree to completely free a stage, along with
  * its related buffers.
  */
@@ -950,7 +931,22 @@ static int idetape_end_request(ide_drive_t *drive, int 
uptodate, int nr_sects)
(void) ide_do_drive_cmd(drive, tape->act_data_rq,
ide_end);
} else if (!error) {
-   idetape_increase_max_pipeline_stages(drive);
+   /*
+* This is a part of the feedback loop which tries to
+* find the optimum number of stages. We are starting
+* from a minimum maximum number of stages, and if we
+* sense that the pipeline is empty, we try to increase
+* it, until we reach the user compile time memory
+* limit.
+*/
+   int i = (tape->max_pipeline - tape->min_pipeline) / 10;
+
+   tape->max_stages += max(i, 1);
+   tape->max_stages =
+   max(tape->max_stages, tape->min_pipeline);
+   tape->max_stages =
+   min(tape->max_stages, tape->max_pipeline);
+
}
}
ide_end_drive_cmd(drive, 0, 0);
-- 
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


[PATCH 28/32] ide-tape: shorten some function names

2008-01-27 Thread Borislav Petkov
From: Borislav Petkov <[EMAIL PROTECTED]>

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |   29 +++--
 1 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index f8a4b27..d4c4255 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -1066,7 +1066,7 @@ static void idetape_postpone_request (ide_drive_t *drive)
  * command. We will transfer some of the data (as requested by the drive) and
  * will re-point interrupt handler to us. When data transfer is finished, we
  * will act according to the algorithm described before
- * idetape_issue_packet_command.
+ * idetape_issue_pc.
  */
 
 typedef void idetape_io_buf(ide_drive_t *, idetape_pc_t *, uint);
@@ -1249,7 +1249,7 @@ static ide_startstop_t idetape_pc_intr(ide_drive_t *drive)
  *
  * The handling will be done in three stages:
  *
- * 1.  idetape_issue_packet_command will send the packet command to the
+ * 1.  idetape_issue_pc will send the packet command to the
  * drive, and will set the interrupt handler to idetape_pc_intr.
  *
  * 2.  On each interrupt, idetape_pc_intr will be called. This step
@@ -1324,7 +1324,7 @@ static ide_startstop_t idetape_transfer_pc(ide_drive_t 
*drive)
return ide_started;
 }
 
-static ide_startstop_t idetape_issue_packet_command (ide_drive_t *drive, 
idetape_pc_t *pc)
+static ide_startstop_t idetape_issue_pc(ide_drive_t *drive, idetape_pc_t *pc)
 {
ide_hwif_t *hwif = drive->hwif;
idetape_tape_t *tape = drive->driver_data;
@@ -1638,7 +1638,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t 
*drive,
 */
if (tape->failed_pc != NULL &&
tape->pc->c[0] == REQUEST_SENSE) {
-   return idetape_issue_packet_command(drive, tape->failed_pc);
+   return idetape_issue_pc(drive, tape->failed_pc);
}
if (postponed_rq != NULL)
if (rq != postponed_rq) {
@@ -1732,7 +1732,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t 
*drive,
}
BUG();
 out:
-   return idetape_issue_packet_command(drive, pc);
+   return idetape_issue_pc(drive, pc);
 
 err:
printk(KERN_ERR "ide-tape: Error processing request %u\n", rq->cmd[0]);
@@ -2290,10 +2290,10 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, 
int cmd, int blocks, struct
 }
 
 /*
- * idetape_insert_pipeline_into_queue is used to start servicing the
+ * idetape_ins_ppl_into_queue is used to start servicing the
  * pipeline stages, starting from tape->next_stage.
  */
-static void idetape_insert_pipeline_into_queue (ide_drive_t *drive)
+static void idetape_ins_ppl_into_queue(ide_drive_t *drive)
 {
idetape_tape_t *tape = drive->driver_data;
 
@@ -2385,7 +2385,7 @@ static int idetape_add_chrdev_write_request (ide_drive_t 
*drive, int blocks)
spin_unlock_irqrestore(&tape->que_lock, flags);
} else {
spin_unlock_irqrestore(&tape->que_lock, flags);
-   idetape_insert_pipeline_into_queue(drive);
+   idetape_ins_ppl_into_queue(drive);
if (idetape_pipeline_active(tape))
continue;
/*
@@ -2421,7 +2421,7 @@ static int idetape_add_chrdev_write_request (ide_drive_t 
*drive, int blocks)
tape->ins_time = jiffies;
tape->ins_size = 0;
tape->ins_speed = 0;
-   idetape_insert_pipeline_into_queue(drive);
+   idetape_ins_ppl_into_queue(drive);
}
}
if (test_and_clear_bit(IDETAPE_PIPELINE_ERROR, &tape->flags))
@@ -2440,7 +2440,7 @@ static void idetape_wait_for_pipeline (ide_drive_t *drive)
unsigned long flags;
 
while (tape->next_stage || idetape_pipeline_active(tape)) {
-   idetape_insert_pipeline_into_queue(drive);
+   idetape_ins_ppl_into_queue(drive);
spin_lock_irqsave(&tape->que_lock, flags);
if (idetape_pipeline_active(tape))
idetape_wait_for_request(drive, tape->act_data_rq);
@@ -2532,7 +2532,7 @@ static void idetape_restart_speed_control (ide_drive_t 
*drive)
tape->ctl_prev_htime = tape->unctl_prev_htime = jiffies;
 }
 
-static int idetape_initiate_read (ide_drive_t *drive, int max_stages)
+static int idetape_init_read(ide_drive_t *drive, int max_stages)
 {
idetape_tape_t *tape = drive->driver_data;
idetape_stage_t *new_stage;
@@ -2593,7 +2593,7 @@ static int idetape_initiate_read (ide_drive_t *drive, int 
max_stages)
tape->ins_time = jiffies;
tape->ins_s

[PATCH 31/32] ide-tape: remove idetape_config_t typedef

2008-01-27 Thread Borislav Petkov
From: Borislav Petkov <[EMAIL PROTECTED]>

Since this is used only in idetape_blkdev_ioctl(), remove the typedef and make
the struct function-local.

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |   23 +++
 1 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index c22d7f6..424879d 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -540,15 +540,6 @@ struct idetape_id_gcw {
 #defineIDETAPE_CAPABILITIES_PAGE   0x2a
 
 /*
- * Run time configurable parameters.
- */
-typedef struct {
-   int dsc_rw_frequency;
-   int dsc_media_access_frequency;
-   int nr_stages;
-} idetape_config_t;
-
-/*
  * The variables below are used for the character device interface.
  * Additional state variables are defined in our ide_drive_t structure.
  */
@@ -2742,14 +2733,21 @@ static int idetape_rewind_tape (ide_drive_t *drive)
 static int idetape_blkdev_ioctl(ide_drive_t *drive, unsigned int cmd, unsigned 
long arg)
 {
idetape_tape_t *tape = drive->driver_data;
-   idetape_config_t config;
+
+   struct idetape_config {
+   int dsc_rw_frequency;
+   int dsc_media_access_frequency;
+   int nr_stages;
+   } config;
+
void __user *argp = (void __user *)arg;
 
debug_log(DBG_PROCS, "Enter %s\n", __func__);
 
switch (cmd) {
case 0x0340:
-   if (copy_from_user(&config, argp, sizeof 
(idetape_config_t)))
+   if (copy_from_user(&config, argp,
+   sizeof(struct idetape_config)))
return -EFAULT;
tape->best_dsc_rw_freq = config.dsc_rw_frequency;
tape->max_stages = config.nr_stages;
@@ -2757,7 +2755,8 @@ static int idetape_blkdev_ioctl(ide_drive_t *drive, 
unsigned int cmd, unsigned l
case 0x0350:
config.dsc_rw_frequency = (int) tape->best_dsc_rw_freq;
config.nr_stages = tape->max_stages; 
-   if (copy_to_user(argp, &config, sizeof 
(idetape_config_t)))
+   if (copy_to_user(argp, &config,
+   sizeof(struct idetape_config)))
return -EFAULT;
break;
default:
-- 
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


[PATCH 29/32] ide-tape: remove mtio.h related comments

2008-01-27 Thread Borislav Petkov
From: Borislav Petkov <[EMAIL PROTECTED]>

Those are already in mtio.h.

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |   96 +++
 1 files changed, 15 insertions(+), 81 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index d4c4255..cfb26d9 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -3028,69 +3028,20 @@ static int idetape_write_filemark (ide_drive_t *drive)
 }
 
 /*
- * idetape_mtioctop is called from idetape_chrdev_ioctl when
- * the general mtio MTIOCTOP ioctl is requested.
+ * Called from idetape_chrdev_ioctl when the general mtio MTIOCTOP ioctl is
+ * requested.
  *
- * We currently support the following mtio.h operations:
+ * Note: MTBSF and MTBSFM are not supported when the tape doesn't support
+ * spacing over filemarks in the reverse direction. In this case, MTFSFM is 
also
+ * usually not supported (it is supported in the rare case in which we crossed
+ * the filemark during our read-ahead pipelined operation mode).
  *
- * MTFSF   -   Space over mt_count filemarks in the positive direction.
- * The tape is positioned after the last spaced filemark.
+ * The following commands are currently not supported:
  *
- * MTFSFM  -   Same as MTFSF, but the tape is positioned before the
- * last filemark.
- *
- * MTBSF   -   Steps background over mt_count filemarks, tape is
- * positioned before the last filemark.
- *
- * MTBSFM  -   Like MTBSF, only tape is positioned after the last 
filemark.
- *
- * Note:
- *
- * MTBSF and MTBSFM are not supported when the tape doesn't
- * support spacing over filemarks in the reverse direction.
- * In this case, MTFSFM is also usually not supported (it is
- * supported in the rare case in which we crossed the filemark
- * during our read-ahead pipelined operation mode).
- * 
- * MTWEOF  -   Writes mt_count filemarks. Tape is positioned after
- * the last written filemark.
- *
- * MTREW   -   Rewinds tape.
- *
- * MTLOAD  -   Loads the tape.
- *
- * MTOFFL  -   Puts the tape drive "Offline": Rewinds the tape and
- * MTUNLOADprevents further access until the media is replaced.
- *
- * MTNOP   -   Flushes tape buffers.
- *
- * MTRETEN -   Retension media. This typically consists of one end
- * to end pass on the media.
- *
- * MTEOM   -   Moves to the end of recorded data.
- *
- * MTERASE -   Erases tape.
- *
- * MTSETBLK -  Sets the user block size to mt_count bytes. If
- * mt_count is 0, we will attempt to autodetect
- * the block size.
- *
- * MTSEEK  -   Positions the tape in a specific block number, where
- * each block is assumed to contain which user_block_size
- * bytes.
- *
- * MTSETPART - Switches to another tape partition.
- *
- * MTLOCK -Locks the tape door.
- *
- * MTUNLOCK -  Unlocks the tape door.
- *
- * The following commands are currently not supported:
- *
- * MTFSS, MTBSS, MTWSM, MTSETDENSITY,
- * MTSETDRVBUFFER, MT_ST_BOOLEANS, MT_ST_WRITE_THRESHOLD.
+ * MTFSS, MTBSS, MTWSM, MTSETDENSITY, MTSETDRVBUFFER, MT_ST_BOOLEANS,
+ * MT_ST_WRITE_THRESHOLD.
  */
-static int idetape_mtioctop (ide_drive_t *drive,short mt_op,int mt_count)
+static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count)
 {
idetape_tape_t *tape = drive->driver_data;
idetape_pc_t pc;
@@ -3203,29 +3154,12 @@ static int idetape_mtioctop (ide_drive_t *drive,short 
mt_op,int mt_count)
 }
 
 /*
- * Our character device ioctls.
- *
- * General mtio.h magnetic io commands are supported here, and not in
- * the corresponding block interface.
- *
- * The following ioctls are supported:
- *
- * MTIOCTOP -  Refer to idetape_mtioctop for detailed description.
- *
- * MTIOCGET -  The mt_dsreg field in the returned mtget structure
- * will be set to (user block size in bytes <<
- * MT_ST_BLKSIZE_SHIFT) & MT_ST_BLKSIZE_MASK.
- *
- * The mt_blkno is set to the current user block number.
- * The other mtget fields are not supported.
- *
- * MTIOCPOS -  The current tape "block position" is returned. We
- * assume that each block contains user_block_size
- * bytes.
- *
- * Our own ide-tape ioctls are supported on both interfaces.
+ * Our character device ioctls. General mtio.h magnetic io commands are
+ * supported here, and not in the corresponding block interface. Our own
+ * ide-tape ioctls are supported on

[PATCH 25/32] ide-tape: simplify code branching in the interrupt handler

2008-01-27 Thread Borislav Petkov
From: Borislav Petkov <[EMAIL PROTECTED]>

... by adding a new typedef function pointer idetape_io_buf in order to call
the proper buffer i/o handler depending on the data direction.

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |   54 +--
 1 files changed, 29 insertions(+), 25 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index eab552e..041edcd 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -1090,18 +1090,22 @@ static void idetape_postpone_request (ide_drive_t 
*drive)
 }
 
 /*
- * idetape_pc_intr is the usual interrupt handler which will be called
- * during a packet command. We will transfer some of the data (as
- * requested by the drive) and will re-point interrupt handler to us.
- * When data transfer is finished, we will act according to the
- * algorithm described before idetape_issue_packet_command.
- *
+ * This is the usual interrupt handler which will be called during a packet
+ * command. We will transfer some of the data (as requested by the drive) and
+ * will re-point interrupt handler to us. When data transfer is finished, we
+ * will act according to the algorithm described before
+ * idetape_issue_packet_command.
  */
-static ide_startstop_t idetape_pc_intr (ide_drive_t *drive)
+
+typedef void idetape_io_buf(ide_drive_t *, idetape_pc_t *, uint);
+
+static ide_startstop_t idetape_pc_intr(ide_drive_t *drive)
 {
ide_hwif_t *hwif = drive->hwif;
idetape_tape_t *tape = drive->driver_data;
idetape_pc_t *pc = tape->pc;
+   xfer_func_t *xferfunc;
+   idetape_io_buf *iobuf;
unsigned int temp;
 #if SIMULATE_ERRORS
static int error_sim_count = 0;
@@ -1171,7 +1175,8 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t 
*drive)
debug_log(DBG_ERR, "%s: I/O error\n", tape->name);
 
if (pc->c[0] == REQUEST_SENSE) {
-   printk(KERN_ERR "ide-tape: I/O error in request 
sense command\n");
+   printk(KERN_ERR "ide-tape: I/O error in request"
+   " sense command\n");
return ide_do_reset(drive);
}
debug_log(DBG_ERR, "[cmd %x]: check condition\n",
@@ -1210,7 +1215,7 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t 
*drive)
ireason = hwif->INB(IDE_IREASON_REG);
 
if (ireason & CD) {
-   printk(KERN_ERR "ide-tape: CoD != 0 in idetape_pc_intr\n");
+   printk(KERN_ERR "ide-tape: CoD != 0 in %s\n", __func__);
return ide_do_reset(drive);
}
if (((ireason & IO) == IO) == test_bit(PC_WRITING, &pc->flags)) {
@@ -1226,31 +1231,30 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t 
*drive)
temp = pc->xferred + bcount;
if (temp > pc->rq_xfer) {
if (temp > pc->buf_size) {
-   printk(KERN_ERR "ide-tape: The tape wants to 
send us more data than expected - discarding data\n");
+   printk(KERN_ERR "ide-tape: The tape wants to "
+   "send us more data than "
+   "expected - discarding data\n");
idetape_discard_data(drive, bcount);
-   ide_set_handler(drive, &idetape_pc_intr, 
IDETAPE_WAIT_CMD, NULL);
+   ide_set_handler(drive, &idetape_pc_intr,
+   IDETAPE_WAIT_CMD, NULL);
return ide_started;
}
debug_log(DBG_SENSE, "The tape wants to send us more "
"data than expected - allowing transfer\n");
 
}
-   }
-   if (test_bit(PC_WRITING, &pc->flags)) {
-   if (pc->bh != NULL)
-   idetape_output_buffers(drive, pc, bcount);
-   else
-   /* Write the current buffer */
-   hwif->atapi_output_bytes(drive, pc->cur_pos,
-bcount);
+   iobuf = &idetape_input_buffers;
+   xferfunc = hwif->atapi_input_bytes;
} else {
-   if (pc->bh != NULL)
-   idetape_input_buffers(drive, pc, bcount);
-   else
-   /* Read the current buffer */
-   hwif->atapi_input_bytes(drive, pc->cur_pos,
- 

[PATCH 16/32] ide-tape: use generic scsi commands

2008-01-27 Thread Borislav Petkov
From: Borislav Petkov <[EMAIL PROTECTED]>

Also, remove those which weren't used.

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |   80 ++--
 1 files changed, 30 insertions(+), 50 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 0708049..1435f4e 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -36,6 +36,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -521,27 +522,6 @@ static void ide_tape_put(struct ide_tape_obj *tape)
 #define IDETAPE_MEDIUM_PRESENT 9
 
 /*
- * Supported ATAPI tape drives packet commands
- */
-#define IDETAPE_TEST_UNIT_READY_CMD0x00
-#define IDETAPE_REWIND_CMD 0x01
-#define IDETAPE_REQUEST_SENSE_CMD  0x03
-#define IDETAPE_READ_CMD   0x08
-#define IDETAPE_WRITE_CMD  0x0a
-#define IDETAPE_WRITE_FILEMARK_CMD 0x10
-#define IDETAPE_SPACE_CMD  0x11
-#define IDETAPE_INQUIRY_CMD0x12
-#define IDETAPE_ERASE_CMD  0x19
-#define IDETAPE_MODE_SENSE_CMD 0x1a
-#define IDETAPE_MODE_SELECT_CMD0x15
-#define IDETAPE_LOAD_UNLOAD_CMD0x1b
-#define IDETAPE_PREVENT_CMD0x1e
-#define IDETAPE_LOCATE_CMD 0x2b
-#define IDETAPE_READ_POSITION_CMD  0x34
-#define IDETAPE_READ_BUFFER_CMD0x3c
-#define IDETAPE_SET_SPEED_CMD  0xbb
-
-/*
  * Some defines for the READ BUFFER command
  */
 #define IDETAPE_RETRIEVE_FAULTY_BLOCK  6
@@ -813,7 +793,7 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 
*sense)
 * sense key=5, asc=0x22, ascq=0, let it slide.  Some drives (i.e.
 * Seagate STT3401A Travan) don't support 0-length read/writes.
 */
-   if ((pc->c[0] == IDETAPE_READ_CMD || pc->c[0] == IDETAPE_WRITE_CMD)
+   if ((pc->c[0] == READ_6 || pc->c[0] == WRITE_6)
/* length==0 */
&& pc->c[4] == 0 && pc->c[3] == 0 && pc->c[2] == 0) {
if (tape->sense_key == 5) {
@@ -823,11 +803,11 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 
*sense)
set_bit(PC_ABORT, &pc->flags);
}
}
-   if (pc->c[0] == IDETAPE_READ_CMD && !!(sense[2] & 0x80)) {
+   if (pc->c[0] == READ_6 && !!(sense[2] & 0x80)) {
pc->error = IDETAPE_ERROR_FILEMARK;
set_bit(PC_ABORT, &pc->flags);
}
-   if (pc->c[0] == IDETAPE_WRITE_CMD) {
+   if (pc->c[0] == WRITE_6) {
if (!!(sense[2] & 0x40) ||
(tape->sense_key == 0xd &&
 tape->asc == 0x0 &&
@@ -836,7 +816,7 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 
*sense)
set_bit(PC_ABORT, &pc->flags);
}
}
-   if (pc->c[0] == IDETAPE_READ_CMD || pc->c[0] == IDETAPE_WRITE_CMD) {
+   if (pc->c[0] == READ_6 || pc->c[0] == WRITE_6) {
if (tape->sense_key == 8) {
pc->error = IDETAPE_ERROR_EOD;
set_bit(PC_ABORT, &pc->flags);
@@ -1073,7 +1053,7 @@ static ide_startstop_t idetape_request_sense_callback 
(ide_drive_t *drive)
 static void idetape_create_request_sense_cmd (idetape_pc_t *pc)
 {
idetape_init_pc(pc);
-   pc->c[0] = IDETAPE_REQUEST_SENSE_CMD;
+   pc->c[0] = REQUEST_SENSE;
pc->c[4] = 20;
pc->request_transfer = 20;
pc->callback = &idetape_request_sense_callback;
@@ -1216,22 +1196,22 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t 
*drive)
local_irq_enable();
 
 #if SIMULATE_ERRORS
-   if ((pc->c[0] == IDETAPE_WRITE_CMD ||
-pc->c[0] == IDETAPE_READ_CMD) &&
+   if ((pc->c[0] == WRITE_6 ||
+pc->c[0] == READ_6) &&
(++error_sim_count % 100) == 0) {
printk(KERN_INFO "ide-tape: %s: simulating error\n",
tape->name);
stat |= ERR_STAT;
}
 #endif
-   if ((stat & ERR_STAT) && pc->c[0] == IDETAPE_REQUEST_SENSE_CMD)
+   if ((stat & ERR_STAT) && pc->c[0] == REQUEST_SENSE)
stat &= ~ERR_STAT;
if ((stat & ERR_STAT) || test_bit(PC_DMA_ERROR, &pc->flags)) {
 
/* Error detected */
debug_log(DBG_ERR, "%s: I/O error\n", tape->name);
 
-   if (pc->c[0] == IDETAPE_REQUEST_SENSE_CMD) {
+   if (pc->c[0] == REQUEST_SENSE) 

[PATCH 20/32] ide-tape: make function name more accurate

2008-01-27 Thread Borislav Petkov
From: Borislav Petkov <[EMAIL PROTECTED]>

idetape_active_next_stage() was rather ambiguous wrt its purpose. Make that
more explicit and remove superfluous comment.

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |9 +++--
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index fd7eeea..cf308d7 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -820,10 +820,7 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 
*sense)
}
 }
 
-/*
- * idetape_active_next_stage will declare the next stage as "active".
- */
-static void idetape_active_next_stage (ide_drive_t *drive)
+static void idetape_activate_next_stage(ide_drive_t *drive)
 {
idetape_tape_t *tape = drive->driver_data;
idetape_stage_t *stage = tape->next_stage;
@@ -1004,7 +1001,7 @@ static int idetape_end_request(ide_drive_t *drive, int 
uptodate, int nr_sects)
}
}
if (tape->next_stage != NULL) {
-   idetape_active_next_stage(drive);
+   idetape_activate_next_stage(drive);
 
/*
 * Insert the next request into the request queue.
@@ -2338,7 +2335,7 @@ static void idetape_insert_pipeline_into_queue 
(ide_drive_t *drive)
return;
if (!idetape_pipeline_active(tape)) {
set_bit(IDETAPE_PIPELINE_ACTIVE, &tape->flags);
-   idetape_active_next_stage(drive);
+   idetape_activate_next_stage(drive);
(void) ide_do_drive_cmd(drive, tape->active_data_request, 
ide_end);
}
 }
-- 
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


[PATCH 13/32] ide-tape: remove struct idetape_parameter_block_descriptor_t

2008-01-27 Thread Borislav Petkov
From: Borislav Petkov <[EMAIL PROTECTED]>

Also, shorten function name idetape_get_blocksize_from_block_descriptor() and
move its definition up thereby getting rid of its forward declaration.

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |   68 +++
 1 files changed, 28 insertions(+), 40 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index ed53e7f..ea69183 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -664,18 +664,6 @@ struct idetape_id_gcw {
 #define IDETAPE_BUFFER_FILLING_PAGE0x33
 
 /*
- * Mode Parameter Block Descriptor the MODE SENSE packet command
- *
- * Support for block descriptors is optional.
- */
-typedef struct {
-   __u8density_code;   /* Medium density code */
-   __u8blocks[3];  /* Number of blocks */
-   __u8reserved4;  /* Reserved */
-   __u8length[3];  /* Block Length */
-} idetape_parameter_block_descriptor_t;
-
-/*
  * Run time configurable parameters.
  */
 typedef struct {
@@ -3401,7 +3389,32 @@ static int idetape_chrdev_ioctl (struct inode *inode, 
struct file *file, unsigne
}
 }
 
-static void idetape_get_blocksize_from_block_descriptor(ide_drive_t *drive);
+/*
+ * Do a mode sense page 0 with block descriptorand if it succeeds set 
the tape
+ * block size with the reported value
+ */
+static void ide_tape_get_bsize_from_bdesc(ide_drive_t *drive)
+{
+
+   idetape_tape_t *tape = drive->driver_data;
+   idetape_pc_t pc;
+
+   idetape_create_mode_sense_cmd(&pc, IDETAPE_BLOCK_DESCRIPTOR);
+   if (idetape_queue_pc_tail(drive, &pc)) {
+   printk(KERN_ERR "ide-tape: Can't get block descriptor\n");
+   if (tape->tape_block_size == 0) {
+   printk(KERN_WARNING "ide-tape: Cannot deal with zero "
+   "block size, assuming 32k\n");
+   tape->tape_block_size =  32768;
+   }
+   return;
+   }
+   tape->tape_block_size = (pc.buffer[4 + 5] << 16) +
+   (pc.buffer[4 + 6] << 8)  +
+   pc.buffer[4 + 7];
+
+   tape->drv_write_prot = (pc.buffer[2] & 0x80) >> 7;
+}
 
 /*
  * Our character device open function.
@@ -3453,7 +3466,7 @@ static int idetape_chrdev_open (struct inode *inode, 
struct file *filp)
clear_bit(IDETAPE_PIPELINE_ERROR, &tape->flags);
 
/* Read block size and write protect status from drive. */
-   idetape_get_blocksize_from_block_descriptor(drive);
+   ide_tape_get_bsize_from_bdesc(drive);
 
/* Set write protect flag if device is opened as read-only. */
if ((filp->f_flags & O_ACCMODE) == O_RDONLY)
@@ -3665,31 +3678,6 @@ static void idetape_get_mode_sense_results (ide_drive_t 
*drive)
 
 }
 
-/*
- * ide_get_blocksize_from_block_descriptor does a mode sense page 0 with 
block descriptor
- * and if it succeeds sets the tape block size with the reported value
- */
-static void idetape_get_blocksize_from_block_descriptor(ide_drive_t *drive)
-{
-
-   idetape_tape_t *tape = drive->driver_data;
-   idetape_pc_t pc;
-   idetape_parameter_block_descriptor_t *block_descrp;
-
-   idetape_create_mode_sense_cmd(&pc, IDETAPE_BLOCK_DESCRIPTOR);
-   if (idetape_queue_pc_tail(drive, &pc)) {
-   printk(KERN_ERR "ide-tape: Can't get block descriptor\n");
-   if (tape->tape_block_size == 0) {
-   printk(KERN_WARNING "ide-tape: Cannot deal with zero 
block size, assume 32k\n");
-   tape->tape_block_size =  32768;
-   }
-   return;
-   }
-   block_descrp = (idetape_parameter_block_descriptor_t *) pc.buffer + 4;
-   tape->tape_block_size =( block_descrp->length[0]<<16) + 
(block_descrp->length[1]<<8) + block_descrp->length[2];
-   tape->drv_write_prot = (pc.buffer[2] & 0x80) >> 7;
-}
-
 #ifdef CONFIG_IDE_PROC_FS
 static void idetape_add_settings (ide_drive_t *drive)
 {
@@ -3766,7 +3754,7 @@ static void idetape_setup (ide_drive_t *drive, 
idetape_tape_t *tape, int minor)

idetape_get_inquiry_results(drive);
idetape_get_mode_sense_results(drive);
-   idetape_get_blocksize_from_block_descriptor(drive);
+   ide_tape_get_bsize_from_bdesc(drive);
tape->user_bs_factor = 1;
tape->stage_size = *ctl * tape->tape_block_size;
while (tape->stage_size > 0x) {
-- 
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


[PATCH 19/32] ide-tape: remove unused sense packet commands.

2008-01-27 Thread Borislav Petkov
From: Borislav Petkov <[EMAIL PROTECTED]>

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |9 +
 1 files changed, 1 insertions(+), 8 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 5a18158..fd7eeea 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -577,16 +577,9 @@ struct idetape_id_gcw {
unsigned protocol   :2; /* Protocol type */
 };
 
-/*
- * Follows structures which are related to the SELECT SENSE / MODE SENSE
- * packet commands. Those packet commands are still not supported
- * by ide-tape.
- */
+/* Structures related to the SELECT SENSE / MODE SENSE packet commands. */
 #define IDETAPE_BLOCK_DESCRIPTOR   0
 #defineIDETAPE_CAPABILITIES_PAGE   0x2a
-#define IDETAPE_PARAMTR_PAGE   0x2b   /* Onstream DI-x0 only */
-#define IDETAPE_BLOCK_SIZE_PAGE0x30
-#define IDETAPE_BUFFER_FILLING_PAGE0x33
 
 /*
  * Run time configurable parameters.
-- 
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


[PATCH 18/32] ide-tape: use generic byteorder macros

2008-01-27 Thread Borislav Petkov
From: Borislav Petkov <[EMAIL PROTECTED]>

This is not a network driver.

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 1435f4e..5a18158 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -784,7 +784,7 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 
*sense)
if (test_bit(PC_DMA_ERROR, &pc->flags)) {
pc->actually_transferred = pc->request_transfer -
tape->tape_block_size *
-   ntohl(get_unaligned((u32 *)&sense[3]));
+   be32_to_cpu(get_unaligned((u32 *)&sense[3]));
idetape_update_buffers(pc);
}
 
@@ -1617,7 +1617,7 @@ static void idetape_create_read_cmd(idetape_tape_t *tape, 
idetape_pc_t *pc, unsi
 {
idetape_init_pc(pc);
pc->c[0] = READ_6;
-   put_unaligned(htonl(length), (unsigned int *) &pc->c[1]);
+   put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]);
pc->c[1] = 1;
pc->callback = &idetape_rw_callback;
pc->bh = bh;
@@ -1653,7 +1653,7 @@ static void idetape_create_write_cmd(idetape_tape_t 
*tape, idetape_pc_t *pc, uns
 {
idetape_init_pc(pc);
pc->c[0] = WRITE_6;
-   put_unaligned(htonl(length), (unsigned int *) &pc->c[1]);
+   put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]);
pc->c[1] = 1;
pc->callback = &idetape_rw_callback;
set_bit(PC_WRITING, &pc->flags);
@@ -2188,7 +2188,7 @@ static void idetape_create_locate_cmd (ide_drive_t 
*drive, idetape_pc_t *pc, uns
idetape_init_pc(pc);
pc->c[0] = POSITION_TO_ELEMENT;
pc->c[1] = 2;
-   put_unaligned(htonl(block), (unsigned int *) &pc->c[3]);
+   put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[3]);
pc->c[8] = partition;
set_bit(PC_WAIT_FOR_DSC, &pc->flags);
pc->callback = &idetape_pc_callback;
@@ -2379,7 +2379,7 @@ static void idetape_create_space_cmd (idetape_pc_t 
*pc,int count, u8 cmd)
 {
idetape_init_pc(pc);
pc->c[0] = SPACE;
-   put_unaligned(htonl(count), (unsigned int *) &pc->c[1]);
+   put_unaligned(cpu_to_be32(count), (unsigned int *) &pc->c[1]);
pc->c[1] = cmd;
set_bit(PC_WAIT_FOR_DSC, &pc->flags);
pc->callback = &idetape_pc_callback;
-- 
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


[PATCH 21/32] ide-tape: idetape_chrdev_direction_t:shorten enum names

2008-01-27 Thread Borislav Petkov
From: Borislav Petkov <[EMAIL PROTECTED]>

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |   60 ---
 1 files changed, 31 insertions(+), 29 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index cf308d7..b487d56 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -178,11 +178,13 @@ enum {
 /*
  * For general magnetic tape device compatibility.
  */
+
+/* tape directions */
 typedef enum {
-   idetape_direction_none,
-   idetape_direction_read,
-   idetape_direction_write
-} idetape_chrdev_direction_t;
+   idetape_dir_none,
+   idetape_dir_read,
+   idetape_dir_write
+} idetape_chrdev_dir_t;
 
 struct idetape_bh {
u32 b_size;
@@ -318,7 +320,7 @@ typedef struct ide_tape_obj {
/* device name */
char name[4];
/* Current character device data transfer direction */
-   idetape_chrdev_direction_t chrdev_direction;
+   idetape_chrdev_dir_t chrdev_direction;
 
/*
 *  Device information
@@ -1934,7 +1936,7 @@ static void idetape_init_merge_stage (idetape_tape_t 
*tape)
struct idetape_bh *bh = tape->merge_stage->bh;

tape->bh = bh;
-   if (tape->chrdev_direction == idetape_direction_write)
+   if (tape->chrdev_direction == idetape_dir_write)
atomic_set(&bh->b_count, 0);
else {
tape->b_data = bh->b_data;
@@ -2205,7 +2207,7 @@ static int __idetape_discard_read_pipeline (ide_drive_t 
*drive)
unsigned long flags;
int cnt;
 
-   if (tape->chrdev_direction != idetape_direction_read)
+   if (tape->chrdev_direction != idetape_dir_read)
return 0;
 
/* Remove merge stage. */
@@ -2220,7 +,7 @@ static int __idetape_discard_read_pipeline (ide_drive_t 
*drive)
 
/* Clear pipeline flags. */
clear_bit(IDETAPE_PIPELINE_ERROR, &tape->flags);
-   tape->chrdev_direction = idetape_direction_none;
+   tape->chrdev_direction = idetape_dir_none;
 
/* Remove pipeline stages. */
if (tape->first_stage == NULL)
@@ -2260,7 +2262,7 @@ static int idetape_position_tape (ide_drive_t *drive, 
unsigned int block, u8 par
int retval;
idetape_pc_t pc;
 
-   if (tape->chrdev_direction == idetape_direction_read)
+   if (tape->chrdev_direction == idetape_dir_read)
__idetape_discard_read_pipeline(drive);
idetape_wait_ready(drive, 60 * 5 * HZ);
idetape_create_locate_cmd(drive, &pc, block, partition, skip);
@@ -2487,7 +2489,7 @@ static void idetape_empty_write_pipeline (ide_drive_t 
*drive)
int blocks, min;
struct idetape_bh *bh;
 
-   if (tape->chrdev_direction != idetape_direction_write) {
+   if (tape->chrdev_direction != idetape_dir_write) {
printk(KERN_ERR "ide-tape: bug: Trying to empty write pipeline, 
but we are not writing.\n");
return;
}
@@ -2530,7 +2532,7 @@ static void idetape_empty_write_pipeline (ide_drive_t 
*drive)
tape->merge_stage = NULL;
}
clear_bit(IDETAPE_PIPELINE_ERROR, &tape->flags);
-   tape->chrdev_direction = idetape_direction_none;
+   tape->chrdev_direction = idetape_dir_none;
 
/*
 *  On the next backup, perform the feedback loop again.
@@ -2574,8 +2576,8 @@ static int idetape_initiate_read (ide_drive_t *drive, int 
max_stages)
u16 blocks = *(u16 *)&tape->caps[12];
 
/* Initialize read operation */
-   if (tape->chrdev_direction != idetape_direction_read) {
-   if (tape->chrdev_direction == idetape_direction_write) {
+   if (tape->chrdev_direction != idetape_dir_read) {
+   if (tape->chrdev_direction == idetape_dir_write) {
idetape_empty_write_pipeline(drive);
idetape_flush_tape_buffers(drive);
}
@@ -2585,7 +2587,7 @@ static int idetape_initiate_read (ide_drive_t *drive, int 
max_stages)
}
if ((tape->merge_stage = __idetape_kmalloc_stage(tape, 0, 0)) 
== NULL)
return -ENOMEM;
-   tape->chrdev_direction = idetape_direction_read;
+   tape->chrdev_direction = idetape_dir_read;
 
/*
 *  Issue a read 0 command to ensure that DSC handshake
@@ -2599,7 +2601,7 @@ static int idetape_initiate_read (ide_drive_t *drive, int 
max_stages)
if (bytes_read < 0) {
__idetape_kfree_stage(tape->merge_stage);
tape->merge_stage = NULL;
-   tape->chrdev_direction = idetape_direction_none;
+   tape->chr

[PATCH 14/32] ide-tape: remove structs os_partition_t, os_dat_entry_t, os_dat_t

2008-01-27 Thread Borislav Petkov
From: Borislav Petkov <[EMAIL PROTECTED]>

They seem just to sit there completely unused.

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |   37 -
 1 files changed, 0 insertions(+), 37 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index ea69183..02f5d5e 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -42,43 +42,6 @@
 #include 
 #include 
 #include 
-
-/*
- * partition
- */
-typedef struct os_partition_s {
-   __u8partition_num;
-   __u8par_desc_ver;
-   __u16   wrt_pass_cntr;
-   __u32   first_frame_addr;
-   __u32   last_frame_addr;
-   __u32   eod_frame_addr;
-} os_partition_t;
-
-/*
- * DAT entry
- */
-typedef struct os_dat_entry_s {
-   __u32   blk_sz;
-   __u16   blk_cnt;
-   __u8flags;
-   __u8reserved;
-} os_dat_entry_t;
-
-/*
- * DAT
- */
-#define OS_DAT_FLAGS_DATA  (0xc)
-#define OS_DAT_FLAGS_MARK  (0x1)
-
-typedef struct os_dat_s {
-   __u8dat_sz;
-   __u8reserved1;
-   __u8entry_cnt;
-   __u8reserved3;
-   os_dat_entry_t  dat_list[16];
-} os_dat_t;
-
 #include 
 
 / Tunable parameters */
-- 
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


[PATCH 17/32] ide-tape: remove EXPERIMENTAL driver status

2008-01-27 Thread Borislav Petkov
From: Borislav Petkov <[EMAIL PROTECTED]>

ide-tape has depended on EXPERIMENTAL for ages. Change that since the driver is
being only maintained now.

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/Kconfig |3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index 73ce5d1..330a80f 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -216,8 +216,7 @@ config BLK_DEV_IDECD_VERBOSE_ERRORS
  memory, though.
 
 config BLK_DEV_IDETAPE
-   tristate "Include IDE/ATAPI TAPE support (EXPERIMENTAL)"
-   depends on EXPERIMENTAL
+   tristate "Include IDE/ATAPI TAPE support"
help
  If you have an IDE tape drive using the ATAPI protocol, say Y.
  ATAPI is a newer protocol used by IDE tape and CD-ROM drives,
-- 
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


[PATCH 15/32] ide-tape: remove struct idetape_block_size_page_t

2008-01-27 Thread Borislav Petkov
From: Borislav Petkov <[EMAIL PROTECTED]>

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |   18 --
 1 files changed, 0 insertions(+), 18 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 02f5d5e..0708049 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -227,24 +227,6 @@ typedef struct idetape_packet_command_s {
 #definePC_WRITING  5
 
 /*
- * Block Size Page
- */
-typedef struct {
-   unsignedpage_code   :6; /* Page code - Should be 0x30 */
-   unsignedreserved1_6 :1;
-   unsignedps  :1;
-   __u8page_length;/* Page Length - Should be 2 */
-   __u8reserved2;
-   unsignedplay32  :1;
-   unsignedplay32_5:1;
-   unsignedreserved2_23:2;
-   unsignedrecord32:1;
-   unsignedrecord32_5  :1;
-   unsignedreserved2_6 :1;
-   unsignedone :1;
-} idetape_block_size_page_t;
-
-/*
  * A pipeline stage.
  */
 typedef struct idetape_stage_s {
-- 
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


[PATCH 12/32] ide-tape: remove struct idetape_medium_partition_page_t

2008-01-27 Thread Borislav Petkov
From: Borislav Petkov <[EMAIL PROTECTED]>

There should be no functional changes resulting from this patch.

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |   19 ---
 1 files changed, 0 insertions(+), 19 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 0c3ec66..ed53e7f 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -676,25 +676,6 @@ typedef struct {
 } idetape_parameter_block_descriptor_t;
 
 /*
- * The Medium Partition Page, as returned by the MODE SENSE packet command.
- */
-typedef struct {
-   unsignedpage_code   :6; /* Page Code - Should be 0x11 */
-   unsignedreserved1_6 :1; /* Reserved */
-   unsignedps  :1;
-   __u8page_length;/* Page Length - Should be 6 */
-   __u8map;/* Maximum Additional 
Partitions - Should be 0 */
-   __u8apd;/* Additional Partitions 
Defined - Should be 0 */
-   unsignedreserved4_012   :3; /* Reserved */
-   unsignedpsum:2; /* Should be 0 */
-   unsignedidp :1; /* Should be 0 */
-   unsignedsdp :1; /* Should be 0 */
-   unsignedfdp :1; /* Fixed Data Partitions */
-   __u8mfr;/* Medium Format Recognition */
-   __u8reserved[2];/* Reserved */
-} idetape_medium_partition_page_t;
-
-/*
  * Run time configurable parameters.
  */
 typedef struct {
-- 
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


[PATCH 07/32] ide-tape: refactor the debug logging facility

2008-01-27 Thread Borislav Petkov
From: Borislav Petkov <[EMAIL PROTECTED]>

Teach the debug logging macro to differentiate different log levels based on the
type of debug level enabled specifically instead of a threshold-based one.
Thus, convert tape->debug_level to a bitmask that is written to over /proc.

Also,
- Cleanup and simplify debug macro thus removing a lot of code lines,
- Get rid of unused debug levels,
- Adjust the loglevel at several places where it was simply missing (e.g.
idetape_chrdev_open() etc.)

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |  310 +---
 1 files changed, 107 insertions(+), 203 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index efb9d25..a2e7df0 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -103,24 +103,27 @@ typedef struct os_dat_s {
 #define IDETAPE_MAX_PIPELINE_STAGES400
 #define IDETAPE_INCREASE_STAGES_RATE20
 
-/*
- * The following are used to debug the driver:
- *
- * Setting IDETAPE_DEBUG_LOG to 1 will log driver flow control.
- * some places.
- *
- * Setting them to 0 will restore normal operation mode:
- *
- * 1.  Disable logging normal successful operations.
- * 2.  Disable self-sanity checks.
- * 3.  Errors will still be logged, of course.
- *
- * All the #if DEBUG code will be removed some day, when the driver
- * is verified to be stable enough. This will make it much more
- * esthetic.
- */
+enum {
+   DBG_ERR =   (1 << 0),
+   DBG_SENSE = (1 << 1),
+   DBG_CHRDEV =(1 << 2),
+   DBG_PROCS = (1 << 3),
+   DBG_PCRQ_STACK =(1 << 4),
+};
+
+/* define to see debug info */
 #define IDETAPE_DEBUG_LOG  0
 
+#if IDETAPE_DEBUG_LOG
+#define debug_log(lvl, fmt, args...)   \
+{  \
+   if (tape->debug_level & lvl)\
+   printk(KERN_INFO "ide-tape: " fmt, ## args) \
+}
+#else
+#define debug_log(lvl, fmt, args...) do {} while (0)
+#endif
+
 /*
  * After each failed packet command we issue a request sense command
  * and retry the packet command IDETAPE_MAX_PC_RETRIES times.
@@ -557,7 +560,7 @@ typedef struct ide_tape_obj {
  * 5 : 4+include pc_stack rq_stack info
  * 6 : 5+USE_COUNT updates
  */
- int debug_level; 
+ u32 debug_level;
 } idetape_tape_t;
 
 static DEFINE_MUTEX(idetape_ref_mutex);
@@ -923,11 +926,8 @@ static idetape_pc_t *idetape_next_pc_storage (ide_drive_t 
*drive)
 {
idetape_tape_t *tape = drive->driver_data;
 
-#if IDETAPE_DEBUG_LOG
-   if (tape->debug_level >= 5)
-   printk(KERN_INFO "ide-tape: pc_stack_index=%d\n",
-   tape->pc_stack_index);
-#endif /* IDETAPE_DEBUG_LOG */
+   debug_log(DBG_PCRQ_STACK, "pc_stack_index=%d\n", tape->pc_stack_index);
+
if (tape->pc_stack_index == IDETAPE_PC_STACK)
tape->pc_stack_index=0;
return (&tape->pc_stack[tape->pc_stack_index++]);
@@ -950,11 +950,8 @@ static struct request *idetape_next_rq_storage 
(ide_drive_t *drive)
 {
idetape_tape_t *tape = drive->driver_data;
 
-#if IDETAPE_DEBUG_LOG
-   if (tape->debug_level >= 5)
-   printk(KERN_INFO "ide-tape: rq_stack_index=%d\n",
-   tape->rq_stack_index);
-#endif /* IDETAPE_DEBUG_LOG */
+   debug_log(DBG_PCRQ_STACK, "rq_stack_index=%d\n", tape->rq_stack_index);
+
if (tape->rq_stack_index == IDETAPE_PC_STACK)
tape->rq_stack_index=0;
return (&tape->rq_stack[tape->rq_stack_index++]);
@@ -987,17 +984,9 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 
*sense)
tape->sense_key = sense[2] & 0xF;
tape->asc   = sense[12];
tape->ascq  = sense[13];
-#if IDETAPE_DEBUG_LOG
-   /*
-* Without debugging, we only log an error if we decided to give up
-* retrying.
-*/
-   if (tape->debug_level >= 1)
-   printk(KERN_INFO "ide-tape: pc = %x, sense key = %x, "
-   "asc = %x, ascq = %x\n",
-   pc->c[0], tape->sense_key,
-   tape->asc, tape->ascq);
-#endif /* IDETAPE_DEBUG_LOG */
+
+   debug_log(DBG_ERR, "pc = %x, sense key = %x, asc = %x, ascq = %x\n",
+pc->c[0], tape->sense_key, tape->asc, tape->ascq);
 
/* Correct pc->actually_transferred by asking the tape.  */
if (test_bit(PC_DMA_ERROR, &pc->flags)) {
@@ -1055,12 +1044,11 @@ static void idetape_active_next_stage (ide_drive_t 
*drive)
idetape_st

[PATCH 11/32] ide-tape: remove struct idetape_data_compression_page_t

2008-01-27 Thread Borislav Petkov
From: Borislav Petkov <[EMAIL PROTECTED]>

There should be no functional changes resulting from this patch.

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |   19 ---
 1 files changed, 0 insertions(+), 19 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 9f1fc50..0c3ec66 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -676,25 +676,6 @@ typedef struct {
 } idetape_parameter_block_descriptor_t;
 
 /*
- * The Data Compression Page, as returned by the MODE SENSE packet command.
- */
-typedef struct {
-   unsignedpage_code   :6; /* Page Code - Should be 0xf */
-   unsignedreserved0   :1; /* Reserved */
-   unsignedps  :1;
-   __u8page_length;/* Page Length - Should be 14 */
-   unsignedreserved2   :6; /* Reserved */
-   unsigneddcc :1; /* Data Compression Capable */
-   unsigneddce :1; /* Data Compression Enable */
-   unsignedreserved3   :5; /* Reserved */
-   unsignedred :2; /* Report Exception on 
Decompression */
-   unsigneddde :1; /* Data Decompression Enable */
-   __u32   ca; /* Compression Algorithm */
-   __u32   da; /* Decompression Algorithm */
-   __u8reserved[4];/* Reserved */
-} idetape_data_compression_page_t;
-
-/*
  * The Medium Partition Page, as returned by the MODE SENSE packet command.
  */
 typedef struct {
-- 
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


[PATCH 09/32] ide-tape: remove struct idetape_inquiry_result_t

2008-01-27 Thread Borislav Petkov
From: Borislav Petkov <[EMAIL PROTECTED]>

There should be no functional changes resulting from this patch.

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |   51 ---
 1 files changed, 13 insertions(+), 38 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 0f846bc..31c1a20 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -653,31 +653,6 @@ struct idetape_id_gcw {
 };
 
 /*
- * INQUIRY packet command - Data Format (From Table 6-8 of QIC-157C)
- */
-typedef struct {
-   unsigneddevice_type :5; /* Peripheral Device Type */
-   unsignedreserved0_765   :3; /* Peripheral Qualifier - 
Reserved */
-   unsignedreserved1_6t0   :7; /* Reserved */
-   unsignedrmb :1; /* Removable Medium Bit */
-   unsignedansi_version:3; /* ANSI Version */
-   unsignedecma_version:3; /* ECMA Version */
-   unsignediso_version :2; /* ISO Version */
-   unsignedresponse_format :4; /* Response Data Format */
-   unsignedreserved3_45:2; /* Reserved */
-   unsignedreserved3_6 :1; /* TrmIOP - Reserved */
-   unsignedreserved3_7 :1; /* AENC - Reserved */
-   __u8additional_length;  /* Additional Length 
(total_length-4) */
-   __u8rsv5, rsv6, rsv7;   /* Reserved */
-   __u8vendor_id[8];   /* Vendor Identification */
-   __u8product_id[16]; /* Product Identification */
-   __u8revision_level[4];  /* Revision Level */
-   __u8vendor_specific[20];/* Vendor Specific - Optional */
-   __u8reserved56t95[40];  /* Reserved - Optional */
-   /* Additional information may 
be returned */
-} idetape_inquiry_result_t;
-
-/*
  * READ POSITION packet command - Data Format (From Table 6-57)
  */
 typedef struct {
@@ -3662,32 +3637,32 @@ static int idetape_identify_device (ide_drive_t *drive)
return 0;
 }
 
-/*
- * Use INQUIRY to get the firmware revision
- */
-static void idetape_get_inquiry_results (ide_drive_t *drive)
+static void idetape_get_inquiry_results(ide_drive_t *drive)
 {
char *r;
idetape_tape_t *tape = drive->driver_data;
idetape_pc_t pc;
-   idetape_inquiry_result_t *inquiry;
-   
+
idetape_create_inquiry_cmd(&pc);
if (idetape_queue_pc_tail(drive, &pc)) {
-   printk(KERN_ERR "ide-tape: %s: can't get INQUIRY results\n", 
tape->name);
+   printk(KERN_ERR "ide-tape: %s: can't get INQUIRY results\n",
+   tape->name);
return;
}
-   inquiry = (idetape_inquiry_result_t *) pc.buffer;
-   memcpy(tape->vendor_id, inquiry->vendor_id, 8);
-   memcpy(tape->product_id, inquiry->product_id, 16);
-   memcpy(tape->firmware_revision, inquiry->revision_level, 4);
+   memcpy(tape->vendor_id, &pc.buffer[8], 8);
+   memcpy(tape->product_id, &pc.buffer[16], 16);
+   memcpy(tape->firmware_revision, &pc.buffer[32], 4);
+
ide_fixstring(tape->vendor_id, 10, 0);
ide_fixstring(tape->product_id, 18, 0);
ide_fixstring(tape->firmware_revision, 6, 0);
r = tape->firmware_revision;
if (*(r + 1) == '.')
-   tape->firmware_revision_num = (*r - '0') * 100 + (*(r + 2) - 
'0') * 10 + *(r + 3) - '0';
-   printk(KERN_INFO "ide-tape: %s <-> %s: %s %s rev %s\n", drive->name, 
tape->name, tape->vendor_id, tape->product_id, tape->firmware_revision);
+   tape->firmware_revision_num = (*r - '0') * 100 +
+   (*(r + 2) - '0') * 10 + *(r + 3) - '0';
+   printk(KERN_INFO "ide-tape: %s <-> %s: %s %s rev %s\n",
+   drive->name, tape->name, tape->vendor_id,
+   tape->product_id, tape->firmware_revision);
 }
 
 /*
-- 
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


[PATCH 08/32] ide-tape: remove struct idetape_capabilities_page_t

2008-01-27 Thread Borislav Petkov
From: Borislav Petkov <[EMAIL PROTECTED]>

All those 2-byte values denoting the different capabilities are being written to
the local copy of the caps buffer without being converted to big endian for
simplicity of usage and shorter code later.  Also, we add some comments stating
which are the fields of the caps page in question in order to alleviate the
cryptic pointer casting exercises as in e.g. idetape_get_mode_sense_results().

There should be no functional changes resulting from this patch.

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |  143 +++-
 1 files changed, 57 insertions(+), 86 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index a2e7df0..0f846bc 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -264,47 +264,6 @@ typedef struct idetape_packet_command_s {
 #definePC_WRITING  5
 
 /*
- * Capabilities and Mechanical Status Page
- */
-typedef struct {
-   unsignedpage_code   :6; /* Page code - Should be 0x2a */
-   __u8reserved0_6 :1;
-   __u8ps  :1; /* parameters saveable */
-   __u8page_length;/* Page Length - Should be 0x12 
*/
-   __u8reserved2, reserved3;
-   unsignedro  :1; /* Read Only Mode */
-   unsignedreserved4_1234  :4;
-   unsignedsprev   :1; /* Supports SPACE in the 
reverse direction */
-   unsignedreserved4_67:2;
-   unsignedreserved5_012   :3;
-   unsignedefmt:1; /* Supports ERASE command 
initiated formatting */
-   unsignedreserved5_4 :1;
-   unsignedqfa :1; /* Supports the QFA two 
partition formats */
-   unsignedreserved5_67:2;
-   unsignedlock:1; /* Supports locking the volume 
*/
-   unsignedlocked  :1; /* The volume is locked */
-   unsignedprevent :1; /* The device defaults in the 
prevent state after power up */   
-   unsignedeject   :1; /* The device can eject the 
volume */
-   __u8disconnect  :1; /* The device can break request 
> ctl */
-   __u8reserved6_5 :1;
-   unsignedecc :1; /* Supports error correction */
-   unsignedcmprs   :1; /* Supports data compression */
-   unsignedreserved7_0 :1;
-   unsignedblk512  :1; /* Supports 512 bytes block 
size */
-   unsignedblk1024 :1; /* Supports 1024 bytes block 
size */
-   unsignedreserved7_3_6   :4;
-   unsignedblk32768:1; /* slowb - the device restricts 
the byte count for PIO */
-   /* transfers for slow buffer 
memory ??? */
-   /* Also 32768 block size in 
some cases */
-   __u16   max_speed;  /* Maximum speed supported in 
KBps */
-   __u8reserved10, reserved11;
-   __u16   ctl;/* Continuous Transfer Limit in 
blocks */
-   __u16   speed;  /* Current Speed, in KBps */
-   __u16   buffer_size;/* Buffer Size, in 512 bytes */
-   __u8reserved18, reserved19;
-} idetape_capabilities_page_t;
-
-/*
  * Block Size Page
  */
 typedef struct {
@@ -421,8 +380,9 @@ typedef struct ide_tape_obj {
/* Usually 512 or 1024 bytes */
unsigned short tape_block_size;
int user_bs_factor;
+
/* Copy of the tape's Capabilities and Mechanical Page */
-   idetape_capabilities_page_t capabilities;
+   u8 caps[20];
 
/*
 *  Active data transfer request parameters.
@@ -2401,7 +2361,8 @@ static int idetape_create_prevent_cmd (ide_drive_t 
*drive, idetape_pc_t *pc, int
 {
idetape_tape_t *tape = drive->driver_data;
 
-   if (!tape->capabilities.lock)
+   /* device supports locking according to capabilities page */
+   if (!(tape->caps[6] & 0x01))
return 0;
 
idetape_init_pc(pc);
@@ -2783,7 +2744,7 @@ static int idetape_initiate_read (ide_drive_t *drive, int 
max_stages)
idetape_stage_t *new_stage;
struct request rq;
int bytes_read;
-   int blocks = tape->capabilities.ctl;
+   u16 blocks = *(u16 *)&tape->caps[12];
 
/* Initialize read operation */
if (tape->chrdev_direction != idetape_direction_read) {
@@ -3017,11 +2978,12 @@ static int idetape_space_over_filemarks (ide_drive_t 
*drive,short mt_op,int mt_c
idetape_pc_t pc;
unsigned long flags;
int retval,count=

[PATCH 06/32] ide-tape: remove IDETAPE_DEBUG_BUGS

2008-01-27 Thread Borislav Petkov
From: Borislav Petkov <[EMAIL PROTECTED]>

Signed-off-by: Borislav Petkov <[EMAIL PROTECTED]>
---
 drivers/ide/ide-tape.c |   42 ++
 1 files changed, 2 insertions(+), 40 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index dbececc..efb9d25 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -107,7 +107,6 @@ typedef struct os_dat_s {
  * The following are used to debug the driver:
  *
  * Setting IDETAPE_DEBUG_LOG to 1 will log driver flow control.
- * Setting IDETAPE_DEBUG_BUGS to 1 will enable self-sanity checks in
  * some places.
  *
  * Setting them to 0 will restore normal operation mode:
@@ -121,7 +120,6 @@ typedef struct os_dat_s {
  * esthetic.
  */
 #define IDETAPE_DEBUG_LOG  0
-#define IDETAPE_DEBUG_BUGS 1
 
 /*
  * After each failed packet command we issue a request sense command
@@ -847,14 +845,12 @@ static void idetape_input_buffers (ide_drive_t *drive, 
idetape_pc_t *pc, unsigne
int count;
 
while (bcount) {
-#if IDETAPE_DEBUG_BUGS
if (bh == NULL) {
printk(KERN_ERR "ide-tape: bh == NULL in "
"idetape_input_buffers\n");
idetape_discard_data(drive, bcount);
return;
}
-#endif /* IDETAPE_DEBUG_BUGS */
count = min((unsigned int)(bh->b_size - 
atomic_read(&bh->b_count)), bcount);
HWIF(drive)->atapi_input_bytes(drive, bh->b_data + 
atomic_read(&bh->b_count), count);
bcount -= count;
@@ -874,13 +870,11 @@ static void idetape_output_buffers (ide_drive_t *drive, 
idetape_pc_t *pc, unsign
int count;
 
while (bcount) {
-#if IDETAPE_DEBUG_BUGS
if (bh == NULL) {
printk(KERN_ERR "ide-tape: bh == NULL in "
"idetape_output_buffers\n");
return;
}
-#endif /* IDETAPE_DEBUG_BUGS */
count = min((unsigned int)pc->b_count, (unsigned int)bcount);
HWIF(drive)->atapi_output_bytes(drive, pc->b_data, count);
bcount -= count;
@@ -905,13 +899,11 @@ static void idetape_update_buffers (idetape_pc_t *pc)
if (test_bit(PC_WRITING, &pc->flags))
return;
while (bcount) {
-#if IDETAPE_DEBUG_BUGS
if (bh == NULL) {
printk(KERN_ERR "ide-tape: bh == NULL in "
"idetape_update_buffers\n");
return;
}
-#endif /* IDETAPE_DEBUG_BUGS */
count = min((unsigned int)bh->b_size, (unsigned int)bcount);
atomic_set(&bh->b_count, count);
if (atomic_read(&bh->b_count) == bh->b_size)
@@ -1067,12 +1059,10 @@ static void idetape_active_next_stage (ide_drive_t 
*drive)
if (tape->debug_level >= 4)
printk(KERN_INFO "ide-tape: Reached 
idetape_active_next_stage\n");
 #endif /* IDETAPE_DEBUG_LOG */
-#if IDETAPE_DEBUG_BUGS
if (stage == NULL) {
printk(KERN_ERR "ide-tape: bug: Trying to activate a non 
existing stage\n");
return;
}
-#endif /* IDETAPE_DEBUG_BUGS */
 
rq->rq_disk = tape->disk;
rq->buffer = NULL;
@@ -1147,28 +1137,24 @@ static void idetape_remove_stage_head (ide_drive_t 
*drive)
if (tape->debug_level >= 4)
printk(KERN_INFO "ide-tape: Reached 
idetape_remove_stage_head\n");
 #endif /* IDETAPE_DEBUG_LOG */
-#if IDETAPE_DEBUG_BUGS
if (tape->first_stage == NULL) {
printk(KERN_ERR "ide-tape: bug: tape->first_stage is NULL\n");
-   return; 
+   return;
}
if (tape->active_stage == tape->first_stage) {
printk(KERN_ERR "ide-tape: bug: Trying to free our active 
pipeline stage\n");
return;
}
-#endif /* IDETAPE_DEBUG_BUGS */
stage = tape->first_stage;
tape->first_stage = stage->next;
idetape_kfree_stage(tape, stage);
tape->nr_stages--;
if (tape->first_stage == NULL) {
tape->last_stage = NULL;
-#if IDETAPE_DEBUG_BUGS
if (tape->next_stage != NULL)
printk(KERN_ERR "ide-tape: bug: tape->next_stage != 
NULL\n");
if (tape->nr_stages)
printk(KERN_ERR "ide-tape: bug: nr_stages should be 0 
now\n");
-#endif /* IDETAPE_DEBUG_BUGS */
}
 }
 
@@ -1656,13 +1642,11 @@ static ide_startstop_t idetape_issue_packet_command 
(ide_drive_t *dr

  1   2   >