question about drivers/dma/dma-jz4780.c
The file drivers/dma/dma-jz4780.c has a probe function that sets up irqs using devm_request_irq. The probe function then ends with:
err_unregister_dev:
dma_async_device_unregister(dd);
err_disable_clk:
clk_disable_unprepare(jzdma->clk); return ret; }
The remove function, on the other hand contains:
of_dma_controller_free(pdev->dev.of_node);
devm_free_irq(&pdev->dev, jzdma->irq, jzdma);
dma_async_device_unregister(&jzdma->dma_device);The need for calling devm_free_irq explicitly would be that it needs to occur before dma_async_device_unregister, to eg avoid a reference to a dangling pointer. But devm_free_irq is implicitly called after the call to dma_async_device_unregister at the end of the probe function. Which one is correct?
julia
Quoted 17 lines · Julia Lawall
The file
drivers/dma/dma-jz4780.chas a probe function that sets up irqs usingdevm_request_irq. The probe function then ends with:
err_unregister_dev:dma_async_device_unregister(dd);
err_disable_clk:clk_disable_unprepare(jzdma->clk); return ret; }The remove function, on the other hand contains:
of_dma_controller_free(pdev->dev.of_node); devm_free_irq(&pdev->dev, jzdma->irq, jzdma); dma_async_device_unregister(&jzdma->dma_device);
Quoted 7 lines
The need for calling
devm_free_irqexplicitly would be that it needs to occur beforedma_async_device_unregister, to eg avoid a reference to a dangling pointer. Butdevm_free_irqis implicitly called after the call todma_async_device_unregisterat the end of the probe function. Which one is correct?julia
Hi,
I think the explicit devm_free_irq() here is unnecessary, as when remove is called there should be no remaining users of the DMA controller and therefore no chance of an IRQ occurring between the controller being unregistered and an implicit IRQ release afterwards.
I recently sent a series of fixes for this driver, I will send a new version with a patch to remove the unnecessary free.
Thanks,
Alex
Quoted 28 lines · Alex Smith
Quoted 17 lines · Julia Lawall
The file
drivers/dma/dma-jz4780.chas a probe function that sets up irqs usingdevm_request_irq. The probe function then ends with:
err_unregister_dev:dma_async_device_unregister(dd);
err_disable_clk:clk_disable_unprepare(jzdma->clk); return ret; }The remove function, on the other hand contains:
of_dma_controller_free(pdev->dev.of_node); devm_free_irq(&pdev->dev, jzdma->irq, jzdma); dma_async_device_unregister(&jzdma->dma_device);Quoted 7 lines
The need for calling
devm_free_irqexplicitly would be that it needs to occur beforedma_async_device_unregister, to eg avoid a reference to a dangling pointer. Butdevm_free_irqis implicitly called after the call todma_async_device_unregisterat the end of the probe function. Which one is correct?julia
Hi,
Quoted 7 lines
I think the explicit
devm_free_irq()here is unnecessary, as when remove is called there should be no remaining users of the DMA controller and therefore no chance of an IRQ occurring between the controller being unregistered and an implicit IRQ release afterwards.I recently sent a series of fixes for this driver, I will send a new version with a patch to remove the unnecessary free.
Great. Thanks.
julia
Quoted 20 lines · Julia Lawall
Quoted 18 lines · Alex Smith
Quoted 17 lines · Julia Lawall
The file
drivers/dma/dma-jz4780.chas a probe function that sets up irqs usingdevm_request_irq. The probe function then ends with:
err_unregister_dev:dma_async_device_unregister(dd);
err_disable_clk:clk_disable_unprepare(jzdma->clk); return ret; }The remove function, on the other hand contains:
of_dma_controller_free(pdev->dev.of_node); devm_free_irq(&pdev->dev, jzdma->irq, jzdma); dma_async_device_unregister(&jzdma->dma_device);
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
The need for calling
devm_free_irqexplicitly would be that it needs to occur beforedma_async_device_unregister, to eg avoid a reference to a dangling pointer. Butdevm_free_irqis implicitly called after the call todma_async_device_unregisterat the end of the probe function. Which one is correct?
Not just users but from a device management you are ensuring that your device is not able to send any more interrupts and also your tasklet is not spawned further. For this it is neccessary that devm_irq_free be called explcitly by devices
Quoted 9 lines
Quoted 9 lines
Quoted 2 lines
julia
Hi,
I think the explicit
devm_free_irq()here is unnecessary, as when remove is called there should be no remaining users of the DMA controller and therefore no chance of an IRQ occurring between the controller being unregistered and an implicit IRQ release afterwards.
Are you ensuring that device can no longer sent interrupts and all instances of tasklet running or either completed are terminated and no further tasklet can be spawned?
Signature · 1 line
~Vinod
Quoted 35 lines · Vinod Koul
Quoted 20 lines · Julia Lawall
Quoted 18 lines · Alex Smith
Quoted 17 lines · Julia Lawall
The file
drivers/dma/dma-jz4780.chas a probe function that sets up irqs usingdevm_request_irq. The probe function then ends with:
err_unregister_dev:dma_async_device_unregister(dd);
err_disable_clk:clk_disable_unprepare(jzdma->clk); return ret; }The remove function, on the other hand contains:
of_dma_controller_free(pdev->dev.of_node); devm_free_irq(&pdev->dev, jzdma->irq, jzdma); dma_async_device_unregister(&jzdma->dma_device);Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
The need for calling
devm_free_irqexplicitly would be that it needs to occur beforedma_async_device_unregister, to eg avoid a reference to a dangling pointer. Butdevm_free_irqis implicitly called after the call todma_async_device_unregisterat the end of the probe function. Which one is correct?Not just users but from a device management you are ensuring that your device is not able to send any more interrupts and also your tasklet is not spawned further. For this it is neccessary that
devm_irq_freebe called explcitly by devicesQuoted 5 lines
Quoted 5 lines
Quoted 2 lines
julia
Hi,
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
I think the explicit
devm_free_irq()here is unnecessary, as when remove is called there should be no remaining users of the DMA controller and therefore no chance of an IRQ occurring between the controller being unregistered and an implicit IRQ release afterwards.Are you ensuring that device can no longer sent interrupts and all instances of tasklet running or either completed are terminated and no further tasklet can be spawned?
Hi Vinod,
If I understand correctly, when remove() is called, there should be no more users of the DMA controller, enforced by the module reference count.
Wouldn't that guarantee that there are no more transactions running and therefore no chance of an interrupt from the controller or a tasklet still running?
Thanks,
Alex
Quoted 10 lines · Alex Smith
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
I think the explicit
devm_free_irq()here is unnecessary, as when remove is called there should be no remaining users of the DMA controller and therefore no chance of an IRQ occurring between the controller being unregistered and an implicit IRQ release afterwards.Are you ensuring that device can no longer sent interrupts and all instances of tasklet running or either completed are terminated and no further tasklet can be spawned?
Hi Vinod,
Quoted 7 lines
If I understand correctly, when
remove()is called, there should be no more users of the DMA controller, enforced by the module reference count.Wouldn't that guarantee that there are no more transactions running and therefore no chance of an interrupt from the controller or a tasklet still running?
That will only guarantee no new requests are recieved, but you may have tasklet already scheduled or irq sent from HW how do you prevent that?
Signature · 1 line
~Vinod
Quoted 16 lines · Vinod Koul
Quoted 14 lines · Alex Smith
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
I think the explicit
devm_free_irq()here is unnecessary, as when remove is called there should be no remaining users of the DMA controller and therefore no chance of an IRQ occurring between the controller being unregistered and an implicit IRQ release afterwards.Are you ensuring that device can no longer sent interrupts and all instances of tasklet running or either completed are terminated and no further tasklet can be spawned?
Hi Vinod,
If I understand correctly, when
remove()is called, there should be no more users of the DMA controller, enforced by the module reference count.
Quoted 6 lines
Quoted 3 lines
Wouldn't that guarantee that there are no more transactions running and therefore no chance of an interrupt from the controller or a tasklet still running?
That will only guarantee no new requests are recieved, but you may have tasklet already scheduled or irq sent from HW how do you prevent that?
More genrally, I have seen another driver with synchronize_irq in the remove function (dma/img-mdc-dma.c). Would that be safe enough? On the other hand, if one is going to go to the trouble of putting that, maybe one would do just as well to drop the devm for irqs and use free_irq in place of synchronize_irq instead?
thanks,
julia
Quoted 24 lines · Julia Lawall
Quoted 20 lines · Vinod Koul
Quoted 17 lines · Alex Smith
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
I think the explicit
devm_free_irq()here is unnecessary, as when remove is called there should be no remaining users of the DMA controller and therefore no chance of an IRQ occurring between the controller being unregistered and an implicit IRQ release afterwards.Are you ensuring that device can no longer sent interrupts and all instances of tasklet running or either completed are terminated and no further tasklet can be spawned?
Hi Vinod,
If I understand correctly, when
remove()is called, there should be no more users of the DMA controller, enforced by the module reference count.Wouldn't that guarantee that there are no more transactions running and therefore no chance of an interrupt from the controller or a tasklet still running?
Quoted 8 lines
Quoted 2 lines
That will only guarantee no new requests are recieved, but you may have tasklet already scheduled or irq sent from HW how do you prevent that?
More genrally, I have seen another driver with
synchronize_irqin the remove function (dma/img-mdc-dma.c). Would that be safe enough? On the other hand, if one is going to go to the trouble of putting that, maybe one would do just as well to drop the devm for irqs and usefree_irqin place ofsynchronize_irqinstead?
synchronize_irq() will take care of irq but not tasklet right. Also irq can be triggered again as you haven't disabled that yet.
Is it really worth the trouble going though hoops to ensure your device is in right state, so might be simpler to free the irq and kill tasklet
Yes for dmaengine drivers I do ask this question which typically ends up in driver invoking devm_irq_free() in driver's remove callback
IMHO don't think devm irq calls are very useful, they do make stuff complicated
Signature · 1 line
~Vinod
Quoted 5 lines
Yes for dmaengine drivers I do ask this question which typically ends up in driver invoking
devm_irq_free()in driver's remove callbackIMHO don't think devm irq calls are very useful, they do make stuff complicate
Would it be better then to just go back to request_irq (or whatever is appropriate in this case). It would seem that the devm property can never be relied on, so there is no point to use it.
julia
Quoted 9 lines · Julia Lawall
Quoted 5 lines
Yes for dmaengine drivers I do ask this question which typically ends up in driver invoking
devm_irq_free()in driver's remove callbackIMHO don't think devm irq calls are very useful, they do make stuff complicate
Would it be better then to just go back to
request_irq(or whatever is appropriate in this case). It would seem that the devm property can never be relied on, so there is no point to use it.
Yes I do think that is right way in this case
Signature · 1 line
~Vinod
Quoted 4 lines · Vinod Koul
Quoted 3 lines · Julia Lawall
Quoted 3 lines
Yes for dmaengine drivers I do ask this question which typically ends up in driver invoking
devm_irq_free()in driver's remove callback
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
IMHO don't think devm irq calls are very useful, they do make stuff complicate
Would it be better then to just go back to
request_irq(or whatever is appropriate in this case). It would seem that the devm property can never be relied on, so there is no point to use it.Yes I do think that is right way in this case
Thanks for your help.
julia
Quoted 4 lines · Vinod Koul
Quoted 3 lines · Julia Lawall
Quoted 3 lines
Yes for dmaengine drivers I do ask this question which typically ends up in driver invoking
devm_irq_free()in driver's remove callback
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines
IMHO don't think devm irq calls are very useful, they do make stuff complicate
Would it be better then to just go back to
request_irq(or whatever is appropriate in this case). It would seem that the devm property can never be relied on, so there is no point to use it.Yes I do think that is right way in this case
Hmm, OK, I will drop the patch I submitted removing the explicit devm_free_irq() call and send a new one which stops using the devm IRQ functions, and kills the tasklets.
Thanks,
Alex