From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A7B0C169C4 for ; Tue, 12 Feb 2019 00:57:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2F00A21773 for ; Tue, 12 Feb 2019 00:57:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727978AbfBLA5G (ORCPT ); Mon, 11 Feb 2019 19:57:06 -0500 Received: from belmont79srvr.owm.bell.net ([184.150.200.79]:56595 "EHLO mtlfep01.bell.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727630AbfBLA5G (ORCPT ); Mon, 11 Feb 2019 19:57:06 -0500 Received: from bell.net mtlfep01 184.150.200.30 by mtlfep01.bell.net with ESMTP id <20190212005705.RXNQ28651.mtlfep01.bell.net@mtlspm01.bell.net> for ; Mon, 11 Feb 2019 19:57:05 -0500 Received: from [192.168.2.49] (really [70.53.62.20]) by mtlspm01.bell.net with ESMTP id <20190212005705.VLCK17436.mtlspm01.bell.net@[192.168.2.49]>; Mon, 11 Feb 2019 19:57:05 -0500 Subject: Re: [PATCH net] dsa: mv88e6xxx: Ensure all pending interrupts are handled prior to exit To: Andrew Lunn Cc: Russell King , Vivien Didelot , Florian Fainelli , netdev@vger.kernel.org References: <20190123002240.GF3634@lunn.ch> <20190130172818.GJ21904@lunn.ch> <2ea9fd81-f92d-9505-dd0b-bdd0f67d8ce7@bell.net> <20190130223846.GB30115@lunn.ch> <9415d82e-965b-7777-0ad0-f23d6c9f177e@bell.net> <53b49df8-53ed-704f-9197-230b18d83090@bell.net> <824d011b-3692-69c3-5e2c-58e950a80abf@bell.net> <6a1ebc61-3505-beb8-21cb-ea42ad9fe67e@bell.net> <20190211233327.GB8591@lunn.ch> From: John David Anglin Openpgp: preference=signencrypt Message-ID: <2b6bbb4c-1346-461b-ff7a-cb96b4142f7a@bell.net> Date: Mon, 11 Feb 2019 19:57:03 -0500 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 MIME-Version: 1.0 In-Reply-To: <20190211233327.GB8591@lunn.ch> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Language: en-US X-Cloudmark-Analysis: v=2.2 cv=QLaHfkDL c=1 sm=0 tr=0 a=O1s9vCNsZHvkjbFmGvGkaA==:17 a=IkcTkHD0fZMA:10 a=CFTnQlWoA9kA:10 a=FBHGMhGWAAAA:8 a=YcODBABuTQ3FYJ7sRTAA:9 a=QEXdDO2ut3YA:10 a=9gvnlMMaQFpL9xblJ6ne:22 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 2019-02-11 6:33 p.m., Andrew Lunn wrote: >> Signed-off-by: John David Anglin >> --- >> drivers/net/dsa/mv88e6xxx/chip.c | 28 ++++++++++++++++++++++------ >> 1 file changed, 22 insertions(+), 6 deletions(-) >> >> diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c >> index 8dca2c949e73..12fd7ce3f1ff 100644 >> --- a/drivers/net/dsa/mv88e6xxx/chip.c >> +++ b/drivers/net/dsa/mv88e6xxx/chip.c >> @@ -261,6 +261,7 @@ static irqreturn_t mv88e6xxx_g1_irq_thread_work(struct mv88e6xxx_chip *chip) >> unsigned int sub_irq; >> unsigned int n; >> u16 reg; >> + u16 ctl1; >> int err; >> >> mutex_lock(&chip->reg_lock); >> @@ -270,13 +271,28 @@ static irqreturn_t mv88e6xxx_g1_irq_thread_work(struct mv88e6xxx_chip *chip) >> if (err) >> goto out; >> >> - for (n = 0; n < chip->g1_irq.nirqs; ++n) { >> - if (reg & (1 << n)) { >> - sub_irq = irq_find_mapping(chip->g1_irq.domain, n); >> - handle_nested_irq(sub_irq); >> - ++nhandled; >> + do { >> + for (n = 0; n < chip->g1_irq.nirqs; ++n) { >> + if (reg & (1 << n)) { >> + sub_irq = irq_find_mapping(chip->g1_irq.domain, >> + n); >> + handle_nested_irq(sub_irq); >> + ++nhandled; >> + } >> } >> - } >> + >> + mutex_lock(&chip->reg_lock); >> + err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &ctl1); >> + if (err) >> + goto unlock; >> + err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_STS, ®); >> +unlock: >> + mutex_unlock(&chip->reg_lock); >> + if (err) >> + goto out; >> + ctl1 &= GENMASK(chip->g1_irq.nirqs, 0); >> + } while (reg & ctl1); > Hi David > > I just tested this on one of my boards. It loops endlessly: > > [ 47.173396] mv88e6xxx_g1_irq_thread_work: c881 a8 80 > [ 47.182108] mv88e6xxx_g1_irq_thread_work: c881 a8 80 > [ 47.190820] mv88e6xxx_g1_irq_thread_work: c881 a8 80 > [ 47.199535] mv88e6xxx_g1_irq_thread_work: c881 a8 80 > [ 47.208254] mv88e6xxx_g1_irq_thread_work: c881 a8 80 > > These are reg, ctl1, reg & ctl1. > > So there is an unhandled device interrupt. I think this is because > device interrupts are not masked before installing the interrupt > handler. But i've not fully got to the bottom of this yet. Yes, it is true the PHY and SERDES enables in Global 2 should be cleared before the interrupt handler is installed for device interrupts.  That's what is done for the interrupts enables in Global 1.  I'm not seeing that these enables are initialized. Which switch?  The device interrupts are not be cleared properly on that board.  Would it be possible to also print the Global 2 status and enables?  Unplugging the cable that's causing the loop might cause the loop to stop. I suspect the same would happen if level interrupts were used. I tested both edge and polling on espressobin with Armada 3700.  There's no problem with looping there.  I've booted it many times.  I've unplugged and plugged cables many times. Dave -- John David Anglin dave.anglin@bell.net