"Could not set interface wlan0 flags (UP): Input/output error" RT3290

I've encountered a very puzzling issue with my WiFi card on Ubuntu. After reboot it's always disabled and there is no way to bring it back other than suspending or shutting down the laptop. Status according to Network Manager is "device not ready". This occurs consistently.

Some background on my system:

  • The laptop is HP 350 G1.
  • The WLAN card is the infamous Ralink RT3290. (If I knew how much trouble I would have with it I would never have bought it).
  • Ubuntu is the latest LTS 16.04, recently upgraded.
  • Kernel is 4.4.9-040409-generic (was 4.4.0-22-generic before upgrading from mainline - no difference wrt WiFi).

Before upgrading the distro, I was using a version of the rt3290sta/2.6.0.0 driver (compiled from source and loaded via DKMS) which performed mostly fine, but it doesn't work with the newer kernels and it seems abandoned anyway. So now I had to revert to rt2800 and have this problem since.

This seems to be a very old but recurring issue. I read through all threads I could find, but so far no luck. Fortunately it's not critical for me because I rarely reboot, but it's still annoying and vexing at the least.

Below are outputs of some commands that could be of interest (this is the state after reboot):

lshw -c network says the interface is disabled:

# lshw -c network
*-network               
       description: Ethernet interface
       product: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
       vendor: Realtek Semiconductor Co., Ltd.
       physical id: 0
       bus info: pci@0000:01:00.0
       logical name: eth0
       version: 10
       serial: c4:34:6b:05:5f:ff
       size: 10Mbit/s
       capacity: 1Gbit/s
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress msix vpd bus_master cap_list ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd 1000bt 1000bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=r8169 driverversion=2.3LK-NAPI duplex=half firmware=rtl8168g-3_0.0.1 04/23/13 latency=0 link=no multicast=yes port=MII speed=10Mbit/s
       resources: irq:43 ioport:4000(size=256) memory:b2504000-b2504fff memory:b2500000-b2503fff
  *-network DISABLED
       description: Wireless interface
       product: RT3290 Wireless 802.11n 1T/1R PCIe
       vendor: Ralink corp.
       physical id: 0
       bus info: pci@0000:02:00.0
       logical name: wlan0
       version: 00
       serial: 00:71:cc:6b:fe:f1
       width: 32 bits
       clock: 33MHz
       capabilities: pm msi pciexpress bus_master cap_list ethernet physical wireless
       configuration: broadcast=yes driver=rt2800pci driverversion=4.4.9-040409-generic firmware=0.37 latency=0 link=no multicast=yes wireless=IEEE 802.11bgn
       resources: irq:17 memory:b2410000-b241ffff
  *-network DISABLED
       description: Ethernet interface
       physical id: 1
       logical name: virbr0-nic
       serial: 52:54:00:e5:13:31
       size: 10Mbit/s
       capabilities: ethernet physical
       configuration: autonegotiation=off broadcast=yes driver=tun driverversion=1.6 duplex=full link=no multicast=yes port=twisted pair speed=10Mbit/s

However, rfkill list does not agree:

# rfkill list
0: phy0: Wireless LAN
        Soft blocked: no
        Hard blocked: no
# iwconfig 
virbr0-nic  no wireless extensions.

eth0      no wireless extensions.

wlan0     IEEE 802.11bgn  ESSID:off/any  
          Mode:Managed  Access Point: Not-Associated   Tx-Power=0 dBm   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:off

virbr0    no wireless extensions.

lo        no wireless extensions.

We can't bring it up though:

# ifconfig wlan0 up
SIOCSIFFLAGS: Input/output error

dmesg shows a couple of these errors:

# dmesg
...
[   27.648857] ieee80211 phy0: rt2800_wait_wpdma_ready: Error - WPDMA TX/RX busy [0x00000068]
[   29.248929] ieee80211 phy0: rt2800_wait_wpdma_ready: Error - WPDMA TX/RX busy [0x00000068]
[   29.248936] ieee80211 phy0: rt2800pci_set_device_state: Error - Device failed to enter state 4 (-5)
...

Finally, part of syslog that looks relevant to me:

