New Mitsumi legacy CD-ROM driver
Good day.
This is (the start of) a new driver for the legacy Mitsumi CD-ROM (LU-00xS and FX-001x) drives that used to be supported by drivers/cdrom/mcd(x).c, a driver that hasn't worked for a long time.
It's being tested on my LU-005S and is being submitted to -mm in the hope of maybe finding a few more testers and also in the hope of provoking a review. I'm co-authoring this with Pekka Enberg but certainly for me it's the first ever contact with anything having anything to do with block.
A few specific points/questions:
* This driver's core transfer function is doing:
rq_for_each_bio(bio, req)
bio_for_each_segment(bvec, bio, segno) {
buffer = bvec_kmap_irq(bvec, &flags);
ioread8_rep(ioaddr, buffer, bvec->bv_len);
bvec_kunmap_irq(buffer, &flags);
}I've been slightly worried about struct bio having a bi_sector field. If we're not guaranteed that bio[n].bi_sector == bio[n-1].bi_sector + 1 during the rq_for_each_bio() loop we can't read from I/O into bio's directly but will need to use a temporary buffer and transfer into the bio's later. Is this guaranteed?
* This driver purports to support highmem. Given the number of machines out there that have both a Mitsumi legacy CD-ROM drive and enough physical memory installed to want highmem support this may come across as being overly... optimistic but is there much point to not supporting it? I believe we do always need the full rq_for_each_bio/bio_for_each_segment loop meaning that only the bvec_k{,un}map_irq could go, right?
* Some controllers do not support an IRQ; ading polled operation will not be hard. Some other controllers support DMA and I'll try and get one going and add that later as well.
* The hardware communication (mitsumi_{read,write}_cmd) can be improved upon. It was mostly taken from the old mcdx driver but every user is calling mitsumi_read_cmd with a 1 byte command, noone cares for the returned status and using MITSUMI_CMD #defines instead of spraying literals around as this is doing would be a bit nicer. This is subject to a later patch when all user's have been introduced though.
* All timeouts are up for grabs as well. Currently everything is using whole-second resolution timeouts but I'll need to instrument this a bit (preferabbly on more hardware samples than just my own) to see what makes sense. The current timeouts are mostly from the old driver.
* The next thing will be adding audio support to the driver. In fact, some parts were present already but have been deleted for now again to not muddy up the driver for review purposes. Some choices in there such as keeping the toc around as an array of struct cdrom_tocentry have been made with adding back mitsumi_audio_ioctl() in mind though and audio should prove relatively painless.
The plan...
Ofcourse not many have these old drives around anymore and even people that do aren't guaranteed to run 2.6 on the machines that host them. All legacy CD-ROM drivers in drivers/cdrom that I've looked at are and have been for quite some time broken and most do not serve a purpose anymore.
Mitsumi (mcdx, this driver), panasonic (sbpcd) and sony (cdu31a) are somewhat of an exception in so far that controllers for those three are still around on a lot of old ISA soundcards though. Moreover, I have the drives to test that trio so after this mitsumi driver is complete and in good shape I'll do the other two as well.
A few Media Vision based ISA soundcards have Philips CM206 controllers sitting on them and I may want to try and locate a matching drive for that but the rest is probably not useful to anyone for any purpose anymore and I'll submit a patch removing them when the ones that I want to keep are done.
Comments welcome...
Rene.
drivers/cdrom/Kconfig +14 -0
@@ -119,6 +119,20 @@ config MCDX To compile this driver as a module, choose M here: the module will be called mcdx. +config MITSUMI + tristate "New Mitsumi CDROM support (EXPERIMENTAL)" + depends on CD_NO_IDESCSI + ---help--- + Use this driver if you want to be able to use your Mitsumi LU-002S, + LU-005S, LU-006S, FX-001S or FX-001D CD-ROM drive. + + If you say Y here, you should also say Y or M to "ISO 9660 CD-ROM + file system support" below, because that's the file system used on + CD-ROMs. + + To compile this driver as a module, choose M here: the + module will be called mitsumi. + config OPTCD tristate "Optics Storage DOLPHIN 8000AT CDROM support" depends on CD_NO_IDESCSI
drivers/cdrom/Makefile +1 -0
@@ -16,6 +16,7 @@ obj-$(CONFIG_CM206) += cm206.o cdrom.o obj-$(CONFIG_GSCD) += gscd.o obj-$(CONFIG_ISP16_CDI) += isp16.o obj-$(CONFIG_MCDX) += mcdx.o cdrom.o +obj-$(CONFIG_MITSUMI) += mitsumi.o cdrom.o obj-$(CONFIG_OPTCD) += optcd.o obj-$(CONFIG_SBPCD) += sbpcd.o cdrom.o obj-$(CONFIG_SJCD) += sjcd.o
drivers/cdrom/mitsumi.c new file +850 -0
850 lines not on this page · raw message
Quoted 1 line · Rene Herman
This is (the start of) a new driver for the legacy Mitsumi CD-ROM (LU-00xS and FX-001x) drives that used to be supported by drivers/cdrom/mcd(x).c, a driver that hasn't worked for a long time.
Forgot:
Rene.
Quoted 22 lines · Rene Herman
Good day.
This is (the start of) a new driver for the legacy Mitsumi CD-ROM (LU-00xS and FX-001x) drives that used to be supported by drivers/cdrom/mcd(x).c, a driver that hasn't worked for a long time.
It's being tested on my LU-005S and is being submitted to -mm in the hope of maybe finding a few more testers and also in the hope of provoking a review. I'm co-authoring this with Pekka Enberg but certainly for me it's the first ever contact with anything having anything to do with block.
A few specific points/questions:
* This driver's core transfer function is doing:
rq_for_each_bio(bio, req) bio_for_each_segment(bvec, bio, segno) { buffer = bvec_kmap_irq(bvec, &flags); ioread8_rep(ioaddr, buffer, bvec->bv_len); bvec_kunmap_irq(buffer, &flags); }
Quoted 5 lines
I've been slightly worried about struct bio having a
bi_sectorfield. If we're not guaranteed that bio[n].bi_sector == bio[n-1].bi_sector + 1 during therq_for_each_bio()loop we can't read from I/O into bio's directly but will need to use a temporary buffer and transfer into the bio's later. Is this guaranteed?
bio[n - 1].bi_sector + bio_sectors(bio[n - 1]) == bio[n].bi_sector
IOW, the bio's in the chain on the request are contig in the lba space.
Quoted 6 lines
* This driver purports to support highmem. Given the number of machines out there that have both a Mitsumi legacy CD-ROM drive and enough physical memory installed to want highmem support this may come across as being overly... optimistic but is there much point to not supporting it? I believe we do always need the full rq_for_each_bio/bio_for_each_segment loop meaning that only the bvec_k{,un}map_irq could go, right?
Yeah, I think it's pointless to support highmem. And as long as you don't call blk_queue_bounce_limit() to actively enable highmem, you are not going to receive a bio/request with highmem pages. The block layer wil bounce any highmem pages before it reaches you. So for a driver like this, I would recommend just forgetting the mapping aspect.
I don't have time to review your driver right now, but I will applaud your effort to write a maintenable mitsumi driver! Basically all the old cdrom drivers are utter crap, so they are destined for removal.
Signature · 1 line
Jens Axboe
On 05/08/2007 12:35 PM, Jens Axboe wrote:
Thanks very much for the prompt answer!
Quoted 3 lines
bio[n - 1].bi_sector +
bio_sectors(bio[n - 1])== bio[n].bi_sectorIOW, the bio's in the chain on the request are contig in the lba space.
Okay great, thanks, everything fine then.
Quoted 3 lines
Yeah, I think it's pointless to support highmem. And as long as you don't call
blk_queue_bounce_limit()to actively enable highmem, you are not going to receive a bio/request with highmem pages.
Yep, the driver is setting BLK_BOUNCE_ANY.
Quoted 3 lines
The block layer wil bounce any highmem pages before it reaches you. So for a driver like this, I would recommend just forgetting the mapping aspect.
Okay, I agree highmem doesn't make any practical sense for this driver but I'm not really sure what it would gain. if !CONFIG_HIGHMEM the bvec_kmap_irq turns info "(page_address((bvec)->bv_page) + (bvec)->bv_offset)" directly anyway. I am a bit unsure about it all but it's not the case that we can then leave out the entire bio_for_each_segnment() loop is it?
(generic kernels with HIGHMEM enabled are I guess an argument...)
Quoted 3 lines
I don't have time to review your driver right now, but I will applaud your effort to write a maintenable mitsumi driver! Basically all the old cdrom drivers are utter crap, so they are destined for removal.
I noticed by the way there was a bit too much emphasis on the "I" in this message; it's in fact Pekka Enberg who started this and did the core stuff!
Yes ,the current legacy CD-ROM drivers really are complete crap by now. Once this mitsumi driver is in final shape it should serve as a nice template for the few other types that I'd like to keep supported and the rest can just go.
Thanks again for the prompt comments.
Rene.
Quoted 5 lines · Rene Herman
Quoted 3 lines
Yeah, I think it's pointless to support highmem. And as long as you don't call
blk_queue_bounce_limit()to actively enable highmem, you are not going to receive a bio/request with highmem pages.Yep, the driver is setting
BLK_BOUNCE_ANY.
Yes I noticed, which means you are not getting anything bounced and that you will need to handle highmem mapping.
Quoted 10 lines
Quoted 3 lines
The block layer wil bounce any highmem pages before it reaches you. So for a driver like this, I would recommend just forgetting the mapping aspect.
Okay, I agree highmem doesn't make any practical sense for this driver but I'm not really sure what it would gain. if !CONFIG_HIGHMEM the
bvec_kmap_irqturns info "(page_address((bvec)->bv_page) + (bvec)->bv_offset)" directly anyway. I am a bit unsure about it all but it's not the case that we can then leave out the entirebio_for_each_segnment()loop is it?
The key is that you have to have interrupts disabled for the highmem case, which may complicate your driver (or just make it perform worse, from the system POV). If you let the block layer bounce, then you can just use page_address() and don't worry about disabling interrupts. The way I see it:
- Either you are using an ancient system with that drive, where you will never see highmem.
- Or, it's a newer system and the nerd in you likes to play with ancient CD-ROM drives. That box may have highmem, but it can also bounce memory thousands of times faster than the mitsumi drive can dish out the data.
IOW, you are always better off not supporting highmem for this driver. The fact that it also simplifies the handling is a bonus.
Quoted 1 line
(generic kernels with HIGHMEM enabled are I guess an argument...)
Yeah, that is true.
Quoted 6 lines
Quoted 3 lines
I don't have time to review your driver right now, but I will applaud your effort to write a maintenable mitsumi driver! Basically all the old cdrom drivers are utter crap, so they are destined for removal.
I noticed by the way there was a bit too much emphasis on the "I" in this message; it's in fact Pekka Enberg who started this and did the core stuff!
Well thanks to both of you, then :-)
Quoted 4 lines
Yes ,the current legacy CD-ROM drivers really are complete crap by now. Once this mitsumi driver is in final shape it should serve as a nice template for the few other types that I'd like to keep supported and the rest can just go.
Fine with me... As far as I am concerned, you are now the legacy CD-ROM driver maintainer :-)
Signature · 1 line
Jens Axboe
Quoted 2 lines · Jens Axboe
IOW, you are always better off not supporting highmem for this driver. The fact that it also simplifies the handling is a bonus.
Agreed. So we should just use BLK_BOUNCE_HIGH, right?
Quoted 2 lines · Jens Axboe
Fine with me... As far as I am concerned, you are now the legacy CD-ROM driver maintainer :-)
Poor Rene... ;-)
Quoted 5 lines · Pekka J Enberg
Quoted 2 lines · Jens Axboe
IOW, you are always better off not supporting highmem for this driver. The fact that it also simplifies the handling is a bonus.
Agreed. So we should just use
BLK_BOUNCE_HIGH, right?
Yeah, just remove the call to blk_queue_bounce_limit() completely, the block layer has always defaulted to that.
Quoted 5 lines · Jens Axboe
Quoted 2 lines
Fine with me... As far as I am concerned, you are now the legacy CD-ROM driver maintainer :-)
Poor Rene... ;-)
I'll be expecting a MAINTAINERS patch :-)
Signature · 1 line
Jens Axboe
Quoted 6 lines · Jens Axboe
Quoted 4 lines
Quoted 2 lines
Fine with me... As far as I am concerned, you are now the legacy CD-ROM driver maintainer :-)
Poor Rene... ;-)
I'll be expecting a
MAINTAINERSpatch :-)
Hey, I _want_ to be supporting this one and the ones that'll follow but I'm waiting with sending that particular patch until they're done and the rest are gone since I'm not going to be maintaining the horrid crap that's there currently thank you very much :-/
Rene.
Quoted 4 lines · Jens Axboe
The key is that you have to have interrupts disabled for the highmem case, which may complicate your driver (or just make it perform worse, from the system POV). If you let the block layer bounce, then you can just use
page_address()and don't worry about disabling interrupts.
Okay, yes, thank you, the mapping is gone. The data-transfer loop has now turned into just:
rq_for_each_bio(bio, req)
bio_for_each_segment(bvec, bio, segno)
ioread8_rep(mcd->ioaddr, page_address(bvec->bv_page) +
bvec->bv_offset, bvec->bv_len);Quoted 2 lines
- Or, it's a newer system and the nerd in you likes to play with ancient CD-ROM drives.
And he has long since driven out most of my other personalities...
Quoted 2 lines
Fine with me... As far as I am concerned, you are now the legacy CD-ROM driver maintainer :-)
Yippie :-)
Rene.
Hi Rene,
drivers/cdrom/mitsumi.c line 221
Quoted 9 lines · Rene Herman
drivers/cdrom/mitsumi.c new file +9
-0+static int __mitsumi_read_toc (struct mitsumi_cdrom *mcd) +{ +int tracks = mcd->header.cdth_trk1 - mcd->header.cdth_trk0 +1 ; +int retries; +int err =0 ; + +kfree (mcd->toc); + + mcd->toc =kzalloc (tracks *sizeof *mcd->toc,GFP_KERNEL );
Perhaps we should use krealloc() + memset() here?
Quoted 14 lines · Pekka Enberg
Hi Rene,
drivers/cdrom/mitsumi.c line 221
Quoted 9 lines · Rene Herman
drivers/cdrom/mitsumi.c new file +9
-0+static int __mitsumi_read_toc (struct mitsumi_cdrom *mcd) +{ +int tracks = mcd->header.cdth_trk1 - mcd->header.cdth_trk0 +1 ; +int retries; +int err =0 ; + +kfree (mcd->toc); + + mcd->toc =kzalloc (tracks *sizeof *mcd->toc,GFP_KERNEL );Perhaps we should use
krealloc()+memset()here?
and sizeof(*cmd->toc) as well.
Signature · 1 line
Jens Axboe
Quoted 11 lines · Pekka Enberg
drivers/cdrom/mitsumi.c line 221
Quoted 9 lines
drivers/cdrom/mitsumi.c new file +9
-0+static int __mitsumi_read_toc (struct mitsumi_cdrom *mcd) +{ +int tracks = mcd->header.cdth_trk1 - mcd->header.cdth_trk0 +1 ; +int retries; +int err =0 ; + +kfree (mcd->toc); + + mcd->toc =kzalloc (tracks *sizeof *mcd->toc,GFP_KERNEL );Perhaps we should use
krealloc()+memset()here?
Earlier I had a patch lined up that checked the previous number of tracks against the current number and only freed the TOC array when they were not the same. The majority case is a data CD with one TOC entry meaning we just reuse the entry. You then have to keep the previous number of tracks though and it seemed a little pointless so I dropped it.
Another option is using a linked list for the TOC and reusing or allocating nodes upon reading the actual entry from the Q channel and freeing the rest when we got them all. Also seemed overly complex and the CDROMREADTOCENTRY gets slower ;-)
I admit my DOS inspired dislike of realloc() is largely pointless these days but, err... "E426: tag not found: krealloc". Would you perhaps like the list? Or the if (tracks != mcd->tracks) thing?
Rene.
Quoted 3 lines · Rene Herman
I admit my DOS inspired dislike of
realloc()is largely pointless these days but, err... "E426: tag not found: krealloc". Would you perhaps like the list? Or the if (tracks !=mcd->tracks) thing?
The krealloc() API has been in current git for few days now. I suggested it because I thought it would nicely fold the kfree() + kzalloc() pair into a simple krealloc() call but the error handling makes it a total mess. I think we need kzrealloc() in the kernel... ;-)
So please simply ignore my comment.
Pekka
Quoted 9 lines · Rene Herman
Quoted 9 lines
drivers/cdrom/mitsumi.c new file +9
-0+static int __mitsumi_read_toc (struct mitsumi_cdrom *mcd) +{ +int tracks = mcd->header.cdth_trk1 - mcd->header.cdth_trk0 +1 ; +int retries; +int err =0 ; + +kfree (mcd->toc); + + mcd->toc =kzalloc (tracks *sizeof *mcd->toc,GFP_KERNEL );
Quoted 1 line · Pekka Enberg
Perhaps we should use
krealloc()+memset()here?
Strike that, krealloc() only makes it look ugly.
Quoted 5 lines · On Tuesday 08 May 2007 11:42:08 you wrote:
Mitsumi (mcdx, this driver), panasonic (sbpcd) and sony (cdu31a) are somewhat of an exception in so far that controllers for those three are still around on a lot of old ISA soundcards though. Moreover, I have the drives to test that trio so after this mitsumi driver is complete and in good shape I'll do the other two as well.
I fixed cdu31a some time ago - so it at least works.
I also have a Panasonic drive with controller integrated on a SB16 sound card but haven't tried it with Linux yet.
It's nice to see new driver for these old drives.
Signature · 1 line
Ondrej Zary
Quoted 7 lines · Ondrej Zary
Quoted 5 lines · On Tuesday 08 May 2007 11:42:08 you wrote:
Mitsumi (mcdx, this driver), panasonic (sbpcd) and sony (cdu31a) are somewhat of an exception in so far that controllers for those three are still around on a lot of old ISA soundcards though. Moreover, I have the drives to test that trio so after this mitsumi driver is complete and in good shape I'll do the other two as well.
Quoted 5 lines
I fixed cdu31a some time ago - so it at least works.
I also have a Panasonic drive with controller integrated on a SB16 sound card but haven't tried it with Linux yet.It's nice to see new driver for these old drives.
Agreed. I've still got a GUS in one of my museum pieces that runs MS-Win 3.1 by default. The BIOS is too old to support booting from anything except hda, sda and floppy, but because I enjoy pain I'll be happy to modify the startup floppy images for a 2.6.X-based live CD distro (DSL, anyone?) and give the new drivers a spin when they're ready for testing. The motherboard is a curiosity: it has ISA, PCI, *and* VLB slots. The processor is an AMD 5x86 (think 486 on steroids). I *might* have 32 MB of RAM to work with: I simply don't remember :-).
Signature · 4 lines
----------------------------------------------------------------------- Bob Tracy WTO + WIPO = DMCA? http://www.anti-dmca.org [email protected] -----------------------------------------------------------------------
Quoted 5 lines · Bob Tracy
Agreed. I've still got a GUS in one of my museum pieces that runs MS-Win 3.1 by default. The BIOS is too old to support booting from anything except hda, sda and floppy, but because I enjoy pain I'll be happy to modify the startup floppy images for a 2.6.X-based live CD distro (DSL, anyone?) and give the new drivers a spin when they're ready for testing.
Okay, thanks. Which drive(s) do you have? If mitsumi, the driver as posted is already functioning well for data. My LU005 drive is a single speed drive (150 K/s) but it's giving me close to 400 K/s. At the moment I also have it hanging of a GUS...
Quoted 1 line
The motherboard is a curiosity: it has ISA, PCI, *and* VLB slots.
Mmm. Never seen that...
Rene.
Quoted 1 line · Ondrej Zary
I fixed cdu31a some time ago - so it at least works.
Oh, okay, thanks, I missed that. When I last tested it (which I see is in fact well over a year ago) it "sort of" worked sometimes but was really flakey.
Quoted 2 lines
I also have a Panasonic drive with controller integrated on a SB16 sound card but haven't tried it with Linux yet.
Current driver doesn't work. Or, again, very much didn't when I last tried it.
Rene.