From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tony Lindgren Subject: Re: [PATCH] dmaengine: cppi41: Fix oops in cppi41_runtime_resume Date: Thu, 12 Jan 2017 15:04:56 -0800 Message-ID: <20170112230456.GS2630@atomide.com> References: <20170112213016.19367-1-tony@atomide.com> <927792da-2e90-b2ae-1206-8fcb504d7551@ti.com> <20170112221933.GM2630@atomide.com> <1c8967b7-d59b-e53d-feeb-80c71464fb94@ti.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <1c8967b7-d59b-e53d-feeb-80c71464fb94-l0cyMroinI0@public.gmane.org> Sender: linux-usb-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Grygorii Strashko Cc: Dan Williams , Vinod Koul , Bin Liu , Daniel Mack , Felipe Balbi , George Cherian , Johan Hovold , Peter Ujfalusi , Sekhar Nori , Sebastian Andrzej Siewior , dmaengine-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Andy Shevchenko , Kevin Hilman , Patrick Titiano , Sergei Shtylyov List-Id: linux-omap@vger.kernel.org * Grygorii Strashko [170112 14:53]: > > > On 01/12/2017 04:19 PM, Tony Lindgren wrote: > > * Grygorii Strashko [170112 13:54]: > >> On 01/12/2017 03:30 PM, Tony Lindgren wrote: > >> > >> Sry, but even if it looks better it might still race with PM runtime :( > >> > >>> - if (likely(pm_runtime_active(cdd->ddev.dev))) > >>> + if (likely(atomic_read(&cdd->active))) > >>> push_desc_queue(c); > >>> else > >> > >> > >> - CPU is here (-EINPROGRESS and active == 0) and then preempted > >> - PM runtime will finish cppi41_runtime_resume and clean-up pending descs > >> - CPU return here and adds desc to the pending queue > >> - oops > >> > >> Am I wrong? > > > > We had cppi41_dma_issue_pending() getting called from atomic contex and > > cppi41_runtime_resume() getting preempted where cppi41_dma_issue_pending() > > would add to the queue. > > Again, I can be mistaken but cppi41_configure_channel() seems not atomic. > cppi41_configure_channel()->dma_async_issue_pending() > + documentation says "This function can be called in an interrupt context" > > And definitely it will be preemptive on RT :( Hmm OK. So are you thinking we should add a spinlock around the test in cppi41_dma_issue_pending() and when modifying cdd->active? Something like: spin_lock_irqsave(&cdd->lock, flags); if (likely(cdd->active)) push_desc_queue(c); else list_add_tail(&c->node, &cdd->pending); spin_unlock_irqrestore(&cdd->lock, flags); Or do you have something better in mind? Regards, Tony -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html