Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp5946405pxb; Tue, 16 Feb 2021 11:30:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJzDbp7wm/hmN6KzpFSAAykVopPt3EzdgDYWNRafBmIxnej0VWGnF5cZZpzTRQelk/7ghhEr X-Received: by 2002:a50:fe04:: with SMTP id f4mr22793413edt.63.1613503800910; Tue, 16 Feb 2021 11:30:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613503800; cv=none; d=google.com; s=arc-20160816; b=z1RXDYFIRro8Y0/6Ux/LcqENATDPll4O1G/5V74bFO/CHFWg8MkcRLbGFNhH01T0rQ +aN+Ky5YKAx8P1CZ4oo4Vd1be2swpdosVP6VgEFgWB4ILmtjNOKqTKvXUTSioSlfPumE N3RxDJFNsmGjPdjLCGNh12X4KhLGCVNBH1hotX1MSka2wpwA1wQ5Ta6Jg0m8dMSTlOgL ciPwswGuxJM0wFmf5COnPedZP+aLn8Vx4Lcx8jK78/jF4CL7mqvgs78h1k6ac692qQi2 ladtogx6RKJ4GyPZ00VNCiRH7ZiA/i0Z1eGWLN9CTeu+mdXi6Yj0+svM1eu59+xrlWtl g0FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=OCPQgnbjLgA7YVvQBbgmxVfVKFKhfnAewkU/b7kYeps=; b=i4EW8NO7VuBujDBGw78ipJ9l/iGNq2SFKrwgMf3Jv4oPmMjnMHLKdKAH1kjZu3OtU3 zvvSflvGE4ExOnjmtuZg9LoUDC+cd1RJUdbkq+wr/duElkw8MzyCGSIfY8x5T+YxoZZh Joslyw193DnwJWfDQ30SB6QUwsdAO/S6SxuCBPJXPj4dVzp/a6TyYyeKQdKtNiokdqz6 WU6qizWrwfkaI3y0+PnW+o0jq6vX48dxV10Pwv1jqv3Z73kTTdIzFKZUpoz4fCFMK3xp 7XmTfL6Uc7leXilWtbNYHUAxdMRRx5JUye4PQdd1NCeX3iBwUEzfdAeWmYuI8wJMrCl1 goYg== ARC-Authentication-Results: i=1; mx.google.com; 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 p5si15029087ejo.398.2021.02.16.11.29.35; Tue, 16 Feb 2021 11:30:00 -0800 (PST) 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; 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 S230119AbhBPT2M (ORCPT + 99 others); Tue, 16 Feb 2021 14:28:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:53742 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230049AbhBPT2H (ORCPT ); Tue, 16 Feb 2021 14:28:07 -0500 Received: from archlinux (cpc108967-cmbg20-2-0-cust86.5-4.cable.virginm.net [81.101.6.87]) (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 A079F64ED0; Tue, 16 Feb 2021 19:27:23 +0000 (UTC) Date: Tue, 16 Feb 2021 19:27:20 +0000 From: Jonathan Cameron To: William Breathitt Gray Cc: kernel@pengutronix.de, linux-stm32@st-md-mailman.stormreply.com, a.fatoum@pengutronix.de, kamel.bouhara@bootlin.com, gwendal@chromium.org, alexandre.belloni@bootlin.com, david@lechnology.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, syednwaris@gmail.com, patrick.havelange@essensium.com, fabrice.gasnier@st.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, o.rempel@pengutronix.de Subject: Re: [PATCH v8 21/22] counter: 104-quad-8: Replace mutex with spinlock Message-ID: <20210216192720.75082d22@archlinux> In-Reply-To: References: <20210214181946.1d2f7e78@archlinux> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 16 Feb 2021 11:16:03 +0900 William Breathitt Gray wrote: > On Sun, Feb 14, 2021 at 06:19:46PM +0000, Jonathan Cameron wrote: > > On Fri, 12 Feb 2021 21:13:45 +0900 > > William Breathitt Gray wrote: > > > > > This patch replaces the mutex I/O lock with a spinlock. This is in > > > preparation for a subsequent patch adding IRQ support for 104-QUAD-8 > > > devices; we can't sleep in an interrupt context, so we'll need to use a > > > spinlock instead. > > > > > > Cc: Syed Nayyar Waris > > > Signed-off-by: William Breathitt Gray > > > > Why do these need to be raw_spin_locks? > > Normally only need to do that if in code related to interrupt chips etc, > > not their use. > > > > Jonathan > > This lock can be taken in an interrupt context in a subsequent patch: > counter_push_event() called by quad8_irq_handler() can end up calling > the Counter component callbacks which take this lock. We can't use a > mutex nor a regular spinlock because those can sleep on RT setups [1] But on RT setups the interrupts become threads and are preemptable etc, so that shouldn't matter. There are a few corner cases that cause trouble, but in most normal drivers you should be fine with a spin_lock. Jonathan > which would result in a deadlock due to the interrupt context here -- so > therefore we're left with using raw_spin_lock. > > [1] https://lwn.net/Articles/367219/ > > William Breathitt Gray