aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAkinobu Mita <akinobu.mita@gmail.com>2014-07-13 08:24:46 -0400
committerChristoph Hellwig <hch@lst.de>2014-07-25 17:17:02 -0400
commitca3d7bf9c646e976d33027d65dfd60124e3dc7e9 (patch)
tree10d45b3543a810333734e3b721e1f99887a429ad
parenteeda47499f01878d60b3db8883fbbafc3c6a2a54 (diff)
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>
-rw-r--r--drivers/scsi/ufs/ufshcd-pci.c26
-rw-r--r--drivers/scsi/ufs/ufshcd.c22
2 files changed, 22 insertions, 26 deletions
diff --git a/drivers/scsi/ufs/ufshcd-pci.c b/drivers/scsi/ufs/ufshcd-pci.c
index 8b9531204c2b..c007a7a69c28 100644
--- a/drivers/scsi/ufs/ufshcd-pci.c
+++ b/drivers/scsi/ufs/ufshcd-pci.c
@@ -135,26 +135,6 @@ static void ufshcd_pci_remove(struct pci_dev *pdev)
135} 135}
136 136
137/** 137/**
138 * ufshcd_set_dma_mask - Set dma mask based on the controller
139 * addressing capability
140 * @pdev: PCI device structure
141 *
142 * Returns 0 for success, non-zero for failure
143 */
144static int ufshcd_set_dma_mask(struct pci_dev *pdev)
145{
146 int err;
147
148 if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))
149 && !pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)))
150 return 0;
151 err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
152 if (!err)
153 err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
154 return err;
155}
156
157/**
158 * ufshcd_pci_probe - probe routine of the driver 138 * ufshcd_pci_probe - probe routine of the driver
159 * @pdev: pointer to PCI device handle 139 * @pdev: pointer to PCI device handle
160 * @id: PCI device id 140 * @id: PCI device id
@@ -184,12 +164,6 @@ ufshcd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
184 164
185 mmio_base = pcim_iomap_table(pdev)[0]; 165 mmio_base = pcim_iomap_table(pdev)[0];
186 166
187 err = ufshcd_set_dma_mask(pdev);
188 if (err) {
189 dev_err(&pdev->dev, "set dma mask failed\n");
190 return err;
191 }
192
193 err = ufshcd_init(&pdev->dev, &hba, mmio_base, pdev->irq); 167 err = ufshcd_init(&pdev->dev, &hba, mmio_base, pdev->irq);
194 if (err) { 168 if (err) {
195 dev_err(&pdev->dev, "Initialization failed\n"); 169 dev_err(&pdev->dev, "Initialization failed\n");
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)
3259EXPORT_SYMBOL_GPL(ufshcd_remove); 3259EXPORT_SYMBOL_GPL(ufshcd_remove);
3260 3260
3261/** 3261/**
3262 * ufshcd_set_dma_mask - Set dma mask based on the controller
3263 * addressing capability
3264 * @hba: per adapter instance
3265 *
3266 * Returns 0 for success, non-zero for failure
3267 */
3268static int ufshcd_set_dma_mask(struct ufs_hba *hba)
3269{
3270 if (hba->capabilities & MASK_64_ADDRESSING_SUPPORT) {
3271 if (!dma_set_mask_and_coherent(hba->dev, DMA_BIT_MASK(64)))
3272 return 0;
3273 }
3274 return dma_set_mask_and_coherent(hba->dev, DMA_BIT_MASK(32));
3275}
3276
3277/**
3262 * ufshcd_init - Driver initialization routine 3278 * ufshcd_init - Driver initialization routine
3263 * @dev: pointer to device handle 3279 * @dev: pointer to device handle
3264 * @hba_handle: driver private handle 3280 * @hba_handle: driver private handle
@@ -3309,6 +3325,12 @@ int ufshcd_init(struct device *dev, struct ufs_hba **hba_handle,
3309 /* Get Interrupt bit mask per version */ 3325 /* Get Interrupt bit mask per version */
3310 hba->intr_mask = ufshcd_get_intr_mask(hba); 3326 hba->intr_mask = ufshcd_get_intr_mask(hba);
3311 3327
3328 err = ufshcd_set_dma_mask(hba);
3329 if (err) {
3330 dev_err(hba->dev, "set dma mask failed\n");
3331 goto out_disable;
3332 }
3333
3312 /* Allocate memory for host memory space */ 3334 /* Allocate memory for host memory space */
3313 err = ufshcd_memory_alloc(hba); 3335 err = ufshcd_memory_alloc(hba);
3314 if (err) { 3336 if (err) {