public inbox for linux-edac@vger.kernel.org
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Yazen Ghannam <yazen.ghannam@amd.com>
Cc: linux-edac@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
	 tony.luck@intel.com, x86@kernel.org, avadhut.naik@amd.com,
	 john.allen@amd.com, mario.limonciello@amd.com,
	bhelgaas@google.com,  Shyam-sundar.S-k@amd.com,
	richard.gong@amd.com, jdelvare@suse.com,  linux@roeck-us.net,
	clemens@ladisch.de,  Hans de Goede <hdegoede@redhat.com>,
	linux-pci@vger.kernel.org,  linux-hwmon@vger.kernel.org,
	platform-driver-x86@vger.kernel.org,
	 naveenkrishna.chatradhi@amd.com, carlos.bilbao.osdev@gmail.com
Subject: Re: [PATCH 14/16] x86/amd_smn, platform/x86/amd/hsmp: Have HSMP use SMN
Date: Thu, 24 Oct 2024 16:23:55 +0300 (EEST)	[thread overview]
Message-ID: <2797ecc5-935d-21a2-bb43-273a7eae3a12@linux.intel.com> (raw)
In-Reply-To: <20241023172150.659002-15-yazen.ghannam@amd.com>

On Wed, 23 Oct 2024, Yazen Ghannam wrote:

