Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752578AbbKIHk3 (ORCPT ); Mon, 9 Nov 2015 02:40:29 -0500 Received: from mga11.intel.com ([192.55.52.93]:61059 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752041AbbKIHkZ (ORCPT ); Mon, 9 Nov 2015 02:40:25 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,265,1444719600"; d="scan'208";a="845880503" From: Lu Baolu To: Mathias Nyman , Greg Kroah-Hartman , Alan Stern Cc: linux-usb@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v3 07/12] usb: xhci: dbc: handle dbc-configured exit Date: Mon, 9 Nov 2015 15:38:36 +0800 Message-Id: <1447054721-7390-8-git-send-email-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1447054721-7390-1-git-send-email-baolu.lu@linux.intel.com> References: <1447054721-7390-1-git-send-email-baolu.lu@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1805 Lines: 64 DbC might exit configured state in some cases (refer to 7.6.4.4 in xHCI spec 1.1). Software needs detect and clear this situation by clearing DCCTRL.DCR and wait until the DbC configured before read or write oprations. Signed-off-by: Lu Baolu --- drivers/usb/early/xhci-dbc.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/usb/early/xhci-dbc.c b/drivers/usb/early/xhci-dbc.c index f51daa4..8a5a51f 100644 --- a/drivers/usb/early/xhci-dbc.c +++ b/drivers/usb/early/xhci-dbc.c @@ -1153,6 +1153,29 @@ static int xdbc_wait_until_bulk_done(struct xdbc_trb *trb, int loops) return -EIO; } +static int xdbc_wait_until_dbc_configured(void) +{ + int timeout = 0; + u32 reg; + + /* Port exits configured state */ + reg = readl(&xdbcp->xdbc_reg->control); + if (!(reg & CTRL_DRC)) + return 0; + + /* clear run change bit (RW1C) */ + writel(reg | CTRL_DRC, &xdbcp->xdbc_reg->control); + + do { + if (readl(&xdbcp->xdbc_reg->control) & CTRL_DCR) + return 0; + + xdbc_udelay(10); + } while (timeout++ < XDBC_LOOPS); + + return -ETIMEDOUT; +} + static int xdbc_bulk_transfer(void *data, int size, int loops, bool read) { u64 addr; @@ -1167,6 +1190,11 @@ static int xdbc_bulk_transfer(void *data, int size, int loops, bool read) return -EINVAL; } + if (xdbc_wait_until_dbc_configured()) { + xdbc_trace("%s: hardware not ready\n", __func__); + return -EPERM; + } + ring = (read ? &xdbcp->in_ring : &xdbcp->out_ring); trb = ring->enqueue; cycle = ring->cycle_state; -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/