From d85316d3201bfda47efae12ff824ecf68835020e Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Tue, 1 Mar 2016 18:53:29 +0100 Subject: Detect page mask before any kmem operations (locks, softregs, etc.) --- pcilib/pci.c | 6 +++--- pcilib/pci.h | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pcilib/pci.c b/pcilib/pci.c index eaf41ac..6ec8c9d 100644 --- a/pcilib/pci.c +++ b/pcilib/pci.c @@ -131,7 +131,7 @@ pcilib_t *pcilib_open(const char *device, const char *model) { return NULL; } - ctx->page_mask = (uintptr_t)-1; + ctx->page_mask = pcilib_get_page_mask(); if ((model)&&(!strcasecmp(model, "maintenance"))) { ctx->model = strdup("maintenance"); @@ -263,14 +263,14 @@ const pcilib_driver_version_t *pcilib_get_driver_version(pcilib_t *ctx) { const pcilib_board_info_t *pcilib_get_board_info(pcilib_t *ctx) { int ret; - if (ctx->page_mask == (uintptr_t)-1) { + if (!ctx->board_info_ready) { ret = ioctl( ctx->handle, PCIDRIVER_IOC_PCI_INFO, &ctx->board_info ); if (ret) { pcilib_error("PCIDRIVER_IOC_PCI_INFO ioctl have failed"); return NULL; } - ctx->page_mask = pcilib_get_page_mask(); + ctx->board_info_ready = 1; } return &ctx->board_info; diff --git a/pcilib/pci.h b/pcilib/pci.h index 43de485..172a6fc 100644 --- a/pcilib/pci.h +++ b/pcilib/pci.h @@ -46,9 +46,11 @@ typedef struct { struct pcilib_s { int handle; /**< file handle of device */ - - uintptr_t page_mask; /**< Selects bits which define offset within the page */ + pcilib_driver_version_t driver_version; /**< Version reported by the driver */ + + uintptr_t page_mask; /**< Selects bits which define offset within the page */ + int board_info_ready; /**< Flag indicating if board info is already requested and populated */ pcilib_board_info_t board_info; /**< The mandatory information about board as defined by PCI specification */ pcilib_pcie_link_info_t link_info; /**< Infomation about PCIe connection */ char *bar_space[PCILIB_MAX_BARS]; /**< Pointers to the mapped BARs in virtual address space */ -- cgit v1.2.3