All of lore.kernel.org
 help / color / mirror / Atom feed
* remove pci_dma_* abuses and workarounds
@ 2018-01-09 20:39 Christoph Hellwig
  2018-01-09 20:39 ` [PATCH 1/3] media/ttusb-budget: remove pci_zalloc_coherent abuse Christoph Hellwig
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Christoph Hellwig @ 2018-01-09 20:39 UTC (permalink / raw)
  To: Bjorn Helgaas, Mauro Carvalho Chehab; +Cc: linux-pci, linux-media, linux-kernel

Back before the dawn of time pci_dma_* with a NULL pci_dev argument
was used for all kinds of things, e.g. dma mapping for non-PCI
devices.  All this has been long removed, but it turns out we
still care for a NULL pci_dev in the wrappers, and we still have
two odd USB drivers that use pci_dma_alloc_consistent for allocating
memory while ignoring the dma_addr_t entirely.

This series switches the two drivers to use plain kzalloc and then
removes the handling of the NULL pci_dev in the pci_dma_* wrappers.

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

* [PATCH 1/3] media/ttusb-budget: remove pci_zalloc_coherent abuse
  2018-01-09 20:39 remove pci_dma_* abuses and workarounds Christoph Hellwig
@ 2018-01-09 20:39 ` Christoph Hellwig
  2018-01-09 20:49   ` Joe Perches
  2018-01-09 23:45   ` Bjorn Helgaas
  2018-01-09 20:39 ` [PATCH 2/3] media/ttusb-dev: " Christoph Hellwig
  2018-01-09 20:39 ` [PATCH 3/3] pci-dma-compat: remove handling of NULL pdev arguments Christoph Hellwig
  2 siblings, 2 replies; 9+ messages in thread
From: Christoph Hellwig @ 2018-01-09 20:39 UTC (permalink / raw)
  To: Bjorn Helgaas, Mauro Carvalho Chehab; +Cc: linux-pci, linux-media, linux-kernel

