Skip to contentSkip to conversation

Problems with Toshiba SD-W2002 DVD-RAM drive (IDE)

DISCUSSION Stefan Jaschke 2 participants 12 messages Apr 17, 2001 – Apr 21, 2001

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Judging from the thread started Jan 1, 2001, by Andre Hedrick, I thought IDE DVD-RAM just works out of the box and got a Toshiba SD-W2002.

Problem: /dev/hdc cannot be read or written to when the drive contains
DVD-RAM media. The behavior is the same for the stock 2.4.3 kernel and the SuSE-2.4.0 kernel. Strangely enough, the disk can be read, but not written to, with the 2.2.18 kernel.

Diagnostics:
(1) The hardware is properly connected: mounting CD-ROMs and the SuSE-7.1 DVD-ROM works.
(2) The drive is recognized at boot time (2.4.3 kernel):
from "/var/log/boot.msg":
<4>ide_setup: idebus=33
<4>ide_setup: ide0=dma
<4>ide_setup: ide0=ata66
<4>ide: Assuming 33MHz system bus speed for PIO modes
<4>AMD7409: IDE controller on PCI bus 00 dev 39
<4>AMD7409: chipset revision 7
<4>AMD7409: not 100%% native mode: will probe irqs later <4>AMD7409: ATA-66/100 forced bit set (WARNING)!!
<4> ide0: BM-DMA at 0xf000-0xf007, BIOS settings: hda:DMA, hdb:pio
<4> ide1: BM-DMA at 0xf008-0xf00f, BIOS settings: hdc:DMA, hdd:pio
<4>hda: IBM-DTLA-307030, ATA DISK drive
<4>hdc: TOSHIBA DVD-RAM SD-W2002, ATAPI CD/DVD-ROM drive
<4>ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
<4>ide1 at 0x170-0x177,0x376 on irq 15
<6>hda: 60036480 sectors (30739 MB) w/1916KiB Cache, CHS=3737/255/63, UDMA(66) <4>hdc: ATAPI 24X DVD-ROM DVDAM drive, 8192kB Cache, DMA <6>Uniform CD-ROM driver Revision: 3.12

# cat /proc/sys/dev/cdrom/info 
CD-ROM information, Id: cdrom.c 3.12 2000/10/18
drive name:             hdc
drive speed:            0
drive # of slots:       1
Can close tray:         1
Can open tray:          1
Can lock tray:          1
Can change speed:       1
Can select disk:        0
Can read multisession:  1
Can read MCN:           1
Reports media changed:  1
Can play audio:         1
Can write CD-R:         0
Can write CD-RW:        0
Can read DVD:           1
Can write DVD-R:        0
Can write DVD-RAM:      1
# cat /proc/ide/hdc/settings 
name                    value           min             max             mode
----                    -----           ---             ---             ----
breada_readahead        4               0               127             rw
current_speed           34              0               69              rw
dsc_overlap             0               0               1               rw
file_readahead          0               0               2097151         rw
ide_scsi                0               0               1               rw
init_speed              34              0               69              rw
io_32bit                0               0               3               rw
keepsettings            0               0               1               rw
max_kb_per_request      127             1               127             rw
nice1                   1               0               1               rw
number                  2               0               3               rw
pio_mode                write-only      0               255             w
slow                    0               0               1               rw
unmaskirq               0               0               1               rw
using_dma               1               0               1               rw

(3) the DVD-RAM medium cannot be read from or written to:

# dd if=/dev/hdc of=/dev/null bs=2048 count=8 
0+0 records in
0+0 records out
# dd if=/dev/null of=/dev/hdc bs=2048 count=8 
0+0 records in
0+0 records out
# fdisk /dev/hdc
Unable to read /dev/hdc
# badblocks /dev/hdc
0
1
2
3
4
...
# mke2fs -v -b 2048 -m 0 /dev/hdc
mke2fs 1.19, 13-Jul-2000 for EXT2 FS 0.5b, 95/08/09
/dev/hdc: Memory allocation failed while setting up superblock
# mkudf --media-type=dvdram --blocksize=2048 /dev/hdc
7200 (CEST)/-120
mkudf: min blocks=1762

(Just to make sure, I tried 2 different DVD-RAM media.)
______________________________________________________________________________

I am somewhat clueless what to do next.
Are there any experiences with this or other IDE DVD-RAM drives?

Stefan J.

Signature · 2 lines
Stefan R. Jaschke <[email protected]>
http://www.jaschke-net.de
#1 lore raw
Quoted 8 lines · Stefan Jaschke

