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: 123992 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4701242qgn; Tue, 9 Jan 2018 17:48:26 -0800 (PST) X-Google-Smtp-Source: ACJfBosty47JOaOVgmLD60yAqCU6AEOldxK5csV79CFFcFepoZ7dVzHc+mL3X1QLTT7HuApjNOB6 X-Received: by 10.80.149.246 with SMTP id x51mr23749591eda.74.1515548906778; Tue, 09 Jan 2018 17:48:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515548906; cv=none; d=google.com; s=arc-20160816; b=U/uEOtdaOKUPio2AXxelWFI2x1j2RbbQVnVQFcHCAH5K7PsjqqzhVquVMDDugkrVHR bvFt62Ho7MeayqUXUhR2kW8iFeO98yLFvQlqkucm2boGun3pTSZKfMzpQI3bX7exN5lT 800UXxc4oajp0TdNHoZT+SzGLiI9xGkrD8ufXIB3JX1ntlUBSqHYUGe6at8gBuRuv/6P YNAl5nlVqyqse3XBxcxe9wewvBp+e4QeUppRs6AmKpJcGpZuPFvXXsb/pn6HkSeqv+iL XBwvprZbyAl93ioIbCUIrOdbuwWVe8kHmmu63CLP525LtUjY3x9KtB1XOetQ/Lv5/0qT lw9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:dkim-filter:arc-authentication-results; bh=PLrhuS6QAuFC3JddGWEfyUXMo2UaBWhE0P661pPH6lo=; b=P0nWVZwjrnMAi3pVdMdbR77CyMDIGEtzHqS+wA+GqcgkOAN8UGBRFAgId6AHcQNABC c4yhNC5mDV6p9Rd3AADlpgd8Qq6vUA45DoQRZ7SzPxBXy7woaSLNtZ6DgvMdYVLRpGVr wCj21NcMKMdbtDgxUysNeY4PTwdQGa5fAnndar0dj+siTHte3IDMhgEIQ7GnuW1IBSmr +x/6YGw02PDP6RqatRq8DLF+VNKSEyo5nF/mBLcAbYPi5/Fs6iWVytN1PfRx23riADmV S4+84BNQnIZnuAK0twLtEqtVXNIjbzUchn17OuwyuOgHUMbwhH4isNN2V1wH28rCPrGD 4ADA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=IXnjwzPA; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id l88si5501885edl.104.2018.01.09.17.48.26; Tue, 09 Jan 2018 17:48:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=IXnjwzPA; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 59DD9C22042; Wed, 10 Jan 2018 01:47:13 +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); } /*