> The HSMP interface is just an SMN interface with different offsets.
> 
> Define an HSMP wrapper in the SMN code and have the HSMP platform driver
> use that rather than a local solution.
> 
> Also, remove the "root" member from AMD_NB, since there are no more
> users of it.
> 
> Signed-off-by: Yazen Ghannam <yazen.ghannam@amd.com>
> ---
>  arch/x86/include/asm/amd_nb.h    |  1 -
>  arch/x86/include/asm/amd_smn.h   |  3 +++
>  arch/x86/kernel/amd_nb.c         |  1 -
>  arch/x86/kernel/amd_smn.c        |  9 +++++++++
>  drivers/platform/x86/amd/Kconfig |  2 +-
>  drivers/platform/x86/amd/hsmp.c  | 32 +++++---------------------------
>  6 files changed, 18 insertions(+), 30 deletions(-)
> 
> diff --git a/arch/x86/include/asm/amd_nb.h b/arch/x86/include/asm/amd_nb.h
> index 55c03d3495bc..cbe31e316e39 100644
> --- a/arch/x86/include/asm/amd_nb.h
> +++ b/arch/x86/include/asm/amd_nb.h
> @@ -27,7 +27,6 @@ struct amd_l3_cache {
>  };
>  
>  struct amd_northbridge {
> -	struct pci_dev *root;
>  	struct pci_dev *misc;
>  	struct pci_dev *link;
>  	struct amd_l3_cache l3_cache;
> diff --git a/arch/x86/include/asm/amd_smn.h b/arch/x86/include/asm/amd_smn.h
> index 6850de69f863..f0eb12859c42 100644
> --- a/arch/x86/include/asm/amd_smn.h
> +++ b/arch/x86/include/asm/amd_smn.h
> @@ -8,4 +8,7 @@
>  int __must_check amd_smn_read(u16 node, u32 address, u32 *value);
>  int __must_check amd_smn_write(u16 node, u32 address, u32 value);
>  
> +/* Should only be used by the HSMP driver. */
> +int __must_check amd_smn_hsmp_rdwr(u16 node, u32 address, u32 *value, bool write);
> +
>  #endif /* _ASM_X86_AMD_SMN_H */
> diff --git a/arch/x86/kernel/amd_nb.c b/arch/x86/kernel/amd_nb.c
> index 10cdeddeda02..4c22317a6dfe 100644
> --- a/arch/x86/kernel/amd_nb.c
> +++ b/arch/x86/kernel/amd_nb.c
> @@ -73,7 +73,6 @@ static int amd_cache_northbridges(void)
>  	amd_northbridges.nb = nb;
>  
>  	for (i = 0; i < amd_northbridges.num; i++) {
> -		node_to_amd_nb(i)->root = amd_node_get_root(i);
>  		node_to_amd_nb(i)->misc = amd_node_get_func(i, 3);
>  		node_to_amd_nb(i)->link = amd_node_get_func(i, 4);
>  	}
> diff --git a/arch/x86/kernel/amd_smn.c b/arch/x86/kernel/amd_smn.c
> index 997fd3edd9c0..527dda8e3a2b 100644
> --- a/arch/x86/kernel/amd_smn.c
> +++ b/arch/x86/kernel/amd_smn.c
> @@ -18,6 +18,9 @@ static DEFINE_MUTEX(smn_mutex);
>  #define SMN_INDEX_OFFSET	0x60
>  #define SMN_DATA_OFFSET		0x64
>  
> +#define HSMP_INDEX_OFFSET	0xc4
> +#define HSMP_DATA_OFFSET	0xc8
> +
>  /*
>   * SMN accesses may fail in ways that are difficult to detect here in the called
>   * functions amd_smn_read() and amd_smn_write(). Therefore, callers must do
> @@ -100,6 +103,12 @@ int __must_check amd_smn_write(u16 node, u32 address, u32 value)
>  }
>  EXPORT_SYMBOL_GPL(amd_smn_write);
>  
> +int __must_check amd_smn_hsmp_rdwr(u16 node, u32 address, u32 *value, bool write)
> +{
> +	return __amd_smn_rw(HSMP_INDEX_OFFSET, HSMP_DATA_OFFSET, node, address, value, write);
> +}
> +EXPORT_SYMBOL_GPL(amd_smn_hsmp_rdwr);
> +
>  static int amd_cache_roots(void)
>  {
>  	u16 node, num_nodes = amd_num_nodes();
> diff --git a/drivers/platform/x86/amd/Kconfig b/drivers/platform/x86/amd/Kconfig
> index f88682d36447..e100b315c62b 100644
> --- a/drivers/platform/x86/amd/Kconfig
> +++ b/drivers/platform/x86/amd/Kconfig
> @@ -8,7 +8,7 @@ source "drivers/platform/x86/amd/pmc/Kconfig"
>  
>  config AMD_HSMP
>  	tristate "AMD HSMP Driver"
> -	depends on AMD_NB && X86_64 && ACPI
> +	depends on AMD_SMN && X86_64 && ACPI
>  	help
>  	  The driver provides a way for user space tools to monitor and manage
>  	  system management functionality on EPYC server CPUs from AMD.
> diff --git a/drivers/platform/x86/amd/hsmp.c b/drivers/platform/x86/amd/hsmp.c
> index 8fcf38eed7f0..544efb0255c0 100644
> --- a/drivers/platform/x86/amd/hsmp.c
> +++ b/drivers/platform/x86/amd/hsmp.c

FYI, there has been major restructuring done for this driver in 
pdx86/for-next.

-- 
 i.

> @@ -10,7 +10,7 @@
>  #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>  
>  #include <asm/amd_hsmp.h>
> -#include <asm/amd_nb.h>
> +#include <asm/amd_smn.h>
>  #include <linux/delay.h>
>  #include <linux/io.h>
>  #include <linux/miscdevice.h>
> @@ -48,9 +48,6 @@
>  #define SMN_HSMP_MSG_RESP	0x0010980
>  #define SMN_HSMP_MSG_DATA	0x00109E0
>  
> -#define HSMP_INDEX_REG		0xc4
> -#define HSMP_DATA_REG		0xc8
> -
>  #define HSMP_CDEV_NAME		"hsmp_cdev"
>  #define HSMP_DEVNODE_NAME	"hsmp"
>  #define HSMP_METRICS_TABLE_NAME	"metrics_bin"
> @@ -62,8 +59,6 @@
>  #define MSG_ARGOFF_STR		"MsgArgOffset"
>  #define MSG_RESPOFF_STR		"MsgRspOffset"
>  
> -#define MAX_AMD_SOCKETS 8
> -
>  struct hsmp_mbaddr_info {
>  	u32 base_addr;
>  	u32 msg_id_off;
> @@ -79,7 +74,6 @@ struct hsmp_socket {
>  	void __iomem *virt_base_addr;
>  	struct semaphore hsmp_sem;
>  	char name[HSMP_ATTR_GRP_NAME_SIZE];
> -	struct pci_dev *root;
>  	struct device *dev;
>  	u16 sock_ind;
>  };
> @@ -98,20 +92,7 @@ static struct hsmp_plat_device plat_dev;
>  static int amd_hsmp_pci_rdwr(struct hsmp_socket *sock, u32 offset,
>  			     u32 *value, bool write)
>  {
> -	int ret;
> -
> -	if (!sock->root)
> -		return -ENODEV;
> -
> -	ret = pci_write_config_dword(sock->root, HSMP_INDEX_REG,
> -				     sock->mbinfo.base_addr + offset);
> -	if (ret)
> -		return ret;
> -
> -	ret = (write ? pci_write_config_dword(sock->root, HSMP_DATA_REG, *value)
> -		     : pci_read_config_dword(sock->root, HSMP_DATA_REG, value));
> -
> -	return ret;
> +	return amd_smn_hsmp_rdwr(sock->sock_ind, sock->mbinfo.base_addr + offset, value, write);
>  }
>  
>  static void amd_hsmp_acpi_rdwr(struct hsmp_socket *sock, u32 offset,
> @@ -749,10 +730,7 @@ static int init_platform_device(struct device *dev)
>  	int ret, i;
>  
>  	for (i = 0; i < plat_dev.num_sockets; i++) {
> -		if (!node_to_amd_nb(i))
> -			return -ENODEV;
>  		sock = &plat_dev.sock[i];
> -		sock->root			= node_to_amd_nb(i)->root;
>  		sock->sock_ind			= i;
>  		sock->dev			= dev;
>  		sock->mbinfo.base_addr		= SMN_HSMP_BASE;
> @@ -946,11 +924,11 @@ static int __init hsmp_plt_init(void)
>  	int ret = -ENODEV;
>  
>  	/*
> -	 * amd_nb_num() returns number of SMN/DF interfaces present in the system
> +	 * amd_num_nodes() returns number of SMN/DF interfaces present in the system
>  	 * if we have N SMN/DF interfaces that ideally means N sockets
>  	 */
> -	plat_dev.num_sockets = amd_nb_num();
> -	if (plat_dev.num_sockets == 0 || plat_dev.num_sockets > MAX_AMD_SOCKETS)
> +	plat_dev.num_sockets = amd_num_nodes();
> +	if (plat_dev.num_sockets == 0 || plat_dev.num_sockets > MAX_AMD_NUM_NODES)
>  		return ret;
>  
>  	ret = platform_driver_register(&amd_hsmp_driver);
> 

  reply	other threads:[~2024-10-24 13:24 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-23 17:21 [PATCH 00/16] AMD NB and SMN rework Yazen Ghannam
2024-10-23 17:21 ` [PATCH 01/16] x86/mce/amd: Remove shared threshold bank plumbing Yazen Ghannam
2024-10-23 17:21 ` [PATCH 02/16] x86/amd_nb: Restrict init function to AMD-based systems Yazen Ghannam
2024-10-31  8:09   ` Zhuo, Qiuxu
2024-10-31 10:36     ` Borislav Petkov
2024-10-31 11:50       ` Zhuo, Qiuxu
2024-10-31 13:11         ` Borislav Petkov
2024-10-23 17:21 ` [PATCH 03/16] x86/amd_nb: Clean up early_is_amd_nb() Yazen Ghannam
2024-10-25 15:58   ` Borislav Petkov
2024-10-29 14:39     ` Yazen Ghannam
2024-10-29 15:08       ` Borislav Petkov
2024-10-29 16:15         ` Luck, Tony
2024-10-30 14:21           ` Yazen Ghannam
2024-10-31  0:53             ` Sohil Mehta
2024-10-31 10:34               ` [PATCH] x86/cpufeature: Document cpu_feature_enabled() as the default to use Borislav Petkov
2024-10-31 18:26                 ` Sohil Mehta
2024-10-31 19:15                   ` Borislav Petkov
2024-11-05 19:59                 ` Dave Hansen
2024-10-31 10:24             ` [PATCH 03/16] x86/amd_nb: Clean up early_is_amd_nb() Borislav Petkov
2024-10-23 17:21 ` [PATCH 04/16] x86: Start moving AMD Node functionality out of AMD_NB Yazen Ghannam
2024-10-23 17:21 ` [PATCH 05/16] x86/amd_nb: Simplify function 4 search Yazen Ghannam
2024-10-31 11:15   ` Borislav Petkov
2024-10-23 17:21 ` [PATCH 06/16] x86/amd_nb: Simplify root device search Yazen Ghannam
2024-10-31  7:52   ` Zhuo, Qiuxu
2024-10-31 10:08     ` Ilpo Järvinen
2024-10-31 13:10       ` Zhuo, Qiuxu
2024-10-31 15:34       ` Yazen Ghannam
2024-10-31 15:42         ` Ilpo Järvinen
2024-10-31 15:45           ` Yazen Ghannam
2024-10-31 11:20   ` Borislav Petkov
2024-10-31 15:29     ` Yazen Ghannam
2024-10-23 17:21 ` [PATCH 07/16] x86/amd_nb: Use topology info to get AMD node count Yazen Ghannam
2024-10-23 17:21 ` [PATCH 08/16] x86/amd_nb: Simplify function 3 search Yazen Ghannam
2024-10-23 17:21 ` [PATCH 09/16] x86/amd_nb, x86/amd_node: Simplify amd_pci_dev_to_node_id() Yazen Ghannam
2024-11-04 14:23   ` Borislav Petkov
2024-11-05 14:54     ` Yazen Ghannam
2024-10-23 17:21 ` [PATCH 10/16] x86/amd_nb: Move SMN access code to a new amd_smn driver Yazen Ghannam
2024-11-04 14:29   ` Borislav Petkov
2024-11-05 14:58     ` Yazen Ghannam
2024-11-05 19:42       ` Borislav Petkov
2024-10-23 17:21 ` [PATCH 11/16] x86/amd_smn: Fixup __amd_smn_rw() Yazen Ghannam
2024-11-04 14:32   ` Borislav Petkov
2024-11-05 14:59     ` Yazen Ghannam
2024-10-23 17:21 ` [PATCH 12/16] x86/amd_smn: Remove dependency on AMD_NB Yazen Ghannam
2024-10-23 17:21 ` [PATCH 13/16] x86/amd_smn: Use defines for register offsets Yazen Ghannam
2024-10-23 17:21 ` [PATCH 14/16] x86/amd_smn, platform/x86/amd/hsmp: Have HSMP use SMN Yazen Ghannam
2024-10-24 13:23   ` Ilpo Järvinen [this message]
2024-10-24 16:06     ` Yazen Ghannam
2024-10-25 13:39       ` Ilpo Järvinen
2024-10-23 17:21 ` [PATCH 15/16] x86/amd_smn: Add SMN offsets to exclusive region access Yazen Ghannam
2024-10-23 17:21 ` [PATCH 16/16] x86/amd_smn: Add support for debugfs access to SMN registers Yazen Ghannam
2024-11-05 19:21   ` Borislav Petkov
2024-11-05 19:46     ` Mario Limonciello
2024-11-05 19:53       ` Borislav Petkov
2024-11-05 19:56         ` Mario Limonciello
2024-11-05 19:59           ` Borislav Petkov
2024-11-05 20:53             ` Mario Limonciello
2024-10-23 17:59 ` [PATCH 00/16] AMD NB and SMN rework Bjorn Helgaas
2024-10-24 16:01   ` Yazen Ghannam
2024-10-24 17:46     ` Bjorn Helgaas
2024-10-24 20:08       ` Mario Limonciello
2024-10-24 21:06         ` Bjorn Helgaas
2024-10-24 21:20           ` Mario Limonciello
2024-10-24 21:47             ` Bjorn Helgaas
2024-10-31 16:22               ` Yazen Ghannam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2797ecc5-935d-21a2-bb43-273a7eae3a12@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=Shyam-sundar.S-k@amd.com \
    --cc=avadhut.naik@amd.com \
    --cc=bhelgaas@google.com \
    --cc=carlos.bilbao.osdev@gmail.com \
    --cc=clemens@ladisch.de \
    --cc=hdegoede@redhat.com \
    --cc=jdelvare@suse.com \
    --cc=john.allen@amd.com \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=mario.limonciello@amd.com \
    --cc=naveenkrishna.chatradhi@amd.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=richard.gong@amd.com \
    --cc=tony.luck@intel.com \
    --cc=x86@kernel.org \
    --cc=yazen.ghannam@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox