usb: musb: cppi41: Add a way to manage DMA irq
Subsystems (3)
v3 cover usb: musb: cppi41: Add a way to manage DMA irq
This series was "dmaengine: cppi41: Make the driver more generic". I have tried to separate as munch I could CPPI 4.1 MUSB driver changes.
Currently, the DMA interrupt is managed by the CPPI 4.1 driver. The issue here is the CPPI 4.1 driver must access to MUSB glue registers to manage its interrupt.
In order to move the interrupts management from CPPI 4.1 driver to MUSB (and then make it more generic), update the MUSB CPPI 4.1 driver with changes that will help to manage DMA interrupt from MUSB driver.
Changes in v3:
- Move a patch from another series to this one to avoid build error report from kbuild test robot
- Instead of adding and exporting function, add one callback and a pointer to musb in struct dma_controller
- Surround the DMA function introduced in musb_dsps with #ifdef / #endif.
Changes in v2:
- Fix some typo in commit messages
- Add more explanation about some changes made by patch 2 in commit message
Alexandre Bailon (3):
usb: musb: dma: Add a DMA completion platform callback
usb: musb: cppi41: Detect aborted transfers in cppi41_dma_callback()
usb: musb: dsps: Manage CPPI 4.1 DMA interrupt in dsps
drivers/dma/cppi41.c | 28 ++++------------ drivers/usb/musb/musb_cppi41.c | 20 ++++++++---- drivers/usb/musb/musb_dma.h | 4 +++ drivers/usb/musb/musb_dsps.c | 72 ++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 95 insertions(+), 29 deletions(-)
Signature · 6 lines
2.10.2 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 20170119100659.11370-1-abailon-rdvid1DuHRBWk0Htik3J/[email protected]
PATCH v3 1/3 usb: musb: dma: Add a DMA completion platform callback
Currently, the CPPI 4.1 driver is not completely generic and only work on dsps. This is because of IRQ management.
Add a callback to dma_controller that could be invoked on DMA completion to acknodlege the IRQ.
--- drivers/usb/musb/musb_cppi41.c | 7 +++++-- drivers/usb/musb/musb_dma.h | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-)
drivers/usb/musb/musb_cppi41.c +5 -2
@@ -217,6 +217,10 @@ static void cppi41_dma_callback(void *private_data)int is_hs =0 ;bool empty; + controller = cppi41_channel->controller; +if (controller->controller.dma_callback) + controller->controller.dma_callback (&controller->controller); +spin_lock_irqsave (&musb->lock, flags); dmaengine_tx_status(cppi41_channel->dc, cppi41_channel->cookie,
@@ -249,8 +253,6 @@ static void cppi41_dma_callback(void *private_data)* We spin on HS (no longer than than 25us and setup a timer on * FS to check for the bit and complete the transfer. */ - controller = cppi41_channel->controller; -if (is_host_active (musb)) {if (musb->port1_status &USB_PORT_STAT_HIGH_SPEED ) is_hs =1 ;
@@ -695,6 +697,7 @@ cppi41_dma_controller_create(struct musb *musb, void __iomem *base) controller->controller.channel_program = cppi41_dma_channel_program; controller->controller.channel_abort = cppi41_dma_channel_abort; controller->controller.is_compatible = cppi41_is_compatible; + controller->controller.musb = musb; ret =cppi41_dma_controller_start (controller);if (ret)
drivers/usb/musb/musb_dma.h +4 -0
@@ -181,10 +181,13 @@ dma_channel_status(struct dma_channel *c)* @channel_release: call this to release a DMA channel * @channel_abort: call this to abort a pending DMA transaction, * returning it to FREE (but allocated) state +* @platform_dma_callback: invoked on DMA completion, useful to run platform +* code such IRQ acknowledgment. * * Controllers manage dma channels. */ struct dma_controller { +struct musb *musb;struct dma_channel *(*channel_alloc)(struct dma_controller *,struct musb_hw_ep *,u8 is_tx);void (*channel_release)(struct dma_channel *);
@@ -196,6 +199,7 @@ struct dma_controller {int (*is_compatible)(struct dma_channel *channel,u16 maxpacket,void *buf,u32 length); +void (*dma_callback)(struct dma_controller *); };/* called after channel_program(), may indicate a fault */
Signature · 6 lines
2.10.2 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 20170119100659.11370-2-abailon-rdvid1DuHRBWk0Htik3J/[email protected]
Re: [PATCH v3 1/3] usb: musb: dma: Add a DMA completion platform callback
Hello!
Quoted 2 lines · Alexandre Bailon
Currently, the CPPI 4.1 driver is not completely generic and only work on dsps. This is because of IRQ management.
Works. DSPS.
Quoted 2 lines
Add a callback to
dma_controllerthat could be invoked on DMA completion to acknodlege the IRQ.
Acknowledge.
Quoted 1 line
[...]
drivers/usb/musb/musb_dma.h dma_channel_status(struct dma_channel *c) · line 184
Quoted 9 lines
drivers/usb/musb/musb_dma.h +1
-0@@ -181,10 +181,13 @@ dma_channel_status(struct dma_channel *c)* @channel_release: call this to release a DMA channel * @channel_abort: call this to abort a pending DMA transaction, * returning it to FREE (but allocated) state +* @platform_dma_callback: invoked on DMA completion, useful to run platform
It's called just dma_callback below.
drivers/usb/musb/musb_dma.h dma_channel_status(struct dma_channel *c) · line 190
Quoted 6 lines
drivers/usb/musb/musb_dma.h +2
-0+* code such IRQ acknowledgment. * * Controllers manage dma channels. */ struct dma_controller { +struct musb *musb;
You forgot to document this above.
drivers/usb/musb/musb_dma.h struct dma_controller { · line 205
Quoted 11 lines
drivers/usb/musb/musb_dma.h +1
-0struct dma_channel *(*channel_alloc)(struct dma_controller *,struct musb_hw_ep *,u8 is_tx);void (*channel_release)(struct dma_channel *);@@ -196,6 +199,7 @@ struct dma_controller {int (*is_compatible)(struct dma_channel *channel,u16 maxpacket,void *buf,u32 length); +void (*dma_callback)(struct dma_controller *); };/* called after channel_program(), may indicate a fault */
MBR, Sergei
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 1/3] usb: musb: dma: Add a DMA completion platform callback
In reply to a message not in the archiveQuoted 48 lines · Alexandre Bailon
Currently, the CPPI 4.1 driver is not completely generic and only work on dsps. This is because of IRQ management.
Add a callback todma_controllerthat could be invoked on DMA completion to acknodlege the IRQ.--- drivers/usb/musb/musb_cppi41.c | 7 +++++-- drivers/usb/musb/musb_dma.h | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-)drivers/usb/musb/musb_cppi41.c +5
-2@@ -217,6 +217,10 @@ static void cppi41_dma_callback(void *private_data)int is_hs =0 ;bool empty; + controller = cppi41_channel->controller; +if (controller->controller.dma_callback) + controller->controller.dma_callback (&controller->controller); +spin_lock_irqsave (&musb->lock, flags); dmaengine_tx_status(cppi41_channel->dc, cppi41_channel->cookie,@@ -249,8 +253,6 @@ static void cppi41_dma_callback(void *private_data)* We spin on HS (no longer than than 25us and setup a timer on * FS to check for the bit and complete the transfer. */ - controller = cppi41_channel->controller; -if (is_host_active (musb)) {if (musb->port1_status &USB_PORT_STAT_HIGH_SPEED ) is_hs =1 ;@@ -695,6 +697,7 @@ cppi41_dma_controller_create(struct musb *musb, void __iomem *base) controller->controller.channel_program = cppi41_dma_channel_program; controller->controller.channel_abort = cppi41_dma_channel_abort; controller->controller.is_compatible = cppi41_is_compatible; + controller->controller.musb = musb; ret =cppi41_dma_controller_start (controller);if (ret)drivers/usb/musb/musb_dma.h +0
-0
drivers/usb/musb/musb_dma.h dma_channel_status(struct dma_channel *c) · line 190
Quoted 10 lines
drivers/usb/musb/musb_dma.h +3
-0@@ -181,10 +181,13 @@ dma_channel_status(struct dma_channel *c)* @channel_release: call this to release a DMA channel * @channel_abort: call this to abort a pending DMA transaction, * returning it to FREE (but allocated) state +* @platform_dma_callback: invoked on DMA completion, useful to run platform +* code such IRQ acknowledgment. * * Controllers manage dma channels. */ struct dma_controller { +struct musb *musb;
Since musb is added here, can we clean up the corresponding one in struct cppi41_dma_controller and struct cppi?
Regards,
-Bin.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 1/3] usb: musb: dma: Add a DMA completion platform callback
Quoted 54 lines · Bin Liu
Quoted 53 lines · Alexandre Bailon
Currently, the CPPI 4.1 driver is not completely generic and only work on dsps. This is because of IRQ management.
Add a callback todma_controllerthat could be invoked on DMA completion to acknodlege the IRQ.--- drivers/usb/musb/musb_cppi41.c | 7 +++++-- drivers/usb/musb/musb_dma.h | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-)drivers/usb/musb/musb_cppi41.c +5
-2@@ -217,6 +217,10 @@ static void cppi41_dma_callback(void *private_data)int is_hs =0 ;bool empty; + controller = cppi41_channel->controller; +if (controller->controller.dma_callback) + controller->controller.dma_callback (&controller->controller); +spin_lock_irqsave (&musb->lock, flags); dmaengine_tx_status(cppi41_channel->dc, cppi41_channel->cookie,@@ -249,8 +253,6 @@ static void cppi41_dma_callback(void *private_data)* We spin on HS (no longer than than 25us and setup a timer on * FS to check for the bit and complete the transfer. */ - controller = cppi41_channel->controller; -if (is_host_active (musb)) {if (musb->port1_status &USB_PORT_STAT_HIGH_SPEED ) is_hs =1 ;@@ -695,6 +697,7 @@ cppi41_dma_controller_create(struct musb *musb, void __iomem *base) controller->controller.channel_program = cppi41_dma_channel_program; controller->controller.channel_abort = cppi41_dma_channel_abort; controller->controller.is_compatible = cppi41_is_compatible; + controller->controller.musb = musb; ret =cppi41_dma_controller_start (controller);if (ret)drivers/usb/musb/musb_dma.h +2
-0@@ -181,10 +181,13 @@ dma_channel_status(struct dma_channel *c)* @channel_release: call this to release a DMA channel * @channel_abort: call this to abort a pending DMA transaction, * returning it to FREE (but allocated) state +* @platform_dma_callback: invoked on DMA completion, useful to run platform +* code such IRQ acknowledgment.
Quoted 8 lines
drivers/usb/musb/musb_dma.h dma_channel_status(struct dma_channel *c) · line 190
Quoted 5 lines
drivers/usb/musb/musb_dma.h +1
-0* * Controllers manage dma channels. */ struct dma_controller { +struct musb *musb;Since musb is added here, can we clean up the corresponding one in struct
cppi41_dma_controllerand struct cppi?
Yes, and also for the one in tusb_omap_dma.
Quoted 4 lines
Regards,
-Bin.
Regards,
Alexandre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v3 2/3 usb: musb: cppi41: Detect aborted transfers in cppi41_dma_callback()
In reply to a message not in the archiveUpdate cppi41_dma_callback() to detect an aborted transfer. This was not required before because cppi41_dma_callback() was only invoked on transfer completion.
In order to make CPPI 4.1 driver more generic, cppi41_dma_callback() will be invoked after a transfer abort in order to let the MUSB driver perform some action such as acknowledge the interrupt that may be fired during a teardown.
--- drivers/usb/musb/musb_cppi41.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/usb/musb/musb_cppi41.c +9 -4
@@ -99,7 +99,8 @@ static bool musb_is_tx_fifo_empty(struct musb_hw_ep *hw_ep)return true; } -static void cppi41_dma_callback (void *private_data); +static void cppi41_dma_callback (void *private_data, +const struct dmaengine_result *result);static void cppi41_trans_done (struct cppi41_dma_channel *cppi41_channel) {
@@ -154,7 +155,7 @@ static void cppi41_trans_done(struct cppi41_dma_channel *cppi41_channel)if (WARN_ON (!dma_desc))return ; - dma_desc->callback = cppi41_dma_callback; + dma_desc->callback_result = cppi41_dma_callback; dma_desc->callback_param = &cppi41_channel->channel; cppi41_channel->cookie = dma_desc->tx_submit (dma_desc);trace_musb_cppi41_cont (cppi41_channel);
@@ -204,7 +205,8 @@ static enum hrtimer_restart cppi41_recheck_tx_req(struct hrtimer *timer)return ret; } -static void cppi41_dma_callback (void *private_data) +static void cppi41_dma_callback (void *private_data, +const struct dmaengine_result *result) {struct dma_channel *channel = private_data;struct cppi41_dma_channel *cppi41_channel = channel->private_data;
@@ -221,6 +223,9 @@ static void cppi41_dma_callback(void *private_data)if (controller->controller.dma_callback) controller->controller.dma_callback (&controller->controller); +if (result->result ==DMA_TRANS_ABORTED ) +return ; +spin_lock_irqsave (&musb->lock, flags); dmaengine_tx_status(cppi41_channel->dc, cppi41_channel->cookie,
@@ -403,7 +408,7 @@ static bool cppi41_configure_channel(struct dma_channel *channel,if (!dma_desc)return false; - dma_desc->callback = cppi41_dma_callback; + dma_desc->callback_result = cppi41_dma_callback; dma_desc->callback_param = channel; cppi41_channel->cookie = dma_desc->tx_submit (dma_desc); cppi41_channel->channel.rx_packet_done = false;
Signature · 6 lines
2.10.2 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v3 3/3 usb: musb: dsps: Manage CPPI 4.1 DMA interrupt in dsps
In reply to a message not in the archiveDespite the CPPI 4.1 is a generic DMA, it is tied to USB.
On the dsps, CPPI 4.1 interrupt's registers are in USBSS (the MUSB glue). Currently, to enable / disable and clear interrupts, the CPPI 4.1 driver maps and accesses to USBSS's register, which making CPPI 4.1 driver not really generic.
Move the interrupt management to dsps driver.
--- drivers/dma/cppi41.c | 28 ++++------------ drivers/usb/musb/musb_dsps.c | 77 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 82 insertions(+), 23 deletions(-)
drivers/dma/cppi41.c +7 -21
@@ -79,14 +79,6 @@#define QMGR_QUEUE_C (n) (0x2008 + (n) * 0x10)#define QMGR_QUEUE_D (n) (0x200c + (n) * 0x10) -/* Glue layer specific */ -/* USBSS / USB AM335x */ -#define USBSS_IRQ_STATUS 0x28 -#define USBSS_IRQ_ENABLER 0x2c -#define USBSS_IRQ_CLEARR 0x30 - -#define USBSS_IRQ_PD_COMP (1 << 2) -/* Packet Descriptor */ #define PD2_ZERO_LENGTH (1 << 19)
@@ -288,14 +280,8 @@ static irqreturn_t cppi41_irq(int irq, void *data) {struct cppi41_dd *cdd = data;struct cppi41_channel *c; -u32 status;int i; - status =cppi_readl (cdd->usbss_mem +USBSS_IRQ_STATUS ); -if (!(status &USBSS_IRQ_PD_COMP )) -return IRQ_NONE ; -cppi_writel (status, cdd->usbss_mem +USBSS_IRQ_STATUS ); -for (i =QMGR_PENDING_SLOT_Q (FIST_COMPLETION_QUEUE ); i <QMGR_NUM_PEND ; i++) {u32 val;
@@ -599,6 +585,7 @@ static void cppi41_compute_td_desc(struct cppi41_desc *d)static int cppi41_tear_down_chan (struct cppi41_channel *c) { +struct dmaengine_result abort_result;struct cppi41_dd *cdd = c->cdd;struct cppi41_desc *td;u32 reg;
@@ -682,6 +669,12 @@ static int cppi41_tear_down_chan(struct cppi41_channel *c) c->td_seen =0 ; c->td_desc_seen =0 ;cppi_writel (0 , c->gcr_reg); + +/* Invoke the callback to do the necessary clean-up */ + abort_result.result =DMA_TRANS_ABORTED ; +dma_cookie_complete (&c->txd); +dmaengine_desc_get_callback_invoke (&c->txd, &abort_result); +return 0 ; }
@@ -1044,8 +1037,6 @@ static int cppi41_dma_probe(struct platform_device *pdev) goto err_irq; } -cppi_writel (USBSS_IRQ_PD_COMP , cdd->usbss_mem +USBSS_IRQ_ENABLER ); - ret =devm_request_irq (&pdev->dev, irq, glue_info->isr,IRQF_SHARED ,dev_name (dev), cdd);if (ret)
@@ -1069,7 +1060,6 @@ static int cppi41_dma_probe(struct platform_device *pdev)dma_async_device_unregister (&cdd->ddev); err_dma_reg: err_irq: -cppi_writel (0 , cdd->usbss_mem +USBSS_IRQ_CLEARR );cleanup_chans (cdd); err_chans:deinit_cppi41 (dev, cdd);
@@ -1097,7 +1087,6 @@ static int cppi41_dma_remove(struct platform_device *pdev)of_dma_controller_free (pdev->dev.of_node);dma_async_device_unregister (&cdd->ddev); -cppi_writel (0 , cdd->usbss_mem +USBSS_IRQ_CLEARR );devm_free_irq (&pdev->dev, cdd->irq, cdd);cleanup_chans (cdd);deinit_cppi41 (&pdev->dev, cdd);
@@ -1116,7 +1105,6 @@ static int __maybe_unused cppi41_suspend(struct device *dev)struct cppi41_dd *cdd =dev_get_drvdata (dev); cdd->dma_tdfdq =cppi_readl (cdd->ctrl_mem +DMA_TDFDQ ); -cppi_writel (0 , cdd->usbss_mem +USBSS_IRQ_CLEARR );disable_sched (cdd);return 0 ;
@@ -1142,8 +1130,6 @@ static int __maybe_unused cppi41_resume(struct device *dev)cppi_writel (QMGR_SCRATCH_SIZE , cdd->qmgr_mem +QMGR_LRAM_SIZE );cppi_writel (0 , cdd->qmgr_mem +QMGR_LRAM1_BASE ); -cppi_writel (USBSS_IRQ_PD_COMP , cdd->usbss_mem +USBSS_IRQ_ENABLER ); -return 0 ; }
drivers/usb/musb/musb_dsps.c +75 -2
119 lines not on this page · raw message
Signature · 6 lines
2.10.2 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 20170119100659.11370-4-abailon-rdvid1DuHRBWk0Htik3J/[email protected]
Re: [PATCH v3 3/3] usb: musb: dsps: Manage CPPI 4.1 DMA interrupt in dsps
Quoted 7 lines · Alexandre Bailon
Despite the CPPI 4.1 is a generic DMA, it is tied to USB.
On the dsps, CPPI 4.1 interrupt's registers are in USBSS (the MUSB glue). Currently, to enable / disable and clear interrupts, the CPPI 4.1 driver maps and accesses to USBSS's register, which making CPPI 4.1 driver not really generic.
Move the interrupt management to dsps driver.
Quoted 5 lines
--- drivers/dma/cppi41.c | 28 ++++------------ drivers/usb/musb/musb_dsps.c | 77 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 82 insertions(+), 23 deletions(-)
This patch touches both dma and musb modules, I know it makes review easier, but how we get it merged? One maintainer ACK it and the other pick it up? Sorry for the dumb question, I am new as a maintainer...
Quoted 5 lines
drivers/dma/cppi41.c +0
-0
[...]
Quoted 13 lines
drivers/usb/musb/musb_dsps.c +1
-0@@ -121,6 +121,7 @@ struct dsps_glue {struct timer_list timer;/* otg_workaround timer */ unsigned long last_timer;/* last timer data for each instance */ bool sw_babble_enabled; +void __iomem *usbss_base;struct dsps_context context;struct debugfs_regset32 regset;
drivers/usb/musb/musb_dsps.c static const struct debugfs_reg32 dsps_musb_regs[] = { · line 154
Quoted 9 lines
drivers/usb/musb/musb_dsps.c +6
-0@@ -145,6 +146,13 @@ static const struct debugfs_reg32 dsps_musb_regs[] = { { "mode", 0xe8 }, }; +/* USBSS / USB AM335x */ +#define USBSS_IRQ_STATUS 0x28 +#define USBSS_IRQ_ENABLER 0x2c +#define USBSS_IRQ_CLEARR 0x30 + +#define USBSS_IRQ_PD_COMP (1 << 2)
Please fix the double white spaces bwteen '<' and '2' this time.
Quoted 51 lines
drivers/usb/musb/musb_dsps.c +44
-0+/** * dsps_musb_enable - enable interrupts */ @@ -619,14 +627,72 @@ static void dsps_read_fifo32(struct musb_hw_ep *hw_ep, u16 len, u8 *dst) } } +#ifdef CONFIG_USB_TI_CPPI41_DMA +static void dsps_dma_controller_callback (struct dma_controller *c) +{ +struct musb *musb = c->musb; +struct dsps_glue *glue =dev_get_drvdata (musb->controller->parent); +void __iomem *usbss_base = glue->usbss_base; +u32 status; + + status =musb_readl (usbss_base,USBSS_IRQ_STATUS ); +if (status &USBSS_IRQ_PD_COMP ) +musb_writel (usbss_base,USBSS_IRQ_STATUS ,USBSS_IRQ_PD_COMP ); +} + +static struct dma_controller * +dsps_dma_controller_create (struct musb *musb,void __iomem *base) +{ +struct dma_controller *controller; +struct dsps_glue *glue =dev_get_drvdata (musb->controller->parent); +void __iomem *usbss_base = glue->usbss_base; + + controller =cppi41_dma_controller_create (musb, base); +if (IS_ERR_OR_NULL (controller)) +return controller; + +musb_writel (usbss_base,USBSS_IRQ_ENABLER ,USBSS_IRQ_PD_COMP ); + controller->dma_callback = dsps_dma_controller_callback; + +return controller; +} + +static void dsps_dma_controller_destroy (struct dma_controller *c) +{ +struct musb *musb = c->musb; +struct dsps_glue *glue =dev_get_drvdata (musb->controller->parent); +void __iomem *usbss_base = glue->usbss_base; + +musb_writel (usbss_base,USBSS_IRQ_CLEARR ,USBSS_IRQ_PD_COMP ); +cppi41_dma_controller_destroy (c); +} + +static void dsps_dma_controller_suspend (struct dsps_glue *glue) +{ +void __iomem *usbss_base = glue->usbss_base;
drivers/usb/musb/musb_dsps.c static void dsps_read_fifo32(struct musb_hw_ep *hw_ep, u16 len, u8 *dst) · line 682
Quoted 10 lines
drivers/usb/musb/musb_dsps.c +10
-0+ +musb_writel (usbss_base,USBSS_IRQ_CLEARR ,USBSS_IRQ_PD_COMP ); +} + +static void dsps_dma_controller_resume (struct dsps_glue *glue) +{ +void __iomem *usbss_base = glue->usbss_base; + +musb_writel (usbss_base,USBSS_IRQ_ENABLER ,USBSS_IRQ_PD_COMP ); +}
The two functions above need to be wrapped in CONFIG_PM_SLEEP.
Quoted 19 lines
drivers/usb/musb/musb_dsps.c +7
-2+#else +static void dsps_dma_controller_suspend (struct dsps_glue *glue) {} +static void dsps_dma_controller_resume (struct dsps_glue *glue) {} +#endif +static struct musb_platform_ops dsps_ops = { .quirks =MUSB_DMA_CPPI41 |MUSB_INDEXED_EP , .init = dsps_musb_init, .exit = dsps_musb_exit, #ifdef CONFIG_USB_TI_CPPI41_DMA - .dma_init = cppi41_dma_controller_create, - .dma_exit = cppi41_dma_controller_destroy, + .dma_init = dsps_dma_controller_create, + .dma_exit = dsps_dma_controller_destroy, #endif .enable = dsps_musb_enable, .disable = dsps_musb_disable,
drivers/usb/musb/musb_dsps.c static int dsps_probe(struct platform_device *pdev) · line 862
Quoted 5 lines
drivers/usb/musb/musb_dsps.c +2
-0@@ -792,6 +858,9 @@ static int dsps_probe(struct platform_device *pdev) glue->dev = &pdev->dev; glue->wrp = wrp; + glue->usbss_base =of_iomap (pdev->dev.parent->of_node,0 ); +if (!glue->usbss_base)
use IS_ERR()?
drivers/usb/musb/musb_dsps.c static int dsps_probe(struct platform_device *pdev) · line 863
Quoted 1 line
drivers/usb/musb/musb_dsps.c +1
-0+return -ENXIO ;
and return PTR_ERR()?
Regards,
-Bin.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 3/3] usb: musb: dsps: Manage CPPI 4.1 DMA interrupt in dsps
Quoted 135 lines · Bin Liu
Quoted 7 lines · Alexandre Bailon
Despite the CPPI 4.1 is a generic DMA, it is tied to USB.
On the dsps, CPPI 4.1 interrupt's registers are in USBSS (the MUSB glue). Currently, to enable / disable and clear interrupts, the CPPI 4.1 driver maps and accesses to USBSS's register, which making CPPI 4.1 driver not really generic.
Move the interrupt management to dsps driver.Quoted 5 lines
--- drivers/dma/cppi41.c | 28 ++++------------ drivers/usb/musb/musb_dsps.c | 77 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 82 insertions(+), 23 deletions(-)This patch touches both dma and musb modules, I know it makes review easier, but how we get it merged? One maintainer ACK it and the other pick it up? Sorry for the dumb question, I am new as a maintainer...
Quoted 5 lines
drivers/dma/cppi41.c +0
-0[...]
Quoted 13 lines
drivers/usb/musb/musb_dsps.c +1
-0@@ -121,6 +121,7 @@ struct dsps_glue {struct timer_list timer;/* otg_workaround timer */ unsigned long last_timer;/* last timer data for each instance */ bool sw_babble_enabled; +void __iomem *usbss_base;struct dsps_context context;struct debugfs_regset32 regset;drivers/usb/musb/musb_dsps.c static const struct debugfs_reg32 dsps_musb_regs[] = { · line 154
Quoted 9 lines
drivers/usb/musb/musb_dsps.c +6
-0@@ -145,6 +146,13 @@ static const struct debugfs_reg32 dsps_musb_regs[] = { { "mode", 0xe8 }, }; +/* USBSS / USB AM335x */ +#define USBSS_IRQ_STATUS 0x28 +#define USBSS_IRQ_ENABLER 0x2c +#define USBSS_IRQ_CLEARR 0x30 + +#define USBSS_IRQ_PD_COMP (1 << 2)Please fix the double white spaces bwteen '<' and '2' this time.
Quoted 51 lines
drivers/usb/musb/musb_dsps.c +44
-0+/** * dsps_musb_enable - enable interrupts */ @@ -619,14 +627,72 @@ static void dsps_read_fifo32(struct musb_hw_ep *hw_ep, u16 len, u8 *dst) } } +#ifdef CONFIG_USB_TI_CPPI41_DMA +static void dsps_dma_controller_callback (struct dma_controller *c) +{ +struct musb *musb = c->musb; +struct dsps_glue *glue =dev_get_drvdata (musb->controller->parent); +void __iomem *usbss_base = glue->usbss_base; +u32 status; + + status =musb_readl (usbss_base,USBSS_IRQ_STATUS ); +if (status &USBSS_IRQ_PD_COMP ) +musb_writel (usbss_base,USBSS_IRQ_STATUS ,USBSS_IRQ_PD_COMP ); +} + +static struct dma_controller * +dsps_dma_controller_create (struct musb *musb,void __iomem *base) +{ +struct dma_controller *controller; +struct dsps_glue *glue =dev_get_drvdata (musb->controller->parent); +void __iomem *usbss_base = glue->usbss_base; + + controller =cppi41_dma_controller_create (musb, base); +if (IS_ERR_OR_NULL (controller)) +return controller; + +musb_writel (usbss_base,USBSS_IRQ_ENABLER ,USBSS_IRQ_PD_COMP ); + controller->dma_callback = dsps_dma_controller_callback; + +return controller; +} + +static void dsps_dma_controller_destroy (struct dma_controller *c) +{ +struct musb *musb = c->musb; +struct dsps_glue *glue =dev_get_drvdata (musb->controller->parent); +void __iomem *usbss_base = glue->usbss_base; + +musb_writel (usbss_base,USBSS_IRQ_CLEARR ,USBSS_IRQ_PD_COMP ); +cppi41_dma_controller_destroy (c); +} + +static void dsps_dma_controller_suspend (struct dsps_glue *glue) +{ +void __iomem *usbss_base = glue->usbss_base;drivers/usb/musb/musb_dsps.c static void dsps_read_fifo32(struct musb_hw_ep *hw_ep, u16 len, u8 *dst) · line 682
Quoted 10 lines
drivers/usb/musb/musb_dsps.c +10
-0+ +musb_writel (usbss_base,USBSS_IRQ_CLEARR ,USBSS_IRQ_PD_COMP ); +} + +static void dsps_dma_controller_resume (struct dsps_glue *glue) +{ +void __iomem *usbss_base = glue->usbss_base; + +musb_writel (usbss_base,USBSS_IRQ_ENABLER ,USBSS_IRQ_PD_COMP ); +}The two functions above need to be wrapped in
CONFIG_PM_SLEEP.Quoted 20 lines
drivers/usb/musb/musb_dsps.c +7
-2+#else +static void dsps_dma_controller_suspend (struct dsps_glue *glue) {} +static void dsps_dma_controller_resume (struct dsps_glue *glue) {} +#endif +static struct musb_platform_ops dsps_ops = { .quirks =MUSB_DMA_CPPI41 |MUSB_INDEXED_EP , .init = dsps_musb_init, .exit = dsps_musb_exit, #ifdef CONFIG_USB_TI_CPPI41_DMA - .dma_init = cppi41_dma_controller_create, - .dma_exit = cppi41_dma_controller_destroy, + .dma_init = dsps_dma_controller_create, + .dma_exit = dsps_dma_controller_destroy, #endif .enable = dsps_musb_enable, .disable = dsps_musb_disable,@@ -792,6 +858,9 @@ static int dsps_probe(struct platform_device *pdev)
Quoted 6 lines
drivers/usb/musb/musb_dsps.c static int dsps_probe(struct platform_device *pdev) · line 862
Quoted 4 lines
drivers/usb/musb/musb_dsps.c +2
-0glue->dev = &pdev->dev; glue->wrp = wrp; + glue->usbss_base =of_iomap (pdev->dev.parent->of_node,0 ); +if (!glue->usbss_base)use
IS_ERR()?
I don't we can use it here. As far I know, of_iomap() only return NULL in the case of error.
Quoted 4 lines
drivers/usb/musb/musb_dsps.c static int dsps_probe(struct platform_device *pdev) · line 863
Quoted 2 lines
drivers/usb/musb/musb_dsps.c +1
-0+return -ENXIO ;and return
PTR_ERR()?
Again, I don't think we can use it here. THough, may be -ENXIO is not the best error code to return. I used it because it was the used in DMA driver.
Quoted 4 lines
Regards,
-Bin.
Regards,
Alexandre
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 3/3] usb: musb: dsps: Manage CPPI 4.1 DMA interrupt in dsps
In reply to Bin LiuQuoted 14 lines · Bin Liu
Quoted 7 lines · Alexandre Bailon
Despite the CPPI 4.1 is a generic DMA, it is tied to USB.
On the dsps, CPPI 4.1 interrupt's registers are in USBSS (the MUSB glue). Currently, to enable / disable and clear interrupts, the CPPI 4.1 driver maps and accesses to USBSS's register, which making CPPI 4.1 driver not really generic.
Move the interrupt management to dsps driver.Quoted 5 lines
--- drivers/dma/cppi41.c | 28 ++++------------ drivers/usb/musb/musb_dsps.c | 77 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 82 insertions(+), 23 deletions(-)
Quoted 3 lines
This patch touches both dma and musb modules, I know it makes review easier, but how we get it merged? One maintainer ACK it and the other pick it up? Sorry for the dumb question, I am new as a maintainer...
For patches where the change needs to go together, then one maintainer can ack, and the other can merge. Alternately, if the patch can be done in a way that the parts can go independently, that is sometimes cleaner. I don't know this code well enough to know which is which.
Kevin
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): m2pojd3c39.fsf-rdvid1DuHRBWk0Htik3J/[email protected]
Re: [PATCH v3 3/3] usb: musb: dsps: Manage CPPI 4.1 DMA interrupt in dsps
Quoted 16 lines · Kevin Hilman
Quoted 14 lines · Bin Liu
Quoted 12 lines · Alexandre Bailon
Despite the CPPI 4.1 is a generic DMA, it is tied to USB.
On the dsps, CPPI 4.1 interrupt's registers are in USBSS (the MUSB glue). Currently, to enable / disable and clear interrupts, the CPPI 4.1 driver maps and accesses to USBSS's register, which making CPPI 4.1 driver not really generic.
Move the interrupt management to dsps driver.--- drivers/dma/cppi41.c | 28 ++++------------ drivers/usb/musb/musb_dsps.c | 77 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 82 insertions(+), 23 deletions(-)
Quoted 6 lines
Quoted 3 lines
This patch touches both dma and musb modules, I know it makes review easier, but how we get it merged? One maintainer ACK it and the other pick it up? Sorry for the dumb question, I am new as a maintainer...
For patches where the change needs to go together, then one maintainer can ack, and the other can merge. Alternately, if the patch can be done
Ok, this is what I thought :)
Quoted 2 lines
in a way that the parts can go independently, that is sometimes cleaner. I don't know this code well enough to know which is which.
In this case it is better to keep all together, since it moves code from one place to another.
I think it makes sense it goes to my tree, since the reset patches are for musb.
Regards,
-Bin.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html