From patchwork Mon Nov 2 11:44:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 11873685 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B3BBC2D0A3 for ; Mon, 2 Nov 2020 11:46:50 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E4971222B9 for ; Mon, 2 Nov 2020 11:46:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="dkPQLCHa"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="YVW84JmD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E4971222B9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ce7+eeINXqDa+PafbXZEJmGKn6WqYmzH3NHETm54LWQ=; b=dkPQLCHaKyme1gFdxOmAeu7EkC qsCXPDmSTfmAmtUvFd0YbNla3Ll/NztEnF3NSb0+VyOrPCEXipTlklmmgfPXhy8at2P9TD1EHZD7j krHA5jYY2fobH5jjPO1SRo9d/pJaTx0JU/cV2rWnFTpGBk3o9cIRirUrpZb7cjYChDT9vGAU0xTVM K0iPrjUSypb+kbh4idPtjS2Xs9RouNrnG6YEEPhGT1nXvtNYghYEfOsDxjHfy90l6+gQgX0l+vEND 8TvpwlbzTSFHnQiv0hoL8sSo0rWmqlvor7AH1DEkzvYwogzXK9LbnYRbY7f1UKbPMi6LWYEk8UWcM WJg+O/zw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kZYHs-0007FO-5f; Mon, 02 Nov 2020 11:46:12 +0000 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kZYHg-0007BE-RU for linux-arm-kernel@lists.infradead.org; Mon, 02 Nov 2020 11:46:03 +0000 Received: by mail-pf1-x442.google.com with SMTP id 133so10881261pfx.11 for ; Mon, 02 Nov 2020 03:46:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8pOpPNam2BTL4szbnxJp4LS7vtJkYCW9OQ62wkxqSGo=; b=YVW84JmDAp8DIjenSpzHBz73rPBLIFXlDsIDnEzlxzixQWBzr5oubMrEB0suStZQDA 5u6FcZCH8rb7meD9z1wNrw22eNmKkh3xbRJmMpuejN6q8yErP4k0xoX3Gm7mNElk5dwo IpBqFT+p+1Yu0zC1WTwVvn3fcNkP0p7hLTpUCXn+z4h+j74HvR7GvqMCTfcEpU71h3iM lQq9D0AfCb5fCIHihCcJGevGeBlNDHbCIgPFT0G3YCr7VP39+goGdwX8dAbQGQsyd02H QK5fpZergbM89BpvkMNpkQzDgvXD4K3gCopYVu+qJ/nfsrOElciYmtrDgPaXhj4dFbT1 vq5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8pOpPNam2BTL4szbnxJp4LS7vtJkYCW9OQ62wkxqSGo=; b=KMuqj86BaByYh6QBokxXcjFQfQz8XBirmScMsCk2orQhLl1ftFdUtAP0CY5wfQIW4n Qw3WQLub9fNJlsldU3XjFiAza54ld0I7IjVGj3RjpnxmdzX4mFUgl9FqvEmOzTwpZWBc 3jnJZpPDXmQb95SNVY6uE7kCBaa5ZnmaSxCI2FW17f4whM9hp/svSM55TMnLcpiPpyEM ioHtZ9QnNw3YTugE3Y19CPU7XUODAefeQD64qBAlHElbaCTmdOH3HaWfEnSifXBF7Anz zCC5TL3mV8vOygQ5coBSb58iClOiLazLk7fSyonUQHmvZ15vt4TYfm7LV9Tq7Eys4tug q0Bw== X-Gm-Message-State: AOAM533gyIpE91BfpCFg2ag3CwF7NfmNYuEZnwNN7A5aibul3sneDrdJ Den25QVOcwhbpShasjq1awf8OA== X-Google-Smtp-Source: ABdhPJwO3VPcjiMibXY/VqKjgGT4CpMVBqGEJct7m1nqiv5+M4BIMRRSqvYKD5zYQ9yu5ohzOtLOmA== X-Received: by 2002:a17:90b:111:: with SMTP id p17mr17758894pjz.159.1604317558334; Mon, 02 Nov 2020 03:45:58 -0800 (PST) Received: from localhost.localdomain ([122.173.169.225]) by smtp.gmail.com with ESMTPSA id y5sm14276184pfq.79.2020.11.02.03.45.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Nov 2020 03:45:57 -0800 (PST) From: Sumit Garg To: maz@kernel.org, catalin.marinas@arm.com, will@kernel.org, daniel.thompson@linaro.org Subject: [PATCH v7 2/7] irqchip/gic-v3: Enable support for SGIs to act as NMIs Date: Mon, 2 Nov 2020 17:14:42 +0530 Message-Id: <1604317487-14543-3-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1604317487-14543-1-git-send-email-sumit.garg@linaro.org> References: <1604317487-14543-1-git-send-email-sumit.garg@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201102_064601_061659_A486BF55 X-CRM114-Status: GOOD ( 16.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, Sumit Garg , tsbogend@alpha.franken.de, linux-kernel@vger.kernel.org, jason@lakedaemon.net, ito-yuichi@fujitsu.com, mpe@ellerman.id.au, x86@kernel.org, linux@armlinux.org.uk, dianders@chromium.org, mingo@redhat.com, bp@alien8.de, julien.thierry.kdev@gmail.com, jason.wessel@windriver.com, kgdb-bugreport@lists.sourceforge.net, tglx@linutronix.de, msys.mizuma@gmail.com, davem@davemloft.net, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add support to handle SGIs as pseudo NMIs. As SGIs or IPIs default to a special flow handler: handle_percpu_devid_fasteoi_ipi(), so skip NMI handler update in case of SGIs. Also, enable NMI support prior to gic_smp_init() as allocation of SGIs as IRQs/NMIs happen as part of this routine. Signed-off-by: Sumit Garg --- drivers/irqchip/irq-gic-v3.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index 16fecc0..7010ae2 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -461,6 +461,7 @@ static u32 gic_get_ppi_index(struct irq_data *d) static int gic_irq_nmi_setup(struct irq_data *d) { struct irq_desc *desc = irq_to_desc(d->irq); + u32 idx; if (!gic_supports_nmi()) return -EINVAL; @@ -478,16 +479,22 @@ static int gic_irq_nmi_setup(struct irq_data *d) return -EINVAL; /* desc lock should already be held */ - if (gic_irq_in_rdist(d)) { - u32 idx = gic_get_ppi_index(d); + switch (get_intid_range(d)) { + case SGI_RANGE: + break; + case PPI_RANGE: + case EPPI_RANGE: + idx = gic_get_ppi_index(d); /* Setting up PPI as NMI, only switch handler for first NMI */ if (!refcount_inc_not_zero(&ppi_nmi_refs[idx])) { refcount_set(&ppi_nmi_refs[idx], 1); desc->handle_irq = handle_percpu_devid_fasteoi_nmi; } - } else { + break; + default: desc->handle_irq = handle_fasteoi_nmi; + break; } gic_irq_set_prio(d, GICD_INT_NMI_PRI); @@ -498,6 +505,7 @@ static int gic_irq_nmi_setup(struct irq_data *d) static void gic_irq_nmi_teardown(struct irq_data *d) { struct irq_desc *desc = irq_to_desc(d->irq); + u32 idx; if (WARN_ON(!gic_supports_nmi())) return; @@ -515,14 +523,20 @@ static void gic_irq_nmi_teardown(struct irq_data *d) return; /* desc lock should already be held */ - if (gic_irq_in_rdist(d)) { - u32 idx = gic_get_ppi_index(d); + switch (get_intid_range(d)) { + case SGI_RANGE: + break; + case PPI_RANGE: + case EPPI_RANGE: + idx = gic_get_ppi_index(d); /* Tearing down NMI, only switch handler for last NMI */ if (refcount_dec_and_test(&ppi_nmi_refs[idx])) desc->handle_irq = handle_percpu_devid_irq; - } else { + break; + default: desc->handle_irq = handle_fasteoi_irq; + break; } gic_irq_set_prio(d, GICD_INT_DEF_PRI); @@ -1708,6 +1722,7 @@ static int __init gic_init_bases(void __iomem *dist_base, gic_dist_init(); gic_cpu_init(); + gic_enable_nmi_support(); gic_smp_init(); gic_cpu_pm_init(); @@ -1719,8 +1734,6 @@ static int __init gic_init_bases(void __iomem *dist_base, gicv2m_init(handle, gic_data.domain); } - gic_enable_nmi_support(); - return 0; out_free: