Commit bf482c60 authored by Dave Jiang's avatar Dave Jiang Committed by Dan Williams

isci: Retrieve the EFI variable for OEM parameter

We can call the EFI get_variable service routine directly to retrieve
the EFI variable that holds the OEM parameters table.
Signed-off-by: default avatarDave Jiang <dave.jiang@intel.com>
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent 77d67385
...@@ -34,14 +34,8 @@ ...@@ -34,14 +34,8 @@
#include "task.h" #include "task.h"
#include "probe_roms.h" #include "probe_roms.h"
struct efi_variable { static efi_char16_t isci_efivar_name[] =
efi_char16_t VariableName[1024/sizeof(efi_char16_t)]; {'R', 's', 't', 'S', 'c', 'u', 'O'};
efi_guid_t VendorGuid;
unsigned long DataSize;
__u8 Data[1024];
efi_status_t Status;
__u32 Attributes;
} __attribute__((packed));
struct isci_orom *isci_request_oprom(struct pci_dev *pdev) struct isci_orom *isci_request_oprom(struct pci_dev *pdev)
{ {
...@@ -169,62 +163,50 @@ struct isci_orom *isci_request_firmware(struct pci_dev *pdev, const struct firmw ...@@ -169,62 +163,50 @@ struct isci_orom *isci_request_firmware(struct pci_dev *pdev, const struct firmw
static struct efi *get_efi(void) static struct efi *get_efi(void)
{ {
#ifdef CONFIG_EFI #ifdef CONFIG_EFI
return &efi; return &efi;
#else #else
return NULL; return NULL;
#endif #endif
} }
struct isci_orom *isci_get_efi_var(struct pci_dev *pdev) struct isci_orom *isci_get_efi_var(struct pci_dev *pdev)
{ {
struct efi_variable *evar;
efi_status_t status; efi_status_t status;
struct isci_orom *rom = NULL; struct isci_orom *rom;
struct isci_oem_hdr *oem_hdr; struct isci_oem_hdr *oem_hdr;
u8 *tmp, sum; u8 *tmp, sum;
int j; int j;
size_t copy_len; ssize_t data_len;
u8 *efi_data;
u32 efi_attrib = 0;
evar = devm_kzalloc(&pdev->dev, data_len = 1024;
sizeof(struct efi_variable), efi_data = devm_kzalloc(&pdev->dev, data_len, GFP_KERNEL);
GFP_KERNEL); if (!efi_data) {
if (!evar) {
dev_warn(&pdev->dev, dev_warn(&pdev->dev,
"Unable to allocate memory for EFI var\n"); "Unable to allocate memory for EFI data\n");
return NULL;
}
rom = devm_kzalloc(&pdev->dev, sizeof(*rom), GFP_KERNEL);
if (!rom) {
dev_warn(&pdev->dev,
"Unable to allocate memory for orom\n");
return NULL; return NULL;
} }
for (j = 0; j < strlen(ISCI_EFI_VAR_NAME) + 1; j++) rom = (struct isci_orom *)(efi_data + sizeof(struct isci_oem_hdr));
evar->VariableName[j] = ISCI_EFI_VAR_NAME[j];
evar->DataSize = 1024;
evar->VendorGuid = ISCI_EFI_VENDOR_GUID;
evar->Attributes = ISCI_EFI_ATTRIBUTES;
if (get_efi()) if (get_efi())
status = get_efi()->get_variable(evar->VariableName, status = get_efi()->get_variable(isci_efivar_name,
&evar->VendorGuid, &ISCI_EFI_VENDOR_GUID,
&evar->Attributes, &efi_attrib,
&evar->DataSize, &data_len,
evar->Data); efi_data);
else else
status = EFI_NOT_FOUND; status = EFI_NOT_FOUND;
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {
dev_warn(&pdev->dev, dev_warn(&pdev->dev,
"Unable to obtain EFI variable for OEM parms\n"); "Unable to obtain EFI var data for OEM parms\n");
return NULL; return NULL;
} }
oem_hdr = (struct isci_oem_hdr *)evar->Data; oem_hdr = (struct isci_oem_hdr *)efi_data;
if (memcmp(oem_hdr->sig, ISCI_OEM_SIG, ISCI_OEM_SIG_SIZE) != 0) { if (memcmp(oem_hdr->sig, ISCI_OEM_SIG, ISCI_OEM_SIG_SIZE) != 0) {
dev_warn(&pdev->dev, dev_warn(&pdev->dev,
...@@ -233,12 +215,8 @@ struct isci_orom *isci_get_efi_var(struct pci_dev *pdev) ...@@ -233,12 +215,8 @@ struct isci_orom *isci_get_efi_var(struct pci_dev *pdev)
} }
/* calculate checksum */ /* calculate checksum */
tmp = (u8 *)oem_hdr; tmp = (u8 *)efi_data;
for (j = 0, sum = 0; j < sizeof(oem_hdr); j++, tmp++) for (j = 0, sum = 0; j < (sizeof(*oem_hdr) + sizeof(*rom)); j++, tmp++)
sum += *tmp;
tmp = (u8 *)rom;
for (j = 0; j < sizeof(*rom); j++, tmp++)
sum += *tmp; sum += *tmp;
if (sum != 0) { if (sum != 0) {
...@@ -247,11 +225,6 @@ struct isci_orom *isci_get_efi_var(struct pci_dev *pdev) ...@@ -247,11 +225,6 @@ struct isci_orom *isci_get_efi_var(struct pci_dev *pdev)
return NULL; return NULL;
} }
copy_len = min_t(u16, evar->DataSize,
min_t(u16, oem_hdr->len - sizeof(*oem_hdr), sizeof(*rom)));
memcpy(rom, (char *)evar->Data + sizeof(*oem_hdr), copy_len);
if (memcmp(rom->hdr.signature, if (memcmp(rom->hdr.signature,
ISCI_ROM_SIG, ISCI_ROM_SIG,
ISCI_ROM_SIG_SIZE) != 0) { ISCI_ROM_SIG_SIZE) != 0) {
......
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
#ifdef __KERNEL__ #ifdef __KERNEL__
#include <linux/firmware.h> #include <linux/firmware.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/efi.h>
#include "isci.h" #include "isci.h"
#define SCIC_SDS_PARM_NO_SPEED 0 #define SCIC_SDS_PARM_NO_SPEED 0
...@@ -202,7 +203,6 @@ struct isci_oem_hdr { ...@@ -202,7 +203,6 @@ struct isci_oem_hdr {
#define ISCI_EFI_VENDOR_GUID \ #define ISCI_EFI_VENDOR_GUID \
EFI_GUID(0x193dfefa, 0xa445, 0x4302, 0x99, 0xd8, 0xef, 0x3a, 0xad, \ EFI_GUID(0x193dfefa, 0xa445, 0x4302, 0x99, 0xd8, 0xef, 0x3a, 0xad, \
0x1a, 0x04, 0xc6) 0x1a, 0x04, 0xc6)
#define ISCI_EFI_ATTRIBUTES 0
#define ISCI_EFI_VAR_NAME "RstScuO" #define ISCI_EFI_VAR_NAME "RstScuO"
/* Allowed PORT configuration modes APC Automatic PORT configuration mode is /* Allowed PORT configuration modes APC Automatic PORT configuration mode is
......
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