Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3536816pxb; Mon, 4 Apr 2022 20:22:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyiVKybtrT2uqyTJauRgyeyv/HOJ0xJ7blZwPJ3w3ml7ozQakfVV++LAqeEadJjAnlv4INV X-Received: by 2002:a63:445f:0:b0:381:6cef:d841 with SMTP id t31-20020a63445f000000b003816cefd841mr1132798pgk.363.1649128924026; Mon, 04 Apr 2022 20:22:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649128924; cv=none; d=google.com; s=arc-20160816; b=0wzfDgf7OEo2jybx7BFqe0Z8vhtXaPtgN2b7l9VAltrPJyhHqIWVE6BZux5uX0qmzH EQSc7xhmE90pyq0ad38IZxF/CAuEo246ijdqpDtHr/0jvVPkZ6FkQ8oIjLatXCc1RR6q 08C0XOOzg/IuWtkEIehkeD99IXk2qpI5V3pVcoGbAEEyw8clUuMevL84v4MDceoJqDMY 9TGqrlH08KpnNcCRqu/QybZiG3/XkLvZbTCcbACoiz+DySWHR2RQc8fiBKq6GGELOqx/ f5U6S0B7TEeRbvOlhIAXNT34RM6mOvKIuD1jxtiKPk/vPXx8dq6WMd00OxSeVtzkxvuU yOFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=JweidwxrjFhAI/2v7P1YrxPew3638Ty2dzeJpVrQWYE=; b=0yPG/4r8gycaIaqIz67whYQ60AziwYbZO0U3364zutpWTlG0e7QpwhyBfW21OmgfIl 9A2iPbEMmh1/7ufMXy6J4sugju8m1Uz/nKag5y9DBNH3eLF6we5L0Rb67G4h/HAsqXoF TN3OiPeaQ7V8kbwCQvHc//Epy/JT/e1GUET1EWC0UsuGtRFPjgyd5vlsIE2fCNnuHjE7 aJVQf0+RZ2p7ywtOlVIsTZLK1ec6QHAjRfJKtFRGv3AOMGLxYOsn9XnqRNTmteOIr5KH +Vb0iF2+6zqYDbJSX/n3qBeRplbGexCpRzKfO4oBhaKC6iCLITJqh39epe9tndDINyv8 tMHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="I8pC/miI"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id e17-20020a056a001a9100b004fa882655e5si11220884pfv.133.2022.04.04.20.22.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 20:22:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="I8pC/miI"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 206C6345D46; Mon, 4 Apr 2022 18:21:42 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379703AbiDDV2j (ORCPT + 99 others); Mon, 4 Apr 2022 17:28:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379402AbiDDRFy (ORCPT ); Mon, 4 Apr 2022 13:05:54 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FCAF12086; Mon, 4 Apr 2022 10:03:57 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id bu29so18600074lfb.0; Mon, 04 Apr 2022 10:03:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=JweidwxrjFhAI/2v7P1YrxPew3638Ty2dzeJpVrQWYE=; b=I8pC/miIU61OHd5dqRJenQe4iwqEMNWcbRRJquHcwqrA41pIdbn+rDkftP4Wgy8De6 l2P/kMX+m1AlHndTCFw3I9e8C2PbWnptwDkLhCKGENUjppP00s+oaSpn30odJADOWz80 gZ8aVgizdoRJMD3T6AeNpo8DIwPDr87SzDVdFiM8OdSG4AmvAn65FA0Q/pYGDN1oIlao +YKcox4/vRA3RiBKPCUROakAioTHX5ZKNwEvMn7A4BVVjmQPgHDz09Xezqhs7kUtDDfY rUW3RKJYgdzLAkmjcApGuwZWiQMC6aAEsIC1HT66RK9v0vxmMklonMMLr9nzl3HGoQcI 8TDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=JweidwxrjFhAI/2v7P1YrxPew3638Ty2dzeJpVrQWYE=; b=nWUf9C3SEGVmGBxXGgqgOjKzTw5U8BMB1Ivzx6o7pKMu0Rv2z6cTt1h77mlrzvNYAm 2sg0tVAYvE5dTv+Rn9I9o1IwcT7k5/9CpbNYE0MFDq6Bo3dgz8gj0CBUd9l7pqHNMzbH qZjCwV+PiiemdMDpIQzn+8Nt1mp15MtAvFkIEkX59Xm81fqARBQaSAcKgNiKUDBCnIA9 MIGr3RQXfyGJUfF7Pn3ifinQ3EaYkL4/Drh6g3JXt3jiwpI5mmV9E4QD6Eu3GcviZyYR fwsSi9OspxO/y7ldlyC9hXvXzqFAPUPjpEFX/GMbIqCq1nfhRXn84j496BHrJ2AZ5x3L WbkA== X-Gm-Message-State: AOAM5334RbHfa900H78JbYhacd6y6ejmGa2uu8LQCfFpsEQn/CCixLU+ 6Ek5G9edFNbYcADMYqF4uCVLIYqyTueH/ZS+kzbGOaYq1A== X-Received: by 2002:ac2:4203:0:b0:448:8053:d402 with SMTP id y3-20020ac24203000000b004488053d402mr252549lfh.687.1649091835467; Mon, 04 Apr 2022 10:03:55 -0700 (PDT) MIME-Version: 1.0 References: <20220303083141.8742-1-warp5tw@gmail.com> <20220303083141.8742-10-warp5tw@gmail.com> In-Reply-To: From: Avi Fishman Date: Mon, 4 Apr 2022 20:03:44 +0300 Message-ID: Subject: Re: [PATCH v3 09/11] i2c: npcm: Handle spurious interrupts To: Andy Shevchenko Cc: Tali Perry , Tyrone Ting , Tomer Maimon , Patrick Venture , Nancy Yuen , Benjamin Fair , Rob Herring , Krzysztof Kozlowski , yangyicong@hisilicon.com, semen.protsenko@linaro.org, Wolfram Sang , jie.deng@intel.com, sven@svenpeter.dev, bence98@sch.bme.hu, Lukas Bulwahn , Arnd Bergmann , olof@lixom.net, Tali Perry , Avi Fishman , Tomer Maimon , KWLIU@nuvoton.com, JJLIU0@nuvoton.com, kfting@nuvoton.com, OpenBMC Maillist , Linux I2C , devicetree , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 3, 2022 at 4:14 PM Andy Shevchenko wrote: > > On Thu, Mar 03, 2022 at 02:48:20PM +0200, Tali Perry wrote: > > > On Thu, Mar 3, 2022 at 12:37 PM Andy Shevchenko wrote: > > > > > > > > On Thu, Mar 03, 2022 at 04:31:39PM +0800, Tyrone Ting wrote: > > > > > From: Tali Perry > > > > > > > > > > In order to better handle spurious interrupts: > > > > > 1. Disable incoming interrupts in master only mode. > > > > > 2. Clear end of busy (EOB) after every interrupt. > > > > > 3. Return correct status during interrupt. > > > > > > > > This is bad commit message, it doesn't explain "why" you are doing these. > > ... > > > BMC users connect a huge tree of i2c devices and muxes. > > This tree suffers from spikes, noise and double clocks. > > All these may cause spurious interrupts to the BMC. > > > > If the driver gets an IRQ which was not expected and was not handled > > by the IRQ handler, > > there is nothing left to do but to clear the interrupt and move on. > > Yes, the problem is what "move on" means in your case. > If you get a spurious interrupts there are possibilities what's wrong: > 1) HW bug(s) > 2) FW bug(s) > 3) Missed IRQ mask in the driver > 4) Improper IRQ mask in the driver > > The below approach seems incorrect to me. > Andy, What about this explanation: On rare cases the i2c gets a spurious interrupt which means that we enter an interrupt but in the interrupt handler we don't find any status bit that points to the reason we got this interrupt. This may be a rare case of HW issue that is still under investigation. In order to overcome this we are doing the following: 1. Disable incoming interrupts in master mode only when slave mode is not enabled. 2. Clear end of busy (EOB) after every interrupt. 3. Clear other status bits (just in case since we found them cleared) 4. Return correct status during the interrupt that will finish the transaction. On next xmit transaction if the bus is still busy the master will issue a recovery process before issuing the new transaction. > > If the transaction failed, driver has a recovery function. > > After that, user may retry to send the message. > > > > Indeed the commit message doesn't explain all this. > > We will fix and add to the next patchset. > > > > > > > + /* > > > > > + * if irq is not one of the above, make sure EOB is disabled and all > > > > > + * status bits are cleared. > > > > > > > > This does not explain why you hide the spurious interrupt. > > > > > > > > > + */ > > > > > + if (ret == IRQ_NONE) { > > > > > + npcm_i2c_eob_int(bus, false); > > > > > + npcm_i2c_clear_master_status(bus); > > > > > + } > > > > > + > > > > > + return IRQ_HANDLED; > > -- > With Best Regards, > Andy Shevchenko > > -- Regards, Avi