* [PATCH v2 1/5] dma-mapping: Convert NO_DMA get_dma_ops() into a real dummy
[not found] ` <1521206744-1504-1-git-send-email-geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
@ 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
` (3 subsequent siblings)
4 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-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
linux-usb-u79uwXL29TY76Z2rM5mHXA, Geert Uytterhoeven,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-scsi-u79uwXL29TY76Z2rM5mHXA
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-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
Reviewed-by: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Acked-by: Robin Murphy <robin.murphy-5wv7dgnIgG8@public.gmane.org>
---
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
[not found] ` <1521206744-1504-1-git-send-email-geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
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
` (2 subsequent siblings)
4 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-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
linux-usb-u79uwXL29TY76Z2rM5mHXA, Geert Uytterhoeven,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-scsi-u79uwXL29TY76Z2rM5mHXA
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-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
Reviewed-by: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Acked-by: Robin Murphy <robin.murphy-5wv7dgnIgG8@public.gmane.org>
---
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
[not found] ` <1521206744-1504-1-git-send-email-geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
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
[not found] ` <1521206744-1504-4-git-send-email-geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
2018-03-16 13:25 ` [PATCH v2 5/5] scsi: Add NO_DMA dummies for SCSI " Geert Uytterhoeven
2018-03-16 18:59 ` [PATCH v2 0/5] Allow compile-testing NO_DMA (core) Christoph Hellwig
4 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-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
linux-usb-u79uwXL29TY76Z2rM5mHXA, Geert Uytterhoeven,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-scsi-u79uwXL29TY76Z2rM5mHXA
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-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
Reviewed-by: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Acked-by: Robin Murphy <robin.murphy-5wv7dgnIgG8@public.gmane.org>
Acked-by: Felipe Balbi <felipe.balbi-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
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* [PATCH v2 5/5] scsi: Add NO_DMA dummies for SCSI DMA mapping API
[not found] ` <1521206744-1504-1-git-send-email-geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
` (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 18:59 ` [PATCH v2 0/5] Allow compile-testing NO_DMA (core) Christoph Hellwig
4 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-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
linux-usb-u79uwXL29TY76Z2rM5mHXA, Geert Uytterhoeven,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-scsi-u79uwXL29TY76Z2rM5mHXA
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-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
Reviewed-by: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Acked-by: Robin Murphy <robin.murphy-5wv7dgnIgG8@public.gmane.org>
---
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)
[not found] ` <1521206744-1504-1-git-send-email-geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
` (3 preceding siblings ...)
2018-03-16 13:25 ` [PATCH v2 5/5] scsi: Add NO_DMA dummies for SCSI " Geert Uytterhoeven
@ 2018-03-16 18:59 ` Christoph Hellwig
4 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2018-03-16 18:59 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Felipe Balbi, James E . J . Bottomley,
linux-scsi-u79uwXL29TY76Z2rM5mHXA, Martin K . Petersen,
Greg Kroah-Hartman, linux-usb-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, Andrew Morton,
Christoph Hellwig
Thanks Geert,
applied to the dma-mapping tree for 4.17.
^ permalink raw reply [flat|nested] 8+ messages in thread