Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp362492ybb; Fri, 3 Apr 2020 04:16:00 -0700 (PDT) X-Google-Smtp-Source: APiQypKOFollb9yoSSeUylduS9D9gHwQXFUcb+iEkcENc5d7FDezjndVrXT9EDIltqaEZ43h2HLz X-Received: by 2002:aca:ecd7:: with SMTP id k206mr2517024oih.113.1585912559933; Fri, 03 Apr 2020 04:15:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585912559; cv=none; d=google.com; s=arc-20160816; b=nVRHughAEQKy3G4DZd0AebxXB2bzF4PVx6hZR1g3f3DS7+r2U/X08fqd/reHQkOYNo 54iypM/pOemVjrkGEISQNNcJixwyBpNzwZ3oSloILPjznjId7hAW220mFliDsrZOUQP9 VZSaaAllsMAgsfM11ptpDM92eUlY6Bz65XTpuFWfbW/rJS7wAjpK79Z/jWfdtpqKY1N5 UdM14ovCo2E6fZYXXjo4zMc9OlYNUtcxzAyIKYK+OxWuDuDCq8r19KZrwM6r9pMHDa92 ayjLJhhEheg3aU6R5azJNn04bHIpEEqfEFJQX96F/bjatSljIjS2kOUhTvrmcKnNlgj2 PclQ== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=JvWqGNGSWU6DWrsOHOFKdACpD+bY4oqNaVseQCkk5wY=; b=dCzBRnh/9tauIV4B9Rk417zS16FLMuDWvYhzgdEIGLxMSVE5lNHaJXN/Risz+pjp4/ ZXK1IQWmqU51mgj+ol4P3OrAE2YZjvHl4Penq6pPWdwAyRD9PF+IeqM+se+E1ZBUhPQa SI34K4UP8qr4QAusy14aW7liwCBqMBgAkiwzFt/7qnSqI88cbXt5l6noJBD8DHO4rx3u 3qJqSB0Cvfu9kQebliwa71fdPTgJxv6u5p6m9Ld7f8TMj8NBOfJV9B0dvmy5lMLJ2zkp M/IOMVFsMiVV+0dw89pMVij60e/NhuB+MkMKfgGR+GaVAoEWb2qiIl5ca+Fkabo7+sdR sQGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qSIUF3zG; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l13si3368652oib.268.2020.04.03.04.15.45; Fri, 03 Apr 2020 04:15:59 -0700 (PDT) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qSIUF3zG; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390716AbgDCLNt (ORCPT + 99 others); Fri, 3 Apr 2020 07:13:49 -0400 Received: from mail-wr1-f43.google.com ([209.85.221.43]:35228 "EHLO mail-wr1-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727968AbgDCLNs (ORCPT ); Fri, 3 Apr 2020 07:13:48 -0400 Received: by mail-wr1-f43.google.com with SMTP id g3so5745123wrx.2 for ; Fri, 03 Apr 2020 04:13:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=JvWqGNGSWU6DWrsOHOFKdACpD+bY4oqNaVseQCkk5wY=; b=qSIUF3zGi9tV3IrF1qe82YGqzafnUkfe/mm+KL59FIbShzEdN2pLPv2S7/ANxsUC/Z gR0ENOe+P6wpalquOb7E6clVPjAxAmkuv3b0r1MdZ0PTNwrpb7FEXsu05Tr/8gwUDWZp esPfXBSgQD+qwhI0epBNbG6RYiwfKIlDtONttjwfjEq/9ZaAWHKTVoIYVbV4r8prlVAw nhXwgy/1nB5lqGW9yxv4pCsfyt3maUZwLE+YAz79JCTLTW6ofF3UZX7efDwNJHYmWOrm q9OFeRWLP+3g7vbSMR7dhKetiqpJPNnO2cIsikLujJ23xRrdr9TQ6HNdwKff61JcmTyT E0fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=JvWqGNGSWU6DWrsOHOFKdACpD+bY4oqNaVseQCkk5wY=; b=fdVfOV0XyPlVLx1nwcwVrZKDZRZa1y+Kbh4aFzIZ7QOafQTPuFyQ0OW1BAVZ8f+rvl qME/dsAWxIyI+NYnQNxXS5MsF2ROrXnzA/RKNq+62B0I4iQ3m2X9MMzW1NSgc8p1GMRs BV2kpbF/8WPATveW/ZJjRhDwsHVfLM3HofDs+HgDfVao/QnXixdJFbvJSxE0SeK3JfNM 7Hb6f69ixPXrUaNlicOEsKvS7gamZ17FjeCzoYb9U9MZnHmL5vJLdTQp3OguiSDd1USK OMRMVJVWECmQC+vlIz1nXUUazmDsbqVSUBxwwhzXJ2hXDCoKw1kAuixYEucRRcXhGz50 JiQA== X-Gm-Message-State: AGi0PubBpSIUD0IIBIn4PV94PC84Y4UHicpLaJgkDn6fKfR2J3SWGwhY 6mwu0cn/ObLXroI2z4ibxEfm/XXBJeQQZN3TcyxDJw== X-Received: by 2002:adf:ff8b:: with SMTP id j11mr8958919wrr.117.1585912425936; Fri, 03 Apr 2020 04:13:45 -0700 (PDT) MIME-Version: 1.0 References: <3ebbe879471898218f34918b1d009887@kernel.org> In-Reply-To: <3ebbe879471898218f34918b1d009887@kernel.org> From: =?UTF-8?Q?Lu=C3=ADs_Matallui?= Date: Fri, 3 Apr 2020 05:13:35 -0600 Message-ID: Subject: Re: Help with IRQ-MSI-IRQ bridges To: Marc Zyngier Cc: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Marc, On Fri, 3 Apr 2020 at 04:18, Marc Zyngier wrote: > > Hi Luis, > > On 2020-04-03 02:35, Lu=C3=ADs Matallui wrote: > > Hi, > > > > I've got this SoC which uses IRQ-MSI and MSI-IRQ bridges in order to > > get interrupts from devices external to the ARM subsystem. > > I already got some pointers from Maz and have been able to create the > > drivers with the stacked domains and can now see the mappings working > > fine across domains. > > > > Maz pointed me to the Marvell mvebu-gicp (for my MSI controller, a.k.a > > MSI-IRQ bridge) and to mvebu-icu for the MSI client (IRQ-MSI bridge). > > > > I now have the interrupts working, but it seems like I'm missing a > > bunch of them. And therefore my device doesn't work properly. > > The main difference between my HW and Marvell's is that my IRQs are > > not level-triggered and the MSIs don't support the two messages for > > level-triggered interrupts. > > Which is probably a very good thing, as long as all your devices > generate > only edge-triggered interrupts. > > > > > To illustrate my system: > > > > DEV --line--> IRQ-MSI Bridge (MSIC) --msi--> MSI-IRQ Bridge (GICP) > > --line--> GICv2 > > > > For MSIC, all I can do is configure the address and data for the MSI, > > and I believe on every rising edge of the Device IRQ, an MSI is sent. > > For GICP, all I have is a doorbell and a way to enable/disable it, and > > whenever the doorbell is enabled and has a value !=3D 0, the IRQ line t= o > > GICv2 gets asserted. > > > > The first thing I noticed is that when I get an interrupt, the IRQ > > flow goes like: > > > > handle_irq(); > > irq_eoi(); > > > > So, I guess my first question here is, how can I guarantee that I > > don't get another MSI whilst in handle_irq()? > > At the GIC level, once the interrupt is Ack'd, anything that is signed > after this ack is a separate interrupt. It will be made pending and will > fire once the GIC driver EOIs the first one. The thing here is, there is no Ack, or at least my irqchips are not getting the irq_ack() callback, which is where I was expecting to clear the doorbel= l. > > > If I do, then I will clear the doorbell on irq_eoi() (because that's > > my only choice) and will lose the queued IRQs. > > Why do you need to do anything at the doorbell level? This is just a > write, > so there should be nothing to clear. If you do need to clear anything, > then your MSI-IRQ bridge isn't stateless as it should, and you'll need > to > give much more details about the HW. Do you have a pointer to the TRM > for your HW? The hardware is really simple. On the MSI controller (GICP) side, each interrupt only has 3 registers: 1 status, 1 mask and 1 clear. When an MSI lands a write on the status register, it asserts the interrupt line. The interrupt stays asserted until we clear the status (using the clear register). The mask register is just to enable the interrupt basically. The MSI data is really irrelevant, as long as it's non-zero we always obtain the same result. On the MSI client side, we only configure the MSI address and data for a certain device interrupt line, and for each rising edge, an MSI gets issu= ed. > > > It also seems that I'm missing IRQs in the beginning after probing the > > device, and before it was working for me when I was setting up all > > these registers manually and simply using GICv2 as my only interrupt > > controller. > > Well, setting all of this in firmware is always the preferred option > if you don't expect things to change dynamically. Well, the solution I have now works perfectly for the configuration, becaus= e the MSIC gets configured by msi_compose_msg -> msi_write_msg at IRQ allocation time and never gets touched again. Then when the IRQ gets activated, the GICP is unmasking the interrupt but enabling the doorbell (setting the mask register). The only thing I really need is to intercept every MSI before the handler s= o I can Ack it by clearing the doorbell status register. > > > I do see the unmask() ops being called for all my stacked irqchips, so > > I don't understand how I'm missing so many interrupts. > > unmask is just a static configuration to enable the interrupt. There > shouldn't > be that many calls to that later on unless an endpoint driver > disables/enables > interrupts by hand. > > Please give us a bit more details to understand the context, as there is > only > so much I can do with so little HW information. > > Thanks, > > M. > -- > Jazz is not dead. It just smells funny... Let me know if that is good enough information. There's really not much on the HW side. Thanks, Luis