Switch to a plain kzalloc instea of pci_zalloc_coherent to allocate
memory for the USB DMA.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c
index a142b9dc0feb..b8619fb23351 100644
--- a/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c
+++ b/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c
@@ -102,7 +102,6 @@ struct ttusb {
 	unsigned int isoc_in_pipe;
 
 	void *iso_buffer;
-	dma_addr_t iso_dma_handle;
 
 	struct urb *iso_urb[ISO_BUF_COUNT];
 
@@ -792,21 +791,15 @@ static void ttusb_free_iso_urbs(struct ttusb *ttusb)
 
 	for (i = 0; i < ISO_BUF_COUNT; i++)
 		usb_free_urb(ttusb->iso_urb[i]);
-
-	pci_free_consistent(NULL,
-			    ISO_FRAME_SIZE * FRAMES_PER_ISO_BUF *
-			    ISO_BUF_COUNT, ttusb->iso_buffer,
-			    ttusb->iso_dma_handle);
+	kfree(ttusb->iso_buffer);
 }
 
 static int ttusb_alloc_iso_urbs(struct ttusb *ttusb)
 {
 	int i;
 
-	ttusb->iso_buffer = pci_zalloc_consistent(NULL,
-						  ISO_FRAME_SIZE * FRAMES_PER_ISO_BUF * ISO_BUF_COUNT,
-						  &ttusb->iso_dma_handle);
-
+	ttusb->iso_buffer = kzalloc(ISO_FRAME_SIZE * FRAMES_PER_ISO_BUF *
+			ISO_BUF_COUNT, GFP_KERNEL);
 	if (!ttusb->iso_buffer) {
 		dprintk("%s: pci_alloc_consistent - not enough memory\n",
 			__func__);
-- 
2.14.2

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

* [PATCH 2/3] media/ttusb-dev: remove pci_zalloc_coherent abuse
  2018-01-09 20:39 remove pci_dma_* abuses and workarounds Christoph Hellwig
  2018-01-09 20:39 ` [PATCH 1/3] media/ttusb-budget: remove pci_zalloc_coherent abuse Christoph Hellwig
@ 2018-01-09 20:39 ` Christoph Hellwig
  2018-01-09 20:39 ` [PATCH 3/3] pci-dma-compat: remove handling of NULL pdev arguments Christoph Hellwig
  2 siblings, 0 replies; 9+ messages in thread
From: Christoph Hellwig @ 2018-01-09 20:39 UTC (permalink / raw)
  To: Bjorn Helgaas, Mauro Carvalho Chehab; +Cc: linux-pci, linux-media, linux-kernel

Switch to a plain kzalloc instea of pci_zalloc_coherent to allocate
memory for the USB DMA.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/media/usb/ttusb-dec/ttusb_dec.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/media/usb/ttusb-dec/ttusb_dec.c b/drivers/media/usb/ttusb-dec/ttusb_dec.c
index cdefb5dfbbdc..794ea8a78181 100644
--- a/drivers/media/usb/ttusb-dec/ttusb_dec.c
+++ b/drivers/media/usb/ttusb-dec/ttusb_dec.c
@@ -127,7 +127,6 @@ struct ttusb_dec {
 	struct urb		*irq_urb;
 	dma_addr_t		irq_dma_handle;
 	void			*iso_buffer;
-	dma_addr_t		iso_dma_handle;
 	struct urb		*iso_urb[ISO_BUF_COUNT];
 	int			iso_stream_count;
 	struct mutex		iso_mutex;
@@ -1185,11 +1184,7 @@ static void ttusb_dec_free_iso_urbs(struct ttusb_dec *dec)
 
 	for (i = 0; i < ISO_BUF_COUNT; i++)
 		usb_free_urb(dec->iso_urb[i]);
-
-	pci_free_consistent(NULL,
-			    ISO_FRAME_SIZE * (FRAMES_PER_ISO_BUF *
-					      ISO_BUF_COUNT),
-			    dec->iso_buffer, dec->iso_dma_handle);
+	kfree(dec->iso_buffer);
 }
 
 static int ttusb_dec_alloc_iso_urbs(struct ttusb_dec *dec)
@@ -1198,10 +1193,8 @@ static int ttusb_dec_alloc_iso_urbs(struct ttusb_dec *dec)
 
 	dprintk("%s\n", __func__);
 
-	dec->iso_buffer = pci_zalloc_consistent(NULL,
-						ISO_FRAME_SIZE * (FRAMES_PER_ISO_BUF * ISO_BUF_COUNT),
-						&dec->iso_dma_handle);
-
+	dec->iso_buffer = kzalloc(ISO_FRAME_SIZE *
+			(FRAMES_PER_ISO_BUF * ISO_BUF_COUNT), GFP_KERNEL);
 	if (!dec->iso_buffer) {
 		dprintk("%s: pci_alloc_consistent - not enough memory\n",
 			__func__);
-- 
2.14.2

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

* [PATCH 3/3] pci-dma-compat: remove handling of NULL pdev arguments
  2018-01-09 20:39 remove pci_dma_* abuses and workarounds Christoph Hellwig
  2018-01-09 20:39 ` [PATCH 1/3] media/ttusb-budget: remove pci_zalloc_coherent abuse Christoph Hellwig
  2018-01-09 20:39 ` [PATCH 2/3] media/ttusb-dev: " Christoph Hellwig
@ 2018-01-09 20:39 ` Christoph Hellwig
  2018-01-10  0:25   ` Bjorn Helgaas
  2 siblings, 1 reply; 9+ messages in thread
From: Christoph Hellwig @ 2018-01-09 20:39 UTC (permalink / raw)
  To: Bjorn Helgaas, Mauro Carvalho Chehab; +Cc: linux-pci, linux-media, linux-kernel

Historically some ISA drivers used the old pci DMA API with a NULL pdev
argument, but these days this isn't used and not too useful due to the
per-device DMA ops, so remove it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 include/linux/pci-dma-compat.h | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/include/linux/pci-dma-compat.h b/include/linux/pci-dma-compat.h
index d1f9fdade1e0..0dd1a3f7b309 100644
--- a/include/linux/pci-dma-compat.h
+++ b/include/linux/pci-dma-compat.h
@@ -17,91 +17,90 @@ static inline void *
 pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
 		     dma_addr_t *dma_handle)
 {
-	return dma_alloc_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, dma_handle, GFP_ATOMIC);
+	return dma_alloc_coherent(&hwdev->dev, size, dma_handle, GFP_ATOMIC);
 }
 
 static inline void *
 pci_zalloc_consistent(struct pci_dev *hwdev, size_t size,
 		      dma_addr_t *dma_handle)
 {
-	return dma_zalloc_coherent(hwdev == NULL ? NULL : &hwdev->dev,
-				   size, dma_handle, GFP_ATOMIC);
+	return dma_zalloc_coherent(&hwdev->dev, size, dma_handle, GFP_ATOMIC);
 }
 
 static inline void
 pci_free_consistent(struct pci_dev *hwdev, size_t size,
 		    void *vaddr, dma_addr_t dma_handle)
 {
-	dma_free_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, vaddr, dma_handle);
+	dma_free_coherent(&hwdev->dev, size, vaddr, dma_handle);
 }
 
 static inline dma_addr_t
 pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size, int direction)
 {
-	return dma_map_single(hwdev == NULL ? NULL : &hwdev->dev, ptr, size, (enum dma_data_direction)direction);
+	return dma_map_single(&hwdev->dev, ptr, size, (enum dma_data_direction)direction);
 }
 
 static inline void
 pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr,
 		 size_t size, int direction)
 {
-	dma_unmap_single(hwdev == NULL ? NULL : &hwdev->dev, dma_addr, size, (enum dma_data_direction)direction);
+	dma_unmap_single(&hwdev->dev, dma_addr, size, (enum dma_data_direction)direction);
 }
 
 static inline dma_addr_t
 pci_map_page(struct pci_dev *hwdev, struct page *page,
 	     unsigned long offset, size_t size, int direction)
 {
-	return dma_map_page(hwdev == NULL ? NULL : &hwdev->dev, page, offset, size, (enum dma_data_direction)direction);
+	return dma_map_page(&hwdev->dev, page, offset, size, (enum dma_data_direction)direction);
 }
 
 static inline void
 pci_unmap_page(struct pci_dev *hwdev, dma_addr_t dma_address,
 	       size_t size, int direction)
 {
-	dma_unmap_page(hwdev == NULL ? NULL : &hwdev->dev, dma_address, size, (enum dma_data_direction)direction);
+	dma_unmap_page(&hwdev->dev, dma_address, size, (enum dma_data_direction)direction);
 }
 
 static inline int
 pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg,
 	   int nents, int direction)
 {
-	return dma_map_sg(hwdev == NULL ? NULL : &hwdev->dev, sg, nents, (enum dma_data_direction)direction);
+	return dma_map_sg(&hwdev->dev, sg, nents, (enum dma_data_direction)direction);
 }
 
 static inline void
 pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg,
 	     int nents, int direction)
 {
-	dma_unmap_sg(hwdev == NULL ? NULL : &hwdev->dev, sg, nents, (enum dma_data_direction)direction);
+	dma_unmap_sg(&hwdev->dev, sg, nents, (enum dma_data_direction)direction);
 }
 
 static inline void
 pci_dma_sync_single_for_cpu(struct pci_dev *hwdev, dma_addr_t dma_handle,
 		    size_t size, int direction)
 {
-	dma_sync_single_for_cpu(hwdev == NULL ? NULL : &hwdev->dev, dma_handle, size, (enum dma_data_direction)direction);
+	dma_sync_single_for_cpu(&hwdev->dev, dma_handle, size, (enum dma_data_direction)direction);
 }
 
 static inline void
 pci_dma_sync_single_for_device(struct pci_dev *hwdev, dma_addr_t dma_handle,
 		    size_t size, int direction)
 {
-	dma_sync_single_for_device(hwdev == NULL ? NULL : &hwdev->dev, dma_handle, size, (enum dma_data_direction)direction);
+	dma_sync_single_for_device(&hwdev->dev, dma_handle, size, (enum dma_data_direction)direction);
 }
 
 static inline void
 pci_dma_sync_sg_for_cpu(struct pci_dev *hwdev, struct scatterlist *sg,
 		int nelems, int direction)
 {
-	dma_sync_sg_for_cpu(hwdev == NULL ? NULL : &hwdev->dev, sg, nelems, (enum dma_data_direction)direction);
+	dma_sync_sg_for_cpu(&hwdev->dev, sg, nelems, (enum dma_data_direction)direction);
 }
 
 static inline void
 pci_dma_sync_sg_for_device(struct pci_dev *hwdev, struct scatterlist *sg,
 		int nelems, int direction)
 {
-	dma_sync_sg_for_device(hwdev == NULL ? NULL : &hwdev->dev, sg, nelems, (enum dma_data_direction)direction);
+	dma_sync_sg_for_device(&hwdev->dev, sg, nelems, (enum dma_data_direction)direction);
 }
 
 static inline int
-- 
2.14.2

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

* Re: [PATCH 1/3] media/ttusb-budget: remove pci_zalloc_coherent abuse
  2018-01-09 20:39 ` [PATCH 1/3] media/ttusb-budget: remove pci_zalloc_coherent abuse Christoph Hellwig
@ 2018-01-09 20:49   ` Joe Perches
  2018-01-10  8:17     ` Christoph Hellwig
  2018-01-09 23:45   ` Bjorn Helgaas
  1 sibling, 1 reply; 9+ messages in thread
From: Joe Perches @ 2018-01-09 20:49 UTC (permalink / raw)
  To: Christoph Hellwig, Bjorn Helgaas, Mauro Carvalho Chehab
  Cc: linux-pci, linux-media, linux-kernel

On Tue, 2018-01-09 at 21:39 +0100, Christoph Hellwig wrote:
> Switch to a plain kzalloc instea of pci_zalloc_coherent to allocate
> memory for the USB DMA.
[]
> diff --git a/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c
[]
> @@ -792,21 +791,15 @@ static void ttusb_free_iso_urbs(struct ttusb *ttusb)
> []
>  static int ttusb_alloc_iso_urbs(struct ttusb *ttusb)
>  {
>  	int i;
>  
> -	ttusb->iso_buffer = pci_zalloc_consistent(NULL,
> -						  ISO_FRAME_SIZE * FRAMES_PER_ISO_BUF * ISO_BUF_COUNT,
> -						  &ttusb->iso_dma_handle);
> -
> +	ttusb->iso_buffer = kzalloc(ISO_FRAME_SIZE * FRAMES_PER_ISO_BUF *
> +			ISO_BUF_COUNT, GFP_KERNEL);
>  	if (!ttusb->iso_buffer) {
>  		dprintk("%s: pci_alloc_consistent - not enough memory\n",
>  			__func__);

This message doesn't make sense anymore and it might as well
be deleted.

And it might be better to use kcalloc

	ttusb->iso_buffer = kcalloc(FRAMES_PER_ISO_BUF * ISO_BUF_COUNT,
				    ISO_FRAME_SIZE, GFP_KERNEL);

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

* Re: [PATCH 1/3] media/ttusb-budget: remove pci_zalloc_coherent abuse
  2018-01-09 20:39 ` [PATCH 1/3] media/ttusb-budget: remove pci_zalloc_coherent abuse Christoph Hellwig
  2018-01-09 20:49   ` Joe Perches
@ 2018-01-09 23:45   ` Bjorn Helgaas
  1 sibling, 0 replies; 9+ messages in thread
From: Bjorn Helgaas @ 2018-01-09 23:45 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Bjorn Helgaas, Mauro Carvalho Chehab, linux-pci, linux-media,
	linux-kernel

On Tue, Jan 09, 2018 at 09:39:37PM +0100, Christoph Hellwig wrote:
> Switch to a plain kzalloc instea of pci_zalloc_coherent to allocate
> memory for the USB DMA.

s/instea/instead/

> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c | 13 +++----------
>  1 file changed, 3 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c
> index a142b9dc0feb..b8619fb23351 100644
> --- a/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c
> +++ b/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c
> @@ -102,7 +102,6 @@ struct ttusb {
>  	unsigned int isoc_in_pipe;
>  
>  	void *iso_buffer;
> -	dma_addr_t iso_dma_handle;
>  
>  	struct urb *iso_urb[ISO_BUF_COUNT];
>  
> @@ -792,21 +791,15 @@ static void ttusb_free_iso_urbs(struct ttusb *ttusb)
>  
>  	for (i = 0; i < ISO_BUF_COUNT; i++)
>  		usb_free_urb(ttusb->iso_urb[i]);
> -
> -	pci_free_consistent(NULL,
> -			    ISO_FRAME_SIZE * FRAMES_PER_ISO_BUF *
> -			    ISO_BUF_COUNT, ttusb->iso_buffer,
> -			    ttusb->iso_dma_handle);
> +	kfree(ttusb->iso_buffer);
>  }
>  
>  static int ttusb_alloc_iso_urbs(struct ttusb *ttusb)
>  {
>  	int i;
>  
> -	ttusb->iso_buffer = pci_zalloc_consistent(NULL,
> -						  ISO_FRAME_SIZE * FRAMES_PER_ISO_BUF * ISO_BUF_COUNT,
> -						  &ttusb->iso_dma_handle);
> -
> +	ttusb->iso_buffer = kzalloc(ISO_FRAME_SIZE * FRAMES_PER_ISO_BUF *
> +			ISO_BUF_COUNT, GFP_KERNEL);
>  	if (!ttusb->iso_buffer) {
>  		dprintk("%s: pci_alloc_consistent - not enough memory\n",
>  			__func__);
> -- 
> 2.14.2
> 

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

* Re: [PATCH 3/3] pci-dma-compat: remove handling of NULL pdev arguments
  2018-01-09 20:39 ` [PATCH 3/3] pci-dma-compat: remove handling of NULL pdev arguments Christoph Hellwig
@ 2018-01-10  0:25   ` Bjorn Helgaas
  2018-01-10  8:14     ` Christoph Hellwig
  0 siblings, 1 reply; 9+ messages in thread
From: Bjorn Helgaas @ 2018-01-10  0:25 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Bjorn Helgaas, Mauro Carvalho Chehab, linux-pci, linux-media,
	linux-kernel

s/pci-dma-compat: remove handling of NULL pdev
 /PCI: Remove NULL device handling from DMA API/

On Tue, Jan 09, 2018 at 09:39:39PM +0100, Christoph Hellwig wrote:
> Historically some ISA drivers used the old pci DMA API with a NULL pdev
> argument, but these days this isn't used and not too useful due to the
> per-device DMA ops, so remove it.

s/pci/PCI/

I like this a lot, thanks!

It looks like "pci_free_consistent(NULL" is still used in
drivers/net/ethernet/tundra/tsi108_eth.c.

> Signed-off-by: Christoph Hellwig <hch@lst.de>

With Mauro's ack on the media/ttusb-dev patches, I could merge the
whole series via the PCI tree?

> ---
>  include/linux/pci-dma-compat.h | 27 +++++++++++++--------------
>  1 file changed, 13 insertions(+), 14 deletions(-)
> 
> diff --git a/include/linux/pci-dma-compat.h b/include/linux/pci-dma-compat.h
> index d1f9fdade1e0..0dd1a3f7b309 100644
> --- a/include/linux/pci-dma-compat.h
> +++ b/include/linux/pci-dma-compat.h
> @@ -17,91 +17,90 @@ static inline void *
>  pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
>  		     dma_addr_t *dma_handle)
>  {
> -	return dma_alloc_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, dma_handle, GFP_ATOMIC);
> +	return dma_alloc_coherent(&hwdev->dev, size, dma_handle, GFP_ATOMIC);
>  }
>  
>  static inline void *
>  pci_zalloc_consistent(struct pci_dev *hwdev, size_t size,
>  		      dma_addr_t *dma_handle)
>  {
> -	return dma_zalloc_coherent(hwdev == NULL ? NULL : &hwdev->dev,
> -				   size, dma_handle, GFP_ATOMIC);
> +	return dma_zalloc_coherent(&hwdev->dev, size, dma_handle, GFP_ATOMIC);
>  }
>  
>  static inline void
>  pci_free_consistent(struct pci_dev *hwdev, size_t size,
>  		    void *vaddr, dma_addr_t dma_handle)
>  {
> -	dma_free_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, vaddr, dma_handle);
> +	dma_free_coherent(&hwdev->dev, size, vaddr, dma_handle);
>  }
>  
>  static inline dma_addr_t
>  pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size, int direction)
>  {
> -	return dma_map_single(hwdev == NULL ? NULL : &hwdev->dev, ptr, size, (enum dma_data_direction)direction);
> +	return dma_map_single(&hwdev->dev, ptr, size, (enum dma_data_direction)direction);
>  }
>  
>  static inline void
>  pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr,
>  		 size_t size, int direction)
>  {
> -	dma_unmap_single(hwdev == NULL ? NULL : &hwdev->dev, dma_addr, size, (enum dma_data_direction)direction);
> +	dma_unmap_single(&hwdev->dev, dma_addr, size, (enum dma_data_direction)direction);
>  }
>  
>  static inline dma_addr_t
>  pci_map_page(struct pci_dev *hwdev, struct page *page,
>  	     unsigned long offset, size_t size, int direction)
>  {
> -	return dma_map_page(hwdev == NULL ? NULL : &hwdev->dev, page, offset, size, (enum dma_data_direction)direction);
> +	return dma_map_page(&hwdev->dev, page, offset, size, (enum dma_data_direction)direction);
>  }
>  
>  static inline void
>  pci_unmap_page(struct pci_dev *hwdev, dma_addr_t dma_address,
>  	       size_t size, int direction)
>  {
> -	dma_unmap_page(hwdev == NULL ? NULL : &hwdev->dev, dma_address, size, (enum dma_data_direction)direction);
> +	dma_unmap_page(&hwdev->dev, dma_address, size, (enum dma_data_direction)direction);
>  }
>  
>  static inline int
>  pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg,
>  	   int nents, int direction)
>  {
> -	return dma_map_sg(hwdev == NULL ? NULL : &hwdev->dev, sg, nents, (enum dma_data_direction)direction);
> +	return dma_map_sg(&hwdev->dev, sg, nents, (enum dma_data_direction)direction);
>  }
>  
>  static inline void
>  pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg,
>  	     int nents, int direction)
>  {
> -	dma_unmap_sg(hwdev == NULL ? NULL : &hwdev->dev, sg, nents, (enum dma_data_direction)direction);
> +	dma_unmap_sg(&hwdev->dev, sg, nents, (enum dma_data_direction)direction);
>  }
>  
>  static inline void
>  pci_dma_sync_single_for_cpu(struct pci_dev *hwdev, dma_addr_t dma_handle,
>  		    size_t size, int direction)
>  {
> -	dma_sync_single_for_cpu(hwdev == NULL ? NULL : &hwdev->dev, dma_handle, size, (enum dma_data_direction)direction);
> +	dma_sync_single_for_cpu(&hwdev->dev, dma_handle, size, (enum dma_data_direction)direction);
>  }
>  
>  static inline void
>  pci_dma_sync_single_for_device(struct pci_dev *hwdev, dma_addr_t dma_handle,
>  		    size_t size, int direction)
>  {
> -	dma_sync_single_for_device(hwdev == NULL ? NULL : &hwdev->dev, dma_handle, size, (enum dma_data_direction)direction);
> +	dma_sync_single_for_device(&hwdev->dev, dma_handle, size, (enum dma_data_direction)direction);
>  }
>  
>  static inline void
>  pci_dma_sync_sg_for_cpu(struct pci_dev *hwdev, struct scatterlist *sg,
>  		int nelems, int direction)
>  {
> -	dma_sync_sg_for_cpu(hwdev == NULL ? NULL : &hwdev->dev, sg, nelems, (enum dma_data_direction)direction);
> +	dma_sync_sg_for_cpu(&hwdev->dev, sg, nelems, (enum dma_data_direction)direction);
>  }
>  
>  static inline void
>  pci_dma_sync_sg_for_device(struct pci_dev *hwdev, struct scatterlist *sg,
>  		int nelems, int direction)
>  {
> -	dma_sync_sg_for_device(hwdev == NULL ? NULL : &hwdev->dev, sg, nelems, (enum dma_data_direction)direction);
> +	dma_sync_sg_for_device(&hwdev->dev, sg, nelems, (enum dma_data_direction)direction);
>  }
>  
>  static inline int
> -- 
> 2.14.2
> 

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

* Re: [PATCH 3/3] pci-dma-compat: remove handling of NULL pdev arguments
  2018-01-10  0:25   ` Bjorn Helgaas
@ 2018-01-10  8:14     ` Christoph Hellwig
  0 siblings, 0 replies; 9+ messages in thread
From: Christoph Hellwig @ 2018-01-10  8:14 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Christoph Hellwig, Bjorn Helgaas, Mauro Carvalho Chehab,
	linux-pci, linux-media, linux-kernel

On Tue, Jan 09, 2018 at 06:25:44PM -0600, Bjorn Helgaas wrote:
> It looks like "pci_free_consistent(NULL" is still used in
> drivers/net/ethernet/tundra/tsi108_eth.c.

Yikes.  That one needs to pass the device is the platform dev to
the dma_map_* routines to start with, and mixing that with PCI
is pretty horrible.  I'll add a conversion of that driver to the
next resend.

> > Signed-off-by: Christoph Hellwig <hch@lst.de>
> 
> With Mauro's ack on the media/ttusb-dev patches, I could merge the
> whole series via the PCI tree?

Fine with me.

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

* Re: [PATCH 1/3] media/ttusb-budget: remove pci_zalloc_coherent abuse
  2018-01-09 20:49   ` Joe Perches
@ 2018-01-10  8:17     ` Christoph Hellwig
  0 siblings, 0 replies; 9+ messages in thread
From: Christoph Hellwig @ 2018-01-10  8:17 UTC (permalink / raw)
  To: Joe Perches
  Cc: Christoph Hellwig, Bjorn Helgaas, Mauro Carvalho Chehab,
	linux-pci, linux-media, linux-kernel

On Tue, Jan 09, 2018 at 12:49:26PM -0800, Joe Perches wrote:
> This message doesn't make sense anymore and it might as well
> be deleted.
> 
> And it might be better to use kcalloc
> 
> 	ttusb->iso_buffer = kcalloc(FRAMES_PER_ISO_BUF * ISO_BUF_COUNT,
> 				    ISO_FRAME_SIZE, GFP_KERNEL);

Sure.

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

end of thread, other threads:[~2018-01-10  8:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-09 20:39 remove pci_dma_* abuses and workarounds Christoph Hellwig
2018-01-09 20:39 ` [PATCH 1/3] media/ttusb-budget: remove pci_zalloc_coherent abuse Christoph Hellwig
2018-01-09 20:49   ` Joe Perches
2018-01-10  8:17     ` Christoph Hellwig
2018-01-09 23:45   ` Bjorn Helgaas
2018-01-09 20:39 ` [PATCH 2/3] media/ttusb-dev: " Christoph Hellwig
2018-01-09 20:39 ` [PATCH 3/3] pci-dma-compat: remove handling of NULL pdev arguments Christoph Hellwig
2018-01-10  0:25   ` Bjorn Helgaas
2018-01-10  8:14     ` Christoph Hellwig

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.