linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: chunfeng.yun@mediatek.com
Cc: linux-usb@vger.kernel.org
Subject: [bug report] usb: gadget: bdc: use readl_poll_timeout() to simplify code
Date: Tue, 27 Jul 2021 11:42:08 +0300	[thread overview]
Message-ID: <20210727084208.GA19962@kili> (raw)

Hello Chunfeng Yun,

The patch 75ae051efc9b: "usb: gadget: bdc: use readl_poll_timeout()
to simplify code" from Jul 13, 2020, leads to the following static
checker warning:

	drivers/usb/gadget/udc/bdc/bdc_core.c:38 poll_oip()
	warn: sleeping in atomic context

drivers/usb/gadget/udc/bdc/bdc_core.c
    33 static int poll_oip(struct bdc *bdc, u32 usec)
    34 {
    35 	u32 status;
    36 	int ret;
    37 
--> 38 	ret = readl_poll_timeout(bdc->regs + BDC_BDCSC, status,
    39 				 (BDC_CSTS(status) != BDC_OIP), 10, usec);
                                                                ^^
This adds a 10us sleep, but we're holding a spin lock so it's a sleeping
in atomic bug.  One call tree is:

bdc_udc_stop() <-- takes a spin lock
  --> bdc_stop
      --> poll_oip() <-- sleep

    40 	if (ret)
    41 		dev_err(bdc->dev, "operation timedout BDCSC: 0x%08x\n", status);
    42 	else
    43 		dev_dbg(bdc->dev, "%s complete status=%d", __func__, BDC_CSTS(status));
    44 
    45 	return ret;
    46 }

regards,
dan carpenter

                 reply	other threads:[~2021-07-27  8:42 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=20210727084208.GA19962@kili \
    --to=dan.carpenter@oracle.com \
    --cc=chunfeng.yun@mediatek.com \
    --cc=linux-usb@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).