public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <jens.axboe@oracle.com>
To: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: davem@davemloft.net, linux-kernel@vger.kernel.org,
	linux-scsi@vger.kernel.org
Subject: Re: [PATCH] SPARC64: fix iommu sg chaining
Date: Wed, 17 Oct 2007 13:16:01 +0200	[thread overview]
Message-ID: <20071017111600.GY5043@kernel.dk> (raw)
In-Reply-To: <20071017111348.GX5043@kernel.dk>

On Wed, Oct 17 2007, Jens Axboe wrote:
> On Wed, Oct 17 2007, FUJITA Tomonori wrote:
> > On Wed, 17 Oct 2007 02:45:47 -0700 (PDT)
> > David Miller <davem@davemloft.net> wrote:
> > 
> > > From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
> > > Date: Wed, 17 Oct 2007 18:24:01 +0900
> > > 
> > > > On Wed, 17 Oct 2007 11:16:29 +0200
> > > > Jens Axboe <jens.axboe@oracle.com> wrote:
> > > > 
> > > > > On Wed, Oct 17 2007, David Miller wrote:
> > > > > > I would suggest that other sg_last() uses be audited for the same bug.
> > > > > 
> > > > > Agree.
> > > > 
> > > > Only libata, I think.
> > > 
> > > There are a few other spots, like ide-scsi
> > 
> > Oops, I missed that. But seems that we have only three, ide-scsi,
> > libata, sparc64 iommu.
> 
> And now only ide-scsi and libata, Dave killed sg_last() in sparc64
> already. So less than I remember, I'd say kill it NOW...

libata remains.

diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index bd74f6c..fa7ba64 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -70,7 +70,7 @@ typedef struct idescsi_pc_s {
 	u8 *buffer;				/* Data buffer */
 	u8 *current_position;			/* Pointer into the above buffer */
 	struct scatterlist *sg;			/* Scatter gather table */
-	struct scatterlist *last_sg;		/* Last sg element */
+	unsigned int sg_cnt;			/* Number of entries in sg */
 	int b_count;				/* Bytes transferred from current entry */
 	struct scsi_cmnd *scsi_cmd;		/* SCSI command */
 	void (*done)(struct scsi_cmnd *);	/* Scsi completion routine */
@@ -192,7 +192,7 @@ static void idescsi_input_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsigne
 		}
 		bcount -= count; pc->b_count += count;
 		if (pc->b_count == pc->sg->length) {
-			if (pc->sg == pc->last_sg)
+			if (!--pc->sg_cnt)
 				break;
 			pc->sg = sg_next(pc->sg);
 			pc->b_count = 0;
@@ -229,7 +229,7 @@ static void idescsi_output_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsign
 		}
 		bcount -= count; pc->b_count += count;
 		if (pc->b_count == pc->sg->length) {
-			if (pc->sg == pc->last_sg)
+			if (!--pc->sg_cnt)
 				break;
 			pc->sg = sg_next(pc->sg);
 			pc->b_count = 0;
@@ -807,7 +807,7 @@ static int idescsi_queue (struct scsi_cmnd *cmd,
 	memcpy (pc->c, cmd->cmnd, cmd->cmd_len);
 	pc->buffer = NULL;
 	pc->sg = scsi_sglist(cmd);
-	pc->last_sg = sg_last(pc->sg, scsi_sg_count(cmd));
+	pc->sg_cnt = scsi_sg_count(cmd);
 	pc->b_count = 0;
 	pc->request_transfer = pc->buffer_size = scsi_bufflen(cmd);
 	pc->scsi_cmd = cmd;

-- 
Jens Axboe


  reply	other threads:[~2007-10-17 11:16 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-17  5:07 [PATCH] SPARC64: fix iommu sg chaining FUJITA Tomonori
2007-10-17  7:21 ` Jens Axboe
2007-10-17  8:33   ` David Miller
2007-10-17  8:42     ` David Miller
2007-10-17  8:45       ` Jens Axboe
2007-10-17  9:13         ` David Miller
2007-10-17  9:16           ` Jens Axboe
2007-10-17  9:24             ` FUJITA Tomonori
2007-10-17  9:27               ` Jens Axboe
2007-10-17  9:45               ` David Miller
2007-10-17 11:08                 ` FUJITA Tomonori
2007-10-17 11:13                   ` Jens Axboe
2007-10-17 11:16                     ` Jens Axboe [this message]
2007-10-17 10:54             ` David Miller
2007-10-17 10:58               ` Jens Axboe
2007-10-17 11:01                 ` Jens Axboe
2007-10-17 11:10                   ` David Miller
2007-10-17 11:11                     ` Jens Axboe
2007-10-17 11:18                       ` David Miller
2007-10-17 11:27                         ` Jens Axboe
2007-10-17 11:37                   ` FUJITA Tomonori
2007-10-17 11:41                     ` Jens Axboe
2007-10-17 11:57                       ` FUJITA Tomonori
2007-10-17 12:05                         ` FUJITA Tomonori
2007-10-17 14:36                           ` Jens Axboe
2007-10-17 23:01                     ` FUJITA Tomonori
2007-10-17 11:04                 ` David Miller
2007-10-17 11:04                   ` Jens Axboe
2007-10-17 11:04                 ` FUJITA Tomonori

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=20071017111600.GY5043@kernel.dk \
    --to=jens.axboe@oracle.com \
    --cc=davem@davemloft.net \
    --cc=fujita.tomonori@lab.ntt.co.jp \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    /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