From a397eb398e95eade1ebbe3cab7394f302084c321 Mon Sep 17 00:00:00 2001 From: Dr-Noob Date: Sat, 18 Dec 2021 20:11:02 +0100 Subject: [PATCH] [v0.11] Handle the case where the GPU is not found in the pci LUT --- src/cuda/chips.hpp | 2 +- src/cuda/pci.cpp | 2 +- src/cuda/uarch.cpp | 2 +- src/intel/pci.cpp | 2 +- src/intel/uarch.cpp | 10 +++++++--- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/cuda/chips.hpp b/src/cuda/chips.hpp index 6e1e290..e0f2f61 100644 --- a/src/cuda/chips.hpp +++ b/src/cuda/chips.hpp @@ -4,7 +4,7 @@ typedef uint32_t GPUCHIP; enum { - CHIP_UNKNOWN, + CHIP_UNKNOWN_CUDA, CHIP_G80, CHIP_G80GL, CHIP_G84, diff --git a/src/cuda/pci.cpp b/src/cuda/pci.cpp index 146c636..868d0ac 100644 --- a/src/cuda/pci.cpp +++ b/src/cuda/pci.cpp @@ -8,7 +8,7 @@ #define CHECK_PCI_START if (false) {} #define CHECK_PCI(pci, id, chip) \ else if (pci->device_id == id) return chip; -#define CHECK_PCI_END else { printBug("TODOO"); return CHIP_UNKNOWN; } +#define CHECK_PCI_END else { printBug("Unkown CUDA device id: 0x%.4X", pci->device_id); return CHIP_UNKNOWN_CUDA; } /* * pci ids were retrieved using https://github.com/pciutils/pciids diff --git a/src/cuda/uarch.cpp b/src/cuda/uarch.cpp index ef2f86d..f769b18 100644 --- a/src/cuda/uarch.cpp +++ b/src/cuda/uarch.cpp @@ -39,7 +39,7 @@ static const char *uarch_str[] = { #define CHECK_UARCH_START if (false) {} #define CHECK_UARCH(arch, chip_, str, uarch, process) \ else if (arch->chip == chip_) fill_uarch(arch, str, uarch, process); -#define CHECK_UARCH_END else { printBug("map_chip_to_uarch_cuda: Unknown chip id: %d", arch->chip); fill_uarch(arch, STRING_UNKNOWN, UARCH_UNKNOWN, 0); } +#define CHECK_UARCH_END else { if(arch->chip != CHIP_UNKNOWN_CUDA) printBug("map_chip_to_uarch_cuda: Unknown chip id: %d", arch->chip); fill_uarch(arch, STRING_UNKNOWN, UARCH_UNKNOWN, 0); } void fill_uarch(struct uarch* arch, char const *str, MICROARCH u, uint32_t process) { arch->chip_str = (char *) emalloc(sizeof(char) * (strlen(str)+1)); diff --git a/src/intel/pci.cpp b/src/intel/pci.cpp index 024c2ab..ea1af9d 100644 --- a/src/intel/pci.cpp +++ b/src/intel/pci.cpp @@ -8,7 +8,7 @@ #define CHECK_PCI_START if (false) {} #define CHECK_PCI(pci, id, chip) \ else if (pci->device_id == id) return chip; -#define CHECK_PCI_END else { printBug("TODOO"); return CHIP_UNKNOWN_INTEL; } +#define CHECK_PCI_END else { printBug("Unkown Intel device id: 0x%.4X", pci->device_id); return CHIP_UNKNOWN_INTEL; } /* * https://github.com/mesa3d/mesa/blob/main/include/pci_ids/i965_pci_ids.h diff --git a/src/intel/uarch.cpp b/src/intel/uarch.cpp index 8b5f30a..21643e2 100644 --- a/src/intel/uarch.cpp +++ b/src/intel/uarch.cpp @@ -149,9 +149,13 @@ struct uarch* get_uarch_from_pci(struct pci* pci) { arch->chip_str = NULL; arch->chip = get_chip_from_pci_intel(pci); - map_chip_to_uarch_intel(arch); - - return arch; + if(arch->chip == CHIP_UNKNOWN_INTEL) { + return NULL; + } + else { + map_chip_to_uarch_intel(arch); + return arch; + } } char* get_name_from_uarch(struct uarch* arch) {