Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1192555pxk; Fri, 2 Oct 2020 03:36:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhzPU+TbQCHLmMg+UnT4jhIuQqDi5Jd8/adrWPtr2CFD5VKBUP2hW/HwZHaeMBegLu13J0 X-Received: by 2002:a17:906:14d8:: with SMTP id y24mr1449654ejc.123.1601634967267; Fri, 02 Oct 2020 03:36:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601634967; cv=none; d=google.com; s=arc-20160816; b=NyA1YMLXhYxULowZeEi08TXpxaxW2bLixB3UJjNkpP7x7r4E1raDcruyJ6ySGFl+8g 3cEsXGVgBm8A8+B8kFNABgkmxd+6saXgrbx8p7ESWKsiJI25wSiS9/byIt8i2f/Uj04O RSSsVe2tK8VF+iDtHO5SsxOlsj4MkLijJKZ9dm3yMfhuHj9ILAkPAyaWz+K/TK5JCxpU exTyPxJpsRGmw5q/TzjT+FVnBce3phe3+uwgXezZwC7WOZWJ8QPGQbYrjq1qwD59CWFU A4M4l0tKGPIQIevQIln/7iwJgOlSwgx1rJnbRTuozE/kH0lXf2IXgW04G/60VbseKLk+ /9sQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-disposition :mime-version:message-id:subject:cc:to:from:dkim-signature :dkim-signature:date; bh=CeDJ1dXLme679M/bPGlRbCUFKCuFkyI8moFOBFkwQtM=; b=CdcIMnoqzjygoYIRml87qVM32mnpJotXywQj5gTadROKy8HK8SSU5AmhjFjYIFQmxA B8ZZxlTyyy6SDpXvUlKjgYnCJaRr5u3kOemsqonNolqdtscGY+aXF612sugg6/TLF9ZP kVg5qPqKnea3A5g+i/DZFZltIkfrsMtGYywLi2pk0TxLyTHjjSZXq/UvJRFc2ALMHbnB YYMKeUVUGFSoV4zeCsPJ+VdE4tUUfg8fNI7QY8RwOgBblRFVCB/tY9J6y48uvNqumBKU PGGR8HvjibRi5XyoPklsgoHhxbyxHRrWyIXmM9ja0uP9h+ikQINQlmY27/rv6Q0YKShy wxVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Oiv80LLE; dkim=neutral (no key) header.i=@linutronix.de header.b="3//r+E4P"; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v15si736150edw.67.2020.10.02.03.35.32; Fri, 02 Oct 2020 03:36:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Oiv80LLE; dkim=neutral (no key) header.i=@linutronix.de header.b="3//r+E4P"; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387652AbgJBKfW (ORCPT + 99 others); Fri, 2 Oct 2020 06:35:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725993AbgJBKfU (ORCPT ); Fri, 2 Oct 2020 06:35:20 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70E46C0613D0; Fri, 2 Oct 2020 03:35:20 -0700 (PDT) Date: Fri, 2 Oct 2020 12:35:17 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1601634918; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CeDJ1dXLme679M/bPGlRbCUFKCuFkyI8moFOBFkwQtM=; b=Oiv80LLEtF21HuKEaTpvbjRgw5+l7EOAcB/SOXXKTYcbou07z3rJbr4MB0bYSGcA2WJJNa 1Nv0EKGxpPyQiztkzJb9aM2oTAOnevTd1Lz5Qk5YVsEO7Cf2Q2q+LeBBwSepc2f9hOAuH3 qp7N66HZyRdoSb/HV+p63t8D7iEOOAa2aZuuzyLEsORPQkKCG3HYL87gJM8ToGDGBjRzFr kCrGGHcsr1L5C+cr7z6bw8OtnZofxSg5cHB6Z9qSs1ijtF+7FyN2SQboPT4yr33mbC2CyD dW0xpXTeouJtrVMFvtYmsIf9x6yykUyy9ichRfpWbc5VOan4pcPYXUu84qK0GA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1601634918; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CeDJ1dXLme679M/bPGlRbCUFKCuFkyI8moFOBFkwQtM=; b=3//r+E4PAS6xtqgqLaHydxvPAjbLIRQymyWCJwefulBoiGjQ02eQLJ3lMuh0vBAITCfvRA RBMIj5yxxTGKH4Bw== From: Sebastian Andrzej Siewior To: netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Kalle Valo , "David S. Miller" , Jakub Kicinski , Greg Kroah-Hartman , Thomas Gleixner Subject: [RFC] Status of orinoco_usb Message-ID: <20201002103517.fhsi5gaepzbzo2s4@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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) =E2=80=A6 | if (in_softirq()) { | /* If we get called from a timer, timeout timers = don't | * get the chance to run themselves. So we make s= ure | * that we don't sleep for ever */ | int msecs =3D DEF_TIMEOUT * (1000 / HZ); |=20 | while (!try_wait_for_completion(&ctx->done) && ms= ecs--) | udelay(1000); | } else { | wait_for_completion(&ctx->done); =E2=80=A6 | } 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 =3D 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