Laptops inbuild sc card reader not working

Im having Thinkpad L14, which has a sd card reader slot.
And when i insert a sd card it dosent work out of the box.
Also when i tried dmesg nothing over the output stating something similar to it. And lsusb command was not found.
Tried to install as given over another OP, getting weird error

Any help please.

What does “not work” mean in this context? Does your DE not automatically bring up a mount button on your desktop, are you attempting to mount manually and it fails, or does the device not show up in the kernel?

You’ll have to install usbutils for that:

# Somewhere in /etc/configuration.nix
environment.systemPackages = with pkgs; [
  usbutils
];

lsblk is pre-installed and should help you find device names for manual mounting, too.

Your nixos channel is missing - that probably means you’ve explicitly deleted it for some reason. You won’t be able to rebuild your system or install anything either. You’re on an outdated NixOS release (and a way outdated home-manager one as well), so for now add back the outdated 23.11 channel:

sudo nix-channel --add https://channels.nixos.org/nixos-23.11 nixos
sudo nix-channel --update

That should allow you to run that command, and build your configuration again.


Once you’ve got your channel back and can build configs again, consider upgrading to NixOS 24.05. You should read the release notes, and then run:

sudo nix-channel --add https://channels.nixos.org/nixos-24.05 nixos
sudo nix-channel --update

After that update any configuration mentioned in the release notes, rebuild with nixos-rebuild boot --use-remote-sudo and reboot.

Should your system not boot properly, remember that you can go back to an old generation using the grub/systemd-boot menu.

Also update your home-manager config, since you’re running it standalone you have to do that manually. This might be more painful since you’ve missed at least a full year of updates, but the commands are:

nix-channel --add https://github.com/nix-community/home-manager/archive/release-24.05.tar.gz home-manager
nix-channel --update
home-manager switch
1 Like

On my T14 the SD card is totally unacknowledged until I run lspci. :person_shrugging:

you mean Desktop Environment ?!, If it is, then yes, it doesn’t bring up the mount button automatically in the files and folder window manager.

No, Im still a beginner and haven’t gone to this level yet.

When i installed nixos, it was on 23.05. Later i installed flakes and then got it updated to 23.11 by changing the flakes input nixpkgs.url = "nixpkgs/nixos-23.05"; to nixpkgs.url = "nixpkgs/nixos-23.11"; (which is my current state). I thought flakes takes care of channels automatically.

This is my channels list currently,

❯ nix-channel --list
home-manager https://github.com/nix-community/home-manager/archive/release-23.05.tar.gz

but i have this line in my flakes input,

inputs = {
    nixpkgs.url = "nixpkgs/nixos-23.11";
    nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
};

so by definition, this should take care of adding the channels right ? Should i still need to do nix-channel -add ....-23.11 before updating to 24.05?

Do you mean nixos-rebuild commands ? If it is, then i am able to currently run them(i mean it dosent throws any error), but when i tried to install usbutils through configuration.nix and rebuild the system, it says command not found

To update from 23.11 to 24.05 correct me if im wrong, i should be changing the input of flakes like below, should i still add the channels using channel --add & --update . right ?!

inputs = {
-   nixpkgs.url = "nixpkgs/nixos-23.11";
+   nixpkgs.url = "nixpkgs/nixos-24.05";
    nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
};

And im not getting this point from the release notes of 24.05.

On flake-based NixOS configurations using nixpkgs.lib.nixosSystem, NixOS will automatically set NIX_PATH and the system-wide flake registry (/etc/nix/registry.json) to point <nixpkgs> and the unqualified flake path nixpkgs to the version of nixpkgs used to build the system.

dose that mean, anything under this nixpkgs.lib.nixosSystem should be changed in the flake.nix file?
This is my flake.nix,

......
let
    lib = nixpkgs.lib;
in {
 nixosConfigurations = {
      system = lib.nixosSystem {
        system = systemSettings.system;
        modules = [
          ./configuration.nix
          home-manager.nixosModules.home-manager
            {
                home-manager.users.${userSettings.username} = import ./home.nix;
                home-manager.extraSpecialArgs = { inherit systemSettings userSettings pkgs-unstable; };
            }
          ];
        specialArgs = {
          inherit systemSettings;
          inherit userSettings;
          inherit pkgs-unstable;
        };
      };
    };
  };
};

Ah, I see, that explains the missing channel. All the channel stuff I was talking about is irrelevant then, but since you don’t have a nixos channel, the nix-shell command cannot work. You’d need to use nix run if you wanted to run the command suggested in the other post:

nix run nixpkgs#nix-info -- -m

No, flakes replace the concept of channels completely. Since 24.05 NixOS comes with a module to put your nixpkgs input in NIX_PATH so you can run nix-shell & co., but 23.11 doesn’t have that yet. That’s what this paragraph tries to explain:

In addition, you could delete that home-manager channel from your user channels, just to avoid anything accidentally referring to it:

nix-channel --remove home-manager

Nah, instead, just change the url in your inputs like you said. But for the record, I don’t think updating will fix this issue (even though that will probably come with a kernel update which might, I just think it’s unlikely).

Gotcha. Which DE are you using? What setting did you enable? Does just enabling udisks help?

Also give updating the firmware with fwupd a go:

fwupdmgr update

If that does not help, we’ll have to do a bit more sleuthing. With the SD card inserted, try these commands:

$ nix shell nixpkgs#usbutils nixpkgs#pciutils
$ lsusb
$ lspci -v
$ lsblk

If you used nixos-rebuild boot instead of switch, you’ll have to reboot before the command is in scope. If that’s not the problem, not sure where that went wrong, but hence I suggest the nix shell command to just ensure it’s properly in your shell for the above commands.

