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 */
Hi Luiz,
2015-09-13 20:26 GMT-07:00 Ge, Ethan <[email protected]>:
> Hi Luiz
>
> -----Original Message-----
> From: Luiz Augusto von Dentz [mailto:[email protected]]
> Sent: Friday, September 11, 2015 9:36 PM
> To: Ge, Ethan
> Cc: [email protected]; [email protected]; 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 <[email protected]> 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
> --
I want to correct my description in previous mail, this issue doesn't
cause from hidinput_setup_battery. And I found
/sys/bus/usb/devices/1-5/power/wakeup is enabled after BR/EDR HID
connected, but it's disabled after BLE HID connected. If I echo
enabled > /sys/bus/usb/devices/1-5/power/wakeup, and issue will
disappear. The wakeup value is configured from
wake_store->device_set_wakeup_enable(dev, 1) for BR/EDR HID case. I am
trying to figure out why BLE HID won't process it.
Ethan
SGkgTHVpeg0KDQotLS0tLU9yaWdpbmFsIE1lc3NhZ2UtLS0tLQ0KRnJvbTogTHVpeiBBdWd1c3Rv
IHZvbiBEZW50eiBbbWFpbHRvOmx1aXouZGVudHpAZ21haWwuY29tXSANClNlbnQ6IEZyaWRheSwg
U2VwdGVtYmVy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3N1cHBseV9kZXNjICpkZXNjLA0KICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0
cnVjdCBwb3dlcl9zdXBwbHlfY29uZmlnICpjZmcsDQogICAgICAgICAgICAgICAgICAgYm9vbCB3
cykNCnsNCiAuLi4uDQoNCiAgICBzcGluX2xvY2tfaW5pdCgmcHN5LT5jaGFuZ2VkX2xvY2spOw0K
ICAgIHJjID0gZGV2aWNlX2luaXRfd2FrZXVwKGRldiwgd3MpOw0KICAgIGlmIChyYykNCiAgICAg
ICAgZ290byB3YWtldXBfaW5pdF9mYWlsZWQ7DQouLi4uDQp9DQoNCmludCBkZXZpY2VfaW5pdF93
YWtldXAoc3RydWN0IGRldmljZSAqZGV2LCBib29sIGVuYWJsZSkNCnsNCiAgICBpbnQgcmV0ID0g
MDsNCg0KICAgIGlmICghZGV2KQ0KICAgICAgICByZXR1cm4gLUVJTlZBTDsNCg0KICAgIGlmIChl
bmFibGUpIHsNCiAgICAgICAgZGV2aWNlX3NldF93YWtldXBfY2FwYWJsZShkZXYsIHRydWUpOw0K
ICAgICAgICByZXQgPSBkZXZpY2Vfd2FrZXVwX2VuYWJsZShkZXYpOw0KLi4uDQp9DQpFdGhhbg0K
LS0NCg==
Hi Ethan,
On Fri, Sep 11, 2015 at 1:12 PM, Ge, Ethan <[email protected]> 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