# cat /var/log/syslog | grep -i wlan
...
May 10 22:09:25 hp350g1 NetworkManager[820]:   [1462910965.2639] devices added (path: /sys/devices/pci0000:00/0000:00:1c.1/0000:02:00.0/net/wlan0, iface: wlan0)
May 10 22:09:25 hp350g1 NetworkManager[820]:   [1462910965.2639] device added (path: /sys/devices/pci0000:00/0000:00:1c.1/0000:02:00.0/net/wlan0, iface: wlan0): no ifupdown configuration found.
May 10 22:09:25 hp350g1 NetworkManager[820]:   [1462910965.6626] (wlan0): using nl80211 for WiFi device control
May 10 22:09:25 hp350g1 NetworkManager[820]:   [1462910965.6645] device (wlan0): driver supports Access Point (AP) mode
May 10 22:09:25 hp350g1 NetworkManager[820]:   [1462910965.6813] manager: (wlan0): new 802.11 WiFi device (/org/freedesktop/NetworkManager/Devices/0)
May 10 22:09:25 hp350g1 NetworkManager[820]:   [1462910965.6882] device (wlan0): state change: unmanaged -> unavailable (reason 'managed') [10 20 2]
May 10 22:09:25 hp350g1 kernel: [    5.704724] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
May 10 22:09:29 hp350g1 NetworkManager[820]:   [1462910969.0227] device (wlan0): supplicant interface state: init -> starting
May 10 22:09:32 hp350g1 wpa_supplicant[1339]: Could not set interface wlan0 flags (UP): Input/output error
May 10 22:09:32 hp350g1 wpa_supplicant[1339]: nl80211: Could not set interface 'wlan0' UP
May 10 22:09:32 hp350g1 wpa_supplicant[1339]: nl80211: deinit ifname=wlan0 disabled_11b_rates=0
May 10 22:09:35 hp350g1 wpa_supplicant[1339]: Could not set interface wlan0 flags (UP): Input/output error
May 10 22:09:35 hp350g1 wpa_supplicant[1339]: WEXT: Could not set interface 'wlan0' UP
May 10 22:09:35 hp350g1 wpa_supplicant[1339]: wlan0: Failed to initialize driver interface
May 10 22:09:35 hp350g1 NetworkManager[820]:  [1462910975.4904] sup-iface[0x2450570,wlan0]: error adding interface: wpa_supplicant couldn't grab this interface.
May 10 22:09:35 hp350g1 NetworkManager[820]:   [1462910975.4904] device (wlan0): supplicant interface state: starting -> down
May 10 22:09:46 hp350g1 NetworkManager[820]:   [1462910986.0143] device (wlan0): re-acquiring supplicant interface (#1).
May 10 22:09:49 hp350g1 wpa_supplicant[1339]: Could not set interface wlan0 flags (UP): Input/output error
May 10 22:09:49 hp350g1 wpa_supplicant[1339]: nl80211: Could not set interface 'wlan0' UP
May 10 22:09:49 hp350g1 wpa_supplicant[1339]: nl80211: deinit ifname=wlan0 disabled_11b_rates=0
May 10 22:09:52 hp350g1 wpa_supplicant[1339]: Could not set interface wlan0 flags (UP): Input/output error
May 10 22:09:52 hp350g1 wpa_supplicant[1339]: WEXT: Could not set interface 'wlan0' UP
May 10 22:09:52 hp350g1 wpa_supplicant[1339]: wlan0: Failed to initialize driver interface
May 10 22:09:52 hp350g1 NetworkManager[820]:  [1462910992.4485] sup-iface[0x24506d0,wlan0]: error adding interface: wpa_supplicant couldn't grab this interface.

... (after couple more tries)

May 10 22:11:00 hp350g1 NetworkManager[820]: [1462911060.4668] device (wlan0): supplicant interface state: starting -> down May 10 22:11:00 hp350g1 NetworkManager[820]: [1462911060.4669] device (wlan0): supplicant interface keeps failing, giving up


The driver rt2800pci needs to unload firmware from the device which persists during reboot. In Ubuntu 16.04 before you reboot you need to execute following command:

sudo rmmod rt2800pci

then reboot.

In order to automate the task for the reboot create a shell script in /etc/init.d/rt3290removedriver with following content:

#!/bin/sh
### BEGIN INIT INFO
# Provides:          skeleton
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Example initscript
# Description:       This file should be used to construct scripts to be
#                    placed in /etc/init.d.  This example start a
#                    single forking daemon capable of writing a pid
#                    file.  To get other behavoirs, implemend
#                    do_start(), do_stop() or other functions to
#                    override the defaults in /lib/init/init-d-script.
### END INIT INFO

# /etc/init.d/rt3290removedriver

case "$1" in
   start)
       echo "Removal of driver rt2800pci success" > /home/youruser/rt2800pci.txt
       echo "Power Down" 
   ;;
   stop)
       rmmod rt2800pci
       echo "Removal of driver rt2800pci success" > /home/youruser/rt2800pci.txt
       echo "Power Down"
       exit 1
   ;;
   *)
       rmmod rt2800pci
       echo "Removal of driver rt2800pci success" > /home/youruser/rt2800pci.txt
       echo "Power Down"
       exit 1
   ;;
esac
exit 0

Then update scripts with command

sudo update-rc.d rt3290removedriver defaults

And you are done. Replace youruser in the script with your user name. Tested on a HP Pavilion with Ubuntu 16.04 and rt3290 wifi pci card.