Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751328AbeAII3t (ORCPT + 1 other); Tue, 9 Jan 2018 03:29:49 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:45080 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750753AbeAII3r (ORCPT ); Tue, 9 Jan 2018 03:29:47 -0500 X-Google-Smtp-Source: ACJfBosXhEez9haKqfOoC9a5pOTed5BzPWYc+6mpgyPWPG1xT0Qenhel0ad+u6JvXiuKyurPIXiQ+TTi+au3jDamgrg= MIME-Version: 1.0 In-Reply-To: <1514168416-4285-1-git-send-email-qi.hou@windriver.com> References: <1514168416-4285-1-git-send-email-qi.hou@windriver.com> From: Jassi Brar Date: Tue, 9 Jan 2018 13:59:45 +0530 Message-ID: Subject: Re: [RFC] dmaengine: pl330: fix a race condition in case of threaded irqs To: Qi Hou Cc: Vinod Koul , Dan Williams , paul.gortmaker@windriver.com, xiao.zhang@windriver.com, Russell King , dmaengine@vger.kernel.org, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Mon, Dec 25, 2017 at 7:50 AM, Qi Hou wrote: > I found this problem below, and I now understand why it happens, but I'm not > 100% sure what is the best way to fix it. > > When booting up with "threadirqs" in command line, all irq handlers of the DMA > controller pl330 will be threaded forcedly. These threads will race for the same > list, pl330->req_done. > > Before the callback, the spinlock was released. And after it, the spinlock was > taken. This opened an race window where another threaded irq handler could steal > the spinlock and be permitted to delete entries of the list, pl330->req_done. > The locking has been recently modified beyond recognition, so I can't tell why that part of code is the way it is. The safest and cleanest solution seems to be to not drop and re-aquire the lock. Cheers!