2006-02-18 20:23:32

by linuxer

[permalink] [raw]
Subject: pktcdvd DVD+RW always writes at max drive speed (not media speed)

In drivers/block/pktcdvd.c it appears that in the case of DVD
rewriting, pkt_open_write always sets the write speed to pkt_get_max_speed
(the maximum writing speed reported by the drive).

In my case, I have a new drive capable of 8x re-writing. However, all of
my existing media is rated for only 4x rewrite speed.

When attempting to rw mount these disks, pktcdvd reports:

Feb 18 00:09:52 ever kernel: pktcdvd: write speed 11080kB/s
Feb 18 00:09:54 ever kernel: pktcdvd: 54 01 00 00 00 00 00 00 00 00 00 00 -
sense 00.54.9c (No sense)
Feb 18 00:09:54 ever kernel: pktcdvd: pktcdvd0 Optimum Power Calibration failed

And then of course a huge heap of I/O errors on the disk.


pktcdvd.c only calls pkt_media_speed for CD drives, not DVD
drives. dvd+rw-tools has a program, dvd+rw-mediainfo, that is able to derive
the information of the rated media speed successfully. Code from this should
be integrated into the pktcdvd driver so as to avoid this pitfall.

However, as I don't necessarily expect someone to do this for me right
away, I have a second question:

Although migrating sensing code from dvd+rw-mediatype would be by far the
more elegant solution, it occurs to me that an easier hack would be to add
a new case to pkt_ctl_ioctl, something along the lines of
PKT_CTRL_CMD_FORCESPEED or similar, and patch pktsetup.c (simple user mode
pktcdvd setup/teardown utility, a component provided in udftools) likewise
to allow the user to specify the write speed. I would also have to add an
additional member to struct pktcdvd_device in order to store this setting
on a per device context, however. Would this work, or am I too naive about
kernel programming?

Also, would this be a welcome or useful addition anyways (regardless of
possible future media-speed autodetection), to allow the user to override
and write faster/slower than drive reports media speed, to allow the user
more flexibility in overspeed/underspeed writing based on individual media
performance?

Thank you for taking the time to read this, and I would appreciate any of
your thoughts.

PS: Please CC me, as I am not currently subscribed to the list.


2006-02-18 22:19:16

by Peter Osterlund

[permalink] [raw]
Subject: Re: pktcdvd DVD+RW always writes at max drive speed (not media speed)

[email protected] writes:

> In drivers/block/pktcdvd.c it appears that in the case of DVD
> rewriting, pkt_open_write always sets the write speed to pkt_get_max_speed
> (the maximum writing speed reported by the drive).
>
> In my case, I have a new drive capable of 8x re-writing. However, all of
> my existing media is rated for only 4x rewrite speed.
>
> When attempting to rw mount these disks, pktcdvd reports:
>
> Feb 18 00:09:52 ever kernel: pktcdvd: write speed 11080kB/s
> Feb 18 00:09:54 ever kernel: pktcdvd: 54 01 00 00 00 00 00 00 00 00 00 00 -
> sense 00.54.9c (No sense)
> Feb 18 00:09:54 ever kernel: pktcdvd: pktcdvd0 Optimum Power Calibration failed
>
> And then of course a huge heap of I/O errors on the disk.

Have you verified that this is caused by the speed setting, ie does it
work correctly if you hack the driver to write at 4x speed?

--
Peter Osterlund - [email protected]
http://web.telia.com/~u89404340

2006-02-18 23:35:19

by linuxer

[permalink] [raw]
Subject: Re: pktcdvd DVD+RW always writes at max drive speed (not media speed)


Peter Osterlund <[email protected]> writes:
>
> [email protected] writes:
>
> > In drivers/block/pktcdvd.c it appears that in the case of DVD
> > rewriting, pkt_open_write always sets the write speed to pkt_get_max_speed
> > (the maximum writing speed reported by the drive).
> >
> > In my case, I have a new drive capable of 8x re-writing. However, all of
> > my existing media is rated for only 4x rewrite speed.
> >
> > When attempting to rw mount these disks, pktcdvd reports:
> >
> > Feb 18 00:09:52 ever kernel: pktcdvd: write speed 11080kB/s
> > Feb 18 00:09:54 ever kernel: pktcdvd: 54 01 00 00 00 00 00 00 00 00 00 00 -
> > sense 00.54.9c (No sense)
> > Feb 18 00:09:54 ever kernel: pktcdvd: pktcdvd0 Optimum Power Calibration failed
> >
> > And then of course a huge heap of I/O errors on the disk.
>
> Have you verified that this is caused by the speed setting, ie does it
> work correctly if you hack the driver to write at 4x speed?
>

