Changeset View
Changeset View
Standalone View
Standalone View
sys/compat/linuxkpi/common/include/linux/scatterlist.h
Show First 20 Lines • Show All 373 Lines • ▼ Show 20 Lines | #endif | ||||
if (__predict_false((rc = sg_alloc_table(sgt, segs, gfp_mask)))) | if (__predict_false((rc = sg_alloc_table(sgt, segs, gfp_mask)))) | ||||
#if defined(LINUXKPI_VERSION) && LINUXKPI_VERSION >= 51300 | #if defined(LINUXKPI_VERSION) && LINUXKPI_VERSION >= 51300 | ||||
return (ERR_PTR(rc)); | return (ERR_PTR(rc)); | ||||
#else | #else | ||||
return (rc); | return (rc); | ||||
#endif | #endif | ||||
cur = 0; | cur = 0; | ||||
for (i = 0, s = sgt->sgl; i < sgt->orig_nents; i++) { | for (i = 0, s = sgt->sgl; i < sgt->orig_nents; i++) { | ||||
bz: I wonder at the same time why we switched from using for_each_sg() in first place as that would… | |||||
ashafer_badland.ioAuthorUnsubmitted Not Done Inline ActionsI think the intention was to add a check of the value of s, but I thought it looked doable to do that while still using for_each_sg(). I'm not 100% sure either. ashafer_badland.io: I think the intention was to add a check of the value of s, but I thought it looked doable to… | |||||
unsigned long seg_size; | unsigned long seg_size; | ||||
unsigned int j; | unsigned int j; | ||||
s = sg_next(s); | |||||
len = 0; | len = 0; | ||||
for (j = cur + 1; j < count; ++j) { | for (j = cur + 1; j < count; ++j) { | ||||
len += PAGE_SIZE; | len += PAGE_SIZE; | ||||
if (len >= max_segment || page_to_pfn(pages[j]) != | if (len >= max_segment || page_to_pfn(pages[j]) != | ||||
page_to_pfn(pages[j - 1]) + 1) | page_to_pfn(pages[j - 1]) + 1) | ||||
break; | break; | ||||
} | } | ||||
seg_size = ((j - cur) << PAGE_SHIFT) - off; | seg_size = ((j - cur) << PAGE_SHIFT) - off; | ||||
sg_set_page(s, pages[cur], MIN(size, seg_size), off); | sg_set_page(s, pages[cur], MIN(size, seg_size), off); | ||||
size -= seg_size; | size -= seg_size; | ||||
off = 0; | off = 0; | ||||
cur = j; | cur = j; | ||||
s = sg_next(s); | |||||
} | } | ||||
KASSERT(s != NULL, ("s is NULL after loop in __sg_alloc_table_from_pages()")); | KASSERT(s != NULL, ("s is NULL after loop in __sg_alloc_table_from_pages()")); | ||||
#if defined(LINUXKPI_VERSION) && LINUXKPI_VERSION >= 51300 | #if defined(LINUXKPI_VERSION) && LINUXKPI_VERSION >= 51300 | ||||
if (left_pages == 0) | if (left_pages == 0) | ||||
sg_mark_end(s); | sg_mark_end(s); | ||||
return (s); | return (s); | ||||
▲ Show 20 Lines • Show All 262 Lines • Show Last 20 Lines |
I wonder at the same time why we switched from using for_each_sg() in first place as that would have avoided the problem, but I am probably too tired to see that...