Merge pull request #1 from AuxXxilium-Tech/main

sync
This commit is contained in:
Christian Schulthess 2023-12-27 18:07:02 +01:00 committed by GitHub
commit 135e44b4d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 3 deletions

View File

@ -0,0 +1,30 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef REDPILL_PCI_H
#define REDPILL_PCI_H
#warning "Using compatibility file for drivers/pci/pci.h - if possible do NOT compile using toolkit"
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,18,0) && LINUX_VERSION_CODE < KERNEL_VERSION(4,20,0) //v4.18 - v4.20
/* pci_dev priv_flags */
#define PCI_DEV_ADDED 1
static inline bool pci_dev_is_added(const struct pci_dev *dev)
{
return test_bit(PCI_DEV_ADDED, &dev->priv_flags);
}
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4,20,0) && LINUX_VERSION_CODE < KERNEL_VERSION(6,0,0) //v4.20 - v6.0
#define PCI_DEV_ADDED 0
static inline bool pci_dev_is_added(const struct pci_dev *dev)
{
return test_bit(PCI_DEV_ADDED, &dev->priv_flags);
}
#else
static inline bool pci_dev_is_added(const struct pci_dev *dev)
{
return 1 == dev->is_added;
}
#endif //LINUX_VERSION_CODE check
#endif /* REDPILL_PCI_H */

View File

@ -373,7 +373,7 @@ static inline void restart_port(struct uart_8250_port *up)
// because we did swap IRQ values. However, we MUST restart such port not to reinit the hardware (which doesn't
// care) but to fix the interrupt mapping in the kernel!
//skip extensive tests - it was working before
#if LINUX_VERSION_CODE <= KERNEL_VERSION(5,0,0)
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,14,0)
port->flags |= UPF_NO_TXEN_TEST;
#else
port->quirks |= UPQ_NO_TXEN_TEST;

View File

@ -176,6 +176,9 @@
#include <linux/pci_ids.h> //Constants for vendors, classes, and other
#include <linux/list.h> //list_for_each
#include <linux/device.h> //device_del
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,18,0)
#include <../drivers/pci/pci.h> //pci_dev_is_added
#endif
#define PCIBUS_VIRTUAL_DOMAIN 0x0001 //normal PC buses are (always?) on domain 0, this is just a next one
#define PCI_DEVICE_NOT_FOUND_VID_DID 0xFFFFFFFF //A special case to detect non-existing devices (per PCI spec)
@ -545,10 +548,10 @@ int vpci_remove_all_devices_and_buses(void)
for_each_bus_idx() {
list_for_each_entry_safe(pci_dev, pci_dev_n, &buses[i]->devices, bus_list) {
pr_loc_dbg("Detaching vDEV dev=%02x fn=%02x from bus=%02x [add=%d]", PCI_SLOT(pci_dev->devfn),
#if LINUX_VERSION_CODE <= KERNEL_VERSION(5,0,0)
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,18,0)
PCI_FUNC(pci_dev->devfn), buses[i]->number, pci_dev->is_added);
#else
PCI_FUNC(pci_dev->devfn), buses[i]->number, 0); // Not found a replacement for pci_dev->is_added
PCI_FUNC(pci_dev->devfn), buses[i]->number, pci_dev_is_added(pci_dev));
#endif
pci_stop_and_remove_bus_device(pci_dev);
}

View File

@ -348,10 +348,12 @@ static int _apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab, unsigned
val -= (u64)loc;
*(u32 *)loc = val;
break;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,20,0)
case R_X86_64_PC64:
val -= (u64)loc;
*(u64 *)loc = val;
break;
#endif
default:
pr_err("%s: Unknown rela relocation: %llu\n",
me->name, ELF64_R_TYPE(rel[i].r_info));