Correct. Adding a hard-coded manual setting of write_speed = 5540 to
pkt_open_write results in functional operation (at least with 4x rated
DVD+RW media).

Obviously, this particular drive is perfectly happy to try to write at over
the rated media speed if it is asked to. I can't fault the manufacturer for
this, for I generally like the idea of letting the user decide instead of
imposing hardware/firmware fixed limits.

2006-02-19 06:11:37

by Phillip Susi

[permalink] [raw]
Subject: Re: pktcdvd DVD+RW always writes at max drive speed (not media speed)

I thought that the code asked the drive for the max supported speed _for
the loaded media_. I know I've been using pktcdvd without problem on
cdrw media that is only rated for 4x on drives that support 12x or 16x,
and based on the performance I've been seeing, it is only burning at 4x.
Maybe your drive isn't reporting properly?

[email protected] wrote:
> In drivers/block/pktcdvd.c it appears that in the case of DVD
> rewriting, pkt_open_write always sets the write speed to pkt_get_max_speed
> (the maximum writing speed reported by the drive).
>
> In my case, I have a new drive capable of 8x re-writing. However, all of
> my existing media is rated for only 4x rewrite speed.
>
> When attempting to rw mount these disks, pktcdvd reports:
>
> Feb 18 00:09:52 ever kernel: pktcdvd: write speed 11080kB/s
> Feb 18 00:09:54 ever kernel: pktcdvd: 54 01 00 00 00 00 00 00 00 00 00 00 -
> sense 00.54.9c (No sense)
> Feb 18 00:09:54 ever kernel: pktcdvd: pktcdvd0 Optimum Power Calibration failed
>
> And then of course a huge heap of I/O errors on the disk.
>
>
> pktcdvd.c only calls pkt_media_speed for CD drives, not DVD
> drives. dvd+rw-tools has a program, dvd+rw-mediainfo, that is able to derive
> the information of the rated media speed successfully. Code from this should
> be integrated into the pktcdvd driver so as to avoid this pitfall.
>
> However, as I don't necessarily expect someone to do this for me right
> away, I have a second question:
>
> Although migrating sensing code from dvd+rw-mediatype would be by far the
> more elegant solution, it occurs to me that an easier hack would be to add
> a new case to pkt_ctl_ioctl, something along the lines of
> PKT_CTRL_CMD_FORCESPEED or similar, and patch pktsetup.c (simple user mode
> pktcdvd setup/teardown utility, a component provided in udftools) likewise
> to allow the user to specify the write speed. I would also have to add an
> additional member to struct pktcdvd_device in order to store this setting
> on a per device context, however. Would this work, or am I too naive about
> kernel programming?
>
> Also, would this be a welcome or useful addition anyways (regardless of
> possible future media-speed autodetection), to allow the user to override
> and write faster/slower than drive reports media speed, to allow the user
> more flexibility in overspeed/underspeed writing based on individual media
> performance?
>
> Thank you for taking the time to read this, and I would appreciate any of
> your thoughts.
>
> PS: Please CC me, as I am not currently subscribed to the list.
>

2006-02-19 06:47:06

by linuxer

[permalink] [raw]
Subject: Re: pktcdvd DVD+RW always writes at max drive speed (not media speed)

Phillip Susi <[email protected]> wrote:

>
> I thought that the code asked the drive for the max supported speed _for
> the loaded media_. I know I've been using pktcdvd without problem on
> cdrw media that is only rated for 4x on drives that support 12x or 16x,
> and based on the performance I've been seeing, it is only burning at 4x.
> Maybe your drive isn't reporting properly?
>

As I stated clearly before, I am having this problem with DVD+RW media. The
relevant code in pktcdvd.c (in function pkt_open_write) is:

