Skip to content

Commit 22cda7c

Browse files
oohalmpe
authored andcommitted
powerpc/eeh: Add debugfs interface to run an EEH check
Detecting an frozen EEH PE usually occurs when an MMIO load returns a 0xFFs response. When performing EEH testing using the EEH error injection feature available on some platforms there is no simple way to kick-off the kernel's recovery process since any accesses from userspace (usually /dev/mem) will bypass the MMIO helpers in the kernel which check if a 0xFF response is due to an EEH freeze or not. If a device contains a 0xFF byte in it's config space it's possible to trigger the recovery process via config space read from userspace, but this is not a reliable method. If a driver is bound to the device an in use it will frequently trigger the MMIO check, but this is also inconsistent. To solve these problems this patch adds a debugfs file called "eeh_dev_check" which accepts a <domain>:<bus>:<dev>.<fn> string and runs eeh_dev_check_failure() on it. This is the same check that's done when the kernel gets a 0xFF result from an config or MMIO read with the added benifit that it can be reliably triggered from userspace. Signed-off-by: Oliver O'Halloran <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent aeff27c commit 22cda7c

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

arch/powerpc/kernel/eeh.c

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1871,6 +1871,64 @@ static const struct file_operations eeh_force_recover_fops = {
18711871
.llseek = no_llseek,
18721872
.write = eeh_force_recover_write,
18731873
};
1874+
1875+
static ssize_t eeh_debugfs_dev_usage(struct file *filp,
1876+
char __user *user_buf,
1877+
size_t count, loff_t *ppos)
1878+
{
1879+
static const char usage[] = "input format: <domain>:<bus>:<dev>.<fn>\n";
1880+
1881+
return simple_read_from_buffer(user_buf, count, ppos,
1882+
usage, sizeof(usage) - 1);
1883+
}
1884+
1885+
static ssize_t eeh_dev_check_write(struct file *filp,
1886+
const char __user *user_buf,
1887+
size_t count, loff_t *ppos)
1888+
{
1889+
uint32_t domain, bus, dev, fn;
1890+
struct pci_dev *pdev;
1891+
struct eeh_dev *edev;
1892+
char buf[20];
1893+
int ret;
1894+
1895+
ret = simple_write_to_buffer(buf, sizeof(buf), ppos, user_buf, count);
1896+
if (!ret)
1897+
return -EFAULT;
1898+
1899+
ret = sscanf(buf, "%x:%x:%x.%x", &domain, &bus, &dev, &fn);
1900+
if (ret != 4) {
1901+
pr_err("%s: expected 4 args, got %d\n", __func__, ret);
1902+
return -EINVAL;
1903+
}
1904+
1905+
pdev = pci_get_domain_bus_and_slot(domain, bus, (dev << 3) | fn);
1906+
if (!pdev)
1907+
return -ENODEV;
1908+
1909+
edev = pci_dev_to_eeh_dev(pdev);
1910+
if (!edev) {
1911+
pci_err(pdev, "No eeh_dev for this device!\n");
1912+
pci_dev_put(pdev);
1913+
return -ENODEV;
1914+
}
1915+
1916+
ret = eeh_dev_check_failure(edev);
1917+
pci_info(pdev, "eeh_dev_check_failure(%04x:%02x:%02x.%01x) = %d\n",
1918+
domain, bus, dev, fn, ret);
1919+
1920+
pci_dev_put(pdev);
1921+
1922+
return count;
1923+
}
1924+
1925+
static const struct file_operations eeh_dev_check_fops = {
1926+
.open = simple_open,
1927+
.llseek = no_llseek,
1928+
.write = eeh_dev_check_write,
1929+
.read = eeh_debugfs_dev_usage,
1930+
};
1931+
18741932
#endif
18751933

18761934
static int __init eeh_init_proc(void)
@@ -1886,6 +1944,9 @@ static int __init eeh_init_proc(void)
18861944
debugfs_create_bool("eeh_disable_recovery", 0600,
18871945
powerpc_debugfs_root,
18881946
&eeh_debugfs_no_recover);
1947+
debugfs_create_file_unsafe("eeh_dev_check", 0600,
1948+
powerpc_debugfs_root, NULL,
1949+
&eeh_dev_check_fops);
18891950
debugfs_create_file_unsafe("eeh_force_recover", 0600,
18901951
powerpc_debugfs_root, NULL,
18911952
&eeh_force_recover_fops);

0 commit comments

Comments
 (0)