Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp8370137ybi; Thu, 6 Jun 2019 11:05:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqzoid/a3f4CGLu1ZZvhOqS94+z/0d+XDWfu+/5yIvKikgxJYgzDuEkQEJ17O6ry6oDq9/FP X-Received: by 2002:a17:90a:f992:: with SMTP id cq18mr1108931pjb.54.1559844339871; Thu, 06 Jun 2019 11:05:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559844339; cv=none; d=google.com; s=arc-20160816; b=SbhmWiHVBcJsK157EAn9Ogu9lw158bsdmBNiP0Zimu287y7sbN10Xh12MPKMdv2MSu xwZtOMtIPtuJuHMWtkb/GbdwtiN0ok4iLhEtTr5+6xK94NXBr+B5kAw1P3z8yiEWhU38 YDcVh2GBrAKCuJk+PNg+wvi6zZRQj7/+XmWdtrftRFPjfWBhx9c6bFsb0ohv/p08NHnT OiLHgAW6+m8zH4b8R86UYgQ3cWKG97zAqN3fRQtD3VwfQCxniAisUaE8rMEB3wq89Knq TNSnVY3UgPI6RsnT9RHMfeIEmVpf4PZzVsbON6jN529tD05GU8dJZIuENkt2QpzPCl0R eTxg== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=yyHmDT71JtnOIbPTTmq5VRin2fYImT5tlifCLJuVgoQ=; b=n4Gq0dn/MktaZuYPoxd3aYCh2aq8+TVVD3TIZ2M5tOFmGmV4MWEaET+ot16n+Zcf5N sePNkfDLQqVPEtBJoqiuHWLZa6GY7WYXyhNrVeb2uKsCf1iGkTKU+PUyTAB5ZiXMvv75 2Wdgsm8K1V3uVxXfvvcZr8HYyjnOWA0Zp58voXLdzm9jUyS/WaX1c9/OKXpVIoTgbYOl 8FPfyaRR7tgM/xzY/ePa+assPx7C8ddX/3zJTyfUDPtIxxWL85eil6BKaRnYNEb2CD5l UgUEQOqJNTnVVHi1hTbjhZgxHcPKdyZ3u2ggizGcmq47SDaZcvwpDGGFYl5U8y8btm49 s8bQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d31si2299784pld.248.2019.06.06.11.05.20; Thu, 06 Jun 2019 11:05:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728963AbfFFO4y (ORCPT + 99 others); Thu, 6 Jun 2019 10:56:54 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:18095 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728011AbfFFO4y (ORCPT ); Thu, 6 Jun 2019 10:56:54 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 664D46298DBADB926477; Thu, 6 Jun 2019 22:56:51 +0800 (CST) Received: from localhost (10.202.226.61) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.439.0; Thu, 6 Jun 2019 22:56:46 +0800 Date: Thu, 6 Jun 2019 15:56:37 +0100 From: Jonathan Cameron To: Pavel Machek CC: , Justin Chen , "Sasha Levin" Subject: Re: [PATCH 4.19 189/276] iio: adc: ti-ads7950: Fix improper use of mlock Message-ID: <20190606155637.00002b4f@huawei.com> In-Reply-To: <20190606131300.GE27432@amd> References: <20190530030523.133519668@linuxfoundation.org> <20190530030537.017297326@linuxfoundation.org> <20190606131300.GE27432@amd> Organization: Huawei X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.202.226.61] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 6 Jun 2019 15:13:00 +0200 Pavel Machek wrote: > (stable removed from cc list) > > > Indio->mlock is used for protecting the different iio device modes. > > It is currently not being used in this way. Replace the lock with > > an internal lock specifically used for protecting the SPI transfer > > buffer. > > > > Signed-off-by: Justin Chen > > Signed-off-by: Jonathan Cameron > > Signed-off-by: Sasha Levin > > --- > > drivers/iio/adc/ti-ads7950.c | 19 +++++++++++++++---- > > 1 file changed, 15 insertions(+), 4 deletions(-) > > > > > @@ -277,6 +280,7 @@ static irqreturn_t ti_ads7950_trigger_handler(int irq, void *p) > > struct ti_ads7950_state *st = iio_priv(indio_dev); > > int ret; > > > > + mutex_lock(&st->slock); > > ret = spi_sync(st->spi, &st->ring_msg); > > if (ret < 0) > > goto out; > > @@ -285,6 +289,7 @@ static irqreturn_t ti_ads7950_trigger_handler(int irq, void *p) > > iio_get_time_ns(indio_dev)); > > > > out: > > + mutex_unlock(&st->slock); > > iio_trigger_notify_done(indio_dev->trig); > > > > return IRQ_HANDLED; > > Does trigger_handler run from interrupt context? Prototype suggests > so... If so, it can not really take mutexes... It's an interrupt thread so taking mutexes should be fine. For this particular case there is no 'top half' provided to the call to iio_triggered_buffer_setup so nothing runs in interrupt context. The spi_sync call can sleep anyway so this code can only run where sleeping is fine. Thanks, Jonathan > > Best regards, > Pavel >