Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp1876282ybc; Wed, 20 Nov 2019 05:35:05 -0800 (PST) X-Google-Smtp-Source: APXvYqx3gtchY0daiFebjazfZL+c/jgwZJMP1SPaRMAa8uxchea/jtSGeqMdoLSTDdqJMoZSzsGF X-Received: by 2002:a17:907:4300:: with SMTP id oa24mr5493066ejb.8.1574256904930; Wed, 20 Nov 2019 05:35:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574256904; cv=none; d=google.com; s=arc-20160816; b=unBv8MtDAHDEeVBgAZ1d5+/KHKPKSvkeUpcT23Ph7bMekgz/zjsQMlB/ecYZErAFDh khEa9Gx8VTrOpsW1ER51RrsLPA1CuUvfh4bng60bTfwEeQw6cTlutoXUOiazYG3yOniK GNw/VBoutj2UOw+gc11Vhkvf54F4qJGasENfv7eRsO5aHBWJDTjkiquXiqCFWr5qHaFm 0cXWXJOY0kAOw2JM6Qvdl4BJ9OaWypOFltfUO2PpsGTIddSS5JuOL9js8VVj+X1sborR xcqKHZR7aaSF4hMo/rM1MJE8tYd8v4YITXzBXVqnbBuE9lzidVe2dQU8smkxg7O+m+Kj Gk3w== 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=POkZP8bg0Wf7WEWUqZbJgF6CcNkn7Fy/LrOQ1RrCBzE=; b=cQDV3I5w7gb+TeJ5qqJnH4jxPH4fc7huNuza9iI1k8tCSfCIgToTVcO3M4Rs5gWGoZ /yHSM8qXxH/3m0z9I4/dnm6kkzBJZi9In4Mi0IOLS5F00i3VwtXr+sZJ8YgKoOvN6Lw3 1ZcFY94KTDsVGJ2UAgWtd/oPpr20l9N/fn1hlYbgtDCo48gJx1hlQCRfaRRSzX1GmNMu cV8kALY8Pb/aKL4DyvE9q8fMOKBRNMCO6bmWbHKWIGSYERskU2z9Ru7zK4wpT9z1BXIy n5cuRM7Mh74CspWLT9E+xTko9xRjXahC0NFYZA7uU+o5vGdXHK8NVJryz6m5o5D5hlG/ 5KTg== 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 k21si16045101ejc.148.2019.11.20.05.34.40; Wed, 20 Nov 2019 05:35:04 -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 S1729679AbfKTMXx (ORCPT + 99 others); Wed, 20 Nov 2019 07:23:53 -0500 Received: from inca-roads.misterjones.org ([213.251.177.50]:60894 "EHLO inca-roads.misterjones.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729026AbfKTMXw (ORCPT ); Wed, 20 Nov 2019 07:23:52 -0500 Received: from www-data by cheepnis.misterjones.org with local (Exim 4.80) (envelope-from ) id 1iXP1R-0002tb-PO; Wed, 20 Nov 2019 13:23:49 +0100 To: =?UTF-8?Q?Andreas_F=C3=A4rber?= Subject: Re: [PATCH v4 2/8] irqchip: Add Realtek RTD1295 mux driver 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: Wed, 20 Nov 2019 12:23:49 +0000 From: Marc Zyngier Cc: , , , Aleix Roca Nonell , James Tai , Thomas Gleixner , Jason Cooper In-Reply-To: <37b3b5d3-b3c8-b513-f8b5-9054f32a4b53@suse.de> References: <20191119021917.15917-1-afaerber@suse.de> <20191119021917.15917-3-afaerber@suse.de> <0bff78c1-a1d0-9631-fbf4-e0d1ef1264ea@suse.de> <8137861d0a89dd246b3334ac596da8be@www.loen.fr> <37b3b5d3-b3c8-b513-f8b5-9054f32a4b53@suse.de> Message-ID: <3d74bc591552a22b06f6f77190cbfec5@www.loen.fr> 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, kernelrocks@gmail.com, james.tai@realtek.com, 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-20 12:12, Andreas Färber wrote: > Am 20.11.19 um 11:18 schrieb Marc Zyngier: >> On 2019-11-19 23:25, Andreas Färber wrote: >>> Am 19.11.19 um 13:01 schrieb Marc Zyngier: >>>> On 2019-11-19 02:19, Andreas Färber wrote: >>>>> diff --git a/drivers/irqchip/irq-rtd1195-mux.c >>>>> b/drivers/irqchip/irq-rtd1195-mux.c >>>>> new file mode 100644 >>>>> index 000000000000..e6b08438b23c >>>>> --- /dev/null >>>>> +++ b/drivers/irqchip/irq-rtd1195-mux.c >>> [...] >>>>> +static void rtd1195_mux_irq_handle(struct irq_desc *desc) >>>>> +{ >>>>> +    struct rtd1195_irq_mux_data *data = >>>>> irq_desc_get_handler_data(desc); >>>>> +    struct irq_chip *chip = irq_desc_get_chip(desc); >>>>> +    u32 isr, mask; >>>>> +    int i; >>>>> + >>>>> +    chained_irq_enter(chip, desc); >>>>> + >>>>> +    isr = readl_relaxed(data->reg_isr); >>>>> + >>>>> +    while (isr) { >>>>> +        i = __ffs(isr); >>>>> +        isr &= ~BIT(i); >>>>> + >>>>> +        mask = data->info->isr_to_int_en_mask[i]; >>>>> +        if (mask && !(data->scpu_int_en & mask)) >>>>> +            continue; >>>>> + >>>>> +        if (!generic_handle_irq(irq_find_mapping(data->domain, >>>>> i))) >>>>> +            writel_relaxed(BIT(i), data->reg_isr); >>>> >>>> What does this write do exactly? It is the same thing as a 'mask', >>>> which is pretty odd. So either: >>>> >>>> - this is not doing anything and your 'mask' callback is bogus >>>>   (otherwise you'd never have more than a single interrupt) >>>> >>>> - or this is an ACK operation, and this should be described as >>>>   such (and then fix the mask/unmask/enable/disable mess that >>>>   results from it). >>> >>> This is supposed to be an ACK, i.e. clear-1-bits operation. >> >> If it is an ACK, model it as such, and do not open-code it. > > I have found an .irq_ack callback - moving this there appears to > work. > > Alternatively there is an irq_eoi callback and an > IRQCHIP_EOI_IF_HANDLED > flag. > > It would really help me if you spelled out explicitly where you think > I > should be moving code, as the documentation in irq.h is not all that > helpful in terms of when are they called and what should be done > there. > In case not obvious, this is my first irqchip driver. Implementing one callback or the other really depends on how the HW behaves. The irq framework gives you a wide range of flows that allow you to plug your driver in the stack, but the prerequisite is that you know *exactly* how the HW behaves. Ack and EOI have very different meanings, are called from different flows, and correspond to different states in the interrupt life cycle. Use the wrong one, and you will lose interrupts. If you don't know how the HW behaves, then the chances of something bad happening are pretty high (you'll end-up in deadlock land at some point). I'm afraid I cannot help you with that, short of being given access to some documentation that doesn't seem to exist. M. -- Jazz is not dead. It just smells funny...