Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756744AbdLOOvJ (ORCPT ); Fri, 15 Dec 2017 09:51:09 -0500 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:19566 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755322AbdLOOvG (ORCPT ); Fri, 15 Dec 2017 09:51:06 -0500 From: Fabien DESSENNE To: Jia-Ju Bai , Mauro Carvalho Chehab CC: "linux-media@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Benjamin GAIGNARD" , Hans Verkuil Subject: Re: [PATCH 1/2] bdisp: Fix a possible sleep-in-atomic bug in bdisp_hw_reset Thread-Topic: [PATCH 1/2] bdisp: Fix a possible sleep-in-atomic bug in bdisp_hw_reset Thread-Index: AQHTc09yYJfNEbF0xESxyxWq+ItQLaNEcNqA Date: Fri, 15 Dec 2017 14:51:00 +0000 Message-ID: <0370257c-ce0c-792f-6c85-50ebc18975f9@st.com> References: <1513086445-29265-1-git-send-email-baijiaju1990@gmail.com> In-Reply-To: <1513086445-29265-1-git-send-email-baijiaju1990@gmail.com> Accept-Language: fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.75.127.48] Content-Type: text/plain; charset="utf-8" Content-ID: <63D993B0F6DA184F8CC4EA714FEBE9AA@st.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-12-15_06:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by nfs id vBFEpD0H019759 Content-Length: 1208 Lines: 35 Hi On 12/12/17 14:47, Jia-Ju Bai wrote: > The driver may sleep under a spinlock. > The function call path is: > bdisp_device_run (acquire the spinlock) > bdisp_hw_reset > msleep --> may sleep > > To fix it, msleep is replaced with mdelay. May I suggest you to use readl_poll_timeout_atomic (instead of the whole "for" block): this fixes the problem and simplifies the code? > > This bug is found by my static analysis tool(DSAC) and checked by my code review. > > Signed-off-by: Jia-Ju Bai > --- > drivers/media/platform/sti/bdisp/bdisp-hw.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/media/platform/sti/bdisp/bdisp-hw.c b/drivers/media/platform/sti/bdisp/bdisp-hw.c > index b7892f3..4b62ceb 100644 > --- a/drivers/media/platform/sti/bdisp/bdisp-hw.c > +++ b/drivers/media/platform/sti/bdisp/bdisp-hw.c > @@ -382,7 +382,7 @@ int bdisp_hw_reset(struct bdisp_dev *bdisp) > for (i = 0; i < POLL_RST_MAX; i++) { > if (readl(bdisp->regs + BLT_STA1) & BLT_STA1_IDLE) > break; > - msleep(POLL_RST_DELAY_MS); > + mdelay(POLL_RST_DELAY_MS); > } > if (i == POLL_RST_MAX) > dev_err(bdisp->dev, "Reset timeout\n");