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>
This commit is contained in:
Enzo Matsumiya 2021-12-23 23:38:17 -03:00 committed by Mario Limonciello
parent 9d7e4309a3
commit 9b386965f2

View File

@ -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;