public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Boaz Harrosh <bharrosh@panasas.com>
To: Jens Axboe <jens.axboe@oracle.com>,
	James Bottomley <James.Bottomley@SteelEye.com>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>,
	FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	dougg@torque.net
Subject: [PATCH 3/3] SG: Update ide/ to use sg_table
Date: Thu, 20 Dec 2007 16:06:56 +0200	[thread overview]
Message-ID: <476A7700.6080008@panasas.com> (raw)
In-Reply-To: <476A743D.2080506@panasas.com>

From: Jens Axboe <jens.axboe@oracle.com>

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
---
 drivers/ide/arm/icside.c      |    6 +++---
 drivers/ide/cris/ide-cris.c   |    2 +-
 drivers/ide/ide-dma.c         |    8 ++++----
 drivers/ide/ide-io.c          |    2 +-
 drivers/ide/ide-probe.c       |    6 +-----
 drivers/ide/ide-taskfile.c    |    2 +-
 drivers/ide/ide.c             |    2 +-
 drivers/ide/mips/au1xxx-ide.c |    8 ++++----
 drivers/ide/pci/sgiioc4.c     |    4 ++--
 drivers/ide/ppc/pmac.c        |    6 +++---
 drivers/scsi/ide-scsi.c       |    2 +-
 include/linux/ide.h           |    2 +-
 12 files changed, 23 insertions(+), 27 deletions(-)

