Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2551095rdh; Sun, 29 Oct 2023 23:44:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHbIdtnMkV7I/UeLjqrXP9JBpKxajutgxPFGDIh6MO0MMKzWgGsLGfy5QVepgmOI4FaBgA6 X-Received: by 2002:a17:90b:613:b0:27d:3fa4:9d9a with SMTP id gb19-20020a17090b061300b0027d3fa49d9amr5808561pjb.29.1698648274212; Sun, 29 Oct 2023 23:44:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698648274; cv=none; d=google.com; s=arc-20160816; b=hhscG9ddJKZic6S2NdNpoQXHMo7/+XuAA/b68pAOCMyaZSJAKLTR0y72VeR43+K2dX cWS1lnGpwKpklk7LHu4kdXk0tRlETaE6Et90eaq1idLuWmR1XbjDsloMba9TkkhE7R22 vac5eTWEbxokolQOq8sAhbDcHa5IQSoPTYV/XGEwMmGDN5U+o6rMVUuiVhi3nPBLIFXN j00Mqpm8W7f23p45jhbjCSjNN7FaaORfmWdRX7MPLk+VXX4dNOZ7R1yA85ERwY+dz2ns OietTMSLKQ+oqGo+8eEQH5TFE6PxHkljE4xEtUfK9oFzKaJEzVknXCkRcUW8AdK26IQd FFEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=fdQBxQPfZIPpAvNC7NxnysI/eAD5OLPyNYsQPg7ikb4=; fh=Z3+Z5vsrTIIegE9cYf8YSHA4XzLl28UsaXsOSrPVIAk=; b=0KzFE3xMNjpgHkclRxeGELtVa/VfIo9xzjGZ5XNOGW1uMzq18gl31MgznFut/i6bKl dDsJPTIE3ZRaBIWr9odF5wnHCuj0llv6COYotqDx3e7vDHhZvmcgjXxwItYihkDIOneT sSiKP+X3me9YjiZLlCOO6jbj7b55MtoyDUpNhx8mHbq0Ol7LvRuMABihnZF9rOWkONbt TLMp3XN39LkMK5ER0U9r6jKmVnAGpRgORHVwCgZsMDKK0RsAiCFAgAIGW0sDjcJkSP5D +qRaK8rkVJQD2et1P8+eq8qiT/kmh86UIYEwU/Fuz1FxUPS/iD1KsnPQLDve4/5yInSu M/Cw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=andestech.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id d10-20020a17090a628a00b0026b49c1aa50si6421775pjj.111.2023.10.29.23.44.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Oct 2023 23:44:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=andestech.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id BA9F380AA246; Sun, 29 Oct 2023 23:44:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231720AbjJ3GoX (ORCPT + 99 others); Mon, 30 Oct 2023 02:44:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230477AbjJ3GoX (ORCPT ); Mon, 30 Oct 2023 02:44:23 -0400 Received: from Atcsqr.andestech.com (60-248-80-70.hinet-ip.hinet.net [60.248.80.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE14FAB for ; Sun, 29 Oct 2023 23:44:19 -0700 (PDT) Received: from mail.andestech.com (ATCPCS16.andestech.com [10.0.1.222]) by Atcsqr.andestech.com with ESMTP id 39U6hhxX026703; Mon, 30 Oct 2023 14:43:43 +0800 (+08) (envelope-from peterlin@andestech.com) Received: from APC323 (10.0.12.98) by ATCPCS16.andestech.com (10.0.1.222) with Microsoft SMTP Server id 14.3.498.0; Mon, 30 Oct 2023 14:43:40 +0800 Date: Mon, 30 Oct 2023 14:43:37 +0800 From: Yu-Chien Peter Lin To: Thomas Gleixner CC: , , , , , , , , , , Subject: Re: [PATCH v2 03/10] irqchip/riscv-intc: Introduce Andes IRQ chip Message-ID: References: <20231019135723.3657156-1-peterlin@andestech.com> <87cyx04k53.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <87cyx04k53.ffs@tglx> User-Agent: Mutt/2.2.10 (2023-03-25) X-Originating-IP: [10.0.12.98] X-DNSRBL: X-SPAM-SOURCE-CHECK: pass X-MAIL: Atcsqr.andestech.com 39U6hhxX026703 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sun, 29 Oct 2023 23:44:31 -0700 (PDT) Hi Thomas, On Fri, Oct 27, 2023 at 09:08:56AM +0200, Thomas Gleixner wrote: > On Thu, Oct 19 2023 at 21:57, Yu Chien Peter Lin wrote: > > This commit adds support for the Andes IRQ chip, which provides > > "This commit" is not any different from "This patch" and equaly > pointless. See Documentation/process/submitting-patches.rst Sure, will rewrite the commit message. Thanks for the pointer. > Also please write out interrupt instead of IRQ. Changelogs are text and > not subject to twitter limitations. OK! > > IRQ mask/unmask functions to access the custom CSR (SLIE) > > What is a CSR? These acronyms are really annoying for people who are not > familiar with the chip specific details. OK! > > +static void andes_intc_irq_mask(struct irq_data *d) > > +{ > > + unsigned int mask = BIT(d->hwirq % BITS_PER_LONG); > > + > > + if (d->hwirq < ANDES_SLI_CAUSE_BASE) > > This lacks a comment which explains why these hardware interrupts are > special. Sure, will add a comment here. > > + csr_clear(CSR_IE, mask); > > + else > > + csr_clear(ANDES_CSR_SLIE, mask); > > +} > > + > > +static void andes_intc_irq_unmask(struct irq_data *d) > > +{ > > + unsigned int mask = BIT(d->hwirq % BITS_PER_LONG); > > + > > + if (d->hwirq < ANDES_SLI_CAUSE_BASE) > > + csr_set(CSR_IE, mask); > > + else > > + csr_set(ANDES_CSR_SLIE, mask); > > +} > > + > > static void riscv_intc_irq_eoi(struct irq_data *d) > > { > > /* > > @@ -68,12 +89,35 @@ static struct irq_chip riscv_intc_chip = { > > .irq_eoi = riscv_intc_irq_eoi, > > }; > > > > +static struct irq_chip andes_intc_chip = { > > + .name = "RISC-V INTC", > > + .irq_mask = andes_intc_irq_mask, > > + .irq_unmask = andes_intc_irq_unmask, > > + .irq_eoi = riscv_intc_irq_eoi, > > https://www.kernel.org/doc/html/latest/process/maintainer-tip.html#struct-declarations-and-initializers OK, will fix. > > +}; > > + > > static int riscv_intc_domain_map(struct irq_domain *d, unsigned int irq, > > irq_hw_number_t hwirq) > > { > > + struct fwnode_handle *fn = riscv_get_intc_hwnode(); > > + struct irq_chip *chip; > > + const char *cp; > > + int rc; > > + > > irq_set_percpu_devid(irq); > > Why is this not moved after the failure condition too? > > > - irq_domain_set_info(d, irq, hwirq, &riscv_intc_chip, d->host_data, > > - handle_percpu_devid_irq, NULL, NULL); > > + > > + rc = fwnode_property_read_string(fn, "compatible", &cp); > > + if (rc) > > + return rc; > > + > > + if (strcmp(cp, "riscv,cpu-intc") == 0) > > + chip = &riscv_intc_chip; > > + else if (strcmp(cp, "andestech,cpu-intc") == 0) > > + chip = &andes_intc_chip; > > How is this supposed to work with ACPI? > > The obvious solution for this is to have two different init functions > > riscv_intc_init() > { > riscv_intc_init_common(..., &risc_intc_chip); > } > > riscv_andes_init() > { > riscv_intc_init_common(..., &andes_intc_chip); > } > > riscv_intc_init_common(...., *chip) > { > // Set the interrupt chip pointer as domain host data > irqdomain_create_linear(...., chip); > } > > and then you can use that in the map function: > > chip = domain->host_data; > > See? Got it! Will reimplement according to this method. > > diff --git a/include/linux/irqchip/irq-riscv-intc.h b/include/linux/irqchip/irq-riscv-intc.h > > new file mode 100644 > > index 000000000000..87c105b5b545 > > --- /dev/null > > +++ b/include/linux/irqchip/irq-riscv-intc.h > > @@ -0,0 +1,12 @@ > > +/* SPDX-License-Identifier: GPL-2.0-only */ > > +/* > > + * Copyright (C) 2023 Andes Technology Corporation > > + */ > > +#ifndef __INCLUDE_LINUX_IRQCHIP_IRQ_RISCV_INTC_H > > +#define __INCLUDE_LINUX_IRQCHIP_IRQ_RISCV_INTC_H > > + > > +#define ANDES_SLI_CAUSE_BASE 256 > > +#define ANDES_CSR_SLIE 0x9c4 > > +#define ANDES_CSR_SLIP 0x9c5 > > + > > +#endif /* __INCLUDE_LINUX_IRQCHIP_IRQ_RISCV_INTC_H */ > > What's the purpose of this header file? The defines are only used in the > interrupt chip driver code, so they can just be in the C file. No? > > Thanks, These definitions are shared with drivers/perf/riscv_pmu_sbi.c, however, I should not add vendor specific things here, they will be move to include/linux/soc/andes/irq.h. Thanks for the review! Best regards, Peter Lin > tglx >