All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: nicolas.ferre@microchip.com
Cc: kernel-janitors@vger.kernel.org
Subject: [bug report] net: macb: WoL support for GEM type of Ethernet controller
Date: Wed, 19 Jan 2022 13:47:20 +0300	[thread overview]
Message-ID: <20220119104720.GA3945@kili> (raw)

Hello Nicolas Ferre,

The patch 558e35ccfe95: "net: macb: WoL support for GEM type of
Ethernet controller" from Jul 20, 2020, leads to the following Smatch
static checker warning:

	./include/linux/interrupt.h:215 devm_request_irq()
	warn: sleeping in atomic context

The call tree is:

macb_suspend() <- disables preempt
macb_resume() <- disables preempt
-> devm_request_irq()

drivers/net/ethernet/cadence/macb_main.c
  4922        static int __maybe_unused macb_resume(struct device *dev)
  4923        {
  4924                struct net_device *netdev = dev_get_drvdata(dev);
  4925                struct macb *bp = netdev_priv(netdev);
  4926                struct macb_queue *queue;
  4927                unsigned long flags;
  4928                unsigned int q;
  4929                int err;
  4930
  4931                if (!netif_running(netdev))
  4932                        return 0;
  4933
  4934                if (!device_may_wakeup(dev))
  4935                        pm_runtime_force_resume(dev);
  4936
  4937                if (bp->wol & MACB_WOL_ENABLED) {
  4938                        spin_lock_irqsave(&bp->lock, flags);

Holding a spinlock

  4939                        /* Disable WoL */
  4940                        if (macb_is_gem(bp)) {
  4941                                queue_writel(bp->queues, IDR, GEM_BIT(WOL));
  4942                                gem_writel(bp, WOL, 0);
  4943                        } else {
  4944                                queue_writel(bp->queues, IDR, MACB_BIT(WOL));
  4945                                macb_writel(bp, WOL, 0);
  4946                        }
  4947                        /* Clear ISR on queue 0 */
  4948                        queue_readl(bp->queues, ISR);
  4949                        if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE)
  4950                                queue_writel(bp->queues, ISR, -1);
  4951                        /* Replace interrupt handler on queue 0 */
  4952                        devm_free_irq(dev, bp->queues[0].irq, bp->queues);
  4953                        err = devm_request_irq(dev, bp->queues[0].irq, macb_interrupt,

devm_request_irq() has a GFP_KERNEL allocation in it.  The suspend and
resume function have this same bug.

  4954                                               IRQF_SHARED, netdev->name, bp->queues);
  4955                        if (err) {
  4956                                dev_err(dev,
  4957                                        "Unable to request IRQ %d (error %d)\n",
  4958                                        bp->queues[0].irq, err);
  4959                                spin_unlock_irqrestore(&bp->lock, flags);
  4960                                return err;
  4961                        }
  4962                        spin_unlock_irqrestore(&bp->lock, flags);
  4963
  4964                        disable_irq_wake(bp->queues[0].irq);
  4965

regards,
dan carpenter

                 reply	other threads:[~2022-01-19 10:47 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=20220119104720.GA3945@kili \
    --to=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=nicolas.ferre@microchip.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.