Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp841680ybl; Thu, 12 Dec 2019 05:50:29 -0800 (PST) X-Google-Smtp-Source: APXvYqymez6qgMnex9LPMSZxyvqzyAYplxOQj5f/VDuw+GZpzTCMzNQcVU8sRQMPSf2ihMzUrQqy X-Received: by 2002:a9d:7495:: with SMTP id t21mr8267999otk.86.1576158629588; Thu, 12 Dec 2019 05:50:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576158629; cv=none; d=google.com; s=arc-20160816; b=Dqcp+AMeO2Pmm1bYl1RobkQXSVyQVR69FeWaadgwYfy3PJAK7m9YY/9KYm+D58blLy 38vEuVEdf5LTO1V33HCYafk/JoOJPmLnoCdK/m64yx895tRD0v48+syxuEmiTAJKyl65 v+A7pDaBADzzPgzhjWuyJuk4f+Z33bBBFu7rrDPpM4LDZIbeRHWl4wDXUv49OlutgOe4 7eGHFMXbzwuONSOVyxm7YxTuJpnC8gNWNtjj2W0MbWTwvVQMZTtvVG2GW6HkZ7Rr/sf0 jNeKjV7pal9BPxsY9GllW/XnGQVqyHX+autQwVJhIQycHyWHVIfqc1cUH2lkrU5hJCCq lfBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:cc:from:date:content-transfer-encoding:mime-version :subject:to; bh=NkFYC1lQfGM7R6L91ngZBpY+i5njNEm1QcSfkairwog=; b=k87op72yizZ4muHtQ4eWC+VH7f4zDOX/yDppvvcko3kpi+DENW9NGlCX7CkOfOVF0t GzS+TNnI6EDoyg84baIgpbqSZAmiJ64f477BFTw9F8LweiY6H2Qvt5VjznJKzFb50Bwf L0MzTxOcStwKl7OccuT0nOxZzLxlyOWRP5lcsYsusK1RkbVjhmEh7bjEczY6LZxc3XRt gEZ2Mo5ZcuqagIcxTheueVj3tDSW6W+erGP2cUqDuvxHe3ymfBupwl6O/bitXOI/7IFH rsDOKWbp05X4CtFyMg4Occv1W85jgOs1EE23cdc/Jk2iyHWMlVRKB24S6LT7ixjxU1X6 kJJg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k126si3201632oib.43.2019.12.12.05.50.16; Thu, 12 Dec 2019 05:50:29 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729490AbfLLNsn (ORCPT + 99 others); Thu, 12 Dec 2019 08:48:43 -0500 Received: from inca-roads.misterjones.org ([213.251.177.50]:48589 "EHLO inca-roads.misterjones.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729405AbfLLNsn (ORCPT ); Thu, 12 Dec 2019 08:48:43 -0500 Received: from www-data by cheepnis.misterjones.org with local (Exim 4.80) (envelope-from ) id 1ifOpd-0002Ct-8N; Thu, 12 Dec 2019 14:48:41 +0100 To: =?UTF-8?Q?Andreas_F=C3=A4rber?= Subject: Re: [PATCH v5 3/9] irqchip: rtd1195-mux: Implement =?UTF-8?Q?irq=5Fget=5Firqchip=5Fstate?= X-PHP-Originating-Script: 0:main.inc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Thu, 12 Dec 2019 13:48:41 +0000 From: Marc Zyngier Cc: , , , Thomas Gleixner , Jason Cooper In-Reply-To: <20191121050208.11324-4-afaerber@suse.de> References: <20191121050208.11324-1-afaerber@suse.de> <20191121050208.11324-4-afaerber@suse.de> Message-ID: X-Sender: maz@kernel.org User-Agent: Roundcube Webmail/0.7.2 X-SA-Exim-Connect-IP: X-SA-Exim-Rcpt-To: afaerber@suse.de, linux-realtek-soc@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, jason@lakedaemon.net X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on cheepnis.misterjones.org); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-11-21 05:02, Andreas Färber wrote: > Implement the .irq_get_irqchip_state callback to retrieve pending, > active and masked interrupt status. > > Signed-off-by: Andreas Färber > --- > v5: New > > drivers/irqchip/irq-rtd1195-mux.c | 36 > ++++++++++++++++++++++++++++++++++++ > 1 file changed, 36 insertions(+) > > diff --git a/drivers/irqchip/irq-rtd1195-mux.c > b/drivers/irqchip/irq-rtd1195-mux.c > index 0e86973aafca..2f1bcfd9d5d6 100644 > --- a/drivers/irqchip/irq-rtd1195-mux.c > +++ b/drivers/irqchip/irq-rtd1195-mux.c > @@ -7,6 +7,7 @@ > > #include > #include > +#include > #include > #include > #include > @@ -96,10 +97,45 @@ static void rtd1195_mux_unmask_irq(struct > irq_data *data) > raw_spin_unlock_irqrestore(&mux->lock, flags); > } > > +static int rtd1195_mux_get_irqchip_state(struct irq_data *data, > + enum irqchip_irq_state which, bool *state) > +{ > + struct rtd1195_irq_mux_data *mux = > irq_data_get_irq_chip_data(data); > + u32 val; > + > + switch (which) { > + case IRQCHIP_STATE_PENDING: > + /* > + * UMSK_ISR provides the unmasked pending interrupts, > + * except UART and I2C. > + */ > + val = readl_relaxed(mux->reg_umsk_isr); > + *state = !!(val & BIT(data->hwirq)); > + break; > + case IRQCHIP_STATE_ACTIVE: > + /* > + * ISR provides the masked pending interrupts, > + * including UART and I2C. > + */ > + val = readl_relaxed(mux->reg_isr); > + *state = !!(val & BIT(data->hwirq)); > + break; ACTIVE has a very specific meaning: it indicates that the interrupt is being handled right now. What this tells you is whether the interrupt is pending and unmasked, which is an entirely different thing. This will lead to irq_disable() misbehaving (it will assume that the interrupt is active while it is only pending). Given what the HW exposes (or rather, what this driver exposes of the HW), I don't think you can implement this state. > + case IRQCHIP_STATE_MASKED: > + val = mux->info->isr_to_int_en_mask[data->hwirq]; > + *state = !(mux->scpu_int_en & val); Shouldn't you take the corresponding spinlock given that you can have a pending update in parallel? M. > + break; > + default: > + return -EINVAL; > + } > + > + return 0; > +} > + > static const struct irq_chip rtd1195_mux_irq_chip = { > .irq_ack = rtd1195_mux_ack_irq, > .irq_mask = rtd1195_mux_mask_irq, > .irq_unmask = rtd1195_mux_unmask_irq, > + .irq_get_irqchip_state = rtd1195_mux_get_irqchip_state, > }; > > static int rtd1195_mux_irq_domain_map(struct irq_domain *d, -- Jazz is not dead. It just smells funny...