Judging from the thread started Jan 1, 2001, by Andre Hedrick, I thought IDE DVD-RAM just works out of the box and got a Toshiba SD-W2002.

Problem: /dev/hdc cannot be read or written to when the drive contains
DVD-RAM media. The behavior is the same for the stock 2.4.3 kernel and the SuSE-2.4.0 kernel. Strangely enough, the disk can be read, but not written to, with the 2.2.18 kernel.

It should work, note that I recently spotted some quite severe bugs in the pio write handling for ATAPI which I've almost fixed here now. It seems you drive is in DMA mode though, so it shouldn't be affecting you.

Please send me strace info when reading/writing to the drive (or at least attempting to), this looks very queer indeed.

Signature · 1 line
Jens Axboe
#2 lore raw
In reply to Stefan Jaschke
Quoted 5 lines · Jens Axboe
Quoted 4 lines · Stefan Jaschke

Judging from the thread started Jan 1, 2001, by Andre Hedrick, I thought IDE DVD-RAM just works out of the box and got a Toshiba SD-W2002.

Quoted 8 lines
Quoted 4 lines

Problem: /dev/hdc cannot be read or written to when the drive contains
DVD-RAM media. The behavior is the same for the stock 2.4.3 kernel and the SuSE-2.4.0 kernel. Strangely enough, the disk can be read, but not written to, with the 2.2.18 kernel.

It should work, note that I recently spotted some quite severe bugs in the pio write handling for ATAPI which I've almost fixed here now. It seems you drive is in DMA mode though, so it shouldn't be affecting you.

Attached patch for 2.4.4-pre4 which fixes all known DVD-RAM ATAPI bugs. Both pio and dma mode work fine here, using ext2, on a 9.4gb HITACHI DVD-RAM GF-2000 drive.

Signature · 1 line
Jens Axboe
drivers/cdrom/cdrom.c renamed from opt/kernel/linux-2.4.4-pre4/drivers/cdrom/cdrom.c +74 -5
diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.4-pre4/drivers/cdrom/cdrom.c linux/drivers/cdrom/cdrom.c
@@ -279,6 +279,9 @@
 static int lockdoor = 1;
 /* will we ever get to use this... sigh. */
 static int check_media_type;
+static unsigned long *cdrom_numbers;
+static DECLARE_MUTEX(cdrom_sem);
+
 MODULE_PARM(debug, "i");
 MODULE_PARM(autoclose, "i");
 MODULE_PARM(autoeject, "i");
@@ -340,6 +343,38 @@
 	check_media_change:	cdrom_media_changed,
 };
 
+/*
+ * get or clear a new cdrom number, run under cdrom_sem
+ */
+static int cdrom_get_entry(void)
+{
+	int i, nr, foo;
+
+	nr = 0;
+	foo = -1;
+	for (i = 0; i < CDROM_MAX_CDROMS / (sizeof(unsigned long) * 8); i++) {
+		if (cdrom_numbers[i] == ~0UL) {
+			nr += sizeof(unsigned long) * 8;
+			continue;
+		}
+		foo = ffz(cdrom_numbers[i]);
+		set_bit(foo, &cdrom_numbers[i]);
+		nr += foo;
+		break;
+	}
+
+	return foo == -1 ? foo : nr;
+}
+
+static void cdrom_clear_entry(struct cdrom_device_info *cdi)
+{
+	int bit_nr = cdi->nr & ~(sizeof(unsigned long) * 8);
+	int cd_index = cdi->nr / (sizeof(unsigned long) * 8);
+
+	clear_bit(bit_nr, &cdrom_numbers[cd_index]);
+}
+
+
 /* This macro makes sure we don't have to check on cdrom_device_ops
  * existence in the run-time routines below. Change_capability is a
  * hack to have the capability flags defined const, while we can still
@@ -354,7 +389,6 @@
         struct cdrom_device_ops *cdo = cdi->ops;
         int *change_capability = (int *)&cdo->capability; /* hack */
 	char vname[16];
-	static unsigned int cdrom_counter;
 
 	cdinfo(CD_OPEN, "entering register_cdrom\n"); 
 
@@ -395,7 +429,17 @@
 
 	if (!devfs_handle)
 		devfs_handle = devfs_mk_dir (NULL, "cdroms", NULL);
