[RTEMS Project] #3029: PCI libary hard configured for auto-configuration code failure
RTEMS trac
trac at rtems.org
Thu Jun 1 18:33:59 UTC 2017
#3029: PCI libary hard configured for auto-configuration code failure
--------------------------+-----------------------------
Reporter: Jeffrey Hill | Owner: joel.sherrill@…
Type: defect | Status: new
Priority: normal | Milestone:
Component: cpukit | Version: 4.11
Severity: normal | Keywords: PCI
--------------------------+-----------------------------
Executine Summary:
1) The PCI_CFG_AUTO_LIB macro needs to be defined in both "pci_cfg_auto.c"
and also "pci_dev_create.c" otherwise the "pci_bus" structure is allocated
too small in size in "pci_dev_create.c". Currently, PCI_CFG_AUTO_LIB is
set only within "pci_cfg_auto.c" and therefore it sees random values in
field "busres" of "struct pci_bus".
2) I can identify two potential issues with the PCI library documentation.
See below.
After some quality time in the debugger the user discovers the following
code in "pci/cfg.h".
{{{
struct pci_bus {
struct pci_dev dev; /* PCI Bridge */
struct pci_dev *devs; /* Devices on child (secondary) Bus */
unsigned int flags;
/* Bridge Information */
int num; /* Bus number (0=Root-PCI-bus) */
int pri; /* Primary Bus Number */
int sord; /* Subordinate Buses (Child bus count) */
#if defined(PCI_CFG_AUTO_LIB)
/* Resources of devices on bus. USED INTERNALLY IN AUTO-CFG
LIBRARY.
*
* BUS_RES_IO = 0: I/O resources
* BUS_RES_MEMIO = 1: Prefetchable memory resources
* BUS_RES_MEM = 2: Non-Prefetchable memory resources
*/
struct pci_res *busres[3];
#endif
};
}}}
And the following in "pci_dev_create.c" which explains why the PCI auto
configuration code crashes using random values in the "busres" field.
{{{
struct pci_dev *pci_dev_create(int isbus)
{
void *ptr;
int size;
if (isbus)
size = sizeof(struct pci_bus);
else
size = sizeof(struct pci_dev);
ptr = malloc(size);
if (!ptr)
rtems_fatal_error_occurred(RTEMS_NO_MEMORY);
memset(ptr, 0, size);
return ptr;
}
}}}
Furthermore, I had to modify the following in the cpukit configure.ac to
build the PCI library for architecture nios2, but perhaps this should be
accomplished in some other way by configuring the rtems build or by
specifying options in the BSP, but its unclear, at least to me, how that
might be done. So perhaps there is a nit against the documentation on this
point.
{{{
# Filter libpci to only build for architectures that have support for it
AC_MSG_CHECKING([whether CPU supports libpci])
case $RTEMS_CPU in
sparc | nios2)
HAVE_LIBPCI=yes ;;
*)
HAVE_LIBPCI=no ;;
esac
AM_CONDITIONAL(LIBPCI,[test x"$HAVE_LIBPCI" = x"yes"])
AC_MSG_RESULT([$HAVE_LIBPCI])
# Filter libdrvmgr to only build for architectures that have support for
it
AC_MSG_CHECKING([whether CPU supports libdrvmgr])
case $RTEMS_CPU in
sparc | nios2)
HAVE_LIBDRVMGR=yes ;;
*)
HAVE_LIBDRVMGR=no ;;
esac
AM_CONDITIONAL(LIBDRVMGR,[test x"$HAVE_LIBDRVMGR" = x"yes"])
AC_MSG_RESULT([$HAVE_LIBDRVMGR])
}}}
Furthermore, it was necessary to add some code like this to the
application, but perhaps the documentation could be updated to indicate
that this is required, or if not how it might be configured to run auto-
magically.
{{{
# if defined ( RTEMS_PCI_CONFIG_LIB )
if ( pci_config_init () ) {
printk ( "PCI Configuration Failed\n" );
}
# endif
}}}
--
Ticket URL: <http://devel.rtems.org/ticket/3029>
RTEMS Project <http://www.rtems.org/>
RTEMS Project
More information about the bugs
mailing list