* [PATCH 1/2] [SCSI] ufshcd-pltfrm: remove unnecessary dma_set_coherent_mask() call
@ 2013-06-09 11:19 Akinobu Mita
2013-06-09 11:19 ` [PATCH 2/2] [SCSI] ufs: fix DMA mask setting Akinobu Mita
2013-06-12 7:05 ` [PATCH 1/2] [SCSI] ufshcd-pltfrm: remove unnecessary dma_set_coherent_mask() call Santosh Y
0 siblings, 2 replies; 4+ messages in thread
From: Akinobu Mita @ 2013-06-09 11:19 UTC (permalink / raw)
To: linux-scsi
Cc: Akinobu Mita, Vinayak Holikatti, Santosh Y, James E.J. Bottomley
Changing the device coherent dma mask to the value that currently set
has no effect.
Signed-off-by: Akinobu Mita <mita@fixstars.com>
Cc: Vinayak Holikatti <vinholikatti@gmail.com>
Cc: Santosh Y <santoshsy@gmail.com>
Cc: "James E.J. Bottomley" <JBottomley@parallels.com>
Cc: linux-scsi@vger.kernel.org
---
drivers/scsi/ufs/ufshcd-pltfrm.c | 7 -------
1 file changed, 7 deletions(-)
diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c
index 0014e28..969c9bc 100644
--- a/drivers/scsi/ufs/ufshcd-pltfrm.c
+++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
@@ -100,7 +100,6 @@ static int ufshcd_pltfrm_probe(struct platform_device *pdev)
struct resource *irq_res;
resource_size_t mem_size;
int err;
- struct device *dev = &pdev->dev;
mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!mem_res) {
@@ -132,12 +131,6 @@ static int ufshcd_pltfrm_probe(struct platform_device *pdev)
goto out_iounmap;
}
- err = dma_set_coherent_mask(dev, dev->coherent_dma_mask);
- if (err) {
- dev_err(&pdev->dev, "set dma mask failed\n");
- goto out_iounmap;
- }
-
err = ufshcd_init(&pdev->dev, &hba, mmio_base, irq_res->start);
if (err) {
dev_err(&pdev->dev, "Intialization failed\n");
--
1.8.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] [SCSI] ufs: fix DMA mask setting
2013-06-09 11:19 [PATCH 1/2] [SCSI] ufshcd-pltfrm: remove unnecessary dma_set_coherent_mask() call Akinobu Mita
@ 2013-06-09 11:19 ` Akinobu Mita
2013-06-12 7:05 ` Santosh Y
2013-06-12 7:05 ` [PATCH 1/2] [SCSI] ufshcd-pltfrm: remove unnecessary dma_set_coherent_mask() call Santosh Y
1 sibling, 1 reply; 4+ messages in thread
From: Akinobu Mita @ 2013-06-09 11:19 UTC (permalink / raw)
To: linux-scsi
Cc: Akinobu Mita, Vinayak Holikatti, Santosh Y, James E.J. Bottomley
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.
Lastly, we need to relax dma_set_mask(dev, DMA_BIT_MASK(32)) error check
for platform devices on ARM, which do not have a valid dma_mask pointer.
Signed-off-by: Akinobu Mita <mita@fixstars.com>
Cc: Vinayak Holikatti <vinholikatti@gmail.com>
Cc: Santosh Y <santoshsy@gmail.com>
Cc: "James E.J. Bottomley" <JBottomley@parallels.com>
Cc: linux-scsi@vger.kernel.org
---
drivers/scsi/ufs/ufshcd-pci.c | 26 --------------------------
drivers/scsi/ufs/ufshcd.c | 25 +++++++++++++++++++++++++
2 files changed, 25 insertions(+), 26 deletions(-)
diff --git a/drivers/scsi/ufs/ufshcd-pci.c b/drivers/scsi/ufs/ufshcd-pci.c
index 5cb1d75..6835520 100644
--- a/drivers/scsi/ufs/ufshcd-pci.c
+++ b/drivers/scsi/ufs/ufshcd-pci.c
@@ -101,26 +101,6 @@ static void ufshcd_pci_remove(struct pci_dev *pdev)
}
/**
- * ufshcd_set_dma_mask - Set dma mask based on the controller
- * addressing capability
- * @pdev: PCI device structure
- *
- * Returns 0 for success, non-zero for failure
- */
-static int ufshcd_set_dma_mask(struct pci_dev *pdev)
-{
- int err;
-
- if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))
- && !pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)))
- return 0;
- err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
- if (!err)
- err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
- return err;
-}
-
-/**
* ufshcd_pci_probe - probe routine of the driver
* @pdev: pointer to PCI device handle
* @id: PCI device id
@@ -156,12 +136,6 @@ ufshcd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
goto out_release_regions;
}
- err = ufshcd_set_dma_mask(pdev);
- if (err) {
- dev_err(&pdev->dev, "set dma mask failed\n");
- goto out_iounmap;
- }
-
err = ufshcd_init(&pdev->dev, &hba, mmio_base, pdev->irq);
if (err) {
dev_err(&pdev->dev, "Initialization failed\n");
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 492f2b7..7f5399c 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -1598,6 +1598,25 @@ 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(hba->dev, DMA_BIT_MASK(64)) &&
+ !dma_set_coherent_mask(hba->dev, DMA_BIT_MASK(64)))
+ return 0;
+ }
+ dma_set_mask(hba->dev, DMA_BIT_MASK(32));
+
+ return dma_set_coherent_mask(hba->dev, DMA_BIT_MASK(32));
+}
+
+/**
* ufshcd_init - Driver initialization routine
* @dev: pointer to device handle
* @hba_handle: driver private handle
@@ -1645,6 +1664,12 @@ int ufshcd_init(struct device *dev, struct ufs_hba **hba_handle,
/* Get UFS version supported by the controller */
hba->ufs_version = ufshcd_get_ufs_version(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) {
--
1.8.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] [SCSI] ufshcd-pltfrm: remove unnecessary dma_set_coherent_mask() call
2013-06-09 11:19 [PATCH 1/2] [SCSI] ufshcd-pltfrm: remove unnecessary dma_set_coherent_mask() call Akinobu Mita
2013-06-09 11:19 ` [PATCH 2/2] [SCSI] ufs: fix DMA mask setting Akinobu Mita
@ 2013-06-12 7:05 ` Santosh Y
1 sibling, 0 replies; 4+ messages in thread
From: Santosh Y @ 2013-06-12 7:05 UTC (permalink / raw)
To: Akinobu Mita; +Cc: linux-scsi, Vinayak Holikatti, James E.J. Bottomley
On Sun, Jun 9, 2013 at 4:49 PM, Akinobu Mita <mita@fixstars.com> wrote:
> Changing the device coherent dma mask to the value that currently set
> has no effect.
>
> Signed-off-by: Akinobu Mita <mita@fixstars.com>
> Cc: Vinayak Holikatti <vinholikatti@gmail.com>
> Cc: Santosh Y <santoshsy@gmail.com>
> Cc: "James E.J. Bottomley" <JBottomley@parallels.com>
> Cc: linux-scsi@vger.kernel.org
> ---
> drivers/scsi/ufs/ufshcd-pltfrm.c | 7 -------
> 1 file changed, 7 deletions(-)
>
> diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c
> index 0014e28..969c9bc 100644
> --- a/drivers/scsi/ufs/ufshcd-pltfrm.c
> +++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
> @@ -100,7 +100,6 @@ static int ufshcd_pltfrm_probe(struct platform_device *pdev)
> struct resource *irq_res;
> resource_size_t mem_size;
> int err;
> - struct device *dev = &pdev->dev;
>
> mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> if (!mem_res) {
> @@ -132,12 +131,6 @@ static int ufshcd_pltfrm_probe(struct platform_device *pdev)
> goto out_iounmap;
> }
>
> - err = dma_set_coherent_mask(dev, dev->coherent_dma_mask);
> - if (err) {
> - dev_err(&pdev->dev, "set dma mask failed\n");
> - goto out_iounmap;
> - }
> -
> err = ufshcd_init(&pdev->dev, &hba, mmio_base, irq_res->start);
> if (err) {
> dev_err(&pdev->dev, "Intialization failed\n");
> --
> 1.8.1.4
>
Acked-by: Santosh Y <santoshsy@gmail.com>
--
~Santosh
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] [SCSI] ufs: fix DMA mask setting
2013-06-09 11:19 ` [PATCH 2/2] [SCSI] ufs: fix DMA mask setting Akinobu Mita
@ 2013-06-12 7:05 ` Santosh Y
0 siblings, 0 replies; 4+ messages in thread
From: Santosh Y @ 2013-06-12 7:05 UTC (permalink / raw)
To: Akinobu Mita; +Cc: linux-scsi, Vinayak Holikatti, James E.J. Bottomley
On Sun, Jun 9, 2013 at 4:49 PM, Akinobu Mita <mita@fixstars.com> wrote:
> 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.
>
> Lastly, we need to relax dma_set_mask(dev, DMA_BIT_MASK(32)) error check
> for platform devices on ARM, which do not have a valid dma_mask pointer.
>
> Signed-off-by: Akinobu Mita <mita@fixstars.com>
> Cc: Vinayak Holikatti <vinholikatti@gmail.com>
> Cc: Santosh Y <santoshsy@gmail.com>
> Cc: "James E.J. Bottomley" <JBottomley@parallels.com>
> Cc: linux-scsi@vger.kernel.org
> ---
> drivers/scsi/ufs/ufshcd-pci.c | 26 --------------------------
> drivers/scsi/ufs/ufshcd.c | 25 +++++++++++++++++++++++++
> 2 files changed, 25 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/scsi/ufs/ufshcd-pci.c b/drivers/scsi/ufs/ufshcd-pci.c
> index 5cb1d75..6835520 100644
> --- a/drivers/scsi/ufs/ufshcd-pci.c
> +++ b/drivers/scsi/ufs/ufshcd-pci.c
> @@ -101,26 +101,6 @@ static void ufshcd_pci_remove(struct pci_dev *pdev)
> }
>
> /**
> - * ufshcd_set_dma_mask - Set dma mask based on the controller
> - * addressing capability
> - * @pdev: PCI device structure
> - *
> - * Returns 0 for success, non-zero for failure
> - */
> -static int ufshcd_set_dma_mask(struct pci_dev *pdev)
> -{
> - int err;
> -
> - if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))
> - && !pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)))
> - return 0;
> - err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
> - if (!err)
> - err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
> - return err;
> -}
> -
> -/**
> * ufshcd_pci_probe - probe routine of the driver
> * @pdev: pointer to PCI device handle
> * @id: PCI device id
> @@ -156,12 +136,6 @@ ufshcd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> goto out_release_regions;
> }
>
> - err = ufshcd_set_dma_mask(pdev);
> - if (err) {
> - dev_err(&pdev->dev, "set dma mask failed\n");
> - goto out_iounmap;
> - }
> -
> err = ufshcd_init(&pdev->dev, &hba, mmio_base, pdev->irq);
> if (err) {
> dev_err(&pdev->dev, "Initialization failed\n");
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index 492f2b7..7f5399c 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -1598,6 +1598,25 @@ 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(hba->dev, DMA_BIT_MASK(64)) &&
> + !dma_set_coherent_mask(hba->dev, DMA_BIT_MASK(64)))
> + return 0;
> + }
> + dma_set_mask(hba->dev, DMA_BIT_MASK(32));
> +
> + return dma_set_coherent_mask(hba->dev, DMA_BIT_MASK(32));
> +}
> +
> +/**
> * ufshcd_init - Driver initialization routine
> * @dev: pointer to device handle
> * @hba_handle: driver private handle
> @@ -1645,6 +1664,12 @@ int ufshcd_init(struct device *dev, struct ufs_hba **hba_handle,
> /* Get UFS version supported by the controller */
> hba->ufs_version = ufshcd_get_ufs_version(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) {
> --
> 1.8.1.4
>
Acked-by: Santosh Y <santoshsy@gmail.com>
--
~Santosh
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-06-12 7:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-09 11:19 [PATCH 1/2] [SCSI] ufshcd-pltfrm: remove unnecessary dma_set_coherent_mask() call Akinobu Mita
2013-06-09 11:19 ` [PATCH 2/2] [SCSI] ufs: fix DMA mask setting Akinobu Mita
2013-06-12 7:05 ` Santosh Y
2013-06-12 7:05 ` [PATCH 1/2] [SCSI] ufshcd-pltfrm: remove unnecessary dma_set_coherent_mask() call Santosh Y
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).