All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: netdev@vger.kernel.org, linux-wireless@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: Kalle Valo <kvalo@codeaurora.org>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: [RFC] Status of orinoco_usb
Date: Fri, 2 Oct 2020 12:35:17 +0200	[thread overview]
Message-ID: <20201002103517.fhsi5gaepzbzo2s4@linutronix.de> (raw)

I was trying to get rid of the in in_softirq() in ezusb_req_ctx_wait()
within the orinoco usb driver,
drivers/net/wireless/intersil/orinoco/orinoco_usb.c. A small snippet:

| static void ezusb_req_ctx_wait(struct ezusb_priv *upriv,
|                                struct request_context *ctx)
…
|                 if (in_softirq()) {
|                         /* If we get called from a timer, timeout timers don't
|                          * get the chance to run themselves. So we make sure
|                          * that we don't sleep for ever */
|                         int msecs = DEF_TIMEOUT * (1000 / HZ);
| 
|                         while (!try_wait_for_completion(&ctx->done) && msecs--)
|                                 udelay(1000);
|                 } else {
|                         wait_for_completion(&ctx->done);
…
| }

This is broken. The EHCI and XHCI HCD will complete the URB in
BH/tasklet. Should we ever get here in_softirq() then we will spin
here/wait here until the timeout passes because the tasklet won't be
able to run. OHCI/UHCI HCDs still complete in hard-IRQ so it would work
here.

Is it possible to end up here in softirq context or is this a relic?
Well I have no hardware but I see this:

  orinoco_set_monitor_channel() [I assume that this is fully preemtible]
  -> orinoco_lock() [this should point to ezusb_lock_irqsave() which
                     does spin_lock_bh(lock), so from here on
		     in_softirq() returns true]
  -> hw->ops->cmd_wait() [-> ezusb_docmd_wait()]
  -> ezusb_alloc_ctx() [ sets ctx->in_rid to EZUSB_RID_ACK/0x0710 ]
  -> ezusb_access_ltv()
     -> if (ctx->in_rid)
       -> ezusb_req_ctx_wait(upriv, ctx);
	 -> ctx->state should be EZUSB_CTX_REQ_COMPLETE so we end up in
	    the while loop above. So we udelay() 3 * 1000 * 1ms = 3sec.
	 -> Then ezusb_access_ltv() should return with an error due to
	    timeout.

This isn't limited to exotic features like monitor mode. orinoco_open()
does orinoco_lock() followed by orinoco_hw_program_rids() which in the
end invokes ezusb_write_ltv(,, EZUSB_RID_ACK) which is non-zero and also
would block (ezusb_xmit() would use 0 as the last argument so it won't
block).

I don't see how this driver can work on EHCI/XHCI HCD as of today.
The driver is an orphan since commit
   3a59babbee409 ("orinoco: update status in MAINTAINERS")

which is ten years ago. If I replace in_softirq() with a `may_sleep'
argument then it is still broken.
Should it be removed?

Sebastian

             reply	other threads:[~2020-10-02 10:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-02 10:35 Sebastian Andrzej Siewior [this message]
2020-10-02 11:37 ` [RFC] Status of orinoco_usb Greg Kroah-Hartman
2020-10-02 11:53   ` Sebastian Andrzej Siewior
2020-10-02 12:06     ` Greg Kroah-Hartman
2020-10-05 14:12       ` Kalle Valo
2020-10-06  7:45         ` Arend Van Spriel
2020-10-06 12:40           ` Jes Sorensen
2020-10-06 15:05             ` Dan Williams

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=20201002103517.fhsi5gaepzbzo2s4@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=davem@davemloft.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=kuba@kernel.org \
    --cc=kvalo@codeaurora.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /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.