Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2846796pxb; Fri, 12 Feb 2021 02:59:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJxWeNSl7rjzmy9DSXPc9t9kmdRvknuzAIc8KnmiDHHTcpHjTbV0ES2f6P/OtkoTAKiOgHVF X-Received: by 2002:a17:906:c455:: with SMTP id ck21mr2498025ejb.354.1613127594501; Fri, 12 Feb 2021 02:59:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613127594; cv=none; d=google.com; s=arc-20160816; b=aFxIZAJSDH7j2GcpzT7RH9mTIOjlqrNUzfcon/eypVWH9ECJ3d9J0+Md/hpX60p1gb ruWtV/sZ2aHiYcjk4V/SGp1F9xQJGbeynB+ds6A49pS7c7DupNbzqzi3gwLYZQjQS1Xh GD28JctR+Urw+ak6E8/lvsKTu3ts8GqRmfXvzfX1cihLHJZDvl+HWsJAaOotLzfzI6un /BP51BS0vIkR92ZlYgVK6AMns9bDvY8oNuy9wODLmLXmYVA6JEC0jPmXiCiU7dB4J0dO vNq3u/YkXk9fGMuE44aZD4fizZLrZs7rTA9XYhG3BpEMMPdB3C4hP3Ob1d8aOZqKFg2/ uiyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=RehvZe62zlz2PupH+qpak9Exw2PtKPKJXE9HJ/axV7A=; b=I6YXATA8dMnqw8p16mhL1dQhB3xJwC6c+tJac/8AgYY4SfG6V4vYrmkmXfxc2u2He+ EaH7QLllwSUEz7319ayL2USQR+/NAHidqOkKYz5xTb/el34lkjsqGYjmK6LduXn2ne2k ip+p05wFeQZWoBVzllHYwEeAVBhbLs4arPbVAAI0mlufbQFx1uZwPasorsLRL0R5YyPH C+/O9dA1MHfkALydn1Tc1oFfjcSsBz0lsw5EwxZ6Nx2G9ImXGoejLSOc9pLP/F2Di5zs prOuPffWiR/VadwyzUPTtLi0/V5Es+16GBSGbgJ5HmHt12SI8OjZqF+FKBz9QZvw/HsD x41g== 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x19si5783275ejj.294.2021.02.12.02.59.31; Fri, 12 Feb 2021 02:59:54 -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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230514AbhBLK54 (ORCPT + 99 others); Fri, 12 Feb 2021 05:57:56 -0500 Received: from mga12.intel.com ([192.55.52.136]:3862 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230499AbhBLK5x (ORCPT ); Fri, 12 Feb 2021 05:57:53 -0500 IronPort-SDR: Msc0ne6Lli93QUSjLrdfc72tcHLuSbHjcEh5PmS3Rrv+NfDtBP6NeUI9F/JyJE6pLFEsIfSkSX EtNFov53YncQ== X-IronPort-AV: E=McAfee;i="6000,8403,9892"; a="161537835" X-IronPort-AV: E=Sophos;i="5.81,173,1610438400"; d="scan'208";a="161537835" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2021 02:57:13 -0800 IronPort-SDR: ds8EiGl430OaoxknE8C9zs40H3BgYQzYvPR/X7Z+E8ucm0P/b7n3OftSrChzWiUuBQk7Gq+365 gVOawMkQrvNA== X-IronPort-AV: E=Sophos;i="5.81,173,1610438400"; d="scan'208";a="376309979" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2021 02:57:11 -0800 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1lAW8K-004SjL-14; Fri, 12 Feb 2021 12:57:08 +0200 Date: Fri, 12 Feb 2021 12:57:08 +0200 From: Andy Shevchenko To: "Song Bao Hua (Barry Song)" Cc: Grygorii Strashko , Arnd Bergmann , luojiaxing , Linus Walleij , Santosh Shilimkar , Kevin Hilman , "open list:GPIO SUBSYSTEM" , "linux-kernel@vger.kernel.org" , "linuxarm@openeuler.org" Subject: Re: [Linuxarm] Re: [PATCH for next v1 1/2] gpio: omap: Replace raw_spin_lock_irqsave with raw_spin_lock in omap_gpio_irq_handler() Message-ID: References: <1612774577-55943-1-git-send-email-luojiaxing@huawei.com> <1612774577-55943-2-git-send-email-luojiaxing@huawei.com> <2a12cf7a21f74a0c9e2552a467b77fae@hisilicon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2a12cf7a21f74a0c9e2552a467b77fae@hisilicon.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 12, 2021 at 10:42:19AM +0000, Song Bao Hua (Barry Song) wrote: > > From: Grygorii Strashko [mailto:grygorii.strashko@ti.com] > > Sent: Friday, February 12, 2021 11:28 PM > > On 12/02/2021 11:45, Arnd Bergmann wrote: > > > On Fri, Feb 12, 2021 at 6:05 AM Song Bao Hua (Barry Song) > > > wrote: > > >>> Note. there is also generic_handle_irq() call inside. > > >> > > >> So generic_handle_irq() is not safe to run in thread thus requires > > >> an interrupt-disabled environment to run? If so, I'd rather this > > >> irqsave moved into generic_handle_irq() rather than asking everyone > > >> calling it to do irqsave. > > > > > > In a preempt-rt kernel, interrupts are run in task context, so they clearly > > > should not be called with interrupts disabled, that would defeat the > > > purpose of making them preemptible. > > > > > > generic_handle_irq() does need to run with in_irq()==true though, > > > but this should be set by the caller of the gpiochip's handler, and > > > it is not set by raw_spin_lock_irqsave(). > > > > It will produce warning from __handle_irq_event_percpu(), as this is IRQ > > dispatcher > > and generic_handle_irq() will call one of handle_level_irq or handle_edge_irq. > > > > The history behind this is commit 450fa54cfd66 ("gpio: omap: convert to use > > generic irq handler"). > > > > The resent related discussion: > > https://lkml.org/lkml/2020/12/5/208 > > Ok, second thought. irqsave before generic_handle_irq() won't defeat > the purpose of preemption too much as the dispatched irq handlers by > gpiochip will run in their own threads but not in the thread of > gpiochip's handler. > > so looks like this patch can improve by: > * move other raw_spin_lock_irqsave to raw_spin_lock; > * keep the raw_spin_lock_irqsave before generic_handle_irq() to mute > the warning in genirq. Isn't the idea of irqsave is to prevent dead lock from the process context when we get interrupt on the *same* CPU? -- With Best Regards, Andy Shevchenko