Commit db7ebcf2 authored by Ilpo Järvinen's avatar Ilpo Järvinen Committed by Peng Zhang
Browse files

EDAC/amd64: Convert PCIBIOS_* return codes to errnos

stable inclusion
from stable-v6.6.34
commit 8f84ae504348a2985a1520b2c47a04935d86cae2
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IAD6H2

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=8f84ae504348a2985a1520b2c47a04935d86cae2



--------------------------------

commit 3ec8ebd8a5b782d56347ae884de880af26f93996 upstream.

gpu_get_node_map() uses pci_read_config_dword() that returns PCIBIOS_*
codes. The return code is then returned all the way into the module
init function amd64_edac_init() that returns it as is. The module init
functions, however, should return normal errnos.

Convert PCIBIOS_* returns code using pcibios_err_to_errno() into normal
errno before returning it from gpu_get_node_map().

For consistency, convert also the other similar cases which return
PCIBIOS_* codes even if they do not have any bugs at the moment.

Fixes: 4251566e ("EDAC/amd64: Cache and use GPU node map")
Signed-off-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20240527132236.13875-1-ilpo.jarvinen@linux.intel.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>

Conflicts:
	drivers/edac/amd64_edac.c
[Context conflicts]
Signed-off-by: default avatarZhangPeng <zhangpeng362@huawei.com>
parent a8513a51
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -80,7 +80,7 @@ int __amd64_read_pci_cfg_dword(struct pci_dev *pdev, int offset,
		amd64_warn("%s: error reading F%dx%03x.\n",
			   func, PCI_FUNC(pdev->devfn), offset);

	return err;
	return pcibios_err_to_errno(err);
}

int __amd64_write_pci_cfg_dword(struct pci_dev *pdev, int offset,
@@ -93,7 +93,7 @@ int __amd64_write_pci_cfg_dword(struct pci_dev *pdev, int offset,
		amd64_warn("%s: error writing to F%dx%03x.\n",
			   func, PCI_FUNC(pdev->devfn), offset);

	return err;
	return pcibios_err_to_errno(err);
}

static u32 get_umc_base_f18h_m4h(u16 node, u8 channel)
@@ -1027,8 +1027,10 @@ static int gpu_get_node_map(void)
	}

	ret = pci_read_config_dword(pdev, REG_LOCAL_NODE_TYPE_MAP, &tmp);
	if (ret)
	if (ret) {
		ret = pcibios_err_to_errno(ret);
		goto out;
	}

	gpu_node_map.node_count = FIELD_GET(LNTM_NODE_COUNT, tmp);
	gpu_node_map.base_node_id = FIELD_GET(LNTM_BASE_NODE_ID, tmp);