Skip to contentSkip to conversation

misc fixes building sandbox 64-bit allyesconfig

PATCH Applied Ahmad Fatoum 2 participants 21 messages Jun 12, 2023 – Jun 13, 2023

Subsystems (14)
lore
Share & tools
lore
#0 lore raw

cover misc fixes building sandbox 64-bit allyesconfig

Eventually, I want to run static analysis against the configuration, but this series fixed build warnings/errors just compiling it normally with GCC 13 and clang 14.

The critical parts were factored into their own series, so this can go into next first.

Ahmad Fatoum (19):
clk: always define clk_prepare_enable/disable
clk: define clk_get_parent stub
pci: disable building CONFIG_PCI when CONFIG_COMPILE_TEST
mci: tegra: fix base address constant to be hexadecimal
ata: ide-sff: fix warnings when compiling as 64-bit
video: bochs: remove dependency on PCI header in common part
commands: ubsan: hide pointer provenance used to trigger UB
test: self: printf: silence clang warnings
crypto: caam - fix pointer to u32 casts
crypto: imx-scc: fix u32 to pointer casts
mci: sdhci: dove: fix pointer to u32 casts
lib: make_directory: return -ENOMEM on allocation failure include <linux/idr.h>: handle OOM gracefully inside idr_alloc_one
mci: tegra: use correct types for mmio and DMA address
mtd: spi-nor: cadence: fix types
video: simplefb-fixup: warn on framebuffers >= 4G
watchdog: imx28: use correct constant for computing timeout_max
firmware: mark firmware sections as having non-executable stack
phy: stm32: usb: depend on COMMON_CLK

 commands/ubsan.c                      |  2 ++
 drivers/ata/ide-sff.c                 |  8 ++++----
 drivers/crypto/caam/jr.c              |  2 +-
 drivers/crypto/caam/rng_self_test.c   |  2 +-
 drivers/crypto/imx-scc/scc.c          |  6 +++---
 drivers/mci/dove-sdhci.c              | 20 +++++++++++++-------
 drivers/mci/tegra-sdmmc.c             | 11 ++++++-----
 drivers/mtd/spi-nor/cadence-quadspi.c |  8 +++-----
 drivers/pci/Kconfig                   |  2 +-
 drivers/phy/Kconfig                   |  1 +
 drivers/video/bochs/bochs_hw.c        |  1 -
 drivers/video/simplefb-fixup.c        | 10 +++++++---
 drivers/watchdog/im28wd.c             |  2 +-
 firmware/Makefile                     |  1 +
 include/linux/clk.h                   | 11 +++++++++--
 include/linux/idr.h                   |  2 ++
 lib/make_directory.c                  |  3 +++
 test/self/Makefile                    |  2 +-
 18 files changed, 59 insertions(+), 35 deletions(-)
Signature · 1 line
2.39.2
#1 lore raw

PATCH 1/19 clk: always define clk_prepare_enable/disable

clk_enable/clk_disable have stubs defined for !HAVE_CLK. By moving t clk_prepare_enable/disable definitions, we can reuse them for the prepare helpers as well.

---
 include/linux/clk.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
include/linux/clk.h +3 -2
index c78132d40582..60534ddb732c 100644
@@ -72,7 +72,6 @@ struct clk *clk_get(struct device *dev, const char *id);
  * Returns success (0) or negative errno.
  */
 int clk_enable(struct clk *clk);
-#define clk_prepare_enable(clk) clk_enable(clk)
 
 /**
  * clk_disable - inform the system when the clock source is no longer required.
@@ -87,7 +86,6 @@ int clk_enable(struct clk *clk);
  * disabled.
  */
 void clk_disable(struct clk *clk);
