All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Dave Jiang <dave.jiang@intel.com>
Cc: <linux-acpi@vger.kernel.org>, <linux-cxl@vger.kernel.org>,
	<rafael@kernel.org>, <lenb@kernel.org>,
	<dan.j.williams@intel.com>, <ira.weiny@intel.com>,
	<vishal.l.verma@intel.com>, <alison.schofield@intel.com>,
	<lukas@wunner.de>
Subject: Re: [PATCH v3 3/6] acpi: numa: Add genport target allocation to the HMAT parsing
Date: Thu, 22 Jun 2023 14:45:11 +0100	[thread overview]
Message-ID: <20230622144511.0000319d@Huawei.com> (raw)
In-Reply-To: <168686424175.2950427.1861604402516465647.stgit@djiang5-mobl3>

On Thu, 15 Jun 2023 14:24:01 -0700
Dave Jiang <dave.jiang@intel.com> wrote:

> Add SRAT parsing for the HMAT init in order to collect the device handle
> from the Generic Port Affinity Structure. The device handle will serve as
> the key to search for target data.
> 
> Consoliate the common code with alloc_memory_target() in a helper function
> alloc_target().
> 
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
> 

On second thoughts - device_handle is rather cryptic as a name
and there are no handy comments on what it is.
Can we call it gen_port_device_handle or something like that?


> ---
> v3:
> - Move ACPI_SRAT_DEVICE_HANDLE_SIZE to separate patch for ACPICA
> ---
>  drivers/acpi/numa/hmat.c |   53 +++++++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 50 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/acpi/numa/hmat.c b/drivers/acpi/numa/hmat.c
> index abed728bf09d..e2ab1cce0add 100644
> --- a/drivers/acpi/numa/hmat.c
> +++ b/drivers/acpi/numa/hmat.c
> @@ -71,6 +71,7 @@ struct memory_target {
>  	struct access_coordinate coord[NODE_ACCESS_CLASS_MAX];
>  	struct list_head caches;
>  	struct node_cache_attrs cache_attrs;
> +	u8 device_handle[ACPI_SRAT_DEVICE_HANDLE_SIZE];
>  	bool registered;
>  };
>  
> @@ -125,8 +126,7 @@ static __init void alloc_memory_initiator(unsigned int cpu_pxm)
>  	list_add_tail(&initiator->node, &initiators);
>  }
>  
> -static __init void alloc_memory_target(unsigned int mem_pxm,
> -		resource_size_t start, resource_size_t len)
> +static __init struct memory_target *alloc_target(unsigned int mem_pxm)
>  {
>  	struct memory_target *target;
>  
> @@ -134,7 +134,7 @@ static __init void alloc_memory_target(unsigned int mem_pxm,
>  	if (!target) {
>  		target = kzalloc(sizeof(*target), GFP_KERNEL);
>  		if (!target)
> -			return;
> +			return NULL;
>  		target->memory_pxm = mem_pxm;
>  		target->processor_pxm = PXM_INVAL;
>  		target->memregions = (struct resource) {
> @@ -147,6 +147,19 @@ static __init void alloc_memory_target(unsigned int mem_pxm,
>  		INIT_LIST_HEAD(&target->caches);
>  	}
>  
> +	return target;
> +}
> +
> +static __init void alloc_memory_target(unsigned int mem_pxm,
> +				       resource_size_t start,
> +				       resource_size_t len)
> +{
> +	struct memory_target *target;
> +
> +	target = alloc_target(mem_pxm);
> +	if (!target)
> +		return;
> +
>  	/*
>  	 * There are potentially multiple ranges per PXM, so record each
>  	 * in the per-target memregions resource tree.
> @@ -157,6 +170,17 @@ static __init void alloc_memory_target(unsigned int mem_pxm,
>  				start, start + len, mem_pxm);
>  }
>  
> +static __init void alloc_genport_target(unsigned int mem_pxm, u8 *handle)
> +{
> +	struct memory_target *target;
> +
> +	target = alloc_target(mem_pxm);
> +	if (!target)
> +		return;
> +
> +	memcpy(target->device_handle, handle, ACPI_SRAT_DEVICE_HANDLE_SIZE);
> +}
> +
>  static __init const char *hmat_data_type(u8 type)
>  {
>  	switch (type) {
> @@ -498,6 +522,22 @@ static __init int srat_parse_mem_affinity(union acpi_subtable_headers *header,
>  	return 0;
>  }
>  
> +static __init int srat_parse_genport_affinity(union acpi_subtable_headers *header,
> +					      const unsigned long end)
> +{
> +	struct acpi_srat_generic_affinity *ga = (void *)header;
> +
> +	if (!ga)
> +		return -EINVAL;
> +
> +	if (!(ga->flags & ACPI_SRAT_GENERIC_AFFINITY_ENABLED))
> +		return 0;
> +
> +	alloc_genport_target(ga->proximity_domain, (u8 *)ga->device_handle);
> +
> +	return 0;
> +}
> +
>  static u32 hmat_initiator_perf(struct memory_target *target,
>  			       struct memory_initiator *initiator,
>  			       struct acpi_hmat_locality *hmat_loc)
> @@ -848,6 +888,13 @@ static __init int hmat_init(void)
>  				ACPI_SRAT_TYPE_MEMORY_AFFINITY,
>  				srat_parse_mem_affinity, 0) < 0)
>  		goto out_put;
> +
> +	if (acpi_table_parse_entries(ACPI_SIG_SRAT,
> +				     sizeof(struct acpi_table_srat),
> +				     ACPI_SRAT_TYPE_GENERIC_PORT_AFFINITY,
> +				     srat_parse_genport_affinity, 0) < 0)
> +		goto out_put;
> +
>  	acpi_put_table(tbl);
>  
>  	status = acpi_get_table(ACPI_SIG_HMAT, 0, &tbl);
> 
> 
> 


  reply	other threads:[~2023-06-22 13:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-15 21:23 [PATCH v3 0/6] acpi: numa: add target support for generic port to HMAT parsing Dave Jiang
2023-06-15 21:23 ` [PATCH v3 1/6] acpi: numa: Create enum for memory_target access coordinates indexing Dave Jiang
2023-06-15 21:23 ` [PATCH v3 2/6] ACPICA: Add a define for size of acpi_srat_generic_affinity DeviceHandle Dave Jiang
2023-06-15 21:24 ` [PATCH v3 3/6] acpi: numa: Add genport target allocation to the HMAT parsing Dave Jiang
2023-06-22 13:45   ` Jonathan Cameron [this message]
2023-06-22 18:41     ` Dave Jiang
2023-06-15 21:24 ` [PATCH v3 4/6] acpi: Break out nesting for hmat_parse_locality() Dave Jiang
2023-06-22 13:40   ` Jonathan Cameron
2023-06-15 21:24 ` [PATCH v3 5/6] acpi: numa: Add setting of generic port system locality attributes Dave Jiang
2023-06-22 13:47   ` Jonathan Cameron
2023-06-15 21:24 ` [PATCH v3 6/6] acpi: numa: Add helper function to retrieve the performance attributes Dave Jiang
2023-06-16 17:58 ` [PATCH v3 0/6] acpi: numa: add target support for generic port to HMAT parsing Rafael J. Wysocki

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=20230622144511.0000319d@Huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=alison.schofield@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=ira.weiny@intel.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-cxl@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=rafael@kernel.org \
    --cc=vishal.l.verma@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.