2 Likes

okay.

In that case , i will try to update the system may be after fixing the sd card reader issue.

but im not getting this, removing home-manager part ? You mean, for me to avoid conflict of using flakes and manual channel --add --remove, just in case ?

And based on this statement, i presume that there is no mistakes/something wrong in my .nix files.

im using plasma 5 for now,

 services.xserver.enable = true;

 services.xserver.displayManager.sddm.enable = true;
 services.xserver.desktopManager.plasma5.enable = true;

 services.xserver = {
    layout = "us";
    xkbVariant = "";
  };

also,

i gave switch, even after reboot the command is not available.

i added services.udisks2.enable = true; to my configuration.nix, It didn’t help.

I first added services.fwupd.enable = true; to my configuration.nix and then gave then the fwupdmgr update. Initially, after the switch it said no updates available, but after reboot im getting the below output. Im bit concerned the moment i saw “Microsoft Boot manager” & “black lotus” (The machine im running is strictly “NixOS” alone, then why is it saying as microsoft boot manager, that was the actual concern). Should i continue installing this ?

❯ fwupdmgr update
Devices with no available firmware updates: 
 • UEFI Device Firmware
 • UEFI Device Firmware
 • UEFI Device Firmware
 • UEFI Device Firmware
 • UEFI Device Firmware
 • UEFI Device Firmware
 • UEFI Device Firmware
 • UEFI Device Firmware
 • ELAN067F:00 04F3:3209
 • Fingerprint Sensor
╔══════════════════════════════════════════════════════════════════════════════╗
║ Upgrade UEFI dbx from 267 to 371?                                            ║
╠══════════════════════════════════════════════════════════════════════════════╣
║ Insecure versions of the Microsoft Windows boot manager affected by Black    ║
║ Lotus were added to the list of forbidden signatures due to a discovered     ║
║ security problem.This updates the dbx to the latest release from Microsoft.  ║
║                                                                              ║
║ Before installing the update, fwupd will check for any affected executables  ║
║ in the ESP and will refuse to update if it finds any boot binaries signed    ║
║ with any of the forbidden signatures.Applying this update may also cause     ║
║ some Windows install media to not start correctly.                           ║
║                                                                              ║
╚══════════════════════════════════════════════════════════════════════════════╝
Perform operation? [Y|n]: 

Yeah, this is a secure boot issue. Even if you’re only running Linux, your laptop comes with Windows boot loader signatures pre-installed, and this firmware update blacklists some of those signatures since your computer should be prevented from booting insecure windows boot loaders with those signatures - even if you never actually plan on booting them.

This does not help you at all if you do not use secure boot, but the firmware update shouldn’t do anything negative either, and there will be other important updates in there.

Interesting - that means part of your configuration is being ignored, which might mean you’re not actually importing it or such. What did the commands run with nix shell show, if anything? Can you share the rest of your config?

Very sorry for the late response. I was sick and couldn’t try anything these many days.

Got it, I have installed them.

Now it works. all the 3 commands are with the sd card inserted.

❯ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 0489:e0d8 Foxconn / Hon Hai Bluetooth Adapter
Bus 001 Device 003: ID 27c6:6594 Shenzhen Goodix Technology Co.,Ltd. Goodix USB2.0 MISC
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 002: ID 05e3:0610 Genesys Logic, Inc. Hub
Bus 003 Device 003: ID 5986:2148 Bison Electronics Inc. Integrated Camera
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
❯ lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
mmcblk0     179:0    0  59.6G  0 disk 
├─mmcblk0p1 179:1    0   512M  0 part /run/media/arvindh/bootfs
└─mmcblk0p2 179:2    0   2.1G  0 part /run/media/arvindh/rootfs
nvme0n1     259:0    0 953.9G  0 disk 
├─nvme0n1p1 259:1    0   512M  0 part /boot
├─nvme0n1p2 259:2    0 920.2G  0 part /nix/store
│                                     /
└─nvme0n1p3 259:3    0  33.2G  0 part [SWAP]
❯ lspci -v
.
.
.
04:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. RTS522A PCI Express Card Reader (rev 01)
        Subsystem: Lenovo Device 50bf
        Flags: bus master, fast devsel, latency 0, IRQ 41, IOMMU group 12
        Memory at fd500000 (32-bit, non-prefetchable) [size=4K]
        Capabilities: <access denied>
        Kernel driver in use: rtsx_pci
        Kernel modules: rtsx_pci
.
.
.

it works now. But i have a question. Is the above one RTS522A PCI Express Card Reader my card reader. It says capability access denied!. And i noticed some thing weird too. The outputs are from from the first attempt of nix shell. I had a doubt in the command execution and got pulled up buy some other activity. Later i had to turn my machine off and when i tried after i turned it on, lsusb worked, but lsblk and lspci was showing as command not found. So i did the nix shell again and even after i was not showing immediately. I was removing and inserting the sd card multiple times and then both lsblk and lspci worked, later there was a popup asking “what to do for mounting” option.

So do i need to do the nixshell each time before running the lscpi and lsblk ?

1 Like

Well, nix shell creates a temporary environment where those commands are present. If you want them to be installed permanently, you need to figure out what’s wrong with your configuration that makes you unable to install packages.

If you want help with that, it’s probably worth starting a new thread for, in which you share your config, ideally. It sounds like the SD card reader issue was resolved with the firmware update.

1 Like

Does that mean, each time it will download them freshly or nix shell will place them in store somewhere and use it from there each time ?

Actually, here are my nix files. This was the earlier issue i was having and till date there is no changes other than what i tried to add in this OP under configuration.nix

  # ----trying to see is DBus service allows application to query
  services.udisks2.enable = true;
  services.fwupd.enable = true;
