Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1183425pxa; Thu, 20 Aug 2020 05:02:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCnqAfvwYujYcfUQI1K35NU5caMgnRwgf/066wNEVIXbLscYrbv6qQiOFVqEJDJgTkxsFD X-Received: by 2002:aa7:cd6c:: with SMTP id ca12mr2396573edb.365.1597924957737; Thu, 20 Aug 2020 05:02:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597924957; cv=none; d=google.com; s=arc-20160816; b=ev+QEG0VtNOyC1GpN4RcyAHjSiyuCqwRTDTS20g5IpDU30aPl3MKSdcDieqv3HxFnf uqsGdpNSSc3pZLzEfreAnymn6QmOyq3UVy+q63Q+27fTEIDnI8El87f6o6cVHwEu9W5Q SmZrp6B27dTvFbkX7kwgzNQjz9HEqiaCwP7Q3K7D9h8VO2qJhryAXLSRUxvj7wVF7RUe lM32cvZR70rHmkUNRfzR/ONmK9csB9dY+xdjF6joJkZq2HYy28kCGOZQ0dzfJSM/peyz 8lh4UKVY17nE7+crFRWmsa4MwbV+lScRp3c7yet85twsWVT+/8oCtvFq6KZ7Vl4hzZ+L jemg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:cc:to:subject:from:date :dkim-signature; bh=kB2wGLDuU6aSHvN4xthqcKsE4uQqughcC0pSUs3BWBU=; b=uyYIWgYvpiILFOHYZ+I/Kmk4bKcTrL3yGB1F9TKcU385m7XzDRaG+bHM3bHF5WF6Cz 28bsTKQe6RHOTEhHNS/Gcz1utgQ0J6LJWnNl63AFVrrCm6F36rYZYww8rFlSlny7KVj8 PNYluMd2MWBcLYYAg/SgNwcldp0g/GY5PBmitUILSMemzS0FyXS3EP2xwvA8MYNeIPHa vVyceKDIpg1qF2ueoMJILK5hptqMtWQ9BsyVzWr62ZPrEi9mVfS6nu5gIPE75uiTgALt g56ZMThFYdAEu7gBKpKAbTM0/Nf/LtOzp5P6lOZ7Ujnw3GKWNaJ+dqCzVHEF6qlzYsL8 5Zqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@crapouillou.net header.s=mail header.b=prx1avjq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cn16si1098496edb.505.2020.08.20.05.02.13; Thu, 20 Aug 2020 05:02:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@crapouillou.net header.s=mail header.b=prx1avjq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730302AbgHTL7y (ORCPT + 99 others); Thu, 20 Aug 2020 07:59:54 -0400 Received: from crapouillou.net ([89.234.176.41]:45940 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730471AbgHTL7h (ORCPT ); Thu, 20 Aug 2020 07:59:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1597924774; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kB2wGLDuU6aSHvN4xthqcKsE4uQqughcC0pSUs3BWBU=; b=prx1avjqa0Ec51djNOI7gQDIPqvrOlAPUI7yPDnkvY580F1LFMbGawsak00Ou/nO9a0UWN 3d3DtzU5B+oepNoiQrT4clwIKAnw4yO/pMifbAFDcAFpXOvjJHAPknTYYFM6wOlYa5kq+P NdU8DgqFntO9IBnHFyjFnr+Qa13EEtk= Date: Thu, 20 Aug 2020 13:59:23 +0200 From: Paul Cercueil Subject: Re: [PATCH] drivers/dma/dma-jz4780: Fix race condition between probe and irq handler To: madhuparnabhowmik10@gmail.com Cc: dan.j.williams@intel.com, vkoul@kernel.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, andrianov@ispras.ru, ldv-project@linuxtesting.org Message-Id: In-Reply-To: <20200816072253.13817-1-madhuparnabhowmik10@gmail.com> References: <20200816072253.13817-1-madhuparnabhowmik10@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Le dim. 16 ao=FBt 2020 =E0 12:52, madhuparnabhowmik10@gmail.com a =E9crit : > From: Madhuparna Bhowmik >=20 > In probe IRQ is requested before zchan->id is initialized which can be > read in the irq handler. Hence, shift request irq and enable clock=20 > after > other initializations complete. Here, enable clock part is not part of > the race, it is just shifted down after request_irq to keep the error > path same as before. >=20 > Found by Linux Driver Verification project (linuxtesting.org). >=20 > Signed-off-by: Madhuparna Bhowmik I don't think there is a race at all, the interrupt handler won't be=20 called before the DMA is registered. More importantly, this patch will break things, as there are now=20 register writes in the probe before the clock is enabled. Cheers, -Paul > --- > drivers/dma/dma-jz4780.c | 44=20 > ++++++++++++++++++++-------------------- > 1 file changed, 22 insertions(+), 22 deletions(-) >=20 > diff --git a/drivers/dma/dma-jz4780.c b/drivers/dma/dma-jz4780.c > index 448f663da89c..5cbc8c3bd6c7 100644 > --- a/drivers/dma/dma-jz4780.c > +++ b/drivers/dma/dma-jz4780.c > @@ -879,28 +879,6 @@ static int jz4780_dma_probe(struct=20 > platform_device *pdev) > return -EINVAL; > } >=20 > - ret =3D platform_get_irq(pdev, 0); > - if (ret < 0) > - return ret; > - > - jzdma->irq =3D ret; > - > - ret =3D request_irq(jzdma->irq, jz4780_dma_irq_handler, 0,=20 > dev_name(dev), > - jzdma); > - if (ret) { > - dev_err(dev, "failed to request IRQ %u!\n", jzdma->irq); > - return ret; > - } > - > - jzdma->clk =3D devm_clk_get(dev, NULL); > - if (IS_ERR(jzdma->clk)) { > - dev_err(dev, "failed to get clock\n"); > - ret =3D PTR_ERR(jzdma->clk); > - goto err_free_irq; > - } > - > - clk_prepare_enable(jzdma->clk); > - > /* Property is optional, if it doesn't exist the value will remain=20 > 0. */ > of_property_read_u32_index(dev->of_node,=20 > "ingenic,reserved-channels", > 0, &jzdma->chan_reserved); > @@ -949,6 +927,28 @@ static int jz4780_dma_probe(struct=20 > platform_device *pdev) > jzchan->vchan.desc_free =3D jz4780_dma_desc_free; > } >=20 > + ret =3D platform_get_irq(pdev, 0); > + if (ret < 0) > + return ret; > + > + jzdma->irq =3D ret; > + > + ret =3D request_irq(jzdma->irq, jz4780_dma_irq_handler, 0,=20 > dev_name(dev), > + jzdma); > + if (ret) { > + dev_err(dev, "failed to request IRQ %u!\n", jzdma->irq); > + return ret; > + } > + > + jzdma->clk =3D devm_clk_get(dev, NULL); > + if (IS_ERR(jzdma->clk)) { > + dev_err(dev, "failed to get clock\n"); > + ret =3D PTR_ERR(jzdma->clk); > + goto err_free_irq; > + } > + > + clk_prepare_enable(jzdma->clk); > + > ret =3D dmaenginem_async_device_register(dd); > if (ret) { > dev_err(dev, "failed to register device\n"); > -- > 2.17.1 >=20