All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] habanalabs: Use 'dma_set_mask_and_coherent()' instead of hand-writing it
@ 2020-12-29 11:12 ` Christophe JAILLET
  0 siblings, 0 replies; 4+ messages in thread
From: Christophe JAILLET @ 2020-12-29 11:12 UTC (permalink / raw)
  To: ogabbay, arnd, gregkh, obitton, lee.jones, ttayar, fkassabri
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET

Axe 'hl_pci_set_dma_mask()' and replace it with an equivalent
'dma_set_mask_and_coherent()' call.

This makes the code a bit less verbose.

It also removes an erroneous comment, because 'hl_pci_set_dma_mask()' does
not try to use a fall-back value.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/misc/habanalabs/common/pci.c | 42 ++++------------------------
 1 file changed, 6 insertions(+), 36 deletions(-)

diff --git a/drivers/misc/habanalabs/common/pci.c b/drivers/misc/habanalabs/common/pci.c
index 923b2606e29f..eb8a784ba863 100644
--- a/drivers/misc/habanalabs/common/pci.c
+++ b/drivers/misc/habanalabs/common/pci.c
@@ -301,40 +301,6 @@ int hl_pci_set_outbound_region(struct hl_device *hdev,
 	return rc;
 }
 
-/**
- * hl_pci_set_dma_mask() - Set DMA masks for the device.
- * @hdev: Pointer to hl_device structure.
- *
- * This function sets the DMA masks (regular and consistent) for a specified
- * value. If it doesn't succeed, it tries to set it to a fall-back value
- *
- * Return: 0 on success, non-zero for failure.
- */
-static int hl_pci_set_dma_mask(struct hl_device *hdev)
-{
-	struct pci_dev *pdev = hdev->pdev;
-	int rc;
-
-	/* set DMA mask */
-	rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(hdev->dma_mask));
-	if (rc) {
-		dev_err(hdev->dev,
-			"Failed to set pci dma mask to %d bits, error %d\n",
-			hdev->dma_mask, rc);
-		return rc;
-	}
-
-	rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(hdev->dma_mask));
-	if (rc) {
-		dev_err(hdev->dev,
-			"Failed to set pci consistent dma mask to %d bits, error %d\n",
-			hdev->dma_mask, rc);
-		return rc;
-	}
-
-	return 0;
-}
-
 /**
  * hl_pci_init() - PCI initialization code.
  * @hdev: Pointer to hl_device structure.
@@ -371,9 +337,13 @@ int hl_pci_init(struct hl_device *hdev)
 		goto unmap_pci_bars;
 	}
 
-	rc = hl_pci_set_dma_mask(hdev);
-	if (rc)
+	rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(hdev->dma_mask));
+	if (rc) {
+		dev_err(hdev->dev,
+			"Failed to set dma mask to %d bits, error %d\n",
+			hdev->dma_mask, rc);
 		goto unmap_pci_bars;
+	}
 
 	return 0;
 
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] habanalabs: Use 'dma_set_mask_and_coherent()' instead of hand-writing it
@ 2020-12-29 11:12 ` Christophe JAILLET
  0 siblings, 0 replies; 4+ messages in thread
From: Christophe JAILLET @ 2020-12-29 11:12 UTC (permalink / raw)
  To: ogabbay, arnd, gregkh, obitton, lee.jones, ttayar, fkassabri
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET

Axe 'hl_pci_set_dma_mask()' and replace it with an equivalent
'dma_set_mask_and_coherent()' call.

This makes the code a bit less verbose.

It also removes an erroneous comment, because 'hl_pci_set_dma_mask()' does
not try to use a fall-back value.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/misc/habanalabs/common/pci.c | 42 ++++------------------------
 1 file changed, 6 insertions(+), 36 deletions(-)

diff --git a/drivers/misc/habanalabs/common/pci.c b/drivers/misc/habanalabs/common/pci.c
index 923b2606e29f..eb8a784ba863 100644
--- a/drivers/misc/habanalabs/common/pci.c
+++ b/drivers/misc/habanalabs/common/pci.c
@@ -301,40 +301,6 @@ int hl_pci_set_outbound_region(struct hl_device *hdev,
 	return rc;
 }
 
