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 <jens.axboe@oracle.com>
This commit is contained in:
Родитель
18dabf473e
Коммит
d6ec084200
|
@ -5,6 +5,9 @@
|
||||||
#include <asm/types.h>
|
#include <asm/types.h>
|
||||||
|
|
||||||
struct scatterlist {
|
struct scatterlist {
|
||||||
|
#ifdef CONFIG_DEBUG_SG
|
||||||
|
unsigned long sg_magic;
|
||||||
|
#endif
|
||||||
unsigned long page_link;
|
unsigned long page_link;
|
||||||
unsigned int offset;
|
unsigned int offset;
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
#include <asm/types.h>
|
#include <asm/types.h>
|
||||||
|
|
||||||
struct scatterlist {
|
struct scatterlist {
|
||||||
|
#ifdef CONFIG_DEBUG_SG
|
||||||
|
unsigned long sg_magic;
|
||||||
|
#endif
|
||||||
unsigned long page_link;
|
unsigned long page_link;
|
||||||
unsigned int offset; /* buffer offset */
|
unsigned int offset; /* buffer offset */
|
||||||
dma_addr_t dma_address; /* dma address */
|
dma_addr_t dma_address; /* dma address */
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
#include <asm/types.h>
|
#include <asm/types.h>
|
||||||
|
|
||||||
struct scatterlist {
|
struct scatterlist {
|
||||||
|
#ifdef CONFIG_DEBUG_SG
|
||||||
|
unsigned long sg_magic;
|
||||||
|
#endif
|
||||||
unsigned long page_link;
|
unsigned long page_link;
|
||||||
unsigned int offset;
|
unsigned int offset;
|
||||||
dma_addr_t dma_address;
|
dma_addr_t dma_address;
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
#include <linux/mm.h>
|
#include <linux/mm.h>
|
||||||
|
|
||||||
struct scatterlist {
|
struct scatterlist {
|
||||||
|
#ifdef CONFIG_DEBUG_SG
|
||||||
|
unsigned long sg_magic;
|
||||||
|
#endif
|
||||||
unsigned long page_link;
|
unsigned long page_link;
|
||||||
unsigned int offset;
|
unsigned int offset;
|
||||||
dma_addr_t dma_address;
|
dma_addr_t dma_address;
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
#define __ASM_CRIS_SCATTERLIST_H
|
#define __ASM_CRIS_SCATTERLIST_H
|
||||||
|
|
||||||
struct scatterlist {
|
struct scatterlist {
|
||||||
|
#ifdef CONFIG_DEBUG_SG
|
||||||
|
unsigned long sg_magic;
|
||||||
|
#endif
|
||||||
char * address; /* Location data is to be transferred to */
|
char * address; /* Location data is to be transferred to */
|
||||||
unsigned int length;
|
unsigned int length;
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,9 @@
|
||||||
* and that's it. There's no excuse for not highmem enabling YOUR driver. /jens
|
* and that's it. There's no excuse for not highmem enabling YOUR driver. /jens
|
||||||
*/
|
*/
|
||||||
struct scatterlist {
|
struct scatterlist {
|
||||||
|
#ifdef CONFIG_DEBUG_SG
|
||||||
|
unsigned long sg_magic;
|
||||||
|
#endif
|
||||||
unsigned long page_link;
|
unsigned long page_link;
|
||||||
unsigned int offset; /* for highmem, page offset */
|
unsigned int offset; /* for highmem, page offset */
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
#include <asm/types.h>
|
#include <asm/types.h>
|
||||||
|
|
||||||
struct scatterlist {
|
struct scatterlist {
|
||||||
|
#ifdef CONFIG_DEBUG_SG
|
||||||
|
unsigned long sg_magic;
|
||||||
|
#endif
|
||||||
unsigned long page_link;
|
unsigned long page_link;
|
||||||
unsigned int offset;
|
unsigned int offset;
|
||||||
dma_addr_t dma_address;
|
dma_addr_t dma_address;
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
#include <asm/types.h>
|
#include <asm/types.h>
|
||||||
|
|
||||||
struct scatterlist {
|
struct scatterlist {
|
||||||
|
#ifdef CONFIG_DEBUG_SG
|
||||||
|
unsigned long sg_magic;
|
||||||
|
#endif
|
||||||
unsigned long page_link;
|
unsigned long page_link;
|
||||||
unsigned int offset;
|
unsigned int offset;
|
||||||
unsigned int length; /* buffer length */
|
unsigned int length; /* buffer length */
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
#include <asm/types.h>
|
#include <asm/types.h>
|
||||||
|
|
||||||
struct scatterlist {
|
struct scatterlist {
|
||||||
|
#ifdef CONFIG_DEBUG_SG
|
||||||
|
unsigned long sg_magic;
|
||||||
|
#endif
|
||||||
char * address; /* Location data is to be transferred to, NULL for
|
char * address; /* Location data is to be transferred to, NULL for
|
||||||
* highmem page */
|
* highmem page */
|
||||||
unsigned long page_link;
|
unsigned long page_link;
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
|
|
||||||
struct scatterlist {
|
struct scatterlist {
|
||||||
|
#ifdef CONFIG_DEBUG_SG
|
||||||
|
unsigned long sg_magic;
|
||||||
|
#endif
|
||||||
unsigned long page_link;
|
unsigned long page_link;
|
||||||
unsigned int offset;
|
unsigned int offset;
|
||||||
unsigned int length;
|
unsigned int length;
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
#include <asm/types.h>
|
#include <asm/types.h>
|
||||||
|
|
||||||
struct scatterlist {
|
struct scatterlist {
|
||||||
|
#ifdef CONFIG_DEBUG_SG
|
||||||
|
unsigned long sg_magic;
|
||||||
|
#endif
|
||||||
unsigned long page_link;
|
unsigned long page_link;
|
||||||
unsigned int offset;
|
unsigned int offset;
|
||||||
dma_addr_t dma_address;
|
dma_addr_t dma_address;
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
#include <asm/types.h>
|
#include <asm/types.h>
|
||||||
|
|
||||||
struct scatterlist {
|
struct scatterlist {
|
||||||
|
#ifdef CONFIG_DEBUG_SG
|
||||||
|
unsigned long sg_magic;
|
||||||
|
#endif
|
||||||
unsigned long page_link;
|
unsigned long page_link;
|
||||||
unsigned int offset;
|
unsigned int offset;
|
||||||
dma_addr_t dma_address;
|
dma_addr_t dma_address;
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
#include <asm/types.h>
|
#include <asm/types.h>
|
||||||
|
|
||||||
struct scatterlist {
|
struct scatterlist {
|
||||||
|
#ifdef CONFIG_DEBUG_SG
|
||||||
|
unsigned long sg_magic;
|
||||||
|
#endif
|
||||||
unsigned long page_link;
|
unsigned long page_link;
|
||||||
unsigned int offset;
|
unsigned int offset;
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,9 @@
|
||||||
#include <asm/dma.h>
|
#include <asm/dma.h>
|
||||||
|
|
||||||
struct scatterlist {
|
struct scatterlist {
|
||||||
|
#ifdef CONFIG_DEBUG_SG
|
||||||
|
unsigned long sg_magic;
|
||||||
|
#endif
|
||||||
unsigned long page_link;
|
unsigned long page_link;
|
||||||
unsigned int offset;
|
unsigned int offset;
|
||||||
unsigned int length;
|
unsigned int length;
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
#define _ASMS390_SCATTERLIST_H
|
#define _ASMS390_SCATTERLIST_H
|
||||||
|
|
||||||
struct scatterlist {
|
struct scatterlist {
|
||||||
|
#ifdef CONFIG_DEBUG_SG
|
||||||
|
unsigned long sg_magic;
|
||||||
|
#endif
|
||||||
unsigned long page_link;
|
unsigned long page_link;
|
||||||
unsigned int offset;
|
unsigned int offset;
|
||||||
unsigned int length;
|
unsigned int length;
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
#include <asm/types.h>
|
#include <asm/types.h>
|
||||||
|
|
||||||
struct scatterlist {
|
struct scatterlist {
|
||||||
|
#ifdef CONFIG_DEBUG_SG
|
||||||
|
unsigned long sg_magic;
|
||||||
|
#endif
|
||||||
unsigned long page_link;
|
unsigned long page_link;
|
||||||
unsigned int offset;/* for highmem, page offset */
|
unsigned int offset;/* for highmem, page offset */
|
||||||
dma_addr_t dma_address;
|
dma_addr_t dma_address;
|
||||||
|
|
|
@ -14,6 +14,9 @@
|
||||||
#include <asm/types.h>
|
#include <asm/types.h>
|
||||||
|
|
||||||
struct scatterlist {
|
struct scatterlist {
|
||||||
|
#ifdef CONFIG_DEBUG_SG
|
||||||
|
unsigned long sg_magic;
|
||||||
|
#endif
|
||||||
unsigned long page_link;
|
unsigned long page_link;
|
||||||
unsigned int offset;/* for highmem, page offset */
|
unsigned int offset;/* for highmem, page offset */
|
||||||
dma_addr_t dma_address;
|
dma_addr_t dma_address;
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
|
|
||||||
struct scatterlist {
|
struct scatterlist {
|
||||||
|
#ifdef CONFIG_DEBUG_SG
|
||||||
|
unsigned long sg_magic;
|
||||||
|
#endif
|
||||||
unsigned long page_link;
|
unsigned long page_link;
|
||||||
unsigned int offset;
|
unsigned int offset;
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,9 @@
|
||||||
#include <asm/types.h>
|
#include <asm/types.h>
|
||||||
|
|
||||||
struct scatterlist {
|
struct scatterlist {
|
||||||
|
#ifdef CONFIG_DEBUG_SG
|
||||||
|
unsigned long sg_magic;
|
||||||
|
#endif
|
||||||
unsigned long page_link;
|
unsigned long page_link;
|
||||||
unsigned int offset;
|
unsigned int offset;
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,9 @@
|
||||||
#include <asm/types.h>
|
#include <asm/types.h>
|
||||||
|
|
||||||
struct scatterlist {
|
struct scatterlist {
|
||||||
|
#ifdef CONFIG_DEBUG_SG
|
||||||
|
unsigned long sg_magic;
|
||||||
|
#endif
|
||||||
unsigned long page_link;
|
unsigned long page_link;
|
||||||
unsigned offset;
|
unsigned offset;
|
||||||
dma_addr_t dma_address;
|
dma_addr_t dma_address;
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
#include <asm/types.h>
|
#include <asm/types.h>
|
||||||
|
|
||||||
struct scatterlist {
|
struct scatterlist {
|
||||||
|
#ifdef CONFIG_DEBUG_SG
|
||||||
|
unsigned long sg_magic;
|
||||||
|
#endif
|
||||||
unsigned long page_link;
|
unsigned long page_link;
|
||||||
unsigned int offset;
|
unsigned int offset;
|
||||||
dma_addr_t dma_address;
|
dma_addr_t dma_address;
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
#include <asm/types.h>
|
#include <asm/types.h>
|
||||||
|
|
||||||
struct scatterlist {
|
struct scatterlist {
|
||||||
|
#ifdef CONFIG_DEBUG_SG
|
||||||
|
unsigned long sg_magic;
|
||||||
|
#endif
|
||||||
unsigned long page_link;
|
unsigned long page_link;
|
||||||
unsigned int offset;
|
unsigned int offset;
|
||||||
unsigned int length;
|
unsigned int length;
|
||||||
|
|
|
@ -14,6 +14,9 @@
|
||||||
#include <asm/types.h>
|
#include <asm/types.h>
|
||||||
|
|
||||||
struct scatterlist {
|
struct scatterlist {
|
||||||
|
#ifdef CONFIG_DEBUG_SG
|
||||||
|
unsigned long sg_magic;
|
||||||
|
#endif
|
||||||
unsigned long page_link;
|
unsigned long page_link;
|
||||||
unsigned int offset;
|
unsigned int offset;
|
||||||
dma_addr_t dma_address;
|
dma_addr_t dma_address;
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define SG_MAGIC 0x87654321
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sg_set_page - Set sg entry to point at given page
|
* sg_set_page - Set sg entry to point at given page
|
||||||
* @sg: SG entry
|
* @sg: SG entry
|
||||||
|
@ -39,6 +41,9 @@ static inline void sg_set_page(struct scatterlist *sg, struct page *page)
|
||||||
{
|
{
|
||||||
unsigned long page_link = sg->page_link & 0x3;
|
unsigned long page_link = sg->page_link & 0x3;
|
||||||
|
|
||||||
|
#ifdef CONFIG_DEBUG_SG
|
||||||
|
BUG_ON(sg->sg_magic != SG_MAGIC);
|
||||||
|
#endif
|
||||||
sg->page_link = page_link | (unsigned long) page;
|
sg->page_link = page_link | (unsigned long) page;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,6 +86,9 @@ static inline void sg_set_buf(struct scatterlist *sg, const void *buf,
|
||||||
**/
|
**/
|
||||||
static inline struct scatterlist *sg_next(struct scatterlist *sg)
|
static inline struct scatterlist *sg_next(struct scatterlist *sg)
|
||||||
{
|
{
|
||||||
|
#ifdef CONFIG_DEBUG_SG
|
||||||
|
BUG_ON(sg->sg_magic != SG_MAGIC);
|
||||||
|
#endif
|
||||||
if (sg_is_last(sg))
|
if (sg_is_last(sg))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -123,6 +131,10 @@ static inline struct scatterlist *sg_last(struct scatterlist *sgl,
|
||||||
for_each_sg(sgl, sg, nents, i)
|
for_each_sg(sgl, sg, nents, i)
|
||||||
ret = sg;
|
ret = sg;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_DEBUG_SG
|
||||||
|
BUG_ON(sgl[0].sg_magic != SG_MAGIC);
|
||||||
|
BUG_ON(!sg_is_last(ret));
|
||||||
#endif
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -180,6 +192,9 @@ static inline void sg_init_one(struct scatterlist *sg, const void *buf,
|
||||||
unsigned int buflen)
|
unsigned int buflen)
|
||||||
{
|
{
|
||||||
memset(sg, 0, sizeof(*sg));
|
memset(sg, 0, sizeof(*sg));
|
||||||
|
#ifdef CONFIG_DEBUG_SG
|
||||||
|
sg->sg_magic = SG_MAGIC;
|
||||||
|
#endif
|
||||||
sg_mark_end(sg, 1);
|
sg_mark_end(sg, 1);
|
||||||
sg_set_buf(sg, buf, buflen);
|
sg_set_buf(sg, buf, buflen);
|
||||||
}
|
}
|
||||||
|
@ -198,6 +213,13 @@ static inline void sg_init_table(struct scatterlist *sgl, unsigned int nents)
|
||||||
{
|
{
|
||||||
memset(sgl, 0, sizeof(*sgl) * nents);
|
memset(sgl, 0, sizeof(*sgl) * nents);
|
||||||
sg_mark_end(sgl, nents);
|
sg_mark_end(sgl, nents);
|
||||||
|
#ifdef CONFIG_DEBUG_SG
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < nents; i++)
|
||||||
|
sgl[i].sg_magic = SG_MAGIC;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -389,6 +389,16 @@ config DEBUG_LIST
|
||||||
|
|
||||||
If unsure, say N.
|
If unsure, say N.
|
||||||
|
|
||||||
|
config DEBUG_SG
|
||||||
|
bool "Debug SG table operations"
|
||||||
|
depends on DEBUG_KERNEL
|
||||||
|
help
|
||||||
|
Enable this to turn on checks on scatter-gather tables. This can
|
||||||
|
help find problems with drivers that do not properly initialize
|
||||||
|
their sg tables.
|
||||||
|
|
||||||
|
If unsure, say N.
|
||||||
|
|
||||||
config FRAME_POINTER
|
config FRAME_POINTER
|
||||||
bool "Compile the kernel with frame pointers"
|
bool "Compile the kernel with frame pointers"
|
||||||
depends on DEBUG_KERNEL && (X86 || CRIS || M68K || M68KNOMMU || FRV || UML || S390 || AVR32 || SUPERH || BFIN)
|
depends on DEBUG_KERNEL && (X86 || CRIS || M68K || M68KNOMMU || FRV || UML || S390 || AVR32 || SUPERH || BFIN)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче