diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2014-07-13 14:24:46 +0200 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2014-07-25 23:17:02 +0200 |
commit | ca3d7bf9c646e976d33027d65dfd60124e3dc7e9 (patch) | |
tree | 10d45b3543a810333734e3b721e1f99887a429ad /drivers/scsi/ufs/ufshcd.c | |
parent | ufs: adjust queue settings to PRDT limitations (diff) | |
download | linux-ca3d7bf9c646e976d33027d65dfd60124e3dc7e9.tar.xz linux-ca3d7bf9c646e976d33027d65dfd60124e3dc7e9.zip |
ufs: fix DMA mask setting
If the controller doesn't support 64-bit addressing mode, it must not
set the DMA mask to 64-bit. But it's unconditionally trying to set to
64-bit without checking 64-bit addressing support in the controller
capabilities.
It was correctly checked before commit 3b1d05807a9a68c6d0580e9248247a774a4d3be6
("[SCSI] ufs: Segregate PCI Specific Code"), this aims to restores
the correct behaviour.
To achieve this in a generic way, firstly we should push down the DMA
mask setting routine ufshcd_set_dma_mask() from PCI glue driver to core
driver in order to do it for both PCI glue driver and Platform glue
driver. Secondly, we should change pci_ DMA mapping API to dma_ DMA
mapping API because core driver is independent of glue drivers.
Signed-off-by: Akinobu Mita <mita@fixstars.com>
Acked-by: Santosh Y <santoshsy@gmail.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to '')
-rw-r--r-- | drivers/scsi/ufs/ufshcd.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index af1bffc1eac8..d41233914336 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -3259,6 +3259,22 @@ void ufshcd_remove(struct ufs_hba *hba) EXPORT_SYMBOL_GPL(ufshcd_remove); /** + * ufshcd_set_dma_mask - Set dma mask based on the controller + * addressing capability + * @hba: per adapter instance + * + * Returns 0 for success, non-zero for failure + */ +static int ufshcd_set_dma_mask(struct ufs_hba *hba) +{ + if (hba->capabilities & MASK_64_ADDRESSING_SUPPORT) { + if (!dma_set_mask_and_coherent(hba->dev, DMA_BIT_MASK(64))) + return 0; + } + return dma_set_mask_and_coherent(hba->dev, DMA_BIT_MASK(32)); +} + +/** * ufshcd_init - Driver initialization routine * @dev: pointer to device handle * @hba_handle: driver private handle @@ -3309,6 +3325,12 @@ int ufshcd_init(struct device *dev, struct ufs_hba **hba_handle, /* Get Interrupt bit mask per version */ hba->intr_mask = ufshcd_get_intr_mask(hba); + err = ufshcd_set_dma_mask(hba); + if (err) { + dev_err(hba->dev, "set dma mask failed\n"); + goto out_disable; + } + /* Allocate memory for host memory space */ err = ufshcd_memory_alloc(hba); if (err) { |