Received: by 10.223.185.116 with SMTP id b49csp6416658wrg; Wed, 28 Feb 2018 09:03:31 -0800 (PST) X-Google-Smtp-Source: AH8x225TDUN1lFwhJagdJ0/qeEdPz166nsJPkCWc+WPrGku7ozcDNNYHWzxgkohrKBaEChPe1XqE X-Received: by 10.101.87.132 with SMTP id b4mr14505485pgr.282.1519837411023; Wed, 28 Feb 2018 09:03:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519837410; cv=none; d=google.com; s=arc-20160816; b=D6ybAACvKR30GgJrX66z6tKvp+mIAsAVgO3GsXEr+uertpB9Vij/1aTpRWMHWkYd5x T6BrkaS6NMjs23LoOllLZz+GbH2trRjFZ/sZsKLXlB4qh7B+10QwoxxU4iXpfOmA1srN AcsPfJRdYXhk6c7yndu3OooS44g4cIpSDdHG5Zl57M8R4Ufn7lZheqXSvj01JRG29BkW 5z4cayZepZlyXrts+WfKFYrHDq1ICtb15/xAOHWxCamzcZZ5oRjADXZPdvXM4cdLcMch AvJB4HegSFn2bd+4C8iNQp/1vszNqHrhYGtUsv4nq7+DgdzvF/o5Kj5nqFdmM4WZxBkt 9n1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=Gojb3YnoRIHHdjsFgJLa3Z1FAl+hRU+7+kl7WuNpN7A=; b=O54RitXpRGpvc9U19DFU0eedw4YrmzxFzhhoJpsI0ZwE5YAHLZCEeOhTsfbJD5zgZg +1BtYtcvVUEEB9au2AFOADrOv1ribkUot5rb9Etr6a9ZaprjNiijfG9vCywztxugRL2S XashaykqW5t3YCBx0ooS0HK/ZfYzB/pQfen/PFSg/saZ6rbEM52JnTaBotgpwmcaffFj YtQKOyE31jkLC56q2Jx4mSPhM/TwcAMXLxQM/3LAAIwvC+GF0QWLpizLQoBeEkWR7t0Z ej8BDHdQAo7UoWxoVHJzTsdeKYS0+vdEeBdarrKYiyCLN6IqG3XV1pK11cs4azviI5/K +PEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@semihalf-com.20150623.gappssmtp.com header.s=20150623 header.b=QWhpI528; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p1-v6si1553753pld.80.2018.02.28.09.02.53; Wed, 28 Feb 2018 09:03:30 -0800 (PST) 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=@semihalf-com.20150623.gappssmtp.com header.s=20150623 header.b=QWhpI528; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933846AbeB1RB0 (ORCPT + 99 others); Wed, 28 Feb 2018 12:01:26 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:43016 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932782AbeB1RBY (ORCPT ); Wed, 28 Feb 2018 12:01:24 -0500 Received: by mail-lf0-f66.google.com with SMTP id q69so4543878lfi.10 for ; Wed, 28 Feb 2018 09:01:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=Gojb3YnoRIHHdjsFgJLa3Z1FAl+hRU+7+kl7WuNpN7A=; b=QWhpI528Y+uuEoOOJa4wzaua9RptOTXyZ2JRmhSf2+f9ST8CY8mVeoJdOm0l+dSKR+ jMD8GmnESToP3piaVE3DQweCuGh9XA0ALCibFw5M2i794lWK45xgL2xBniJ3SbGFwLeR tCoPqH4Kuj+GJEhD2rKw8r2akz/niNngpqPKsJQ8OTHB1tzWKLs8eraz134lc8DcWkC5 zznTZhaUq582KYmPlSAhn3Km2/fpQB+xS3nmDV+Ub6JGWuLHSrHDPzrseBTJdPEl6nKO x6kJXJHzNtfL2jP2/qnR6v2ktDczPAqFvOQfohRPtGYMu6fdyqlV8so/ENxNUDg4r4cE nhfA== 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; bh=Gojb3YnoRIHHdjsFgJLa3Z1FAl+hRU+7+kl7WuNpN7A=; b=myfN2rEjJVjB24Xwk87507YQ5ypYo7DtcI7+8t2Xx5LURWpo3SeczmL6iNFDMlrJ/T 5ps2OcU66NRTtW5SgtFmke9FBNXQsCQTKUhyscpZIDdUge0EnZqMLLE5LM1/AHjlM3hy xhcfSOnlw41HAjl+bgsz1gozHkpW98dMCP2SADHJxOEIp7kBTRi+46PKv+RTDdXMODIU PdCRIHtkrqAPhUqHNPTGEFR3EsLu1kNtxdUoRTyH/BRUTOxob98kfWTicUng92dpoh24 gySFnE1FsgNuPrxExr4MoeDSWvfosHFQaWQfNZZugRC8GEO1QbYJusUWPlnnWWBc02nV kygg== X-Gm-Message-State: APf1xPAigAtGSGYhfGfZcZXc7sMZWBIaeWODqrLUZwQHyaYQwPyj5lfe sb0x1rRSroiqv99tBZ37/wNyyw== X-Received: by 10.25.150.78 with SMTP id y75mr14076312lfd.81.1519837282427; Wed, 28 Feb 2018 09:01:22 -0800 (PST) Received: from gilgamesh.semihalf.com (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id 70sm454250lft.2.2018.02.28.09.01.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Feb 2018 09:01:21 -0800 (PST) From: Grzegorz Jaszczyk To: catalin.marinas@arm.com, will.deacon@arm.com, james.morse@arm.com, takahiro.akashi@linaro.org, hoeun.ryu@gmail.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: jaz@semihalf.com, mw@semihalf.com, nadavh@marvell.com Subject: [PATCH] arm64: kdump: fix interrupt handling done during machine_crash_shutdown Date: Wed, 28 Feb 2018 18:01:00 +0100 Message-Id: <1519837260-30662-1-git-send-email-jaz@semihalf.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hitherto during machine_kexec_mask_interrupts there was an attempt to remove active state using irq_set_irqchip_state() routine and only if it failed, the attempt to EOI the interrupt was made. Nevertheless relaying on return value from irq_set_irqchip_state inside machine_kexec_mask_interrupts is incorrect - it only returns the status of the routine but doesn't provide information if the interrupt was deactivated correctly or not. Therefore the irq_eoi wasn't call even if the interrupt remained active. To determine the sate correctly the irq_get_irqchip_state() could be used but according to the ARM Generic Interrupt Controller Architecture Spec, non-secure reading from GICD_ISACTIVERn/GICD_ICACTIVERn can be not permitted (depending on NS_access setting of Non-secure Access Control Registers, a.k.a. GICD_NSACRn). What is more interesting GICD_NSACRn is optional Secure register. Moreover de-activating the interrupt via GICD_ISACTIVERn register (regardless of the possibility of checking status or not) seems to not do the job, when the GIC Distributor is configured to forward the interrupts to the CPU interfaces. Because of all above the attempt to deactivate interrupts via irq_set_irqchip_state() is removed in this patch. Instead the irq_eoi is called whenever the interrupt is in progress(irqd_irq_inprogress). Before this patch the kdump triggered from interrupt context worked correctly by accident when the GIC was configured with GIC_CPU_CTRL_EOImodeNS == 1 (supports_deactivate == true). In mentioned mode GIC_CPU_EOI has priority drop functionality only and GIC_CPU_DEACTIVATE is used for interrupt deactivation. Also the gic_handle_irq behaviour is a bit different in mentioned mode and performs write to the GIC_CPU_EOI which causes the priority drop to the idle priority. So even if the irq_eoi wasn't called during machine_kexec_mask_interrupts, the interrupts of the crashdump kernel was handled due to interrupt preemption (since the priority of still active interrupt was dropped to idle priority). Nevertheless when the kdump was triggered from interrupt context while the GIC was configured to work in GIC_CPU_CTRL_EOImodeNS == 0, the crashdump kernel hang in early stage due to lack of timer interrupt arrival. After this fix the kdump behaves correctly when triggered from interrupt context independently of GIC_CPU_CTRL_EOImodeNS configuration. Signed-off-by: Grzegorz Jaszczyk --- arch/arm64/kernel/machine_kexec.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/arch/arm64/kernel/machine_kexec.c b/arch/arm64/kernel/machine_kexec.c index f76ea92..30ad183 100644 --- a/arch/arm64/kernel/machine_kexec.c +++ b/arch/arm64/kernel/machine_kexec.c @@ -220,20 +220,12 @@ static void machine_kexec_mask_interrupts(void) for_each_irq_desc(i, desc) { struct irq_chip *chip; - int ret; chip = irq_desc_get_chip(desc); if (!chip) continue; - /* - * First try to remove the active state. If this - * fails, try to EOI the interrupt. - */ - ret = irq_set_irqchip_state(i, IRQCHIP_STATE_ACTIVE, false); - - if (ret && irqd_irq_inprogress(&desc->irq_data) && - chip->irq_eoi) + if (irqd_irq_inprogress(&desc->irq_data) && chip->irq_eoi) chip->irq_eoi(&desc->irq_data); if (chip->irq_mask) -- 2.7.4