public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: netdev@vger.kernel.org
Cc: Sanjay Hortikar <horti@google.com>
Subject: [bug report] net-forcedeth: Add internal loopback support for forcedeth NICs.
Date: Fri, 6 Jan 2023 17:50:50 +0300	[thread overview]
Message-ID: <Y7g1Skvt3d0YDHmf@kili> (raw)

[ This bug is 11 years old now but it's pretty obviously buggy so maybe
  someone wants to take a look.  I have no idea why this warning is
  only showing up now.  - dan ]

The patch e19df76a1113: "net-forcedeth: Add internal loopback support
for forcedeth NICs." from Nov 11, 2011, leads to the following Smatch
static checker warning:

drivers/net/ethernet/nvidia/forcedeth.c:4889 nv_set_loopback() warn: sleeping in atomic context
drivers/net/ethernet/nvidia/forcedeth.c:4915 nv_set_loopback() warn: sleeping in atomic context

drivers/net/ethernet/nvidia/forcedeth.c
    4874 static int nv_set_loopback(struct net_device *dev, netdev_features_t features)
    4875 {
    4876         struct fe_priv *np = netdev_priv(dev);
    4877         unsigned long flags;
    4878         u32 miicontrol;
    4879         int err, retval = 0;
    4880 
    4881         spin_lock_irqsave(&np->lock, flags);
                 ^^^^^^^^^^^^^^^^^
Holding a spin lock.

    4882         miicontrol = mii_rw(dev, np->phyaddr, MII_BMCR, MII_READ);
    4883         if (features & NETIF_F_LOOPBACK) {
    4884                 if (miicontrol & BMCR_LOOPBACK) {
    4885                         spin_unlock_irqrestore(&np->lock, flags);
    4886                         netdev_info(dev, "Loopback already enabled\n");
    4887                         return 0;
    4888                 }
--> 4889                 nv_disable_irq(dev);

You can't call disable_irq() with preempt disabled.

    4890                 /* Turn on loopback mode */
    4891                 miicontrol |= BMCR_LOOPBACK | BMCR_FULLDPLX | BMCR_SPEED1000;
    4892                 err = mii_rw(dev, np->phyaddr, MII_BMCR, miicontrol);
    4893                 if (err) {
    4894                         retval = PHY_ERROR;
    4895                         spin_unlock_irqrestore(&np->lock, flags);
    4896                         phy_init(dev);
    4897                 } else {
    4898                         if (netif_running(dev)) {
    4899                                 /* Force 1000 Mbps full-duplex */
    4900                                 nv_force_linkspeed(dev, NVREG_LINKSPEED_1000,
    4901                                                                          1);
    4902                                 /* Force link up */
    4903                                 netif_carrier_on(dev);
    4904                         }
    4905                         spin_unlock_irqrestore(&np->lock, flags);
    4906                         netdev_info(dev,
    4907                                 "Internal PHY loopback mode enabled.\n");
    4908                 }
    4909         } else {
    4910                 if (!(miicontrol & BMCR_LOOPBACK)) {
    4911                         spin_unlock_irqrestore(&np->lock, flags);
    4912                         netdev_info(dev, "Loopback already disabled\n");
    4913                         return 0;
    4914                 }
    4915                 nv_disable_irq(dev);

Same.

    4916                 /* Turn off loopback */
    4917                 spin_unlock_irqrestore(&np->lock, flags);
    4918                 netdev_info(dev, "Internal PHY loopback mode disabled.\n");
    4919                 phy_init(dev);
    4920         }
    4921         msleep(500);
    4922         spin_lock_irqsave(&np->lock, flags);
    4923         nv_enable_irq(dev);
    4924         spin_unlock_irqrestore(&np->lock, flags);
    4925 
    4926         return retval;
    4927 }

regards,
dan carpenter

                 reply	other threads:[~2023-01-06 14:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=Y7g1Skvt3d0YDHmf@kili \
    --to=error27@gmail.com \
    --cc=horti@google.com \
    --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