linux-edac.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yazen Ghannam <yazen.ghannam@amd.com>
To: John Allen <john.allen@amd.com>,
	bp@alien8.de, linux-edac@vger.kernel.org, tony.luck@intel.com
Cc: yazen.ghannam@amd.com, linux-kernel@vger.kernel.org,
	avadhut.naik@amd.com, muralidhara.mk@amd.com
Subject: Re: [PATCH v2 2/4] RAS/AMD/ATL: Expand helpers for adding and removing base and hole
Date: Tue, 2 Apr 2024 22:45:24 -0400	[thread overview]
Message-ID: <943f76ae-d83a-4824-abeb-f1a6b187c305@amd.com> (raw)
In-Reply-To: <20240327185222.98998-3-john.allen@amd.com>



On 3/27/24 14:52, John Allen wrote:
> The existing helpers for adding and removing the base and legacy MMIO

The remove helper is newly introduced in this patch, correct?

> hole operate on the ret_addr stored in the addr_ctx struct. This works
> for the existing use case as adding and removing the base and hole is
> only done once for an address that is already stored in ret_addr as part
> of translation.
>

I think it would help to give a bit more context and to describe things
more generally.

"The ret_addr field in struct addr_ctx contains the intermediate value of
the returned address as it passes through multiple steps in the
translation process. Currently, the "add DRAM base and legacy hole"
step is only done once, so it operates directly on the intermediate
value."

> However, in the Data Fabric 4.5 non-power-of-2 cases, we will add and
> remove the base and hole temporarily to check for correctness on
> addresses other than ret_addr multiple times throughout translation.
>

Don't say "we". Keep the voice passive.

"However, for X cases, the "add DRAM base and legacy hole" step, and its
inverse, need to be done for multiple temporary addresses values. During
this process, the intermediate should not be lost, so the ret_addr value
cannot be reused."

> Modify the helpers to take any address as a parameter and return the
> resulting address after adding or removing the hole. This will allow for
> more simply adding and removing the base and hole from any address
> without having to store them in the ret_addr field of the addr_ctx
> struct.
>

"Update the existing 'add' helper to operate on an arbitrary address.
And introduce a new 'remove' helper to do the inverse operations."

How do these sound?