-#define clk_disable_unprepare(clk) clk_disable(clk)
 
 /**
  * clk_get_rate - obtain the current clock rate (in Hz) for a clock source.
@@ -206,6 +204,9 @@ static inline int clk_set_rate(struct clk *clk, unsigned long rate)
 }
 #endif
 
+#define clk_prepare_enable(clk) clk_enable(clk)
+#define clk_disable_unprepare(clk) clk_disable(clk)
+
 static inline void clk_put(struct clk *clk)
 {
 }
Signature · 1 line
2.39.2
#2 lore raw

PATCH 2/19 clk: define clk_get_parent stub

In reply to Ahmad Fatoum

clk_get_parent is used in stm32_ltdc driver, which can be compiled on !HAVE_CLK platforms, because it can be selected when COMPILE_TEST=y.

This leads to a build error, because clk_get_parent wasn't defined in that case. Fix this.

---
 include/linux/clk.h | 6 ++++++
 1 file changed, 6 insertions(+)
include/linux/clk.h +6 -0
index 60534ddb732c..8509d5ece9d5 100644
@@ -179,6 +179,11 @@ static inline struct clk *clk_get(struct device *dev, const char *id)
 	return NULL;
 }
 
+static inline struct clk *clk_get_parent(struct clk *clk)
+{
+	return NULL;
+}
+
 static inline int clk_enable(struct clk *clk)
 {
 	return 0;
@@ -744,6 +749,7 @@ static inline unsigned int of_clk_get_parent_count(struct device_node *np)
 {
 	return 0;
 }
+
 static inline int of_clk_init(void)
 {
 	return 0;
Signature · 1 line
2.39.2
#3 lore raw

PATCH 3/19 pci: disable building CONFIG_PCI when CONFIG_COMPILE_TEST

In reply to Ahmad Fatoum

Architectures enabling HW_HAS_PCI are expected to also define <asm/pci.h>. Giving HW_HAS_PCI a prompt can thus lead to build errors on architectures that don't really support PCI. Remove the prompt again.

---
 drivers/pci/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/Kconfig +1 -1
index 32a9e831b9e3..39df54f215cf 100644
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 config HW_HAS_PCI
-	bool "Compile in PCI core" if COMPILE_TEST
+	bool
 
 if HW_HAS_PCI
 
Signature · 1 line
2.39.2
#4 lore raw

PATCH 4/19 mci: tegra: fix base address constant to be hexadecimal

In reply to Ahmad Fatoum

Tegra SoCs don't have MMC peripherals at decimal address 78000400 (hexadecimal: 0x4a63110), but they do at 0x78000400. Fix it.

---
 drivers/mci/tegra-sdmmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mci/tegra-sdmmc.c +1 -1
index f8ce6c8d7ba0..a6e2b3032057 100644
@@ -310,7 +310,7 @@ static int tegra_sdmmc_init(struct mci_host *mci, struct device *dev)
 	/* sdmmc1 and sdmmc3 on T30 need a bit of padctrl init */
 	if (of_device_is_compatible(mci->hw_dev->of_node,
 				    "nvidia,tegra30-sdhci") &&
-			((u32)regs == 0x78000000 || (u32)regs == 78000400)) {
+			((u32)regs == 0x78000000 || (u32)regs == 0x78000400)) {
 		val = readl(regs + TEGRA_SDMMC_SDMEMCOMPPADCTRL);
 		val &= 0xfffffff0;
 		val |= 0x7 << TEGRA_SDMMC_SDMEMCOMPPADCTRL_VREF_SEL_SHIFT;
Signature · 1 line
2.39.2
#5 lore raw

PATCH 5/19 ata: ide-sff: fix warnings when compiling as 64-bit

In reply to Ahmad Fatoum

Driver is applicable to both IDEs with I/O port and MMIO control. This is differentiated by ide->io.mmio. Compiler can't follow that and criticizes casting pointers to 32-bit integers on 64-bit architectures. Adjust the casts to silence this false positive.

---
 drivers/ata/ide-sff.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/ata/ide-sff.c +4 -4
index 69055e058503..f25dfeae4328 100644
@@ -26,7 +26,7 @@ static inline uint8_t ata_rd_byte(struct ide_port *ide, void __iomem *addr)
 	if (ide->io.mmio)
 		return readb(addr);
 	else
-		return (uint8_t) inb((int) addr);
+		return (uint8_t) inb((ulong)addr);
 }
 
 /**
@@ -42,7 +42,7 @@ static inline void ata_wr_byte(struct ide_port *ide, uint8_t value,
 	if (ide->io.mmio)
 		writeb(value, addr);
 	else
-		outb(value, (int) addr);
+		outb(value, (ulong)addr);
 }
 
 /**
@@ -57,7 +57,7 @@ static inline uint16_t ata_rd_word(struct ide_port *ide,
 	if (ide->io.mmio)
 		return readw(addr);
 	else
-		return (uint16_t) inw((int) addr);
+		return (uint16_t) inw((ulong)addr);
 }
 
 /**
@@ -73,7 +73,7 @@ static inline void ata_wr_word(struct ide_port *ide, uint16_t value,
 	if (ide->io.mmio)
 		writew(value, addr);
 	else
-		outw(value, (int) addr);
+		outw(value, (ulong)addr);
 }
 
 /**
Signature · 1 line
2.39.2
#6 lore raw

PATCH 6/19 video: bochs: remove dependency on PCI header in common part

In reply to Ahmad Fatoum

bochs_hw is the common code that's called into from both PCI and ISA Bochs drivers. It has no need to include the PCI header, so drop it.

---
 drivers/video/bochs/bochs_hw.c | 1 -
 1 file changed, 1 deletion(-)
drivers/video/bochs/bochs_hw.c +0 -1
index 48de5ea0bd7a..60439ddee576 100644
@@ -8,7 +8,6 @@
 
 #include <common.h>
 #include <driver.h>
-#include <linux/pci.h>
 #include <fb.h>
 #include "../edid.h"
 #include "bochs_hw.h"
Signature · 1 line
2.39.2
#7 lore raw

PATCH 7/19 commands: ubsan: hide pointer provenance used to trigger UB

In reply to Ahmad Fatoum

The ubsan command invokes various sort of undefined behavior to verify that the Undefined Behavior Sanitizer works as expected. Compiler warns about some of this, which is not helpful, so work around the warning.

---
 commands/ubsan.c | 2 ++
 1 file changed, 2 insertions(+)
commands/ubsan.c +2 -0
index 620b4774c3c2..4a9716139c4b 100644
@@ -102,6 +102,8 @@ static void test_ubsan_object_size_mismatch(void)
 	volatile long long *ptr, val2;
 
 	ptr = (long long *)&val;
+	OPTIMIZER_HIDE_VAR(ptr);
+
 	val2 = *ptr;
 }
 
Signature · 1 line
2.39.2
#8 lore raw

PATCH 8/19 test: self: printf: silence clang warnings

In reply to Ahmad Fatoum

We added -Wno-format-security a short while back, because we didn't want GCC to warn us about possible format string issues in the self test that's meant to exercise the printf facility. In a similar vein, clang also sees potential problems in the code, so hide it, just for that file, with -Wno-format.

---
 test/self/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
test/self/Makefile +1 -1
index 080ef303cc35..78a337810d1f 100644
@@ -3,7 +3,7 @@
 obj-$(CONFIG_SELFTEST) += core.o
 obj-$(CONFIG_SELFTEST_MALLOC) += malloc.o
 obj-$(CONFIG_SELFTEST_PRINTF) += printf.o
-CFLAGS_printf.o += -Wno-format-security
+CFLAGS_printf.o += -Wno-format-security -Wno-format
 obj-$(CONFIG_SELFTEST_PROGRESS_NOTIFIER) += progress-notifier.o
 obj-$(CONFIG_SELFTEST_OF_MANIPULATION) += of_manipulation.o of_manipulation.dtb.o
 obj-$(CONFIG_SELFTEST_ENVIRONMENT_VARIABLES) += envvar.o
Signature · 1 line
2.39.2
#9 lore raw

PATCH 9/19 crypto: caam - fix pointer to u32 casts

In reply to Ahmad Fatoum

For 64-bit systems, we only have CAAM initialization support in PBL running as BL2 in EL3, but nothing for barebox proper. Understandably, trying to compile the CAAM code for 64-bit leads to warnings about casts between pointers and smaller integers. A sync with Linux to get 64-bit support is probably in-order for barebox proper CAAM drivers to actually work on i.MX8M, but for now, let's just fix the warnings.

---
 drivers/crypto/caam/jr.c            | 2 +-
 drivers/crypto/caam/rng_self_test.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/caam/jr.c +1 -1
index f15902866998..b5d70b24b380 100644
@@ -207,7 +207,7 @@ int caam_jr_enqueue(struct device *dev, u32 *desc,
 	}
 
 	head_entry = &jrp->entinfo[head];
-	head_entry->desc_addr_virt = phys_to_virt((u32) desc);
+	head_entry->desc_addr_virt = desc;
 	head_entry->desc_size = desc_size;
 	head_entry->callbk = (void *)cbk;
 	head_entry->cbkarg = areq;
drivers/crypto/caam/rng_self_test.c +1 -1
index 3b20f8aad293..b6fcc3bc0947 100644
@@ -116,7 +116,7 @@ static void construct_rng_self_test_jobdesc(u32 *desc, const u32 *rng_st_dsc, u8
 	}
 
 	/* Replace destination address in the descriptor */