-	sprintf (vname, "cdrom%u", cdrom_counter++);
+
+	/*
+	 * get new cdrom number
+	 */
+	down(&cdrom_sem);
+	cdi->nr = cdrom_get_entry();
+	up(&cdrom_sem);
+	if (cdi->nr == -1)
+		return -ENOMEM;
+
+	sprintf(vname, "cdrom%u", cdi->nr);
 	if (cdi->de) {
 		int pos;
 		devfs_handle_t slave;
@@ -418,9 +462,13 @@
 				    S_IFBLK | S_IRUGO | S_IWUGO,
 				    &cdrom_fops, NULL);
 	}
-	cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
+
+	down(&cdrom_sem);
 	cdi->next = topCdromPtr; 	
 	topCdromPtr = cdi;
+	up(&cdrom_sem);
+
+	cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
 	return 0;
 }
 #undef ENSURE
@@ -429,12 +477,14 @@
 {
 	struct cdrom_device_info *cdi, *prev;
 	int major = MAJOR(unreg->dev);
+	int bit_nr, cd_index;
 
 	cdinfo(CD_OPEN, "entering unregister_cdrom\n"); 
 
 	if (major < 0 || major >= MAX_BLKDEV)
 		return -1;
 
+	down(&cdrom_sem);
 	prev = NULL;
 	cdi = topCdromPtr;
 	while (cdi != NULL && cdi->dev != unreg->dev) {
@@ -442,14 +492,20 @@
 		cdi = cdi->next;
 	}
 
-	if (cdi == NULL)
+	if (cdi == NULL) {
+		up(&cdrom_sem);
 		return -2;
+	}
+
+	cdrom_clear_entry(cdi);
+
 	if (prev)
 		prev->next = cdi->next;
 	else
 		topCdromPtr = cdi->next;
+	up(&cdrom_sem);
 	cdi->ops->n_minors--;
-	devfs_unregister (cdi->de);
+	devfs_unregister(cdi->de);
 	cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
 	return 0;
 }
@@ -458,10 +514,14 @@
 {
 	struct cdrom_device_info *cdi;
 
+	down(&cdrom_sem);
+
 	cdi = topCdromPtr;
 	while (cdi != NULL && cdi->dev != dev)
 		cdi = cdi->next;
 
+	up(&cdrom_sem);
+
 	return cdi;
 }
 
@@ -2418,6 +2478,8 @@
 	}
 
 	pos = sprintf(info, "CD-ROM information, " VERSION "\n");
+
+	down(&cdrom_sem);
 	
 	pos += sprintf(info+pos, "\ndrive name:\t");
 	for (cdi=topCdromPtr;cdi!=NULL;cdi=cdi->next)
@@ -2487,6 +2549,8 @@
 	for (cdi=topCdromPtr;cdi!=NULL;cdi=cdi->next)
 	    pos += sprintf(info+pos, "\t%d", CDROM_CAN(CDC_DVD_RAM) != 0);
 
+	up(&cdrom_sem);
+
 	strcpy(info+pos,"\n\n");
 		
         return proc_dostring(ctl, write, filp, buffer, lenp);
