Mercurial > illumos > illumos-gate
changeset 13364:b600b8d927a8
696 Incorrect check dma_attr_sgllen <= 0 in rootnex_valid_alloc_parms
Reviewed by: Dan McDonald <danmcd@nexenta.com>
Reviewed by: Gordon Ross <gwr@nexenta.com>
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Reviewed by: Albert Lee <trisk@nexenta.com>
Approved by: Albert Lee <trisk@nexenta.com>
author | Garrett D'Amore <garrett@nexenta.com> |
---|---|
date | Sun, 08 May 2011 09:02:29 -0700 |
parents | ef9e6008c21c |
children | b868f9d61081 |
files | usr/src/uts/i86pc/io/rootnex.c |
diffstat | 1 files changed, 12 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/uts/i86pc/io/rootnex.c Fri May 06 10:04:21 2011 -0700 +++ b/usr/src/uts/i86pc/io/rootnex.c Sun May 08 09:02:29 2011 -0700 @@ -2169,9 +2169,14 @@ * all of memory, shouldn't try to bind more than it can transfer, and * the buffer shouldn't require more cookies than the driver/device can * handle [sgllen]). + * + * Note that negative values of dma_attr_sgllen are supposed + * to mean unlimited, but we just cast them to mean a + * "ridiculous large limit". This saves some extra checks on + * hot paths. */ if ((sinfo->si_copybuf_req == 0) && - (sinfo->si_sgl_size <= attr->dma_attr_sgllen) && + (sinfo->si_sgl_size <= (unsigned)attr->dma_attr_sgllen) && (dmao->dmao_size < dma->dp_maxxfer)) { fast: /* @@ -2699,7 +2704,7 @@ if ((attr->dma_attr_seg & MMU_PAGEOFFSET) != MMU_PAGEOFFSET || MMU_PAGESIZE & (attr->dma_attr_granular - 1) || - attr->dma_attr_sgllen <= 0) { + attr->dma_attr_sgllen == 0) { return (DDI_DMA_BADATTR); } @@ -3292,7 +3297,7 @@ */ if ((dma->dp_copybuf_size < sinfo->si_copybuf_req) || (dmao->dmao_size > dma->dp_maxxfer) || - (attr->dma_attr_sgllen < sinfo->si_sgl_size)) { + ((unsigned)attr->dma_attr_sgllen < sinfo->si_sgl_size)) { dma->dp_partial_required = B_TRUE; if (attr->dma_attr_granular != 1) { dma->dp_trim_required = B_TRUE; @@ -3388,7 +3393,8 @@ dma->dp_dip); /* if the cookie cnt == max sgllen, move to the next window */ - } else if (window->wd_cookie_cnt >= attr->dma_attr_sgllen) { + } else if (window->wd_cookie_cnt >= + (unsigned)attr->dma_attr_sgllen) { partial = B_TRUE; ASSERT(window->wd_cookie_cnt == attr->dma_attr_sgllen); e = rootnex_sgllen_window_boundary(hp, dma, &window, @@ -3532,11 +3538,7 @@ */ lattr = *attr; lattr.dma_attr_align = MMU_PAGESIZE; - /* - * this should be < 0 to indicate no limit, but due to a bug in - * the rootnex, we'll set it to the maximum positive int. - */ - lattr.dma_attr_sgllen = 0x7fffffff; + lattr.dma_attr_sgllen = -1; /* no limit */ /* * if we're using the copy buffer because of seg, use that for our * upper address limit. @@ -3625,7 +3627,7 @@ * be (cookie count / cookies count H/W supports minus 1[for * trim]) plus one for remainder. */ - if (attr->dma_attr_sgllen < sinfo->si_sgl_size) { + if ((unsigned)attr->dma_attr_sgllen < sinfo->si_sgl_size) { sglwin = (sinfo->si_sgl_size / (attr->dma_attr_sgllen - 1)) + 1; } else {