public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Patch(?): linux-2.5.1-pre7/drivers/block/DAC960.c compilation fixes
@ 2001-12-09  5:12 Adam J. Richter
  2001-12-09 11:36 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Adam J. Richter @ 2001-12-09  5:12 UTC (permalink / raw)
  To: lnz, linux-kernel; +Cc: torvalds

[-- Attachment #1: Type: text/plain, Size: 1338 bytes --]

	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
adam@yggdrasil.com     \ /                  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."

[-- Attachment #2: DAC960.diff --]
[-- Type: text/plain, Size: 4674 bytes --]

--- linux-2.5.1-pre7/drivers/block/DAC960.c	Fri Dec  7 19:37:41 2001
+++ linux/drivers/block/DAC960.c	Sat Dec  8 20:52:40 2001
@@ -1931,7 +1931,6 @@
 {
   int MajorNumber = DAC960_MAJOR + Controller->ControllerNumber;
   RequestQueue_T *RequestQueue;
-  int MinorNumber;
   /*
     Register the Block Device Major Number for this DAC960 Controller.
   */
@@ -1956,9 +1955,6 @@
     Initialize the Disk Partitions array, Partition Sizes array, Block Sizes
     array, and Max Sectors per Request array.
   */
-  for (MinorNumber = 0; MinorNumber < DAC960_MinorCount; MinorNumber++)
-    Controller->MaxSectorsPerRequest[MinorNumber] =
-      Controller->MaxBlocksPerCommand;
   Controller->GenericDiskInfo.part = Controller->DiskPartitions;
   Controller->GenericDiskInfo.sizes = Controller->PartitionSizes;
   blksize_size[MajorNumber] = Controller->BlockSizes;
@@ -2744,17 +2740,17 @@
 	  if (bio_data(BufferHeader) == LastDataEndPointer)
 	    {
 	      ScatterGatherList[SegmentNumber-1].SegmentByteCount +=
-		bio_size(BufferHeader);
-	      LastDataEndPointer += bio_size(BufferHeader);
+		BufferHeader->bi_size;
+	      LastDataEndPointer += BufferHeader->bi_size;
 	    }
 	  else
 	    {
 	      ScatterGatherList[SegmentNumber].SegmentDataPointer =
 		Virtual_to_Bus32(bio_data(BufferHeader));
 	      ScatterGatherList[SegmentNumber].SegmentByteCount =
-		bio_size(BufferHeader);
+		BufferHeader->bi_size;
 	      LastDataEndPointer = bio_data(BufferHeader) +
-		bio_size(BufferHeader);
+		BufferHeader->bi_size;
 	      if (SegmentNumber++ > Controller->DriverScatterGatherLimit)
 		panic("DAC960: Scatter/Gather Segment Overflow\n");
 	    }
@@ -2835,17 +2831,17 @@
 	  if (bio_data(BufferHeader) == LastDataEndPointer)
 	    {
 	      ScatterGatherList[SegmentNumber-1].SegmentByteCount +=
-		bio_size(BufferHeader);
-	      LastDataEndPointer += bio_size(BufferHeader);
+		BufferHeader->bi_size;
+	      LastDataEndPointer += BufferHeader->bi_size;
 	    }
 	  else
 	    {
 	      ScatterGatherList[SegmentNumber].SegmentDataPointer =
 		Virtual_to_Bus64(bio_data(BufferHeader));
 	      ScatterGatherList[SegmentNumber].SegmentByteCount =
-		bio_size(BufferHeader);
+		BufferHeader->bi_size;
 	      LastDataEndPointer = bio_data(BufferHeader) +
-		bio_size(BufferHeader);
+		BufferHeader->bi_size;
 	      if (SegmentNumber++ > Controller->DriverScatterGatherLimit)
 		panic("DAC960: Scatter/Gather Segment Overflow\n");
 	    }
@@ -2947,7 +2943,7 @@
   if (SuccessfulIO)
     set_bit(BIO_UPTODATE, &BufferHeader->bi_flags);
   blk_finished_io(bio_sectors(BufferHeader));
-  BufferHeader->bi_end_io(BufferHeader);
+  BufferHeader->bi_end_io(BufferHeader, bio_sectors(BufferHeader));
 }
 
 
@@ -3063,7 +3059,7 @@
 	      Command->CommandType = DAC960_WriteRetryCommand;
 	      CommandMailbox->Type5.CommandOpcode = DAC960_V1_Write;
 	    }
-	  Command->BlockCount = bio_size(BufferHeader) >> DAC960_BlockSizeBits;
+	  Command->BlockCount = BufferHeader->bi_size >> DAC960_BlockSizeBits;
 	  CommandMailbox->Type5.LD.TransferLength = Command->BlockCount;
 	  CommandMailbox->Type5.BusAddress =
 	    Virtual_to_Bus32(bio_data(BufferHeader));
@@ -3112,9 +3108,9 @@
 	  DAC960_V1_CommandMailbox_T *CommandMailbox =
 	    &Command->V1.CommandMailbox;
 	  Command->BlockNumber +=
-	    bio_size(BufferHeader) >> DAC960_BlockSizeBits;
+	    BufferHeader->bi_size >> DAC960_BlockSizeBits;
 	  Command->BlockCount =
-	    bio_size(NextBufferHeader) >> DAC960_BlockSizeBits;
+	    NextBufferHeader->bi_size >> DAC960_BlockSizeBits;
 	  Command->BufferHeader = NextBufferHeader;
 	  CommandMailbox->Type5.LD.TransferLength = Command->BlockCount;
 	  CommandMailbox->Type5.LogicalBlockAddress = Command->BlockNumber;
@@ -4160,7 +4156,7 @@
 	  if (CommandType == DAC960_ReadCommand)
 	    Command->CommandType = DAC960_ReadRetryCommand;
 	  else Command->CommandType = DAC960_WriteRetryCommand;
-	  Command->BlockCount = bio_size(BufferHeader) >> DAC960_BlockSizeBits;
+	  Command->BlockCount = BufferHeader->bi_size >> DAC960_BlockSizeBits;
 	  CommandMailbox->SCSI_10.CommandControlBits
 				 .AdditionalScatterGatherListMemory = false;
 	  CommandMailbox->SCSI_10.DataTransferSize =
@@ -4216,9 +4212,9 @@
       if (NextBufferHeader != NULL)
 	{
 	  Command->BlockNumber +=
-	    bio_size(BufferHeader) >> DAC960_BlockSizeBits;
+	    BufferHeader->bi_size >> DAC960_BlockSizeBits;
 	  Command->BlockCount =
-	    bio_size(NextBufferHeader) >> DAC960_BlockSizeBits;
+	    NextBufferHeader->bi_size >> DAC960_BlockSizeBits;
 	  Command->BufferHeader = NextBufferHeader;
 	  CommandMailbox->SCSI_10.DataTransferSize =
 	    Command->BlockCount << DAC960_BlockSizeBits;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Patch(?): linux-2.5.1-pre7/drivers/block/DAC960.c compilation fixes
  2001-12-09  5:12 Patch(?): linux-2.5.1-pre7/drivers/block/DAC960.c compilation fixes Adam J. Richter
@ 2001-12-09 11:36 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2001-12-09 11:36 UTC (permalink / raw)
  To: Adam J. Richter; +Cc: lnz, linux-kernel, torvalds

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-12-09 11:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-12-09  5:12 Patch(?): linux-2.5.1-pre7/drivers/block/DAC960.c compilation fixes Adam J. Richter
2001-12-09 11:36 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox