* [PATCH v2 1/5] dma-mapping: Convert NO_DMA get_dma_ops() into a real dummy
2018-03-16 13:25 [PATCH v2 0/5] Allow compile-testing NO_DMA (core) Geert Uytterhoeven
@ 2018-03-16 13:25 ` Geert Uytterhoeven
2018-03-16 13:25 ` [PATCH v2 2/5] dma-coherent: Add NO_DMA dummies for managed DMA API Geert Uytterhoeven
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Geert Uytterhoeven @ 2018-03-16 13:25 UTC (permalink / raw)
To: Christoph Hellwig, Marek Szyprowski, Robin Murphy, Felipe Balbi,
Greg Kroah-Hartman, James E . J . Bottomley, Martin K . Petersen,
Andrew Morton
Cc: iommu, linux-usb, linux-scsi, linux-kernel, Geert Uytterhoeven
If NO_DMA=y, get_dma_ops() returns a reference to the
non-existing symbol bad_dma_ops, thus causing a link failure if it is
ever used.
Make get_dma_ops() return NULL instead, to avoid the link failure.
This allows to improve compile-testing, and limits the need to keep on
sprinkling dependencies on HAS_DMA all over the place.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Mark Brown <broonie@kernel.org>
Acked-by: Robin Murphy <robin.murphy@arm.com>
---
v2:
- Add Reviewed-by, Acked-by,
- Drop RFC state.
---
include/linux/dma-mapping.h | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index eb9eab4ecd6d7a05..5ea7eec83c0fbb82 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -212,14 +212,14 @@ static inline void set_dma_ops(struct device *dev,
}
#else
/*
- * Define the dma api to allow compilation but not linking of
- * dma dependent code. Code that depends on the dma-mapping
- * API needs to set 'depends on HAS_DMA' in its Kconfig
+ * Define the dma api to allow compilation of dma dependent code.
+ * Code that depends on the dma-mapping API needs to set 'depends on HAS_DMA'
+ * in its Kconfig, unless it already depends on <something> || COMPILE_TEST,
+ * where <something> guarantuees the availability of the dma-mapping API.
*/
-extern const struct dma_map_ops bad_dma_ops;
static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
{
- return &bad_dma_ops;
+ return NULL;
}
#endif
--
2.7.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 2/5] dma-coherent: Add NO_DMA dummies for managed DMA API
2018-03-16 13:25 [PATCH v2 0/5] Allow compile-testing NO_DMA (core) Geert Uytterhoeven
2018-03-16 13:25 ` [PATCH v2 1/5] dma-mapping: Convert NO_DMA get_dma_ops() into a real dummy Geert Uytterhoeven
@ 2018-03-16 13:25 ` Geert Uytterhoeven
2018-03-16 13:25 ` [PATCH v2 3/5] usb: gadget: Add NO_DMA dummies for DMA mapping API Geert Uytterhoeven
` (3 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Geert Uytterhoeven @ 2018-03-16 13:25 UTC (permalink / raw)
To: Christoph Hellwig, Marek Szyprowski, Robin Murphy, Felipe Balbi,
Greg Kroah-Hartman, James E . J . Bottomley, Martin K . Petersen,
Andrew Morton
Cc: iommu, linux-usb, linux-scsi, linux-kernel, Geert Uytterhoeven
Add dummies for dmam_{alloc,free}_coherent(), to allow compile-testing
if NO_DMA=y.
This prevents the following from showing up later:
ERROR: "dmam_alloc_coherent" [drivers/net/ethernet/arc/arc_emac.ko] undefined!
ERROR: "dmam_free_coherent" [drivers/net/ethernet/apm/xgene/xgene-enet.ko] undefined!
ERROR: "dmam_alloc_coherent" [drivers/net/ethernet/apm/xgene/xgene-enet.ko] undefined!
ERROR: "dmam_alloc_coherent" [drivers/mtd/nand/hisi504_nand.ko] undefined!
ERROR: "dmam_alloc_coherent" [drivers/mmc/host/dw_mmc.ko] undefined!
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Mark Brown <broonie@kernel.org>
Acked-by: Robin Murphy <robin.murphy@arm.com>
---
v2:
- Add Reviewed-by, Acked-by,
- Drop RFC state.
---
include/linux/dma-mapping.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 5ea7eec83c0fbb82..94f41846b933fca7 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -776,10 +776,19 @@ static inline void dma_deconfigure(struct device *dev) {}
/*
* Managed DMA API
*/
+#ifdef CONFIG_HAS_DMA
extern void *dmam_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *dma_handle, gfp_t gfp);
extern void dmam_free_coherent(struct device *dev, size_t size, void *vaddr,
dma_addr_t dma_handle);
+#else /* !CONFIG_HAS_DMA */
+static inline void *dmam_alloc_coherent(struct device *dev, size_t size,
+ dma_addr_t *dma_handle, gfp_t gfp)
+{ return NULL; }
+static inline void dmam_free_coherent(struct device *dev, size_t size,
+ void *vaddr, dma_addr_t dma_handle) { }
+#endif /* !CONFIG_HAS_DMA */
+
extern void *dmam_alloc_attrs(struct device *dev, size_t size,
dma_addr_t *dma_handle, gfp_t gfp,
unsigned long attrs);
--
2.7.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 3/5] usb: gadget: Add NO_DMA dummies for DMA mapping API
2018-03-16 13:25 [PATCH v2 0/5] Allow compile-testing NO_DMA (core) Geert Uytterhoeven
2018-03-16 13:25 ` [PATCH v2 1/5] dma-mapping: Convert NO_DMA get_dma_ops() into a real dummy Geert Uytterhoeven
2018-03-16 13:25 ` [PATCH v2 2/5] dma-coherent: Add NO_DMA dummies for managed DMA API Geert Uytterhoeven
@ 2018-03-16 13:25 ` Geert Uytterhoeven
2018-03-16 14:34 ` Greg Kroah-Hartman
2018-03-16 13:25 ` [PATCH v2 4/5] mm: Add NO_DMA dummies for DMA pool API Geert Uytterhoeven
` (2 subsequent siblings)
5 siblings, 1 reply; 8+ messages in thread
From: Geert Uytterhoeven @ 2018-03-16 13:25 UTC (permalink / raw)
To: Christoph Hellwig, Marek Szyprowski, Robin Murphy, Felipe Balbi,
Greg Kroah-Hartman, James E . J . Bottomley, Martin K . Petersen,
Andrew Morton
Cc: iommu, linux-usb, linux-scsi, linux-kernel, Geert Uytterhoeven
Add dummies for usb_gadget_{,un}map_request{,_by_dev}(), to allow
compile-testing if NO_DMA=y.
This prevents the following from showing up later:
ERROR: "usb_gadget_unmap_request_by_dev" [drivers/usb/renesas_usbhs/renesas_usbhs.ko] undefined!
ERROR: "usb_gadget_map_request_by_dev" [drivers/usb/renesas_usbhs/renesas_usbhs.ko] undefined!
ERROR: "usb_gadget_map_request" [drivers/usb/mtu3/mtu3.ko] undefined!
ERROR: "usb_gadget_unmap_request" [drivers/usb/mtu3/mtu3.ko] undefined!
ERROR: "usb_gadget_map_request" [drivers/usb/gadget/udc/renesas_usb3.ko] undefined!
ERROR: "usb_gadget_unmap_request" [drivers/usb/gadget/udc/renesas_usb3.ko] undefined!
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Mark Brown <broonie@kernel.org>
Acked-by: Robin Murphy <robin.murphy@arm.com>
Acked-by: Felipe Balbi <felipe.balbi@linux.intel.com>
---
v2:
- Add Reviewed-by, Acked-by,
- Drop RFC state.
---
include/linux/usb/gadget.h | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index 66a5cff7ee142d6a..b68e7f9b210be122 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -805,6 +805,7 @@ int usb_otg_descriptor_init(struct usb_gadget *gadget,
/* utility to simplify map/unmap of usb_requests to/from DMA */
+#ifdef CONFIG_HAS_DMA
extern int usb_gadget_map_request_by_dev(struct device *dev,
struct usb_request *req, int is_in);
extern int usb_gadget_map_request(struct usb_gadget *gadget,
@@ -814,6 +815,17 @@ extern void usb_gadget_unmap_request_by_dev(struct device *dev,
struct usb_request *req, int is_in);
extern void usb_gadget_unmap_request(struct usb_gadget *gadget,
struct usb_request *req, int is_in);
+#else /* !CONFIG_HAS_DMA */
+static inline int usb_gadget_map_request_by_dev(struct device *dev,
+ struct usb_request *req, int is_in) { return -ENOSYS; }
+static inline int usb_gadget_map_request(struct usb_gadget *gadget,
+ struct usb_request *req, int is_in) { return -ENOSYS; }
+
+static inline void usb_gadget_unmap_request_by_dev(struct device *dev,
+ struct usb_request *req, int is_in) { }
+static inline void usb_gadget_unmap_request(struct usb_gadget *gadget,
+ struct usb_request *req, int is_in) { }
+#endif /* !CONFIG_HAS_DMA */
/*-------------------------------------------------------------------------*/
--
2.7.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 3/5] usb: gadget: Add NO_DMA dummies for DMA mapping API
2018-03-16 13:25 ` [PATCH v2 3/5] usb: gadget: Add NO_DMA dummies for DMA mapping API Geert Uytterhoeven
@ 2018-03-16 14:34 ` Greg Kroah-Hartman
0 siblings, 0 replies; 8+ messages in thread
From: Greg Kroah-Hartman @ 2018-03-16 14:34 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Christoph Hellwig, Marek Szyprowski, Robin Murphy, Felipe Balbi,
James E . J . Bottomley, Martin K . Petersen, Andrew Morton,
iommu, linux-usb, linux-scsi, linux-kernel
On Fri, Mar 16, 2018 at 02:25:42PM +0100, Geert Uytterhoeven wrote:
> Add dummies for usb_gadget_{,un}map_request{,_by_dev}(), to allow
> compile-testing if NO_DMA=y.
>
> This prevents the following from showing up later:
>
> ERROR: "usb_gadget_unmap_request_by_dev" [drivers/usb/renesas_usbhs/renesas_usbhs.ko] undefined!
> ERROR: "usb_gadget_map_request_by_dev" [drivers/usb/renesas_usbhs/renesas_usbhs.ko] undefined!
> ERROR: "usb_gadget_map_request" [drivers/usb/mtu3/mtu3.ko] undefined!
> ERROR: "usb_gadget_unmap_request" [drivers/usb/mtu3/mtu3.ko] undefined!
> ERROR: "usb_gadget_map_request" [drivers/usb/gadget/udc/renesas_usb3.ko] undefined!
> ERROR: "usb_gadget_unmap_request" [drivers/usb/gadget/udc/renesas_usb3.ko] undefined!
>
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Reviewed-by: Mark Brown <broonie@kernel.org>
> Acked-by: Robin Murphy <robin.murphy@arm.com>
> Acked-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 4/5] mm: Add NO_DMA dummies for DMA pool API
2018-03-16 13:25 [PATCH v2 0/5] Allow compile-testing NO_DMA (core) Geert Uytterhoeven
` (2 preceding siblings ...)
2018-03-16 13:25 ` [PATCH v2 3/5] usb: gadget: Add NO_DMA dummies for DMA mapping API Geert Uytterhoeven
@ 2018-03-16 13:25 ` Geert Uytterhoeven
2018-03-16 13:25 ` [PATCH v2 5/5] scsi: Add NO_DMA dummies for SCSI DMA mapping API Geert Uytterhoeven
2018-03-16 18:59 ` [PATCH v2 0/5] Allow compile-testing NO_DMA (core) Christoph Hellwig
5 siblings, 0 replies; 8+ messages in thread
From: Geert Uytterhoeven @ 2018-03-16 13:25 UTC (permalink / raw)
To: Christoph Hellwig, Marek Szyprowski, Robin Murphy, Felipe Balbi,
Greg Kroah-Hartman, James E . J . Bottomley, Martin K . Petersen,
Andrew Morton
Cc: iommu, linux-usb, linux-scsi, linux-kernel, Geert Uytterhoeven
Add dummies for dma{,m}_pool_{create,destroy,alloc,free}(), to allow
compile-testing if NO_DMA=y.
This prevents the following from showing up later:
ERROR: "dma_pool_destroy" [drivers/usb/mtu3/mtu3.ko] undefined!
ERROR: "dma_pool_free" [drivers/usb/mtu3/mtu3.ko] undefined!
ERROR: "dma_pool_alloc" [drivers/usb/mtu3/mtu3.ko] undefined!
ERROR: "dma_pool_create" [drivers/usb/mtu3/mtu3.ko] undefined!
ERROR: "dma_pool_destroy" [drivers/scsi/hisi_sas/hisi_sas_main.ko] undefined!
ERROR: "dma_pool_free" [drivers/scsi/hisi_sas/hisi_sas_main.ko] undefined!
ERROR: "dma_pool_alloc" [drivers/scsi/hisi_sas/hisi_sas_main.ko] undefined!
ERROR: "dma_pool_create" [drivers/scsi/hisi_sas/hisi_sas_main.ko] undefined!
ERROR: "dma_pool_alloc" [drivers/mailbox/bcm-pdc-mailbox.ko] undefined!
ERROR: "dma_pool_free" [drivers/mailbox/bcm-pdc-mailbox.ko] undefined!
ERROR: "dma_pool_create" [drivers/mailbox/bcm-pdc-mailbox.ko] undefined!
ERROR: "dma_pool_destroy" [drivers/mailbox/bcm-pdc-mailbox.ko] undefined!
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Mark Brown <broonie@kernel.org>
Acked-by: Robin Murphy <robin.murphy@arm.com>
---
v2:
- Add Reviewed-by, Acked-by,
- Drop RFC state,
- Group NO_DMA-stubs under a single #ifdef,
- Move dma_pool_zalloc() definition down.
---
include/linux/dmapool.h | 30 +++++++++++++++++++++++-------
1 file changed, 23 insertions(+), 7 deletions(-)
diff --git a/include/linux/dmapool.h b/include/linux/dmapool.h
index 53ba737505df31c7..f632ecfb4238404e 100644
--- a/include/linux/dmapool.h
+++ b/include/linux/dmapool.h
@@ -16,6 +16,8 @@
struct device;
+#ifdef CONFIG_HAS_DMA
+
struct dma_pool *dma_pool_create(const char *name, struct device *dev,
size_t size, size_t align, size_t allocation);
@@ -23,13 +25,6 @@ void dma_pool_destroy(struct dma_pool *pool);
void *dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags,
dma_addr_t *handle);
-
-static inline void *dma_pool_zalloc(struct dma_pool *pool, gfp_t mem_flags,
- dma_addr_t *handle)
-{
- return dma_pool_alloc(pool, mem_flags | __GFP_ZERO, handle);
-}
-
void dma_pool_free(struct dma_pool *pool, void *vaddr, dma_addr_t addr);
/*
@@ -39,5 +34,26 @@ struct dma_pool *dmam_pool_create(const char *name, struct device *dev,
size_t size, size_t align, size_t allocation);
void dmam_pool_destroy(struct dma_pool *pool);
+#else /* !CONFIG_HAS_DMA */
+static inline struct dma_pool *dma_pool_create(const char *name,
+ struct device *dev, size_t size, size_t align, size_t allocation)
+{ return NULL; }
+static inline void dma_pool_destroy(struct dma_pool *pool) { }
+static inline void *dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags,
+ dma_addr_t *handle) { return NULL; }
+static inline void dma_pool_free(struct dma_pool *pool, void *vaddr,
+ dma_addr_t addr) { }
+static inline struct dma_pool *dmam_pool_create(const char *name,
+ struct device *dev, size_t size, size_t align, size_t allocation)
+{ return NULL; }
+static inline void dmam_pool_destroy(struct dma_pool *pool) { }
+#endif /* !CONFIG_HAS_DMA */
+
+static inline void *dma_pool_zalloc(struct dma_pool *pool, gfp_t mem_flags,
+ dma_addr_t *handle)
+{
+ return dma_pool_alloc(pool, mem_flags | __GFP_ZERO, handle);
+}
+
#endif
--
2.7.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 5/5] scsi: Add NO_DMA dummies for SCSI DMA mapping API
2018-03-16 13:25 [PATCH v2 0/5] Allow compile-testing NO_DMA (core) Geert Uytterhoeven
` (3 preceding siblings ...)
2018-03-16 13:25 ` [PATCH v2 4/5] mm: Add NO_DMA dummies for DMA pool API Geert Uytterhoeven
@ 2018-03-16 13:25 ` Geert Uytterhoeven
2018-03-16 18:59 ` [PATCH v2 0/5] Allow compile-testing NO_DMA (core) Christoph Hellwig
5 siblings, 0 replies; 8+ messages in thread
From: Geert Uytterhoeven @ 2018-03-16 13:25 UTC (permalink / raw)
To: Christoph Hellwig, Marek Szyprowski, Robin Murphy, Felipe Balbi,
Greg Kroah-Hartman, James E . J . Bottomley, Martin K . Petersen,
Andrew Morton
Cc: iommu, linux-usb, linux-scsi, linux-kernel, Geert Uytterhoeven
Add dummies for scsi_dma_{,un}map(), to allow compile-testing if
NO_DMA=y.
This prevents the following from showing up later:
ERROR: "scsi_dma_unmap" [drivers/firewire/firewire-sbp2.ko] undefined!
ERROR: "scsi_dma_map" [drivers/firewire/firewire-sbp2.ko] undefined!
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Mark Brown <broonie@kernel.org>
Acked-by: Robin Murphy <robin.murphy@arm.com>
---
v2:
- Add Reviewed-by, Acked-by,
- Drop RFC state.
---
include/scsi/scsi_cmnd.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index 2280b2351739572c..aaf1e971c6a368d1 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -174,8 +174,13 @@ extern void scsi_kunmap_atomic_sg(void *virt);
extern int scsi_init_io(struct scsi_cmnd *cmd);
+#ifdef CONFIG_SCSI_DMA
extern int scsi_dma_map(struct scsi_cmnd *cmd);
extern void scsi_dma_unmap(struct scsi_cmnd *cmd);
+#else /* !CONFIG_SCSI_DMA */
+static inline int scsi_dma_map(struct scsi_cmnd *cmd) { return -ENOSYS; }
+static inline void scsi_dma_unmap(struct scsi_cmnd *cmd) { }
+#endif /* !CONFIG_SCSI_DMA */
static inline unsigned scsi_sg_count(struct scsi_cmnd *cmd)
{
--
2.7.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/5] Allow compile-testing NO_DMA (core)
2018-03-16 13:25 [PATCH v2 0/5] Allow compile-testing NO_DMA (core) Geert Uytterhoeven
` (4 preceding siblings ...)
2018-03-16 13:25 ` [PATCH v2 5/5] scsi: Add NO_DMA dummies for SCSI DMA mapping API Geert Uytterhoeven
@ 2018-03-16 18:59 ` Christoph Hellwig
5 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2018-03-16 18:59 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Christoph Hellwig, Marek Szyprowski, Robin Murphy, Felipe Balbi,
Greg Kroah-Hartman, James E . J . Bottomley, Martin K . Petersen,
Andrew Morton, iommu, linux-usb, linux-scsi, linux-kernel
Thanks Geert,
applied to the dma-mapping tree for 4.17.
^ permalink raw reply [flat|nested] 8+ messages in thread