netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Asmaa Mnebhi <asmaa@nvidia.com>
Cc: David Thompson <dthompson@mellanox.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"kuba@kernel.org" <kuba@kernel.org>,
	Jiri Pirko <jiri@mellanox.com>, Asmaa Mnebhi <Asmaa@mellanox.com>
Subject: Re: [PATCH net-next] Add Mellanox BlueField Gigabit Ethernet driver
Date: Tue, 11 Aug 2020 22:06:52 +0200	[thread overview]
Message-ID: <20200811200652.GD2141651@lunn.ch> (raw)
In-Reply-To: <CH2PR12MB3895E054D1E00168D9FFB2F0D7450@CH2PR12MB3895.namprd12.prod.outlook.com>

On Tue, Aug 11, 2020 at 07:53:35PM +0000, Asmaa Mnebhi wrote:
> Hi Andrew,
> 
> Thanks again for your feedback.
> 
> > > +	/* Finally check if this interrupt is from PHY device.
> > > +	 * Return if it is not.
> > > +	 */
> > > +	val = readl(priv->gpio_io +
> > > +			MLXBF_GIGE_GPIO_CAUSE_OR_CAUSE_EVTEN0);
> > > +	if (!(val & priv->phy_int_gpio_mask))
> > > +		return IRQ_NONE;
> > > +
> > > +	/* Clear interrupt when done, otherwise, no further interrupt
> > > +	 * will be triggered.
> > > +	 * Writing 0x1 to the clear cause register also clears the
> > > +	 * following registers:
> > > +	 * cause_gpio_arm_coalesce0
> > > +	 * cause_rsh_coalesce0
> > > +	 */
> > > +	val = readl(priv->gpio_io +
> > > +			MLXBF_GIGE_GPIO_CAUSE_OR_CLRCAUSE);
> > > +	val |= priv->phy_int_gpio_mask;
> > > +	writel(val, priv->gpio_io +
> > > +			MLXBF_GIGE_GPIO_CAUSE_OR_CLRCAUSE);
> > 
> > Shoudn't there be a call into the PHY driver at this point?
> > 
> > > +
> > > +	return IRQ_HANDLED;
> > > +}
> > 
> > So these last three functions seem to be an interrupt controller?  So why not
> > model it as a Linux interrupt controller?
> 
> Apologies for the confusion. The plan is to remove support to the polling and instead support the HW interrupt as follows (from the probe):
> irq = platform_get_irq(pdev, MLXBF_GIGE_PHY_INT_N);
>          if (irq < 0) {
>                  dev_err(dev, "Failed to retrieve irq 0x%x\n", irq);
>                  return -ENODEV;
>          }
>          priv->mdiobus->irq[phy_addr] = irq;

O.K, that is one way to do it. The other is via the MAC driver calling
phy_mac_interrupt().

> I guess my question is should we model it as a linux interrupt
> controller rather than use phy_connect_direct ?

It seems like there are other interrupt sources, not just the PHY. Do
you plan to use any of them? It can be easier to debug issues if you
have an interrupt controller, can see counters in /proc/interrupts,
etc. Also, if you need to export the lines to some other driver,
e.g. SFP, it is easier to do when there is an interrupt controller.

> Using phy_connect_direct to register my interrupt handler, I have
> encountered a particular issue where the PHY interrupt is triggered
> before the phy link status bit (reg 0x1 of the PHY device) is set to
> 1 (indicating link is up).

So the hardware is broken :-(

What about the other way, link down? Same problem?

Polling is probably your best bet, since it is robust against broken
interrupts. If i remember correctly, this is an off the shelf 1G PHY?
Microchip? Is there an errata for this? Maybe the errata suggests a
work around?

     Andrew

  reply	other threads:[~2020-08-11 20:07 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-29 18:29 [PATCH net-next] Add Mellanox BlueField Gigabit Ethernet driver David Thompson
2020-07-29 19:41 ` David Thompson
2020-07-29 20:31   ` David Miller
2020-07-29 20:49 ` Jakub Kicinski
2020-07-30  4:03 ` kernel test robot
2020-07-31 17:42 ` Andrew Lunn
     [not found]   ` <VI1PR05MB4110070900CF42CB3E18983EDA4E0@VI1PR05MB4110.eurprd05.prod.outlook.com>
2020-07-31 19:54     ` Andrew Lunn
2020-07-31 21:38       ` Asmaa Mnebhi
2020-08-01  1:14         ` Andrew Lunn
2020-08-03 14:23           ` Asmaa Mnebhi
2020-08-11 19:53   ` Asmaa Mnebhi
2020-08-11 20:06     ` Andrew Lunn [this message]
2020-08-12 20:37       ` Asmaa Mnebhi
2020-08-12 21:34         ` Andrew Lunn
2020-07-31 18:37 ` Andrew Lunn
2020-08-28 14:29   ` Asmaa Mnebhi
2020-07-31 18:38 ` Andrew Lunn
2020-08-28 14:24   ` Asmaa Mnebhi
2020-08-28 14:36     ` Andrew Lunn
2020-07-31 18:41 ` Andrew Lunn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200811200652.GD2141651@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=Asmaa@mellanox.com \
    --cc=asmaa@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=dthompson@mellanox.com \
    --cc=jiri@mellanox.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).