> Signed-off-by: John Allen <john.allen@amd.com>
> ---
> v2:
>    - Make remove_base_and_hole the inverse of add_base_and_hole, removing
>      the hole first and then removing the base.
>    - Improve commit description.
> ---
>   drivers/ras/amd/atl/core.c     | 43 ++++++++++++++++++++++------------
>   drivers/ras/amd/atl/internal.h |  3 +++
>   2 files changed, 31 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/ras/amd/atl/core.c b/drivers/ras/amd/atl/core.c
> index 63513d972c07..d45f9948c0ab 100644
> --- a/drivers/ras/amd/atl/core.c
> +++ b/drivers/ras/amd/atl/core.c
> @@ -49,15 +49,26 @@ static bool legacy_hole_en(struct addr_ctx *ctx)
>   	return FIELD_GET(DF_LEGACY_MMIO_HOLE_EN, reg);
>   }
>   
> -static int add_legacy_hole(struct addr_ctx *ctx)
> +static u64 add_legacy_hole(struct addr_ctx *ctx, u64 addr)
>   {
>   	if (!legacy_hole_en(ctx))
> -		return 0;
> +		return addr;
>   
> -	if (ctx->ret_addr >= df_cfg.dram_hole_base)
> -		ctx->ret_addr += (BIT_ULL(32) - df_cfg.dram_hole_base);
> +	if (addr >= df_cfg.dram_hole_base)
> +		addr += (BIT_ULL(32) - df_cfg.dram_hole_base);
>   
> -	return 0;
> +	return addr;
> +}
> +
> +static u64 remove_legacy_hole(struct addr_ctx *ctx, u64 addr)
> +{
> +	if (!legacy_hole_en(ctx))
> +		return addr;
> +
> +	if (addr >= df_cfg.dram_hole_base)
> +		addr -= (BIT_ULL(32) - df_cfg.dram_hole_base);
> +
> +	return addr;
>   }
>   
>   static u64 get_base_addr(struct addr_ctx *ctx)
> @@ -72,14 +83,16 @@ static u64 get_base_addr(struct addr_ctx *ctx)
>   	return base_addr << DF_DRAM_BASE_LIMIT_LSB;
>   }
>   
> -static int add_base_and_hole(struct addr_ctx *ctx)
> +u64 add_base_and_hole(struct addr_ctx *ctx, u64 addr)
>   {
> -	ctx->ret_addr += get_base_addr(ctx);
> -
> -	if (add_legacy_hole(ctx))
> -		return -EINVAL;
> +	addr += get_base_addr(ctx);
> +	return add_legacy_hole(ctx, addr);
> +}
>   
> -	return 0;
> +u64 remove_base_and_hole(struct addr_ctx *ctx, u64 addr)
> +{
> +	remove_legacy_hole(ctx, addr);
> +	return addr - get_base_addr(ctx);
>   }
>   
>   static bool late_hole_remove(struct addr_ctx *ctx)
> @@ -123,14 +136,14 @@ unsigned long norm_to_sys_addr(u8 socket_id, u8 die_id, u8 coh_st_inst_id, unsig
>   	if (denormalize_address(&ctx))
>   		return -EINVAL;
>   
> -	if (!late_hole_remove(&ctx) && add_base_and_hole(&ctx))
> -		return -EINVAL;
> +	if (!late_hole_remove(&ctx))
> +		ctx.ret_addr = add_base_and_hole(&ctx, ctx.ret_addr);
>   
>   	if (dehash_address(&ctx))
>   		return -EINVAL;
>   
> -	if (late_hole_remove(&ctx) && add_base_and_hole(&ctx))
> -		return -EINVAL;
> +	if (late_hole_remove(&ctx))
> +		ctx.ret_addr = add_base_and_hole(&ctx, ctx.ret_addr);
>   
>   	if (addr_over_limit(&ctx))
>   		return -EINVAL;
> diff --git a/drivers/ras/amd/atl/internal.h b/drivers/ras/amd/atl/internal.h
> index 1413c8ddc6c5..05b870fcb24e 100644
> --- a/drivers/ras/amd/atl/internal.h
> +++ b/drivers/ras/amd/atl/internal.h
> @@ -236,6 +236,9 @@ int dehash_address(struct addr_ctx *ctx);
>   unsigned long norm_to_sys_addr(u8 socket_id, u8 die_id, u8 coh_st_inst_id, unsigned long addr);
>   unsigned long convert_umc_mca_addr_to_sys_addr(struct atl_err *err);
>   
> +u64 add_base_and_hole(struct addr_ctx *ctx, u64 addr);
> +u64 remove_base_and_hole(struct addr_ctx *ctx, u64 addr);
> +
>   /*
>    * Make a gap in @data that is @num_bits long starting at @bit_num.
>    * e.g. data		= 11111111'b

Besides the commit message notes, I think this looks good.

Reviewed-by: Yazen Ghannam <yazen.ghannam@amd.com>

Thanks,
Yazen

  reply	other threads:[~2024-04-03 14:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-27 18:52 [PATCH v2 0/4] RAS: ATL: DF 4.5 NP2 Denormalization John Allen
2024-03-27 18:52 ` [PATCH v2 1/4] RAS/AMD/ATL: Read DRAM hole base early John Allen
2024-04-03  2:03   ` Yazen Ghannam
2024-03-27 18:52 ` [PATCH v2 2/4] RAS/AMD/ATL: Expand helpers for adding and removing base and hole John Allen
2024-04-03  2:45   ` Yazen Ghannam [this message]
2024-03-27 18:52 ` [PATCH v2 3/4] RAS/AMD/ATL: Validate address map when information is gathered John Allen
2024-04-03  3:06   ` Yazen Ghannam
2024-03-27 18:52 ` [PATCH v2 4/4] RAS/AMD/ATL: Implement DF 4.5 NP2 denormalization John Allen
2024-04-03  3:56   ` 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=943f76ae-d83a-4824-abeb-f1a6b187c305@amd.com \
    --to=yazen.ghannam@amd.com \
    --cc=avadhut.naik@amd.com \
    --cc=bp@alien8.de \
    --cc=john.allen@amd.com \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=muralidhara.mk@amd.com \
    --cc=tony.luck@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).