public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Stephan Gerhold <stephan.gerhold@linaro.org>
To: Caleb Connolly <caleb.connolly@linaro.org>
Cc: Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>,
	Tom Rini <trini@konsulko.com>, Simon Glass <sjg@chromium.org>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Sumit Garg <sumit.garg@linaro.org>,
	Mario Six <mario.six@gdsys.cc>,
	u-boot@lists.denx.de, u-boot-qcom@groups.io
Subject: Re: [PATCH 08/15] soc: qcom: smem: get serial number from socinfo
Date: Wed, 8 Jan 2025 10:38:24 +0100	[thread overview]
Message-ID: <Z35HkLAVL5QF4O5-@linaro.org> (raw)
In-Reply-To: <20241124-b4-modernise-smem-v1-8-b7852c11b67c@linaro.org>

On Sun, Nov 24, 2024 at 08:17:50PM +0100, Caleb Connolly wrote:
> Implement socinfo support to fetch the serial number if available.
> 
> Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
> ---
>  drivers/soc/qcom/smem.c | 25 +++++++++++++++++++++++++
>  include/soc/qcom/smem.h |  1 +
>  2 files changed, 26 insertions(+)
> 
> diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c
> index 5166f289dfb6..5570c5c907ad 100644
> --- a/drivers/soc/qcom/smem.c
> +++ b/drivers/soc/qcom/smem.c
> @@ -13,8 +13,10 @@
>  #include <linux/io.h>
>  #include <linux/ioport.h>
>  #include <linux/sizes.h>
>  #include <soc/qcom/smem.h>
> +#include <soc/qcom/socinfo.h>
> +#include <env.h>
>  
>  /*
>   * The Qualcomm shared memory system is a allocate only heap structure that
>   * consists of one of more memory areas that can be accessed by the processors
> @@ -982,8 +984,31 @@ static int qcom_smem_map_global(struct qcom_smem *smem, u32 size)
>  
>  	return 0;
>  }
>  
> +int qcom_socinfo_init(void)
> +{
> +	struct socinfo *info;
> +	size_t item_size;
> +	char buf[32] = { 0 };
> +
> +	info = qcom_smem_get(QCOM_SMEM_HOST_ANY, SMEM_HW_SW_BUILD_ID,
> +			     &item_size);
> +	if (IS_ERR(info)) {
> +		log_err("Couldn't find socinfo: %ld\n", PTR_ERR(info));
> +		return PTR_ERR(info);
> +	}
> +
> +	if (offsetof(struct socinfo, serial_num) <= item_size) {
> +		snprintf(buf, sizeof(buf), "%u", le32_to_cpu(info->serial_num));
> +		env_set("serial#", buf);

Hm, this conflicts with qcom_late_init() setting the serial# in
board/qualcomm/dragonboard410c/dragonboard410c.c:

## Error: Can't overwrite "serial#"
## Error inserting "serial#" variable, errno=1

DB410c doesn't have a proper serial number in socinfo. Turns out using
offsetof() in this check is wrong, I sent a patch for this on Linux that
was applied upstream:
https://git.kernel.org/pub/scm/linux/kernel/git/qcom/linux.git/commit/?h=for-next&id=22cf4fae6660b6e1a583a41cbf84e3046ca9ccd0

Can you add that fix here? offsetofend() doesn't exist in U-Boot. Might
be cleanest to just copy that over to U-Boot's linux/stddef.h.

Thanks,
Stephan

  parent reply	other threads:[~2025-01-08 15:49 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-24 19:17 [PATCH 00/15] qcom: smem: modernize SMEM in U-Boot Caleb Connolly
2024-11-24 19:17 ` [PATCH 01/15] Revert "dm: SMEM (Shared memory) uclass" Caleb Connolly
2025-01-07 15:30   ` Simon Glass
2024-11-24 19:17 ` [PATCH 02/15] smem: drop drivers/smem Caleb Connolly
2025-01-07 15:30   ` Simon Glass
2024-11-24 19:17 ` [PATCH 03/15] Revert "test: smem: add basic smem test" Caleb Connolly
2025-01-07 15:33   ` Simon Glass
2024-11-24 19:17 ` [PATCH 04/15] Revert "drivers: smem: sandbox" Caleb Connolly
2025-01-07 15:31   ` Simon Glass
2024-11-24 19:17 ` [PATCH 05/15] soc: qcom: import smem from Linux 6.11-rc2 Caleb Connolly
2025-01-07 15:30   ` Simon Glass
2025-01-08 14:45     ` Caleb Connolly
2024-11-24 19:17 ` [PATCH 06/15] soc: qcom: smem: adjust headers for U-Boot Caleb Connolly
2025-01-07 15:30   ` Simon Glass
2024-11-24 19:17 ` [PATCH 07/15] soc: qcom: smem: adjust " Caleb Connolly
2025-01-07 15:30   ` Simon Glass
2024-11-24 19:17 ` [PATCH 08/15] soc: qcom: smem: get serial number from socinfo Caleb Connolly
2025-01-07 15:30   ` Simon Glass
2025-01-08  9:38   ` Stephan Gerhold [this message]
2024-11-24 19:17 ` [PATCH 09/15] soc: qcom: smem: stub functions Caleb Connolly
2025-01-07 15:32   ` Simon Glass
2024-11-24 19:17 ` [PATCH 10/15] soc: qcom: smem: add build infra Caleb Connolly
2025-01-07 15:32   ` Simon Glass
2024-11-24 19:17 ` [PATCH 11/15] mach-snapdragon: increase pre-relocation malloc size for smem Caleb Connolly
2025-01-07 15:32   ` Simon Glass
2024-11-24 19:17 ` [PATCH 12/15] mach-snapdragon: move memory parsing to its own file Caleb Connolly
2025-01-07 15:32   ` Simon Glass
2024-11-24 19:17 ` [PATCH 13/15] mach-snapdragon: support parsing memory map from SMEM Caleb Connolly
2025-01-07 15:32   ` Simon Glass
2025-01-08  9:41   ` Stephan Gerhold
2024-11-24 19:17 ` [PATCH 14/15] mach-snapdragon: fetch serial# " Caleb Connolly
2025-01-07 15:32   ` Simon Glass
2025-01-08 15:03     ` Caleb Connolly
2024-11-24 19:17 ` [PATCH 15/15] qcom_defconfig: enable QCOM_SMEM Caleb Connolly
2025-01-08 16:57   ` 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=Z35HkLAVL5QF4O5-@linaro.org \
    --to=stephan.gerhold@linaro.org \
    --cc=caleb.connolly@linaro.org \
    --cc=mario.six@gdsys.cc \
    --cc=neil.armstrong@linaro.org \
    --cc=rayagonda.kokatanur@broadcom.com \
    --cc=sjg@chromium.org \
    --cc=sumit.garg@linaro.org \
    --cc=trini@konsulko.com \
    --cc=u-boot-qcom@groups.io \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox