Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752620AbbEDDPx (ORCPT ); Sun, 3 May 2015 23:15:53 -0400 Received: from mga02.intel.com ([134.134.136.20]:15279 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752566AbbEDDPj (ORCPT ); Sun, 3 May 2015 23:15:39 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,363,1427785200"; d="scan'208";a="565694318" From: Lu Baolu To: Greg Kroah-Hartman , Mathias Nyman , Alan Stern Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [RFC][PATCH 2/3] usb: xhci: implement hc_driver notify entry Date: Mon, 4 May 2015 11:15:31 +0800 Message-Id: <1430709332-18814-3-git-send-email-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1430709332-18814-1-git-send-email-baolu.lu@linux.intel.com> References: <1430709332-18814-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: 3662 Lines: 100 This patch implements the notify entry defined in hc_driver for xHC driver. For HCD_MSG_DEV_SUSPEND message, it will issue stop endpoint command for each endpoint in the device. The Suspend(SP) bit in the command TRB will be set, which gives xHC a hint about the suspend. For HCD_MSG_DEV_RESUME, it will ring doorbells for all endpoints unconditionally. XHC may use these hints to optimize its operation on endpoint state cashes. Signed-off-by: Lu Baolu --- drivers/usb/host/xhci-hub.c | 2 +- drivers/usb/host/xhci.c | 28 ++++++++++++++++++++++++++++ drivers/usb/host/xhci.h | 3 +++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index 0827d7c..a83e82e 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c @@ -266,7 +266,7 @@ int xhci_find_slot_id_by_port(struct usb_hcd *hcd, struct xhci_hcd *xhci, * to complete. * suspend will set to 1, if suspend bit need to set in command. */ -static int xhci_stop_device(struct xhci_hcd *xhci, int slot_id, int suspend) +int xhci_stop_device(struct xhci_hcd *xhci, int slot_id, int suspend) { struct xhci_virt_device *virt_dev; struct xhci_command *cmd; diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index ec8ac16..1e4aa78 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -4917,6 +4917,29 @@ error: } EXPORT_SYMBOL_GPL(xhci_gen_setup); +void xhci_notify(struct usb_hcd *hcd, struct usb_device *udev, + enum hcd_notification_type type, void *data) +{ + struct xhci_hcd *xhci; + + xhci = hcd_to_xhci(hcd); + if (!xhci || !xhci->devs[udev->slot_id]) + return; + + switch (type) { + case HCD_MSG_DEV_SUSPEND: + xhci_stop_device(xhci, udev->slot_id, 1); + break; + case HCD_MSG_DEV_RESUME: + xhci_ring_device(xhci, udev->slot_id); + break; + default: + xhci_dbg(xhci, "unknown notification message %d.\n", type); + break; + } + +} + static const struct hc_driver xhci_hc_driver = { .description = "xhci-hcd", .product_desc = "xHCI Host Controller", @@ -4976,6 +4999,11 @@ static const struct hc_driver xhci_hc_driver = { .enable_usb3_lpm_timeout = xhci_enable_usb3_lpm_timeout, .disable_usb3_lpm_timeout = xhci_disable_usb3_lpm_timeout, .find_raw_port_number = xhci_find_raw_port_number, + + /* + * notification call back + */ + .notify = xhci_notify, }; void xhci_init_driver(struct hc_driver *drv, int (*setup_fn)(struct usb_hcd *)) diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 8e421b8..f71c643 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1867,10 +1867,13 @@ u32 xhci_port_state_to_neutral(u32 state); int xhci_find_slot_id_by_port(struct usb_hcd *hcd, struct xhci_hcd *xhci, u16 port); void xhci_ring_device(struct xhci_hcd *xhci, int slot_id); +int xhci_stop_device(struct xhci_hcd *xhci, int slot_id, int suspend); /* xHCI contexts */ struct xhci_input_control_ctx *xhci_get_input_control_ctx(struct xhci_container_ctx *ctx); struct xhci_slot_ctx *xhci_get_slot_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx); struct xhci_ep_ctx *xhci_get_ep_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx, unsigned int ep_index); +void xhci_notify(struct usb_hcd *hcd, struct usb_device *udev, + enum hcd_notification_type type, void *data); #endif /* __LINUX_XHCI_HCD_H */ -- 2.1.0 -- 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/