if ((ret = pkt_get_max_speed(pd, &write_speed)))
write_speed = 16 * 177;
switch (pd->mmc3_profile) {
case 0x13: /* DVD-RW */
case 0x1a: /* DVD+RW */
case 0x12: /* DVD-RAM */
DPRINTK("pktcdvd: write speed %ukB/s\n", write_speed);
break;
default:
if ((ret = pkt_media_speed(pd, &media_write_speed)))
media_write_speed = 16;
write_speed = min(write_speed, media_write_speed * 177);
DPRINTK("pktcdvd: write speed %ux\n", write_speed / 176);
break;
}
read_speed = write_speed;

if ((ret = pkt_set_speed(pd, write_speed, read_speed))) {
DPRINTK("pktcdvd: %s couldn't set write speed\n", pd->name);
return -EIO;
}

As you can see, in the case of DVD+RW, the speed is set to the value stored
to write_speed by the function pkt_get_max_speed, whose documented purpose
(according to comments) is to return the drives reported maximum rewrite
speed capability. pkt_media_speed is only called in the case of CD-RW's. In
fact, it returns an error if the media is not CD-RW.

2006-02-19 10:09:41

by Peter Osterlund

[permalink] [raw]
Subject: Re: pktcdvd DVD+RW always writes at max drive speed (not media speed)

[email protected] writes:

> Peter Osterlund <[email protected]> writes:
> >
> > [email protected] writes:
> >
> > > In drivers/block/pktcdvd.c it appears that in the case of DVD
> > > rewriting, pkt_open_write always sets the write speed to pkt_get_max_speed
> > > (the maximum writing speed reported by the drive).
> > >
> > > In my case, I have a new drive capable of 8x re-writing. However, all of
> > > my existing media is rated for only 4x rewrite speed.
> > >
> > > When attempting to rw mount these disks, pktcdvd reports:
> > >
> > > Feb 18 00:09:52 ever kernel: pktcdvd: write speed 11080kB/s
> > > Feb 18 00:09:54 ever kernel: pktcdvd: 54 01 00 00 00 00 00 00 00 00 00 00 -
> > > sense 00.54.9c (No sense)
> > > Feb 18 00:09:54 ever kernel: pktcdvd: pktcdvd0 Optimum Power Calibration failed
> > >
> > > And then of course a huge heap of I/O errors on the disk.
> >
> > Have you verified that this is caused by the speed setting, ie does it
> > work correctly if you hack the driver to write at 4x speed?
>
> Correct. Adding a hard-coded manual setting of write_speed = 5540 to
> pkt_open_write results in functional operation (at least with 4x rated
> DVD+RW media).
>
> Obviously, this particular drive is perfectly happy to try to write at over
> the rated media speed if it is asked to. I can't fault the manufacturer for
> this, for I generally like the idea of letting the user decide instead of
> imposing hardware/firmware fixed limits.

The Mt. Fuji specification would put the blame on the manufacturer.
>From the description of the "set cd speed" command:

If the Logical Unit is requested to write at the speed which
is not listed in the Logical Unit Write Speed Performance
Descriptor, the Logical Unit shall select any slower Logical
Unit Write Speed. This condition is not regarded as an error
condition.

However, the specification doesn't matter if following it blindly
makes real hardware fail. I don't think it would be that hard to get
the maximum DVD media speed from the drive and use that instead of the
maximum drive speed.

--
Peter Osterlund - [email protected]
http://web.telia.com/~u89404340

2006-02-22 22:28:33

by Peter Osterlund

[permalink] [raw]
Subject: Re: pktcdvd DVD+RW always writes at max drive speed (not media speed)

[email protected] writes:

