char: xillybus: Eliminate redundant wrappers to DMA related calls
Subsystems (2)
[email protected]
maintainerPATCH v2 1/1 char: xillybus: Eliminate redundant wrappers to DMA related calls
From: Eli Billauer <[email protected]>
The driver was originally written with the assumption that a different API must be used for DMA-related functions if the device is PCIe based or if not. Since Xillybus' driver supports devices on a PCIe bus (with xillybus_pcie) as well as connected directly to the processor (with xillybus_of), it originally used wrapper functions that ensure that a different API is used for each.
This patch eliminates the said wrapper functions, as all use the same dma_* API now. This is most notable by the code deleted in xillybus_pcie.c and xillybus_of.c.
It also eliminates the OF driver's check for a "dma-coherent" attribute in the device's OF entry, since this is taken care of by the kernel's implementation of dma_sync_single_for_*().
There is however still need for one wrapper function, which is merged from xillybus_pcie.c and xillybus_of.c into xillybus_core.c: The call to dma_map_single() is wrapped by a function that uses the Managed Device (devres) framework, in the absence of a relevant function in the current kernel's API.
---
Notes:
Changelog:
v2
-- Eliminate the OF driver's check for a "dma-coherent" attribute:
The driver always calls dma_sync_single_for_*(), and the kernel's implementation of these functions makes sure that nothing is done if the "dma-coherent" attribute is present for the device. Thanks to Arnd for pointing this out.
drivers/char/xillybus/xillybus.h | 23 +---- drivers/char/xillybus/xillybus_core.c | 129 ++++++++++++++++---------- drivers/char/xillybus/xillybus_of.c | 86 +---------------- drivers/char/xillybus/xillybus_pcie.c | 90 +----------------- 4 files changed, 86 insertions(+), 242 deletions(-)
drivers/char/xillybus/xillybus.h +2 -21
@@ -88,7 +88,7 @@ struct xilly_channel {struct xilly_endpoint {struct device *dev; -struct xilly_endpoint_hardware *ephw; +struct module *owner;int dma_using_dac;/* =1 if 64-bit DMA is used, =0 otherwise. */ __iomem void *registers;
@@ -108,23 +108,6 @@ struct xilly_endpoint {unsigned int msg_buf_size; }; -struct xilly_endpoint_hardware { -struct module *owner; -void (*hw_sync_sgl_for_cpu)(struct xilly_endpoint *, -dma_addr_t , -size_t , -int ); -void (*hw_sync_sgl_for_device)(struct xilly_endpoint *, -dma_addr_t , -size_t , -int ); -int (*map_single)(struct xilly_endpoint *, -void *, -size_t , -int , -dma_addr_t *); -}; -struct xilly_mapping {struct device *device;dma_addr_t dma_addr;
@@ -134,9 +117,7 @@ struct xilly_mapping {irqreturn_t xillybus_isr (int irq,void *data); -struct xilly_endpoint *xillybus_init_endpoint (struct device *dev, -struct xilly_endpoint_hardware - *ephw); +struct xilly_endpoint *xillybus_init_endpoint (struct device *dev);int xillybus_endpoint_discovery (struct xilly_endpoint *endpoint);
drivers/char/xillybus/xillybus_core.c +78 -51
213 lines not on this page · raw message
drivers/char/xillybus/xillybus_of.c +3 -83
105 lines not on this page · raw message
drivers/char/xillybus/xillybus_pcie.c +3 -87
108 lines not on this page · raw message
Signature · 1 line
2.17.1
Quoted 24 lines · On Wed, Sep 29, 2021 at 11:44 AM <[email protected]> wrote:
From: Eli Billauer <[email protected]>
The driver was originally written with the assumption that a different API must be used for DMA-related functions if the device is PCIe based or if not. Since Xillybus' driver supports devices on a PCIe bus (with
xillybus_pcie) as well as connected directly to the processor (withxillybus_of), it originally used wrapper functions that ensure that a different API is used for each.This patch eliminates the said wrapper functions, as all use the same dma_* API now. This is most notable by the code deleted in
xillybus_pcie.candxillybus_of.c.It also eliminates the OF driver's check for a "dma-coherent" attribute in the device's OF entry, since this is taken care of by the kernel's implementation of dma_sync_single_for_*().
There is however still need for one wrapper function, which is merged from
xillybus_pcie.candxillybus_of.cintoxillybus_core.c: The call todma_map_single()is wrapped by a function that uses the Managed Device (devres) framework, in the absence of a relevant function in the current kernel's API.
Quoted 3 lines
Suggested-by Christophe JAILLET <[email protected]>Suggested-by Arnd Bergmann <[email protected]>Signed-off-by Eli Billauer <[email protected]>