@@ -2633,6 +2697,10 @@
 
 static int __init cdrom_init(void)
 {
+	int n_entries = CDROM_MAX_CDROMS / (sizeof(unsigned long) * 8);
+
+	cdrom_numbers = kmalloc(n_entries * sizeof(unsigned long), GFP_KERNEL);
+
 #ifdef CONFIG_SYSCTL
 	cdrom_sysctl_register();
 #endif
@@ -2643,6 +2711,7 @@
 static void __exit cdrom_exit(void)
 {
 	printk(KERN_INFO "Uniform CD-ROM driver unloaded\n");
+	kfree(cdrom_numbers);
 #ifdef CONFIG_SYSCTL
 	cdrom_sysctl_unregister();
 #endif
drivers/ide/ide-cd.c renamed from opt/kernel/linux-2.4.4-pre4/drivers/ide/ide-cd.c +119 -25

240 lines not on this page · raw message

drivers/ide/ide-cd.h renamed from opt/kernel/linux-2.4.4-pre4/drivers/ide/ide-cd.h +4 -3
diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.4-pre4/drivers/ide/ide-cd.h linux/drivers/ide/ide-cd.h
@@ -37,11 +37,12 @@
 
 /************************************************************************/
 
-#define SECTOR_SIZE		512
 #define SECTOR_BITS 		9
-#define SECTORS_PER_FRAME	(CD_FRAMESIZE / SECTOR_SIZE)
+#define SECTOR_SIZE		(1 << SECTOR_BITS)
+#define SECTORS_PER_FRAME	(CD_FRAMESIZE >> SECTOR_BITS)
 #define SECTOR_BUFFER_SIZE	(CD_FRAMESIZE * 32)
-#define SECTORS_BUFFER		(SECTOR_BUFFER_SIZE / SECTOR_SIZE)
+#define SECTORS_BUFFER		(SECTOR_BUFFER_SIZE >> SECTOR_BITS)
+#define SECTORS_MAX		(131072 >> SECTOR_BITS)
 
 #define BLOCKS_PER_FRAME	(CD_FRAMESIZE / BLOCK_SIZE)
 
drivers/scsi/sr.c renamed from opt/kernel/linux-2.4.4-pre4/drivers/scsi/sr.c +12 -5
diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.4-pre4/drivers/scsi/sr.c linux/drivers/scsi/sr.c
@@ -262,7 +262,7 @@
 static int sr_scatter_pad(Scsi_Cmnd *SCpnt, int s_size)
 {
 	struct scatterlist *sg, *old_sg = NULL;
-	int i, fsize, bsize, sg_ent;
+	int i, fsize, bsize, sg_ent, sg_count;
 	char *front, *back;
 
 	back = front = NULL;
@@ -290,17 +290,24 @@
 	/*
 	 * extend or allocate new scatter-gather table
 	 */
-	if (SCpnt->use_sg)
+	sg_count = SCpnt->use_sg;
+	if (sg_count)
 		old_sg = (struct scatterlist *) SCpnt->request_buffer;
 	else {
-		SCpnt->use_sg = 1;
+		sg_count = 1;
 		sg_ent++;
 	}
 
-	SCpnt->sglist_len = ((sg_ent * sizeof(struct scatterlist)) + 511) & ~511;
-	if ((sg = scsi_malloc(SCpnt->sglist_len)) == NULL)
+	i = ((sg_ent * sizeof(struct scatterlist)) + 511) & ~511;
+	if ((sg = scsi_malloc(i)) == NULL)
 		goto no_mem;
 
+	/*
+	 * no more failing memory allocs possible, we can safely assign
+	 * SCpnt values now
+	 */
+	SCpnt->sglist_len = i;
+	SCpnt->use_sg = sg_count;
 	memset(sg, 0, SCpnt->sglist_len);
 
 	i = 0;
drivers/scsi/sr_ioctl.c renamed from opt/kernel/linux-2.4.4-pre4/drivers/scsi/sr_ioctl.c +2 -0
diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.4-pre4/drivers/scsi/sr_ioctl.c linux/drivers/scsi/sr_ioctl.c
@@ -530,6 +530,8 @@
 	target = MINOR(cdi->dev);
 
 	switch (cmd) {
+	case BLKGETSIZE:
+		return put_user(scsi_CDs[target].capacity >> 1, (long *) arg);
 	case BLKROSET:
 	case BLKROGET:
 	case BLKRASET:
include/linux/cdrom.h renamed from opt/kernel/linux-2.4.4-pre4/include/linux/cdrom.h +3 -0
diff -ur --exclude-from /home/axboe/exclude /opt/kernel/linux-2.4.4-pre4/include/linux/cdrom.h linux/include/linux/cdrom.h
@@ -577,6 +577,8 @@
 	struct dvd_manufact	manufact;
 } dvd_struct;
 
+#define CDROM_MAX_CDROMS	256
+
 /*
  * DVD authentication ioctl
  */
@@ -732,6 +734,7 @@
 	devfs_handle_t de;		/* real driver creates this  */
 /* specifications */
         kdev_t dev;	                /* device number */
+	int nr;				/* cdrom entry */
 	int mask;                       /* mask of capability: disables them */
 	int speed;			/* maximum speed for reading data */
 	int capacity;			/* number of discs in jukebox */
#3 lore raw
In reply to Stefan Jaschke
Quoted 6 lines · Jens Axboe

Please send me strace info when reading/writing to the drive (or at least attempting to), this looks very queer indeed.

Attached patch for 2.4.4-pre4 which fixes all known DVD-RAM ATAPI bugs. Both pio and dma mode work fine here, using ext2, on a 9.4gb HITACHI DVD-RAM GF-2000 drive.

I'll try the patch asap.

Here is a quick strace (on the SuSE 2.4.0 kernel, since my SMC Etherpower doesn't work with 2.4.3) of a read with DVD-RAM medium inserted:

# strace dd if=/dev/hdc of=/dev/null bs=2k count=3
<... loading libraries ...>
close(0)                                = 0
open("/dev/hdc", O_RDONLY|O_LARGEFILE)  = 0
close(1)                                = 0
open("/dev/null", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 1
rt_sigaction(SIGINT, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGINT, {0x80493d0, [], 0x4000000}, NULL, 8) = 0
rt_sigaction(SIGQUIT, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGQUIT, {0x80493d0, [], 0x4000000}, NULL, 8) = 0
rt_sigaction(SIGPIPE, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGPIPE, {0x80493d0, [], 0x4000000}, NULL, 8) = 0
rt_sigaction(SIGUSR1, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGUSR1, {0x8049440, [], 0x4000000}, NULL, 8) = 0
brk(0x8054000)                          = 0x8054000
read(0, "", 2048)                       = 0
write(2, "0+0 records in\n", 150+0 records in
)        = 15
write(2, "0+0 records out\n", 160+0 records out
)       = 16
close(0)                                = 0
close(1)                                = 0
_exit(0)                                = ?

--------------------------------

Writing works, the LED is blinking. (I didn't know the difference between /dev/zero and /dev/null when I did the first post. Sorry.):

# strace dd if=/dev/zero of=/dev/hdc bs=2k count=3
<... loading libraries ...>
close(0)                                = 0
open("/dev/zero", O_RDONLY|O_LARGEFILE) = 0
close(1)                                = 0
open("/dev/hdc", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 1
rt_sigaction(SIGINT, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGINT, {0x80493d0, [], 0x4000000}, NULL, 8) = 0
rt_sigaction(SIGQUIT, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGQUIT, {0x80493d0, [], 0x4000000}, NULL, 8) = 0
rt_sigaction(SIGPIPE, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGPIPE, {0x80493d0, [], 0x4000000}, NULL, 8) = 0
rt_sigaction(SIGUSR1, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGUSR1, {0x8049440, [], 0x4000000}, NULL, 8) = 0
brk(0x8054000)                          = 0x8054000
read(0, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 2048) = 
2048
write(1, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 2048) = 
2048
read(0, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 2048) = 
2048
write(1, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 2048) = 
2048
read(0, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 2048) = 
2048
write(1, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 2048) = 
2048
write(2, "3+0 records in\n", 153+0 records in
)        = 15
write(2, "3+0 records out\n", 163+0 records out
)       = 16
close(0)                                = 0
close(1)                                = 0
_exit(0)                                = ?
-------------------------------------

But mke2fs does not work:

# strace mke2fs -b 2048 /dev/hdc
... <libraries loaded> ...
write(2, "mke2fs 1.19, 13-Jul-2000 for EXT"..., 52mke2fs 1.19, 13-Jul-2000 
for EXT2 FS 0.5b, 95/08/09
) = 52
stat64("/dev/hdc", {st_mode=S_IFBLK|0660, st_rdev=makedev(22, 0), ...}) = 0
open("/etc/mtab", O_RDONLY)             = 3
brk(0x8050000)                          = 0x8050000
fstat64(3, {st_mode=S_IFREG|0644, st_size=234, ...}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) 
= 0x40017000
read(3, "/dev/sda3 / ext2 rw 0 0\nproc /pr"..., 4096) = 234
read(3, "", 4096)                       = 0
close(3)                                = 0
munmap(0x40017000, 4096)                = 0
open("/dev/hdc", O_RDONLY|O_LARGEFILE)  = 3
ioctl(3, BLKGETSIZE, 0xbffff524)        = 0
close(3)                                = 0
open("/dev/hdc", O_RDWR|O_LARGEFILE)    = 3
time(NULL)                              = 987630857
old_mmap(NULL, 488173568, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 
-1, 0) = -1 ENOMEM (Cannot allocate memory)
brk(0x251df000)                         = 0x8050000
old_mmap(NULL, 2097152, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, 
-1, 0) = 0x40159000
munmap(0x40159000, 684032)              = 0
munmap(0x40300000, 364544)              = 0
mprotect(0x40200000, 32768, PROT_READ|PROT_WRITE) = 0
old_mmap(NULL, 488173568, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 
-1, 0) = -1 ENOMEM (Cannot allocate memory)
old_mmap(NULL, 488173568, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 
-1, 0) = -1 ENOMEM (Cannot allocate memory)
close(3)                                = 0
write(2, "/dev/hdc", 8/dev/hdc)                 = 8
write(2, ": ", 2: )                       = 2
write(2, "Memory allocation failed", 24Memory allocation failed) = 24
write(2, " ", 1 )                        = 1
write(2, "while setting up superblock", 27while setting up superblock) = 27
)                       = 1
write(2, "\n", 1
)                       = 1
_exit(1)                                = ?
___________________________________

Another story: With the SuSE DVD-ROM in the drive, the
"dd if=/dev/hdc of=/dev/null bs=2k count=3" also just reads 0 bytes as above, but the "mount -t iso9660 /dev/hdc /dvd" and then reading from /dvd succeeds.

Stefan

#4 lore raw
In reply to Stefan Jaschke

Hi Jens,

I applied your patch to 2.4.4-pre4. It compiled fine, but crashed during boot (just right after the IDE init) with
-------------------
Uniform CD-ROM driver Revision: 3.12

Unable to handle kernel NULL pointer dereference at virtual address 00000000
printing eip: ...
Oops: 0000

...
-------------------

I looked up the eip. It's in
c01a5490 t cdrom_get_entry
c01a5490 t gcc2_compiled.
(Although I don't know what the second line on the same address means.)

Please let me know, if you need more info or I can help in any other way.

Thanks,
Stefan

#5 lore raw
In reply to Stefan Jaschke
Quoted 11 lines · Stefan Jaschke

Hi Jens,

I applied your patch to 2.4.4-pre4. It compiled fine, but crashed during boot (just right after the IDE init) with
-------------------
Uniform CD-ROM driver Revision: 3.12

Unable to handle kernel NULL pointer dereference at virtual address 00000000
printing eip: ...
Oops: 0000

...
-------------------

This should fix it.

Signature · 1 line
Jens Axboe
cdrom/cdrom.c renamed from cdrom/cdrom.c~ +6 -4
@@ -350,6 +350,12 @@
 {
 	int i, nr, foo;
 
+	if (!cdrom_numbers) {
+		int n_entries = CDROM_MAX_CDROMS / (sizeof(unsigned long) * 8);
+		cdrom_numbers = kmalloc(n_entries * sizeof(unsigned long), GFP_KERNEL);
+		memset(cdrom_numbers, 0, n_entries * sizeof(unsigned long));
+	}
+
 	nr = 0;
 	foo = -1;
 	for (i = 0; i < CDROM_MAX_CDROMS / (sizeof(unsigned long) * 8); i++) {
@@ -2696,10 +2702,6 @@
 
 static int __init cdrom_init(void)
 {
-	int n_entries = CDROM_MAX_CDROMS / (sizeof(unsigned long) * 8);
-
-	cdrom_numbers = kmalloc(n_entries * sizeof(unsigned long), GFP_KERNEL);
-
 #ifdef CONFIG_SYSCTL
 	cdrom_sysctl_register();
 #endif
#6 lore raw
In reply to Stefan Jaschke
Quoted 4 lines
Quoted 2 lines

I applied your patch to 2.4.4-pre4. It compiled fine, but crashed during boot (just right after the IDE init) with

This should fix it.

It boots now. But I still cannot read a DVD-RAM disk (same behavior as before):

# strace dd of=/dev/null if=/dev/hdc bs=2k count=3
open("/dev/hdc", O_RDONLY|O_LARGEFILE)  = 0
close(1)                                = 0
open("/dev/null", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 1
rt_sigaction(SIGINT, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGINT, {0x80493d0, [], 0x4000000}, NULL, 8) = 0
rt_sigaction(SIGQUIT, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGQUIT, {0x80493d0, [], 0x4000000}, NULL, 8) = 0
rt_sigaction(SIGPIPE, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGPIPE, {0x80493d0, [], 0x4000000}, NULL, 8) = 0
rt_sigaction(SIGUSR1, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGUSR1, {0x8049440, [], 0x4000000}, NULL, 8) = 0
brk(0x8054000)                          = 0x8054000
read(0, "", 2048)                       = 0
write(2, "0+0 records in\n", 150+0 records in
)        = 15
write(2, "0+0 records out\n", 160+0 records out
)       = 16
close(0)                                = 0
close(1)                                = 0
_exit(0)                                = ?
------------------
Nor mke2fs:
# strace mke2fs -b 2048 /dev/hdc
open("/dev/hdc", O_RDONLY|O_LARGEFILE)  = 3
ioctl(3, BLKGETSIZE, 0xbffff524)        = 0
close(3)                                = 0
open("/dev/hdc", O_RDWR|O_LARGEFILE)    = 3
time(NULL)                              = 987682145
old_mmap(NULL, 472477696, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 
-1, 0) = -1 ENOMEM (Cannot allocate memory)
brk(0x242e7000)                         = 0x8050000
old_mmap(NULL, 2097152, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, 
-1, 0) = 0x40159000
munmap(0x40159000, 684032)              = 0
munmap(0x40300000, 364544)              = 0
mprotect(0x40200000, 32768, PROT_READ|PROT_WRITE) = 0
old_mmap(NULL, 472477696, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 
-1, 0) = -1 ENOMEM (Cannot allocate memory)
old_mmap(NULL, 472477696, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 
-1, 0) = -1 ENOMEM (Cannot allocate memory)
close(3)                                = 0
write(2, "/dev/hdc", 8/dev/hdc)                 = 8
write(2, ": ", 2: )                       = 2
write(2, "Memory allocation failed", 24Memory allocation failed) = 24
write(2, " ", 1 )                        = 1
write(2, "while setting up superblock", 27while setting up superblock) = 27
)                       = 1
write(2, "\n", 1
)                       = 1
_exit(1)                                = ?

Cheers,
Stefan

#7 lore raw
In reply to Stefan Jaschke
Quoted 7 lines · Stefan Jaschke
Quoted 4 lines
Quoted 2 lines

I applied your patch to 2.4.4-pre4. It compiled fine, but crashed during boot (just right after the IDE init) with

This should fix it.

It boots now. But I still cannot read a DVD-RAM disk (same behavior as before):

This is really strange, are you sure your drive is ok? Does mounting dvd-rom and cd-rom's work fine?

Signature · 1 line
Jens Axboe
#8 lore raw
In reply to Stefan Jaschke
Quoted 2 lines · Jens Axboe

This is really strange, are you sure your drive is ok? Does mounting dvd-rom and cd-rom's work fine?

OK. I'll check again with 2.4.4-pre4+patches:
(1) Mounting the SuSE DVD-ROM (-t iso9660) from /dev/hdc on /dvd and reading from /dvd works. Same for CD-ROMs. I don't have a formatted DVD-RAM.
(2) Reading with "dd if=/dev/hdc ..."
(2.1) works with CD-ROM inserted
(2.2) fails with DVD-ROM inserted
(2.3) fails with DVD-RAM inserted
(3) Writing with "dd of=/dev/hdc ..." works (with DVD-RAM inserted).
(4) "mke2fs -b 2048 /dev/hdc" fails (with DVD-RAM inserted).

As if the drive gives the driver wrong information (like size=0)?

If nothing helps, I have to plug the drive into a Windows machine to make sure it really works with Toshiba's own drivers. This would be a major hassle, though. No place for Windows on my own machine. Hence some amount of screwing... :-(

Signature · 2 lines
Stefan R. Jaschke <[email protected]>
http://www.jaschke-net.de
#9 lore raw
In reply to Stefan Jaschke
Quoted 11 lines · Stefan Jaschke
Quoted 2 lines · Jens Axboe

This is really strange, are you sure your drive is ok? Does mounting dvd-rom and cd-rom's work fine?

OK. I'll check again with 2.4.4-pre4+patches:
(1) Mounting the SuSE DVD-ROM (-t iso9660) from /dev/hdc on /dvd and reading from /dvd works. Same for CD-ROMs. I don't have a formatted DVD-RAM.
(2) Reading with "dd if=/dev/hdc ..."
(2.1) works with CD-ROM inserted
(2.2) fails with DVD-ROM inserted

dd fails with DVD-ROM inserted??? In the same way? Is this the SuSE DVD, and not a movie DVD? Also, check dmesg for errors.

Quoted 3 lines

(2.3) fails with DVD-RAM inserted
(3) Writing with "dd of=/dev/hdc ..." works (with DVD-RAM inserted).
(4) "mke2fs -b 2048 /dev/hdc" fails (with DVD-RAM inserted).

Side note -- use as big a block size as you can for a DVD-RAM hosted fs, 4kB is better than 2kB.

Quoted 1 line

As if the drive gives the driver wrong information (like size=0)?

Could be, try

cat /proc/ide/hdc/capacity

and see what that says.

But at least it looks like your drive is just fine.

Quoted 3 lines

If nothing helps, I have to plug the drive into a Windows machine to make sure it really works with Toshiba's own drivers. This would be a major hassle, though. No place for Windows on my own machine.

Lets not go that far yet :)

Quoted 1 line

Hence some amount of screwing... :-(

And lets stick to hardware for now, ok? :-)

Signature · 1 line
Jens Axboe
#10 lore raw
In reply to Stefan Jaschke
Quoted 9 lines · Jens Axboe
Quoted 7 lines · Stefan Jaschke

OK. I'll check again with 2.4.4-pre4+patches:
(1) Mounting the SuSE DVD-ROM (-t iso9660) from /dev/hdc on /dvd and reading from /dvd works. Same for CD-ROMs. I don't have a formatted DVD-RAM.
(2) Reading with "dd if=/dev/hdc ..."
(2.1) works with CD-ROM inserted
(2.2) fails with DVD-ROM inserted

Quoted 3 lines

dd fails with DVD-ROM inserted??? In the same way? Is this the SuSE DVD, and not a movie DVD? Also, check dmesg for errors.

Quoted 1 line

(2.3) fails with DVD-RAM inserted

"dd if=/dev/hdc of=/dev/null bs=2k count=3" produces the same strace, whether the DVD-RAM or the SuSE DVD-ROM is inserted. I interpret the fact that the first read() returns 0 as some lower layer coming to the conclusion that "/dev/hdc" has length 0.
The only line that appears in the system logs is
"VFS: Disk change detected on device ide1(22,0)"
when I change the disks.

Quoted 2 lines
Quoted 2 lines

(3) Writing with "dd of=/dev/hdc ..." works (with DVD-RAM inserted).
(4) "mke2fs -b 2048 /dev/hdc" fails (with DVD-RAM inserted).

I took a closer look at the strace of the "mke2fs ...". The first system call that fails is
old_mmap(NULL, 504938496, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = -1 ENOMEM
It asks for 481MB, which I simply don't have. (128MB RAM, 256MB swap). So, this may be unrelated to the kernel, just a quirk of mke2fs to ask for that much memory.

Quoted 2 lines

Could be, try
cat /proc/ide/hdc/capacity

0 (with empty tray)

8946816       (with single-sided 4.7GB DVD-RAM)
4875840       (with single-sided 2.6GB DVD-RAM)
9106700       (with SuSE DVD-ROM)
1325240       (with SuSE CD-ROM)

Seem to be 512 Byte blocks. Looks OK.

Quoted 1 line

And lets stick to hardware for now, ok? :-)

This means "There is hope to get the drive working under Linux"?

Correct me if I am wrong in my interpretations.

There are two mysteries (for me at least) left:
(1) Why does mke2fs need 481MB memory?
(2) Why does the very first read() on /dev/hdc return EOF?

What would you suggest to try next?

Stefan

#11 lore raw
In reply to Stefan Jaschke

Hi Jens,

I took some time to try to understand why "mke2fs -b 2048 /dev/hdc" wants 500MB memory. Here is a first explanation:

# mke2fs -m 0 -n /dev/hdc
mke2fs 1.19, 13-Jul-2000 for EXT2 FS 0.5b, 95/08/09
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
406650880 inodes, 813284544 blocks
0 blocks (0.00%) reserved for the super user
First data block=0
24820 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group

813284544 4k blocks would be 3.7 Terabyte.
(Strangely enough, calling mke2fs with any blocksize parameter results in a memory allocation larger then my memory available.)

I took some more time to understand at what point the wrong size is introduced. I got the source rpm, set CFLAGS to "-g", ran gdb, and nailed down the point:

(gdb) l
80 #endif
81 if (fd < 0)
82 return errno;
83
84 #ifdef BLKGETSIZE
85 if (ioctl(fd, BLKGETSIZE, &size) >= 0) {

86                      close(fd);
87                      *retblocks = size / (blocksize / 512);
88                      return 0;

89 }
(gdb) n
86 close(fd);
(gdb) print size
$1 = -2083658236
(gdb) bt
#0 ext2fs_get_device_size (file=0xbffff911 "/dev/hdc", blocksize=1024,

    retblocks=0xbffff534) at ../../../lib/ext2fs/getsize.c:86
#1  0x804aca3 in PRS (argc=4, argv=0xbffff75c) at ../../misc/mke2fs.c:993
#2  0x804af2e in main (argc=4, argv=0xbffff75c) at ../../misc/mke2fs.c:1081
#3  0x40044baf in __libc_start_main () from /lib/libc.so.6

I am afraid I'd need help to go deeper.

Cheers,
Stefan J.

Signature · 2 lines
Stefan R. Jaschke <[email protected]>
http://www.jaschke-net.de