Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp339038imm; Thu, 21 Jun 2018 19:58:25 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLGZkZzwIvXdF/eGmdyu5QToUcvoDMCimTn7Bb57mVg4FrdmD1TKbWv1f52zPu9SKMweSKN X-Received: by 2002:a62:d508:: with SMTP id d8-v6mr30130587pfg.128.1529636305542; Thu, 21 Jun 2018 19:58:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529636305; cv=none; d=google.com; s=arc-20160816; b=v+daTA9RMZv20ToNV1bkEtVKfXxxvIj7nvPLgFTCQqh+Mj2CHb/m9AWKJEYki2+Yl2 f0bx0hNzRnhdPX3LXT34a9TolxEoXmQLWbid229fVMRgzIG3MFTxU5lCMiY0W0z0tyIK JCq6HOWjk8EQrJEVUHYSwB65C8z8N/10hp0PH/N1N9GlwHeFdW12fivKiBz8I76l7TzT J22tCgRA3s9gZT8y56FH8JjEVRvZON0LdwH9NQUKSR/4ydtbNC8/X28YqBfjC997oP+H zpKDlb2p98YEW9saqQnqhT+o497ywPVWK+IRb4SMuxtVANfVC3VvoRcTUDz0qmghzh4T PKOA== 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 :arc-authentication-results; bh=H32dMOu6YuOcEixCboVX7KjkpK+St3UusjMCyux8TLQ=; b=yXx5sijYoRW1m2g7BIAIBC5y8dNBwjgDjImxSiGTdXwicqXgQf4SEZ5GmeAad3b8yb 1ySy0hfwAPTxCizMuqWDm39svb8TvJ6rw2E1+Qae3AIJRIrdgtzOsa31w0alUR5XkK8r HM7hUV9oMzq+JynLtn9S6LZHQIxZvhXxMmzYl0n6mWlNskxuWNjAMoB2Y/MHUA9vZNOf AknuPHL2wVMR4Jjt7JjQ7pIb7HNI289KPeDR4Oph5YCehXK7d6keZzeX3Bd3qufZ8fv2 l3O66KgcS79wSdJ/xAUXIvWb9aSuybMNKrenYjVuhx7lI9KDW/pv32c1uluM+/Fd5eWK e0ag== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c2-v6si6403896pfm.26.2018.06.21.19.58.10; Thu, 21 Jun 2018 19:58:25 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934224AbeFVC5c (ORCPT + 99 others); Thu, 21 Jun 2018 22:57:32 -0400 Received: from mga07.intel.com ([134.134.136.100]:51301 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934071AbeFVC5b (ORCPT ); Thu, 21 Jun 2018 22:57:31 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Jun 2018 19:57:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,255,1526367600"; d="scan'208";a="66240339" Received: from dpdk-haiyue-s2600wfp.sh.intel.com ([10.67.111.114]) by fmsmga001.fm.intel.com with ESMTP; 21 Jun 2018 19:57:28 -0700 From: Haiyue Wang To: minyard@acm.org, arnd@arndb.de, gregkh@linuxfoundation.org, openipmi-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: Haiyue Wang , luis.a.silva@dell.com, avi.fishman@nuvoton.com, openbmc@lists.ozlabs.org Subject: [PATCH ] ipmi: kcs_bmc: fix IRQ exception if the channel is not open Date: Fri, 22 Jun 2018 10:56:58 +0800 Message-Id: <1529636218-280096-1-git-send-email-haiyue.wang@linux.intel.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 The original core KCS IRQ handling function 'kcs_bmc_handle_event' had a wrong logical desgin, it should force abort the KCS transaction only if the IBF flag is set, because multiple KCS channels share the same handle function; and it should return 0, which indicates that event of current channel is handled. An negative value -ENODATA will cause the IRQ handler of BMC KCS controller return IRQ_NONE, then IRQ moudle will treat this IRQ 'nobody cared', it will trigger IRQ exception. irq 30: nobody cared (try booting with the "irqpoll" option) CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.10.15-npcm750 #1 Hardware name: NPCMX50 Chip family [] (unwind_backtrace) from [] (show_stack+0x20/0x24) [] (show_stack) from [] (dump_stack+0x8c/0xa0) [] (dump_stack) from [] (__report_bad_irq+0x3c/0xdc) [] (__report_bad_irq) from [] (note_interrupt+0x29c/0x2ec) [] (note_interrupt) from [] (handle_irq_event_percpu+0x5c/0x68) [] (handle_irq_event_percpu) from [] (handle_irq_event+0x48/0x6c) [] (handle_irq_event) from [] (handle_fasteoi_irq+0xc8/0x198) [] (handle_fasteoi_irq) from [] (__handle_domain_irq+0x90/0xe8) [] (__handle_domain_irq) from [] (gic_handle_irq+0x58/0x9c) [] (gic_handle_irq) from [] (__irq_svc+0x6c/0x90) Exception stack(0xc0a01de8 to 0xc0a01e30) 1de0: 00002080 c0a6fbc0 00000000 00000000 00000000 c096d294 1e00: 00000000 00000001 dc406400 f03ff100 00000082 c0a01e94 c0a6fbc0 c0a01e38 1e20: 00200102 c01015bc 60000113 ffffffff [] (__irq_svc) from [] (__do_softirq+0xbc/0x358) [] (__do_softirq) from [] (irq_exit+0xb8/0xec) [] (irq_exit) from [] (__handle_domain_irq+0x94/0xe8) [] (__handle_domain_irq) from [] (gic_handle_irq+0x58/0x9c) [] (gic_handle_irq) from [] (__irq_svc+0x6c/0x90) Exception stack(0xc0a01ef8 to 0xc0a01f40) 1ee0: 00000000 000003ae 1f00: dcc0f338 c0111060 c0a00000 c0a0cc44 c0a0cbe4 c0a1c22b c07bc218 00000001 1f20: dcffca40 c0a01f54 c0a01f58 c0a01f48 c0103524 c0103528 60000013 ffffffff [] (__irq_svc) from [] (arch_cpu_idle+0x48/0x4c) [] (arch_cpu_idle) from [] (default_idle_call+0x30/0x3c) [] (default_idle_call) from [] (do_idle+0xc8/0x134) [] (do_idle) from [] (cpu_startup_entry+0x28/0x2c) [] (cpu_startup_entry) from [] (rest_init+0x84/0x88) [] (rest_init) from [] (start_kernel+0x388/0x394) [] (start_kernel) from [<0000807c>] (0x807c) handlers: [] npcm7xx_kcs_irq Disabling IRQ #30 Signed-off-by: Haiyue Wang --- Hi Corey, This patch looks introducing BIG modification, it should be easily understandable, and makes code clean & fix an error design, which is introduced by misunderstanding the IRQ return value. BR, Haiyue --- drivers/char/ipmi/kcs_bmc.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/drivers/char/ipmi/kcs_bmc.c b/drivers/char/ipmi/kcs_bmc.c index fbfc05e..bb882ab1 100644 --- a/drivers/char/ipmi/kcs_bmc.c +++ b/drivers/char/ipmi/kcs_bmc.c @@ -210,34 +210,23 @@ static void kcs_bmc_handle_cmd(struct kcs_bmc *kcs_bmc) int kcs_bmc_handle_event(struct kcs_bmc *kcs_bmc) { unsigned long flags; - int ret = 0; + int ret = -ENODATA; u8 status; spin_lock_irqsave(&kcs_bmc->lock, flags); - if (!kcs_bmc->running) { - kcs_force_abort(kcs_bmc); - ret = -ENODEV; - goto out_unlock; - } - - status = read_status(kcs_bmc) & (KCS_STATUS_IBF | KCS_STATUS_CMD_DAT); - - switch (status) { - case KCS_STATUS_IBF | KCS_STATUS_CMD_DAT: - kcs_bmc_handle_cmd(kcs_bmc); - break; - - case KCS_STATUS_IBF: - kcs_bmc_handle_data(kcs_bmc); - break; + status = read_status(kcs_bmc); + if (status & KCS_STATUS_IBF) { + if (!kcs_bmc->running) + kcs_force_abort(kcs_bmc); + else if (status & KCS_STATUS_CMD_DAT) + kcs_bmc_handle_cmd(kcs_bmc); + else + kcs_bmc_handle_data(kcs_bmc); - default: - ret = -ENODATA; - break; + ret = 0; } -out_unlock: spin_unlock_irqrestore(&kcs_bmc->lock, flags); return ret; -- 2.7.4