Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1412833pxb; Sat, 16 Apr 2022 07:55:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRgnVx8jqMj1X2Gml/Ox4aEyzhyfp9vP8tGx2RmauFVIMARe+2v6JcVIbwBh7mlR0oXQ7O X-Received: by 2002:a17:906:1603:b0:6ce:362:c938 with SMTP id m3-20020a170906160300b006ce0362c938mr3007164ejd.253.1650120938322; Sat, 16 Apr 2022 07:55:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650120938; cv=none; d=google.com; s=arc-20160816; b=qQnWfrt2dksmk2LhC7HjKu7YCgcM8T0L/PhngLA2DNI90OtcgI4N8yM3chq2rBtv3M lnZFHUGdRq1aHWocbCgdXXUs8FtciDLVkVbu9kGy5+FkUKIDljwLG8KS+OO1S72nXXD6 D/PoYJuL2PRZIAZZyPtTf2ER5ny0JA3snQ/nXOCJkoek36UUI+TVEbWoyZNF++dayfh4 V59bSRJetFT/sGx4PwBnGAm/++GiSG+bCvnirQutTxYjnjS7j0td44Ih8FSlhp1/CaWq KSPYqROKnKccR/MkFCgh0H0ewAZKeGwhgzWtvJ2AMLdSk6mIeyEq9VaTrPZ6hxS1JoGJ Dnbg== 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:dkim-signature; bh=ksyY81buYHpBvFd7vVUwYBF2PVx3FJm7Czy6ELpPmDI=; b=FLcFv/nd/RwQPwY+8ToDpIH/H4bqIG+RgFatO1bdmdVv6+/mBoEwauW5LoKKt3t3DM wTtB/lW6QXNUwhAoyTxyg9854lkBH34CHbUubhtuDNh4gkfuJ0yG2UjbVEYN51kGy3dd KNad17rE8WrffxPshMsHMuKMzbolzEBw7oklN5PLu08KCFG2JOdOdtTmxgAaohIbPPKl 0MYVH9CjEsR0lEbUlWiSq0UrcVbDP1sAExPfgBLc8bnP8p9XXCIZWCf4hsukTMJjCXq5 xWws6aAczgIsTTCWYcnQ0CTu0ww0jGSFn8FMWbp0l85IFNM9Y/wHxcCp62C8WnrIrc4/ v4ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=GghB9GPS; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z3-20020a05640240c300b0041d93698583si3602029edb.565.2022.04.16.07.55.13; Sat, 16 Apr 2022 07:55:38 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=GghB9GPS; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232049AbiDPN1K (ORCPT + 99 others); Sat, 16 Apr 2022 09:27:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230237AbiDPN1J (ORCPT ); Sat, 16 Apr 2022 09:27:09 -0400 Received: from mail-yw1-x1136.google.com (mail-yw1-x1136.google.com [IPv6:2607:f8b0:4864:20::1136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2271C4EDCD; Sat, 16 Apr 2022 06:24:38 -0700 (PDT) Received: by mail-yw1-x1136.google.com with SMTP id 00721157ae682-2f16645872fso3881917b3.4; Sat, 16 Apr 2022 06:24:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ksyY81buYHpBvFd7vVUwYBF2PVx3FJm7Czy6ELpPmDI=; b=GghB9GPS+QOJ/7hViErvgFw3KSyG8IIwgdRWCfXWqkO/cBbHxLgav4XQ/SGEo9BV9M Xij1Z6SCwrOwJuDah6XoCqUe8FAPZTSZGR6OaqeQsjd/DsrbKrl41GkWEkphVDNDj17b 3AyiKVsURXFp7UfuKAsS9q9UM97q5vrQw6HVa1T+ywAsKwUW5O0oNkArXqAYKrkBi2fV yUjudMnB1jljICD/9LKWlUXsCRR0KRJ6Oo4Ue+htkiK/COIVjbi8zzOZ7fU1Te6vqwxG gowc8SX8s/uT7239+jSshvrsvpEt4SDQae9u2JAI08+ybX8qpehl5c5kiZlcSwOQm72H kLkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ksyY81buYHpBvFd7vVUwYBF2PVx3FJm7Czy6ELpPmDI=; b=AkWOgsOHg4cTh3L7ePpmSHLMnSPbIX1r1kdo2Y0URGiNwy3emr86t3P1tFZP/B8HGV hIseeX77DkKHDwzSwgrWAUfAQZA8zMDvpCFTXikNGHoLE9tpo6Ch/Zo5RkA/Z3Op6Een zw+Pw5HP3AFcfBTyv4NNr68RJnDokO/5GyfgjazLpFsxoH8XRDU8nAUeWjw/MZDHKz1a 8vJZilgLJmjeqCyU6VmVWRi1uzPLKmx/WPJSqYgEHs5uj81aw8Wsf3Uj8/Oi8uam1kLk GYFAozfZvBEgIzsOHQdggCpuI6aCviUmJsoLJRxvuM2o7iubfBDLwhUOChO0arF5wy7m uyIQ== X-Gm-Message-State: AOAM530Yl/36F2EHcQ2tSL/3KAKhHFvc1ukHCqTN4cELXldFLMSAzhhn HeqzDkZcBa0FBmS21185yEXP/BpR0izeMA8wUfYib3PbVTrStQ== X-Received: by 2002:a81:5904:0:b0:2eb:f900:882e with SMTP id n4-20020a815904000000b002ebf900882emr2888532ywb.281.1650115477295; Sat, 16 Apr 2022 06:24:37 -0700 (PDT) MIME-Version: 1.0 References: <20220416110507.642398-1-pgwipeout@gmail.com> <20220416110507.642398-3-pgwipeout@gmail.com> <308e9c47197d4f7ae5a31cfcb5a10886@kernel.org> In-Reply-To: <308e9c47197d4f7ae5a31cfcb5a10886@kernel.org> From: Peter Geis Date: Sat, 16 Apr 2022 09:24:26 -0400 Message-ID: Subject: Re: [PATCH v7 2/4] PCI: dwc: rockchip: add legacy interrupt support To: Marc Zyngier Cc: Lorenzo Pieralisi , Rob Herring , =?UTF-8?Q?Krzysztof_Wilczy=C5=84ski?= , Bjorn Helgaas , Heiko Stuebner , "open list:ARM/Rockchip SoC..." , PCI , devicetree , arm-mail-list , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 On Sat, Apr 16, 2022 at 8:54 AM Marc Zyngier wrote: > > Peter, > > May I suggest that you slow down on the number of versions you send? > This is the 7th in 5 days, the 3rd today. > > At this stage, this is entirely counterproductive. Apologies, I'll be sure to be at least one cup of coffee in before doing early morning code. > > On 2022-04-16 12:05, Peter Geis wrote: > > The legacy interrupts on the rk356x pcie controller are handled by a > > single muxed interrupt. Add irq domain support to the pcie-dw-rockchip > > driver to support the virtual domain. > > > > Signed-off-by: Peter Geis > > --- > > drivers/pci/controller/dwc/pcie-dw-rockchip.c | 112 +++++++++++++++++- > > 1 file changed, 110 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/pci/controller/dwc/pcie-dw-rockchip.c > > b/drivers/pci/controller/dwc/pcie-dw-rockchip.c > > index c9b341e55cbb..863374604fb1 100644 > > --- a/drivers/pci/controller/dwc/pcie-dw-rockchip.c > > +++ b/drivers/pci/controller/dwc/pcie-dw-rockchip.c > > @@ -10,9 +10,12 @@ > > > > #include > > #include > > +#include > > +#include > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > @@ -36,10 +39,13 @@ > > #define PCIE_LINKUP (PCIE_SMLH_LINKUP | PCIE_RDLH_LINKUP) > > #define PCIE_L0S_ENTRY 0x11 > > #define PCIE_CLIENT_GENERAL_CONTROL 0x0 > > +#define PCIE_CLIENT_INTR_STATUS_LEGACY 0x8 > > +#define PCIE_CLIENT_INTR_MASK_LEGACY 0x1c > > #define PCIE_CLIENT_GENERAL_DEBUG 0x104 > > -#define PCIE_CLIENT_HOT_RESET_CTRL 0x180 > > +#define PCIE_CLIENT_HOT_RESET_CTRL 0x180 > > #define PCIE_CLIENT_LTSSM_STATUS 0x300 > > -#define PCIE_LTSSM_ENABLE_ENHANCE BIT(4) > > +#define PCIE_LEGACY_INT_ENABLE GENMASK(3, 0) > > +#define PCIE_LTSSM_ENABLE_ENHANCE BIT(4) > > #define PCIE_LTSSM_STATUS_MASK GENMASK(5, 0) > > > > struct rockchip_pcie { > > @@ -51,6 +57,8 @@ struct rockchip_pcie { > > struct reset_control *rst; > > struct gpio_desc *rst_gpio; > > struct regulator *vpcie3v3; > > + struct irq_domain *irq_domain; > > + raw_spinlock_t irq_lock; > > }; > > > > static int rockchip_pcie_readl_apb(struct rockchip_pcie *rockchip, > > @@ -65,6 +73,94 @@ static void rockchip_pcie_writel_apb(struct > > rockchip_pcie *rockchip, > > writel_relaxed(val, rockchip->apb_base + reg); > > } > > > > +static void rockchip_pcie_legacy_int_handler(struct irq_desc *desc) > > +{ > > + struct irq_chip *chip = irq_desc_get_chip(desc); > > + struct rockchip_pcie *rockchip = irq_desc_get_handler_data(desc); > > + unsigned long reg, hwirq; > > + > > + chained_irq_enter(chip, desc); > > + > > + reg = rockchip_pcie_readl_apb(rockchip, > > PCIE_CLIENT_INTR_STATUS_LEGACY); > > + > > + for_each_set_bit(hwirq, ®, 8) > > 8? And yet: > > #define PCI_NUM_INTX 4 > > So whatever bits are set above bit 3, you are feeding garbage > to the irqdomain code. There are 8 bits in total, the top four are for the TX interrupts, for which EP mode is not yet supported by the driver. I can constrain this further and let it be expanded when that support is added, if that works for you? > > > + generic_handle_domain_irq(rockchip->irq_domain, hwirq); > > + > > + chained_irq_exit(chip, desc); > > +} > > + > > +static void rockchip_intx_mask(struct irq_data *data) > > +{ > > + struct rockchip_pcie *rockchip = irq_data_get_irq_chip_data(data); > > + unsigned long flags; > > + u32 val; > > + > > + /* disable legacy interrupts */ > > + raw_spin_lock_irqsave(&rockchip->irq_lock, flags); > > + val = HIWORD_UPDATE_BIT(PCIE_LEGACY_INT_ENABLE); > > + val |= PCIE_LEGACY_INT_ENABLE; > > + rockchip_pcie_writel_apb(rockchip, val, > > PCIE_CLIENT_INTR_MASK_LEGACY); > > + raw_spin_unlock_irqrestore(&rockchip->irq_lock, flags); > > This is completely busted. INTx lines must be controlled individually. > If I disable one device's INTx output, I don't want to see the > interrupt firing because another one has had its own enabled. Okay, that makes sense. I'm hitting the entire block when it should be the individual IRQ. I also notice some drivers protect this with a spinlock while others do not, how should this be handled? > > M. > -- > Jazz is not dead. It just smells funny... Thanks Again!