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

2001-04-21 Thread 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=0xb911 "/dev/hdc", blocksize=1024, 
retblocks=0xb534) at ../../../lib/ext2fs/getsize.c:86
#1  0x804aca3 in PRS (argc=4, argv=0xb75c) at ../../misc/mke2fs.c:993
#2  0x804af2e in main (argc=4, argv=0xb75c) 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.

-- 
Stefan R. Jaschke <[EMAIL PROTECTED]>
http://www.jaschke-net.de
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



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

2001-04-19 Thread Stefan Jaschke

On Thursday 19 April 2001 15:03, Jens Axboe wrote:
> On Thu, Apr 19 2001, Stefan Jaschke wrote:
> > 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.
> >(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.

> > (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.

> 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.

> 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

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



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

2001-04-19 Thread Jens Axboe

On Thu, Apr 19 2001, Stefan Jaschke wrote:
> On Thursday 19 April 2001 14:15, Jens Axboe wrote:
> > 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.

>(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.

> 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.

> 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 :)

> Hence some amount of screwing... :-(

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

-- 
Jens Axboe

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



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

2001-04-19 Thread Stefan Jaschke

On Thursday 19 April 2001 14:15, Jens Axboe wrote:
> 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... :-(


-- 
Stefan R. Jaschke <[EMAIL PROTECTED]>
http://www.jaschke-net.de
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



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

2001-04-19 Thread Jens Axboe

On Thu, Apr 19 2001, Stefan Jaschke wrote:
> > > 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?

-- 
Jens Axboe

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



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

2001-04-19 Thread Stefan Jaschke

> > 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, [], 0x400}, NULL, 8) = 0
rt_sigaction(SIGQUIT, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGQUIT, {0x80493d0, [], 0x400}, NULL, 8) = 0
rt_sigaction(SIGPIPE, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGPIPE, {0x80493d0, [], 0x400}, NULL, 8) = 0
rt_sigaction(SIGUSR1, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGUSR1, {0x8049440, [], 0x400}, 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, 0xb524)= 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) = 0x805
old_mmap(NULL, 2097152, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, 
-1, 0) = 0x40159000
munmap(0x40159000, 684032)  = 0
munmap(0x4030, 364544)  = 0
mprotect(0x4020, 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

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



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

2001-04-19 Thread Jens Axboe

On Thu, Apr 19 2001, Stefan Jaschke wrote:
> 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 
> printing eip: ...
> Oops: 
> ...
> ---

This should fix it.

-- 
Jens Axboe



--- drivers/cdrom/cdrom.c~  Thu Apr 19 13:44:46 2001
+++ drivers/cdrom/cdrom.c   Thu Apr 19 13:45:33 2001
@@ -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



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

2001-04-19 Thread 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 
printing eip: ...
Oops: 
...
---

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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



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

2001-04-18 Thread Stefan Jaschke

On Wednesday 18 April 2001 14:39, Jens Axboe wrote:

> 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, [], 0x400}, NULL, 8) = 0
rt_sigaction(SIGQUIT, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGQUIT, {0x80493d0, [], 0x400}, NULL, 8) = 0
rt_sigaction(SIGPIPE, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGPIPE, {0x80493d0, [], 0x400}, NULL, 8) = 0
rt_sigaction(SIGUSR1, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGUSR1, {0x8049440, [], 0x400}, 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, [], 0x400}, NULL, 8) = 0
rt_sigaction(SIGQUIT, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGQUIT, {0x80493d0, [], 0x400}, NULL, 8) = 0
rt_sigaction(SIGPIPE, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGPIPE, {0x80493d0, [], 0x400}, NULL, 8) = 0
rt_sigaction(SIGUSR1, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGUSR1, {0x8049440, [], 0x400}, 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
...  ...
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(0x805)  = 0x805
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, 0xb524)= 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) = 0x805
old_mmap(NULL, 2097152, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, 
-1, 0) = 0x40159000
munmap(0x40159000, 684032)  = 0
munmap(0x4030, 364544)  = 0
mprotect(0x4020, 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: ) 

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

2001-04-18 Thread Jens Axboe

On Wed, Apr 18 2001, Jens Axboe wrote:
> On Tue, Apr 17 2001, Stefan Jaschke wrote:
> > 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.

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.

-- 
Jens Axboe



diff -ur --exclude-from /home/axboe/exclude 
/opt/kernel/linux-2.4.4-pre4/drivers/cdrom/cdrom.c linux/drivers/cdrom/cdrom.c
--- /opt/kernel/linux-2.4.4-pre4/drivers/cdrom/cdrom.c  Thu Mar 29 21:56:07 2001
+++ linux/drivers/cdrom/cdrom.c Wed Apr 18 13:27:36 2001
@@ -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;

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

2001-04-18 Thread Jens Axboe

On Tue, Apr 17 2001, Stefan Jaschke wrote:
> 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.

-- 
Jens Axboe

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



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

2001-04-17 Thread 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.

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 
namevalue   min max mode
-   --- --- 
breada_readahead4   0   127 rw
current_speed   34  0   69  rw
dsc_overlap 0   0   1   rw
file_readahead  0   0   2097151 rw
ide_scsi0   0   1   rw
init_speed  34  0   69  rw
io_32bit0   0   3   rw
keepsettings0   0   1   rw
max_kb_per_request  127 1   127 rw
nice1   1   0   1   rw
number  2   0   3   rw
pio_modewrite-only  0   255 w
slow0   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.


-- 
Stefan R. Jaschke <[EMAIL PROTECTED]>
http://www.jaschke-net.de
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/