Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci Fix a bug that SR-IOV's system page size was dou...



details:   https://anonhg.NetBSD.org/src/rev/ebb5fac2b696
branches:  trunk
changeset: 352392:ebb5fac2b696
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Thu Mar 30 08:44:33 2017 +0000

description:
Fix a bug that SR-IOV's system page size was doubled. ffs()'s bit are
numbered starting from 1.

diffstat:

 sys/dev/pci/pci_subr.c |  13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diffs (36 lines):

diff -r 79bf021a8fa7 -r ebb5fac2b696 sys/dev/pci/pci_subr.c
--- a/sys/dev/pci/pci_subr.c    Thu Mar 30 08:43:40 2017 +0000
+++ b/sys/dev/pci/pci_subr.c    Thu Mar 30 08:44:33 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pci_subr.c,v 1.170 2017/03/28 10:30:27 msaitoh Exp $   */
+/*     $NetBSD: pci_subr.c,v 1.171 2017/03/30 08:44:33 msaitoh Exp $   */
 
 /*
  * Copyright (c) 1997 Zubin D. Dittia.  All rights reserved.
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.170 2017/03/28 10:30:27 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.171 2017/03/30 08:44:33 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pci.h"
@@ -3097,11 +3097,14 @@
        printf("    System Page Sizes register: 0x%08x\n", reg);
        printf("      Page Size: ");
        if (reg != 0) {
+               int bitpos = ffs(reg) -1;
+
+               /* Assume only one bit is set. */
 #ifdef _KERNEL
-               format_bytes(buf, sizeof(buf), 1LL << (ffs(reg) + 12));
+               format_bytes(buf, sizeof(buf), 1LL << (bitpos + 12));
 #else
-               humanize_number(buf, sizeof(buf), 1LL << (ffs(reg) + 12), "B",
-                   HN_AUTOSCALE, 0);
+               humanize_number(buf, sizeof(buf), 1LL << (bitpos + 12),
+                   "B", HN_AUTOSCALE, 0);
 #endif
                printf("%s", buf);
        } else {



Home | Main Index | Thread Index | Old Index