2003-05-05 19:51:42

by Pascal Schmidt

[permalink] [raw]
Subject: [IDE] trying to make MO drive work with ide-floppy


Hi all, Alan,

I've been trying to make my 640 MB ATAPI MO drive work with the
ide-floppy driver. I've patched ide-probe.c and ide-floppy.c for
assigning the MO drive (type ide_optical) to the floppy driver
(patch against 2.4-bkcvs below).

On bootup, the drive now gets reported as:

hde: FUJITSU MCC3064AP, ATAPI OPTICAL drive
hde: attached ide-floppy driver.
hde: No disk in drive
hde: 520192kB, 508/64/32 CHS, 2000 kBps, 512 sector size, 3600 rpm

These values would be correct for a 512 MB MO disk in the drive. So far,
so good.

Upon inserting a 640 MB disk and running 'fdisk -l /dev/hde' I get:

hde: 620704kB, 310352 blocks, 2048 sector size
hde: warning: non 512 bytes block size not fully supported
hde: 618496kB, 151/64/32 CHS, 2000 kBps, 2048 sector size, 3600 rpm
hde: The disk reports a capacity of 635600896 bytes, but the drive only handles 633339904
hde: unknown partition table

The size and geometry stuff reported first looks good (310352 blocks is
also reported when using ide-scsi/sd for the drive). The second line
with slightly different size looks wrong, though.

That "non 512 bytes block size" stuff doesn't look encouraging. On
trying 'mount -t ext2 -o ro /dev/hde /mnt/mo', I get:

hde: warning: non 512 bytes block size not fully supported
hde: The disk reports a capacity of 635600896 bytes, but the drive only handles 633339904
hde: unknown partition table
hde: unsupported r/w request size
end_request: I/O error, dev 21:00 (hde), sector 2
EXT2-fs: unable to read superblock
hde: warning: non 512 bytes block size not fully supported
hde: The disk reports a capacity of 635600896 bytes, but the drive only handles 633339904
hde: unknown partition table

The disk is formatted as a whole (no partition table) and works just fine
when using ide-scsi.

I cannot test with an MO disk with 512 byte sectors since I don't own
any.

Are there any plans to support drives with blocksizes != 512 bytes? What
changes would be needed to make it work? Or do I simply have to live with
ide-scsi (still broken on 2.5, I assume...)?

Finally, the patch I used:

