4 ms·
> we have hardware that is flat out broken Reading Linux driver code is very informative. Sometimes hardware just doesn't do what is expected and the driver mu
by matheusmoreira 6y ago
> we have hardware that is flat out broken
Reading Linux driver code is very informative. Sometimes hardware just doesn't do what is expected and the driver must try and fix it up so that user space can have a reasonable interface.
A simple example:
/* The ITE8595 always reports 0 as value for the rfkill button. Luckily
* it is the only button in its report, and it sends a report on
* release only, so receiving a report means the button was pressed.
*/
if (usage->hid == HID_GD_RFKILL_BTN) {
input_event(input, EV_KEY, KEY_RFKILL, 1);
input_sync(input);
input_event(input, EV_KEY, KEY_RFKILL, 0);
input_sync(input);
return 1;
}
- Dunedan 6y agoIt's even more interesting when you can infer why its broken. Let's take the NVMe controller in the MacBook Pro 2016 and later for example: That controller is not properly detected by Linux and needs a quirk [1] to be identified by its PCI device id instead. Why is that? Well, Linux usually detects NVMe devices based on their PCI class. The class for NVMe devices is 0x010802. So guess what the Apple controller provides as class id: 0x018002. If you have to compare the ids twice to notice what's different, you're not alone. My guess is that this subtle difference is just a human error made by an Apple engineer, which wasn't caught during QA and macOS simply works around it as well or doesn't use PCI class anyway. So for the same reason software isn't perfect, hardware (or the firmware powering that hardware) is neither. [1]: https://github.com/torvalds/linux/blob/b791d1bdf9212d944d749a5c7ff6febdba241771/drivers/nvme/host/pci.c#L3126 https://github.com/torvalds/linux/blob/b791d1bdf9212d944d749... [2]: https://lists.infradead.org/pipermail/linux-nvme/2017-February/008351.html https://lists.infradead.org/pipermail/linux-nvme/2017-Februa...