Commit c03c08d5 authored by Sebastian Sanchez's avatar Sebastian Sanchez Committed by Doug Ledford

IB/hfi1: Check upper-case EFI variables

The EFI variable that provides board ID is named
by the PCI address of the device, which is published
in upper-case, while the HFI1 driver reads the EFI
variable in lower-case.
This prevents returning the correct board id when
queried through sysfs. Read EFI variables in
upper-case if the lower-case read fails.
Reviewed-by: default avatarEaswar Hariharan <easwar.hariharan@intel.com>
Signed-off-by: default avatarSebastian Sanchez <sebastian.sanchez@intel.com>
Signed-off-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 76327627
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
* *
*/ */
#include <linux/ctype.h>
#include "efivar.h" #include "efivar.h"
/* GUID for HFI1 variables in EFI */ /* GUID for HFI1 variables in EFI */
...@@ -150,15 +151,32 @@ static int read_efi_var(const char *name, unsigned long *size, ...@@ -150,15 +151,32 @@ static int read_efi_var(const char *name, unsigned long *size,
int read_hfi1_efi_var(struct hfi1_devdata *dd, const char *kind, int read_hfi1_efi_var(struct hfi1_devdata *dd, const char *kind,
unsigned long *size, void **return_data) unsigned long *size, void **return_data)
{ {
char prefix_name[64];
char name[64]; char name[64];
int result;
int i;
/* create a common prefix */ /* create a common prefix */
snprintf(name, sizeof(name), "%04x:%02x:%02x.%x-%s", snprintf(prefix_name, sizeof(prefix_name), "%04x:%02x:%02x.%x",
pci_domain_nr(dd->pcidev->bus), pci_domain_nr(dd->pcidev->bus),
dd->pcidev->bus->number, dd->pcidev->bus->number,
PCI_SLOT(dd->pcidev->devfn), PCI_SLOT(dd->pcidev->devfn),
PCI_FUNC(dd->pcidev->devfn), PCI_FUNC(dd->pcidev->devfn));
kind); snprintf(name, sizeof(name), "%s-%s", prefix_name, kind);
result = read_efi_var(name, size, return_data);
/*
* If reading the lowercase EFI variable fail, read the uppercase
* variable.
*/
if (result) {
/* Converting to uppercase */
for (i = 0; prefix_name[i]; i++)
if (isalpha(prefix_name[i]))
prefix_name[i] = toupper(prefix_name[i]);
snprintf(name, sizeof(name), "%s-%s", prefix_name, kind);
result = read_efi_var(name, size, return_data);
}
return read_efi_var(name, size, return_data); return result;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment