[RTEMS Project] #3055: Infinite Loop in PCI Library Auto Bus Enumeration

RTEMS trac trac at rtems.org
Thu Jun 29 00:23:20 UTC 2017


#3055: Infinite Loop in PCI Library Auto Bus Enumeration
--------------------------+-----------------------------
 Reporter:  Jeffrey Hill  |      Owner:  joel.sherrill@…
     Type:  defect        |     Status:  new
 Priority:  normal        |  Milestone:
Component:  cpukit        |    Version:  4.11
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 There are some infinite loops in the PCI Library Auto Bus Enumeration,
 fixed as follows. Also, there is a memory leak at where the pragma
 indicates.
 {{{
 @@ -76,6 +76,7 @@ static void pci_res_insert(struct pci_res **root, struct
 pci_res *res)
          * sorted after resulting boundary - the boundary after
          * the resource.
          */
 +  if ( size ) {
      while (curr && (curr->boundary >= boundary)) {
        if (curr->boundary == boundary) {
          /* Find Resulting boundary of size */
 @@ -97,6 +98,7 @@ static void pci_res_insert(struct pci_res **root, struct
 pci_res *res)
        last = curr;
        curr = curr->next;
      }
 +  }

         if (last == NULL) {
                 /* Insert first in list */
 @@ -106,6 +108,7 @@ static void pci_res_insert(struct pci_res **root,
 struct pci_res *res)
                 last->next = res;
                 res->next = curr;
         }
 +
  }

  #ifdef DEBUG
 @@ -114,9 +117,9 @@ void pci_res_list_print(struct pci_res *root)
         if (root == NULL)
                 return;

 -       printf("RESOURCE LIST:\n");
 +       DBG("RESOURCE LIST:\n");
         while (root) {
 -               printf(" SIZE: 0x%08x, BOUNDARY: 0x%08x\n", root->size,
 +               DBG(" SIZE: 0x%08x, BOUNDARY: 0x%08x\n", root->size,
 root->boundary);
                 root = root->next;
         }
 @@ -182,13 +185,13 @@ static void pci_res_reorder(struct pci_res *root)
                  * and next */
                 hole_size = start_next - start;

 +               /* Detect dead hole */
 +               if (hole_size > 0) {
        /* Find Boundary of START */
        hole_boundary = 1;
        while ((start & hole_boundary) == 0)
          hole_boundary = hole_boundary<<1;

 -               /* Detect dead hole */
 -               if (hole_size > 0) {
                         /* Step through list and try to find a resource
 that
                          * can fit into hole. Take into account hole start
                          * boundary and hole size.
 @@ -509,6 +512,7 @@ static void pci_add_res_bus(struct pci_bus *bus, int
 type)
  {
         int tindex = type - 1;

 +#pragma message ("memory leak likely, second pass through here")
         /* Clear old resources */
         bus->busres[tindex] = NULL;

 @@ -580,7 +584,7 @@ static int pci_add_res_dev(struct pci_dev *dev, void
 *arg)
                 }
         }

 -       /* Normal PCI Device as max 6 BARs and a ROM Bar.
 +       /* Normal PCI Device has max 6 BARs and a ROM Bar.
          * Insert BARs into the sorted resource list.
          */
         for (i = 0; i < DEV_RES_CNT; i++) {
 @@ -621,7 +625,7 @@ static uint32_t pci_alloc_res(struct pci_bus *bus, int
 type,

                 if ((starttmp + res->size - 1) > end) {
                         /* Not enough memory available for this resource
 */
 -                       printk("PCI[%x:%x:%x]: DEV BAR%d (%d): no resource
 "
 +                       DBG("PCI[%x:%x:%x]: DEV BAR%d (%d): no resource "
                                "assigned\n",
                                PCI_DEV_EXPAND(dev->busdevfun),
                                res->bar, res->flags & PCI_RES_TYPE_MASK);
 @@ -725,7 +729,7 @@ static void pci_set_bar(struct pci_dev *dev, int
 residx)
                 tmp = ((res->end-1) & 0xffff0000) | (res->start >> 16);

                 DBG("PCI[%x:%x:%x]: BRIDGE BAR 0x%x: 0x%08x [0x30:
 0x%x]\n",
 -                       PCI_DEV_EXPAND(pcidev), 0x1C, tmp, tmp2);
 +                       PCI_DEV_EXPAND(pcidev), 0x1C, tmp, tmp16);
                 PCI_CFG_W16(pcidev, 0x1C, tmp16);
                 PCI_CFG_W32(pcidev, 0x30, tmp);
         } else if (is_bridge && (res->bar >= BRIDGE_RES_MEMIO)) {
 }}}

--
Ticket URL: <http://devel.rtems.org/ticket/3055>
RTEMS Project <http://www.rtems.org/>
RTEMS Project


More information about the bugs mailing list