All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: horatiu.vultur@microchip.com
Cc: kernel-janitors@vger.kernel.org
Subject: [bug report] net: lan966x: add support for interrupts from analyzer
Date: Wed, 19 Jan 2022 13:40:00 +0300	[thread overview]
Message-ID: <20220119104000.GA2730@kili> (raw)

Hello Horatiu Vultur,

The patch 5ccd66e01cbe: "net: lan966x: add support for interrupts
from analyzer" from Dec 18, 2021, leads to the following Smatch
static checker warning:

	drivers/net/ethernet/microchip/lan966x/lan966x_mac.c:43 lan966x_mac_wait_for_completion()
	warn: sleeping in atomic context

The call tree is:

lan966x_mac_del_entry() <- disables preempt
lan966x_mac_purge_entries() <- disables preempt
-> lan966x_mac_forget()
   -> lan966x_mac_wait_for_completion()

drivers/net/ethernet/microchip/lan966x/lan966x_mac.c
   261        int lan966x_mac_del_entry(struct lan966x *lan966x, const unsigned char *addr,
   262                                  u16 vid)
   263        {
   264                struct lan966x_mac_entry *mac_entry, *tmp;
   265
   266                spin_lock(&lan966x->mac_lock);
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Take a spin locks

   267                list_for_each_entry_safe(mac_entry, tmp, &lan966x->mac_entries,
   268                                         list) {
   269                        if (mac_entry->vid == vid &&
   270                            ether_addr_equal(addr, mac_entry->mac)) {
   271                                lan966x_mac_forget(lan966x, mac_entry->mac, mac_entry->vid,
                                      ^^^^^^^^^^^^^^^^^^
Calls function which can sleep

   272                                                   ENTRYTYPE_LOCKED);
   273
   274                                list_del(&mac_entry->list);
   275                                kfree(mac_entry);
   276                        }
   277                }
   278                spin_unlock(&lan966x->mac_lock);
   279
   280                return 0;
   281        }
   282
   283        void lan966x_mac_purge_entries(struct lan966x *lan966x)
   284        {
   285                struct lan966x_mac_entry *mac_entry, *tmp;
   286
   287                spin_lock(&lan966x->mac_lock);
   288                list_for_each_entry_safe(mac_entry, tmp, &lan966x->mac_entries,
   289                                         list) {
   290                        lan966x_mac_forget(lan966x, mac_entry->mac, mac_entry->vid,

Same thing

   291                                           ENTRYTYPE_LOCKED);
   292
   293                        list_del(&mac_entry->list);
   294                        kfree(mac_entry);
   295                }
   296                spin_unlock(&lan966x->mac_lock);
   297        }

drivers/net/ethernet/microchip/lan966x/lan966x_mac.c
    39 static int lan966x_mac_wait_for_completion(struct lan966x *lan966x)
    40 {
    41         u32 val;
    42 
--> 43         return readx_poll_timeout(lan966x_mac_get_status,
                      ^^^^^^^^^^^^^^^^^^
sleeps

    44                 lan966x, val,
    45                 (ANA_MACACCESS_MAC_TABLE_CMD_GET(val)) ==
    46                 MACACCESS_CMD_IDLE,
    47                 TABLE_UPDATE_SLEEP_US, TABLE_UPDATE_TIMEOUT_US);
    48 }

regards,
dan carpenter

                 reply	other threads:[~2022-01-19 10:40 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=20220119104000.GA2730@kili \
    --to=dan.carpenter@oracle.com \
    --cc=horatiu.vultur@microchip.com \
    --cc=kernel-janitors@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 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.