All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wolfgang Wallner <wolfgang.wallner@br-automation.com>
To: u-boot@lists.denx.de
Subject: [PATCH 17/22] x86: mtrr: Update MTRRs on all CPUs
Date: Wed, 10 Jun 2020 15:28:09 +0200	[thread overview]
Message-ID: <OFC85DB1D2.9200461B-ONC1258583.0046C34E-C1258583.0049FD35@br-automation.com> (raw)
In-Reply-To: <20200521202309.17.Ib8a974f884b75e218eed2a2eff355cbfa1919381@changeid>

Hi Simon,

-----"Simon Glass" <sjg@chromium.org> schrieb: -----
> Betreff: [PATCH 17/22] x86: mtrr: Update MTRRs on all CPUs
> 
> When the boot CPU MTRRs are updated, perform the same update on all other
> CPUs so they are kept in sync.
> 
> This avoids kernel warnings about mismatched MTRRs.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
> 
>  arch/x86/cpu/mtrr.c | 57 +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 57 insertions(+)
> 
> diff --git a/arch/x86/cpu/mtrr.c b/arch/x86/cpu/mtrr.c
> index 11f3ef08172..a48c9d8232e 100644
> --- a/arch/x86/cpu/mtrr.c
> +++ b/arch/x86/cpu/mtrr.c
> @@ -74,10 +74,61 @@ void mtrr_save_all(struct mtrr_info *info)
>  	}
>  }
>  
> +void mtrr_load_all(struct mtrr_info *info)

Nit: Similar request as in the previous patch. How about naming this
function "mtrr_write_all" ?

> +{
> +	struct mtrr_state state;
> +	int i;
> +
> +	for (i = 0; i < MTRR_COUNT; i++) {
> +		mtrr_open(&state, true);
> +		wrmsrl(MTRR_PHYS_BASE_MSR(i), info->mtrr[i].base);
> +		wrmsrl(MTRR_PHYS_MASK_MSR(i), info->mtrr[i].mask);
> +		mtrr_close(&state, true);
> +	}
> +}
> +
> +static void save_mtrrs(void *arg)
> +{
> +	struct mtrr_info *info = arg;
> +
> +	mtrr_save_all(info);
> +}
> +
> +static void load_mtrrs(void *arg)
> +{
> +	struct mtrr_info *info = arg;
> +
> +	mtrr_load_all(info);
> +}
> +
> +/**
> + * mtrr_copy_to_aps() - Copy the MTRRs from the boot CPU to other CPUs
> + *
> + * @return 0 on success, -ve on failure
> + */
> +static int mtrr_copy_to_aps(void)
> +{
> +	struct mtrr_info info;
> +	int ret;
> +
> +	ret = mp_run_on_cpus(MP_SELECT_BSP, save_mtrrs, &info);
> +	if (ret == -ENXIO)
> +		return 0;
> +	else if (ret)
> +		return log_msg_ret("bsp", ret);
> +
> +	ret = mp_run_on_cpus(MP_SELECT_APS, load_mtrrs, &info);
> +	if (ret)
> +		return log_msg_ret("bsp", ret);
> +
> +	return 0;
> +}
> +
>  int mtrr_commit(bool do_caches)
>  {
>  	struct mtrr_request *req = gd->arch.mtrr_req;
>  	struct mtrr_state state;
> +	int ret;
>  	int i;
>  
>  	debug("%s: enabled=%d, count=%d\n", __func__, gd->arch.has_mtrr,
> @@ -99,6 +150,12 @@ int mtrr_commit(bool do_caches)
>  	mtrr_close(&state, do_caches);
>  	debug("mtrr done\n");
>  
> +	if (gd->flags & GD_FLG_RELOC) {
> +		ret = mtrr_copy_to_aps();
> +		if (ret)
> +			return log_msg_ret("copy", ret);
> +	}
> +
>  	return 0;
>  }
>  
> -- 
> 2.27.0.rc0.183.gde8f92d652-goog

Reviewed-by: Wolfgang Wallner <wolfgang.wallner@br-automation.com>

  reply	other threads:[~2020-06-10 13:28 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-22  2:23 [PATCH 00/22] x86: Enhance MTRR functionality to support multiple CPUs Simon Glass
2020-05-22  2:23 ` [PATCH 01/22] x86: mp_init: Switch to livetree Simon Glass
2020-06-10 13:25   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 02/22] x86: Move MP code into mp_init Simon Glass
2020-06-10 13:25   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 03/22] x86: mp_init: Avoid declarations in header files Simon Glass
2020-06-10 13:25   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 04/22] x86: mp_init: Switch parameter names in start_aps() Simon Glass
2020-06-10 13:25   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 05/22] x86: mp_init: Drop the num_cpus static variable Simon Glass
2020-06-10 13:25   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 06/22] x86: mtrr: Fix 'ensable' typo Simon Glass
2020-06-10 13:26   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 07/22] x86: mp_init: Set up the CPU numbers at the start Simon Glass
2020-06-10 13:26   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 08/22] x86: mp_init: Adjust bsp_init() to return more information Simon Glass
2020-06-10 13:26   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 09/22] x86: cpu: Remove unnecessary #ifdefs Simon Glass
2020-06-10 13:26   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 10/22] x86: mp: Support APs waiting for instructions Simon Glass
2020-06-10 13:27   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 11/22] global_data: Add a generic global_data flag for SMP state Simon Glass
2020-06-10 13:27   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 12/22] x86: Set the SMP flag when MP init is complete Simon Glass
2020-06-10 13:27   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 13/22] x86: mp: Allow running functions on multiple CPUs Simon Glass
2020-06-10 13:27   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 14/22] x86: mp: Park CPUs before running the OS Simon Glass
2020-06-10 13:27   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 15/22] x86: mp: Add iterators for CPUs Simon Glass
2020-06-10 13:27   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 16/22] x86: mtrr: Use MP calls to list the MTRRs Simon Glass
2020-06-10 13:28   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 17/22] x86: mtrr: Update MTRRs on all CPUs Simon Glass
2020-06-10 13:28   ` Wolfgang Wallner [this message]
2020-05-22  2:23 ` [PATCH 18/22] x86: mtrr: Add support for writing to MTRRs on any CPU Simon Glass
2020-06-10 13:28   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 19/22] x86: mtrr: Update the command to use the new mtrr calls Simon Glass
2020-06-10 13:28   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 20/22] x86: mtrr: Restructure so command execution is in one place Simon Glass
2020-06-10 13:28   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 21/22] x86: mtrr: Update 'mtrr' to allow setting MTRRs on any CPU Simon Glass
2020-06-10 13:29   ` Wolfgang Wallner
2020-05-22  2:23 ` [PATCH 22/22] x86: mtrr: Enhance 'mtrr' command to list " Simon Glass
2020-06-10 13:29   ` Wolfgang Wallner
2020-05-22 10:54 ` [PATCH 00/22] x86: Enhance MTRR functionality to support multiple CPUs Andy Shevchenko
2020-05-22 13:42   ` Simon Glass

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=OFC85DB1D2.9200461B-ONC1258583.0046C34E-C1258583.0049FD35@br-automation.com \
    --to=wolfgang.wallner@br-automation.com \
    --cc=u-boot@lists.denx.de \
    /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.