> Peter Osterlund <[email protected]> writes:
> >
> > [email protected] writes:
> >
> > > In drivers/block/pktcdvd.c it appears that in the case of DVD
> > > rewriting, pkt_open_write always sets the write speed to pkt_get_max_speed
> > > (the maximum writing speed reported by the drive).
> > >
> > > In my case, I have a new drive capable of 8x re-writing. However, all of
> > > my existing media is rated for only 4x rewrite speed.
> > >
> > > When attempting to rw mount these disks, pktcdvd reports:
> > >
> > > Feb 18 00:09:52 ever kernel: pktcdvd: write speed 11080kB/s
> > > Feb 18 00:09:54 ever kernel: pktcdvd: 54 01 00 00 00 00 00 00 00 00 00 00 -
> > > sense 00.54.9c (No sense)
> > > Feb 18 00:09:54 ever kernel: pktcdvd: pktcdvd0 Optimum Power Calibration failed
> > >
> > > And then of course a huge heap of I/O errors on the disk.
> >
> > Have you verified that this is caused by the speed setting, ie does it
> > work correctly if you hack the driver to write at 4x speed?
>
> Correct. Adding a hard-coded manual setting of write_speed = 5540 to
> pkt_open_write results in functional operation (at least with 4x rated
> DVD+RW media).

Does this patch work for you?


pktcdvd: Don't try to write faster than the DVD media speed allows.

In theory the drive firmware should limit the speed to the fastest
allowed by the currently loaded media, but it doesn't always work in
practice.

Signed-off-by: Peter Osterlund <[email protected]>
---