--- ide-probe.c.orig Mon May 5 21:25:32 2003
+++ ide-probe.c Mon May 5 21:25:59 2003
@@ -222,6 +222,7 @@ static inline void do_identify (ide_driv
break;
case ide_optical:
printk ("OPTICAL");
+ type = ide_floppy;
drive->removable = 1;
break;
default:
--- ide-floppy.c.orig Mon May 5 21:25:45 2003
+++ ide-floppy.c Mon May 5 21:26:40 2003
@@ -1962,7 +1962,7 @@ static int idefloppy_identify_device (id

if (gcw.protocol != 2)
printk(KERN_ERR "ide-floppy: Protocol is not ATAPI\n");
- else if (gcw.device_type != 0)
+ else if ((gcw.device_type != 0) && (gcw.device_type != 7))
printk(KERN_ERR "ide-floppy: Device type is not set to floppy\n");
else if (!gcw.removable)
printk(KERN_ERR "ide-floppy: The removable flag is not set\n");

--
Ciao,
Pascal


2003-05-06 10:27:04

by Alan

[permalink] [raw]
Subject: Re: [IDE] trying to make MO drive work with ide-floppy

On Llu, 2003-05-05 at 21:04, Pascal Schmidt wrote:
> Are there any plans to support drives with blocksizes != 512 bytes? What
> changes would be needed to make it work? Or do I simply have to live with
> ide-scsi (still broken on 2.5, I assume...)?

I'm not aware of any plans to make ide-floppy handle that disk, or reasons
you would want to use ide floppy in 2.5 not the ide-cd layer (which does now
handle writable devices I believe).



2003-05-06 13:50:36

by Pascal Schmidt

[permalink] [raw]
Subject: Re: [IDE] trying to make MO drive work with ide-floppy/ide-cd

On 6 May 2003, Alan Cox wrote:

> I'm not aware of any plans to make ide-floppy handle that disk, or reasons
> you would want to use ide floppy in 2.5 not the ide-cd layer (which does
> now handle writable devices I believe).

Okay, didn't think of that, so I now tried using ide-cd for the MO drive
(2.5.68+bkcvs). I still had to patch ide-probe.c, just passing "hde=cdrom"
did not do what I wanted. ;)

Now I get the following at bootup:

hde: FUJITSU MCC3064AP, ATAPI OPTICAL drive
hde: set_drive_speed_status: status=0x51 { DriveReady SeekComplete Error }
hde: set_drive_speed_status: error=0x04
Uniform CD-ROM driver Revision: 3.12
end_request: I/O error, dev hde, sector 0
hde: packet command error: status=0x51 { DriveReady SeekComplete Error }
hde: packet command error: error=0x50
end_request: I/O error, dev hde, sector 0
ATAPI device hde:
Error: Illegal request -- (Sense key=0x05)
Invalid field in command packet -- (asc=0x24, ascq=0x00)
The failed "Mode Sense 10" packet command was:
"5a 00 2a 00 00 00 00 00 18 00 00 00 00 00 00 00 "
Error in command data byte 8800
hde: packet command error: status=0x51 { DriveReady SeekComplete Error }
hde: packet command error: error=0x50
end_request: I/O error, dev hde, sector 0
ATAPI device hde:
Error: Illegal request -- (Sense key=0x05)
Invalid field in command packet -- (asc=0x24, ascq=0x00)
The failed "Mode Sense 10" packet command was:
"5a 00 2a 00 00 00 00 00 18 00 00 00 00 00 00 00 "
Error in command data byte 8800
end_request: I/O error, dev hde, sector 0

This doesn't look encouraging. However, the MO drive sort of works:

# mount -t ext2 /dev/hde /mnt/mo
mount: block device /dev/hde is write-protected, mounting read-only

The disk gets mounted and reading works just fine. No write support,
though. To reiterate, everything works under 2.4 using ide-scsi.

What can I do to help get this drive supported under 2.5/ide-cd?

I'll check if reading from the MO drive works with ide-cd under 2.4
as well. If it does: what about a patch that makes ATAPI MO drives
and CD writers behave the same on 2.4: read-only with native ide drivers,
read-write with ide-scsi?

--- linux-2.5/drivers/ide/ide-probe.c Sat Apr 26 18:49:57 2003
+++ build25/drivers/ide/ide-probe.c Tue May 6 15:42:40 2003
@@ -221,6 +221,7 @@ static inline void do_identify (ide_driv
break;
case ide_optical:
printk ("OPTICAL");
+ type = ide_cdrom;
drive->removable = 1;
break;
default:

--
Ciao,
Pascal

2003-05-06 14:01:28

by Jens Axboe

[permalink] [raw]
Subject: Re: [IDE] trying to make MO drive work with ide-floppy/ide-cd

On Tue, May 06 2003, Pascal Schmidt wrote:
> On Tue, 6 May 2003, Pascal Schmidt wrote:
>
> > I'll check if reading from the MO drive works with ide-cd under 2.4
> > as well. If it does: what about a patch that makes ATAPI MO drives
> > and CD writers behave the same on 2.4: read-only with native ide drivers,
> > read-write with ide-scsi?
>
> I can now confirm that using the MO drive read-only with 2.4 and ide-cd
> also works fine.
>
> Could we please have this patch included in the 2.4 IDE code to make
> MO drives and CD writers behave the same?

Not until you fix ide-cd to correctly identify it. This half-assed
solution wont do.

--
Jens Axboe

2003-05-06 14:07:34

by Jens Axboe

[permalink] [raw]
Subject: Re: [IDE] trying to make MO drive work with ide-floppy/ide-cd

On Tue, May 06 2003, Pascal Schmidt wrote:
> On 6 May 2003, Alan Cox wrote:
>
> > I'm not aware of any plans to make ide-floppy handle that disk, or reasons
> > you would want to use ide floppy in 2.5 not the ide-cd layer (which does
> > now handle writable devices I believe).
>
> Okay, didn't think of that, so I now tried using ide-cd for the MO drive
> (2.5.68+bkcvs). I still had to patch ide-probe.c, just passing "hde=cdrom"
> did not do what I wanted. ;)

Uh nasty :)

> Now I get the following at bootup:
>
> hde: FUJITSU MCC3064AP, ATAPI OPTICAL drive
> hde: set_drive_speed_status: status=0x51 { DriveReady SeekComplete Error }
> hde: set_drive_speed_status: error=0x04
> Uniform CD-ROM driver Revision: 3.12
> end_request: I/O error, dev hde, sector 0
> hde: packet command error: status=0x51 { DriveReady SeekComplete Error }
> hde: packet command error: error=0x50
> end_request: I/O error, dev hde, sector 0
> ATAPI device hde:
> Error: Illegal request -- (Sense key=0x05)
> Invalid field in command packet -- (asc=0x24, ascq=0x00)
> The failed "Mode Sense 10" packet command was:
> "5a 00 2a 00 00 00 00 00 18 00 00 00 00 00 00 00 "
> Error in command data byte 8800
> hde: packet command error: status=0x51 { DriveReady SeekComplete Error }
> hde: packet command error: error=0x50
> end_request: I/O error, dev hde, sector 0
> ATAPI device hde:
> Error: Illegal request -- (Sense key=0x05)
> Invalid field in command packet -- (asc=0x24, ascq=0x00)
> The failed "Mode Sense 10" packet command was:
> "5a 00 2a 00 00 00 00 00 18 00 00 00 00 00 00 00 "
> Error in command data byte 8800
> end_request: I/O error, dev hde, sector 0

