Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1018877ybz; Sat, 25 Apr 2020 09:10:57 -0700 (PDT) X-Google-Smtp-Source: APiQypIMbFMF5EUdXSAsX+nYmINbz1r5UWUQ19SuV/RIy/AbVmrqrxTvVgAhb1k2RxOewqu+MxIQ X-Received: by 2002:aa7:d344:: with SMTP id m4mr12429707edr.297.1587831057278; Sat, 25 Apr 2020 09:10:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587831057; cv=none; d=google.com; s=arc-20160816; b=OpMM7aDzV9+UNtc1C9pVsxqhdT8PX8VA3soCa8eyv2XvlKvZieEc1L8Yuuroze/Qko OrIhv+1DT01ZT4ZRMpRo1S30/kbYeqZbi7dRsfomdel9Av/ROMfJahXTtXjRJzDz5cV4 aLMaz7UcWAomFLGj57FRsNG6M1vbDLRY8rHfcUU3u8zX6dZFNBraqIrYPapNY7y2SiB0 b24+nr4E24UMSwH92vDxgVimLDIgbFrkfTSh5lyUEUIQUZKYAISRJ6VhHMpMy2ANbAIT u5h7Gtb6+RNqe3QjVZhMfkqZaNyHTuIE7d67/VZjGzZQFkPhsVfd7bGNlGg+A9h3pFio gJmg== 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:subject:cc:to:from:date :dkim-signature; bh=nm1pUbn/D2/xpd5DA6Fi5L7E0q8dJk02d16ZQng0HQs=; b=v9+TdIIr+45e5X72zMRhPyLyYMYXqxy7MLfLeya28NIrqjDvNsTEb7QgeupXx+W7Lu mmO7czgoXsj5pIt3AjMvAILOzz+hS6JzLErU86jy77zNHaQn3yXeZGeCm7o+liHGZJ27 0LDawcQUJzWtfyGpTaS4u9iuKEmwyhswCyG/D6MRriW5+8LsDqV2wPUnobnJQlJA6cap kgJNCKPSVrkbfFoVnXbtUQZmvySPJn9IPptlaSgvX9AFu5Fi0T+wkl9rmcPGpXhP3yY/ lLfeNlY4tg3VXGOgbcdEzzkDmjJ9N9nohfGKBSd6kPKeVozR2g19MPEFGl8VpG4jZ+2h MWvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xeQTsz2H; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ca19si5776837edb.334.2020.04.25.09.10.33; Sat, 25 Apr 2020 09:10:57 -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=pass header.i=@kernel.org header.s=default header.b=xeQTsz2H; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726144AbgDYQJR (ORCPT + 99 others); Sat, 25 Apr 2020 12:09:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:36916 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726076AbgDYQJR (ORCPT ); Sat, 25 Apr 2020 12:09:17 -0400 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E0BA32071E; Sat, 25 Apr 2020 16:09:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587830957; bh=D7BBrL9B2g9quMzqYC+c4PGNXXBaDGjBMYSEbY32ULE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=xeQTsz2HowrC1MlzlTj2hmjl0g1HBpL4QMQd4eQQgwiFaPnQ7oo0eo7dmBauz4T6o WyGw0T6zCQL5UTFRIer4KBtK7MiIvEhSX8Ar0sDZZs8y61zG4OM9UCX1JhpKisa0au X9EPrFUPlxq9/11HGewHL9ipn+z3Qbrosh3ReYCA= Date: Sat, 25 Apr 2020 17:09:12 +0100 From: Jonathan Cameron To: Mathieu Othacehe Cc: Andy Shevchenko , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald , linux-iio , Linux Kernel Mailing List Subject: Re: [PATCH v4 4/4] iio: vcnl4000: Add buffer support for VCNL4010/20. Message-ID: <20200425170912.17c3435a@archlinux> In-Reply-To: <87tv1cos2q.fsf@gmail.com> References: <20200421075532.19192-1-m.othacehe@gmail.com> <20200421075532.19192-5-m.othacehe@gmail.com> <87tv1cos2q.fsf@gmail.com> X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 22 Apr 2020 10:14:21 +0200 Mathieu Othacehe wrote: > >> +static int vcnl4010_buffer_predisable(struct iio_dev *indio_dev) > >> +{ > >> + struct vcnl4000_data *data = iio_priv(indio_dev); > >> + int ret, ret_disable; > >> + > >> + ret = i2c_smbus_write_byte_data(data->client, VCNL4010_INT_CTRL, 0); > >> + if (ret < 0) > >> + goto end; > >> + > >> + ret = i2c_smbus_write_byte_data(data->client, VCNL4000_COMMAND, 0); > >> + > >> +end: > > > >> + ret_disable = iio_triggered_buffer_predisable(indio_dev); > >> + if (ret == 0) > >> + ret = ret_disable; > > > > What is this? > > > > Can't you rather call IIO API first, and then try to handle the rest? > > Well, iio_triggered_buffer_predisable will call free_irq which requires > that the interruption source is disabled, hence this strange pattern. > > However, this may be some misunderstanding from me, but I noticed > something strange here. In a configuration with one CPU and > CONFIG_PREEMPT disabled, I have kernel lockups when disabling the > buffer. > > This is because free_irq calls synchronize_irq that will wait for any > IRQ handler to be over. If the kthread handling the interruption is > still running, it has no chances to terminate, and synchronize_irq waits > forever. So maybe I'm missing something. That is indeed worrying. The synchronize_irq is documented as sleeping if we have a threaded interrupt. From a quick look I'd have expected the wait in there to result in the interrupt thread being able to complete whether or not we had preemption enabled. I wonder what I'm missing... Jonathan > > Anyway, I'll send a v5 addressing your remarks. > > Thanks, > > Mathieu