From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
To: linux-ide@vger.kernel.org
Cc: Borislav Petkov <petkovbb@gmail.com>,
Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH 18/20] ide-cd: use scatterlists for PIO transfers (non-fs requests)
Date: Mon, 16 Feb 2009 01:15:08 +0100 [thread overview]
Message-ID: <20090216001508.27491.1594.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20090216001309.27491.59759.sendpatchset@localhost.localdomain>
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: [PATCH] ide-cd: use scatterlists for PIO transfers (non-fs requests)
Convert ide-cd to use scatterlists for PIO transfers and get rid of
partial completions (except on error) also for non-fs requests.
Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
drivers/ide/ide-cd.c | 102 +++++++++++++++------------------------------------
1 file changed, 30 insertions(+), 72 deletions(-)
Index: b/drivers/ide/ide-cd.c
===================================================================
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -501,8 +501,10 @@ static int ide_cd_check_ireason(ide_driv
return -1;
}
-static void ide_cd_request_sense_fixup(ide_drive_t *drive, struct request *rq)
+static void ide_cd_request_sense_fixup(ide_drive_t *drive, struct ide_cmd *cmd)
{
+ struct request *rq = cmd->rq;
+
ide_debug_log(IDE_DBG_FUNC, "rq->cmd[0]: 0x%x", rq->cmd[0]);
/*
@@ -510,11 +512,14 @@ static void ide_cd_request_sense_fixup(i
* and some drives don't send them. Sigh.
*/
if (rq->cmd[0] == GPCMD_REQUEST_SENSE &&
- rq->data_len > 0 && rq->data_len <= 5)
- while (rq->data_len > 0) {
- *(u8 *)rq->data++ = 0;
- --rq->data_len;
+ cmd->nleft > 0 && cmd->nleft <= 5) {
+ unsigned int ofs = cmd->nbytes - cmd->nleft;
+
+ while (cmd->nleft > 0) {
+ *((u8 *)rq->data + ofs++) = 0;
+ cmd->nleft--;
}
+ }
}
int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd,
@@ -605,22 +610,11 @@ static void ide_cd_error_cmd(ide_drive_t
ide_complete_rq(drive, 0, nr_bytes);
}
-/*
- * Called from blk_end_request_callback() after the data of the request is
- * completed and before the request itself is completed. By returning value '1',
- * blk_end_request_callback() returns immediately without completing it.
- */
-static int cdrom_newpc_intr_dummy_cb(struct request *rq)
-{
- return 1;
-}
-
static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
{
ide_hwif_t *hwif = drive->hwif;
struct ide_cmd *cmd = &hwif->cmd;
struct request *rq = hwif->rq;
- xfer_func_t *xferfunc;
ide_expiry_t *expiry = NULL;
int dma_error = 0, dma, stat, thislen, uptodate = 0;
int write = (rq_data_dir(rq) == WRITE) ? 1 : 0, rc, nsectors;
@@ -670,7 +664,7 @@ static ide_startstop_t cdrom_newpc_intr(
ide_read_bcount_and_ireason(drive, &len, &ireason);
- thislen = blk_fs_request(rq) ? len : rq->data_len;
+ thislen = blk_fs_request(rq) ? len : cmd->nleft;
if (thislen > len)
thislen = len;
@@ -694,9 +688,9 @@ static ide_startstop_t cdrom_newpc_intr(
uptodate = 0;
}
} else if (!blk_pc_request(rq)) {
- ide_cd_request_sense_fixup(drive, rq);
+ ide_cd_request_sense_fixup(drive, cmd);
/* complain if we still have data left to transfer */
- uptodate = rq->data_len ? 0 : 1;
+ uptodate = cmd->nleft ? 0 : 1;
if (uptodate == 0)
rq->cmd_flags |= REQ_FAILED;
}
@@ -710,35 +704,15 @@ static ide_startstop_t cdrom_newpc_intr(
cmd->last_xfer_len = 0;
- if (ireason == 0) {
- write = 1;
- xferfunc = hwif->tp_ops->output_data;
- } else {
- write = 0;
- xferfunc = hwif->tp_ops->input_data;
- }
-
ide_debug_log(IDE_DBG_PC, "data transfer, rq->cmd_type: 0x%x, "
"ireason: 0x%x",
rq->cmd_type, ireason);
/* transfer data */
while (thislen > 0) {
- u8 *ptr = blk_fs_request(rq) ? NULL : rq->data;
- int blen = rq->data_len;
-
- /* bio backed? */
- if (rq->bio) {
- if (blk_fs_request(rq)) {
- blen = min_t(int, thislen, cmd->nleft);
- } else {
- ptr = bio_data(rq->bio);
- blen = bio_iovec(rq->bio)->bv_len;
- }
- }
+ int blen = min_t(int, thislen, cmd->nleft);
- if ((blk_fs_request(rq) && cmd->nleft == 0) ||
- (blk_fs_request(rq) == 0 && ptr == NULL)) {
+ if (cmd->nleft == 0) {
if (blk_fs_request(rq) && !write)
/*
* If the buffers are full, pipe the rest into
@@ -755,33 +729,12 @@ static ide_startstop_t cdrom_newpc_intr(
break;
}
- if (blen > thislen)
- blen = thislen;
-
- if (blk_fs_request(rq)) {
- ide_pio_bytes(drive, cmd, write, blen);
- cmd->last_xfer_len += blen;
- } else
- xferfunc(drive, NULL, ptr, blen);
+ ide_pio_bytes(drive, cmd, write, blen);
+ cmd->last_xfer_len += blen;
thislen -= blen;
len -= blen;
- if (blk_fs_request(rq) == 0) {
- rq->data_len -= blen;
-
- /*
- * The request can't be completed until DRQ is cleared.
- * So complete the data, but don't complete the request
- * using the dummy function for the callback feature
- * of blk_end_request_callback().
- */
- if (rq->bio)
- blk_end_request_callback(rq, 0, blen,
- cdrom_newpc_intr_dummy_cb);
- else
- rq->data += blen;
- }
if (sense && write == 0)
rq->sense_len += blen;
}
@@ -806,8 +759,7 @@ out_end:
if (blk_pc_request(rq) && rc == 0) {
unsigned int dlen = rq->data_len;
- if (dma)
- rq->data_len = 0;
+ rq->data_len = 0;
if (blk_end_request(rq, 0, dlen))
BUG();
@@ -820,13 +772,14 @@ out_end:
if (blk_fs_request(rq)) {
if (cmd->nleft == 0)
uptodate = 1;
- if (uptodate == 0)
- ide_cd_error_cmd(drive, cmd);
} else {
if (uptodate <= 0 && rq->errors == 0)
rq->errors = -EIO;
}
+ if (uptodate == 0)
+ ide_cd_error_cmd(drive, cmd);
+
/* make sure it's fully ended */
if (blk_pc_request(rq))
nsectors = (rq->data_len + 511) >> 9;
@@ -836,6 +789,12 @@ out_end:
if (nsectors == 0)
nsectors = 1;
+ if (blk_fs_request(rq) == 0) {
+ rq->data_len -= (cmd->nbytes - cmd->nleft);
+ if (uptodate == 0 && (cmd->tf_flags & IDE_TFLAG_WRITE))
+ rq->data_len += cmd->last_xfer_len;
+ }
+
ide_complete_rq(drive, uptodate ? 0 : -EIO, nsectors << 9);
if (sense && rc == 2)
@@ -963,10 +922,9 @@ static ide_startstop_t ide_cd_do_request
cmd.rq = rq;
- if (blk_fs_request(rq)) {
- ide_init_sg_cmd(&cmd, rq->nr_sectors << 9);
- ide_map_sg(drive, &cmd);
- }
+ ide_init_sg_cmd(&cmd,
+ blk_fs_request(rq) ? (rq->nr_sectors << 9) : rq->data_len);
+ ide_map_sg(drive, &cmd);
return ide_issue_pc(drive, &cmd);
out_end:
next prev parent reply other threads:[~2009-02-16 0:13 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-16 0:13 [PATCH 00/20] ide-cd: use scatterlists also for PIO transfers Bartlomiej Zolnierkiewicz
2009-02-16 0:13 ` [PATCH 01/20] ide: add support for arbitrary transfer lengths to ide_pio_bytes() Bartlomiej Zolnierkiewicz
2009-02-16 0:13 ` [PATCH 02/20] ide: use PageHighMem() instead of ifdefs in ide_pio_bytes() Bartlomiej Zolnierkiewicz
2009-02-16 0:13 ` [PATCH 03/20] ide-cd: remove dead URLs Bartlomiej Zolnierkiewicz
2009-02-16 0:13 ` [PATCH 04/20] ide-cd: use ide_end_rq() also for failed non-fs requests Bartlomiej Zolnierkiewicz
2009-02-16 0:13 ` [PATCH 05/20] ide-cd: remove dead code from cdrom_decode_status() Bartlomiej Zolnierkiewicz
2009-02-16 0:13 ` [PATCH 06/20] ide: remove needless ide_dump_status_no_sense() wrapper Bartlomiej Zolnierkiewicz
2009-02-16 0:13 ` [PATCH 07/20] ide-cd: remove no longer needed 'ignore' module parameter Bartlomiej Zolnierkiewicz
2009-02-16 0:14 ` [PATCH 08/20] ide-cd: factor out failed request completion from cdrom_end_request() Bartlomiej Zolnierkiewicz
2009-02-16 0:14 ` [PATCH 09/20] ide-cd: unify ide_cd_do_request() exit paths Bartlomiej Zolnierkiewicz
2009-02-16 0:14 ` [PATCH 10/20] ide-cd: move setting REQ_FAILED flag out from 'end_request' exit path Bartlomiej Zolnierkiewicz
2009-02-16 0:14 ` [PATCH 11/20] ide-cd: unify cdrom_newpc_intr() exit paths Bartlomiej Zolnierkiewicz
2009-02-16 9:25 ` Borislav Petkov
2009-02-16 21:09 ` Bartlomiej Zolnierkiewicz
2009-02-16 0:14 ` [PATCH 12/20] ide-cd: remove cdrom_end_request() Bartlomiej Zolnierkiewicz
2009-02-16 0:14 ` [PATCH 13/20] ide-cd: kill whole failed request in ide_cd_do_request() Bartlomiej Zolnierkiewicz
2009-02-16 0:14 ` [PATCH 14/20] ide-cd: cleanup ide_cd_do_request() Bartlomiej Zolnierkiewicz
2009-02-16 0:14 ` [PATCH 15/20] ide-cd: use scatterlists for PIO transfers (fs requests) Bartlomiej Zolnierkiewicz
2009-02-16 0:14 ` [PATCH 16/20] ide-cd: fix non-SECTOR_SIZE-multiples PIO transfers for fs requests Bartlomiej Zolnierkiewicz
2009-02-16 0:15 ` [PATCH 17/20] ide-cd: merge ide_cd_prepare_rw_request() into cdrom_start_rw() Bartlomiej Zolnierkiewicz
2009-02-16 0:15 ` Bartlomiej Zolnierkiewicz [this message]
2009-02-16 0:15 ` [PATCH 19/20] ide-cd: use common completion path for DMA requests in cdrom_newpc_intr() Bartlomiej Zolnierkiewicz
2009-02-16 0:15 ` [PATCH 20/20] ide-cd: unify transfer padding " Bartlomiej Zolnierkiewicz
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=20090216001508.27491.1594.sendpatchset@localhost.localdomain \
--to=bzolnier@gmail.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=petkovbb@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).