Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp353300rwb; Wed, 21 Sep 2022 23:57:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Ea+O3/afL43SAmx1F//denUXjH6XoMFNY7zqyibhjbzluorugZekpSKjqJTiNsedIZYbJ X-Received: by 2002:aa7:c610:0:b0:44e:9a0f:753a with SMTP id h16-20020aa7c610000000b0044e9a0f753amr1757393edq.140.1663829836048; Wed, 21 Sep 2022 23:57:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663829836; cv=none; d=google.com; s=arc-20160816; b=gLcR3ZEDZy8r9u5Q0gDJ57Ojn5ByY+YpRkswK0hcdH6zqHXqJaVZ4G1kABNg000Khp 3kd5gK1dHWciEp0lMe5CpCXrBRYJLShC+Skfhioleyj6Hdfe4mU8W5VbBQG4TL5s4AeY cG0QX1V8tL6ffYHuxQI/uBE3eP8G+SVKOFG9ZDRALlHipd1L6pCCiwjcba97+v4HaqV4 2Z/dfHyFWBKWi1gVGp7sM2EQJidDIBT1JAdtfNY2cVgHdxMUio7mcnH/7hzI69qBug4v DqstFydXVFCtQ7MrJ5vvfHBqlTmfEKCcDDmiC4FrYoFdr7GRxTw3b3Y4h/Lmj0HkTaVi xVSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=F/e1JPlHkuPobKR8svZ3nWeTTrTnp+M9ecDUY6t2TzI=; b=b8WK6GAiGWIIBo8RaiHcYvvzX/lOEWNjzq2GZW7d/xE8SfoZ2OzjTGim+LmAaxP3B7 +Y0yp0DoiGDOWmg7TPCq32mr3gi/5Lz38CYhvv5LLGoHToDxB+9KBP/z6h+iHS3o7iDE 5OKkXOxgto9HAUD0l+hRip+9g5mgkZ87Ywgh5kNxxghB0faqQl1Cr/9G3HcdoZBTb2ZW Hrt6qirjKMt5PjFrIKg/90UZY2M+xSi8DnYi1+NXKfdhXTBEtZq28VQujoNYstqKlbB0 e6v9FpvZPirB+IfhASEVASipbYaWcoscsWnCScjQQP/JbdiBxDmIFyhjWsas+XtwCmU/ rOPA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i17-20020a0564020f1100b00453bc1fda81si4315784eda.556.2022.09.21.23.56.50; Wed, 21 Sep 2022 23:57:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230155AbiIVGkW (ORCPT + 99 others); Thu, 22 Sep 2022 02:40:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230081AbiIVGkU (ORCPT ); Thu, 22 Sep 2022 02:40:20 -0400 Received: from mail-qt1-f177.google.com (mail-qt1-f177.google.com [209.85.160.177]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9961ACA2F; Wed, 21 Sep 2022 23:40:18 -0700 (PDT) Received: by mail-qt1-f177.google.com with SMTP id c11so5670167qtw.8; Wed, 21 Sep 2022 23:40:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=F/e1JPlHkuPobKR8svZ3nWeTTrTnp+M9ecDUY6t2TzI=; b=1QtR7/Y4f7Az3e7b+CjKoI2Bk/8emyGvxs8Z1F6jeuMB77HwLCSdTzi+bFL4qjKTdG MMmFaKNIvm7ROOfiedzq42s4luG3OibaJ5hmDTNDXtZsPWpPjmHOE5ezxN8aaTpOWyeR 3gmY/mbukmv4VWxxADpgDZIByyWY7JvWddR6qpzDuHxcjzKaPDmgNQNOz6xcogdEJw99 /cgY5+WNvHN9kBueBvuv7X9eV4K3qf3wKqkNsF2XkAEhHnqCOd/lRBz7PLL+wORbt1LQ 9CTRCYxf7UcdEXXhEl8elE4FW5U52biDJeJ7h7EHMbEmL9QhIgia9RA2x7Y+ABojX0Ex G+3Q== X-Gm-Message-State: ACrzQf0Y5KRJRZg0yFQwI87T0PzbZM/0fDaLp+KE3ogLO0J39Yx75Ks0 gDgFlGhXpUmz0UvQGyVftwlw0O3B+Ce+jGDZ X-Received: by 2002:ac8:5c0b:0:b0:35c:e066:998d with SMTP id i11-20020ac85c0b000000b0035ce066998dmr1575511qti.336.1663828817401; Wed, 21 Sep 2022 23:40:17 -0700 (PDT) Received: from mail-yw1-f169.google.com (mail-yw1-f169.google.com. [209.85.128.169]) by smtp.gmail.com with ESMTPSA id bl21-20020a05620a1a9500b006ce30a5f892sm3191406qkb.102.2022.09.21.23.40.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 21 Sep 2022 23:40:17 -0700 (PDT) Received: by mail-yw1-f169.google.com with SMTP id 00721157ae682-3450990b0aeso88276527b3.12; Wed, 21 Sep 2022 23:40:16 -0700 (PDT) X-Received: by 2002:a0d:dd09:0:b0:344:fca5:9b44 with SMTP id g9-20020a0ddd09000000b00344fca59b44mr1713044ywe.358.1663828816340; Wed, 21 Sep 2022 23:40:16 -0700 (PDT) MIME-Version: 1.0 References: <45d2e6c2-3b4b-5720-0431-002c74b1f9cc@arm.com> <0603b2a5-6253-4c4b-8b30-aa0253ed0480@www.fastmail.com> In-Reply-To: <0603b2a5-6253-4c4b-8b30-aa0253ed0480@www.fastmail.com> From: Geert Uytterhoeven Date: Thu, 22 Sep 2022 08:40:05 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Similar SoCs with different CPUs and interrupt bindings To: Arnd Bergmann Cc: Robin Murphy , Rob Herring , Krzysztof Kozlowski , Andre Przywara , "Conor.Dooley" , Samuel Holland , Biju Das , Chris Paterson , Atish Patra , "Lad, Prabhakar" , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , linux-riscv , Linux ARM , Linux-Renesas , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Arnd, On Thu, Sep 22, 2022 at 8:30 AM Arnd Bergmann wrote: > On Wed, Sep 21, 2022, at 11:20 AM, Robin Murphy wrote: > > On 2022-09-21 08:46, Geert Uytterhoeven wrote: > >> This is a topic that came up at the RISC-V BoF at Plumbers, and it was > >> suggested to bring it up with you. > >> > >> The same SoC may be available with either RISC-V or other (e.g. ARM) CPU > >> cores (an example of this are the Renesas RZ/Five and RZ/G2UL SoCs). > >> To avoid duplication, we would like to have: > >> - .dtsi includes .dtsi, > >> - .dtsi includes .dtsi. > >> > >> Unfortunately RISC-V and ARM typically use different types of interrupt > >> controllers, using different bindings (e.g. 2-cell vs. 3-cell), and > >> possibly using different interrupt numbers. Hence the interrupt-parent > >> and interrupts{-extended} properties should be different, too. > >> > >> Possible solutions[1]: > >> 1. interrupt-map > >> > >> 2. Use a SOC_PERIPHERAL_IRQ() macro in interrupts properties in > >> .dtsi, with > >> - #define SOC_PERIPHERAL_IRQ(nr, na) nr // RISC-V > >> - #define SOC_PERIPHERAL_IRQ(nr, na) GIC_SPI na // ARM > >> Note that the cpp/dtc combo does not support arithmetic, so even > >> the simple case where nr = 32 + na cannot be simplified. > >> > >> 3. Wrap inside RISCV() and ARM() macros, e.g.: > >> > >> RISCV(interrupts = <412 IRQ_TYPE_LEVEL_HIGH>;) > >> ARM(interrupts = ;) > >> > >> Cfr. ARM() and THUMB() in arch/arm/include/asm/unified.h, as used > >> to express the same operation using plain ARM or ARM Thumb > >> instructions. > > > > 4. Put all the "interrupts" properties in the SoC-specific DTSI at the > > same level as the interrupt controller to which they correspond. Works > > out of the box with no horrible mystery macros, and is really no more or > > less error-prone than any other approach. Yes, it means replicating a > > bit of structure and/or having labels for everything (many of which may > > be wanted anyway), but that's not necessarily a bad thing for > > readability anyway. Hierarchical definitions are standard FDT practice > > and should be well understood, so this is arguably the simplest and > > least surprising approach :) > > FWIW, approaches 1, 2 and 4 all seem reasonable to me, but I don't > like number 3 if this is only about the IRQ definitions. We also have to handle interrupt-parent at the /soc level. And of course you never know what pops up next ;-) > It sounds like we're already converging on #2, so just one more > idea from me: we could fold the IRQ type into the macro, and > make it just take a single argument for extra flexibility: > > #define SOC_PERIPHERAL_IRQ_LEVEL_HIGH(nr) \ > GIC_SPI (nr + offset) IRQ_TYPE_LEVEL_HIGH > > If all the irqs on the chip have the same type, the name > can be shorter of course. This is usually the case, but not always. And the numbering may be the same (modulo the offset), but not it really depends on the on-SoC wiring. > Either way, some variation of the macro sounds like a good enough > approach to me. Thanks! Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds