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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E506C47089 for ; Sun, 4 Dec 2022 18:02:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229983AbiLDSB6 (ORCPT ); Sun, 4 Dec 2022 13:01:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231124AbiLDSBi (ORCPT ); Sun, 4 Dec 2022 13:01:38 -0500 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09A831E6; Sun, 4 Dec 2022 10:00:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=hxaIyiMKkKRAft5XVZyqxqDaRSGY1h1I1Orv3yrm3ZM=; b=PMPRw/D3ghY75mSPCatMu9WvHV oo7r8yQxvM9Ku1DuQCoY/kKat9UXhMwh8rgI3XeTXIAZSdGK6LWjnPotDLjzMfbY/+66zdJLDZi3U ngfYMvrUgn608+o45FQ97yxByBnWopxwPXzbyvO3APDPiHQ+C+Wy1/gfElB/+Rf2N7wo=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1p1tI6-004KnR-I9; Sun, 04 Dec 2022 19:00:38 +0100 Date: Sun, 4 Dec 2022 19:00:38 +0100 From: Andrew Lunn To: "Russell King (Oracle)" Cc: Piergiorgio Beruto , Heiner Kallweit , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Oleksij Rempel Subject: Re: [PATCH net-next 3/4] drivers/net/phy: Add driver for the onsemi NCN26000 10BASE-T1S PHY Message-ID: References: <834be48779804c338f00f03002f31658d942546b.1670119328.git.piergiorgio.beruto@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Sun, Dec 04, 2022 at 03:31:33AM +0100, Piergiorgio Beruto wrote: > > +static irqreturn_t ncn26000_handle_interrupt(struct phy_device *phydev) > > +{ > > + const struct ncn26000_priv *const priv = phydev->priv; > > + u16 events; > > + int ret; > > + > > + // read and aknowledge the IRQ status register > > + ret = phy_read(phydev, NCN26000_REG_IRQ_STATUS); > > + > > + if (unlikely(ret < 0)) > > + return IRQ_NONE; > > + > > + events = (u16)ret & priv->enabled_irqs; > > + if (events == 0) > > + return IRQ_NONE; > > + > > + if (events & NCN26000_IRQ_LINKST_BIT) { > > + ret = phy_read(phydev, MII_BMSR); > > + > > + if (unlikely(ret < 0)) { > > + phydev_err(phydev, > > + "error reading the status register (%d)\n", > > + ret); > > + > > + return IRQ_NONE; > > + } > > + > > + phydev->link = ((u16)ret & BMSR_ANEGCOMPLETE) ? 1 : 0; Hi Piergiorgio Interrupt handling in PHY don't follow the usual model. Historically, PHYs were always polled once per second. The read_status() function gets called to report the current status of the PHY. Interrupt are just used to indicate that poll should happen now. All the handler needs to do is clear the interrupt line so it can be safely reenabled and not cause an interrupt storm, and call phy_trigger_machine() to trigger the poll. Andrew