RE: [PATCH v14 12/12] dmaengine: imx-sdma: add terminated list for freed descriptor in worker

From: Robin Gong
Date: Tue Apr 13 2021 - 01:05:33 EST


On 2021/04/12 17:39, Vinod Koul <vkoul@xxxxxxxxxx> wrote:
> On 07-04-21, 23:30, Robin Gong wrote:
> > Add terminated list for keeping descriptor so that it could be freed
> > in worker without any potential involving next descriptor raised up
> > before this descriptor freed, because vchan_get_all_descriptors get
> > all descriptors including the last terminated descriptor and the next
> > descriptor, hence, the next descriptor maybe freed unexpectly when
> > it's done in worker without this patch.
> > https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.
> >
> spinics.net%2Flists%2Fdmaengine%2Fmsg23367.html&amp;data=04%7C01%
> 7Cyib
> >
> in.gong%40nxp.com%7Cf255f329c8de459ffbaf08d8fd96d6c5%7C686ea1d3bc
> 2b4c6
> >
> fa92cd99c5c301635%7C0%7C0%7C637538171591949442%7CUnknown%7CT
> WFpbGZsb3d
> >
> 8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3
> D%7C
> >
> 1000&amp;sdata=3YFgzHFDNwRnogvxZpNcwVKOKpk4GHrgScdrbuMKjwE%3D
> &amp;rese
> > rved=0
>
> Sound like you should implement .device_synchronize() and do the actual
> work there..?
Yes, I believe no issue here if call dmaengine_terminate_sync() always since
flush_work(&sdmac->terminate_worker) has already been in .device_synchronize() of
sdma driver. But unfortunately, have to use dmaengine_terminate_all() instead in some
non-atomic case like ALSA.