mirror of
https://github.com/gnif/vendor-reset.git
synced 2026-02-10 11:22:43 +01:00
restructure and added stubs for vega10, vega20 and navi10
This commit is contained in:
21
src/amd/amd.h
Normal file
21
src/amd/amd.h
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
Vendor Reset - Vendor Specific Reset
|
||||
Copyright (C) 2020 Geoffrey McRae <geoff@hostfission.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 2 of the License, or (at your option) any later
|
||||
version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
extern struct vendor_reset_ops amd_vega10_ops;
|
||||
extern struct vendor_reset_ops amd_vega20_ops;
|
||||
extern struct vendor_reset_ops amd_navi10_ops;
|
||||
29
src/amd/navi10.c
Normal file
29
src/amd/navi10.c
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
Vendor Reset - Vendor Specific Reset
|
||||
Copyright (C) 2020 Geoffrey McRae <geoff@hostfission.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 2 of the License, or (at your option) any later
|
||||
version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "vendor-reset-dev.h"
|
||||
|
||||
static int amd_navi10_reset(struct pci_dev * dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
const struct vendor_reset_ops amd_navi10_ops =
|
||||
{
|
||||
.reset = amd_navi10_reset
|
||||
};
|
||||
29
src/amd/vega10.c
Normal file
29
src/amd/vega10.c
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
Vendor Reset - Vendor Specific Reset
|
||||
Copyright (C) 2020 Geoffrey McRae <geoff@hostfission.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 2 of the License, or (at your option) any later
|
||||
version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "vendor-reset-dev.h"
|
||||
|
||||
static int amd_vega10_reset(struct pci_dev * dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
const struct vendor_reset_ops amd_vega10_ops =
|
||||
{
|
||||
.reset = amd_vega10_reset
|
||||
};
|
||||
29
src/amd/vega20.c
Normal file
29
src/amd/vega20.c
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
Vendor Reset - Vendor Specific Reset
|
||||
Copyright (C) 2020 Geoffrey McRae <geoff@hostfission.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 2 of the License, or (at your option) any later
|
||||
version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "vendor-reset-dev.h"
|
||||
|
||||
static int amd_vega20_reset(struct pci_dev * dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
const struct vendor_reset_ops amd_vega20_ops =
|
||||
{
|
||||
.reset = amd_vega20_reset
|
||||
};
|
||||
59
src/device-db.h
Normal file
59
src/device-db.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
Vendor Reset - Vendor Specific Reset
|
||||
Copyright (C) 2020 Geoffrey McRae <geoff@hostfission.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 2 of the License, or (at your option) any later
|
||||
version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "amd/amd.h"
|
||||
|
||||
static struct vendor_reset_device vendor_reset_devices[] =
|
||||
{
|
||||
/* AMD Vega 10 */
|
||||
{ PCI_VENDOR_ID_ATI, 0x6860, &amd_vega10_ops },
|
||||
{ PCI_VENDOR_ID_ATI, 0x6861, &amd_vega10_ops },
|
||||
{ PCI_VENDOR_ID_ATI, 0x6862, &amd_vega10_ops },
|
||||
{ PCI_VENDOR_ID_ATI, 0x6863, &amd_vega10_ops },
|
||||
{ PCI_VENDOR_ID_ATI, 0x6864, &amd_vega10_ops },
|
||||
{ PCI_VENDOR_ID_ATI, 0x6867, &amd_vega10_ops },
|
||||
{ PCI_VENDOR_ID_ATI, 0x6868, &amd_vega10_ops },
|
||||
{ PCI_VENDOR_ID_ATI, 0x6869, &amd_vega10_ops },
|
||||
{ PCI_VENDOR_ID_ATI, 0x686a, &amd_vega10_ops },
|
||||
{ PCI_VENDOR_ID_ATI, 0x686b, &amd_vega10_ops },
|
||||
{ PCI_VENDOR_ID_ATI, 0x686c, &amd_vega10_ops },
|
||||
{ PCI_VENDOR_ID_ATI, 0x686d, &amd_vega10_ops },
|
||||
{ PCI_VENDOR_ID_ATI, 0x686e, &amd_vega10_ops },
|
||||
{ PCI_VENDOR_ID_ATI, 0x686f, &amd_vega10_ops },
|
||||
|
||||
/* AMD Vega 20 */
|
||||
{ PCI_VENDOR_ID_ATI, 0x66a0, &amd_vega20_ops },
|
||||
{ PCI_VENDOR_ID_ATI, 0x66a1, &amd_vega20_ops },
|
||||
{ PCI_VENDOR_ID_ATI, 0x66a2, &amd_vega20_ops },
|
||||
{ PCI_VENDOR_ID_ATI, 0x66a3, &amd_vega20_ops },
|
||||
{ PCI_VENDOR_ID_ATI, 0x66a4, &amd_vega20_ops },
|
||||
{ PCI_VENDOR_ID_ATI, 0x66a7, &amd_vega20_ops },
|
||||
{ PCI_VENDOR_ID_ATI, 0x66af, &amd_vega20_ops },
|
||||
|
||||
/* AMD Navi 10 */
|
||||
{ PCI_VENDOR_ID_ATI, 0x7310, &amd_navi10_ops },
|
||||
{ PCI_VENDOR_ID_ATI, 0x7312, &amd_navi10_ops },
|
||||
{ PCI_VENDOR_ID_ATI, 0x7318, &amd_navi10_ops },
|
||||
{ PCI_VENDOR_ID_ATI, 0x7319, &amd_navi10_ops },
|
||||
{ PCI_VENDOR_ID_ATI, 0x731a, &amd_navi10_ops },
|
||||
{ PCI_VENDOR_ID_ATI, 0x731b, &amd_navi10_ops },
|
||||
{ PCI_VENDOR_ID_ATI, 0x731e, &amd_navi10_ops },
|
||||
{ PCI_VENDOR_ID_ATI, 0x731f, &amd_navi10_ops },
|
||||
|
||||
{ 0 }
|
||||
};
|
||||
45
src/vendor-reset-dev.h
Normal file
45
src/vendor-reset-dev.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
Vendor Reset - Vendor Specific Reset
|
||||
Copyright (C) 2020 Geoffrey McRae <geoff@hostfission.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 2 of the License, or (at your option) any later
|
||||
version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _H_VENDOR_RESET_DEV
|
||||
#define _H_VENDOR_RESET_DEV
|
||||
|
||||
#define VENDOR_RESET_DEVICE_ALL ((unsigned int)-1)
|
||||
|
||||
#include <linux/pci.h>
|
||||
|
||||
struct vendor_reset_ops
|
||||
{
|
||||
/* the reset method for the device at the specified address */
|
||||
int (*reset)(struct pci_dev *dev);
|
||||
};
|
||||
|
||||
struct vendor_reset_device
|
||||
{
|
||||
/* the vendor ID */
|
||||
unsigned int vendor;
|
||||
|
||||
/* the device ID or VENDOR_RESET_DEVICE_ALL to match all devices for the
|
||||
* vendor */
|
||||
unsigned int device;
|
||||
|
||||
/* the reset operations */
|
||||
const struct vendor_reset_ops * ops;
|
||||
};
|
||||
|
||||
#endif
|
||||
118
src/vendor-reset.c
Normal file
118
src/vendor-reset.c
Normal file
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
Vendor Reset - Vendor Specific Reset
|
||||
Copyright (C) 2020 Geoffrey McRae <geoff@hostfission.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 2 of the License, or (at your option) any later
|
||||
version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
||||
Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/miscdevice.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/highmem.h>
|
||||
#include <linux/pci.h>
|
||||
|
||||
#include "vendor-reset-dev.h"
|
||||
#include "vendor-reset.h"
|
||||
|
||||
#include "device-db.h"
|
||||
|
||||
#define VENDOR_RESET_DEVNAME "vendor_reset"
|
||||
|
||||
static long vendor_reset_ioctl_reset(struct file * filp, unsigned long arg)
|
||||
{
|
||||
struct vendor_reset_ioctl dev;
|
||||
struct vendor_reset_device *entry = vendor_reset_devices;
|
||||
struct pci_dev * pcidev;
|
||||
int ret;
|
||||
|
||||
if (copy_from_user(&dev, (void __user *)arg, sizeof(dev)))
|
||||
return -EFAULT;
|
||||
|
||||
pcidev = pci_get_domain_bus_and_slot(dev.domain, dev.bus, dev.devfn);
|
||||
if (!pcidev)
|
||||
return -ENODEV;
|
||||
|
||||
for(entry = vendor_reset_devices; entry->vendor; ++entry)
|
||||
{
|
||||
if (entry->vendor != pcidev->vendor)
|
||||
continue;
|
||||
|
||||
if (entry->device == VENDOR_RESET_DEVICE_ALL ||
|
||||
entry->device == pcidev->device)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!entry->vendor)
|
||||
{
|
||||
ret = -EOPNOTSUPP;
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = entry->ops->reset(pcidev);
|
||||
|
||||
err:
|
||||
pci_dev_put(pcidev);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static long vendor_reset_ioctl(struct file * filp, unsigned int ioctl,
|
||||
unsigned long arg)
|
||||
{
|
||||
long ret;
|
||||
|
||||
switch(ioctl)
|
||||
{
|
||||
case VENDOR_RESET_RESET:
|
||||
ret = vendor_reset_ioctl_reset(filp, arg);
|
||||
break;
|
||||
|
||||
default:
|
||||
ret = -ENOTTY;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const struct file_operations vendor_reset_fops =
|
||||
{
|
||||
.owner = THIS_MODULE,
|
||||
.unlocked_ioctl = vendor_reset_ioctl,
|
||||
#ifdef CONFIG_COMPAT
|
||||
.compat_ioctl = vendor_reset_ioctl,
|
||||
#endif
|
||||
};
|
||||
|
||||
static struct miscdevice vendor_reset_misc =
|
||||
{
|
||||
.minor = MISC_DYNAMIC_MINOR,
|
||||
.name = VENDOR_RESET_DEVNAME,
|
||||
.fops = &vendor_reset_fops
|
||||
};
|
||||
|
||||
static int __init vendor_reset_init(void)
|
||||
{
|
||||
return misc_register(&vendor_reset_misc);
|
||||
}
|
||||
|
||||
static void __exit vendor_reset_exit(void)
|
||||
{
|
||||
misc_deregister(&vendor_reset_misc);
|
||||
}
|
||||
|
||||
module_init(vendor_reset_init);
|
||||
module_exit(vendor_reset_exit);
|
||||
|
||||
MODULE_LICENSE("GPL v2");
|
||||
MODULE_AUTHOR("Geoffrey McRae <geoff@hostfission.com>");
|
||||
Reference in New Issue
Block a user