mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-04-13 10:37:29 +07:00
lib/scatterlist: Add SG_CHAIN and SG_END macros for LSB encodings
This replaces scatterlist->page_link LSB encodings with SG_CHAIN and SG_END definitions without any functional change. Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
468f098734
commit
723fbf563a
@ -65,16 +65,18 @@ struct sg_table {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define SG_MAGIC 0x87654321
|
#define SG_MAGIC 0x87654321
|
||||||
|
#define SG_CHAIN 0x01UL
|
||||||
|
#define SG_END 0x02UL
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We overload the LSB of the page pointer to indicate whether it's
|
* We overload the LSB of the page pointer to indicate whether it's
|
||||||
* a valid sg entry, or whether it points to the start of a new scatterlist.
|
* a valid sg entry, or whether it points to the start of a new scatterlist.
|
||||||
* Those low bits are there for everyone! (thanks mason :-)
|
* Those low bits are there for everyone! (thanks mason :-)
|
||||||
*/
|
*/
|
||||||
#define sg_is_chain(sg) ((sg)->page_link & 0x01)
|
#define sg_is_chain(sg) ((sg)->page_link & SG_CHAIN)
|
||||||
#define sg_is_last(sg) ((sg)->page_link & 0x02)
|
#define sg_is_last(sg) ((sg)->page_link & SG_END)
|
||||||
#define sg_chain_ptr(sg) \
|
#define sg_chain_ptr(sg) \
|
||||||
((struct scatterlist *) ((sg)->page_link & ~0x03))
|
((struct scatterlist *) ((sg)->page_link & ~(SG_CHAIN | SG_END)))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sg_assign_page - Assign a given page to an SG entry
|
* sg_assign_page - Assign a given page to an SG entry
|
||||||
@ -88,13 +90,13 @@ struct sg_table {
|
|||||||
**/
|
**/
|
||||||
static inline void sg_assign_page(struct scatterlist *sg, struct page *page)
|
static inline void sg_assign_page(struct scatterlist *sg, struct page *page)
|
||||||
{
|
{
|
||||||
unsigned long page_link = sg->page_link & 0x3;
|
unsigned long page_link = sg->page_link & (SG_CHAIN | SG_END);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* In order for the low bit stealing approach to work, pages
|
* In order for the low bit stealing approach to work, pages
|
||||||
* must be aligned at a 32-bit boundary as a minimum.
|
* must be aligned at a 32-bit boundary as a minimum.
|
||||||
*/
|
*/
|
||||||
BUG_ON((unsigned long) page & 0x03);
|
BUG_ON((unsigned long) page & (SG_CHAIN | SG_END));
|
||||||
#ifdef CONFIG_DEBUG_SG
|
#ifdef CONFIG_DEBUG_SG
|
||||||
BUG_ON(sg->sg_magic != SG_MAGIC);
|
BUG_ON(sg->sg_magic != SG_MAGIC);
|
||||||
BUG_ON(sg_is_chain(sg));
|
BUG_ON(sg_is_chain(sg));
|
||||||
@ -130,7 +132,7 @@ static inline struct page *sg_page(struct scatterlist *sg)
|
|||||||
BUG_ON(sg->sg_magic != SG_MAGIC);
|
BUG_ON(sg->sg_magic != SG_MAGIC);
|
||||||
BUG_ON(sg_is_chain(sg));
|
BUG_ON(sg_is_chain(sg));
|
||||||
#endif
|
#endif
|
||||||
return (struct page *)((sg)->page_link & ~0x3);
|
return (struct page *)((sg)->page_link & ~(SG_CHAIN | SG_END));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -178,7 +180,8 @@ static inline void sg_chain(struct scatterlist *prv, unsigned int prv_nents,
|
|||||||
* Set lowest bit to indicate a link pointer, and make sure to clear
|
* Set lowest bit to indicate a link pointer, and make sure to clear
|
||||||
* the termination bit if it happens to be set.
|
* the termination bit if it happens to be set.
|
||||||
*/
|
*/
|
||||||
prv[prv_nents - 1].page_link = ((unsigned long) sgl | 0x01) & ~0x02;
|
prv[prv_nents - 1].page_link = ((unsigned long) sgl | SG_CHAIN)
|
||||||
|
& ~SG_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -198,8 +201,8 @@ static inline void sg_mark_end(struct scatterlist *sg)
|
|||||||
/*
|
/*
|
||||||
* Set termination bit, clear potential chain bit
|
* Set termination bit, clear potential chain bit
|
||||||
*/
|
*/
|
||||||
sg->page_link |= 0x02;
|
sg->page_link |= SG_END;
|
||||||
sg->page_link &= ~0x01;
|
sg->page_link &= ~SG_CHAIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -215,7 +218,7 @@ static inline void sg_unmark_end(struct scatterlist *sg)
|
|||||||
#ifdef CONFIG_DEBUG_SG
|
#ifdef CONFIG_DEBUG_SG
|
||||||
BUG_ON(sg->sg_magic != SG_MAGIC);
|
BUG_ON(sg->sg_magic != SG_MAGIC);
|
||||||
#endif
|
#endif
|
||||||
sg->page_link &= ~0x02;
|
sg->page_link &= ~SG_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user