diff --git a/drivers/ide/arm/icside.c b/drivers/ide/arm/icside.c
index 93f71fc..a48a6bd 100644
--- a/drivers/ide/arm/icside.c
+++ b/drivers/ide/arm/icside.c
@@ -210,7 +210,7 @@ static void icside_build_sglist(ide_drive_t *drive, struct request *rq)
 {
 	ide_hwif_t *hwif = drive->hwif;
 	struct icside_state *state = hwif->hwif_data;
-	struct scatterlist *sg = hwif->sg_table;
+	struct scatterlist *sg = hwif->sg_table.sgl;
 
 	ide_map_sg(drive, rq);
 
@@ -319,7 +319,7 @@ static int icside_dma_end(ide_drive_t *drive)
 	disable_dma(ECARD_DEV(state->dev)->dma);
 
 	/* Teardown mappings after DMA has completed. */
-	dma_unmap_sg(state->dev, hwif->sg_table, hwif->sg_nents,
+	dma_unmap_sg(state->dev, hwif->sg_table.sgl, hwif->sg_nents,
 		     hwif->sg_dma_direction);
 
 	return get_dma_residue(ECARD_DEV(state->dev)->dma) != 0;
@@ -373,7 +373,7 @@ static int icside_dma_setup(ide_drive_t *drive)
 	 * Tell the DMA engine about the SG table and
 	 * data direction.
 	 */
-	set_dma_sg(ECARD_DEV(state->dev)->dma, hwif->sg_table, hwif->sg_nents);
+	set_dma_sg(ECARD_DEV(state->dev)->dma, hwif->sg_table.sgl, hwif->sg_nents);
 	set_dma_mode(ECARD_DEV(state->dev)->dma, dma_mode);
 
 	drive->waiting_for_dma = 1;
diff --git a/drivers/ide/cris/ide-cris.c b/drivers/ide/cris/ide-cris.c
index 476e0d6..3701aca 100644
--- a/drivers/ide/cris/ide-cris.c
+++ b/drivers/ide/cris/ide-cris.c
@@ -919,7 +919,7 @@ static int cris_ide_build_dmatable (ide_drive_t *drive)
 	unsigned int count = 0;
 	int i = 0;
 
-	sg = hwif->sg_table;
+	sg = hwif->sg_table.sgl;
 
 	ata_tot_size = 0;
 
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index 4703837..33a2f56 100644
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -190,7 +190,7 @@ static int ide_dma_good_drive(ide_drive_t *drive)
 int ide_build_sglist(ide_drive_t *drive, struct request *rq)
 {
 	ide_hwif_t *hwif = HWIF(drive);
-	struct scatterlist *sg = hwif->sg_table;
+	struct scatterlist *sg = hwif->sg_table.sgl;
 
 	BUG_ON((rq->cmd_type == REQ_TYPE_ATA_TASKFILE) && rq->nr_sectors > 256);
 
@@ -234,7 +234,7 @@ int ide_build_dmatable (ide_drive_t *drive, struct request *rq)
 	if (!i)
 		return 0;
 
-	sg = hwif->sg_table;
+	sg = hwif->sg_table.sgl;
 	while (i) {
 		u32 cur_addr;
 		u32 cur_len;
@@ -293,7 +293,7 @@ int ide_build_dmatable (ide_drive_t *drive, struct request *rq)
 	printk(KERN_ERR "%s: empty DMA table?\n", drive->name);
 use_pio_instead:
 	pci_unmap_sg(hwif->pci_dev,
-		     hwif->sg_table,
+		     hwif->sg_table.sgl,
 		     hwif->sg_nents,
 		     hwif->sg_dma_direction);
 	return 0; /* revert to PIO for this request */
@@ -315,7 +315,7 @@ EXPORT_SYMBOL_GPL(ide_build_dmatable);
 void ide_destroy_dmatable (ide_drive_t *drive)
 {
 	struct pci_dev *dev = HWIF(drive)->pci_dev;
-	struct scatterlist *sg = HWIF(drive)->sg_table;
+	struct scatterlist *sg = HWIF(drive)->sg_table.sgl;
 	int nents = HWIF(drive)->sg_nents;
 
 	pci_unmap_sg(dev, sg, nents, HWIF(drive)->sg_dma_direction);
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index bef781f..638e2db 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -819,7 +819,7 @@ static ide_startstop_t do_special (ide_drive_t *drive)
 void ide_map_sg(ide_drive_t *drive, struct request *rq)
 {
 	ide_hwif_t *hwif = drive->hwif;
-	struct scatterlist *sg = hwif->sg_table;
+	struct scatterlist *sg = hwif->sg_table.sgl;
 
 	if (hwif->sg_mapped)	/* needed by ide-scsi */
 		return;
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 2994523..770f8cf 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -1312,15 +1312,11 @@ static int hwif_init(ide_hwif_t *hwif)
 	if (!hwif->sg_max_nents)
 		hwif->sg_max_nents = PRD_ENTRIES;
 
-	hwif->sg_table = kmalloc(sizeof(struct scatterlist)*hwif->sg_max_nents,
-				 GFP_KERNEL);
-	if (!hwif->sg_table) {
+	if (sg_alloc_table(&hwif->sg_table, hwif->sg_max_nents, GFP_KERNEL)) {
 		printk(KERN_ERR "%s: unable to allocate SG table.\n", hwif->name);
 		goto out;
 	}
 
-	sg_init_table(hwif->sg_table, hwif->sg_max_nents);
-	
 	if (init_irq(hwif) == 0)
 		goto done;
 
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index 2b60f1b..0a898d9 100644
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -246,7 +246,7 @@ static u8 wait_drive_not_busy(ide_drive_t *drive)
 static void ide_pio_sector(ide_drive_t *drive, unsigned int write)
 {
 	ide_hwif_t *hwif = drive->hwif;
-	struct scatterlist *sg = hwif->sg_table;
+	struct scatterlist *sg = hwif->sg_table.sgl;
 	struct scatterlist *cursg = hwif->cursg;
 	struct page *page;
 #ifdef CONFIG_HIGHMEM
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 54943da..a2ad85a 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -594,7 +594,7 @@ void ide_unregister(unsigned int index)
 	 * Remove us from the kernel's knowledge
 	 */
 	blk_unregister_region(MKDEV(hwif->major, 0), MAX_DRIVES<<PARTN_BITS);
-	kfree(hwif->sg_table);
+	sg_free_table(&hwif->sg_table);
 	unregister_blkdev(hwif->major, hwif->name);
 	spin_lock_irq(&ide_lock);
 
diff --git a/drivers/ide/mips/au1xxx-ide.c b/drivers/ide/mips/au1xxx-ide.c
index a4ce3ba..bccf3c0 100644
--- a/drivers/ide/mips/au1xxx-ide.c
+++ b/drivers/ide/mips/au1xxx-ide.c
@@ -216,7 +216,7 @@ static int auide_build_sglist(ide_drive_t *drive,  struct request *rq)
 {
 	ide_hwif_t *hwif = drive->hwif;
 	_auide_hwif *ahwif = (_auide_hwif*)hwif->hwif_data;
-	struct scatterlist *sg = hwif->sg_table;
+	struct scatterlist *sg = hwif->sg_table.sgl;
 
 	ide_map_sg(drive, rq);
 
@@ -250,7 +250,7 @@ static int auide_build_dmatable(ide_drive_t *drive)
 		return 0;
 
 	/* fill the descriptors */
-	sg = hwif->sg_table;
+	sg = hwif->sg_table.sgl;
 	while (i && sg_dma_len(sg)) {
 		u32 cur_addr;
 		u32 cur_len;
@@ -303,7 +303,7 @@ static int auide_build_dmatable(ide_drive_t *drive)
 
  use_pio_instead:
 	dma_unmap_sg(ahwif->dev,
-		     hwif->sg_table,
+		     hwif->sg_table.sgl,
 		     hwif->sg_nents,
 		     hwif->sg_dma_direction);
 
@@ -316,7 +316,7 @@ static int auide_dma_end(ide_drive_t *drive)
 	_auide_hwif *ahwif = (_auide_hwif*)hwif->hwif_data;
 
 	if (hwif->sg_nents) {
-		dma_unmap_sg(ahwif->dev, hwif->sg_table, hwif->sg_nents,
+		dma_unmap_sg(ahwif->dev, hwif->sg_table.sgl, hwif->sg_nents,
 			     hwif->sg_dma_direction);
 		hwif->sg_nents = 0;
 	}
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c
index de820aa..3ad9e4b 100644
--- a/drivers/ide/pci/sgiioc4.c
+++ b/drivers/ide/pci/sgiioc4.c
@@ -487,7 +487,7 @@ sgiioc4_build_dma_table(ide_drive_t * drive, struct request *rq, int ddir)
 	if (!i)
 		return 0;	/* sglist of length Zero */
 
-	sg = hwif->sg_table;
+	sg = hwif->sg_table.sgl;
 	while (i && sg_dma_len(sg)) {
 		dma_addr_t cur_addr;
 		int cur_len;
@@ -535,7 +535,7 @@ sgiioc4_build_dma_table(ide_drive_t * drive, struct request *rq, int ddir)
 	}
 
 use_pio_instead:
-	pci_unmap_sg(hwif->pci_dev, hwif->sg_table, hwif->sg_nents,
+	pci_unmap_sg(hwif->pci_dev, hwif->sg_table.sgl, hwif->sg_nents,
 		     hwif->sg_dma_direction);
 
 	return 0;		/* revert to PIO for this request */
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
index 7f7a598..b982180 100644
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -1503,7 +1503,7 @@ pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq)
 		return 0;
 
 	/* Build DBDMA commands list */
-	sg = hwif->sg_table;
+	sg = hwif->sg_table.sgl;
 	while (i && sg_dma_len(sg)) {
 		u32 cur_addr;
 		u32 cur_len;
@@ -1555,7 +1555,7 @@ pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq)
 	printk(KERN_DEBUG "%s: empty DMA table?\n", drive->name);
  use_pio_instead:
 	pci_unmap_sg(hwif->pci_dev,
-		     hwif->sg_table,
+		     hwif->sg_table.sgl,
 		     hwif->sg_nents,
 		     hwif->sg_dma_direction);
 	return 0; /* revert to PIO for this request */
@@ -1567,7 +1567,7 @@ pmac_ide_destroy_dmatable (ide_drive_t *drive)
 {
 	ide_hwif_t *hwif = drive->hwif;
 	struct pci_dev *dev = HWIF(drive)->pci_dev;
-	struct scatterlist *sg = hwif->sg_table;
+	struct scatterlist *sg = hwif->sg_table.sgl;
 	int nents = hwif->sg_nents;
 
 	if (nents) {
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index 9706de9..762bd93 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -553,7 +553,7 @@ static int idescsi_map_sg(ide_drive_t *drive, idescsi_pc_t *pc)
 	if (idescsi_set_direction(pc))
 		return 1;
 
-	sg = hwif->sg_table;
+	sg = hwif->sg_table.sgl;
 	scsi_sg = scsi_sglist(pc->scsi_cmd);
 	segments = scsi_sg_count(pc->scsi_cmd);
 
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 9a6a41e..80ff2ee 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -750,7 +750,7 @@ typedef struct hwif_s {
 	/* dma physical region descriptor table (dma view) */
 	dma_addr_t	dmatable_dma;
 	/* Scatter-gather list used to build the above */
-	struct scatterlist *sg_table;
+	struct sg_table sg_table;
 	int sg_max_nents;		/* Maximum number of entries in it */
 	int sg_nents;			/* Current number of entries in it */
 	int sg_dma_direction;		/* dma transfer direction */
-- 
1.5.3.3



      parent reply	other threads:[~2007-12-20 14:08 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-20  5:45 [PATCH 0/5] sg_ring for scsi Rusty Russell
2007-12-20  5:48 ` [PATCH 1/5] sg_ring: sg_ring.h Rusty Russell
2007-12-20  5:49   ` [PATCH 2/5] dma_map_sg_ring() helper Rusty Russell
2007-12-20  5:50     ` [PATCH 3/5] blk_rq_map_sg_ring as a counterpart to blk_rq_map_sg Rusty Russell
2007-12-20  5:51       ` [PATCH 4/5] sg_ring: Convert core scsi code to sg_ring Rusty Russell
2007-12-20  5:53         ` [PATCH 5/5] sg_ring: Convert scsi_debug Rusty Russell
2007-12-20  7:06     ` [PATCH 2/5] dma_map_sg_ring() helper FUJITA Tomonori
2007-12-20  7:42       ` David Miller
2007-12-20 22:58         ` Rusty Russell
2007-12-21  0:00           ` FUJITA Tomonori
2007-12-21  0:35             ` Rusty Russell
2007-12-21  0:40               ` David Miller
2007-12-21  2:22                 ` FUJITA Tomonori
2007-12-21  2:47                 ` Rusty Russell
2007-12-20  7:07 ` [PATCH 0/5] sg_ring for scsi FUJITA Tomonori
2007-12-20  7:53   ` Rusty Russell
2007-12-20  7:58     ` David Miller
2007-12-20  7:58       ` Jens Axboe
2007-12-20 23:13       ` Rusty Russell
2007-12-21  0:30         ` David Miller
2007-12-21  2:28         ` FUJITA Tomonori
2007-12-21  3:26           ` Rusty Russell
2007-12-21  4:37             ` FUJITA Tomonori
2007-12-26  0:27               ` Rusty Russell
2007-12-27  2:09                 ` FUJITA Tomonori
2007-12-27 11:52                   ` Rusty Russell
2007-12-21 12:13         ` Herbert Xu
2007-12-20  7:58     ` Jens Axboe
2007-12-20 13:55       ` Boaz Harrosh
2007-12-20 14:00         ` [PATCH 1/3] SG: Move functions to lib/scatterlist.c and add sg chaining allocator helpers Boaz Harrosh
2007-12-20 14:21           ` Boaz Harrosh
2007-12-21 12:15           ` Herbert Xu
2007-12-20 14:03         ` [PATCH 2/3] SG: Convert SCSI to use scatterlist helpers for sg chaining Boaz Harrosh
2007-12-20 14:26           ` Boaz Harrosh
2007-12-20 14:06         ` Boaz Harrosh [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=476A7700.6080008@panasas.com \
    --to=bharrosh@panasas.com \
    --cc=James.Bottomley@SteelEye.com \
    --cc=akpm@linux-foundation.org \
    --cc=dougg@torque.net \
    --cc=fujita.tomonori@lab.ntt.co.jp \
    --cc=jens.axboe@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox