Skip to contentSkip to conversation

crypto: qat - remove to call get_sram_bar_id for qat_c3xxx

PATCH In review Yang Pingchao 3 participants 3 messages Jan 6, 2016 – Jan 18, 2016 Crypto API

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: qat - remove to call get_sram_bar_id for qat_c3xxx

From: Pingchao Yang <[email protected]>

---
 drivers/crypto/qat/qat_common/qat_hal.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/crypto/qat/qat_common/qat_hal.c +6 -3
index 0d0b5ed..bcb39b0 100644
@@ -693,14 +693,12 @@ int qat_hal_init(struct adf_accel_dev *accel_dev)
 	struct adf_hw_device_data *hw_data = accel_dev->hw_device;
 	struct adf_bar *misc_bar =
 			&pci_info->pci_bars[hw_data->get_misc_bar_id(hw_data)];
-	struct adf_bar *sram_bar =
-			&pci_info->pci_bars[hw_data->get_sram_bar_id(hw_data)];
+	struct adf_bar *sram_bar;
 
 	handle = kzalloc(sizeof(*handle), GFP_KERNEL);
 	if (!handle)
 		return -ENOMEM;
 
-	handle->hal_sram_addr_v = sram_bar->virt_addr;
 	handle->hal_cap_g_ctl_csr_addr_v =
 		(void __iomem *)((uintptr_t)misc_bar->virt_addr +
 				 ICP_QAT_CAP_OFFSET);
@@ -714,6 +712,11 @@ int qat_hal_init(struct adf_accel_dev *accel_dev)
 		(void __iomem *)((uintptr_t)handle->hal_cap_ae_xfer_csr_addr_v +
 				 LOCAL_TO_XFER_REG_OFFSET);
 	handle->pci_dev = pci_info->pci_dev;
+	if (handle->pci_dev->device != ADF_C3XXX_PCI_DEVICE_ID) {
+		sram_bar =
+			&pci_info->pci_bars[hw_data->get_sram_bar_id(hw_data)];
+		handle->hal_sram_addr_v = sram_bar->virt_addr;
+	}
 	handle->fw_auth = (handle->pci_dev->device ==
 			   ADF_DH895XCC_PCI_DEVICE_ID) ? false : true;
 	handle->hal_handle = kzalloc(sizeof(*handle->hal_handle), GFP_KERNEL);
Signature · 1 line
2.6.4
#1 lore raw
Quoted 32 lines · Pingchao Yang

From: Pingchao Yang <[email protected]>

---
drivers/crypto/qat/qat_common/qat_hal.c | 9 ++++++---

 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/crypto/qat/qat_common/qat_hal.c +1 -3
index 0d0b5ed..bcb39b0 100644
@@ -693,14 +693,12 @@ int qat_hal_init(struct adf_accel_dev *accel_dev)
 	struct adf_hw_device_data *hw_data = accel_dev->hw_device;
 	struct adf_bar *misc_bar =
 			&pci_info->pci_bars[hw_data->get_misc_bar_id(hw_data)];
-	struct adf_bar *sram_bar =
-			&pci_info->pci_bars[hw_data->get_sram_bar_id(hw_data)];
+	struct adf_bar *sram_bar;
 
 	handle = kzalloc(sizeof(*handle), GFP_KERNEL);
 	if (!handle)
 		return -ENOMEM;
 
-	handle->hal_sram_addr_v = sram_bar->virt_addr;
 	handle->hal_cap_g_ctl_csr_addr_v =
 		(void __iomem *)((uintptr_t)misc_bar->virt_addr +
 				 ICP_QAT_CAP_OFFSET);
@@ -714,6 +712,11 @@ int qat_hal_init(struct adf_accel_dev *accel_dev)
 		(void __iomem *)((uintptr_t)handle->hal_cap_ae_xfer_csr_addr_v +

drivers/crypto/qat/qat_common/qat_hal.c int qat_hal_init(struct adf_accel_dev *accel_dev) · line 722

Quoted 10 lines
drivers/crypto/qat/qat_common/qat_hal.c +5 -0
 				 LOCAL_TO_XFER_REG_OFFSET);
 	handle->pci_dev = pci_info->pci_dev;
+	if (handle->pci_dev->device != ADF_C3XXX_PCI_DEVICE_ID) {
+		sram_bar =
+			&pci_info->pci_bars[hw_data->get_sram_bar_id(hw_data)];
+		handle->hal_sram_addr_v = sram_bar->virt_addr;
+	}
 	handle->fw_auth = (handle->pci_dev->device ==
 			   ADF_DH895XCC_PCI_DEVICE_ID) ? false : true;
 	handle->hal_handle = kzalloc(sizeof(*handle->hal_handle), GFP_KERNEL);

Herbert,
This fixes issue related to invalid BAR mapping on C3XXX device, which leads to memory corruption and kernel oops. Please include this fix into 4.5.
Thanks,

Signature · 1 line
TS