drivers/block/pktcdvd.c | 34 ++++++++++++++++++++++++++++++++--
1 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index c1b8eae..94ff3ac 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -1780,7 +1780,7 @@ static char us_clv_to_speed[16] = {
/*
* reads the maximum media speed from ATIP
*/
-static int pkt_media_speed(struct pktcdvd_device *pd, unsigned *speed)
+static int pkt_cd_media_speed(struct pktcdvd_device *pd, unsigned *speed)
{
struct packet_command cgc;
struct request_sense sense;
@@ -1852,6 +1852,33 @@ static int pkt_media_speed(struct pktcdv
}
}

+static int pkt_dvd_media_speed(struct pktcdvd_device *pd, unsigned int *speed)
+{
+ struct packet_command cgc;
+ struct request_sense sense;
+ unsigned char buf[64];
+ int size, ret;
+
+ init_cdrom_command(&cgc, buf, sizeof(buf), CGC_DATA_READ);
+ cgc.sense = &sense;
+ cgc.cmd[0] = GPCMD_GET_PERFORMANCE;
+ cgc.cmd[8] = 0;
+ cgc.cmd[9] = 1; /* Number of descriptors */
+ cgc.cmd[10] = 0x03; /* Write speed */
+ ret = pkt_generic_packet(pd, &cgc);
+ if (ret) {
+ pkt_dump_sense(&cgc);
+ return ret;
+ }
+ size = be32_to_cpu(*(int*)&buf[0]) + 4;
+ if (size < 8 + 16)
+ return -1;
+
+ *speed = be32_to_cpu(*(int*)&buf[8 + 12]);
+ DPRINTK("pktcdvd: Max. media speed: %dkB/s\n",*speed);
+ return 0;
+}
+
static int pkt_perform_opc(struct pktcdvd_device *pd)
{
struct packet_command cgc;
@@ -1889,14 +1916,17 @@ static int pkt_open_write(struct pktcdvd

if ((ret = pkt_get_max_speed(pd, &write_speed)))
write_speed = 16 * 177;
+ DPRINTK("pktcdvd: Max drive write speed %ukB/s\n", write_speed);
switch (pd->mmc3_profile) {
case 0x13: /* DVD-RW */
case 0x1a: /* DVD+RW */
case 0x12: /* DVD-RAM */
+ if (pkt_dvd_media_speed(pd, &media_write_speed) == 0)
+ write_speed = min(write_speed, media_write_speed);
DPRINTK("pktcdvd: write speed %ukB/s\n", write_speed);
break;
default:
- if ((ret = pkt_media_speed(pd, &media_write_speed)))
+ if ((ret = pkt_cd_media_speed(pd, &media_write_speed)))
media_write_speed = 16;
write_speed = min(write_speed, media_write_speed * 177);
DPRINTK("pktcdvd: write speed %ux\n", write_speed / 176);

--
Peter Osterlund - [email protected]
http://web.telia.com/~u89404340

2006-02-25 01:12:32

by linuxer

[permalink] [raw]
Subject: Re: pktcdvd DVD+RW always writes at max drive speed (not media speed)

[email protected] writes:
>
> [email protected] writes:
>
> > Peter Osterlund <[email protected]> writes:
> > >
> > > [email protected] writes:
> > >
> > > > In drivers/block/pktcdvd.c it appears that in the case of DVD
> > > > rewriting, pkt_open_write always sets the write speed to pkt_get_max_speed
> > > > (the maximum writing speed reported by the drive).
> > > >
> > > > In my case, I have a new drive capable of 8x re-writing. However, all of
> > > > my existing media is rated for only 4x rewrite speed.
> > > >
> > > > When attempting to rw mount these disks, pktcdvd reports:
> > > >
> > > > Feb 18 00:09:52 ever kernel: pktcdvd: write speed 11080kB/s
> > > > Feb 18 00:09:54 ever kernel: pktcdvd: 54 01 00 00 00 00 00 00 00 00 00 00 -
> > > > sense 00.54.9c (No sense)
> > > > Feb 18 00:09:54 ever kernel: pktcdvd: pktcdvd0 Optimum Power Calibration failed
> > > >
> > > > And then of course a huge heap of I/O errors on the disk.
> > >
> > > Have you verified that this is caused by the speed setting, ie does it
> > > work correctly if you hack the driver to write at 4x speed?
> >
> > Correct. Adding a hard-coded manual setting of write_speed = 5540 to
> > pkt_open_write results in functional operation (at least with 4x rated
> > DVD+RW media).
>
> Does this patch work for you?
>
>
> pktcdvd: Don't try to write faster than the DVD media speed allows.
>
> In theory the drive firmware should limit the speed to the fastest
> allowed by the currently loaded media, but it doesn't always work in
> practice.
>
> Signed-off-by: Peter Osterlund <[email protected]>
> ---
>
> drivers/block/pktcdvd.c | 34 ++++++++++++++++++++++++++++++++--
> 1 files changed, 32 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
> index c1b8eae..94ff3ac 100644
> --- a/drivers/block/pktcdvd.c
> +++ b/drivers/block/pktcdvd.c
> @@ -1780,7 +1780,7 @@ static char us_clv_to_speed[16] = {
> /*
> * reads the maximum media speed from ATIP
> */
> -static int pkt_media_speed(struct pktcdvd_device *pd, unsigned *speed)
> +static int pkt_cd_media_speed(struct pktcdvd_device *pd, unsigned *speed)
> {
> struct packet_command cgc;
> struct request_sense sense;
> @@ -1852,6 +1852,33 @@ static int pkt_media_speed(struct pktcdv
> }
> }
>
> +static int pkt_dvd_media_speed(struct pktcdvd_device *pd, unsigned int *speed)
> +{
> + struct packet_command cgc;
> + struct request_sense sense;
> + unsigned char buf[64];
> + int size, ret;
> +
> + init_cdrom_command(&cgc, buf, sizeof(buf), CGC_DATA_READ);
> + cgc.sense = &sense;
> + cgc.cmd[0] = GPCMD_GET_PERFORMANCE;
> + cgc.cmd[8] = 0;
> + cgc.cmd[9] = 1; /* Number of descriptors */
> + cgc.cmd[10] = 0x03; /* Write speed */
> + ret = pkt_generic_packet(pd, &cgc);
> + if (ret) {
> + pkt_dump_sense(&cgc);
> + return ret;
> + }
> + size = be32_to_cpu(*(int*)&buf[0]) + 4;
> + if (size < 8 + 16)
> + return -1;
> +
> + *speed = be32_to_cpu(*(int*)&buf[8 + 12]);
> + DPRINTK("pktcdvd: Max. media speed: %dkB/s\n",*speed);
> + return 0;
> +}
> +
> static int pkt_perform_opc(struct pktcdvd_device *pd)
> {
> struct packet_command cgc;
> @@ -1889,14 +1916,17 @@ static int pkt_open_write(struct pktcdvd
>
> if ((ret = pkt_get_max_speed(pd, &write_speed)))
> write_speed = 16 * 177;
> + DPRINTK("pktcdvd: Max drive write speed %ukB/s\n", write_speed);
> switch (pd->mmc3_profile) {
> case 0x13: /* DVD-RW */
> case 0x1a: /* DVD+RW */
> case 0x12: /* DVD-RAM */
> + if (pkt_dvd_media_speed(pd, &media_write_speed) == 0)
> + write_speed = min(write_speed, media_write_speed);
> DPRINTK("pktcdvd: write speed %ukB/s\n", write_speed);
> break;
> default:
> - if ((ret = pkt_media_speed(pd, &media_write_speed)))
> + if ((ret = pkt_cd_media_speed(pd, &media_write_speed)))
> media_write_speed = 16;
> write_speed = min(write_speed, media_write_speed * 177);
> DPRINTK("pktcdvd: write speed %ux\n", write_speed / 176);
>

Unfortunately, no. It -should- work, but the extra DPRINTK's tell a further
story of the drives stupidity.

Upon running
% pktsetup 0 /dev/hde ; mkudffs /dev/pktcdvd/0'
I get the following output:

Feb 24 19:30:31 ever kernel: pktcdvd: inserted media is DVD+RW
Feb 24 19:30:31 ever kernel: pktcdvd: Max drive write speed 11080kB/s
Feb 24 19:30:31 ever kernel: pktcdvd: Max. media speed: 5540kB/s
Feb 24 19:30:31 ever kernel: pktcdvd: write speed 5540kB/s
Feb 24 19:30:48 ever kernel: pktcdvd: 4590208kB available on disc

All seems well and good. However, upon then issuing
% mount /dev/pktcdvd/0 /mnt/dvdrw -t auto -o noatime,rw

Feb 24 19:31:28 ever kernel: pktcdvd: inserted media is DVD+RW
Feb 24 19:31:28 ever kernel: pktcdvd: Max drive write speed 11080kB/s
Feb 24 19:31:28 ever kernel: pktcdvd: Max. media speed: 11080kB/s
Feb 24 19:31:28 ever kernel: pktcdvd: write speed 11080kB/s
Feb 24 19:31:30 ever kernel: pktcdvd: 54 01 00 00 00 00 00 00 00 00 00 00 - sense 00.54.1c (No sense)
Feb 24 19:31:30 ever kernel: pktcdvd: pktcdvd0 Optimum Power Calibration failed
Feb 24 19:31:30 ever kernel: pktcdvd: 4590208kB available on disc
Feb 24 19:31:31 ever kernel: UDF-fs INFO UDF 0.9.8.1 (2004/29/09) Mounting volume 'LinuxUDF', timestamp 2006/02/24 18:30 (1ed4)
Feb 24 19:31:40 ever kernel: hde: media error (bad sector): status=0x51 { DriveReady SeekComplete Error }
Feb 24 19:31:40 ever kernel: hde: media error (bad sector): error=0x34 { AbortedCommand LastFailedSense=0x03 }
Feb 24 19:31:40 ever kernel: ide: failed opcode was: unknown
Feb 24 19:31:40 ever kernel: end_request: I/O error, dev hde, sector 1088
Feb 24 19:31:40 ever kernel: hde: command error: status=0x51 { DriveReady SeekComplete Error }
Feb 24 19:31:40 ever kernel: hde: command error: error=0x54 { AbortedCommand LastFailedSense=0x05 }
.
. (and so on)

I'm somewhat confused as to what could be happening here, but my first
guess is that after being spun up to high speed for reading in
pkt_iosched_process_queue, the firmware promptly forgets whatever it knew
about the media speed. Perhaps it only stores a single speed value
internally, so calling pkt_set_speed (pd, pd->write_speed, pd->read_speed)
with a larger value of read_speed sets them both. And afterwards the drive
reports this as the maximum media speed on future opens? If you are curious
as to who would curse the market with such a buggy product, the drive is a
BenQ Q60.

Curiously, after the failed mount, running dvd+rw-mediainfo returns:

INQUIRY: [BENQ ][DVD DC DQ60 ][MRCC]
GET [CURRENT] CONFIGURATION:
Mounted Media: 1Ah, DVD+RW
Media ID: INFODISC/A10
Current Write Speed: 8.0x1385=11080KB/s
Write Speed #0: 8.0x1385=11080KB/s
Write Speed #1: 6.0x1385=8310KB/s
Write Speed #2: 4.0x1385=5540KB/s
Write Speed #3: 2.4x1385=3324KB/s
Speed Descriptor#0: 00/2295103 [email protected]=4817KB/s [email protected]=11080KB/s
Speed Descriptor#1: 00/2295103 [email protected]=4817KB/s [email protected]=8310KB/s
Speed Descriptor#2: 00/2295103 [email protected]=4817KB/s [email protected]=5540KB/s
Speed Descriptor#3: 00/2295103 [email protected]=4817KB/s [email protected]=3324KB/s
READ DVD STRUCTURE[#0h]:
Media Book Type: 92h, DVD+RW book [revision 2]
Legacy lead-out at: 2295104*2KB=4700372992
READ DISC INFORMATION:
Disc status: complete
Number of Sessions: 1
State of Last Session: complete
Number of Tracks: 1
BG Format Status: suspended
:-[ READ TRACK INFORMATION failed with SK=3h/ASC=11h/ACQ=05h]: Input/output
error

While before it returned:

INQUIRY: [BENQ ][DVD DC DQ60 ][MRCC]
GET [CURRENT] CONFIGURATION:
Mounted Media: 1Ah, DVD+RW
Media ID: INFODISC/A10
Current Write Speed: 4.0x1385=5540KB/s
Write Speed #0: 4.0x1385=5540KB/s
Write Speed #1: 2.4x1385=3324KB/s
Speed Descriptor#0: 00/2295103 [email protected]=4817KB/s [email protected]=5540KB/s
Speed Descriptor#1: 00/2295103 [email protected]=4817KB/s [email protected]=3324KB/s
READ DVD STRUCTURE[#0h]:
Media Book Type: 92h, DVD+RW book [revision 2]
Legacy lead-out at: 2295104*2KB=4700372992
READ DISC INFORMATION:
Disc status: complete
Number of Sessions: 1
State of Last Session: complete
Number of Tracks: 1
BG Format Status: suspended
READ TRACK INFORMATION[#1]:
Track State: complete incremental
Track Start Address: 0*2KB
Free Blocks: 0*2KB
Fixed Packet Size: 16*2KB
Track Size: 2295104*2KB
FABRICATED TOC:
Track#1 : 17@0
Track#AA : 17@2295104
Multi-session Info: #1@0
READ CAPACITY: 2295104*2048=4700372992

Ejecting and reloading the disc causes dvd+rw-mediainfo to return proper
info again.

2006-02-25 22:43:38

by Peter Osterlund

[permalink] [raw]
Subject: Re: pktcdvd DVD+RW always writes at max drive speed (not media speed)

[email protected] writes:

> [email protected] writes:
> >
> > [email protected] writes:
> >
> > > Peter Osterlund <[email protected]> writes:
> > > >
> > > > [email protected] writes:
> > > >
> > > > > In drivers/block/pktcdvd.c it appears that in the case of DVD
> > > > > rewriting, pkt_open_write always sets the write speed to pkt_get_max_speed
> > > > > (the maximum writing speed reported by the drive).
> > > > >
> > > > > In my case, I have a new drive capable of 8x re-writing. However, all of
> > > > > my existing media is rated for only 4x rewrite speed.
> > > > >
> > > > > When attempting to rw mount these disks, pktcdvd reports:
> > > > >
> > > > > Feb 18 00:09:52 ever kernel: pktcdvd: write speed 11080kB/s
> > > > > Feb 18 00:09:54 ever kernel: pktcdvd: 54 01 00 00 00 00 00 00 00 00 00 00 -
> > > > > sense 00.54.9c (No sense)
> > > > > Feb 18 00:09:54 ever kernel: pktcdvd: pktcdvd0 Optimum Power Calibration failed
> > > > >
> > > > > And then of course a huge heap of I/O errors on the disk.
> > > >
> > > > Have you verified that this is caused by the speed setting, ie does it
> > > > work correctly if you hack the driver to write at 4x speed?
> > >
> > > Correct. Adding a hard-coded manual setting of write_speed = 5540 to
> > > pkt_open_write results in functional operation (at least with 4x rated
> > > DVD+RW media).
> >
> > Does this patch work for you?
> >
> >
> > pktcdvd: Don't try to write faster than the DVD media speed allows.
> >
> > In theory the drive firmware should limit the speed to the fastest
> > allowed by the currently loaded media, but it doesn't always work in
> > practice.
...
> Unfortunately, no. It -should- work, but the extra DPRINTK's tell a further
> story of the drives stupidity.
>
> Upon running
> % pktsetup 0 /dev/hde ; mkudffs /dev/pktcdvd/0'
> I get the following output:
>
> Feb 24 19:30:31 ever kernel: pktcdvd: inserted media is DVD+RW
> Feb 24 19:30:31 ever kernel: pktcdvd: Max drive write speed 11080kB/s
> Feb 24 19:30:31 ever kernel: pktcdvd: Max. media speed: 5540kB/s
> Feb 24 19:30:31 ever kernel: pktcdvd: write speed 5540kB/s
> Feb 24 19:30:48 ever kernel: pktcdvd: 4590208kB available on disc
>
> All seems well and good. However, upon then issuing
> % mount /dev/pktcdvd/0 /mnt/dvdrw -t auto -o noatime,rw
>
> Feb 24 19:31:28 ever kernel: pktcdvd: inserted media is DVD+RW
> Feb 24 19:31:28 ever kernel: pktcdvd: Max drive write speed 11080kB/s
> Feb 24 19:31:28 ever kernel: pktcdvd: Max. media speed: 11080kB/s
> Feb 24 19:31:28 ever kernel: pktcdvd: write speed 11080kB/s
> Feb 24 19:31:30 ever kernel: pktcdvd: 54 01 00 00 00 00 00 00 00 00 00 00 - sense 00.54.1c (No sense)
> Feb 24 19:31:30 ever kernel: pktcdvd: pktcdvd0 Optimum Power Calibration failed
> Feb 24 19:31:30 ever kernel: pktcdvd: 4590208kB available on disc
> Feb 24 19:31:31 ever kernel: UDF-fs INFO UDF 0.9.8.1 (2004/29/09) Mounting volume 'LinuxUDF', timestamp 2006/02/24 18:30 (1ed4)
> Feb 24 19:31:40 ever kernel: hde: media error (bad sector): status=0x51 { DriveReady SeekComplete Error }
> Feb 24 19:31:40 ever kernel: hde: media error (bad sector): error=0x34 { AbortedCommand LastFailedSense=0x03 }
> Feb 24 19:31:40 ever kernel: ide: failed opcode was: unknown
> Feb 24 19:31:40 ever kernel: end_request: I/O error, dev hde, sector 1088
> Feb 24 19:31:40 ever kernel: hde: command error: status=0x51 { DriveReady SeekComplete Error }
> Feb 24 19:31:40 ever kernel: hde: command error: error=0x54 { AbortedCommand LastFailedSense=0x05 }
> .
> . (and so on)
>
> I'm somewhat confused as to what could be happening here, but my first
> guess is that after being spun up to high speed for reading in
> pkt_iosched_process_queue, the firmware promptly forgets whatever it knew
> about the media speed. Perhaps it only stores a single speed value
> internally, so calling pkt_set_speed (pd, pd->write_speed, pd->read_speed)
> with a larger value of read_speed sets them both. And afterwards the drive
> reports this as the maximum media speed on future opens?

You could test that theory with a hack like this:

diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 94ff3ac..a0d6687 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -461,6 +461,8 @@ static int pkt_set_speed(struct pktcdvd_
struct request_sense sense;
int ret;

+ read_speed = write_speed;
+
init_cdrom_command(&cgc, NULL, 0, CGC_DATA_NONE);
cgc.sense = &sense;
cgc.cmd[0] = GPCMD_SET_SPEED;
@@ -2028,7 +2030,9 @@ static void pkt_release_dev(struct pktcd

pkt_lock_door(pd, 0);

+#if 0
pkt_set_speed(pd, MAX_SPEED, MAX_SPEED);
+#endif
bd_release(pd->bdev);
blkdev_put(pd->bdev);


> If you are curious as to who would curse the market with such a
> buggy product, the drive is a BenQ Q60.

Maybe there is a firmware upgrade available?

--
Peter Osterlund - [email protected]
http://web.telia.com/~u89404340