2001-12-09 05:12:55

by Adam J. Richter

[permalink] [raw]
Subject: Patch(?): linux-2.5.1-pre7/drivers/block/DAC960.c compilation fixes

The following patch makes linux-2.5.1-pre7/drivers/block/DAC960.c
compile. I'm not confident in my understanding of the new "bio" system,
so it would be helpful if someone more knowledgeable about bio could
check it. The changes are:

1. Delete references the nonexistant MaxSectorsPerRequest field.
The code already sets RequestQueue->max_sectors.

2. Replace the undefined bio_size(BufferHead) with BufferHead->bi_size
(in many places, which is why the diff is big).

3. Add a missing parameter in one place, changing
BufferHeader->bi_end_io(BufferHeader)
to
BufferHeader->bi_end_io(BufferHeader, bio_sectors(BufferHeader))


#3 is the one that I have the most doubts about.

Anyhow, with this patch and the one that I posted for
drivers/block/xd.c, all of the x86-compatible drivers in
linux-2.5.1-pre7/drivers/block/ seem to compile (as modules, except for
rd.c, which is compiled in).

Alas, there are about 90 other files outside of drivers/block/
that do not compile. I will probably try to fix some of those next.

--
Adam J. Richter __ ______________ 4880 Stevens Creek Blvd, Suite 104
[email protected] \ / San Jose, California 95129-1034
+1 408 261-6630 | g g d r a s i l United States of America
fax +1 408 261-6631 "Free Software For The Rest Of Us."


Attachments:
(No filename) (1.31 kB)
DAC960.diff (4.56 kB)
Download all attachments

2001-12-09 11:36:48

by Jens Axboe

[permalink] [raw]
Subject: Re: Patch(?): linux-2.5.1-pre7/drivers/block/DAC960.c compilation fixes

On Sat, Dec 08 2001, Adam J. Richter wrote:
> The following patch makes linux-2.5.1-pre7/drivers/block/DAC960.c
> compile. I'm not confident in my understanding of the new "bio" system,
> so it would be helpful if someone more knowledgeable about bio could
> check it. The changes are:
>
> 1. Delete references the nonexistant MaxSectorsPerRequest field.
> The code already sets RequestQueue->max_sectors.
>
> 2. Replace the undefined bio_size(BufferHead) with BufferHead->bi_size
> (in many places, which is why the diff is big).
>
> 3. Add a missing parameter in one place, changing
> BufferHeader->bi_end_io(BufferHeader)
> to
> BufferHeader->bi_end_io(BufferHeader, bio_sectors(BufferHeader))
>
>
> #3 is the one that I have the most doubts about.

It's not as easy as this. Note that you can have more than one page
entry in a bio, so if you simply use bio_data() on each bio and then
jump to the next through bi_next, then you are discarding every page but
the first one.

You want to do something like this:

rq_for_each_bio(bio, rq)
bio_for_each_segment(bio_vec, bio, i)
/* handle each bio_vec */

DAC960 needs a huge cleanup to support highmem as well, Virtual_to_Bus32
and Virtual_to_Bus64, yuck, chest pains.

As a reference, read drivers/block/cciss.c for example which I've
converted to use the blk_rq_map_sg interface. Basically you don't have
to worry about any of this. You can check ide-dma.c too, note how easy
it is to setup a scatterlist mapping for DMA from a request now:

/*
* map the request into a scatterlist
*/
nr_sg_entries = blk_rq_map_sg(q, rq, sg_table);

/*
* map the scatterlist pages for streaming dma
*/
sg_nents = pci_map_sg(dev, sg_table, nr_sg_entries, data_dir);

--
Jens Axboe