It barfs at a lot of commands, not surprisingly. ide-cd really has no
concept of devices other than cd/dvd.

> This doesn't look encouraging. However, the MO drive sort of works:
>
> # mount -t ext2 /dev/hde /mnt/mo
> mount: block device /dev/hde is write-protected, mounting read-only
>
> The disk gets mounted and reading works just fine. No write support,
> though. To reiterate, everything works under 2.4 using ide-scsi.

You need to patch cdrom.c as well:

if ((fp->f_mode & FMODE_WRITE) && !CDROM_CAN(CDC_DVD_RAM))
return -EROFS;

> What can I do to help get this drive supported under 2.5/ide-cd?

I'm tempted to say ide-scsi + sd, but that goes against my principles...
It shouldn't be too much work to make ide-cd work gracefully.

--
Jens Axboe

2003-05-06 14:00:32

by Pascal Schmidt

[permalink] [raw]
Subject: Re: [IDE] trying to make MO drive work with ide-floppy/ide-cd

On Tue, 6 May 2003, Pascal Schmidt wrote:

> I'll check if reading from the MO drive works with ide-cd under 2.4
> as well. If it does: what about a patch that makes ATAPI MO drives
> and CD writers behave the same on 2.4: read-only with native ide drivers,
> read-write with ide-scsi?

I can now confirm that using the MO drive read-only with 2.4 and ide-cd
also works fine.

Could we please have this patch included in the 2.4 IDE code to make
MO drives and CD writers behave the same?

--- linux-2.4/drivers/ide/ide-probe.c Mon May 5 21:25:32 2003
+++ build/drivers/ide/ide-probe.c Tue May 6 16:03:28 2003
@@ -222,6 +222,7 @@ static inline void do_identify (ide_driv
break;
case ide_optical:
printk ("OPTICAL");
+ type = ide_cdrom;
drive->removable = 1;
break;
default:

--
Ciao,
Pascal

2003-05-06 15:06:45

by Pascal Schmidt

[permalink] [raw]
Subject: Re: [IDE] trying to make MO drive work with ide-floppy/ide-cd

On Tue, 6 May 2003, Jens Axboe wrote:

> It barfs at a lot of commands, not surprisingly. ide-cd really has no
> concept of devices other than cd/dvd.

I'm not complaining about those messages. ;)

> You need to patch cdrom.c as well:
>
> if ((fp->f_mode & FMODE_WRITE) && !CDROM_CAN(CDC_DVD_RAM))
> return -EROFS;
>

Simply removing that test doesn't get me working write support,
I still get:

# mount -t ext2 /dev/hde /mnt/mo
mount: block device /dev/hde is write-protected, mounting read-only

The disk is not write-protected, I checked.

>> What can I do to help get this drive supported under 2.5/ide-cd?
> I'm tempted to say ide-scsi + sd, but that goes against my principles...
> It shouldn't be too much work to make ide-cd work gracefully.

Well, I'm not familiar with the code at all, so I don't know where
to look.

--
Ciao,
Pascal

2003-05-06 15:02:47

by Pascal Schmidt

[permalink] [raw]
Subject: Re: [IDE] trying to make MO drive work with ide-floppy/ide-cd

On Tue, 6 May 2003, Jens Axboe wrote:

>> Could we please have this patch included in the 2.4 IDE code to make
>> MO drives and CD writers behave the same?
> Not until you fix ide-cd to correctly identify it. This half-assed
> solution wont do.

Okay. There's no problem using ide-scsi and sd for the MO drive
on 2.4.

--
Ciao,
Pascal

2003-05-06 15:13:13

by Jens Axboe

[permalink] [raw]
Subject: Re: [IDE] trying to make MO drive work with ide-floppy/ide-cd

On Tue, May 06 2003, Pascal Schmidt wrote:
> On Tue, 6 May 2003, Jens Axboe wrote:
>
> > It barfs at a lot of commands, not surprisingly. ide-cd really has no
> > concept of devices other than cd/dvd.
>
> I'm not complaining about those messages. ;)

No, but clearly something is wrong. At least that you should agree on.
And knowing hardware, there are probably drives out there that just wont
work because of the various "weird" commands it gets sent.

Just because it happens to work for you doesn't make it a viable
solution.

> > You need to patch cdrom.c as well:
> >
> > if ((fp->f_mode & FMODE_WRITE) && !CDROM_CAN(CDC_DVD_RAM))
> > return -EROFS;
> >
>
> Simply removing that test doesn't get me working write support,
> I still get:
>
> # mount -t ext2 /dev/hde /mnt/mo
> mount: block device /dev/hde is write-protected, mounting read-only
>
> The disk is not write-protected, I checked.

Shouldn't matter, the drive has to check for that particular bit (and it
obviously does not). Are we still talking 2.5 or 2.4?

