From patchwork Wed Jan 10 01:45:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 857867 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=nifty.com header.i=@nifty.com header.b="IXnjwzPA"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3zGX2m1tHRz9s7v for ; Wed, 10 Jan 2018 12:48:00 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 01D94C22019; Wed, 10 Jan 2018 01:47:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 9E955C21FD0; Wed, 10 Jan 2018 01:46:42 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C65D7C22061; Wed, 10 Jan 2018 01:46:10 +0000 (UTC) Received: from conuserg-11.nifty.com (conuserg-11.nifty.com [210.131.2.78]) by lists.denx.de (Postfix) with ESMTPS id 2DEC6C22061 for ; Wed, 10 Jan 2018 01:46:05 +0000 (UTC) Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-11.nifty.com with ESMTP id w0A1jUkU021339; Wed, 10 Jan 2018 10:45:33 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com w0A1jUkU021339 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1515548733; bh=M6vq3SLq02XN7GA9RS1e5mAtBSTlOvmnszA6p1mjMuE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IXnjwzPARh/JYUI+lbwquZXMZCVsRylt4Vmzsipy7njJldEX8xiHkYaOzE1/gT5AJ IWUHulW3wLn299fswWMB8g/8IPMf9B2QqcDqb0IrWOdzC+X7cAf9M4HRH8RZ5tnuj7 4+5arSM1YjsmIaBAjPiXMFzey/1r+zPd4JOsff0VQ/XAiwR5PtByhFJZP2OqkMBoAg A6n0dgceYQWsSodG9CRh3K8YEj5FzmOlyxReGJJjmLEO38M7q/BUh1b98Be0P288Ch aG2rNJXSh88MGgTChxzWKlsVu7Lo+X5fXEIEoM/tPzaPbMrE0nDznqRS+SxgqxWrk8 hk+0c+ATl7ujQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Wed, 10 Jan 2018 10:45:20 +0900 Message-Id: <1515548724-31869-3-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515548724-31869-1-git-send-email-yamada.masahiro@socionext.com> References: <1515548724-31869-1-git-send-email-yamada.masahiro@socionext.com> Cc: Marek Vasut , Tom Rini Subject: [U-Boot] [PATCH v3 2/6] usb: xhci: return ERR_PTR(-ETIMEDOUT) at the end of xhci_wait_for_event() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" xhci_wait_for_event() is supposed to return a pointer to union xhci_trb, but it does not return anything at the end of the function. This relies on that the end of the function is unreachable due to BUG(). We are planning to make BUG() no-op for platforms with strong image size constraint. Doing so would cause compiler warning: drivers/usb/host/xhci-ring.c:475:1: warning: control reaches end of non-void function [-Wreturn-type] } ^ So, this function must return something. From the error message just above, ERR_PTR(-ETIMEDOUT) seems a good choice. The use of BUG() looks suspicious here in the first place; no response from hardware is not a bug. It should be treated as a normal error. So, this function must return an error pointer instead of BUG(), then the caller must handle it properly. I am not fixing the code because this is not the only place that stops the system. Just one failure of xHCI halts the system, here and there. I left a comment block, hoping somebody will take a look. Signed-off-by: Masahiro Yamada --- Changes in v3: - newly added Changes in v2: None drivers/usb/host/xhci-ring.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 579e670..d780367 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -471,7 +471,14 @@ union xhci_trb *xhci_wait_for_event(struct xhci_ctrl *ctrl, trb_type expected) return NULL; printf("XHCI timeout on event type %d... cannot recover.\n", expected); + + /* + * CHECK: + * Is this software bug? Is this a good reason to halt the system? + */ BUG(); + + return ERR_PTR(-ETIMEDOUT); } /*