-/**
- * hl_pci_set_dma_mask() - Set DMA masks for the device.
- * @hdev: Pointer to hl_device structure.
- *
- * This function sets the DMA masks (regular and consistent) for a specified
- * value. If it doesn't succeed, it tries to set it to a fall-back value
- *
- * Return: 0 on success, non-zero for failure.
- */
-static int hl_pci_set_dma_mask(struct hl_device *hdev)
-{
-	struct pci_dev *pdev = hdev->pdev;
-	int rc;
-
-	/* set DMA mask */
-	rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(hdev->dma_mask));
-	if (rc) {
-		dev_err(hdev->dev,
-			"Failed to set pci dma mask to %d bits, error %d\n",
-			hdev->dma_mask, rc);
-		return rc;
-	}
-
-	rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(hdev->dma_mask));
-	if (rc) {
-		dev_err(hdev->dev,
-			"Failed to set pci consistent dma mask to %d bits, error %d\n",
-			hdev->dma_mask, rc);
-		return rc;
-	}
-
-	return 0;
-}
-
 /**
  * hl_pci_init() - PCI initialization code.
  * @hdev: Pointer to hl_device structure.
@@ -371,9 +337,13 @@ int hl_pci_init(struct hl_device *hdev)
 		goto unmap_pci_bars;
 	}
 
-	rc = hl_pci_set_dma_mask(hdev);
-	if (rc)
+	rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(hdev->dma_mask));
+	if (rc) {
+		dev_err(hdev->dev,
+			"Failed to set dma mask to %d bits, error %d\n",
+			hdev->dma_mask, rc);
 		goto unmap_pci_bars;
+	}
 
 	return 0;
 
-- 
2.27.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] habanalabs: Use 'dma_set_mask_and_coherent()' instead of hand-writing it
  2020-12-29 11:12 ` Christophe JAILLET
@ 2021-01-05 15:39   ` Oded Gabbay
  -1 siblings, 0 replies; 4+ messages in thread
From: Oded Gabbay @ 2021-01-05 15:39 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Oded Gabbay, Arnd Bergmann, Greg Kroah-Hartman, Ofir Bitton,
	Lee Jones, Tomer Tayar, farah kassabri,
	Linux-Kernel@Vger. Kernel. Org, kernel-janitors

On Tue, Dec 29, 2020 at 1:17 PM Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
>
> Axe 'hl_pci_set_dma_mask()' and replace it with an equivalent
> 'dma_set_mask_and_coherent()' call.
>
> This makes the code a bit less verbose.
>
> It also removes an erroneous comment, because 'hl_pci_set_dma_mask()' does
> not try to use a fall-back value.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/misc/habanalabs/common/pci.c | 42 ++++------------------------
>  1 file changed, 6 insertions(+), 36 deletions(-)
>
> diff --git a/drivers/misc/habanalabs/common/pci.c b/drivers/misc/habanalabs/common/pci.c
> index 923b2606e29f..eb8a784ba863 100644
> --- a/drivers/misc/habanalabs/common/pci.c
> +++ b/drivers/misc/habanalabs/common/pci.c
> @@ -301,40 +301,6 @@ int hl_pci_set_outbound_region(struct hl_device *hdev,
>         return rc;
>  }
>
> -/**
> - * hl_pci_set_dma_mask() - Set DMA masks for the device.
> - * @hdev: Pointer to hl_device structure.
> - *
> - * This function sets the DMA masks (regular and consistent) for a specified
> - * value. If it doesn't succeed, it tries to set it to a fall-back value
> - *
> - * Return: 0 on success, non-zero for failure.
> - */
> -static int hl_pci_set_dma_mask(struct hl_device *hdev)
> -{
> -       struct pci_dev *pdev = hdev->pdev;
> -       int rc;
> -
> -       /* set DMA mask */
> -       rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(hdev->dma_mask));
> -       if (rc) {
> -               dev_err(hdev->dev,
> -                       "Failed to set pci dma mask to %d bits, error %d\n",
> -                       hdev->dma_mask, rc);
> -               return rc;
> -       }
> -
> -       rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(hdev->dma_mask));
> -       if (rc) {
> -               dev_err(hdev->dev,
> -                       "Failed to set pci consistent dma mask to %d bits, error %d\n",
> -                       hdev->dma_mask, rc);
> -               return rc;
> -       }
> -
> -       return 0;
> -}
> -
>  /**
>   * hl_pci_init() - PCI initialization code.
>   * @hdev: Pointer to hl_device structure.
> @@ -371,9 +337,13 @@ int hl_pci_init(struct hl_device *hdev)
>                 goto unmap_pci_bars;
>         }
>
> -       rc = hl_pci_set_dma_mask(hdev);
> -       if (rc)
> +       rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(hdev->dma_mask));
> +       if (rc) {
> +               dev_err(hdev->dev,
> +                       "Failed to set dma mask to %d bits, error %d\n",
> +                       hdev->dma_mask, rc);
>                 goto unmap_pci_bars;
> +       }
>
>         return 0;
>
> --
> 2.27.0
>

Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Applied to -next
Oded

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] habanalabs: Use 'dma_set_mask_and_coherent()' instead of hand-writing it
@ 2021-01-05 15:39   ` Oded Gabbay
  0 siblings, 0 replies; 4+ messages in thread
From: Oded Gabbay @ 2021-01-05 15:39 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Oded Gabbay, Arnd Bergmann, Greg Kroah-Hartman, Ofir Bitton,
	Lee Jones, Tomer Tayar, farah kassabri,
	Linux-Kernel@Vger. Kernel. Org, kernel-janitors

On Tue, Dec 29, 2020 at 1:17 PM Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
>
> Axe 'hl_pci_set_dma_mask()' and replace it with an equivalent
> 'dma_set_mask_and_coherent()' call.
>
> This makes the code a bit less verbose.
>
> It also removes an erroneous comment, because 'hl_pci_set_dma_mask()' does
> not try to use a fall-back value.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/misc/habanalabs/common/pci.c | 42 ++++------------------------
>  1 file changed, 6 insertions(+), 36 deletions(-)
>
> diff --git a/drivers/misc/habanalabs/common/pci.c b/drivers/misc/habanalabs/common/pci.c
> index 923b2606e29f..eb8a784ba863 100644
> --- a/drivers/misc/habanalabs/common/pci.c
> +++ b/drivers/misc/habanalabs/common/pci.c
> @@ -301,40 +301,6 @@ int hl_pci_set_outbound_region(struct hl_device *hdev,
>         return rc;
>  }
>
> -/**
> - * hl_pci_set_dma_mask() - Set DMA masks for the device.
> - * @hdev: Pointer to hl_device structure.
> - *
> - * This function sets the DMA masks (regular and consistent) for a specified
> - * value. If it doesn't succeed, it tries to set it to a fall-back value
> - *
> - * Return: 0 on success, non-zero for failure.
> - */
> -static int hl_pci_set_dma_mask(struct hl_device *hdev)
> -{
> -       struct pci_dev *pdev = hdev->pdev;
> -       int rc;
> -
> -       /* set DMA mask */
> -       rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(hdev->dma_mask));
> -       if (rc) {
> -               dev_err(hdev->dev,
> -                       "Failed to set pci dma mask to %d bits, error %d\n",
> -                       hdev->dma_mask, rc);
> -               return rc;
> -       }
> -
> -       rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(hdev->dma_mask));
> -       if (rc) {
> -               dev_err(hdev->dev,
> -                       "Failed to set pci consistent dma mask to %d bits, error %d\n",
> -                       hdev->dma_mask, rc);
> -               return rc;
> -       }
> -
> -       return 0;
> -}
> -
>  /**
>   * hl_pci_init() - PCI initialization code.
>   * @hdev: Pointer to hl_device structure.
> @@ -371,9 +337,13 @@ int hl_pci_init(struct hl_device *hdev)
>                 goto unmap_pci_bars;
>         }
>
> -       rc = hl_pci_set_dma_mask(hdev);
> -       if (rc)
> +       rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(hdev->dma_mask));
> +       if (rc) {
> +               dev_err(hdev->dev,
> +                       "Failed to set dma mask to %d bits, error %d\n",
> +                       hdev->dma_mask, rc);
>                 goto unmap_pci_bars;
> +       }
>
>         return 0;
>
> --
> 2.27.0
>

Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Applied to -next
Oded

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-01-05 15:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-29 11:12 [PATCH] habanalabs: Use 'dma_set_mask_and_coherent()' instead of hand-writing it Christophe JAILLET
2020-12-29 11:12 ` Christophe JAILLET
2021-01-05 15:39 ` Oded Gabbay
2021-01-05 15:39   ` Oded Gabbay

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.