Unverified Commit 46e918f5 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!3997 [OLK-6.6] openEuler-24.03 Phytium S2500 IPMI adaption

Merge Pull Request from: @shuaijiakun 
 
The system would hang up when the Phytium S2500 communicates with some BMCs after several rounds of transactions, unless we reset the controller timeout counter manually by calling firmware through SMC.

https://gitee.com/openeuler/kernel/issues/I8WAA9 
 
Link:https://gitee.com/openeuler/kernel/pulls/3997

 

Reviewed-by: default avatarLu Jialin <lujialin4@huawei.com>
Reviewed-by: default avatarMao HongBo <maohongbo@phytium.com.cn>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parents 533518ef d8f6d492
Loading
Loading
Loading
Loading
+76 −0
Original line number Diff line number Diff line
@@ -3,9 +3,77 @@
#include <linux/io.h>
#include "ipmi_si.h"

#ifdef CONFIG_ARM_GIC_PHYTIUM_2500
#include <linux/arm-smccc.h>

#define CTL_RST_FUNC_ID 0xC2000011

static bool apply_phytium2500_workaround;

struct ipmi_workaround_oem_info {
	char oem_id[ACPI_OEM_ID_SIZE + 1];
};

#ifdef CONFIG_ACPI
static struct ipmi_workaround_oem_info wa_info[] = {
	{
		.oem_id		= "KPSVVJ",
	}
};
#endif

static void ipmi_check_phytium_workaround(void)
{
#ifdef CONFIG_ACPI
	struct acpi_table_header tbl;
	int i;

	if (ACPI_FAILURE(acpi_get_table_header(ACPI_SIG_DSDT, 0, &tbl)))
		return;

	for (i = 0; i < ARRAY_SIZE(wa_info); i++) {
		if (strncmp(wa_info[i].oem_id, tbl.oem_id, ACPI_OEM_ID_SIZE))
			continue;

		apply_phytium2500_workaround = true;
		break;
	}
#endif
}

static void ctl_smc(unsigned long arg0, unsigned long arg1,
		    unsigned long arg2, unsigned long arg3)
{
	struct arm_smccc_res res;

	arm_smccc_smc(arg0, arg1, arg2, arg3, 0, 0, 0, 0, &res);
	if (res.a0 != 0)
		pr_err("Error: Firmware call SMC reset Failed: %d, addr: 0x%lx\n",
			(int)res.a0, arg2);
}

static void ctl_timeout_reset(void)
{
	ctl_smc(CTL_RST_FUNC_ID, 0x1, 0x28100208, 0x1);
	ctl_smc(CTL_RST_FUNC_ID, 0x1, 0x2810020C, 0x1);
}

static inline void ipmi_phytium_workaround(void)
{
	if (apply_phytium2500_workaround)
		ctl_timeout_reset();
}

#else
static inline void ipmi_check_phytium_workaround(void) {}
static inline void ipmi_phytium_workaround(void) {}
#endif

static unsigned char intf_mem_inb(const struct si_sm_io *io,
				  unsigned int offset)
{
	ipmi_phytium_workaround();

	return readb((io->addr)+(offset * io->regspacing));
}

@@ -18,6 +86,8 @@ static void intf_mem_outb(const struct si_sm_io *io, unsigned int offset,
static unsigned char intf_mem_inw(const struct si_sm_io *io,
				  unsigned int offset)
{
	ipmi_phytium_workaround();

	return (readw((io->addr)+(offset * io->regspacing)) >> io->regshift)
		& 0xff;
}
@@ -31,6 +101,8 @@ static void intf_mem_outw(const struct si_sm_io *io, unsigned int offset,
static unsigned char intf_mem_inl(const struct si_sm_io *io,
				  unsigned int offset)
{
	ipmi_phytium_workaround();

	return (readl((io->addr)+(offset * io->regspacing)) >> io->regshift)
		& 0xff;
}
@@ -44,6 +116,8 @@ static void intf_mem_outl(const struct si_sm_io *io, unsigned int offset,
#ifdef readq
static unsigned char mem_inq(const struct si_sm_io *io, unsigned int offset)
{
	ipmi_phytium_workaround();

	return (readq((io->addr)+(offset * io->regspacing)) >> io->regshift)
		& 0xff;
}
@@ -81,6 +155,8 @@ int ipmi_si_mem_setup(struct si_sm_io *io)
	if (!addr)
		return -ENODEV;

	ipmi_check_phytium_workaround();

	/*
	 * Figure out the actual readb/readw/readl/etc routine to use based
	 * upon the register size.