From patchwork Sat May 30 04:01:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 187333 Delivered-To: patches@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp1180879ilb; Fri, 29 May 2020 21:02:03 -0700 (PDT) X-Received: by 2002:a63:4b4a:: with SMTP id k10mr3385513pgl.135.1590811322890; Fri, 29 May 2020 21:02:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590811322; cv=none; d=google.com; s=arc-20160816; b=KqvecmDADis+13sOIgkDT+/SEvb9/LvjPClLRP4+jCBeSVmpTm1ZguENTMFFRI3STi JFEcKGKMIHl/Rnh9RTd9HJYyQWQPMccxIeH+MCt3R9UwOMz7zo+FGPKVwGytU6FxSxAl WqjaHRWTl5PWPi0RFP2pQ54l5AuIFWMUJJ5n8TcLnfU4B/kAvGiWYD68WFZnlvqTkUwJ Uexe72LuXZmvEPaGUH9+GHSTOpkQNNppqI6qY2p4RyoKnm0drNDGaGaBv8ffpaOb8zMq Wa+3y7VcCNirpZWNPLAUbIwK1tl2z7lZX5fCxbemN2Q4doLwtLxDMUYfC9AVn6LmOOdW H7ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature; bh=8wOzwyvVgzyZKR9GGg2zllSp9qD/mnxhMdRu73NI63Y=; b=y49kiWexzXHkgcvCOXB6vT4vN64pg26VlIBtniHkU5pQhw+svYBYRvp1uqYoD9BtXd 6INy17ojnNpfmCkfsivTrD0OM4r+v8Ryhrcfpy1fVOHyCyKe61SD01HFXT/RSCHhI2zx Mqn7X0Yc0ET4ZlsD216ZwR/3T7J4VNdVCCZirnahnG67OOnFiLhg3aX2E53aWeNrA8Ul zGp7L0EE4fRoQKU+J9JqWedifQYJ4yF8qrxULVrMtpRXN9l2dwB5UFyUtd+/vEe9GjMs SM8FCuHvs/z+x9nIvX46KLJNtteHRQGsSbmoKWTR8k7sUCzIqeRnLU9eg8PSY1c9rR+M ickA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=v12LqxgK; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id bb21sor1737114pjb.29.2020.05.29.21.02.02 for (Google Transport Security); Fri, 29 May 2020 21:02:02 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=v12LqxgK; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=8wOzwyvVgzyZKR9GGg2zllSp9qD/mnxhMdRu73NI63Y=; b=v12LqxgKfJC2jsmxi01gXIlmZga5Kjq7jmK34g4/VOZ0BrXXWfE/7k7YdhSzhrfo6U KZwCig0chuSdJoTxFRIeoPT/a1KTucMJt6ubY1znecABSPZ2c57Ln9Tuz0tU7Vfxsi/b uzo4sirt7JJ7OwziI2Owxd3+BgcOc+dM0UDq5iADFBUb/KkEI7nDARmZCue0PePecRDi ZkZZ2yPTFRk8YEo2Z17+ih07ev2fodHM71WD1BIFnJLAEaE+8vof6H9X5M2p9hACDqBQ 4PRGqAPfWUAZpr/MlmLISJnywKr8hQlJqFJhgIEqvywXo7lJ5pNXKak8EeOZsqZNijW6 aj2w== 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=8wOzwyvVgzyZKR9GGg2zllSp9qD/mnxhMdRu73NI63Y=; b=rIkmz6Syo6eEI8mX8N5iTwcxUxyDrIX7bu8Kh3bTbeemE4gcvy4v8mzAkT8kRBMBKA a2GEgZw88puMDu1bFneScs1Ju3yqh1AoOwTgFhFy+DIkWejkd1F6mOjrmqDv6ZokkGp6 MI/VCCJHIVxp2SVJ97ZjGtR3DlYSrRSycPUumqgcgGNYLPrt4uMdOaBzwLf6Tfl/RUaA 6uRbFmt6xAzfzCzdMd/eUo+FUWUcT63iY5aDYFvZW8GcBUe7KNXw9E8NJVXH5PPARTPw R20+arDz+e6/rU07ECf2AbQ5+XbyHtdfeTSfUmw+hG6daZytJHzD8t16b9vttiPKzaRI iDMg== X-Gm-Message-State: AOAM530yU1rigBGO3yXq5fokqODvKIdJckNfg8H39DeJag7tGAGOPQw0 cSDCCURzBK9IZXA1W/qjrK0U6nOm X-Google-Smtp-Source: ABdhPJwk2z18kbSHM2nFTpnyw8/PLZm8hbzk2UPkIolenD3B+g/wzpArXov97hQm8W/mnj/9jYqVOA== X-Received: by 2002:a17:90a:3d49:: with SMTP id o9mr11640117pjf.26.1590811322374; Fri, 29 May 2020 21:02:02 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id j13sm8533603pfe.48.2020.05.29.21.02.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2020 21:02:01 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Guenter Roeck , Heikki Krogerus , Greg Kroah-Hartman , YongQin Liu , linux-usb@vger.kernel.org Subject: [RFC][PATCH] usb: typec: tcpci_rt1711h: Try to avoid screaming irq causing boot hangs Date: Sat, 30 May 2020 04:01:57 +0000 Message-Id: <20200530040157.31038-1-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 I've recently (since 5.7-rc1) started noticing very rare hangs pretty early in bootup on my HiKey960 board. They have been particularly difficult to debug, as the system seems to not respond at all to sysrq- commands. However, the system is alive as I'll occaionally see firmware loading timeout errors after awhile. Adding changes like initcall_debug and lockdep weren't informative, as it tended to cause the problem to hide. I finally tried to dig in a bit more on this today, and noticed that the last dmesg output before the hang was usually: "random: crng init done" So I dumped the stack at that point, and saw it was being called from the pl061 gpio irq, and the hang always occurred when the crng init finished on cpu 0. Instrumenting that more I could see that when the issue triggered, we were getting a stream of irqs. Chasing further, I found the screaming irq was for the rt1711h, and narrowed down that we were hitting the !chip->tcpci check which immediately returns IRQ_HANDLED, but does not stop the irq from triggering immediately afterwards. This patch slightly reworks the logic, so if we hit the irq before the chip->tcpci has been assigned, we still read and write the alert register, but just skip calling tcpci_irq(). With this change, I haven't managed to trip over the problem (though it hasn't been super long - but I did confirm I hit the error case and it didn't hang the system). I still have some concern that I don't know why this cropped up since 5.7-rc, as there haven't been any changes to the driver since 5.4 (or before). It may just be the initialization timing has changed due to something else, and its just exposed this issue? I'm not sure, and that's not super re-assuring. Anyway, I'd love to hear your thoughts if this looks like a sane fix or not. Cc: Guenter Roeck Cc: Heikki Krogerus Cc: Greg Kroah-Hartman Cc: YongQin Liu Cc: linux-usb@vger.kernel.org Signed-off-by: John Stultz --- drivers/usb/typec/tcpm/tcpci_rt1711h.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/drivers/usb/typec/tcpm/tcpci_rt1711h.c b/drivers/usb/typec/tcpm/tcpci_rt1711h.c index 017389021b96..530fd2c111ad 100644 --- a/drivers/usb/typec/tcpm/tcpci_rt1711h.c +++ b/drivers/usb/typec/tcpm/tcpci_rt1711h.c @@ -159,9 +159,6 @@ static irqreturn_t rt1711h_irq(int irq, void *dev_id) u8 status; struct rt1711h_chip *chip = dev_id; - if (!chip->tcpci) - return IRQ_HANDLED; - ret = rt1711h_read16(chip, TCPC_ALERT, &alert); if (ret < 0) goto out; @@ -176,6 +173,9 @@ static irqreturn_t rt1711h_irq(int irq, void *dev_id) } out: + if (!chip->tcpci) + return IRQ_HANDLED; + return tcpci_irq(chip->tcpci); }