-	desc[result_addr_idx] = (u32)res_addr;
+	desc[result_addr_idx] = virt_to_phys(res_addr);
 }
 
 /* rng_self_test_done() - callback for caam_jr_enqueue */
Signature · 1 line
2.39.2
#10 lore raw

PATCH 10/19 crypto: imx-scc: fix u32 to pointer casts

In reply to Ahmad Fatoum

We don't deploy the driver to 64-bit systems, but fixing the lone warning we get while build testing is easy enough, so let's do that.

---
 drivers/crypto/imx-scc/scc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/crypto/imx-scc/scc.c +3 -3
index afd7ebe9cb2e..fcff7e9e6e56 100644
@@ -228,9 +228,9 @@ static int imx_scc_ablkcipher_next(struct imx_scc_ctx *ctx,
 	if (err)
 		return err;
 
-	dev_dbg(scc->dev, "Start encryption (0x%p/0x%p)\n",
-		(void *)readl(scc->base + SCC_SCM_RED_START),
-		(void *)readl(scc->base + SCC_SCM_BLACK_START));
+	dev_dbg(scc->dev, "Start encryption (0x%x/0x%x)\n",
+		readl(scc->base + SCC_SCM_RED_START),
+		readl(scc->base + SCC_SCM_BLACK_START));
 
 	/* clear interrupt control registers */
 	writel(SCC_SCM_INTR_CTRL_CLR_INTR,
Signature · 1 line
2.39.2
#11 lore raw

PATCH 11/19 mci: sdhci: dove: fix pointer to u32 casts

In reply to Ahmad Fatoum

The dove SDHCI driver doesn't fully work on 64-bit, which
is ok as the SoC is ARMv7-only anways. We do want to be able to build test the driver though, so replace straight casts of addr with lower_32_bits(virt_to_phys(addr)), which has the same result, but makes it clear that the upper 32 bit are truncated and silences the compiler warnings.

---
 drivers/mci/dove-sdhci.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
drivers/mci/dove-sdhci.c +13 -7
index 9e6da6a81be1..5954058e6b30 100644
@@ -87,9 +87,11 @@ static int dove_sdhci_mci_send_cmd(struct mci_host *mci, struct mci_cmd *cmd,
 	if (data) {
 		num_bytes = data->blocks * data->blocksize;
 		if (data->flags & MMC_DATA_READ)
-			sdhci_write32(&host->sdhci, SDHCI_DMA_ADDRESS, (u32)data->dest);
+			sdhci_write32(&host->sdhci, SDHCI_DMA_ADDRESS,
+				      lower_32_bits(virt_to_phys(data->dest)));
 		else
-			sdhci_write32(&host->sdhci, SDHCI_DMA_ADDRESS, (u32)data->src);
+			sdhci_write32(&host->sdhci, SDHCI_DMA_ADDRESS,
+				      lower_32_bits(virt_to_phys(data->src)));
 		sdhci_write16(&host->sdhci, SDHCI_BLOCK_SIZE, SDHCI_DMA_BOUNDARY_512K |
 				SDHCI_TRANSFER_BLOCK_SIZE(data->blocksize));
 		sdhci_write16(&host->sdhci, SDHCI_BLOCK_COUNT, data->blocks);
@@ -97,10 +99,12 @@ static int dove_sdhci_mci_send_cmd(struct mci_host *mci, struct mci_cmd *cmd,
 
 
 		if (data->flags & MMC_DATA_WRITE)
-			dma_sync_single_for_device(host->mci.hw_dev, (unsigned long)data->src,
+			dma_sync_single_for_device(host->mci.hw_dev,
+						   lower_32_bits(virt_to_phys(data->src)),
 						    num_bytes, DMA_TO_DEVICE);
 		else
-			dma_sync_single_for_device(host->mci.hw_dev, (unsigned long)data->dest,
+			dma_sync_single_for_device(host->mci.hw_dev,
+						   lower_32_bits(virt_to_phys(data->dest)),
 						    num_bytes, DMA_FROM_DEVICE);
 	}
 
@@ -126,11 +130,13 @@ static int dove_sdhci_mci_send_cmd(struct mci_host *mci, struct mci_cmd *cmd,
 
 	if (data) {
 		if (data->flags & MMC_DATA_WRITE)
-			dma_sync_single_for_cpu(host->mci.hw_dev, (unsigned long)data->src,
+			dma_sync_single_for_cpu(host->mci.hw_dev,
+						lower_32_bits(virt_to_phys(data->src)),
 						num_bytes, DMA_TO_DEVICE);
 		else
-			dma_sync_single_for_cpu(host->mci.hw_dev, (unsigned long)data->dest,
-					 num_bytes, DMA_FROM_DEVICE);
+			dma_sync_single_for_cpu(host->mci.hw_dev,
+						lower_32_bits(virt_to_phys(data->dest)),
+						num_bytes, DMA_FROM_DEVICE);
 
 		ret = dove_sdhci_wait_for_done(host, SDHCI_INT_XFER_COMPLETE);
 		if (ret) {
Signature · 1 line
2.39.2
#12 lore raw

PATCH 12/19 lib: make_directory: return -ENOMEM on allocation failure

In reply to Ahmad Fatoum

mkdir calls strdup on the dir that's passed in, but doesn't account for allocation failure. Have it return -ENOMEM in that case.

---
 lib/make_directory.c | 3 +++
 1 file changed, 3 insertions(+)
lib/make_directory.c +3 -0
index 7db93ded8817..59ac87e6bfdf 100644
@@ -19,6 +19,9 @@ STATIC int make_directory(const char *dir)
 	char c;
 	int ret = 0;
 
+	if (!s)
+		return -ENOMEM;
+
 	do {
 		c = 0;
 
Signature · 1 line
2.39.2
#13 lore raw

PATCH 13/19 include <linux/idr.h>: handle OOM gracefully inside idr_alloc_one

In reply to Ahmad Fatoum

The result of allocating a struct idr is dereferenced unconditionally. Return -ENOMEM in that case instead.

---
 include/linux/idr.h | 2 ++
 1 file changed, 2 insertions(+)
include/linux/idr.h +2 -0
index 50c9e3f81ade..12494b1f01cb 100644
@@ -54,6 +54,8 @@ static inline int idr_alloc_one(struct idr *head, void *ptr, int start)
 		return -EBUSY;
 
 	idr = malloc(sizeof(*idr));
+	if (!idr)
+		return -ENOMEM;
 
 	idr->id = start;
 	idr->ptr = ptr;
Signature · 1 line
2.39.2
#14 lore raw

PATCH 14/19 mci: tegra: use correct types for mmio and DMA address

In reply to Ahmad Fatoum

We don't support any ARMv8 Tegra SoCs, but we still want to be able to build test the driver when compiling for 64-bit though, so replace straight casts of addr with lower_32_bits(virt_to_phys(addr)), which has the same result, but makes it clear that the upper 32 bit are truncated and silences the compiler warnings.

---
 drivers/mci/tegra-sdmmc.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/mci/tegra-sdmmc.c +6 -5
index a6e2b3032057..e940edf3227a 100644
@@ -115,11 +115,13 @@ static int tegra_sdmmc_send_cmd(struct mci_host *mci, struct mci_cmd *cmd,
 		if (data->flags & MMC_DATA_WRITE) {
 			dma_sync_single_for_device(mci->hw_dev, (unsigned long)data->src,
 						   num_bytes, DMA_TO_DEVICE);
-			sdhci_write32(&host->sdhci, SDHCI_DMA_ADDRESS, (u32)data->src);
+			sdhci_write32(&host->sdhci, SDHCI_DMA_ADDRESS,
+				      lower_32_bits(virt_to_phys(data->src)));
 		} else {
 			dma_sync_single_for_device(mci->hw_dev, (unsigned long)data->dest,
 						   num_bytes, DMA_FROM_DEVICE);
-			sdhci_write32(&host->sdhci, SDHCI_DMA_ADDRESS, (u32)data->dest);
+			sdhci_write32(&host->sdhci, SDHCI_DMA_ADDRESS,
+				      lower_32_bits(virt_to_phys(data->dest)));
 		}
 
 		sdhci_write32(&host->sdhci, SDHCI_BLOCK_SIZE__BLOCK_COUNT,
@@ -308,9 +310,8 @@ static int tegra_sdmmc_init(struct mci_host *mci, struct device *dev)
 	sdhci_write32(&host->sdhci, TEGRA_SDMMC_PWR_CNTL, val);
 
 	/* sdmmc1 and sdmmc3 on T30 need a bit of padctrl init */
-	if (of_device_is_compatible(mci->hw_dev->of_node,
-				    "nvidia,tegra30-sdhci") &&
-			((u32)regs == 0x78000000 || (u32)regs == 0x78000400)) {
+	if (of_device_is_compatible(mci->hw_dev->of_node, "nvidia,tegra30-sdhci") &&
+	    (regs == IOMEM(0x78000000) || regs == IOMEM(0x78000400))) {
 		val = readl(regs + TEGRA_SDMMC_SDMEMCOMPPADCTRL);
 		val &= 0xfffffff0;
 		val |= 0x7 << TEGRA_SDMMC_SDMEMCOMPPADCTRL_VREF_SEL_SHIFT;
Signature · 1 line
2.39.2
#15 lore raw

PATCH 15/19 mtd: spi-nor: cadence: fix types

In reply to Ahmad Fatoum

The JH7100 for which we have basic support has 64-bit CPUs and a cadence quad SPI controller. Building the driver for that CPU would result in a couple of warning due to casting 64-bit pointers to 32-bit integers. Fix this.

---
 drivers/mtd/spi-nor/cadence-quadspi.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/mtd/spi-nor/cadence-quadspi.c +3 -5
index 5079127be43a..763858567b9c 100644
@@ -336,8 +336,7 @@ static int cqspi_command_read(struct spi_nor *nor,
 
 	if (!n_rx || n_rx > CQSPI_STIG_DATA_LEN_MAX || rxbuf == NULL) {
 		dev_err(nor->dev,
-			"Invalid input argument, len %d rxbuf 0x%08x\n", n_rx,
-			(unsigned int)rxbuf);
+			"Invalid input argument, len %d rxbuf 0x%p\n", n_rx, rxbuf);
 		return -EINVAL;
 	}
 
@@ -382,8 +381,7 @@ static __maybe_unused int cqspi_command_write(struct spi_nor *nor,
 
 	if (n_tx > 4 || (n_tx && txbuf == NULL)) {
 		dev_err(nor->dev,
-			"Invalid input argument, cmdlen %d txbuf 0x%08x\n",
-			n_tx, (unsigned int)txbuf);
+			"Invalid input argument, cmdlen %d txbuf 0x%p\n", n_tx, txbuf);
 		return -EINVAL;
 	}
 
@@ -422,7 +420,7 @@ static int cqspi_indirect_read_setup(struct spi_nor *nor,
 {
 	struct cqspi_flash_pdata *f_pdata;
 	struct cqspi_st *cqspi = nor->priv;
-	unsigned int ahb_base = (unsigned int) cqspi->ahb_base;
+	phys_addr_t ahb_base = virt_to_phys(cqspi->ahb_base);
 	void __iomem *reg_base = cqspi->iobase;
 	unsigned int dummy_clk = 0;
 	unsigned int dummy_bytes;
Signature · 1 line
2.39.2
#16 lore raw

PATCH 16/19 video: simplefb-fixup: warn on framebuffers >= 4G

In reply to Ahmad Fatoum

Building simplefb-fixup for 64-bit has the compiler inform us that the code doesn't handle 64-bit addresses as it should. Silence the warnings and have the code return -ENOSYS if this happens.

---
 drivers/video/simplefb-fixup.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/video/simplefb-fixup.c +7 -3
index a2c59de364a5..65e0281a189f 100644
@@ -90,6 +90,7 @@ static int simplefb_create_node(struct device_node *root,
 				const struct fb_info *fbi, const char *format)
 {
 	struct device_node *node;
+	phys_addr_t screen_base;
 	u32 cells[2];
 	int ret;
 
@@ -105,7 +106,11 @@ static int simplefb_create_node(struct device_node *root,
 	if (ret)
 		return ret;
 
-	cells[0] = cpu_to_be32((u32)fbi->screen_base);
+	screen_base = virt_to_phys(fbi->screen_base);
+	if (upper_32_bits(screen_base))
+		return -ENOSYS;
+
+	cells[0] = cpu_to_be32(lower_32_bits(screen_base));
 	cells[1] = cpu_to_be32(fbi->line_length * fbi->yres);
 	ret = of_set_property(node, "reg", cells, sizeof(cells[0]) * 2, 1);
 	if (ret < 0)
@@ -130,8 +135,7 @@ static int simplefb_create_node(struct device_node *root,
 	if (ret < 0)
 		return ret;
 
-	of_add_reserve_entry((u32)fbi->screen_base,
-			(u32)fbi->screen_base + fbi->screen_size);
+	of_add_reserve_entry(screen_base, screen_base + fbi->screen_size);
 
 	return of_property_write_string(node, "status", "okay");
 }
Signature · 1 line
2.39.2
#17 lore raw

PATCH 17/19 watchdog: imx28: use correct constant for computing timeout_max

In reply to Ahmad Fatoum

timeout_max is a 32-bit variable, so storing ULONG_MAX / WDOG_TICK_RATE into it causes a wrap around on 64-bit systems. As the SoC is a 32-bit one, it's likely the original intention was for it to be U32_MAX instead.

---
 drivers/watchdog/im28wd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/im28wd.c +1 -1
index 7df2e2d99506..b52e5851750b 100644
@@ -187,7 +187,7 @@ static int imx28_wd_probe(struct device *dev)
 		return PTR_ERR(iores);
 	priv->regs = IOMEM(iores->start);
 	priv->wd.set_timeout = imx28_watchdog_set_timeout;
-	priv->wd.timeout_max = ULONG_MAX / WDOG_TICK_RATE;
+	priv->wd.timeout_max = U32_MAX / WDOG_TICK_RATE;
 	priv->wd.hwdev = dev;
 
 	if (!(readl(priv->regs + MXS_RTC_STAT) & MXS_RTC_STAT_WD_PRESENT)) {
Signature · 1 line
2.39.2
#18 lore raw

PATCH 18/19 firmware: mark firmware sections as having non-executable stack

In reply to Ahmad Fatoum

allyesconfig on sandbox detects that firmware misses the annotation, which we already have for environment, DTs and other generated assembly files. Fix it there too.

---
 firmware/Makefile | 1 +
 1 file changed, 1 insertion(+)
firmware/Makefile +1 -0
index 75812cb6bf24..efdd5c0da541 100644
@@ -45,6 +45,7 @@ ASM_ALIGN = $(if $(CONFIG_64BIT),3,2)
 
 filechk_fwbin = { \
 	echo "/* Generated by $(src)/Makefile */"		;\
+	echo ".section .note.GNU-stack,\"\",%progbits"		;\
 	echo "    .section $2,\"$3\""				;\
 	echo "    .p2align $(ASM_ALIGN)"			;\
 	echo ".global _fw_$(FWSTR)_start"			;\
Signature · 1 line
2.39.2
#19 lore raw

PATCH 19/19 phy: stm32: usb: depend on COMMON_CLK

In reply to Ahmad Fatoum

The stm32-usbphyc driver registers a clock with the common clock framework, so compile testing without COMMON_CLK understandably fails and can't be expected to work. Fix the allyesconfig build on sandbox by making the COMMON_CLK dependency explicit.

---
 drivers/phy/Kconfig | 1 +
 1 file changed, 1 insertion(+)
drivers/phy/Kconfig +1 -0
index 4df9bd0523bc..52c792914909 100644
@@ -29,6 +29,7 @@ source "drivers/phy/rockchip/Kconfig"
 config PHY_STM32_USBPHYC
 	tristate "STM32 USB HS PHY Controller"
 	depends on ARCH_STM32MP || COMPILE_TEST
+	depends on COMMON_CLK
 	help
 	  Enable this to support the High-Speed USB transceivers that are part
 	  of some STMicroelectronics STM32 SoCs.
Signature · 1 line
2.39.2
Applied
#20 lore raw
In reply to Ahmad Fatoum
Quoted 19 lines · Ahmad Fatoum

Eventually, I want to run static analysis against the configuration, but this series fixed build warnings/errors just compiling it normally with GCC 13 and clang 14.

The critical parts were factored into their own series, so this can go into next first.

Ahmad Fatoum (19):
clk: always define clk_prepare_enable/disable
clk: define clk_get_parent stub
pci: disable building CONFIG_PCI when CONFIG_COMPILE_TEST
mci: tegra: fix base address constant to be hexadecimal
ata: ide-sff: fix warnings when compiling as 64-bit
video: bochs: remove dependency on PCI header in common part
commands: ubsan: hide pointer provenance used to trigger UB
test: self: printf: silence clang warnings
crypto: caam - fix pointer to u32 casts
crypto: imx-scc: fix u32 to pointer casts
mci: sdhci: dove: fix pointer to u32 casts

Quoted 8 lines

lib: make_directory: return -ENOMEM on allocation failure include <linux/idr.h>: handle OOM gracefully inside idr_alloc_one
mci: tegra: use correct types for mmio and DMA address
mtd: spi-nor: cadence: fix types
video: simplefb-fixup: warn on framebuffers >= 4G
watchdog: imx28: use correct constant for computing timeout_max
firmware: mark firmware sections as having non-executable stack
phy: stm32: usb: depend on COMMON_CLK

Applied, thanks

Sascha

Quoted 26 lines
 commands/ubsan.c                      |  2 ++
 drivers/ata/ide-sff.c                 |  8 ++++----
 drivers/crypto/caam/jr.c              |  2 +-
 drivers/crypto/caam/rng_self_test.c   |  2 +-
 drivers/crypto/imx-scc/scc.c          |  6 +++---
 drivers/mci/dove-sdhci.c              | 20 +++++++++++++-------
 drivers/mci/tegra-sdmmc.c             | 11 ++++++-----
 drivers/mtd/spi-nor/cadence-quadspi.c |  8 +++-----
 drivers/pci/Kconfig                   |  2 +-
 drivers/phy/Kconfig                   |  1 +
 drivers/video/bochs/bochs_hw.c        |  1 -
 drivers/video/simplefb-fixup.c        | 10 +++++++---
 drivers/watchdog/im28wd.c             |  2 +-
 firmware/Makefile                     |  1 +
 include/linux/clk.h                   | 11 +++++++++--
 include/linux/idr.h                   |  2 ++
 lib/make_directory.c                  |  3 +++
 test/self/Makefile                    |  2 +-
 18 files changed, 59 insertions(+), 35 deletions(-)
Signature · 1 line
2.39.2
Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |