Message ID | 20221214070650.703793-2-pumahsu@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp54474wrn; Tue, 13 Dec 2022 23:08:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf40sQaD6Y0fXD6aOlCcwh278a9Tv6bDoeFXSMhxL7kAs57npSBulIVbV5TFSSUuFrxQ4Ee7 X-Received: by 2002:a05:6a00:2bb:b0:57a:9b14:69b7 with SMTP id q27-20020a056a0002bb00b0057a9b1469b7mr3163297pfs.0.1671001700918; Tue, 13 Dec 2022 23:08:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671001700; cv=none; d=google.com; s=arc-20160816; b=PVAYF+yxBljtcxNqcKDovfeKriiF4ggJqOwr/1aSfGk2d9aD2wSuLpR5SJXbISUbBx xDqRROkXnYB7kAnYC/wxbCAaH/MIXf+J/KhTZg3fj4EfqDfojpZXknaXQRG8jgaTI7UD 7UECRJPodAA8qqbMgKkp7LfLpbbGhWBj0yS08IlJjUIRAHtluvZfX0d7qWK3BEV46SBe jRX+RFzKj+PVEThSfq2WAmkM2aoX232jZABNBlOvtcTZChp3do1ZmbfGLmTcbhuVXgXK 1KJE1IPTBZcnCQFszCMEYp8achD+F9VipA3p69gP2tFHvRLnfXyc+QI6MPig+JhHMdKe 1zDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=N1ar1dADbdU6DENQz+1O8bfsS7Rj7vcSTdNKfRYLHK4=; b=EuQGm04Cqesy7+zhwe2FAvkasemrIMKarXy6PUB8YLcT/IR6eRZSFW/nuYBCh4Wjih qJ8s2cC6K8JjGq4cW5n6Tqj+dqrNYxTLwHMrWabnE/76a/8zgnQ9waBtBcvCbTAhRXKL MBZ8DQTBggte0nf4GejYPX3CayLvK00p5RIzVrIudQImsM04sz0dw7mWsNVnDmWu2auS xt23J+W6LW/k0AZPNDSLu3PpK6EqzHfZuSOSKkS8R6BwjY6D2uqhzn95YzppBbq5NNZw yN8uQ/L0mASC8L2pQXFjbdzYj09TXwa206vvRafGV9zHHYNH+OdNweDjzoDHdkdUkw21 /3xA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Y0BnuVQu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ct18-20020a056a000f9200b005765f4a295fsi14747667pfb.350.2022.12.13.23.08.08; Tue, 13 Dec 2022 23:08:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Y0BnuVQu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237512AbiLNHHq (ORCPT <rfc822;jeantsuru.cumc.mandola@gmail.com> + 99 others); Wed, 14 Dec 2022 02:07:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237201AbiLNHHg (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 14 Dec 2022 02:07:36 -0500 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5366B6570 for <linux-kernel@vger.kernel.org>; Tue, 13 Dec 2022 23:07:26 -0800 (PST) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-3b0af5bcbd3so196520377b3.0 for <linux-kernel@vger.kernel.org>; Tue, 13 Dec 2022 23:07:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=N1ar1dADbdU6DENQz+1O8bfsS7Rj7vcSTdNKfRYLHK4=; b=Y0BnuVQuCo6vSf8eHHnJ/qgMABwFE1KDrHYvbMKq59Qi7/2tfcLob/qtmQg0ble+kM +B5jGvL/4ZcC/N1TEHOEjfIzUEcxavRVb4coNc0sVe/ia0lz1lp5MgYmHwaYoGoRhWCC yXfwxeC8nLVZHghItn7IhxQtyOqhcb5Ze1tEjEBnbt7qlGWUrRqqZS+3BPMnGPIBazf9 7Zk4y4JpQ4d/HS5Gi8/2tWOVQ9FlysDDESiH8XxUA5MsiJSloMSX8lEVVkgLWebC5GFl AkF/WVJzD4QY5fycLmTDd0cekmAT232RQs11zitmIFaGryuFMozYq/drxC2gd0641jlS G49A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=N1ar1dADbdU6DENQz+1O8bfsS7Rj7vcSTdNKfRYLHK4=; b=oe6LaJlnTUSVAoV65aVLAkeuDI3/IWEKpCBFBLyV+dvVHYMj0LTxayacOdV4EWJpKc HKJn+TSW3f4XKeDQgUAwgFA8GeEa53KjENtK2/zZ7esYXWHqY1e/FdghfTAbAtgTDNbY CQYJCu9apn3LqOBu4sBLjwagiitZ7XUoXTGZVN79EA4KF7T7iwalPQ79FT7lNGrXWr5r hkAWNRnGdg/YDY2pDfr0KzoSNjSWKfAsp+n+e6fO2fTfqjUr00TmG/zacKvpngB89qhE tACIXfRiPzO6bZY6s/6BQcs7OvsHG2+txEowVzeXUQHT4kcCSHy1FDI5xUwvn9Jndy+7 SpbQ== X-Gm-Message-State: ANoB5plDOXVGiQzdWErhDBWacCvdUaHTEEbJ/FLi/IfZmBMSn/bYJf45 L8EmCww30mswVKBqLutH+wMaLuwzxli4 X-Received: from pumahsu.ntc.corp.google.com ([2401:fa00:fc:202:cb1:cbe3:3a49:1751]) (user=pumahsu job=sendgmr) by 2002:a25:74c7:0:b0:6fb:67c7:33e1 with SMTP id p190-20020a2574c7000000b006fb67c733e1mr35977414ybc.255.1671001645440; Tue, 13 Dec 2022 23:07:25 -0800 (PST) Date: Wed, 14 Dec 2022 15:06:49 +0800 In-Reply-To: <20221214070650.703793-1-pumahsu@google.com> Message-Id: <20221214070650.703793-2-pumahsu@google.com> Mime-Version: 1.0 References: <20221214070650.703793-1-pumahsu@google.com> X-Mailer: git-send-email 2.39.0.rc1.256.g54fd8350bd-goog Subject: [PATCH 1/2] usb: core: add vendor hook for usb suspend and resume From: Puma Hsu <pumahsu@google.com> To: gregkh@linuxfoundation.org, mka@chromium.org, dianders@chromium.org Cc: albertccwang@google.com, raychi@google.com, howardyen@google.com, leejj@google.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Puma Hsu <pumahsu@google.com> Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752172279515339428?= X-GMAIL-MSGID: =?utf-8?q?1752172279515339428?= |
Series |
add vendor hooks for usb suspend and resume
|
|
Commit Message
Puma Hsu
Dec. 14, 2022, 7:06 a.m. UTC
Add the hooks that vendor can design and bypass the suspend/resume.
When the handled is set, skip the original suspend/resume process.
In mobile, a co-processor can be used for USB audio. When the co-processor
is working for USB audio, the co-processor is the user/owner of the USB
driver, and the ACPU is able to sleep in such condition to improve power
consumption. In original process, the ACPU will suspend/resume until the
USB suspend/resume. We add the hooks, so we can control USB suspend/resume
without affecting the ACPU.
Signed-off-by: Puma Hsu <pumahsu@google.com>
---
drivers/usb/core/Makefile | 2 +-
drivers/usb/core/driver.c | 36 ++++++++++++++++++++++++++++++++++++
drivers/usb/core/usb.h | 5 +++++
3 files changed, 42 insertions(+), 1 deletion(-)
Comments
On Wed, Dec 14, 2022 at 3:07 PM Puma Hsu <pumahsu@google.com> wrote: > > Add the hooks that vendor can design and bypass the suspend/resume. > When the handled is set, skip the original suspend/resume process. > > In mobile, a co-processor can be used for USB audio. When the co-processor > is working for USB audio, the co-processor is the user/owner of the USB > driver, and the ACPU is able to sleep in such condition to improve power > consumption. In original process, the ACPU will suspend/resume until the > USB suspend/resume. We add the hooks, so we can control USB suspend/resume > without affecting the ACPU. > > Signed-off-by: Puma Hsu <pumahsu@google.com> > --- > drivers/usb/core/Makefile | 2 +- > drivers/usb/core/driver.c | 36 ++++++++++++++++++++++++++++++++++++ > drivers/usb/core/usb.h | 5 +++++ > 3 files changed, 42 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/core/Makefile b/drivers/usb/core/Makefile > index 7d338e9c0657..f48f646cd874 100644 > --- a/drivers/usb/core/Makefile > +++ b/drivers/usb/core/Makefile > @@ -3,7 +3,7 @@ > # Makefile for USB Core files and filesystem > # > > -usbcore-y := usb.o hub.o hcd.o urb.o message.o driver.o > +usbcore-y := usb.o hub.o hcd.o urb.o message.o driver.o usb-hooks-impl-goog.o > usbcore-y += config.o file.o buffer.o sysfs.o endpoint.o > usbcore-y += devio.o notify.o generic.o quirks.o devices.o > usbcore-y += phy.o port.o Sorry I should not add usb-hooks-impl-goog to the makefile. I will upload a version2 > diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c > index 7e7e119c253f..3d2cfb6c2277 100644 > --- a/drivers/usb/core/driver.c > +++ b/drivers/usb/core/driver.c > @@ -35,6 +35,25 @@ > #include "usb.h" > > > +static struct usb_device_vendor_ops *usb_dev_vendor_ops; > + > +int usb_dev_register_vendor_ops(struct usb_device_vendor_ops *vendor_ops) > +{ > + if (vendor_ops == NULL) > + return -EINVAL; > + > + usb_dev_vendor_ops = vendor_ops; > + return 0; > +} > +EXPORT_SYMBOL_GPL(usb_dev_register_vendor_ops); > + > +struct usb_device_vendor_ops *usb_vendor_get_ops(void) > +{ > + return usb_dev_vendor_ops; > +} > +EXPORT_SYMBOL_GPL(usb_vendor_get_ops); > + > + > /* > * Adds a new dynamic USBdevice ID to this driver, > * and cause the driver to probe for all devices again. > @@ -1400,11 +1419,19 @@ static int usb_suspend_both(struct usb_device *udev, pm_message_t msg) > int status = 0; > int i = 0, n = 0; > struct usb_interface *intf; > + bool handled; > + struct usb_device_vendor_ops *ops = usb_vendor_get_ops(); > > if (udev->state == USB_STATE_NOTATTACHED || > udev->state == USB_STATE_SUSPENDED) > goto done; > > + if (ops && ops->usb_dev_suspend) { > + handled = ops->usb_dev_suspend(udev, msg); > + if (handled) > + goto done; > + } > + > /* Suspend all the interfaces and then udev itself */ > if (udev->actconfig) { > n = udev->actconfig->desc.bNumInterfaces; > @@ -1501,11 +1528,20 @@ static int usb_resume_both(struct usb_device *udev, pm_message_t msg) > int status = 0; > int i; > struct usb_interface *intf; > + bool handled; > + struct usb_device_vendor_ops *ops = usb_vendor_get_ops(); > > if (udev->state == USB_STATE_NOTATTACHED) { > status = -ENODEV; > goto done; > } > + > + if (ops && ops->usb_dev_resume) { > + handled = ops->usb_dev_resume(udev, msg); > + if (handled) > + goto done; > + } > + > udev->can_submit = 1; > > /* Resume the device */ > diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h > index 82538daac8b8..9ccb8683071d 100644 > --- a/drivers/usb/core/usb.h > +++ b/drivers/usb/core/usb.h > @@ -220,3 +220,8 @@ extern acpi_handle usb_get_hub_port_acpi_handle(struct usb_device *hdev, > static inline int usb_acpi_register(void) { return 0; }; > static inline void usb_acpi_unregister(void) { }; > #endif > + > +struct usb_device_vendor_ops { > + bool (*usb_dev_suspend)(struct usb_device *udev, pm_message_t msg); > + bool (*usb_dev_resume)(struct usb_device *udev, pm_message_t msg); > +}; > -- > 2.39.0.rc1.256.g54fd8350bd-goog >
No one gives a rats ass about the "vendor". If at all the implementation matters, and for that you better send along the implementation so that people can actually review this.
On Wed, Dec 14, 2022 at 03:06:49PM +0800, Puma Hsu wrote:
> Add the hooks that vendor can design and bypass the suspend/resume.
As Christoph said, there is no such thing in the kernel as a "vendor
hook". That is a Google-only thing that was created for their Android
kernel for various reasons.
For obvious reaons, we can not take the same type of thing here, as that
makes no sense at all (and neither do you want us to.)
As explained each time this patch set has been sent in over the years,
the full implementation of a new callback must be submitted with the
patch series, otherwise it HAS to be rejected. And again, you want this
rule in place, otherwise you would not even be able to use Linux for
your systems.
thanks,
greg k-h
Hi Puma, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on usb/usb-testing] [also build test WARNING on usb/usb-next usb/usb-linus linus/master v6.1 next-20221214] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Puma-Hsu/add-vendor-hooks-for-usb-suspend-and-resume/20221214-150942 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing patch link: https://lore.kernel.org/r/20221214070650.703793-2-pumahsu%40google.com patch subject: [PATCH 1/2] usb: core: add vendor hook for usb suspend and resume config: i386-randconfig-a002 compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/c37166c62c494c4e2b7ebbb0a920a47a41a4500a git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Puma-Hsu/add-vendor-hooks-for-usb-suspend-and-resume/20221214-150942 git checkout c37166c62c494c4e2b7ebbb0a920a47a41a4500a # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/usb/core/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): >> drivers/usb/core/driver.c:40:5: warning: no previous prototype for function 'usb_dev_register_vendor_ops' [-Wmissing-prototypes] int usb_dev_register_vendor_ops(struct usb_device_vendor_ops *vendor_ops) ^ drivers/usb/core/driver.c:40:1: note: declare 'static' if the function is not intended to be used outside of this translation unit int usb_dev_register_vendor_ops(struct usb_device_vendor_ops *vendor_ops) ^ static >> drivers/usb/core/driver.c:50:31: warning: no previous prototype for function 'usb_vendor_get_ops' [-Wmissing-prototypes] struct usb_device_vendor_ops *usb_vendor_get_ops(void) ^ drivers/usb/core/driver.c:50:1: note: declare 'static' if the function is not intended to be used outside of this translation unit struct usb_device_vendor_ops *usb_vendor_get_ops(void) ^ static 2 warnings generated. vim +/usb_dev_register_vendor_ops +40 drivers/usb/core/driver.c 39 > 40 int usb_dev_register_vendor_ops(struct usb_device_vendor_ops *vendor_ops) 41 { 42 if (vendor_ops == NULL) 43 return -EINVAL; 44 45 usb_dev_vendor_ops = vendor_ops; 46 return 0; 47 } 48 EXPORT_SYMBOL_GPL(usb_dev_register_vendor_ops); 49 > 50 struct usb_device_vendor_ops *usb_vendor_get_ops(void) 51 { 52 return usb_dev_vendor_ops; 53 } 54 EXPORT_SYMBOL_GPL(usb_vendor_get_ops); 55 56
Hi Puma, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on usb/usb-testing] [also build test WARNING on usb/usb-next usb/usb-linus linus/master v6.1 next-20221214] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Puma-Hsu/add-vendor-hooks-for-usb-suspend-and-resume/20221214-150942 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing patch link: https://lore.kernel.org/r/20221214070650.703793-2-pumahsu%40google.com patch subject: [PATCH 1/2] usb: core: add vendor hook for usb suspend and resume config: i386-randconfig-a001 compiler: gcc-11 (Debian 11.3.0-8) 11.3.0 reproduce (this is a W=1 build): # https://github.com/intel-lab-lkp/linux/commit/c37166c62c494c4e2b7ebbb0a920a47a41a4500a git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Puma-Hsu/add-vendor-hooks-for-usb-suspend-and-resume/20221214-150942 git checkout c37166c62c494c4e2b7ebbb0a920a47a41a4500a # save the config file mkdir build_dir && cp config build_dir/.config make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/usb/core/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): >> drivers/usb/core/driver.c:40:5: warning: no previous prototype for 'usb_dev_register_vendor_ops' [-Wmissing-prototypes] 40 | int usb_dev_register_vendor_ops(struct usb_device_vendor_ops *vendor_ops) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ >> drivers/usb/core/driver.c:50:31: warning: no previous prototype for 'usb_vendor_get_ops' [-Wmissing-prototypes] 50 | struct usb_device_vendor_ops *usb_vendor_get_ops(void) | ^~~~~~~~~~~~~~~~~~ vim +/usb_dev_register_vendor_ops +40 drivers/usb/core/driver.c 39 > 40 int usb_dev_register_vendor_ops(struct usb_device_vendor_ops *vendor_ops) 41 { 42 if (vendor_ops == NULL) 43 return -EINVAL; 44 45 usb_dev_vendor_ops = vendor_ops; 46 return 0; 47 } 48 EXPORT_SYMBOL_GPL(usb_dev_register_vendor_ops); 49 > 50 struct usb_device_vendor_ops *usb_vendor_get_ops(void) 51 { 52 return usb_dev_vendor_ops; 53 } 54 EXPORT_SYMBOL_GPL(usb_vendor_get_ops); 55 56
Hi Puma,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on usb/usb-testing]
[also build test ERROR on usb/usb-next usb/usb-linus linus/master v6.1 next-20221214]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Puma-Hsu/add-vendor-hooks-for-usb-suspend-and-resume/20221214-150942
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
patch link: https://lore.kernel.org/r/20221214070650.703793-2-pumahsu%40google.com
patch subject: [PATCH 1/2] usb: core: add vendor hook for usb suspend and resume
config: sh-allmodconfig
compiler: sh4-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/c37166c62c494c4e2b7ebbb0a920a47a41a4500a
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Puma-Hsu/add-vendor-hooks-for-usb-suspend-and-resume/20221214-150942
git checkout c37166c62c494c4e2b7ebbb0a920a47a41a4500a
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sh SHELL=/bin/bash drivers/usb/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
>> make[5]: *** No rule to make target 'drivers/usb/core/usb-hooks-impl-goog.o', needed by 'drivers/usb/core/usbcore.o'.
make[5]: Target 'drivers/usb/core/' not remade because of errors.
diff --git a/drivers/usb/core/Makefile b/drivers/usb/core/Makefile index 7d338e9c0657..f48f646cd874 100644 --- a/drivers/usb/core/Makefile +++ b/drivers/usb/core/Makefile @@ -3,7 +3,7 @@ # Makefile for USB Core files and filesystem # -usbcore-y := usb.o hub.o hcd.o urb.o message.o driver.o +usbcore-y := usb.o hub.o hcd.o urb.o message.o driver.o usb-hooks-impl-goog.o usbcore-y += config.o file.o buffer.o sysfs.o endpoint.o usbcore-y += devio.o notify.o generic.o quirks.o devices.o usbcore-y += phy.o port.o diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index 7e7e119c253f..3d2cfb6c2277 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c @@ -35,6 +35,25 @@ #include "usb.h" +static struct usb_device_vendor_ops *usb_dev_vendor_ops; + +int usb_dev_register_vendor_ops(struct usb_device_vendor_ops *vendor_ops) +{ + if (vendor_ops == NULL) + return -EINVAL; + + usb_dev_vendor_ops = vendor_ops; + return 0; +} +EXPORT_SYMBOL_GPL(usb_dev_register_vendor_ops); + +struct usb_device_vendor_ops *usb_vendor_get_ops(void) +{ + return usb_dev_vendor_ops; +} +EXPORT_SYMBOL_GPL(usb_vendor_get_ops); + + /* * Adds a new dynamic USBdevice ID to this driver, * and cause the driver to probe for all devices again. @@ -1400,11 +1419,19 @@ static int usb_suspend_both(struct usb_device *udev, pm_message_t msg) int status = 0; int i = 0, n = 0; struct usb_interface *intf; + bool handled; + struct usb_device_vendor_ops *ops = usb_vendor_get_ops(); if (udev->state == USB_STATE_NOTATTACHED || udev->state == USB_STATE_SUSPENDED) goto done; + if (ops && ops->usb_dev_suspend) { + handled = ops->usb_dev_suspend(udev, msg); + if (handled) + goto done; + } + /* Suspend all the interfaces and then udev itself */ if (udev->actconfig) { n = udev->actconfig->desc.bNumInterfaces; @@ -1501,11 +1528,20 @@ static int usb_resume_both(struct usb_device *udev, pm_message_t msg) int status = 0; int i; struct usb_interface *intf; + bool handled; + struct usb_device_vendor_ops *ops = usb_vendor_get_ops(); if (udev->state == USB_STATE_NOTATTACHED) { status = -ENODEV; goto done; } + + if (ops && ops->usb_dev_resume) { + handled = ops->usb_dev_resume(udev, msg); + if (handled) + goto done; + } + udev->can_submit = 1; /* Resume the device */ diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h index 82538daac8b8..9ccb8683071d 100644 --- a/drivers/usb/core/usb.h +++ b/drivers/usb/core/usb.h @@ -220,3 +220,8 @@ extern acpi_handle usb_get_hub_port_acpi_handle(struct usb_device *hdev, static inline int usb_acpi_register(void) { return 0; }; static inline void usb_acpi_unregister(void) { }; #endif + +struct usb_device_vendor_ops { + bool (*usb_dev_suspend)(struct usb_device *udev, pm_message_t msg); + bool (*usb_dev_resume)(struct usb_device *udev, pm_message_t msg); +};