linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/1] block: blk-merge: don't merge the pages with non-contiguous descriptors
@ 2013-01-15 16:01 Subhash Jadavani
  2013-01-15 16:19 ` James Bottomley
  0 siblings, 1 reply; 17+ messages in thread
From: Subhash Jadavani @ 2013-01-15 16:01 UTC (permalink / raw)
  To: linux-kernel, linux-scsi; +Cc: linux-mmc, linux-arm-msm, Subhash Jadavani

blk_rq_map_sg() function merges the physically contiguous pages to use same
scatter-gather node without checking if their page descriptors are
contiguous or not.

Now when dma_map_sg() is called on the scatter gather list, it would
take the base page pointer from each node (one by one) and iterates
through all of the pages in same sg node by keep incrementing the base
page pointer with the assumption that physically contiguous pages will
have their page descriptor address contiguous which may not be true
if SPARSEMEM config is enabled. So here we may end referring to invalid
page descriptor.

Following table shows the example of physically contiguous pages but
their page descriptor addresses non-contiguous.
-------------------------------------------
| Page Descriptor    |   Physical Address |
------------------------------------------
| 0xc1e43fdc         |   0xdffff000       |
| 0xc2052000         |   0xe0000000       |
-------------------------------------------

With this patch, relevant blk-merge functions will also check if the
physically contiguous pages are having page descriptors address contiguous
or not? If not then, these pages are separated to be in different
scatter-gather nodes.

Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
---
 block/blk-merge.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/block/blk-merge.c b/block/blk-merge.c
index 936a110..6eaef3d4 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -42,6 +42,9 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q,
 					goto new_segment;
 				if (!BIOVEC_SEG_BOUNDARY(q, bvprv, bv))
 					goto new_segment;
+				if ((bvprv->bv_page != bv->bv_page) &&
+				    (bvprv->bv_page + 1) != bv->bv_page)
+					goto new_segment;
 
 				seg_size += bv->bv_len;
 				bvprv = bv;
@@ -126,6 +129,9 @@ __blk_segment_map_sg(struct request_queue *q, struct bio_vec *bvec,
 			goto new_segment;
 		if (!BIOVEC_SEG_BOUNDARY(q, *bvprv, bvec))
 			goto new_segment;
+		if (((*bvprv)->bv_page != bvec->bv_page) &&
+		    (((*bvprv)->bv_page + 1) != bvec->bv_page))
+			goto new_segment;
 
 		(*sg)->length += nbytes;
 	} else {
-- 
--
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation


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

end of thread, other threads:[~2013-01-17 14:58 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-15 16:01 [PATCH v2 1/1] block: blk-merge: don't merge the pages with non-contiguous descriptors Subhash Jadavani
2013-01-15 16:19 ` James Bottomley
2013-01-16  6:37   ` Subhash Jadavani
2013-01-16  9:25     ` James Bottomley
2013-01-16 10:32     ` James Bottomley
2013-01-16 12:39       ` Subhash Jadavani
2013-01-16 23:14       ` Russell King - ARM Linux
2013-01-17  8:54         ` James Bottomley
2013-01-16 23:18       ` Tejun Heo
2013-01-17  9:11         ` James Bottomley
2013-01-17 10:37           ` Russell King - ARM Linux
2013-01-17 10:47             ` Russell King - ARM Linux
2013-01-17 11:01               ` James Bottomley
2013-01-17 11:04                 ` Russell King - ARM Linux
2013-01-17 11:19                   ` James Bottomley
2013-01-17 11:40                     ` Russell King - ARM Linux
2013-01-17 14:58               ` Subhash Jadavani

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).