2.6 ide-cd DMA ripping
Subsystems (3)
Hi,
I've tried your patch (with the modifications you hinted, included in attachment) with cdparanoia and:
1) it works (I get an identical wav)
2) it makes indeed a huge difference on my system:
- before:
cdparanoia 1 4.20s user 1.98s system 3% cpu 3:12.89 total
- after:
cdparanoia 1 3.87s user 1.41s system 15% cpu 33.793 total
Total time went from 3 min to 30 sec... really great :-)
Vince
Hi,
2.6 still uses PIO for CDROMREADAUDIO cdda ripping, which is less than optimal of course... This patch uses the block layer infrastructure to enable zero copy DMA ripping through CDROMREADAUDIO.
I'd appreciate people giving this a test spin. Patch is against 2.6.4-rc1 (well current BK, actually).
===== drivers/block/ll_rw_blk.c 1.228 vs edited =====
drivers/block/ll_rw_blk.c +137 -0
@@ -28,6 +28,11 @@#include <linux/slab.h> #include <linux/swap.h> +/* +* for max sense size +*/ +#include <scsi/scsi_cmnd.h> +static void blk_unplug_work (void *data);static void blk_unplug_timeout (unsigned long data);
@@ -1756,6 +1761,138 @@ }EXPORT_SYMBOL (blk_insert_request); + +/** +* blk_rq_map_user - map user data to a request, for REQ_BLOCK_PC usage +* @q: request queue where request should be inserted +* @rw: READ or WRITE data +* @ubuf: the user buffer +* @len: length of user data +* +* Description: +* Data will be mapped directly for zero copy io, if possible. Otherwise +* a kernel bounce buffer is used. +* +* A matching blk_rq_unmap_user() must be issued at the end of io, while +* still in process context. +*/ +struct request *blk_rq_map_user (request_queue_t *q,int rw,void __user *ubuf, +unsigned int len) +{ +struct request *rq =NULL ; +char *buf =NULL ; +struct bio *bio; + + rq =blk_get_request (q, rw, __GFP_WAIT); +if (!rq) +return NULL ; + + bio =bio_map_user (q,NULL , (unsigned long ) ubuf, len, rw ==READ ); +if (!bio) { + buf =kmalloc (len, q->bounce_gfp |GFP_USER ); +if (!buf) + goto fault; + +if (rw ==WRITE ) { +if (copy_from_user (buf, ubuf, len)) + goto fault; + }else +memset (buf,0 , len); + } + + rq->bio = rq->biotail = bio; +if (rq->bio) +blk_rq_bio_prep (q, rq, bio); + + rq->buffer = rq->data = buf; + rq->data_len = len; +return rq; +fault: +if (buf) +kfree (buf); +if (bio) +bio_unmap_user (bio,1 ); +if (rq) +blk_put_request (rq); + +return NULL ; +} + +EXPORT_SYMBOL (blk_rq_map_user); + +/** +* blk_rq_unmap_user - unmap a request with user data +* @rq: request to be unmapped +* @ubuf: user buffer +* @ulen: length of user buffer +* @rw: operation was a READ or WRITE +* +* Description: +* Unmap a request previously mapped by blk_rq_map_user(). +*/ +int blk_rq_unmap_user (struct request *rq,void __user *ubuf,unsigned int ulen, +int rw) +{ +int ret =0 ; + +if (rq->biotail) +bio_unmap_user (rq->biotail, rw ==READ ); +if (rq->buffer) { +if (rw ==READ &©_to_user (ubuf, rq->buffer, ulen)) + ret = -EFAULT ; +kfree (rq->buffer); + } + +blk_put_request (rq); +return ret; +} + +EXPORT_SYMBOL (blk_rq_unmap_user); + +/** +* blk_execute_rq - insert a request into queue for execution +* @q: queue to insert the request in +* @bd_disk: matching gendisk +* @rq: request to insert +* +* Description: +* Insert a fully prepared request at the back of the io scheduler queue +* for execution. +*/ +int blk_execute_rq (request_queue_t *q,struct gendisk *bd_disk, +struct request *rq) +{ +DECLARE_COMPLETION (wait); +char sense[SCSI_SENSE_BUFFERSIZE ]; +int err =0 ; + + rq->rq_disk = bd_disk; + +/* +* we need an extra reference to the request, so we can look at +* it after io completion +*/ + rq->ref_count++; + +if (!rq->sense) { +memset (sense,0 ,sizeof (sense)); + rq->sense = sense; + rq->sense_len =0 ; + } + + rq->flags |=REQ_NOMERGE ; + rq->waiting = &wait; +elv_add_request (q, rq,ELEVATOR_INSERT_BACK ,1 ); +generic_unplug_device (q); +wait_for_completion (&wait); + +if (rq->errors) + err = -EIO ; + +return err; +} + +EXPORT_SYMBOL (blk_execute_rq);void drive_stat_acct (struct request *rq,int nr_sectors,int new_io) {
drivers/block/scsi_ioctl.c +4 -42
76 lines not on this page · raw message
drivers/cdrom/cdrom.c +144 -35
203 lines not on this page · raw message
drivers/ide/ide-cd.c +1 -0
@@ -2931,6 +2931,7 @@if (!CDROM_CONFIG_FLAGS (drive)->mrw_w) devinfo->mask |=CDC_MRW_W ; + devinfo->disk = drive->disk;return register_cdrom (devinfo); }
drivers/scsi/sr.c +4 -1
@@ -566,13 +566,16 @@snprintf (disk->devfs_name,sizeof (disk->devfs_name),"%s/cd" , sdev->devfs_name); disk->driverfs_dev = &sdev->sdev_gendev; -register_cdrom (&cd->cdi);set_capacity (disk, cd->capacity); disk->private_data = &cd->driver; disk->queue = sdev->request_queue; + cd->cdi.disk = disk;dev_set_drvdata (dev, cd);add_disk (disk); + +if (register_cdrom (&cd->cdi)) + goto fail_put; printk(KERN_DEBUG "Attached scsi CD-ROM %s at scsi%d, channel %d, id %d, lun %d\n",
include/linux/blkdev.h +3 -0
@@ -514,6 +514,9 @@extern void __blk_stop_queue (request_queue_t *q);extern void blk_run_queue (request_queue_t *q);extern void blk_queue_activity_fn (request_queue_t *,activity_fn *,void *); +extern struct request *blk_rq_map_user (request_queue_t *,int ,void __user *,unsigned int ); +extern int blk_rq_unmap_user (struct request *,void __user *,unsigned int ,int ); +extern int blk_execute_rq (request_queue_t *,struct gendisk *,struct request *);static inline request_queue_t *bdev_get_queue (struct block_device *bdev) {
include/linux/cdrom.h +6 -0
@@ -877,10 +877,15 @@#include <linux/fs.h> /* not really needed, later.. */ #include <linux/device.h> +#define CDDA_OLD 0/* old style */ +#define CDDA_BPC_SINGLE 1/* block_pc, but single frame */ +#define CDDA_BPC_FULL 2/* full speed block pc */ +/* Uniform cdrom data structures for cdrom.c */ struct cdrom_device_info {struct cdrom_device_ops *ops;/* link to device_ops */ struct cdrom_device_info *next;/* next device_info for this major */ +struct gendisk *disk;/* matching block layer disk */ void *handle;/* driver-dependent data */ /* specifications */ int mask;/* mask of capability: disables them */
@@ -894,6 +899,7 @@/* per-device flags */ __u8 sanyo_slot : 2; /* Sanyo 3 CD changer support */ __u8 reserved : 6; /* not used yet */ +int cdda_method;/* see flags */ int for_data;int (*exit)(struct cdrom_device_info *);int mrw_mode_page;
Signature · 6 lines
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
Quoted 8 lines · Vince
Hi,
I've tried your patch (with the modifications you hinted, included in attachment) with cdparanoia and:
1) it works (I get an identical wav)
2) it makes indeed a huge difference on my system:
Quoted 6 lines
- before:
cdparanoia 1 4.20s user 1.98s system 3% cpu 3:12.89 total
- after:
cdparanoia 1 3.87s user 1.41s system 15% cpu 33.793 totalTotal time went from 3 min to 30 sec... really great :-)
Thanks for testing (and reporting back).
Signature · 1 line
Jens Axboe
Hi,
Quoted 2 lines
I'd appreciate people giving this a test spin. Patch is against 2.6.4-rc1 (well current BK, actually).
Works (on ppc, ibook G4 here). It's indeed faster. But, it breaks direct output to dsp (as in cdparanoia 1 /dev/dsp).
HTH,
Signature · 1 line
Colin
Quoted 7 lines · Colin Leroy
Hi,
Quoted 2 lines
I'd appreciate people giving this a test spin. Patch is against 2.6.4-rc1 (well current BK, actually).
Works (on ppc, ibook G4 here). It's indeed faster. But, it breaks direct output to dsp (as in
cdparanoia 1 /dev/dsp).
How do you know it works, then? cdparanoia should receive identical data, otherwise it sounds like it doesn't work.
Dump a track without the patch, repeat with the patch, and compare the images.
(BTW, please cc recipients on lkml. At least to me, otherwise I may not see your message for days).
Signature · 1 line
Jens Axboe
Hi,
Quoted 1 line
Quoted 1 line
Works (on ppc, ibook G4 here). It's indeed faster. But, it breaks
direct
Quoted 4 lines
Quoted 1 line
output to dsp (as in
cdparanoia 1 /dev/dsp).How do you know it works, then? cdparanoia should receive identical data, otherwise it sounds like it doesn't work.
Well, using 'mplayer cdda.wav' works.
Quoted 2 lines
Dump a track without the patch, repeat with the patch, and compare the images.
With or without the patch, that's the exact same file resulting. Maybe the fact that it doesn't work anymore with /dev/dsp isn't due to your patch but to something else (I hadn't tried that since a while). I'll report again as soon as i'll be in front of my laptop.
Quoted 2 lines
(BTW, please cc recipients on lkml. At least to me, otherwise I may not see your message for days).
Yup, sorry, I'm not subscribed so created a new mail, and forgot this.
Thanks,
Signature · 3 lines
Colin This message represents the official view of the voices in my head.
Quoted 11 lines · Colin Leroy
Hi,
Quoted 1 line
Quoted 1 line
Works (on ppc, ibook G4 here). It's indeed faster. But, it breaks
direct
Quoted 4 lines
Quoted 1 line
output to dsp (as in
cdparanoia 1 /dev/dsp).How do you know it works, then? cdparanoia should receive identical data, otherwise it sounds like it doesn't work.
Well, using 'mplayer cdda.wav' works.
Quoted 7 lines
Quoted 2 lines
Dump a track without the patch, repeat with the patch, and compare the images.
With or without the patch, that's the exact same file resulting. Maybe the fact that it doesn't work anymore with
/dev/dspisn't due to your patch but to something else (I hadn't tried that since a while). I'll report again as soon as i'll be in front of my laptop.
Ok great, then it must be something else. Thanks for the report.
Signature · 1 line
Jens Axboe