environment.systemPackages = with pkgs; [
  usbutils      # though its inside the configuration.nix now, command is not found still
];

should i still create a new thread ?

:astonished:Yes, im noticing it now. SD card doesn’t pop up automatically. After inserting, and only when i give lspci (after few seconds of inserting the sd card) i shows the popup notification asking for action

Not quite; they stay in the store forever, but they will only be added to your PATH environment variable when you run that command. If you run nix-collect-garbage, they will be removed, and redownloaded next time you use nix shell on them.

This is a pretty useful feature when you want to use a command you don’t necessarily want to have permanently installed, but yeah, not what you want in this case.

Did you add that in addition to the other environment.systemPackages definition? What are the exact commands you run when you change your system, and where are the configuration files stored?

Interesting! Can you get us your dmesg logs after you go through this after a fresh reboot? We should at the very least be able to make a udev rule that does the same thing.

i was knowing the above part, but not this collect-garbage` part till now. Understood.

Yes, I initially inserted usbutils in btw the list of other environment.systemPackages. And now this is my actual pkgs.

  environment.systemPackages =
  ( with pkgs; [
    # list of unstable packages
    vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
    wget
    neofetch
    libreoffice
    unzip
    unrar
    usbutils
    curl
    gittyup
    jre_minimal
    home-manager
    # nix helpers
    nix-output-monitor
    nvd
    # Media
    vlc
    gimp
    gaphor
  ])
  ++
  ( with pkgs-unstable; [
    # list of unstable packages
    # nix helpers
    nh
  ]);

I initially do nix flake update. Then i give sudo nixos-rebuild switch --flake .#system.
currently i keep all my dot files under ~/.dotfiles. And i usually go inside the folder and then execute the flake update and os-rebuild command.

Here are the exact steps i followed after a reboot. I gave the dmesg and got the following output.

The discource says message content to is too long or big. Please let me know how to send the dmseg output please.

By this time lspci was not found, so i had to do nix-shell again and then try lscpi.
After installing through nix-shell, SD card dint appear automatically. until lspci was given.
Once issuing lspci i was ablet to see the sd card mounted. And i gave dmesg once the SD card was visible. The below are the difference lines in the output with of dmesg before nix-shell install/sd card being visible and after nix-shell install/sd card being visible.

[ 1610.597513] mmc0: cannot verify signal voltage switch
[ 1610.705425] mmc0: new ultra high speed SDR50 SDHC card at address 0001
[ 1610.731890] mmcblk0: mmc0:0001 00000 29.8 GiB 
[ 1610.777476]  mmcblk0: p1

Well, there’s your issue, there’s no pciutils in that list. usbutils provides lsusb, but not lspci.


I found this thread on stackexchange, which matches your symptoms closely. Looks like the underlying issue is probably a quirk of power management with certain SD card readers - probably something like certain sd card readers need to be polled, but the kernel assumes something else nowadays.

That post also suggests a set of udev rules to enable polling all removable media devices, which likely solves the issue:

services.udev.packages = let
  # Avoiding `extraRules` here in case we want to upstream this
  sd-card-polling = pkgs.writeTextFile {
    name = "sd-card-polling-udev-rule";
    text = ''
      # enable in-kernel media-presence polling
      ACTION=="add", SUBSYSTEM=="module", KERNEL=="block", ATTR{parameters/events_dfl_poll_msecs}=="0", ATTR{parameters/events_dfl_poll_msecs}="2000"
      ACTION=="add", ATTR{removable}=="1", ATTR{events_poll_msecs}=="-1", ATTR{events_poll_msecs}="2000"
    '';
    destination = "/etc/udev/rules.d/22-sd-card-polling.rules";
  };
in [
  sd-card-polling
];

I’d assume this comes at a bit of a battery usage penalty. We could probably narrow this down to your specific reader to save some power if you use udevadm monitor to figure out your card reader’s exact attributes. This is conjectue, no idea how the polling feature actually works, but it’s at least nice to limit turning it on to when this card reader is working.

If you do that, we could write a more specific rule and then upstream it to nixos-hardware.

2 Likes

How silly of me. Thanks for letting me know,.

Im in :smiley: :+1:

when i gave udevadm monitor(i inserted my sd card and then the udevadm monitor started giving output only after lspci cmd), this was my output

❯ udevadm monitor
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent

KERNEL[7797.550182] add      /devices/pci0000:00/0000:00:02.4/0000:04:00.0/rtsx_pci_sdmmc.0/mmc_host/mmc0/mmc0:0001 (mmc)
KERNEL[7797.599702] add      /bus/mmc_rpmb (bus)
KERNEL[7797.601161] add      /devices/virtual/bdi/179:0 (bdi)
UDEV  [7797.602914] add      /bus/mmc_rpmb (bus)
UDEV  [7797.604077] add      /devices/virtual/bdi/179:0 (bdi)
KERNEL[7797.610399] add      /devices/pci0000:00/0000:00:02.4/0000:04:00.0/rtsx_pci_sdmmc.0/mmc_host/mmc0/mmc0:0001/block/mmcblk0 (block)
KERNEL[7797.610477] add      /devices/pci0000:00/0000:00:02.4/0000:04:00.0/rtsx_pci_sdmmc.0/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p1 (block)
KERNEL[7797.610546] bind     /devices/pci0000:00/0000:00:02.4/0000:04:00.0/rtsx_pci_sdmmc.0/mmc_host/mmc0/mmc0:0001 (mmc)
KERNEL[7797.610602] add      /bus/mmc/drivers/mmcblk (drivers)
KERNEL[7797.610651] add      /module/mmc_block (module)
UDEV  [7797.610713] add      /devices/pci0000:00/0000:00:02.4/0000:04:00.0/rtsx_pci_sdmmc.0/mmc_host/mmc0/mmc0:0001 (mmc)
UDEV  [7797.613133] add      /module/mmc_block (module)
UDEV  [7797.613395] add      /bus/mmc/drivers/mmcblk (drivers)
UDEV  [7797.643751] add      /devices/pci0000:00/0000:00:02.4/0000:04:00.0/rtsx_pci_sdmmc.0/mmc_host/mmc0/mmc0:0001/block/mmcblk0 (block)
UDEV  [7797.687550] add      /devices/pci0000:00/0000:00:02.4/0000:04:00.0/rtsx_pci_sdmmc.0/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p1 (block)
UDEV  [7797.688795] bind     /devices/pci0000:00/0000:00:02.4/0000:04:00.0/rtsx_pci_sdmmc.0/mmc_host/mmc0/mmc0:0001 (mmc)

Note:
- I have updated nixos from 23.11 to 24.05
- I haven’t tried the polling of all media devices to be enabled, as im bit concerned about the battery usage.
- I just noticed the topic title has a typo. instead of SD card i have typed sc card. Any way the tile could be changed ?!

Hi, Should i start a separate thread regarding writing rule and upstreaming to nixos-hardware. If so should i create one under the Help section or something else.

Sorry, just forgot about this thread.

I’d also like to get a look at the attrs of your device:

udevadm info -ap /devices/pci0000:00/0000:00:02.4/0000:04:00.0/rtsx_pci_sdmmc.0/mmc_host/mmc0/mmc0:0001
# Looks like the kernel treats this as a separate device?
udevadm info -ap /devices/pci0000:00/0000:00:02.4/0000:04:00.0/rtsx_pci_sdmmc.0/mmc_host/mmc0/mmc0:0001/block/mmcblk0

No problem, im sorry that i take a day or two to respond for each try/suggestions you give me. I get to access my personal machine less often due to toxic work culture :frowning_face:

I tried the same command and realized that the number after the device changes ../mmc0:0001.
so started the udevadm monitor again

❯ udevadm monitor
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent

KERNEL[741.108908] change   /devices/pci0000:00/0000:00:02.4/0000:04:00.0/rtsx_pci_sdmmc.0/mmc_host/mmc0/mmc0:0007/block/mmcblk0/mmcblk0p1 (block)
UDEV  [741.233207] change   /devices/pci0000:00/0000:00:02.4/0000:04:00.0/rtsx_pci_sdmmc.0/mmc_host/mmc0/mmc0:0007/block/mmcblk0/mmcblk0p1 (block)
KERNEL[748.346798] change   /devices/pci0000:00/0000:00:02.4/0000:04:00.0/rtsx_pci_sdmmc.0/mmc_host/mmc0/mmc0:0007/block/mmcblk0/mmcblk0p1 (block)
UDEV  [748.476434] change   /devices/pci0000:00/0000:00:02.4/0000:04:00.0/rtsx_pci_sdmmc.0/mmc_host/mmc0/mmc0:0007/block/mmcblk0/mmcblk0p1 (block)
KERNEL[748.511367] remove   /devices/pci0000:00/0000:00:02.4/0000:04:00.0/rtsx_pci_sdmmc.0/mmc_host/mmc0/mmc0:0007/block/mmcblk0/mmcblk0p1 (block)
KERNEL[748.512401] change   /devices/pci0000:00/0000:00:02.4/0000:04:00.0/rtsx_pci_sdmmc.0/mmc_host/mmc0/mmc0:0007/block/mmcblk0 (block)
KERNEL[748.512580] add      /devices/pci0000:00/0000:00:02.4/0000:04:00.0/rtsx_pci_sdmmc.0/mmc_host/mmc0/mmc0:0007/block/mmcblk0/mmcblk0p1 (block)
UDEV  [748.517794] remove   /devices/pci0000:00/0000:00:02.4/0000:04:00.0/rtsx_pci_sdmmc.0/mmc_host/mmc0/mmc0:0007/block/mmcblk0/mmcblk0p1 (block)
UDEV  [748.565433] change   /devices/pci0000:00/0000:00:02.4/0000:04:00.0/rtsx_pci_sdmmc.0/mmc_host/mmc0/mmc0:0007/block/mmcblk0 (block)
UDEV  [748.671078] add      /devices/pci0000:00/0000:00:02.4/0000:04:00.0/rtsx_pci_sdmmc.0/mmc_host/mmc0/mmc0:0007/block/mmcblk0/mmcblk0p1 (block)
^C%

then found that the number behind the device was /devices/pci0000:00/0000:00:02.4/0000:04:00.0/rtsx_pci_sdmmc.0/mmc_host/mmc0/mmc0:0007
so,

❯ udevadm info -ap /devices/pci0000:00/0000:00:02.4/0000:04:00.0/rtsx_pci_sdmmc.0/mmc_host/mmc0/mmc0:0007
  looking at device '/devices/pci0000:00/0000:00:02.4/0000:04:00.0/rtsx_pci_sdmmc.0/mmc_host/mmc0/mmc0:0007':
    KERNEL=="mmc0:0007"
    SUBSYSTEM=="mmc"
    DRIVER=="mmcblk"
    ATTR{cid}=="114499534431323820a70001f6008201"
    ATTR{csd}=="002e00325f5980f0ffff7f818a400001"
    ATTR{date}=="02/2008"
    ATTR{dsr}=="0x404"
    ATTR{erase_size}=="512"
    ATTR{fwrev}=="0x0"
    ATTR{hwrev}=="0x2"
    ATTR{manfid}=="0x000011"
    ATTR{name}=="SD128"
    ATTR{ocr}=="0x00300000"
    ATTR{oemid}=="0x4499"
    ATTR{power/async}=="enabled"
    ATTR{power/autosuspend_delay_ms}=="3000"
    ATTR{power/control}=="auto"
    ATTR{power/runtime_active_kids}=="0"
    ATTR{power/runtime_active_time}=="18826"
    ATTR{power/runtime_enabled}=="enabled"
    ATTR{power/runtime_status}=="suspended"
    ATTR{power/runtime_suspended_time}=="674085"
    ATTR{power/runtime_usage}=="0"
    ATTR{preferred_erase_size}=="1048576"
    ATTR{rca}=="0x0007"
    ATTR{removable}=="removable"
    ATTR{scr}=="0225000001000000"
    ATTR{serial}=="0xa70001f6"
    ATTR{ssr}=="000000000000000a020270000c060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
    ATTR{type}=="SD"

  looking at parent device '/devices/pci0000:00/0000:00:02.4/0000:04:00.0/rtsx_pci_sdmmc.0/mmc_host/mmc0':
    KERNELS=="mmc0"
    SUBSYSTEMS=="mmc_host"
    DRIVERS==""
    ATTRS{power/async}=="enabled"
    ATTRS{power/control}=="auto"
    ATTRS{power/runtime_active_kids}=="0"
    ATTRS{power/runtime_active_time}=="0"
    ATTRS{power/runtime_enabled}=="disabled"
    ATTRS{power/runtime_status}=="unsupported"
    ATTRS{power/runtime_suspended_time}=="0"
    ATTRS{power/runtime_usage}=="0"

  looking at parent device '/devices/pci0000:00/0000:00:02.4/0000:04:00.0/rtsx_pci_sdmmc.0':
    KERNELS=="rtsx_pci_sdmmc.0"
    SUBSYSTEMS=="platform"
    DRIVERS=="rtsx_pci_sdmmc"
    ATTRS{driver_override}=="(null)"
    ATTRS{power/async}=="disabled"
    ATTRS{power/runtime_active_kids}=="0"
    ATTRS{power/runtime_enabled}=="enabled"
    ATTRS{power/runtime_status}=="suspended"
    ATTRS{power/runtime_usage}=="0"

  looking at parent device '/devices/pci0000:00/0000:00:02.4/0000:04:00.0':
    KERNELS=="0000:04:00.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="rtsx_pci"
    ATTRS{ari_enabled}=="0"
    ATTRS{broken_parity_status}=="0"
    ATTRS{class}=="0xff0000"
    ATTRS{consistent_dma_mask_bits}=="32"
    ATTRS{current_link_speed}=="Unknown"
    ATTRS{current_link_width}=="63"
    ATTRS{d3cold_allowed}=="1"
    ATTRS{device}=="0x522a"
    ATTRS{dma_mask_bits}=="32"
    ATTRS{driver_override}=="(null)"
    ATTRS{enable}=="1"
    ATTRS{irq}=="43"
    ATTRS{local_cpulist}=="0-15"
    ATTRS{local_cpus}=="ffff"
    ATTRS{max_link_speed}=="2.5 GT/s PCIe"
    ATTRS{max_link_width}=="63"
    ATTRS{msi_bus}=="1"
    ATTRS{msi_irqs/43}=="msi"
    ATTRS{numa_node}=="-1"
    ATTRS{power/async}=="enabled"
    ATTRS{power/control}=="auto"
    ATTRS{power/runtime_active_kids}=="0"
    ATTRS{power/runtime_active_time}=="81165"
    ATTRS{power/runtime_enabled}=="enabled"
    ATTRS{power/runtime_status}=="suspended"
    ATTRS{power/runtime_suspended_time}=="1243702"
    ATTRS{power/runtime_usage}=="0"
    ATTRS{power/wakeup}=="disabled"
    ATTRS{power/wakeup_abort_count}==""
    ATTRS{power/wakeup_active}==""
    ATTRS{power/wakeup_active_count}==""
    ATTRS{power/wakeup_count}==""
    ATTRS{power/wakeup_expire_count}==""
    ATTRS{power/wakeup_last_time_ms}==""
    ATTRS{power/wakeup_max_time_ms}==""
    ATTRS{power/wakeup_total_time_ms}==""
    ATTRS{power_state}=="D3cold"
    ATTRS{remove}=="(not readable)"
    ATTRS{rescan}=="(not readable)"
    ATTRS{reset}=="(not readable)"
    ATTRS{reset_method}=="pm bus"
    ATTRS{resource0}=="(not readable)"
    ATTRS{revision}=="0x01"
    ATTRS{subsystem_device}=="0x50bf"
    ATTRS{subsystem_vendor}=="0x17aa"
    ATTRS{vendor}=="0x10ec"

  looking at parent device '/devices/pci0000:00/0000:00:02.4':
    KERNELS=="0000:00:02.4"
    SUBSYSTEMS=="pci"
    DRIVERS=="pcieport"
    ATTRS{ari_enabled}=="0"
    ATTRS{broken_parity_status}=="0"
    ATTRS{class}=="0x060400"
    ATTRS{consistent_dma_mask_bits}=="32"
    ATTRS{current_link_speed}=="2.5 GT/s PCIe"
    ATTRS{current_link_width}=="1"
    ATTRS{d3cold_allowed}=="1"
    ATTRS{device}=="0x1634"
    ATTRS{dma_mask_bits}=="32"
    ATTRS{driver_override}=="(null)"
    ATTRS{enable}=="1"
    ATTRS{irq}=="39"
    ATTRS{local_cpulist}=="0-15"
    ATTRS{local_cpus}=="ffff"
    ATTRS{max_link_speed}=="8.0 GT/s PCIe"
    ATTRS{max_link_width}=="1"
    ATTRS{msi_bus}=="1"
    ATTRS{msi_irqs/39}=="msi"
    ATTRS{numa_node}=="-1"
    ATTRS{power/async}=="enabled"
    ATTRS{power/autosuspend_delay_ms}=="100"
    ATTRS{power/control}=="auto"
    ATTRS{power/runtime_active_kids}=="1"
    ATTRS{power/runtime_active_time}=="81263"
    ATTRS{power/runtime_enabled}=="enabled"
    ATTRS{power/runtime_status}=="active"
    ATTRS{power/runtime_suspended_time}=="1243621"
    ATTRS{power/runtime_usage}=="0"
    ATTRS{power/wakeup}=="disabled"
    ATTRS{power/wakeup_abort_count}==""
    ATTRS{power/wakeup_active}==""
    ATTRS{power/wakeup_active_count}==""
    ATTRS{power/wakeup_count}==""
    ATTRS{power/wakeup_expire_count}==""
    ATTRS{power/wakeup_last_time_ms}==""
    ATTRS{power/wakeup_max_time_ms}==""
    ATTRS{power/wakeup_total_time_ms}==""
    ATTRS{power_state}=="D0"
    ATTRS{remove}=="(not readable)"
    ATTRS{rescan}=="(not readable)"
    ATTRS{reset}=="(not readable)"
    ATTRS{reset_method}=="pm"
    ATTRS{revision}=="0x00"
    ATTRS{secondary_bus_number}=="4"
    ATTRS{subordinate_bus_number}=="4"
    ATTRS{subsystem_device}=="0x50bf"
    ATTRS{subsystem_vendor}=="0x17aa"
    ATTRS{vendor}=="0x1022"

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""
    ATTRS{power/async}=="enabled"
    ATTRS{power/control}=="auto"
    ATTRS{power/runtime_active_kids}=="20"
    ATTRS{power/runtime_active_time}=="0"
    ATTRS{power/runtime_enabled}=="disabled"
    ATTRS{power/runtime_status}=="unsupported"
    ATTRS{power/runtime_suspended_time}=="0"
    ATTRS{power/runtime_usage}=="0"
    ATTRS{waiting_for_supplier}=="0"

❯ udevadm info -ap /devices/pci0000:00/0000:00:02.4/0000:04:00.0/rtsx_pci_sdmmc.0/mmc_host/mmc0/mmc0:0007/block/mmcblk0
  looking at device '/devices/pci0000:00/0000:00:02.4/0000:04:00.0/rtsx_pci_sdmmc.0/mmc_host/mmc0/mmc0:0007/block/mmcblk0':
    KERNEL=="mmcblk0"
    SUBSYSTEM=="block"
    DRIVER==""
    ATTR{alignment_offset}=="0"
    ATTR{capability}=="0"
    ATTR{discard_alignment}=="0"
    ATTR{diskseq}=="10"
    ATTR{events}==""
    ATTR{events_async}==""
    ATTR{events_poll_msecs}=="-1"
    ATTR{ext_range}=="256"
    ATTR{force_ro}=="0"
    ATTR{hidden}=="0"
    ATTR{inflight}=="       0        0"
    ATTR{integrity/device_is_integrity_capable}=="0"
    ATTR{integrity/format}=="none"
    ATTR{integrity/protection_interval_bytes}=="0"
    ATTR{integrity/read_verify}=="0"
    ATTR{integrity/tag_size}=="0"
    ATTR{integrity/write_generate}=="0"
    ATTR{mq/0/cpu_list}=="0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15"
    ATTR{mq/0/nr_reserved_tags}=="0"
    ATTR{mq/0/nr_tags}=="64"
    ATTR{partscan}=="1"
    ATTR{power/async}=="disabled"
    ATTR{power/control}=="auto"
    ATTR{power/runtime_active_kids}=="0"
    ATTR{power/runtime_active_time}=="0"
    ATTR{power/runtime_enabled}=="disabled"
    ATTR{power/runtime_status}=="unsupported"
    ATTR{power/runtime_suspended_time}=="0"
    ATTR{power/runtime_usage}=="0"
    ATTR{queue/add_random}=="0"
    ATTR{queue/chunk_sectors}=="0"
    ATTR{queue/dax}=="0"
    ATTR{queue/discard_granularity}=="1048576"
    ATTR{queue/discard_max_bytes}=="730857472"
    ATTR{queue/discard_max_hw_bytes}=="730857472"
    ATTR{queue/discard_zeroes_data}=="0"
    ATTR{queue/dma_alignment}=="511"
    ATTR{queue/fua}=="0"
    ATTR{queue/hw_sector_size}=="512"
    ATTR{queue/io_poll}=="0"
    ATTR{queue/io_poll_delay}=="-1"
    ATTR{queue/io_timeout}=="60000"
    ATTR{queue/iosched/async_depth}=="96"
    ATTR{queue/iosched/fifo_batch}=="16"
    ATTR{queue/iosched/front_merges}=="1"
    ATTR{queue/iosched/prio_aging_expire}=="10000"
    ATTR{queue/iosched/read_expire}=="500"
    ATTR{queue/iosched/write_expire}=="5000"
    ATTR{queue/iosched/writes_starved}=="2"
    ATTR{queue/iostats}=="1"
    ATTR{queue/logical_block_size}=="512"
    ATTR{queue/max_discard_segments}=="1"
    ATTR{queue/max_hw_sectors_kb}=="512"
    ATTR{queue/max_integrity_segments}=="0"
    ATTR{queue/max_sectors_kb}=="512"
    ATTR{queue/max_segment_size}=="65536"
    ATTR{queue/max_segments}=="256"
    ATTR{queue/minimum_io_size}=="512"
    ATTR{queue/nomerges}=="0"
    ATTR{queue/nr_requests}=="128"
    ATTR{queue/nr_zones}=="0"
    ATTR{queue/optimal_io_size}=="0"
    ATTR{queue/physical_block_size}=="512"
    ATTR{queue/read_ahead_kb}=="128"
    ATTR{queue/rotational}=="0"
    ATTR{queue/rq_affinity}=="1"
    ATTR{queue/scheduler}=="none [mq-deadline] kyber "
    ATTR{queue/stable_writes}=="0"
    ATTR{queue/virt_boundary_mask}=="0"
    ATTR{queue/wbt_lat_usec}=="2000"
    ATTR{queue/write_cache}=="write through"
    ATTR{queue/write_same_max_bytes}=="0"
    ATTR{queue/write_zeroes_max_bytes}=="0"
    ATTR{queue/zone_append_max_bytes}=="0"
    ATTR{queue/zone_write_granularity}=="0"
    ATTR{queue/zoned}=="none"
    ATTR{range}=="32"
    ATTR{removable}=="0"
    ATTR{ro}=="0"
    ATTR{size}=="246784"
    ATTR{stat}=="     217       34     9868      807        2        0        2      323        0     1071     1130        0        0        0        0        0        0"
    ATTR{trace/act_mask}=="disabled"
    ATTR{trace/enable}=="0"
    ATTR{trace/end_lba}=="disabled"
    ATTR{trace/pid}=="disabled"
    ATTR{trace/start_lba}=="disabled"

  looking at parent device '/devices/pci0000:00/0000:00:02.4/0000:04:00.0/rtsx_pci_sdmmc.0/mmc_host/mmc0/mmc0:0007':
    KERNELS=="mmc0:0007"
    SUBSYSTEMS=="mmc"
    DRIVERS=="mmcblk"
    ATTRS{cid}=="114499534431323820a70001f6008201"
    ATTRS{csd}=="002e00325f5980f0ffff7f818a400001"
    ATTRS{date}=="02/2008"
    ATTRS{dsr}=="0x404"
    ATTRS{erase_size}=="512"
    ATTRS{fwrev}=="0x0"
    ATTRS{hwrev}=="0x2"
    ATTRS{manfid}=="0x000011"
    ATTRS{name}=="SD128"
    ATTRS{ocr}=="0x00300000"
    ATTRS{oemid}=="0x4499"
    ATTRS{power/async}=="enabled"
    ATTRS{power/autosuspend_delay_ms}=="3000"
    ATTRS{power/control}=="auto"
    ATTRS{power/runtime_active_kids}=="0"
    ATTRS{power/runtime_active_time}=="22705"
    ATTRS{power/runtime_enabled}=="enabled"
    ATTRS{power/runtime_status}=="suspended"
    ATTRS{power/runtime_suspended_time}=="921357"
    ATTRS{power/runtime_usage}=="0"
    ATTRS{preferred_erase_size}=="1048576"
    ATTRS{rca}=="0x0007"
    ATTRS{removable}=="removable"
    ATTRS{scr}=="0225000001000000"
    ATTRS{serial}=="0xa70001f6"
    ATTRS{ssr}=="000000000000000a020270000c060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
    ATTRS{type}=="SD"

  looking at parent device '/devices/pci0000:00/0000:00:02.4/0000:04:00.0/rtsx_pci_sdmmc.0/mmc_host/mmc0':
    KERNELS=="mmc0"
    SUBSYSTEMS=="mmc_host"
    DRIVERS==""
    ATTRS{power/async}=="enabled"
    ATTRS{power/control}=="auto"
    ATTRS{power/runtime_active_kids}=="0"
    ATTRS{power/runtime_active_time}=="0"
    ATTRS{power/runtime_enabled}=="disabled"
    ATTRS{power/runtime_status}=="unsupported"
    ATTRS{power/runtime_suspended_time}=="0"
    ATTRS{power/runtime_usage}=="0"

  looking at parent device '/devices/pci0000:00/0000:00:02.4/0000:04:00.0/rtsx_pci_sdmmc.0':
    KERNELS=="rtsx_pci_sdmmc.0"
    SUBSYSTEMS=="platform"
    DRIVERS=="rtsx_pci_sdmmc"
    ATTRS{driver_override}=="(null)"
    ATTRS{power/async}=="disabled"
    ATTRS{power/runtime_active_kids}=="0"
    ATTRS{power/runtime_enabled}=="enabled"
    ATTRS{power/runtime_status}=="suspended"
    ATTRS{power/runtime_usage}=="0"

  looking at parent device '/devices/pci0000:00/0000:00:02.4/0000:04:00.0':
    KERNELS=="0000:04:00.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="rtsx_pci"
    ATTRS{ari_enabled}=="0"
    ATTRS{broken_parity_status}=="0"
    ATTRS{class}=="0xff0000"
    ATTRS{consistent_dma_mask_bits}=="32"
    ATTRS{current_link_speed}=="2.5 GT/s PCIe"
    ATTRS{current_link_width}=="63"
    ATTRS{d3cold_allowed}=="1"
    ATTRS{device}=="0x522a"
    ATTRS{dma_mask_bits}=="32"
    ATTRS{driver_override}=="(null)"
    ATTRS{enable}=="1"
    ATTRS{irq}=="43"
    ATTRS{local_cpulist}=="0-15"
    ATTRS{local_cpus}=="ffff"
    ATTRS{max_link_speed}=="2.5 GT/s PCIe"
    ATTRS{max_link_width}=="1"
    ATTRS{msi_bus}=="1"
    ATTRS{msi_irqs/43}=="msi"
    ATTRS{numa_node}=="-1"
    ATTRS{power/async}=="enabled"
    ATTRS{power/control}=="auto"
    ATTRS{power/runtime_active_kids}=="0"
    ATTRS{power/runtime_active_time}=="95262"
    ATTRS{power/runtime_enabled}=="enabled"
    ATTRS{power/runtime_status}=="suspended"
    ATTRS{power/runtime_suspended_time}=="1480745"
    ATTRS{power/runtime_usage}=="0"
    ATTRS{power/wakeup}=="disabled"
    ATTRS{power/wakeup_abort_count}==""
    ATTRS{power/wakeup_active}==""
    ATTRS{power/wakeup_active_count}==""
    ATTRS{power/wakeup_count}==""
    ATTRS{power/wakeup_expire_count}==""
    ATTRS{power/wakeup_last_time_ms}==""
    ATTRS{power/wakeup_max_time_ms}==""
    ATTRS{power/wakeup_total_time_ms}==""
    ATTRS{power_state}=="D0"
    ATTRS{remove}=="(not readable)"
    ATTRS{rescan}=="(not readable)"
    ATTRS{reset}=="(not readable)"
    ATTRS{reset_method}=="pm bus"
    ATTRS{resource0}=="(not readable)"
    ATTRS{revision}=="0x01"
    ATTRS{subsystem_device}=="0x50bf"
    ATTRS{subsystem_vendor}=="0x17aa"
    ATTRS{vendor}=="0x10ec"

  looking at parent device '/devices/pci0000:00/0000:00:02.4':
    KERNELS=="0000:00:02.4"
    SUBSYSTEMS=="pci"
    DRIVERS=="pcieport"
    ATTRS{ari_enabled}=="0"
    ATTRS{broken_parity_status}=="0"
    ATTRS{class}=="0x060400"
    ATTRS{consistent_dma_mask_bits}=="32"
    ATTRS{current_link_speed}=="2.5 GT/s PCIe"
    ATTRS{current_link_width}=="1"
    ATTRS{d3cold_allowed}=="1"
    ATTRS{device}=="0x1634"
    ATTRS{dma_mask_bits}=="32"
    ATTRS{driver_override}=="(null)"
    ATTRS{enable}=="1"
    ATTRS{irq}=="39"
    ATTRS{local_cpulist}=="0-15"
    ATTRS{local_cpus}=="ffff"
    ATTRS{max_link_speed}=="8.0 GT/s PCIe"
    ATTRS{max_link_width}=="1"
    ATTRS{msi_bus}=="1"
    ATTRS{msi_irqs/39}=="msi"
    ATTRS{numa_node}=="-1"
    ATTRS{power/async}=="enabled"
    ATTRS{power/autosuspend_delay_ms}=="100"
    ATTRS{power/control}=="auto"
    ATTRS{power/runtime_active_kids}=="1"
    ATTRS{power/runtime_active_time}=="95409"
    ATTRS{power/runtime_enabled}=="enabled"
    ATTRS{power/runtime_status}=="active"
    ATTRS{power/runtime_suspended_time}=="1480627"
    ATTRS{power/runtime_usage}=="0"
    ATTRS{power/wakeup}=="disabled"
    ATTRS{power/wakeup_abort_count}==""
    ATTRS{power/wakeup_active}==""
    ATTRS{power/wakeup_active_count}==""
    ATTRS{power/wakeup_count}==""
    ATTRS{power/wakeup_expire_count}==""
    ATTRS{power/wakeup_last_time_ms}==""
    ATTRS{power/wakeup_max_time_ms}==""
    ATTRS{power/wakeup_total_time_ms}==""
    ATTRS{power_state}=="D0"
    ATTRS{remove}=="(not readable)"
    ATTRS{rescan}=="(not readable)"
    ATTRS{reset}=="(not readable)"
    ATTRS{reset_method}=="pm"
    ATTRS{revision}=="0x00"
    ATTRS{secondary_bus_number}=="4"
    ATTRS{subordinate_bus_number}=="4"
    ATTRS{subsystem_device}=="0x50bf"
    ATTRS{subsystem_vendor}=="0x17aa"
    ATTRS{vendor}=="0x1022"

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""
    ATTRS{power/async}=="enabled"
    ATTRS{power/control}=="auto"
    ATTRS{power/runtime_active_kids}=="20"
    ATTRS{power/runtime_active_time}=="0"
    ATTRS{power/runtime_enabled}=="disabled"
    ATTRS{power/runtime_status}=="unsupported"
    ATTRS{power/runtime_suspended_time}=="0"
    ATTRS{power/runtime_usage}=="0"
    ATTRS{waiting_for_supplier}=="0"

may i ask how you interpreted this? And how actually devices are associated normally ?

Guess because it’s added separately and the path looks like a seperate device. There’s lots of nesting going on.

Depends on the device. This is pretty typical.

As for actually changing the udev rules… I’m unsure how to continue. Firstly, the attributes from that stackoverflow post don’t align with yours:

Secondly, a bunch of these devices are marked as disabled. This could simply be because they haven’t been polled… But I’m not sure.

At this point I would try to guess the intent behind the stackoverflow post, and try to map device attributes to each of those rules, then try until I find combinations that work. I don’t actually have the device, so it’ll be quicker if you just try some of the attributes yourself.

You could also find the source for this driver in the kernel, and maybe check if there are some comments that could help. Doesn’t look like it from a glance, sadly, maybe the kernel docs? There are some pages here, but they also don’t look very useful: MMC/SD/SDIO card support — The Linux Kernel documentation

I’m reaching the end of my knowledge here, this may need to be a kernel mailing list question at this rate.

1 Like