Skip to content

Commit

Permalink
Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/g…
Browse files Browse the repository at this point in the history
…it/jejb/scsi

Pull SCSI fixes from James Bottomley:
 "Nine small fixes.

  The resume fix is a cosmetic removal of a warning with an incorrect
  condition causing it to alarm people wrongly.

  The other eight patches correct a thinko in Christoph Hellwig's DMA
  conversion series. Without it all these drivers end up with 32 bit DMA
  masks meaning they bounce any page over 4GB before sending it to the
  controller.

  Nowadays, even laptops mostly have memory above 4GB, so this can lead
  to significant performance degradation with all the bouncing"

* tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
  scsi: core: Avoid that system resume triggers a kernel warning
  scsi: hptiop: fix calls to dma_set_mask()
  scsi: hisi_sas: fix calls to dma_set_mask_and_coherent()
  scsi: csiostor: fix calls to dma_set_mask_and_coherent()
  scsi: bfa: fix calls to dma_set_mask_and_coherent()
  scsi: aic94xx: fix calls to dma_set_mask_and_coherent()
  scsi: 3w-sas: fix calls to dma_set_mask_and_coherent()
  scsi: 3w-9xxx: fix calls to dma_set_mask_and_coherent()
  scsi: lpfc: fix calls to dma_set_mask_and_coherent()
  • Loading branch information
torvalds committed Mar 2, 2019
2 parents c93d921 + 388b4e6 commit df49fd0
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 35 deletions.
14 changes: 9 additions & 5 deletions drivers/scsi/3w-9xxx.c
Original file line number Diff line number Diff line change
Expand Up @@ -2009,7 +2009,7 @@ static int twa_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id)
struct Scsi_Host *host = NULL;
TW_Device_Extension *tw_dev;
unsigned long mem_addr, mem_len;
int retval = -ENODEV;
int retval;

retval = pci_enable_device(pdev);
if (retval) {
Expand All @@ -2020,8 +2020,10 @@ static int twa_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id)
pci_set_master(pdev);
pci_try_set_mwi(pdev);

if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
retval = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
if (retval)
retval = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
if (retval) {
TW_PRINTK(host, TW_DRIVER, 0x23, "Failed to set dma mask");
retval = -ENODEV;
goto out_disable_device;
Expand Down Expand Up @@ -2240,8 +2242,10 @@ static int twa_resume(struct pci_dev *pdev)
pci_set_master(pdev);
pci_try_set_mwi(pdev);

if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
retval = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
if (retval)
retval = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
if (retval) {
TW_PRINTK(host, TW_DRIVER, 0x40, "Failed to set dma mask during resume");
retval = -ENODEV;
goto out_disable_device;
Expand Down
12 changes: 8 additions & 4 deletions drivers/scsi/3w-sas.c
Original file line number Diff line number Diff line change
Expand Up @@ -1573,8 +1573,10 @@ static int twl_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id)
pci_set_master(pdev);
pci_try_set_mwi(pdev);

if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
retval = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
if (retval)
retval = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
if (retval) {
TW_PRINTK(host, TW_DRIVER, 0x18, "Failed to set dma mask");
retval = -ENODEV;
goto out_disable_device;
Expand Down Expand Up @@ -1805,8 +1807,10 @@ static int twl_resume(struct pci_dev *pdev)
pci_set_master(pdev);
pci_try_set_mwi(pdev);

if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
retval = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
if (retval)
retval = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
if (retval) {
TW_PRINTK(host, TW_DRIVER, 0x25, "Failed to set dma mask during resume");
retval = -ENODEV;
goto out_disable_device;
Expand Down
8 changes: 5 additions & 3 deletions drivers/scsi/aic94xx/aic94xx_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -769,9 +769,11 @@ static int asd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
if (err)
goto Err_remove;

err = -ENODEV;
if (dma_set_mask_and_coherent(&dev->dev, DMA_BIT_MASK(64)) ||
dma_set_mask_and_coherent(&dev->dev, DMA_BIT_MASK(32))) {
err = dma_set_mask_and_coherent(&dev->dev, DMA_BIT_MASK(64));
if (err)
err = dma_set_mask_and_coherent(&dev->dev, DMA_BIT_MASK(32));
if (err) {
err = -ENODEV;
asd_printk("no suitable DMA mask for %s\n", pci_name(dev));
goto Err_remove;
}
Expand Down
18 changes: 13 additions & 5 deletions drivers/scsi/bfa/bfad.c
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ bfad_init_timer(struct bfad_s *bfad)
int
bfad_pci_init(struct pci_dev *pdev, struct bfad_s *bfad)
{
int rc = -ENODEV;
int rc = -ENODEV;

if (pci_enable_device(pdev)) {
printk(KERN_ERR "pci_enable_device fail %p\n", pdev);
Expand All @@ -739,8 +739,12 @@ bfad_pci_init(struct pci_dev *pdev, struct bfad_s *bfad)

pci_set_master(pdev);

if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
if (rc)
rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));

if (rc) {
rc = -ENODEV;
printk(KERN_ERR "dma_set_mask_and_coherent fail %p\n", pdev);
goto out_release_region;
}
Expand Down Expand Up @@ -1534,6 +1538,7 @@ bfad_pci_slot_reset(struct pci_dev *pdev)
{
struct bfad_s *bfad = pci_get_drvdata(pdev);
u8 byte;
int rc;

dev_printk(KERN_ERR, &pdev->dev,
"bfad_pci_slot_reset flags: 0x%x\n", bfad->bfad_flags);
Expand Down Expand Up @@ -1561,8 +1566,11 @@ bfad_pci_slot_reset(struct pci_dev *pdev)
pci_save_state(pdev);
pci_set_master(pdev);

if (dma_set_mask_and_coherent(&bfad->pcidev->dev, DMA_BIT_MASK(64)) ||
dma_set_mask_and_coherent(&bfad->pcidev->dev, DMA_BIT_MASK(32)))
rc = dma_set_mask_and_coherent(&bfad->pcidev->dev, DMA_BIT_MASK(64));
if (rc)
rc = dma_set_mask_and_coherent(&bfad->pcidev->dev,
DMA_BIT_MASK(32));
if (rc)
goto out_disable_device;

if (restart_bfa(bfad) == -1)
Expand Down
7 changes: 5 additions & 2 deletions drivers/scsi/csiostor/csio_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,11 @@ csio_pci_init(struct pci_dev *pdev, int *bars)
pci_set_master(pdev);
pci_try_set_mwi(pdev);

if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
rv = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
if (rv)
rv = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
if (rv) {
rv = -ENODEV;
dev_err(&pdev->dev, "No suitable DMA available.\n");
goto err_release_regions;
}
Expand Down
8 changes: 6 additions & 2 deletions drivers/scsi/hisi_sas/hisi_sas_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2323,6 +2323,7 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev,
struct Scsi_Host *shost;
struct hisi_hba *hisi_hba;
struct device *dev = &pdev->dev;
int error;

shost = scsi_host_alloc(hw->sht, sizeof(*hisi_hba));
if (!shost) {
Expand All @@ -2343,8 +2344,11 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct platform_device *pdev,
if (hisi_sas_get_fw_info(hisi_hba) < 0)
goto err_out;

if (dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64)) &&
dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32))) {
error = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64));
if (error)
error = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));

