Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp1146750ybc; Tue, 19 Nov 2019 15:27:12 -0800 (PST) X-Google-Smtp-Source: APXvYqwIkyEbphtdksf+6i5b5Frb3zsBRdFrRq9BoQaG663iZAyBAkwwh46pEmqXIbmrx7f1F1Py X-Received: by 2002:a17:906:459:: with SMTP id e25mr408720eja.259.1574206032526; Tue, 19 Nov 2019 15:27:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574206032; cv=none; d=google.com; s=arc-20160816; b=lM3oP5WVAwgT6wncbj4JJ+ruaI8ArpBEOh/NALQUVxP+tt4eHnkQWT+CU6QYziTOvo KIIVrqDDE2j+xP6WYK89Usemih0YXk84pumZnu4LHIhvCfHh+JELlhRSyKGw058OvQUW pbLREvVu3cMt38ELoo+aMYfZKk9B2iCHQGOjQNDI/hkkgYoaAiFzFFiDYXBJPn/GylfO tPtrOOWQV0JZzn2V0Xp1Lp8S5hRMyXpdFXU7PRNOOZGwOtydvhMfWImgBYIkoxwz67O0 AjeJc4ge/AJZwRSVMr++ItyK2bOVUYwRc9TJtwgXhrNAEb93NpFq0VFmfdiMyD6pdtJJ tukg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject; bh=R4jj+m/kbaidDaonPjoLWvhIZf+0NQ/2YE3iCC2EGXk=; b=xhbemaUcrGA/AdFzplUITfmB3uk6Im3L6i1gXZXOJc8es7HpCNBpXawVNWfkW2V7A6 VxwsS7PLrbcRUZUjjlQOFNWZr8w8bkOjqPsacqKO7sJzLkkRISCeYTnMb8vy3XspLwVb KMOTdTxt7/jDwWC4U8VNrKjRyPSHeruD0qAJTGIwDloIBWHYrzyIVl4N1XujhOlMMyil jiy734yR6CJx3PTBARTTkT7t/9qauc/4ZSGfa8zPY0Dj78Wv07Et2WBgnw5GwU46R3IE Sp38ZyfmCwRf2Ln8i7JxSf6iMXpuLtCyNmQd3mrM6MdZ03Dk2edKIZIuu5uiibVoe3qz BZKA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k39si17785659edb.99.2019.11.19.15.26.48; Tue, 19 Nov 2019 15:27:12 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727389AbfKSXZ3 (ORCPT + 99 others); Tue, 19 Nov 2019 18:25:29 -0500 Received: from mx2.suse.de ([195.135.220.15]:33424 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726911AbfKSXZ3 (ORCPT ); Tue, 19 Nov 2019 18:25:29 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id D9B13ACC0; Tue, 19 Nov 2019 23:25:26 +0000 (UTC) Subject: Re: [PATCH v4 2/8] irqchip: Add Realtek RTD1295 mux driver To: Marc Zyngier Cc: linux-realtek-soc@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Aleix Roca Nonell , James Tai , Thomas Gleixner , Jason Cooper References: <20191119021917.15917-1-afaerber@suse.de> <20191119021917.15917-3-afaerber@suse.de> From: =?UTF-8?Q?Andreas_F=c3=a4rber?= Organization: SUSE Software Solutions Germany GmbH Message-ID: <0bff78c1-a1d0-9631-fbf4-e0d1ef1264ea@suse.de> Date: Wed, 20 Nov 2019 00:25:25 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. The BSP had extended various drivers, such as 8250 UART, to do this ack in their interrupt handler through an additional DT reg region. I tried to clean that up by handling it centrally here in the irqchip driver. > > as I can't see how the same register can be used for both purposes. > You should be able to verify this experimentally, even without > documentation. There are three registers here: MIS_UMSK_ISR - MISC unmasked interrupt status register MIS_ISR - MISC masked interrupt status register MIS_SCPU_INT_EN - MISC SCPU interrupt enable register The latter is a regular R/W register; the former two have a write_data field as BIT(0), with 1 indicating a write vs. 0 indicating clear, RAZ. By enabling/disabling in _SCPU_INT_EN we mask/unmask them in _ISR but not in _UMSK_ISR. Does that shed any more light? So given that we're iterating over reg_isr above, we could probably drop the mask check here... In addition there are MIS_[UMSK_]ISR_SWC and MIS_SETTING_SWC registers for Secure World, and MIS_FAST_INT_EN_* and MIS_FAST_ISR as well as various GPIO interrupt registers. Regards, Andreas >> +    } >> + >> +    chained_irq_exit(chip, desc); >> +} >> + >> +static void rtd1195_mux_mask_irq(struct irq_data *data) >> +{ >> +    struct rtd1195_irq_mux_data *mux_data = >> irq_data_get_irq_chip_data(data); >> + >> +    writel_relaxed(BIT(data->hwirq), mux_data->reg_isr); >> +} >> + >> +static void rtd1195_mux_unmask_irq(struct irq_data *data) >> +{ >> +    struct rtd1195_irq_mux_data *mux_data = >> irq_data_get_irq_chip_data(data); >> + >> +    writel_relaxed(BIT(data->hwirq), mux_data->reg_umsk_isr); >> +} >> + >> +static void rtd1195_mux_enable_irq(struct irq_data *data) >> +{ >> +    struct rtd1195_irq_mux_data *mux_data = >> irq_data_get_irq_chip_data(data); >> +    unsigned long flags; >> +    u32 mask; >> + >> +    mask = mux_data->info->isr_to_int_en_mask[data->hwirq]; >> +    if (!mask) >> +        return; > > How can this happen? You've mapped the interrupt, so it exists. > I can't see how you can decide to fail such enable. > >> + >> +    raw_spin_lock_irqsave(&mux_data->lock, flags); >> + >> +    mux_data->scpu_int_en |= mask; >> +    writel_relaxed(mux_data->scpu_int_en, mux_data->reg_scpu_int_en); >> + >> +    raw_spin_unlock_irqrestore(&mux_data->lock, flags); >> +} >> + >> +static void rtd1195_mux_disable_irq(struct irq_data *data) >> +{ >> +    struct rtd1195_irq_mux_data *mux_data = >> irq_data_get_irq_chip_data(data); >> +    unsigned long flags; >> +    u32 mask; >> + >> +    mask = mux_data->info->isr_to_int_en_mask[data->hwirq]; >> +    if (!mask) >> +        return; >> + >> +    raw_spin_lock_irqsave(&mux_data->lock, flags); >> + >> +    mux_data->scpu_int_en &= ~mask; >> +    writel_relaxed(mux_data->scpu_int_en, mux_data->reg_scpu_int_en); >> + >> +    raw_spin_unlock_irqrestore(&mux_data->lock, flags); >> +} >> + >> +static struct irq_chip rtd1195_mux_irq_chip = { >> +    .name        = "rtd1195-mux", >> +    .irq_mask    = rtd1195_mux_mask_irq, >> +    .irq_unmask    = rtd1195_mux_unmask_irq, >> +    .irq_enable    = rtd1195_mux_enable_irq, >> +    .irq_disable    = rtd1195_mux_disable_irq, >> +}; > > [...] > > Although the code is pretty clean, the way you drive the HW looks > suspicious, and requires clarification. > > Thanks, > >         M. -- SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Felix Imendörffer HRB 36809 (AG Nürnberg)