File fwupd-bsc1193921-nvme-ignore-non-PCI-NVMe-devices.patch of Package fwupd.28662
From 9b386965f2b63027262f28094b3f8516d4dba17a Mon Sep 17 00:00:00 2001
From: Enzo Matsumiya <ematsumiya@suse.de>
Date: Thu, 23 Dec 2021 23:38:17 -0300
Subject: [PATCH] nvme: ignore non-PCI NVMe devices
Ignore non-PCI NVMe devices (e.g. NVMe-over-Fabrics) when probing.
Otherwise, logs might be flooded with error messages:
03:10:53:0251 FuEngine failed to add device /sys/devices/virtual/nvme-fabrics/ctl/nvme1: failed to find device with subsystems pci, only got nvme,nvme-fabrics
These devices are not supported as they are not on the PCI subsystem.
Signed-off-by: Enzo Matsumiya <ematsumiya@suse.de>
---
plugins/nvme/fu-nvme-device.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/plugins/nvme/fu-nvme-device.c b/plugins/nvme/fu-nvme-device.c
index e0bfb10c..62f5f1c1 100644
--- a/plugins/nvme/fu-nvme-device.c
+++ b/plugins/nvme/fu-nvme-device.c
@@ -267,6 +267,31 @@ fu_nvme_device_dump(const gchar *title, const guint8 *buf, gsize sz)
g_print("\n");
}
+/*
+ * Returns:
+ * %TRUE: device is in PCI subsystem
+ * %FALSE: device is, probably, NVMe-over-Fabrics
+ */
+static gboolean
+fu_nvme_device_is_pci(FuDevice *device, GError **error)
+{
+ g_autoptr(GUdevDevice) device_tmp = NULL;
+ GUdevDevice *gdev;
+
+ gdev = fu_udev_device_get_dev(FU_UDEV_DEVICE(device));
+
+ device_tmp = g_udev_device_get_parent_with_subsystem(gdev, "pci", NULL);
+ if (device_tmp == NULL) {
+ g_set_error(error,
+ FWUPD_ERROR,
+ FWUPD_ERROR_NOT_SUPPORTED,
+ "device is not on PCI subsystem");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
static gboolean
fu_nvme_device_probe(FuDevice *device, GError **error)
{
@@ -280,6 +305,10 @@ fu_nvme_device_probe(FuDevice *device, GError **error)
if (g_strcmp0(fu_device_get_vendor(FU_DEVICE(device)), "Samsung Electronics Co Ltd") == 0)
fu_device_set_vendor(FU_DEVICE(device), "Samsung");
+ /* ignore non-PCI NVMe devices */
+ if (!fu_nvme_device_is_pci(device, error))
+ return FALSE;
+
/* set the physical ID */
if (!fu_udev_device_set_physical_id(FU_UDEV_DEVICE(device), "pci", error))
return FALSE;
--
2.12.3