if (error) {
dev_err(dev, "No usable DMA addressing method\n");
goto err_out;
}
Expand Down
8 changes: 5 additions & 3 deletions drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -2447,10 +2447,12 @@ hisi_sas_v3_probe(struct pci_dev *pdev, const struct pci_device_id *id)
if (rc)
goto err_out_disable_device;

if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32))) {
rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
if (rc)
rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
if (rc) {
dev_err(dev, "No usable DMA addressing method\n");
rc = -EIO;
rc = -ENODEV;
goto err_out_regions;
}

Expand Down
10 changes: 7 additions & 3 deletions drivers/scsi/hptiop.c
Original file line number Diff line number Diff line change
Expand Up @@ -1292,6 +1292,7 @@ static int hptiop_probe(struct pci_dev *pcidev, const struct pci_device_id *id)
dma_addr_t start_phy;
void *start_virt;
u32 offset, i, req_size;
int rc;

dprintk("hptiop_probe(%p)\n", pcidev);

Expand All @@ -1308,9 +1309,12 @@ static int hptiop_probe(struct pci_dev *pcidev, const struct pci_device_id *id)

/* Enable 64bit DMA if possible */
iop_ops = (struct hptiop_adapter_ops *)id->driver_data;
if (dma_set_mask(&pcidev->dev,
DMA_BIT_MASK(iop_ops->hw_dma_bit_mask)) ||
dma_set_mask(&pcidev->dev, DMA_BIT_MASK(32))) {
rc = dma_set_mask(&pcidev->dev,
DMA_BIT_MASK(iop_ops->hw_dma_bit_mask));
if (rc)
rc = dma_set_mask(&pcidev->dev, DMA_BIT_MASK(32));

if (rc) {
printk(KERN_ERR "hptiop: fail to set dma_mask\n");
goto disable_pci_device;
}
Expand Down
19 changes: 12 additions & 7 deletions drivers/scsi/lpfc/lpfc_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -7361,15 +7361,18 @@ lpfc_sli_pci_mem_setup(struct lpfc_hba *phba)
unsigned long bar0map_len, bar2map_len;
int i, hbq_count;
void *ptr;
int error = -ENODEV;
int error;

if (!pdev)
return error;
return -ENODEV;

/* Set the device DMA mask size */
if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)))
error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
if (error)
error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
if (error)
return error;
error = -ENODEV;

/* Get the bus address of Bar0 and Bar2 and the number of bytes
* required by each mapping.
Expand Down Expand Up @@ -9742,11 +9745,13 @@ lpfc_sli4_pci_mem_setup(struct lpfc_hba *phba)
uint32_t if_type;

if (!pdev)
return error;
return -ENODEV;

/* Set the device DMA mask size */
if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) ||
dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)))
error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
if (error)
error = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
if (error)
return error;

/*
Expand Down
1 change: 0 additions & 1 deletion drivers/scsi/scsi_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -2598,7 +2598,6 @@ void scsi_device_resume(struct scsi_device *sdev)
* device deleted during suspend)
*/
mutex_lock(&sdev->state_mutex);
WARN_ON_ONCE(!sdev->quiesced_by);
sdev->quiesced_by = NULL;
blk_clear_pm_only(sdev->request_queue);
if (sdev->sdev_state == SDEV_QUIESCE)
Expand Down

0 comments on commit df49fd0

Please sign in to comment.