Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp965830rdh; Fri, 27 Oct 2023 00:09:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHxAkoAC7L2F5kuFUKtYkHk9ivXFaNkO0GQ0LRisBAulupwdo0W+cmO+UvNNVdVtnz9zTla X-Received: by 2002:a05:620a:198f:b0:773:be2d:7cd2 with SMTP id bm15-20020a05620a198f00b00773be2d7cd2mr2005804qkb.45.1698390571694; Fri, 27 Oct 2023 00:09:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698390571; cv=none; d=google.com; s=arc-20160816; b=Wj5zOaKDEP+iS7UWK0tOUUP00SGQZ7mxBZW/7Y+HaAbG0iaUKDywDNJaKg2CTYAR3l ceCbvlxCzqHnKUy73kl7Jqx0H4jH0d0VWMD2u32c+7EY8V/vbHVIqM43Cp8hhqBxPkN+ ekZscl+6C2H5mLDR6Zu5Qc/D5Xsr0ybe3nH3uoAmrvegnMD2znPMAfSaqMSr88Lr50J3 ebbV53D5QAWCzJfKzyQ6n7rmci1ySUw+dmm/2y7GwtxLfjPqJApjy2/5M8Yv7zP/0rhB ZRxxLvyD1PnVQJGqSXo8Y2ULaoPpPfs+zBKjXwWCja8/teiF//LgDqqCLNxmfOrLd953 zfog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=gS2w1/Bfi8i6DDWcB/LYnN4Uyo2XoSjAzsAo+3P1rhE=; fh=kKQMfKemUsemKp0ohV/y/fDl3UnEm0fv+KFuMAV/Jbc=; b=tLavsQtaBeRJfBf9/EqZfuzg4wSJEhqBS1QdlpRGaUxjP05JawbCrWB0EkMlPgRD2R zki2t8UAU+zgl3hqvqhrjC3pQNVfAKJ5OX73S5BFe/LGNbKllB4taRY2WkQ4+uL57oB8 u2Xt7G/Fpm9FqIYKmsvccqvawvWBJXIR9WVNzGUa44Bs4N66rvyYV5DBxWxKv/QqAg4g o5cCliZ1Ic+L+SZuZl/9s0Y3MuoRgtvPXEBch6b3Tkh7ADtOO2Nc5+hpEZByTHxFDkbQ CKQCqqIhGn7BoobufgRW+7D0/h43rfPVDKLIpjO0/mXqef3AhQD5N6i3oHw609+inl0Q 7itg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=xJaI0I9S; dkim=neutral (no key) header.i=@linutronix.de header.b=mzDDZLL+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id d188-20020a0df4c5000000b005a204618ad3si1478979ywf.505.2023.10.27.00.09.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 00:09:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=xJaI0I9S; dkim=neutral (no key) header.i=@linutronix.de header.b=mzDDZLL+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 8088A833E941; Fri, 27 Oct 2023 00:09:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345347AbjJ0HJD (ORCPT + 99 others); Fri, 27 Oct 2023 03:09:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234963AbjJ0HJB (ORCPT ); Fri, 27 Oct 2023 03:09:01 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B502D40 for ; Fri, 27 Oct 2023 00:08:59 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1698390536; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=gS2w1/Bfi8i6DDWcB/LYnN4Uyo2XoSjAzsAo+3P1rhE=; b=xJaI0I9SbdRA1MUAA10lTxRe2PJdlTYZ/qKVe0NWxISoDDj4gxn3k5+iGHyIwkuUdido4r GT135+ErpzXcWFhZp7og8M5O8ngvIQUPdOJIfzU8dDxMGCO9cD30fiox9lMs10V4WS3RvY 2wUb9I9IqM+qxJQ74vCwfvC/hN4iocLaBOzfEgHw7Ua6Z1MoTTiauAacOj37Vd2+gX8YsT QFHwJ/X1uwsm6ySO1UD5dgixQ9f2avOn5cbD0lKisFarWGzu/HuE7qhO/c8zutS37jBH85 pB6Go2qgq7pcMzxnrjC5XuyWj4EOkZg6XPQsA9UAAH8z6jcZenKshY5GbM51OQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1698390536; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=gS2w1/Bfi8i6DDWcB/LYnN4Uyo2XoSjAzsAo+3P1rhE=; b=mzDDZLL+KpmOjCnUAj9qbTtDUBoyxrHa5hR+TMailW3l5FE+Ru0fipv0s8ca4dDVeymvaz gaZBzqjr3/jRiOBA== To: Yu Chien Peter Lin , paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, peterlin@andestech.com, dminus@andestech.com, ycliang@andestech.com, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Cc: prabhakar.mahadev-lad.rj@bp.renesas.com, tim609@andestech.com, dylan@andestech.com, locus84@andestech.com Subject: Re: [PATCH v2 03/10] irqchip/riscv-intc: Introduce Andes IRQ chip In-Reply-To: <20231019135723.3657156-1-peterlin@andestech.com> References: <20231019135723.3657156-1-peterlin@andestech.com> Date: Fri, 27 Oct 2023 09:08:56 +0200 Message-ID: <87cyx04k53.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 fry.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 (fry.vger.email [0.0.0.0]); Fri, 27 Oct 2023 00:09:28 -0700 (PDT) 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 Also please write out interrupt instead of IRQ. Changelogs are text and not subject to twitter limitations. > 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. > +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. > + 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 > +}; > + > 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? > 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, tglx