linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <htejun@gmail.com>
To: jeff@garzik.org, linux-ide@vger.kernel.org,
	jens.axboe@oracle.com, linux-scsi@vger.kernel.org,
	fujita.tomonori@lab.ntt.co.jp, akpm@linux-foundation.org
Cc: Tejun Heo <htejun@gmail.com>,
	James Bottomley <James.Bottomley@HansenPartnership.com>
Subject: [PATCH 2/7] block: update bio according to DMA alignment padding
Date: Sat,  9 Feb 2008 10:40:21 +0900	[thread overview]
Message-ID: <12025212271469-git-send-email-htejun@gmail.com> (raw)
In-Reply-To: <12025212262892-git-send-email-htejun@gmail.com>

DMA start address and transfer size alignment for PC requests are
achieved using bio_copy_user() instead of bio_map_user().  This works
because bio_copy_user() always uses full pages and block DMA alignment
isn't allowed to go over PAGE_SIZE.

However, the implementation didn't update the last bio of the request
to make this padding visible to lower layers.  This patch makes
blk_rq_map_user() extend the last bio such that it includes the
padding area and the size of area pointed to by the request is
properly aligned.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
---
 block/blk-map.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/block/blk-map.c b/block/blk-map.c
index 955d75c..103b1df 100644
--- a/block/blk-map.c
+++ b/block/blk-map.c
@@ -139,6 +139,23 @@ int blk_rq_map_user(struct request_queue *q, struct request *rq,
 		ubuf += ret;
 	}
 
+	/*
+	 * __blk_rq_map_user() copies the buffers if starting address
+	 * or length isn't aligned.  As the copied buffer is always
+	 * page aligned, we know that there's enough room for padding.
+	 * Extend the last bio and update rq->data_len accordingly.
+	 *
+	 * On unmap, bio_uncopy_user() will use unmodified
+	 * bio_map_data pointed to by bio->bi_private.
+	 */
+	if (len & queue_dma_alignment(q)) {
+		unsigned int pad_len = (queue_dma_alignment(q) & ~len) + 1;
+		struct bio *bio = rq->biotail;
+
+		bio->bi_io_vec[bio->bi_vcnt - 1].bv_len += pad_len;
+		bio->bi_size += pad_len;
+	}
+
 	rq->buffer = rq->data = NULL;
 	return 0;
 unmap_rq:
-- 
1.5.2.4


  parent reply	other threads:[~2008-02-09  1:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-09  1:40 [PATCHSET #upstream] block/libata: update and use block layer padding and draining, take 2 Tejun Heo
2008-02-09  1:40 ` [PATCH 1/7] libata: update ATAPI overflow draining Tejun Heo
2008-02-09  1:40 ` Tejun Heo [this message]
2008-02-09  1:40 ` [PATCH 3/7] block: add request->raw_data_len Tejun Heo
2008-02-09  1:40 ` [PATCH 4/7] block: implement request_queue->dma_drain_needed Tejun Heo
2008-02-09  1:40 ` [PATCH 5/7] block: clear drain buffer if draining for write command Tejun Heo
2008-02-11 23:14   ` James Bottomley
2008-02-09  1:40 ` [PATCH 6/7] libata: eliminate the home grown dma padding in favour of that provided by the block layer Tejun Heo
2008-02-09  1:40 ` [PATCH 7/7] libata: implement drain buffers Tejun Heo

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=12025212271469-git-send-email-htejun@gmail.com \
    --to=htejun@gmail.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=akpm@linux-foundation.org \
    --cc=fujita.tomonori@lab.ntt.co.jp \
    --cc=jeff@garzik.org \
    --cc=jens.axboe@oracle.com \
    --cc=linux-ide@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;
as well as URLs for NNTP newsgroup(s).