mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master 1/3] mci: core: reset number of parttions on card probe failure
@ 2024-05-13  9:58 Ahmad Fatoum
  2024-05-13  9:58 ` [PATCH master 2/3] mci: core: remove HS200 from mci_timing_is_ddr Ahmad Fatoum
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2024-05-13  9:58 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

mci_part_add records information about MMC hardware partitions and
increments mci->nr_parts by one afterwards.
If starting up the card succeeds, this information is then used to
call mci_register_partition for each added partition.

If card start up fails, registration will be skipped, but mci->nr_parts
is not reset. This means that repeatedly calling device_detect will
overflow the mci->part buffer and overwrite subsequent memory.

Fix this by setting mci->nr_parts to zero on error. We don't need to
touch mci->part as it will be overwritten by subsequent detect attempts.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/mci/mci-core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index f6565b2b64dd..66ca98a414ce 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -2363,6 +2363,7 @@ static int mci_card_probe(struct mci *mci)
 		host->clock = 0;	/* disable the MCI clock */
 		mci_set_ios(mci);
 		regulator_disable(host->supply);
+		mci->nr_parts = 0;
 	}
 
 	return rc;
-- 
2.39.2




^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH master 2/3] mci: core: remove HS200 from mci_timing_is_ddr
  2024-05-13  9:58 [PATCH master 1/3] mci: core: reset number of parttions on card probe failure Ahmad Fatoum
@ 2024-05-13  9:58 ` Ahmad Fatoum
  2024-05-13  9:58 ` [PATCH master 3/3] ARM64: reloc: fix relocation error for big fat bareboxes Ahmad Fatoum
  2024-05-15  5:54 ` [PATCH master 1/3] mci: core: reset number of parttions on card probe failure Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2024-05-13  9:58 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

HS200 is a single date rate speed mode. HS400 is the DDR variant, so
drop the former from the mci_timing_is_ddr list.

No functional change expected as the only driver that currently
supported HS200 doesn't call this function anyway.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 include/mci.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/mci.h b/include/mci.h
index 3612c50b1398..b87301f97d47 100644
--- a/include/mci.h
+++ b/include/mci.h
@@ -446,7 +446,6 @@ static inline bool mci_timing_is_ddr(enum mci_timing timing)
 {
 	switch (timing) {
 	case MMC_TIMING_UHS_DDR50:
-	case MMC_TIMING_MMC_HS200:
 	case MMC_TIMING_MMC_DDR52:
 	case MMC_TIMING_MMC_HS400:
 		return true;
-- 
2.39.2




^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH master 3/3] ARM64: reloc: fix relocation error for big fat bareboxes
  2024-05-13  9:58 [PATCH master 1/3] mci: core: reset number of parttions on card probe failure Ahmad Fatoum
  2024-05-13  9:58 ` [PATCH master 2/3] mci: core: remove HS200 from mci_timing_is_ddr Ahmad Fatoum
@ 2024-05-13  9:58 ` Ahmad Fatoum
  2024-05-15  5:54 ` [PATCH master 1/3] mci: core: reset number of parttions on card probe failure Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2024-05-13  9:58 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

A multi_v8 barebox with KASAN enabled is 2051804 even after compression
and this breaks linking for me:

  arch/arm/cpu/common.o: in function `global_variable_offset':
  arch/arm/include/asm/reloc.h:20:(.text.relocate_to_current_adr+0x1c):
    relocation truncated to fit: R_AARCH64_ADR_PREL_LO21 against symbol
    `_text' defined in .text section in .tmp_barebox1
  arch/arm/include/asm/reloc.h:20:(.text.relocate_to_current_adr+0x40):
    relocation truncated to fit: R_AARCH64_ADR_PREL_LO21 against symbol
    `_text' defined in .text section in .tmp_barebox1

This is due to adr's limitation of only addressing bytes +/- 1 MiB from
the current PC. We have a solution for this in the form of the adrp
macro, which we define for out-of-line assembly. Opencode this into the
inline assembly function, by using adrp to compute the page offset and
then add to arrive at the correct offset within the page.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/arm/include/asm/reloc.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/reloc.h b/arch/arm/include/asm/reloc.h
index 95b4ef0af88b..2d7411ab5284 100644
--- a/arch/arm/include/asm/reloc.h
+++ b/arch/arm/include/asm/reloc.h
@@ -18,7 +18,8 @@ static inline __prereloc unsigned long global_variable_offset(void)
 	unsigned long text;
 
 	__asm__ __volatile__(
-		"adr    %0, _text\n"
+		"adrp   %0, _text\n"
+		"add    %0, %0, :lo12:_text\n"
 		: "=r" (text)
 		:
 		: "memory");
-- 
2.39.2




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH master 1/3] mci: core: reset number of parttions on card probe failure
  2024-05-13  9:58 [PATCH master 1/3] mci: core: reset number of parttions on card probe failure Ahmad Fatoum
  2024-05-13  9:58 ` [PATCH master 2/3] mci: core: remove HS200 from mci_timing_is_ddr Ahmad Fatoum
  2024-05-13  9:58 ` [PATCH master 3/3] ARM64: reloc: fix relocation error for big fat bareboxes Ahmad Fatoum
@ 2024-05-15  5:54 ` Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2024-05-15  5:54 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum


On Mon, 13 May 2024 11:58:45 +0200, Ahmad Fatoum wrote:
> mci_part_add records information about MMC hardware partitions and
> increments mci->nr_parts by one afterwards.
> If starting up the card succeeds, this information is then used to
> call mci_register_partition for each added partition.
> 
> If card start up fails, registration will be skipped, but mci->nr_parts
> is not reset. This means that repeatedly calling device_detect will
> overflow the mci->part buffer and overwrite subsequent memory.
> 
> [...]

Applied, thanks!

[1/3] mci: core: reset number of parttions on card probe failure
      https://git.pengutronix.de/cgit/barebox/commit/?id=c3ca560d93be (link may not be stable)
[2/3] mci: core: remove HS200 from mci_timing_is_ddr
      https://git.pengutronix.de/cgit/barebox/commit/?id=5d8a81f83b59 (link may not be stable)
[3/3] ARM64: reloc: fix relocation error for big fat bareboxes
      https://git.pengutronix.de/cgit/barebox/commit/?id=fdb311841c61 (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-05-15  5:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-13  9:58 [PATCH master 1/3] mci: core: reset number of parttions on card probe failure Ahmad Fatoum
2024-05-13  9:58 ` [PATCH master 2/3] mci: core: remove HS200 from mci_timing_is_ddr Ahmad Fatoum
2024-05-13  9:58 ` [PATCH master 3/3] ARM64: reloc: fix relocation error for big fat bareboxes Ahmad Fatoum
2024-05-15  5:54 ` [PATCH master 1/3] mci: core: reset number of parttions on card probe failure Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox