From patchwork Tue Dec 20 05:59:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 88541 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp1559801qgi; Mon, 19 Dec 2016 22:00:15 -0800 (PST) X-Received: by 10.99.226.3 with SMTP id q3mr33861118pgh.37.1482213614961; Mon, 19 Dec 2016 22:00:14 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 91si20825243ply.117.2016.12.19.22.00.14; Mon, 19 Dec 2016 22:00:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755946AbcLTGAL (ORCPT + 4 others); Tue, 20 Dec 2016 01:00:11 -0500 Received: from mail-pf0-f171.google.com ([209.85.192.171]:33411 "EHLO mail-pf0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754673AbcLTGAL (ORCPT ); Tue, 20 Dec 2016 01:00:11 -0500 Received: by mail-pf0-f171.google.com with SMTP id d2so27431900pfd.0 for ; Mon, 19 Dec 2016 22:00:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6zDDbKM5im49TYOITrTSI1CECdYKIHi9ZBUmLOR9DBI=; b=GzXt4ZdHFhEbWFVNGldbgbV0GT+VYSrLCeCfE4tAVHWvTbXY08vvUwqT/ordf8m3wH Sw19GgBva9fcAbykHRMIFhgDmlANUY/YiW32alDWuD7cR+V8YY6dlKAS8YMOTZy5rpjG rNeP9C9tsMm0MZidakStRdD6OwE1HjtgKuRzc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6zDDbKM5im49TYOITrTSI1CECdYKIHi9ZBUmLOR9DBI=; b=OjV9Zc+hb0gPmlSwV7P11hIPdu6bQiRYDZ6ZJRr/q7+zoEMorwJ/b6BAQGN+kbG8wU KSo0lDD7MuxhsF3jYPuCG8t6+q0Q9DkZyfX4xAiaAdSmBpGVxdXiswARQdnfLnpkMSNk 6GnTERWvxQ5XwWRhuMTpBfkByZEZA/z9cJPgGjnUDMDMoSCi3SRh1YWEKxj7r4QeR/7X 9I2Zvvqi19FGF0sbh0nZTjN0kaJam8m6PI617s7QNwWoNngLetPJjc97dG1+jC3rTO2o eXVaqcPlcPGUQHtgw1nP2RXtAXSpexfkvVayhOfModenKBPe939Wk6V8fOaBk8thHE5q NnWA== X-Gm-Message-State: AIkVDXLtjnr5v5TkbwcW52WwF47u5rASBsUA/g/8u7HvUUlmGFZM9gUjRDMTWaRZyZuh23D+ X-Received: by 10.99.96.83 with SMTP id u80mr17339140pgb.151.1482213610243; Mon, 19 Dec 2016 22:00:10 -0800 (PST) Received: from baolinwangubtpc.spreadtrum.com ([175.111.195.49]) by smtp.gmail.com with ESMTPSA id r21sm35458418pfd.44.2016.12.19.22.00.07 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 19 Dec 2016 22:00:09 -0800 (PST) From: Baolin Wang To: mathias.nyman@intel.com, gregkh@linuxfoundation.org Cc: baolu.lu@linux.intel.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, broonie@kernel.org, baolin.wang@linaro.org, linaro-kernel@lists.linaro.org Subject: [PATCH v2 2/2] usb: host: xhci: Handle the right timeout command Date: Tue, 20 Dec 2016 13:59:51 +0800 Message-Id: <99414f74354db54aa4637ef82b0f491762219b98.1482212656.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org If a command event is found on the event ring during an interrupt, we need to stop the command timer with del_timer(). Since del_timer() can fail if the timer is running and waiting on the xHCI lock, then it maybe get the wrong timeout command in xhci_handle_command_timeout() if host fetched a new command and updated the xhci->current_cmd in handle_cmd_completion(). For this situation, we need a way to signal to the command timer that everything is fine and it should exit. We should check if the command timer is pending in xhci_handle_command_timeout() function, if the command timer is pending, which means current timeout command has been handled by host and host has fetched new command and re-added the command timer, then just return and wait for new current command. If not, it means current command is timeout and need to be handled. Signed-off-by: Baolin Wang --- Changes since v1: - Remove the counter and just check if the command timer is pending. --- drivers/usb/host/xhci-ring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 9965a4c..3947344 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -1269,7 +1269,7 @@ void xhci_handle_command_timeout(unsigned long data) xhci = (struct xhci_hcd *) data; spin_lock_irqsave(&xhci->lock, flags); - if (!xhci->current_cmd) { + if (!xhci->current_cmd || timer_pending(&xhci->cmd_timer)) { spin_unlock_irqrestore(&xhci->lock, flags); return; }