> >> What can I do to help get this drive supported under 2.5/ide-cd?
> > I'm tempted to say ide-scsi + sd, but that goes against my principles...
> > It shouldn't be too much work to make ide-cd work gracefully.
>
> Well, I'm not familiar with the code at all, so I don't know where
> to look.

You can play with the c code, you've demonstrated that much so far. So
play some more, find out which commands are aborted and why. The log
messages even tell you which ones. Now find out if these are necessary
for proper MO functionality or not. Or maybe some vital commands are
even missing, lots of fun there :). But it really should not be very
hard.

--
Jens Axboe

2003-05-06 15:31:08

by Jens Axboe

[permalink] [raw]
Subject: Re: [IDE] trying to make MO drive work with ide-floppy/ide-cd

On Tue, May 06 2003, Jens Axboe wrote:
> > > You need to patch cdrom.c as well:
> > >
> > > if ((fp->f_mode & FMODE_WRITE) && !CDROM_CAN(CDC_DVD_RAM))
> > > return -EROFS;
> > >
> >
> > Simply removing that test doesn't get me working write support,
> > I still get:
> >
> > # mount -t ext2 /dev/hde /mnt/mo
> > mount: block device /dev/hde is write-protected, mounting read-only
> >
> > The disk is not write-protected, I checked.
>
> Shouldn't matter, the drive has to check for that particular bit (and it
> obviously does not). Are we still talking 2.5 or 2.4?

You also need to fix this in ide-cd:

if (CDROM_CONFIG_FLAGS(drive)->dvd_ram)
set_disk_ro(drive->disk, 0);

--
Jens Axboe

2003-05-06 16:11:48

by Pascal Schmidt

[permalink] [raw]
Subject: Re: [IDE] trying to make MO drive work with ide-floppy/ide-cd

On Tue, 6 May 2003, Jens Axboe wrote:

> You also need to fix this in ide-cd:
>
> if (CDROM_CONFIG_FLAGS(drive)->dvd_ram)
> set_disk_ro(drive->disk, 0);

Ah, yes. I saw that line, but didn't pay attention.

--
Ciao,
Pascal

2003-05-06 16:11:05

by Pascal Schmidt

[permalink] [raw]
Subject: Re: [IDE] trying to make MO drive work with ide-floppy/ide-cd

On Tue, 6 May 2003, Jens Axboe wrote:

> No, but clearly something is wrong. At least that you should agree on.

Yes, I would guess the MO drive doesn't like most commands that are
used for DVD/CD-ROMs and writers.

> And knowing hardware, there are probably drives out there that just wont
> work because of the various "weird" commands it gets sent.

Okay, I was assuming those errors don't do harm, but that might
be wrong, yeah.

> Just because it happens to work for you doesn't make it a viable
> solution.

Agreed.

> Shouldn't matter, the drive has to check for that particular bit (and it
> obviously does not). Are we still talking 2.5 or 2.4?

2.5
The solution with ide-scsi is good enough for me on 2.4, but since CD
burning also doesn't need ide-scsi any more on 2.5, I'd like to use a
kernel without any SCSI code in it.

> You can play with the c code, you've demonstrated that much so far. So
> play some more, find out which commands are aborted and why. The log
> messages even tell you which ones.

Okay. I'll try to find a way to pass the information that the drive
was originally detected as ide_optical down to ide-cd.c so I can skip
the commands that don't make sense on an MO drive.

> Now find out if these are necessary
> for proper MO functionality or not. Or maybe some vital commands are
> even missing, lots of fun there :). But it really should not be very
> hard.

I'll go play with the code some more, then.

--
Ciao,
Pascal

2003-05-06 17:47:28

by Pascal Schmidt

[permalink] [raw]
Subject: Re: [IDE] trying to make MO drive work with ide-floppy/ide-cd

On Tue, 6 May 2003, Jens Axboe wrote:

> You can play with the c code, you've demonstrated that much so far. So
> play some more, find out which commands are aborted and why. The log
> messages even tell you which ones. Now find out if these are necessary
> for proper MO functionality or not. Or maybe some vital commands are
> even missing, lots of fun there :). But it really should not be very
> hard.

Ok, I got a little bit further with the patch below. I can mount to disk
read-write and do a few things:

$ mount -t ext2 /dev/hde /mnt/mo
$ echo "foo" > /mnt/mo/bar
$ cat /mnt/mo/bar
foo
$ sync

No problem so far. But then

$ umount /mnt/mo

gets me:

