Sony Xperia XA2 not charging

Hi.
Firstly, I would like to apologize if I shouldn’t post it here but it seems to me that it is the only place someone would help me.
So I installed Leap 15.0 on Saturday (26.05) on my HP Probook 450 G3. I did a fresh install including formatting /home partition. Only settings I copied from previous version were DBeaver, Firefox and Thunderbird.

So that’s it for opening. Now to my problem.

Ever since upgrading to Leap 15 my phone (Sony Xperia XA2 with USB-C) won’t charge when connected to laptop with few exceptions:

  • after connecting phone to laptop it is indicating that it is charging for 1-2 seconds, then it’s not indicating so
  • when I start Windows VM (on Virtualbox) and USB connection of my phone is redirected to that VM, it is charging
  • when I click “Run” in Android Studio and a window to choose phone on which I want to run my code shows, phone is charging (I don’t even have to choose that phone)
  • when I access my phone over MTP in Dolphin

Every other device I checked on my laptop (both microUSB and USB-C) are charging normally and also my phone is charging normally when connected to other laptops (with Windows 10).

Seems to me like some weird power saving. Any idea what can be wrong?

Every other device I checked on my laptop (both microUSB and USB-C) are charging normally and also my phone is charging normally when connected to other laptops (with Windows 10).

Strange that it is just impacting this device. Assuming that kernel power management is at play, it is possible to inhibit globally, or just for a particular device via a custom udev rule as explained here…
https://wiki.archlinux.org/index.php/Power_management#USB_autosuspend

The current value (in ms) can be viewed using…

cat /sys/module/usbcore/parameters/autosuspend

If desired, it can be inhibited by creating a custom config file (eg /etc/modprobe.d/usb-autosuspend.conf) with

options usbcore autosuspend=5
  • A negative value to disable power management completely.

Kernel power management for USB documentation:
https://www.kernel.org/doc/html/v4.12/driver-api/usb/power-management.html

I might be wrong but from a high level it seems to me a USB driver problem.

When you connect it to Windows VM, it’s the Windows driver that drives your device and the host OS is just a pass through. I think that’s the reason it is charging.
Similar is the case with Android studio. It may have it’s own drivers to deal with different Android phones.

So, please check your device Id and vendor Id and then see what driver module is driving your phone?

It is possible that the problem lies somewhere else and I might be looking else where.
You can have a look at the driver until you rule this out.

Turning off seems to help. I did

echo -1 > /sys/module/usbcore/parameters/autosuspend

and it fixed a problem till reboot. I don’t fully understand loading this configurations. First I did create a file like you said “/etc/modprobe.d/usb-autosuspend.conf” with

options usbcore autosuspend=-1

but it didn’t switch the autosuspend parameter. Then I tried to black list my phone from this autosuspend as mentioned in Arch wiki but it doesn’t seem to work either.

About shibaa’s post, here’s lsusb -v result for my phone (not sure if that’s what you wanted me to check):

Bus 001 Device 006: ID 0fce:51f7 Sony Ericsson Mobile Communications AB 
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x0fce Sony Ericsson Mobile Communications AB
  idProduct          0x51f7 
  bcdDevice            4.04
  iManufacturer           1 Sony
  iProduct                2 H3113
  iSerial                 3 CQ3000L1C5
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           62
    bNumInterfaces          2
    bConfigurationValue     1
    iConfiguration          4 mtp_adb
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              500mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           3
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass    255 Vendor Specific Subclass
      bInterfaceProtocol      0 
      iInterface              5 MTP
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x001c  1x 28 bytes
        bInterval               6
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass     66 
      bInterfaceProtocol      1 
      iInterface              6 ADB Interface
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
Device Qualifier (for other device speed):
  bLength                10
  bDescriptorType         6
  bcdUSB               2.00
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  bNumConfigurations      1
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x0000
  (Bus Powered)


Also, I just checked and found out that simply running adb usb while phone is connected “fixes” the problem. That’s probably what Android Studio is doing.

Instead, you could add the following kernel boot parameter to grub…

usbcore.autosuspend=-1

I tried this just now (temporarily adding to the grub options at boot), and then confirmed with…

# cat /sys/module/usbcore/parameters/autosuspend
-1

Yeah, adding this to boot parameters fixed it. I’m just wondering if disabling autosuspend wouldn’t impact on battery life (even with no devices connected to USB)? If so I would rather use a blacklist.

Only if you plan to leave USB devices connected (and then it would depend on their nominal current draw). However, it should be possible to blacklist particular devices. An easier way might be to instal TLP (power management utility), as all the configuration can be done via simple edits to /etc/default/tlp
https://linrunner.de/en/tlp/docs/tlp-configuration.html#usb

Well, I don’t understand it. I’ve set autosuspend back to default 2 seconds, added my phone to blacklist in TLP and still it doesn’t black list it.
I guess I will just leave autosuspend off.

Running tlp-stat and examining the USB-related output might be useful

sudo tlp-stat

Something like the following should be evident…

Bus 001 Device 006: ID 0fce:51f7 control = on

TLP started working after I’ve enabled Phone blacklist.