Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F171766706
D59630.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D59630.diff
View Options
diff --git a/sys/compat/linuxkpi/common/include/linux/scatterlist.h b/sys/compat/linuxkpi/common/include/linux/scatterlist.h
--- a/sys/compat/linuxkpi/common/include/linux/scatterlist.h
+++ b/sys/compat/linuxkpi/common/include/linux/scatterlist.h
@@ -50,6 +50,7 @@
unsigned int offset;
unsigned int length;
dma_addr_t dma_address;
+ unsigned int dma_length;
struct bus_dmamap *dma_map; /* FreeBSD specific */
};
@@ -89,13 +90,18 @@
((struct scatterlist *) ((sg)->page_link & ~SG_PAGE_LINK_MASK))
#define sg_dma_address(sg) (sg)->dma_address
+#ifdef CONFIG_NEED_SG_DMA_LENGTH
+#define sg_dma_len(sg) (sg)->dma_length
+#else
#define sg_dma_len(sg) (sg)->length
+#endif
#define for_each_sg_page(sgl, iter, nents, pgoffset) \
for (_sg_iter_init(sgl, iter, nents, pgoffset); \
(iter)->sg; _sg_iter_next(iter))
#define for_each_sg_dma_page(sgl, iter, nents, pgoffset) \
- for_each_sg_page(sgl, &(iter)->base, nents, pgoffset)
+ for (_sg_iter_init(sgl, &(iter)->base, nents, pgoffset); \
+ (iter)->base.sg; _sg_iter_dma_next(&(iter)->base))
#define for_each_sg(sglist, sg, sgmax, iter) \
for (iter = 0, sg = (sglist); iter < (sgmax); iter++, sg = sg_next(sg))
@@ -497,6 +503,27 @@
iter->sg = sg;
}
+static inline void
+_sg_iter_dma_next(struct sg_page_iter *iter)
+{
+ struct scatterlist *sg;
+ unsigned int pgcount;
+
+ sg = iter->sg;
+ pgcount = (sg->offset + sg_dma_len(sg) + PAGE_SIZE - 1) >> PAGE_SHIFT;
+
+ ++iter->sg_pgoffset;
+ while (iter->sg_pgoffset >= pgcount) {
+ iter->sg_pgoffset -= pgcount;
+ sg = sg_next(sg);
+ --iter->maxents;
+ if (sg == NULL || iter->maxents == 0)
+ break;
+ pgcount = (sg->offset + sg_dma_len(sg) + PAGE_SIZE - 1) >> PAGE_SHIFT;
+ }
+ iter->sg = sg;
+}
+
static inline int
sg_page_count(struct scatterlist *sg)
{
diff --git a/sys/compat/linuxkpi/common/src/linux_pci.c b/sys/compat/linuxkpi/common/src/linux_pci.c
--- a/sys/compat/linuxkpi/common/src/linux_pci.c
+++ b/sys/compat/linuxkpi/common/src/linux_pci.c
@@ -2091,6 +2091,7 @@
("More than one segment (nseg=%d)", nseg + 1));
sg_dma_address(sg) = seg.ds_addr;
+ sg->dma_length = sg->length;
}
if ((attrs & DMA_ATTR_SKIP_CPU_SYNC) != 0)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Sep 14, 9:17 AM (18 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38899411
Default Alt Text
D59630.diff (2 KB)
Attached To
Mode
D59630: LinuxKPI: Add dma_length field to struct scatterlist
Attached
Detach File
Event Timeline
Log In to Comment