------------[ cut here ]------------
kernel BUG at fs/buffer.c:2607!
invalid operand: 0000 [#1]
CPU: 0
EIP: 0060:[<c01466f6>] Not tainted
EFLAGS: 00010202
EIP is at submit_bh+0x26/0x110
eax: 00000010 ebx: da449bd0 ecx: dfbb4c34 edx: c1494e98
esi: 00000001 edi: c0394900 ebp: de77d200 esp: de04bea8
ds: 007b es: 007b ss: 0068
Process umount (pid: 1161, threadinfo=de04a000 task=de210c60)
Stack: dd52a400 da449bd0 c01468e0 00000001 da449bd0 dfbb4b84 00000004 da449bd0
de77d200 dd52a400 de77d200 c0188342 da449bd0 00000000 df7c0498 c0186fb9
de77d200 dd52a400 de04a000 00000000 de04bf08 c0157e44 de04bf08 dfbb4c18
Call Trace:
[<c01468e0>] sync_dirty_buffer+0x80/0xb0
[<c0188342>] ext2_sync_super+0x42/0x50
[<c0186fb9>] ext2_put_super+0x29/0x90
[<c0157e44>] invalidate_inodes+0xa4/0xc0
[<c0147d70>] generic_shutdown_super+0xa0/0x140
[<c0148682>] kill_block_super+0x12/0x30
[<c0147bb7>] deactivate_super+0x67/0xa0
[<c015a467>] __mntput+0x17/0x30
[<c014d837>] path_release+0x27/0x30
[<c015abff>] sys_umount+0x7f/0x90
[<c0138783>] sys_munmap+0x43/0x60
[<c015ac1b>] sys_oldumount+0xb/0x10
[<c0108dbf>] syscall_call+0x7/0xb

Code: 0f 0b 2f 0a a6 3a 33 c0 8b 4b 20 85 c9 75 08 0f 0b 30 0a a6

umount then segfaults. The BUG is from:

int submit_bh(int rw, struct buffer_head * bh)
{
struct bio *bio;

BUG_ON(!buffer_locked(bh));
BUG_ON(!buffer_mapped(bh));
^^^^^^^^^^^^^^^^^^^^^^^^^^^ this one

After this, the MO drive is dead until I reboot. Trying to mount the disk
read-only after that reboot works without problems. Trying to mount
read-write gives the same BUG_ON again on umount.

Running e2fsck from a 2.4 kernel shows that the directory entry for
/mnt/mo/bar did in fact get written to the disk, but fsck reports it
as using an unused inode, so I guess the inode and data writes did
not happen due to the BUG_ON.

Something seems to missing still.

My patch:

--- linux-2.5/include/linux/cdrom.h Thu Apr 24 16:39:43 2003
+++ build25/include/linux/cdrom.h Tue May 6 18:39:41 2003
@@ -387,6 +387,7 @@ struct cdrom_generic_command
#define CDC_DVD 0x8000 /* drive is a DVD */
#define CDC_DVD_R 0x10000 /* drive can write DVD-R */
#define CDC_DVD_RAM 0x20000 /* drive can write DVD-RAM */
+#define CDC_MO 0x40000 /* drive is an MO */

/* drive status possibilities returned by CDROM_DRIVE_STATUS ioctl */
#define CDS_NO_INFO 0 /* if not implemented */
--- linux-2.5/drivers/cdrom/cdrom.c Fri Mar 21 07:01:46 2003
+++ build25/drivers/cdrom/cdrom.c Tue May 6 18:40:51 2003
@@ -425,7 +425,8 @@ int cdrom_open(struct cdrom_device_info
if ((fp->f_flags & O_NONBLOCK) && (cdi->options & CDO_USE_FFLAGS))
ret = cdi->ops->open(cdi, 1);
else {
- if ((fp->f_mode & FMODE_WRITE) && !CDROM_CAN(CDC_DVD_RAM))
+ if ((fp->f_mode & FMODE_WRITE)
+ && !(CDROM_CAN(CDC_DVD_RAM) || CDROM_CAN(CDC_MO)))
return -EROFS;

ret = open_for_data(cdi);
--- linux-2.5/drivers/ide/ide.c Thu May 1 15:01:12 2003
+++ build25/drivers/ide/ide.c Tue May 6 17:01:34 2003
@@ -1518,6 +1518,7 @@ int generic_ide_ioctl(struct block_devic
return ide_taskfile_ioctl(drive, cmd, arg);
#ifdef CONFIG_PKT_TASK_IOCTL
case ide_cdrom:
+ case ide_optical:
case ide_tape:
case ide_floppy:
return pkt_taskfile_ioctl(drive, cmd, arg);
--- linux-2.5/drivers/ide/ide-probe.c Sat Apr 26 18:49:57 2003
+++ build25/drivers/ide/ide-probe.c Tue May 6 19:07:37 2003
@@ -1235,7 +1235,7 @@ struct gendisk *ata_probe(dev_t dev, int
(void) request_module("ide-disk");
if (drive->scsi)
(void) request_module("ide-scsi");
- if (drive->media == ide_cdrom)
+ if ((drive->media == ide_cdrom) || (drive->media == ide_optical))
(void) request_module("ide-cd");
if (drive->media == ide_tape)
(void) request_module("ide-tape");
--- linux-2.5/drivers/ide/ide-cd.h Sat Nov 2 22:12:01 2002
+++ build25/drivers/ide/ide-cd.h Tue May 6 18:33:28 2003
@@ -85,7 +85,8 @@ struct ide_cd_config_flags {
__u8 audio_play : 1; /* can do audio related commands */
__u8 close_tray : 1; /* can close the tray */
__u8 writing : 1; /* pseudo write in progress */
- __u8 reserved : 3;
+ __u8 mo : 1; /* Drive is an MO */
+ __u8 reserved : 2;
byte max_speed; /* Max speed of the drive */
};
#define CDROM_CONFIG_FLAGS(drive) (&(((struct cdrom_info *)(drive->driver_data))->config_flags))
--- linux-2.5/drivers/ide/ide-cd.c Sun Apr 20 23:52:14 2003
+++ build25/drivers/ide/ide-cd.c Tue May 6 19:26:24 2003
@@ -2793,7 +2793,7 @@ static struct cdrom_device_ops ide_cdrom
CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO | CDC_RESET |
CDC_IOCTLS | CDC_DRIVE_STATUS | CDC_CD_R |
CDC_CD_RW | CDC_DVD | CDC_DVD_R| CDC_DVD_RAM |
- CDC_GENERIC_PACKET,
+ CDC_GENERIC_PACKET | CDC_MO,
.generic_packet = ide_cdrom_packet,
};

@@ -2826,6 +2826,8 @@ static int ide_cdrom_register (ide_drive
devinfo->mask |= CDC_PLAY_AUDIO;
if (!CDROM_CONFIG_FLAGS(drive)->close_tray)
devinfo->mask |= CDC_CLOSE_TRAY;
+ if (!CDROM_CONFIG_FLAGS(drive)->mo)
+ devinfo->mask |= CDC_MO;

return register_cdrom(devinfo);
}
@@ -2871,12 +2873,17 @@ int ide_cdrom_probe_capabilities (ide_dr
struct atapi_capabilities_page cap;
int nslots = 1;

+ if (drive->media == ide_optical) {
+ CDROM_CONFIG_FLAGS(drive)->mo = 1;
+ return nslots;
+ }
+
if (CDROM_CONFIG_FLAGS(drive)->nec260) {
CDROM_CONFIG_FLAGS(drive)->no_eject = 0;
CDROM_CONFIG_FLAGS(drive)->audio_play = 1;
return nslots;
}
-
+
if (ide_cdrom_get_capabilities(drive, &cap))
return 0;

@@ -3104,6 +3111,7 @@ int ide_cdrom_setup (ide_drive_t *drive)
CDROM_CONFIG_FLAGS(drive)->supp_disc_present = 0;
CDROM_CONFIG_FLAGS(drive)->audio_play = 0;
CDROM_CONFIG_FLAGS(drive)->close_tray = 1;
+ CDROM_CONFIG_FLAGS(drive)->mo = 0;

/* limit transfer size per interrupt. */
CDROM_CONFIG_FLAGS(drive)->limit_nframes = 0;
@@ -3180,7 +3188,8 @@ int ide_cdrom_setup (ide_drive_t *drive)

nslots = ide_cdrom_probe_capabilities (drive);

- if (CDROM_CONFIG_FLAGS(drive)->dvd_ram)
+ if (CDROM_CONFIG_FLAGS(drive)->dvd_ram
+ || CDROM_CONFIG_FLAGS(drive)->mo)
set_disk_ro(drive->disk, 0);

#if 0
@@ -3337,7 +3346,7 @@ static int ide_cdrom_attach (ide_drive_t
goto failed;
if (!drive->present)
goto failed;
- if (drive->media != ide_cdrom)
+ if ((drive->media != ide_cdrom) && (drive->media != ide_optical))
goto failed;
/* skip drives that we were told to ignore */
if (ignore != NULL) {

--
Ciao,
Pascal

2003-05-06 17:51:38

by Jens Axboe

[permalink] [raw]
Subject: Re: [IDE] trying to make MO drive work with ide-floppy/ide-cd

On Tue, May 06 2003, Pascal Schmidt wrote:
> On Tue, 6 May 2003, Jens Axboe wrote:
>
> > You can play with the c code, you've demonstrated that much so far. So
> > play some more, find out which commands are aborted and why. The log
> > messages even tell you which ones. Now find out if these are necessary
> > for proper MO functionality or not. Or maybe some vital commands are
> > even missing, lots of fun there :). But it really should not be very
> > hard.
>
> Ok, I got a little bit further with the patch below. I can mount to disk
> read-write and do a few things:
>
> $ mount -t ext2 /dev/hde /mnt/mo
> $ echo "foo" > /mnt/mo/bar
> $ cat /mnt/mo/bar
> foo
> $ sync
>
> No problem so far. But then
>
> $ umount /mnt/mo
>
> gets me:
>
> ------------[ cut here ]------------
> kernel BUG at fs/buffer.c:2607!

Not good. Does it work correctly with 2kb block size? I would not be
surprised if ide-cd had multi page bio bugs...

> My patch:

Not bad, see that wasn't so hard. Does it load ide-cd without errors
with this one?

--
Jens Axboe

2003-05-06 18:05:42

by Pascal Schmidt

[permalink] [raw]
Subject: Re: [IDE] trying to make MO drive work with ide-floppy/ide-cd

On Tue, 6 May 2003, Jens Axboe wrote:

>> ------------[ cut here ]------------
>> kernel BUG at fs/buffer.c:2607!
> Not good. Does it work correctly with 2kb block size? I would not be
> surprised if ide-cd had multi page bio bugs...

The ext2 filesystem in question uses 2kb block size. The drive can also
handle disks with 1kb and 512b block sizes, but I don't have of those
disks (MOs are hard sectored, so you can't format one to use a different
hw block size).

Under 2.4 with ide-scsi/sd, ext2 with 2kb block size works, other block
sizes for the filesystem don't work (at least that was the case about a
year ago when I tried other sizes the last time).

>> My patch:
> Not bad, see that wasn't so hard.

Turned out to be quite easy once I found out that ide_cdrom_attach was
checking for drive->media == ide_cdrom. I had only looked as far as
ide_cdrom_setup before. :)

Too bad writing doesn't work out quite yet. At least the directory entry
got written, so part of it seems to work.

> Does it load ide-cd without errors with this one?

Yes, the error messages are gone. I skipped all the capability tests that
go to the drive. Maybe that skips to much. Where does the hw block size
get detected? I hope I didn't skip that part...

--
Ciao,
Pascal

2003-05-07 17:49:50

by Pascal Schmidt

[permalink] [raw]
Subject: Re: [IDE] trying to make MO drive work with ide-floppy/ide-cd

On Tue, 6 May 2003, Pascal Schmidt wrote:

The below patch allows me to use the ATAPI MO drive read-only using
ide-cd. It does not send the drive any commands it might not understand.
I'm still trying to get write support to work, but being able to read
from the drive is an independent feature and useful in itself, I think.
Would it be possible to apply this to 2.5?

Tested by reading an entire ext2 filesystem from an MO disk and comparing
against the result obtained from 2.4 with ide-scsi/sd. No differences.

Patch against 2.5-bkcvs.

Index: drivers/ide/ide-cd.c
===================================================================
RCS file: /home/bkcvs/linux-2.5/drivers/ide/ide-cd.c,v
retrieving revision 1.107
diff -u -1 -b -p -r1.107 ide-cd.c
--- drivers/ide/ide-cd.c 20 Apr 2003 21:52:14 -0000 1.107
+++ drivers/ide/ide-cd.c 7 May 2003 17:34:30 -0000
@@ -2873,2 +2873,7 @@ int ide_cdrom_probe_capabilities (ide_dr

+ if (drive->media == ide_optical) {
+ printk("%s: ATAPI magneto-optical drive\n", drive->name);
+ return nslots;
+ }
+
if (CDROM_CONFIG_FLAGS(drive)->nec260) {
@@ -3339,3 +3344,3 @@ static int ide_cdrom_attach (ide_drive_t
goto failed;
- if (drive->media != ide_cdrom)
+ if (drive->media != ide_cdrom && drive->media != ide_optical)
goto failed;
Index: drivers/ide/ide-probe.c
===================================================================
RCS file: /home/bkcvs/linux-2.5/drivers/ide/ide-probe.c,v
retrieving revision 1.85
diff -u -1 -b -p -r1.85 ide-probe.c
--- drivers/ide/ide-probe.c 24 Apr 2003 17:07:04 -0000 1.85
+++ drivers/ide/ide-probe.c 7 May 2003 17:25:37 -0000
@@ -1237,3 +1237,3 @@ struct gendisk *ata_probe(dev_t dev, int
(void) request_module("ide-scsi");
- if (drive->media == ide_cdrom)
+ if (drive->media == ide_cdrom || drive->media == ide_optical)
(void) request_module("ide-cd");

--
Ciao,
Pascal

2003-05-07 19:23:23

by Jens Axboe

[permalink] [raw]
Subject: Re: [IDE] trying to make MO drive work with ide-floppy/ide-cd

On Wed, May 07 2003, Pascal Schmidt wrote:
> On Tue, 6 May 2003, Pascal Schmidt wrote:
>
> The below patch allows me to use the ATAPI MO drive read-only using
> ide-cd. It does not send the drive any commands it might not understand.
> I'm still trying to get write support to work, but being able to read
> from the drive is an independent feature and useful in itself, I think.
> Would it be possible to apply this to 2.5?
>
> Tested by reading an entire ext2 filesystem from an MO disk and comparing
> against the result obtained from 2.4 with ide-scsi/sd. No differences.

Definitely, this looks like a fine start. As far as I'm concerned, it
would be fine to commit to 2.5.

--
Jens Axboe

2003-05-08 11:20:53

by Pascal Schmidt

[permalink] [raw]
Subject: Re: [IDE] trying to make MO drive work with ide-floppy/ide-cd

On Wed, 7 May 2003, Jens Axboe wrote:

> Definitely, this looks like a fine start. As far as I'm concerned, it
> would be fine to commit to 2.5.

As maintainer of ide-cd, would you forward it to Linus, then?
CCed Alan for the ide-probe.c change.

Index: drivers/ide/ide-cd.c
===================================================================
RCS file: /home/bkcvs/linux-2.5/drivers/ide/ide-cd.c,v
retrieving revision 1.107
diff -u -1 -b -p -r1.107 ide-cd.c
--- drivers/ide/ide-cd.c 20 Apr 2003 21:52:14 -0000 1.107
+++ drivers/ide/ide-cd.c 7 May 2003 17:34:30 -0000
@@ -2873,2 +2873,7 @@ int ide_cdrom_probe_capabilities (ide_dr

+ if (drive->media == ide_optical) {
+ printk("%s: ATAPI magneto-optical drive\n", drive->name);
+ return nslots;
+ }
+
if (CDROM_CONFIG_FLAGS(drive)->nec260) {
@@ -3339,3 +3344,3 @@ static int ide_cdrom_attach (ide_drive_t
goto failed;
- if (drive->media != ide_cdrom)
+ if (drive->media != ide_cdrom && drive->media != ide_optical)
goto failed;
Index: drivers/ide/ide-probe.c
===================================================================
RCS file: /home/bkcvs/linux-2.5/drivers/ide/ide-probe.c,v
retrieving revision 1.85
diff -u -1 -b -p -r1.85 ide-probe.c
--- drivers/ide/ide-probe.c 24 Apr 2003 17:07:04 -0000 1.85
+++ drivers/ide/ide-probe.c 7 May 2003 17:25:37 -0000
@@ -1237,3 +1237,3 @@ struct gendisk *ata_probe(dev_t dev, int
(void) request_module("ide-scsi");
- if (drive->media == ide_cdrom)
+ if (drive->media == ide_cdrom || drive->media == ide_optical)
(void) request_module("ide-cd");

--
Ciao,
Pascal

2003-05-08 11:56:29

by Jens Axboe

[permalink] [raw]
Subject: Re: [IDE] trying to make MO drive work with ide-floppy/ide-cd

On Thu, May 08 2003, Pascal Schmidt wrote:
> On Wed, 7 May 2003, Jens Axboe wrote:
>
> > Definitely, this looks like a fine start. As far as I'm concerned, it
> > would be fine to commit to 2.5.
>
> As maintainer of ide-cd, would you forward it to Linus, then?
> CCed Alan for the ide-probe.c change.

Yes I will, I'm checking with Bart too if he's fine with the change.

--
Jens Axboe

Subject: Re: [IDE] trying to make MO drive work with ide-floppy/ide-cd


On Thu, 8 May 2003, Jens Axboe wrote:

> On Thu, May 08 2003, Pascal Schmidt wrote:
> > On Wed, 7 May 2003, Jens Axboe wrote:
> >
> > > Definitely, this looks like a fine start. As far as I'm concerned, it
> > > would be fine to commit to 2.5.
> >
> > As maintainer of ide-cd, would you forward it to Linus, then?
> > CCed Alan for the ide-probe.c change.
>
> Yes I will, I'm checking with Bart too if he's fine with the change.

Looks okay and straightforward.
--
Bartlomiej

> --
> Jens Axboe

2003-05-08 12:30:58

by Pascal Schmidt

[permalink] [raw]
Subject: Re: [IDE] trying to make MO drive work with ide-floppy/ide-cd

On Thu, 8 May 2003, Bartlomiej Zolnierkiewicz wrote:

>>> As maintainer of ide-cd, would you forward it to Linus, then?
>>> CCed Alan for the ide-probe.c change.
>>
>> Yes I will, I'm checking with Bart too if he's fine with the change.
>
> Looks okay and straightforward.

Thanks a lot, you two!

--
Ciao,
Pascal