Hi Luiz -----Original Message----- From: Luiz Augusto von Dentz [mailto:luiz.dentz@xxxxxxxxx] Sent: Friday, September 11, 2015 9:36 PM To: Ge, Ethan Cc: linux-bluetooth@xxxxxxxxxxxxxxx; jeremy@xxxxxxxx; Marcel Holtmann Subject: Re: BLE(ATT) mouse doesn't register wakeup source in Linux kernel during BLE mouse connecting Hi Ethan, On Fri, Sep 11, 2015 at 1:12 PM, Ge, Ethan <ethan.ge@xxxxxxxxx> wrote: > Hi, > > In file drivers/hid/hid-input.c, function hidinput_setup_battery() will return during connect a BLE mouse because of filed->usage->hid != HID_DC_BATTERYSTRENGTH. And BLE(ATT) HID doesn't register wakeup source in Linux kernel. > > It will cause BLE HID mouse can't wake DUT from S3. Issue can be reproduced by IBUFFALO BSMBB09DS / Dell WM615 mouse / Microsoft arc touch, these all are BLE mouse. > > static bool hidinput_setup_battery(struct hid_device *dev, unsigned > report_type, struct hid_field *field) { > struct power_supply_desc *psy_desc = NULL; > struct power_supply_config psy_cfg = { .drv_data = dev, }; > unsigned quirks; > s32 min, max; > > if (field->usage->hid != HID_DC_BATTERYSTRENGTH) > return false; /* no match */ > But this is checked in case the device does not support battery strength support, I thought any input device would register a wakeup source regardless. > Luiz Augusto von Dentz I said that because I verified it by ftrace. I found if it return hidinput_setup_battery(), and input device can't register a wakeup source. Below are the code flow. hidinput_setup_battery->__power_supply_register-> device_init_wakeup. In other hand, the BR/EDR mouse can register a wakeup source because it won't return hidinput_setup_battery() and can go through next function. I am trying to check why BLE mouse usage->hid != HID_DC_BATTERYSTRENGTH and can not wakeup system in S3. static bool hidinput_setup_battery(struct hid_device *dev, unsigned report_type, struct hid_field *field) { struct power_supply_desc *psy_desc = NULL; struct power_supply_config psy_cfg = { .drv_data = dev, }; unsigned quirks; s32 min, max; if (field->usage->hid != HID_DC_BATTERYSTRENGTH) return false; /* no match */ ... dev->battery = power_supply_register(&dev->dev, psy_desc, &psy_cfg); .. } static struct power_supply *__must_check __power_supply_register(struct device *parent, const struct power_supply_desc *desc, const struct power_supply_config *cfg, bool ws) { .... spin_lock_init(&psy->changed_lock); rc = device_init_wakeup(dev, ws); if (rc) goto wakeup_init_failed; .... } int device_init_wakeup(struct device *dev, bool enable) { int ret = 0; if (!dev) return -EINVAL; if (enable) { device_set_wakeup_capable(dev, true); ret = device_wakeup_enable(dev); ... } Ethan -- ��.n��������+%������w��{.n�����{����^n�r������&��z�ޗ�zf���h���~����������_��+v���)ߣ