From: <Arun.Ramadoss@microchip.com>
To: <linux@armlinux.org.uk>
Cc: <andrew@lunn.ch>, <linux-kernel@vger.kernel.org>,
<UNGLinuxDriver@microchip.com>, <vivien.didelot@gmail.com>,
<olteanv@gmail.com>, <Tristram.Ha@microchip.com>,
<f.fainelli@gmail.com>,
<Prasanna.VengateshanVaradharajan@microchip.com>,
<kuba@kernel.org>, <edumazet@google.com>, <pabeni@redhat.com>,
<netdev@vger.kernel.org>, <Woojung.Huh@microchip.com>,
<davem@davemloft.net>, <hkallweit1@gmail.com>
Subject: Re: [Patch net-next v2 4/5] net: dsa: microchip: move interrupt handling logic from lan937x to ksz_common
Date: Thu, 15 Sep 2022 04:43:45 +0000 [thread overview]
Message-ID: <7ad568dc151647a7481a6ddd3c402c0b79277896.camel@microchip.com> (raw)
In-Reply-To: <YyG6q6SPURSAtz7C@shell.armlinux.org.uk>
Hi Russel,
Thanks for the comment.
On Wed, 2022-09-14 at 12:27 +0100, Russell King (Oracle) wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you
> know the content is safe
>
> Hi,
>
> Some suggestions for a few improvements in a future patch:
>
> On Wed, Sep 14, 2022 at 09:22:22AM +0530, Arun Ramadoss wrote:
> > +static int ksz_irq_phy_setup(struct ksz_device *dev)
> > +{
> > + struct dsa_switch *ds = dev->ds;
> > + int phy, err_phy;
> > + int irq;
> > + int ret;
> > +
> > + for (phy = 0; phy < KSZ_MAX_NUM_PORTS; phy++) {
> > + if (BIT(phy) & ds->phys_mii_mask) {
> > + irq = irq_find_mapping(dev-
> > >ports[phy].pirq.domain,
> > + PORT_SRC_PHY_INT);
> > + if (irq < 0) {
> > + ret = irq;
> > + goto out;
> > + }
> > + ds->slave_mii_bus->irq[phy] = irq;
> > + }
> > + }
> > + return 0;
> > +out:
> > + err_phy = phy;
> > +
> > + for (phy = 0; phy < err_phy; phy++)
> > + if (BIT(phy) & ds->phys_mii_mask)
> > + irq_dispose_mapping(ds->slave_mii_bus-
> > >irq[phy]);
>
> while (phy--)
> if (BIT(phy) & ds->phys_mii_mask)
> irq_dispose_mapping(ds->slave_mii_bus-
> >irq[phy]);
Ok. I will update.
>
> ?
>
> > +static void ksz_girq_mask(struct irq_data *d)
> > +{
> > + struct ksz_device *dev = irq_data_get_irq_chip_data(d);
> > + unsigned int n = d->hwirq;
> > +
> > + dev->girq.masked |= (1 << n);
>
> dev->girq.masked |= BIT(d->hwirq);
>
> ?
>
> > +}
> > +
> > +static void ksz_girq_unmask(struct irq_data *d)
> > +{
> > + struct ksz_device *dev = irq_data_get_irq_chip_data(d);
> > + unsigned int n = d->hwirq;
> > +
> > + dev->girq.masked &= ~(1 << n);
>
> dev->girq.masked &= ~BIT(d->hw_irq);
Ok. I will replace them with macros.
>
> ?
>
> > +}
> > +
> > +static void ksz_girq_bus_lock(struct irq_data *d)
> > +{
> > + struct ksz_device *dev = irq_data_get_irq_chip_data(d);
> > +
> > + mutex_lock(&dev->lock_irq);
> > +}
> > +
> > +static void ksz_girq_bus_sync_unlock(struct irq_data *d)
> > +{
> > + struct ksz_device *dev = irq_data_get_irq_chip_data(d);
> > + int ret;
> > +
> > + ret = ksz_write32(dev, REG_SW_PORT_INT_MASK__4, dev-
> > >girq.masked);
> > + if (ret)
> > + dev_err(dev->dev, "failed to change IRQ mask\n");
> > +
> > + mutex_unlock(&dev->lock_irq);
> > +}
> > +
> > +static const struct irq_chip ksz_girq_chip = {
> > + .name = "ksz-global",
> > + .irq_mask = ksz_girq_mask,
> > + .irq_unmask = ksz_girq_unmask,
> > + .irq_bus_lock = ksz_girq_bus_lock,
> > + .irq_bus_sync_unlock = ksz_girq_bus_sync_unlock,
> > +};
>
> As the pirq code is almost identical to the girq code, how about
> putting
> a "reg_mask", "reg_status" and a pointer to ksz_device into ksz_irq,
> and
> using the ksz_irq as the chip data?
>
> These would then become:
>
> static void ksz_irq_mask(struct irq_data *d)
> {
> struct ksz_irq *ki = irq_data_get_irq_chip_data(d);
>
> ki->masked |= BIT(d->hwirq);
> }
>
> static void ksz_irq_unmask(struct irq_data *d)
> {
> struct ksz_irq *ki = irq_data_get_irq_chip_data(d);
>
> ki->masked &= ~BIT(d->hwirq);
> }
>
> static void ksz_irq_bus_lock(struct irq_data *d)
> {
> struct ksz_irq *ki = irq_data_get_irq_chip_data(d);
>
> mutex_lock(&ki->dev->lock_irq);
> }
>
> static void ksz_irq_bus_sync_unlock(struct irq_data *d)
> {
> struct ksz_irq *ki = irq_data_get_irq_chip_data(d);
> struct ksz_device *dev = ki->dev;
> int ret;
>
> ret = ksz_write32(dev, ki->reg_masked, ki->masked);
> if (ret)
> dev_err(dev->dev, "failed to change IRQ mask\n");
>
> mutex_unlock(&dev->lock_irq);
> }
>
> and thus this code could be shared between both pirq and girq.
> I'm pretty sure the thead_fn could be shared as well, and I'm
> sure that the setup and tear down could be improved in a similar
> way.
Thanks for the suggestion. I will update the code and send the next
version of the patch.
>
> --
> RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
> FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
next prev parent reply other threads:[~2022-09-15 4:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-14 3:52 [Patch net-next v2 0/5] net: dsa: microchip: ksz9477: enable interrupt for internal phy link detection Arun Ramadoss
2022-09-14 3:52 ` [Patch net-next v2 1/5] net: dsa: microchip: determine number of port irq based on switch type Arun Ramadoss
2022-09-14 3:52 ` [Patch net-next v2 2/5] net: dsa: microchip: enable phy interrupts only if interrupt enabled in dts Arun Ramadoss
2022-09-14 3:52 ` [Patch net-next v2 3/5] net: dsa: microchip: lan937x: return zero if mdio node not present Arun Ramadoss
2022-09-14 3:52 ` [Patch net-next v2 4/5] net: dsa: microchip: move interrupt handling logic from lan937x to ksz_common Arun Ramadoss
2022-09-14 11:27 ` Russell King (Oracle)
2022-09-15 4:43 ` Arun.Ramadoss [this message]
2022-09-14 3:52 ` [Patch net-next v2 5/5] net: phy: micrel: enable interrupt for ksz9477 phy Arun Ramadoss
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=7ad568dc151647a7481a6ddd3c402c0b79277896.camel@microchip.com \
--to=arun.ramadoss@microchip.com \
--cc=Prasanna.VengateshanVaradharajan@microchip.com \
--cc=Tristram.Ha@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=Woojung.Huh@microchip.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=vivien.didelot@gmail.com \
/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
all inboxes | Powered by JetHome®