From: Kevin Barnett Date: Wed, 3 May 2017 23:53:18 +0000 (-0500) Subject: scsi: smartpqi: correct bdma hw bug X-Git-Tag: v4.1.12-107.0.20170801_2000~51 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=ac47fe0d5aadcdc63036f9786f63a3493def0d7b;p=users%2Fjedix%2Flinux-maple.git scsi: smartpqi: correct bdma hw bug Orabug: 26191021, 26447813 add workaround for BDMA hardware bug that can cause hw to read up to 12 SGL elements (192 bytes) beyond the last element in the list. This fix avoids IOMMU violations Reviewed-by: Scott Benesh Signed-off-by: Kevin Barnett Signed-off-by: Don Brace Signed-off-by: Martin K. Petersen (cherry picked from commit e1d213bdc3e359c6c5da8ebbc5b2e87b376e8777) Signed-off-by: Brian Maly --- diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c index e30d9d9d3c341..752bb175e345b 100644 --- a/drivers/scsi/smartpqi/smartpqi_init.c +++ b/drivers/scsi/smartpqi/smartpqi_init.c @@ -48,6 +48,8 @@ #define DRIVER_NAME "Microsemi PQI Driver (v" DRIVER_VERSION ")" #define DRIVER_NAME_SHORT "smartpqi" +#define PQI_EXTRA_SGL_MEMORY (12 * sizeof(struct pqi_sg_descriptor)) + MODULE_AUTHOR("Microsemi"); MODULE_DESCRIPTION("Driver for Microsemi Smart Family Controller version " DRIVER_VERSION); @@ -3243,6 +3245,8 @@ static int pqi_alloc_operational_queues(struct pqi_ctrl_info *ctrl_info) alloc_length = (size_t)aligned_pointer + PQI_QUEUE_ELEMENT_ARRAY_ALIGNMENT; + alloc_length += PQI_EXTRA_SGL_MEMORY; + ctrl_info->queue_memory_base = dma_zalloc_coherent(&ctrl_info->pci_dev->dev, alloc_length, @@ -4360,7 +4364,8 @@ static void pqi_calculate_io_resources(struct pqi_ctrl_info *ctrl_info) max_transfer_size = (max_sg_entries - 1) * PAGE_SIZE; ctrl_info->sg_chain_buffer_length = - max_sg_entries * sizeof(struct pqi_sg_descriptor); + (max_sg_entries * sizeof(struct pqi_sg_descriptor)) + + PQI_EXTRA_SGL_MEMORY; ctrl_info->sg_tablesize = max_sg_entries; ctrl_info->max_sectors = max_transfer_size / 512; }