From 18dabf473e15850c0dbc8ff13ac1e2806d542c15 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 22 Oct 2007 19:57:20 +0200 Subject: Change table chaining layout Change the page member of the scatterlist structure to be an unsigned long, and encode more stuff in the lower bits: - Bits 0 and 1 zero: this is a normal sg entry. Next sg entry is located at sg + 1. - Bit 0 set: this is a chain entry, the next real entry is at ->page_link with the two low bits masked off. - Bit 1 set: this is the final entry in the sg entry. sg_next() will return NULL when passed such an entry. It's thus important that sg table users use the proper accessors to get and set the page member. Signed-off-by: Jens Axboe --- include/asm-x86/dma-mapping_32.h | 4 ++-- include/asm-x86/scatterlist_32.h | 2 +- include/asm-x86/scatterlist_64.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'include/asm-x86') diff --git a/include/asm-x86/dma-mapping_32.h b/include/asm-x86/dma-mapping_32.h index 6a2d26cb5da..55f01bd9e55 100644 --- a/include/asm-x86/dma-mapping_32.h +++ b/include/asm-x86/dma-mapping_32.h @@ -45,9 +45,9 @@ dma_map_sg(struct device *dev, struct scatterlist *sglist, int nents, WARN_ON(nents == 0 || sglist[0].length == 0); for_each_sg(sglist, sg, nents, i) { - BUG_ON(!sg->page); + BUG_ON(!sg_page(sg)); - sg->dma_address = page_to_phys(sg->page) + sg->offset; + sg->dma_address = sg_phys(sg); } flush_write_buffers(); diff --git a/include/asm-x86/scatterlist_32.h b/include/asm-x86/scatterlist_32.h index bd5164aa8f6..140a5b37fa7 100644 --- a/include/asm-x86/scatterlist_32.h +++ b/include/asm-x86/scatterlist_32.h @@ -4,7 +4,7 @@ #include struct scatterlist { - struct page *page; + unsigned long page_link; unsigned int offset; dma_addr_t dma_address; unsigned int length; diff --git a/include/asm-x86/scatterlist_64.h b/include/asm-x86/scatterlist_64.h index ef3986ba4b7..e3447846e03 100644 --- a/include/asm-x86/scatterlist_64.h +++ b/include/asm-x86/scatterlist_64.h @@ -4,7 +4,7 @@ #include struct scatterlist { - struct page *page; + unsigned long page_link; unsigned int offset; unsigned int length; dma_addr_t dma_address; -- cgit v1.2.3 From d6ec084200c37683278c821338f74ddf21ab80f5 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 22 Oct 2007 20:01:06 +0200 Subject: Add CONFIG_DEBUG_SG sg validation Add a Kconfig entry which will toggle some sanity checks on the sg entry and tables. Signed-off-by: Jens Axboe --- include/asm-x86/scatterlist_32.h | 3 +++ include/asm-x86/scatterlist_64.h | 3 +++ 2 files changed, 6 insertions(+) (limited to 'include/asm-x86') diff --git a/include/asm-x86/scatterlist_32.h b/include/asm-x86/scatterlist_32.h index 140a5b37fa7..0e7d997a34b 100644 --- a/include/asm-x86/scatterlist_32.h +++ b/include/asm-x86/scatterlist_32.h @@ -4,6 +4,9 @@ #include struct scatterlist { +#ifdef CONFIG_DEBUG_SG + unsigned long sg_magic; +#endif unsigned long page_link; unsigned int offset; dma_addr_t dma_address; diff --git a/include/asm-x86/scatterlist_64.h b/include/asm-x86/scatterlist_64.h index e3447846e03..1847c72befe 100644 --- a/include/asm-x86/scatterlist_64.h +++ b/include/asm-x86/scatterlist_64.h @@ -4,6 +4,9 @@ #include struct scatterlist { +#ifdef CONFIG_DEBUG_SG + unsigned long sg_magic; +#endif unsigned long page_link; unsigned int offset; unsigned int length; -- cgit v1.2.3