Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp808339imm; Fri, 22 Jun 2018 05:44:56 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLRyRH44GVWFH6etFwBusiHHYKeJ7nYjKOsaQkW/RirgAX9O9N+AokI4kvROXbaI7mrrKYU X-Received: by 2002:a17:902:2c83:: with SMTP id n3-v6mr1525260plb.211.1529671496488; Fri, 22 Jun 2018 05:44:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529671496; cv=none; d=google.com; s=arc-20160816; b=Q6bhUs5gYZlv1i+k1DvD5YgdVQSWF8s251Evul6BgAp3mDN2O6gxEmDJN0yeeVTei4 53bdlWmJyQb0E8/vT0vn83IDXNZL8+TvHJGMjkzf+9s+5xZqU6/Qxidnh7mDD1cmlKjB CcqWkYQjgFpbZiAm/RHm5H0iODVec3jPGISUSdOvXc2vCQmgzQ6BG0FlzY8wCtX3bfrq 9CUQWJLYL2yQfZ+dhudb3rqTjBCIMo9vqsxOwT1kLToHG8bEdFAPdWVbl6EGiswKw4Gj yy/YEDlZgYxIF370Xx6eFaEWYvYHi0F2fwqcu0gdumqjAmaDXeFYg5hxin3IwMc5qbgP To1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:reply-to:dkim-signature :arc-authentication-results; bh=irfI0nFo1KeCKUAOKhXnoWL8wtmwKWrGjZ6K61EWv0A=; b=s59iI7CQ+WWOdVlBIuG+OCuw9BJFiDa3yZ8c7oOavRa17jw45gTaQ/0UqRAjt2GX29 /D5TvGOOYjDHRKjSwOXpb+w7e++vKJYqNGvj+IM5yLlSq50MJ4Povv69bRLg7G8XTU/E 7mT/vfCfBLCLQbGTDpIgcvtDi9dkUJm5QHJv0TqVGAxW38o2NViZXw7wF/syeiyu0Je6 Sv+0UpSellOu82xzKrPwg0MFV3A8TLG6gSZNWrksRzjU82k6umu/sypj/79vsqBqbZZJ YiSAF4ini050nki2PsxVFNYxnDJ/iorXKZDqUgthiHbU6GOJ/aevhBUWIcjtiM8UkjaK ucOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=EQOxaQRw; 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 y2-v6si6263128pgr.677.2018.06.22.05.44.42; Fri, 22 Jun 2018 05:44:56 -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=fail header.i=@gmail.com header.s=20161025 header.b=EQOxaQRw; 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 S933395AbeFVMn6 (ORCPT + 99 others); Fri, 22 Jun 2018 08:43:58 -0400 Received: from mail-ot0-f195.google.com ([74.125.82.195]:43091 "EHLO mail-ot0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751284AbeFVMn5 (ORCPT ); Fri, 22 Jun 2018 08:43:57 -0400 Received: by mail-ot0-f195.google.com with SMTP id i19-v6so7324563otk.10 for ; Fri, 22 Jun 2018 05:43:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:reply-to:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=irfI0nFo1KeCKUAOKhXnoWL8wtmwKWrGjZ6K61EWv0A=; b=EQOxaQRwKBGNsgWycJ+918Qe9i98UMIpMoLA2SzSjShVdbrLtMeHptKovGTdWh8TSB mjhCbZiwSTxhHm16+s2XR6uUWjGcHnwAVy3Q19pzsxefFI8LFpZAIqxaSSXJ/tW8DMEE /wO9PCjBdyPF0j+s6GxTcje1Rz35Ss7HJfKR5u0pbw28B8LdNJVXP+eajwjjXl753LEd /1UoHoSds/xHMQS1Ll6Dhm8cngr03e8MqH5nTjJrjJNTWUwq3Yz0WftV0gtNN2PvFFxp Q0ToGxIr4qmzgjo/igXgEXyBrGjnUat8FRjwIZ0s1CLkN+/yevo14WZ7I1bVD9pupuLG sCzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:reply-to:subject:to:cc:references:from :message-id:date:user-agent:mime-version:in-reply-to :content-transfer-encoding:content-language; bh=irfI0nFo1KeCKUAOKhXnoWL8wtmwKWrGjZ6K61EWv0A=; b=fI7+cWYiXT6AzYGtbI4zAlxpd17k181X9o8dcDovjIdYcOVj5y0eqCxdSgZWzcZIhg dS+GskOrrXvq/BJbsAydqTlGTumTWCCv0gN2F8dnufgyqRl7MhfLFJl/lVDdG193Nzsr 9M0ZutODR192196MRM1G7NQaZGGy92z2h8enmmQPJSwMG+Dm/b3xffjo87xzu7ffwNK0 pyngVJ17pqM3Qo7d+RmK6AhvlOhVSzmzg/HEu+YxlF+1/o+Un/zvYy002UKyiVB6/L6w 66Nw6f13ESfifF4ECSOYDmKFXlkfaN01TDU4JGVZMioC5tdMEzuJtLMARQljcANwwqk/ EMGQ== X-Gm-Message-State: APt69E1pdiSjsRfTh+okCEwptB7F+Vjk+XC9AR7dXGleolRJ9NSuPt7w PPssYbJs61Td/EHFHz75sg== X-Received: by 2002:a9d:17ce:: with SMTP id j72-v6mr905099otj.244.1529671436490; Fri, 22 Jun 2018 05:43:56 -0700 (PDT) Received: from serve.minyard.net (serve.minyard.net. [2001:470:b8f6:1b::1]) by smtp.gmail.com with ESMTPSA id b63-v6sm3446054oia.4.2018.06.22.05.43.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Jun 2018 05:43:55 -0700 (PDT) Received: from [192.168.27.3] (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPSA id 8E961675; Fri, 22 Jun 2018 07:43:53 -0500 (CDT) Reply-To: minyard@acm.org Subject: Re: [PATCH ] ipmi: kcs_bmc: fix IRQ exception if the channel is not open To: Haiyue Wang , arnd@arndb.de, gregkh@linuxfoundation.org, openipmi-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: luis.a.silva@dell.com, avi.fishman@nuvoton.com, openbmc@lists.ozlabs.org References: <1529636218-280096-1-git-send-email-haiyue.wang@linux.intel.com> From: Corey Minyard Message-ID: Date: Fri, 22 Jun 2018 07:43:52 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <1529636218-280096-1-git-send-email-haiyue.wang@linux.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/21/2018 09:56 PM, Haiyue Wang wrote: > 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. I'm having a little trouble understanding your text above, so let me try to repeat back to you what I'm thinking you are saying... You have two (or more) devices using the same interrupt, and at least one is an IPMI KCS device.  And interrupt comes in to the other device when the IPMI KCS device is not running.  The original code issues an abort when that happens, which is obviously incorrect.  It then returns -ENODATA, . When the interrupt comes in for the abort handling, the driver will then issue another abort, and again returns -ENODATA.  This time neither driver handles the interrupt, resulting in the logs. In general, I think the change you have here is good.  You don't want to issue an abort in this case.  But... If I am right, this fix doesn't completely solve the problem.  It does solve this immediate problem, but what if there is an OS on the other end of the KCS interface that sets the IBF flag?  The same situation will occur.  In fact it will occur even if there is only one handler for the interrupt. Maybe it's best to have the interrupt disabled unless the device is open. You have to handle the interrupt disable race on a close, but with the sync functions that shouldn't be too hard. -corey > > 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;