Subject: [PATCH 0/6] sparc32: build fixes for all{yes,mod}config builds

This is a small set of patches that address build breakage with
allyesconfig / allmodconfig.

This solves some, but not all, build breakage.
The parport fix depends on the previous patch, the rest are independent
fixes.

Signed-off-by: Sam Ravnborg <[email protected]>
---
Sam Ravnborg (6):
sparc32: Use generic cmpdi2/ucmpdi2 variants
sparc32: Fix build with trapbase
mtd: maps: sun_uflash: Declare uflash_devinit static
usb: host: uhci-grlib.c: Fix build, add platform_device
sparc32: Do not select GENERIC_ISA_DMA
sparc32: Fix parport build with sparc32

arch/sparc/Kconfig | 6 +-
arch/sparc/include/asm/parport.h | 259 +-----------------------------------
arch/sparc/include/asm/parport_64.h | 256 +++++++++++++++++++++++++++++++++++
arch/sparc/kernel/irq_32.c | 6 +-
arch/sparc/kernel/kernel.h | 8 +-
arch/sparc/kernel/kgdb_32.c | 4 +-
arch/sparc/kernel/leon_smp.c | 6 +-
arch/sparc/kernel/setup_32.c | 4 +-
arch/sparc/lib/Makefile | 4 +-
arch/sparc/lib/cmpdi2.c | 28 ----
arch/sparc/lib/ucmpdi2.c | 20 ---
drivers/mtd/maps/sun_uflash.c | 2 +-
drivers/usb/host/uhci-grlib.c | 1 +
13 files changed, 283 insertions(+), 321 deletions(-)
---
base-commit: 626db6ee8ee1edac206610db407114aa83b53fd3
change-id: 20240223-sam-fix-sparc32-all-builds-0a0403d6e1b3

Best regards,
--
Sam Ravnborg <[email protected]>



Subject: [PATCH 3/6] mtd: maps: sun_uflash: Declare uflash_devinit static

From: Sam Ravnborg <[email protected]>

This fixes the following warning:
sun_uflash.c:50:5: error: no previous prototype for 'uflash_devinit'

Signed-off-by: Sam Ravnborg <[email protected]>
Cc: Andreas Larsson <[email protected]>
Cc: "David S. Miller" <[email protected]>
---
drivers/mtd/maps/sun_uflash.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/maps/sun_uflash.c b/drivers/mtd/maps/sun_uflash.c
index f58cfb15d6e8..b69dade3f7ad 100644
--- a/drivers/mtd/maps/sun_uflash.c
+++ b/drivers/mtd/maps/sun_uflash.c
@@ -47,7 +47,7 @@ struct map_info uflash_map_templ = {
.bankwidth = UFLASH_BUSWIDTH,
};

-int uflash_devinit(struct platform_device *op, struct device_node *dp)
+static int uflash_devinit(struct platform_device *op, struct device_node *dp)
{
struct uflash_dev *up;


--
2.34.1


Subject: [PATCH 4/6] usb: host: uhci-grlib.c: Fix build, add platform_device

From: Sam Ravnborg <[email protected]>

Fix the followig build error:
uhci-grlib.c:92:29: error: invalid use of undefined type 'struct platform_device'

The fix was straightforward, and no attempt was made to understand why
the build failed.

Signed-off-by: Sam Ravnborg <[email protected]>
Cc: Andreas Larsson <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
---
drivers/usb/host/uhci-grlib.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/usb/host/uhci-grlib.c b/drivers/usb/host/uhci-grlib.c
index ac3fc5970315..cfebb833668e 100644
--- a/drivers/usb/host/uhci-grlib.c
+++ b/drivers/usb/host/uhci-grlib.c
@@ -22,6 +22,7 @@
#include <linux/of_irq.h>
#include <linux/of_address.h>
#include <linux/of_platform.h>
+#include <linux/platform_device.h>

static int uhci_grlib_init(struct usb_hcd *hcd)
{

--
2.34.1


Subject: [PATCH 2/6] sparc32: Fix build with trapbase

From: Sam Ravnborg <[email protected]>

Fix the following build errors:
irq_32.c:258:7: error: array subscript [16, 79] is outside array bounds of 'struct tt_entry[1]
irq_32.c:271:14: error: assignment to 'struct tt_entry *' from incompatible pointer type 'struct tt_entry (*)[]

trapbase is a pointer to an array of tt_entry, but the code declared it
as a pointer so the compiler see a single entry and not an array.
Fix this by modifyinf the declaration to be an array, and modify all
users to take the address of the first member.

Signed-off-by: Sam Ravnborg <[email protected]>
Cc: Andreas Larsson <[email protected]>
Cc: "David S. Miller" <[email protected]>
---
arch/sparc/kernel/irq_32.c | 6 +++---
arch/sparc/kernel/kernel.h | 8 ++++----
arch/sparc/kernel/kgdb_32.c | 4 ++--
arch/sparc/kernel/leon_smp.c | 6 +++---
arch/sparc/kernel/setup_32.c | 4 ++--
5 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/arch/sparc/kernel/irq_32.c b/arch/sparc/kernel/irq_32.c
index e8452be5123b..8605dd710f3c 100644
--- a/arch/sparc/kernel/irq_32.c
+++ b/arch/sparc/kernel/irq_32.c
@@ -268,11 +268,11 @@ int sparc_floppy_request_irq(unsigned int irq, irq_handler_t irq_handler)
if (sparc_cpu_model != sparc_leon) {
struct tt_entry *trap_table;

- trap_table = &trapbase_cpu1;
+ trap_table = &trapbase_cpu1[0];
INSTANTIATE(trap_table)
- trap_table = &trapbase_cpu2;
+ trap_table = &trapbase_cpu2[0];
INSTANTIATE(trap_table)
- trap_table = &trapbase_cpu3;
+ trap_table = &trapbase_cpu3[0];
INSTANTIATE(trap_table)
}
#endif
diff --git a/arch/sparc/kernel/kernel.h b/arch/sparc/kernel/kernel.h
index 15da3c0597a5..a8fb7c0bf053 100644
--- a/arch/sparc/kernel/kernel.h
+++ b/arch/sparc/kernel/kernel.h
@@ -138,10 +138,10 @@ extern unsigned int t_nmi[];
extern unsigned int linux_trap_ipi15_sun4d[];
extern unsigned int linux_trap_ipi15_sun4m[];

-extern struct tt_entry trapbase;
-extern struct tt_entry trapbase_cpu1;
-extern struct tt_entry trapbase_cpu2;
-extern struct tt_entry trapbase_cpu3;
+extern struct tt_entry trapbase[];
+extern struct tt_entry trapbase_cpu1[];
+extern struct tt_entry trapbase_cpu2[];
+extern struct tt_entry trapbase_cpu3[];

extern char cputypval[];

diff --git a/arch/sparc/kernel/kgdb_32.c b/arch/sparc/kernel/kgdb_32.c
index 58ad3f7de1fb..3b2c673ec627 100644
--- a/arch/sparc/kernel/kgdb_32.c
+++ b/arch/sparc/kernel/kgdb_32.c
@@ -37,7 +37,7 @@ void pt_regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *regs)
gdb_regs[GDB_Y] = regs->y;
gdb_regs[GDB_PSR] = regs->psr;
gdb_regs[GDB_WIM] = 0;
- gdb_regs[GDB_TBR] = (unsigned long) &trapbase;
+ gdb_regs[GDB_TBR] = (unsigned long) &trapbase[0];
gdb_regs[GDB_PC] = regs->pc;
gdb_regs[GDB_NPC] = regs->npc;
gdb_regs[GDB_FSR] = 0;
@@ -72,7 +72,7 @@ void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p)

gdb_regs[GDB_PSR] = t->kpsr;
gdb_regs[GDB_WIM] = t->kwim;
- gdb_regs[GDB_TBR] = (unsigned long) &trapbase;
+ gdb_regs[GDB_TBR] = (unsigned long) &trapbase[0];
gdb_regs[GDB_PC] = t->kpc;
gdb_regs[GDB_NPC] = t->kpc + 4;
gdb_regs[GDB_FSR] = 0;
diff --git a/arch/sparc/kernel/leon_smp.c b/arch/sparc/kernel/leon_smp.c
index 991e9ad3d3e8..1ee393abc463 100644
--- a/arch/sparc/kernel/leon_smp.c
+++ b/arch/sparc/kernel/leon_smp.c
@@ -245,13 +245,13 @@ void __init leon_smp_done(void)

/* Free unneeded trap tables */
if (!cpu_present(1)) {
- free_reserved_page(virt_to_page(&trapbase_cpu1));
+ free_reserved_page(virt_to_page(&trapbase_cpu1[0]));
}
if (!cpu_present(2)) {
- free_reserved_page(virt_to_page(&trapbase_cpu2));
+ free_reserved_page(virt_to_page(&trapbase_cpu2[0]));
}
if (!cpu_present(3)) {
- free_reserved_page(virt_to_page(&trapbase_cpu3));
+ free_reserved_page(virt_to_page(&trapbase_cpu3[0]));
}
/* Ok, they are spinning and ready to go. */
smp_processors_ready = 1;
diff --git a/arch/sparc/kernel/setup_32.c b/arch/sparc/kernel/setup_32.c
index e3b72a7b46d3..704375c061e7 100644
--- a/arch/sparc/kernel/setup_32.c
+++ b/arch/sparc/kernel/setup_32.c
@@ -67,7 +67,7 @@ static void prom_sync_me(void)
__asm__ __volatile__("wr %0, 0x0, %%tbr\n\t"
"nop\n\t"
"nop\n\t"
- "nop\n\t" : : "r" (&trapbase));
+ "nop\n\t" : : "r" (&trapbase[0]));

prom_printf("PROM SYNC COMMAND...\n");
show_mem();
@@ -285,7 +285,7 @@ void __init setup_arch(char **cmdline_p)
int i;
unsigned long highest_paddr;

- sparc_ttable = &trapbase;
+ sparc_ttable = &trapbase[0];

/* Initialize PROM console and command line. */
*cmdline_p = prom_getbootargs();

--
2.34.1


Subject: [PATCH 5/6] sparc32: Do not select GENERIC_ISA_DMA

From: Sam Ravnborg <[email protected]>

sparc32 do not support generic isa dma, so do not select the symbol.
Without this fix, the following patch would break the build with a
missing prototype.

Signed-off-by: Sam Ravnborg <[email protected]>
Cc: Andreas Larsson <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Randy Dunlap <[email protected]>
Cc: Maciej W. Rozycki <[email protected]>
Fixes: 66bcd06099bb ("parport_pc: Also enable driver for PCI systems")
---
arch/sparc/Kconfig | 4 ----
1 file changed, 4 deletions(-)

diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 734f23daecca..d08a5662ea60 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -138,10 +138,6 @@ config HIGHMEM
default y if SPARC32
select KMAP_LOCAL

-config GENERIC_ISA_DMA
- bool
- default y if SPARC32
-
config PGTABLE_LEVELS
default 4 if 64BIT
default 3

--
2.34.1


Subject: [PATCH 6/6] sparc32: Fix parport build with sparc32

From: Sam Ravnborg <[email protected]>

include/asm/parport.h is sparc64 specific.
Rename it to parport_64.h and use the generic version for sparc32.

This fixed all{mod,yes}config build errors like:

parport_pc.c:(.text):undefined-reference-to-ebus_dma_enable
parport_pc.c:(.text):undefined-reference-to-ebus_dma_irq_enable
parport_pc.c:(.text):undefined-reference-to-ebus_dma_register

The errors occur as the sparc32 build references sparc64 symbols.

Signed-off-by: Sam Ravnborg <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Andreas Larsson <[email protected]>
Cc: Randy Dunlap <[email protected]>
Cc: Maciej W. Rozycki <[email protected]>
Closes: https://lore.kernel.org/r/[email protected]/
Fixes: 66bcd06099bb ("parport_pc: Also enable driver for PCI systems")
Cc: [email protected] # v5.18+
---
arch/sparc/include/asm/parport.h | 259 +-----------------------------------
arch/sparc/include/asm/parport_64.h | 256 +++++++++++++++++++++++++++++++++++
2 files changed, 263 insertions(+), 252 deletions(-)

diff --git a/arch/sparc/include/asm/parport.h b/arch/sparc/include/asm/parport.h
index 0a7ffcfd59cd..e2eed8f97665 100644
--- a/arch/sparc/include/asm/parport.h
+++ b/arch/sparc/include/asm/parport.h
@@ -1,256 +1,11 @@
/* SPDX-License-Identifier: GPL-2.0 */
-/* parport.h: sparc64 specific parport initialization and dma.
- *
- * Copyright (C) 1999 Eddie C. Dost ([email protected])
- */
+#ifndef ___ASM_SPARC_PARPORT_H
+#define ___ASM_SPARC_PARPORT_H

-#ifndef _ASM_SPARC64_PARPORT_H
-#define _ASM_SPARC64_PARPORT_H 1
-
-#include <linux/of.h>
-#include <linux/platform_device.h>
-
-#include <asm/ebus_dma.h>
-#include <asm/ns87303.h>
-#include <asm/prom.h>
-
-#define PARPORT_PC_MAX_PORTS PARPORT_MAX
-
-/*
- * While sparc64 doesn't have an ISA DMA API, we provide something that looks
- * close enough to make parport_pc happy
- */
-#define HAS_DMA
-
-#ifdef CONFIG_PARPORT_PC_FIFO
-static DEFINE_SPINLOCK(dma_spin_lock);
-
-#define claim_dma_lock() \
-({ unsigned long flags; \
- spin_lock_irqsave(&dma_spin_lock, flags); \
- flags; \
-})
-
-#define release_dma_lock(__flags) \
- spin_unlock_irqrestore(&dma_spin_lock, __flags);
+#if defined(__sparc__) && defined(__arch64__)
+#include <asm/parport_64.h>
+#else
+#include <asm-generic/parport.h>
+#endif
#endif

-static struct sparc_ebus_info {
- struct ebus_dma_info info;
- unsigned int addr;
- unsigned int count;
- int lock;
-
- struct parport *port;
-} sparc_ebus_dmas[PARPORT_PC_MAX_PORTS];
-
-static DECLARE_BITMAP(dma_slot_map, PARPORT_PC_MAX_PORTS);
-
-static inline int request_dma(unsigned int dmanr, const char *device_id)
-{
- if (dmanr >= PARPORT_PC_MAX_PORTS)
- return -EINVAL;
- if (xchg(&sparc_ebus_dmas[dmanr].lock, 1) != 0)
- return -EBUSY;
- return 0;
-}
-
-static inline void free_dma(unsigned int dmanr)
-{
- if (dmanr >= PARPORT_PC_MAX_PORTS) {
- printk(KERN_WARNING "Trying to free DMA%d\n", dmanr);
- return;
- }
- if (xchg(&sparc_ebus_dmas[dmanr].lock, 0) == 0) {
- printk(KERN_WARNING "Trying to free free DMA%d\n", dmanr);
- return;
- }
-}
-
-static inline void enable_dma(unsigned int dmanr)
-{
- ebus_dma_enable(&sparc_ebus_dmas[dmanr].info, 1);
-
- if (ebus_dma_request(&sparc_ebus_dmas[dmanr].info,
- sparc_ebus_dmas[dmanr].addr,
- sparc_ebus_dmas[dmanr].count))
- BUG();
-}
-
-static inline void disable_dma(unsigned int dmanr)
-{
- ebus_dma_enable(&sparc_ebus_dmas[dmanr].info, 0);
-}
-
-static inline void clear_dma_ff(unsigned int dmanr)
-{
- /* nothing */
-}
-
-static inline void set_dma_mode(unsigned int dmanr, char mode)
-{
- ebus_dma_prepare(&sparc_ebus_dmas[dmanr].info, (mode != DMA_MODE_WRITE));
-}
-
-static inline void set_dma_addr(unsigned int dmanr, unsigned int addr)
-{
- sparc_ebus_dmas[dmanr].addr = addr;
-}
-
-static inline void set_dma_count(unsigned int dmanr, unsigned int count)
-{
- sparc_ebus_dmas[dmanr].count = count;
-}
-
-static inline unsigned int get_dma_residue(unsigned int dmanr)
-{
- return ebus_dma_residue(&sparc_ebus_dmas[dmanr].info);
-}
-
-static int ecpp_probe(struct platform_device *op)
-{
- unsigned long base = op->resource[0].start;
- unsigned long config = op->resource[1].start;
- unsigned long d_base = op->resource[2].start;
- unsigned long d_len;
- struct device_node *parent;
- struct parport *p;
- int slot, err;
-
- parent = op->dev.of_node->parent;
- if (of_node_name_eq(parent, "dma")) {
- p = parport_pc_probe_port(base, base + 0x400,
- op->archdata.irqs[0], PARPORT_DMA_NOFIFO,
- op->dev.parent->parent, 0);
- if (!p)
- return -ENOMEM;
- dev_set_drvdata(&op->dev, p);
- return 0;
- }
-
- for (slot = 0; slot < PARPORT_PC_MAX_PORTS; slot++) {
- if (!test_and_set_bit(slot, dma_slot_map))
- break;
- }
- err = -ENODEV;
- if (slot >= PARPORT_PC_MAX_PORTS)
- goto out_err;
-
- spin_lock_init(&sparc_ebus_dmas[slot].info.lock);
-
- d_len = (op->resource[2].end - d_base) + 1UL;
- sparc_ebus_dmas[slot].info.regs =
- of_ioremap(&op->resource[2], 0, d_len, "ECPP DMA");
-
- if (!sparc_ebus_dmas[slot].info.regs)
- goto out_clear_map;
-
- sparc_ebus_dmas[slot].info.flags = 0;
- sparc_ebus_dmas[slot].info.callback = NULL;
- sparc_ebus_dmas[slot].info.client_cookie = NULL;
- sparc_ebus_dmas[slot].info.irq = 0xdeadbeef;
- strcpy(sparc_ebus_dmas[slot].info.name, "parport");
- if (ebus_dma_register(&sparc_ebus_dmas[slot].info))
- goto out_unmap_regs;
-
- ebus_dma_irq_enable(&sparc_ebus_dmas[slot].info, 1);
-
- /* Configure IRQ to Push Pull, Level Low */
- /* Enable ECP, set bit 2 of the CTR first */
- outb(0x04, base + 0x02);
- ns87303_modify(config, PCR,
- PCR_EPP_ENABLE |
- PCR_IRQ_ODRAIN,
- PCR_ECP_ENABLE |
- PCR_ECP_CLK_ENA |
- PCR_IRQ_POLAR);
-
- /* CTR bit 5 controls direction of port */
- ns87303_modify(config, PTR,
- 0, PTR_LPT_REG_DIR);
-
- p = parport_pc_probe_port(base, base + 0x400,
- op->archdata.irqs[0],
- slot,
- op->dev.parent,
- 0);
- err = -ENOMEM;
- if (!p)
- goto out_disable_irq;
-
- dev_set_drvdata(&op->dev, p);
-
- return 0;
-
-out_disable_irq:
- ebus_dma_irq_enable(&sparc_ebus_dmas[slot].info, 0);
- ebus_dma_unregister(&sparc_ebus_dmas[slot].info);
-
-out_unmap_regs:
- of_iounmap(&op->resource[2], sparc_ebus_dmas[slot].info.regs, d_len);
-
-out_clear_map:
- clear_bit(slot, dma_slot_map);
-
-out_err:
- return err;
-}
-
-static int ecpp_remove(struct platform_device *op)
-{
- struct parport *p = dev_get_drvdata(&op->dev);
- int slot = p->dma;
-
- parport_pc_unregister_port(p);
-
- if (slot != PARPORT_DMA_NOFIFO) {
- unsigned long d_base = op->resource[2].start;
- unsigned long d_len;
-
- d_len = (op->resource[2].end - d_base) + 1UL;
-
- ebus_dma_irq_enable(&sparc_ebus_dmas[slot].info, 0);
- ebus_dma_unregister(&sparc_ebus_dmas[slot].info);
- of_iounmap(&op->resource[2],
- sparc_ebus_dmas[slot].info.regs,
- d_len);
- clear_bit(slot, dma_slot_map);
- }
-
- return 0;
-}
-
-static const struct of_device_id ecpp_match[] = {
- {
- .name = "ecpp",
- },
- {
- .name = "parallel",
- .compatible = "ecpp",
- },
- {
- .name = "parallel",
- .compatible = "ns87317-ecpp",
- },
- {
- .name = "parallel",
- .compatible = "pnpALI,1533,3",
- },
- {},
-};
-
-static struct platform_driver ecpp_driver = {
- .driver = {
- .name = "ecpp",
- .of_match_table = ecpp_match,
- },
- .probe = ecpp_probe,
- .remove = ecpp_remove,
-};
-
-static int parport_pc_find_nonpci_ports(int autoirq, int autodma)
-{
- return platform_driver_register(&ecpp_driver);
-}
-
-#endif /* !(_ASM_SPARC64_PARPORT_H */
diff --git a/arch/sparc/include/asm/parport_64.h b/arch/sparc/include/asm/parport_64.h
new file mode 100644
index 000000000000..0a7ffcfd59cd
--- /dev/null
+++ b/arch/sparc/include/asm/parport_64.h
@@ -0,0 +1,256 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* parport.h: sparc64 specific parport initialization and dma.
+ *
+ * Copyright (C) 1999 Eddie C. Dost ([email protected])
+ */
+
+#ifndef _ASM_SPARC64_PARPORT_H
+#define _ASM_SPARC64_PARPORT_H 1
+
+#include <linux/of.h>
+#include <linux/platform_device.h>
+
+#include <asm/ebus_dma.h>
+#include <asm/ns87303.h>
+#include <asm/prom.h>
+
+#define PARPORT_PC_MAX_PORTS PARPORT_MAX
+
+/*
+ * While sparc64 doesn't have an ISA DMA API, we provide something that looks
+ * close enough to make parport_pc happy
+ */
+#define HAS_DMA
+
+#ifdef CONFIG_PARPORT_PC_FIFO
+static DEFINE_SPINLOCK(dma_spin_lock);
+
+#define claim_dma_lock() \
+({ unsigned long flags; \
+ spin_lock_irqsave(&dma_spin_lock, flags); \
+ flags; \
+})
+
+#define release_dma_lock(__flags) \
+ spin_unlock_irqrestore(&dma_spin_lock, __flags);
+#endif
+
+static struct sparc_ebus_info {
+ struct ebus_dma_info info;
+ unsigned int addr;
+ unsigned int count;
+ int lock;
+
+ struct parport *port;
+} sparc_ebus_dmas[PARPORT_PC_MAX_PORTS];
+
+static DECLARE_BITMAP(dma_slot_map, PARPORT_PC_MAX_PORTS);
+
+static inline int request_dma(unsigned int dmanr, const char *device_id)
+{
+ if (dmanr >= PARPORT_PC_MAX_PORTS)
+ return -EINVAL;
+ if (xchg(&sparc_ebus_dmas[dmanr].lock, 1) != 0)
+ return -EBUSY;
+ return 0;
+}
+
+static inline void free_dma(unsigned int dmanr)
+{
+ if (dmanr >= PARPORT_PC_MAX_PORTS) {
+ printk(KERN_WARNING "Trying to free DMA%d\n", dmanr);
+ return;
+ }
+ if (xchg(&sparc_ebus_dmas[dmanr].lock, 0) == 0) {
+ printk(KERN_WARNING "Trying to free free DMA%d\n", dmanr);
+ return;
+ }
+}
+
+static inline void enable_dma(unsigned int dmanr)
+{
+ ebus_dma_enable(&sparc_ebus_dmas[dmanr].info, 1);
+
+ if (ebus_dma_request(&sparc_ebus_dmas[dmanr].info,
+ sparc_ebus_dmas[dmanr].addr,
+ sparc_ebus_dmas[dmanr].count))
+ BUG();
+}
+
+static inline void disable_dma(unsigned int dmanr)
+{
+ ebus_dma_enable(&sparc_ebus_dmas[dmanr].info, 0);
+}
+
+static inline void clear_dma_ff(unsigned int dmanr)
+{
+ /* nothing */
+}
+
+static inline void set_dma_mode(unsigned int dmanr, char mode)
+{
+ ebus_dma_prepare(&sparc_ebus_dmas[dmanr].info, (mode != DMA_MODE_WRITE));
+}
+
+static inline void set_dma_addr(unsigned int dmanr, unsigned int addr)
+{
+ sparc_ebus_dmas[dmanr].addr = addr;
+}
+
+static inline void set_dma_count(unsigned int dmanr, unsigned int count)
+{
+ sparc_ebus_dmas[dmanr].count = count;
+}
+
+static inline unsigned int get_dma_residue(unsigned int dmanr)
+{
+ return ebus_dma_residue(&sparc_ebus_dmas[dmanr].info);
+}
+
+static int ecpp_probe(struct platform_device *op)
+{
+ unsigned long base = op->resource[0].start;
+ unsigned long config = op->resource[1].start;
+ unsigned long d_base = op->resource[2].start;
+ unsigned long d_len;
+ struct device_node *parent;
+ struct parport *p;
+ int slot, err;
+
+ parent = op->dev.of_node->parent;
+ if (of_node_name_eq(parent, "dma")) {
+ p = parport_pc_probe_port(base, base + 0x400,
+ op->archdata.irqs[0], PARPORT_DMA_NOFIFO,
+ op->dev.parent->parent, 0);
+ if (!p)
+ return -ENOMEM;
+ dev_set_drvdata(&op->dev, p);
+ return 0;
+ }
+
+ for (slot = 0; slot < PARPORT_PC_MAX_PORTS; slot++) {
+ if (!test_and_set_bit(slot, dma_slot_map))
+ break;
+ }
+ err = -ENODEV;
+ if (slot >= PARPORT_PC_MAX_PORTS)
+ goto out_err;
+
+ spin_lock_init(&sparc_ebus_dmas[slot].info.lock);
+
+ d_len = (op->resource[2].end - d_base) + 1UL;
+ sparc_ebus_dmas[slot].info.regs =
+ of_ioremap(&op->resource[2], 0, d_len, "ECPP DMA");
+
+ if (!sparc_ebus_dmas[slot].info.regs)
+ goto out_clear_map;
+
+ sparc_ebus_dmas[slot].info.flags = 0;
+ sparc_ebus_dmas[slot].info.callback = NULL;
+ sparc_ebus_dmas[slot].info.client_cookie = NULL;
+ sparc_ebus_dmas[slot].info.irq = 0xdeadbeef;
+ strcpy(sparc_ebus_dmas[slot].info.name, "parport");
+ if (ebus_dma_register(&sparc_ebus_dmas[slot].info))
+ goto out_unmap_regs;
+
+ ebus_dma_irq_enable(&sparc_ebus_dmas[slot].info, 1);
+
+ /* Configure IRQ to Push Pull, Level Low */
+ /* Enable ECP, set bit 2 of the CTR first */
+ outb(0x04, base + 0x02);
+ ns87303_modify(config, PCR,
+ PCR_EPP_ENABLE |
+ PCR_IRQ_ODRAIN,
+ PCR_ECP_ENABLE |
+ PCR_ECP_CLK_ENA |
+ PCR_IRQ_POLAR);
+
+ /* CTR bit 5 controls direction of port */
+ ns87303_modify(config, PTR,
+ 0, PTR_LPT_REG_DIR);
+
+ p = parport_pc_probe_port(base, base + 0x400,
+ op->archdata.irqs[0],
+ slot,
+ op->dev.parent,
+ 0);
+ err = -ENOMEM;
+ if (!p)
+ goto out_disable_irq;
+
+ dev_set_drvdata(&op->dev, p);
+
+ return 0;
+
+out_disable_irq:
+ ebus_dma_irq_enable(&sparc_ebus_dmas[slot].info, 0);
+ ebus_dma_unregister(&sparc_ebus_dmas[slot].info);
+
+out_unmap_regs:
+ of_iounmap(&op->resource[2], sparc_ebus_dmas[slot].info.regs, d_len);
+
+out_clear_map:
+ clear_bit(slot, dma_slot_map);
+
+out_err:
+ return err;
+}
+
+static int ecpp_remove(struct platform_device *op)
+{
+ struct parport *p = dev_get_drvdata(&op->dev);
+ int slot = p->dma;
+
+ parport_pc_unregister_port(p);
+
+ if (slot != PARPORT_DMA_NOFIFO) {
+ unsigned long d_base = op->resource[2].start;
+ unsigned long d_len;
+
+ d_len = (op->resource[2].end - d_base) + 1UL;
+
+ ebus_dma_irq_enable(&sparc_ebus_dmas[slot].info, 0);
+ ebus_dma_unregister(&sparc_ebus_dmas[slot].info);
+ of_iounmap(&op->resource[2],
+ sparc_ebus_dmas[slot].info.regs,
+ d_len);
+ clear_bit(slot, dma_slot_map);
+ }
+
+ return 0;
+}
+
+static const struct of_device_id ecpp_match[] = {
+ {
+ .name = "ecpp",
+ },
+ {
+ .name = "parallel",
+ .compatible = "ecpp",
+ },
+ {
+ .name = "parallel",
+ .compatible = "ns87317-ecpp",
+ },
+ {
+ .name = "parallel",
+ .compatible = "pnpALI,1533,3",
+ },
+ {},
+};
+
+static struct platform_driver ecpp_driver = {
+ .driver = {
+ .name = "ecpp",
+ .of_match_table = ecpp_match,
+ },
+ .probe = ecpp_probe,
+ .remove = ecpp_remove,
+};
+
+static int parport_pc_find_nonpci_ports(int autoirq, int autodma)
+{
+ return platform_driver_register(&ecpp_driver);
+}
+
+#endif /* !(_ASM_SPARC64_PARPORT_H */

--
2.34.1


2024-02-24 00:29:17

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH 2/6] sparc32: Fix build with trapbase



On 2/23/24 11:36, Sam Ravnborg via B4 Relay wrote:
> From: Sam Ravnborg <[email protected]>
>
> Fix the following build errors:
> irq_32.c:258:7: error: array subscript [16, 79] is outside array bounds of 'struct tt_entry[1]
> irq_32.c:271:14: error: assignment to 'struct tt_entry *' from incompatible pointer type 'struct tt_entry (*)[]
>
> trapbase is a pointer to an array of tt_entry, but the code declared it
> as a pointer so the compiler see a single entry and not an array.
> Fix this by modifyinf the declaration to be an array, and modify all
> users to take the address of the first member.
>
> Signed-off-by: Sam Ravnborg <[email protected]>
> Cc: Andreas Larsson <[email protected]>
> Cc: "David S. Miller" <[email protected]>

Acked-by: Randy Dunlap <[email protected]>
Tested-by: Randy Dunlap <[email protected]> # build-tested

Thanks.

> ---
> arch/sparc/kernel/irq_32.c | 6 +++---
> arch/sparc/kernel/kernel.h | 8 ++++----
> arch/sparc/kernel/kgdb_32.c | 4 ++--
> arch/sparc/kernel/leon_smp.c | 6 +++---
> arch/sparc/kernel/setup_32.c | 4 ++--
> 5 files changed, 14 insertions(+), 14 deletions(-)
>


--
#Randy

2024-02-24 00:30:09

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH 3/6] mtd: maps: sun_uflash: Declare uflash_devinit static



On 2/23/24 11:36, Sam Ravnborg via B4 Relay wrote:
> From: Sam Ravnborg <[email protected]>
>
> This fixes the following warning:
> sun_uflash.c:50:5: error: no previous prototype for 'uflash_devinit'
>
> Signed-off-by: Sam Ravnborg <[email protected]>
> Cc: Andreas Larsson <[email protected]>
> Cc: "David S. Miller" <[email protected]>


Reviewed-by: Randy Dunlap <[email protected]>
Tested-by: Randy Dunlap <[email protected]> # build-tested

Thanks.

> ---
> drivers/mtd/maps/sun_uflash.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/maps/sun_uflash.c b/drivers/mtd/maps/sun_uflash.c
> index f58cfb15d6e8..b69dade3f7ad 100644
> --- a/drivers/mtd/maps/sun_uflash.c
> +++ b/drivers/mtd/maps/sun_uflash.c
> @@ -47,7 +47,7 @@ struct map_info uflash_map_templ = {
> .bankwidth = UFLASH_BUSWIDTH,
> };
>
> -int uflash_devinit(struct platform_device *op, struct device_node *dp)
> +static int uflash_devinit(struct platform_device *op, struct device_node *dp)
> {
> struct uflash_dev *up;
>
>

--
#Randy

2024-02-24 00:32:07

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH 4/6] usb: host: uhci-grlib.c: Fix build, add platform_device



On 2/23/24 11:36, Sam Ravnborg via B4 Relay wrote:
> From: Sam Ravnborg <[email protected]>
>
> Fix the followig build error:
> uhci-grlib.c:92:29: error: invalid use of undefined type 'struct platform_device'
>
> The fix was straightforward, and no attempt was made to understand why
> the build failed.
>
> Signed-off-by: Sam Ravnborg <[email protected]>
> Cc: Andreas Larsson <[email protected]>
> Cc: Greg Kroah-Hartman <[email protected]>

This looks good but the same patch is already in linux-next, courtesy of
Andreas.

> ---
> drivers/usb/host/uhci-grlib.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/usb/host/uhci-grlib.c b/drivers/usb/host/uhci-grlib.c
> index ac3fc5970315..cfebb833668e 100644
> --- a/drivers/usb/host/uhci-grlib.c
> +++ b/drivers/usb/host/uhci-grlib.c
> @@ -22,6 +22,7 @@
> #include <linux/of_irq.h>
> #include <linux/of_address.h>
> #include <linux/of_platform.h>
> +#include <linux/platform_device.h>
>
> static int uhci_grlib_init(struct usb_hcd *hcd)
> {
>

--
#Randy

2024-02-24 00:34:35

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH 6/6] sparc32: Fix parport build with sparc32



On 2/23/24 11:36, Sam Ravnborg via B4 Relay wrote:
> From: Sam Ravnborg <[email protected]>
>
> include/asm/parport.h is sparc64 specific.
> Rename it to parport_64.h and use the generic version for sparc32.
>
> This fixed all{mod,yes}config build errors like:
>
> parport_pc.c:(.text):undefined-reference-to-ebus_dma_enable
> parport_pc.c:(.text):undefined-reference-to-ebus_dma_irq_enable
> parport_pc.c:(.text):undefined-reference-to-ebus_dma_register
>
> The errors occur as the sparc32 build references sparc64 symbols.
>
> Signed-off-by: Sam Ravnborg <[email protected]>
> Cc: "David S. Miller" <[email protected]>
> Cc: Andreas Larsson <[email protected]>
> Cc: Randy Dunlap <[email protected]>
> Cc: Maciej W. Rozycki <[email protected]>
> Closes: https://lore.kernel.org/r/[email protected]/
> Fixes: 66bcd06099bb ("parport_pc: Also enable driver for PCI systems")
> Cc: [email protected] # v5.18+

Acked-by: Randy Dunlap <[email protected]>
Tested-by: Randy Dunlap <[email protected]> # build-tested

Thanks.

> ---
> arch/sparc/include/asm/parport.h | 259 +-----------------------------------
> arch/sparc/include/asm/parport_64.h | 256 +++++++++++++++++++++++++++++++++++
> 2 files changed, 263 insertions(+), 252 deletions(-)
>


--
#Randy

2024-02-24 03:39:41

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH 5/6] sparc32: Do not select GENERIC_ISA_DMA



On 2/23/24 11:36, Sam Ravnborg via B4 Relay wrote:
> From: Sam Ravnborg <[email protected]>
>
> sparc32 do not support generic isa dma, so do not select the symbol.
> Without this fix, the following patch would break the build with a
> missing prototype.
>
> Signed-off-by: Sam Ravnborg <[email protected]>
> Cc: Andreas Larsson <[email protected]>
> Cc: "David S. Miller" <[email protected]>
> Cc: Randy Dunlap <[email protected]>
> Cc: Maciej W. Rozycki <[email protected]>
> Fixes: 66bcd06099bb ("parport_pc: Also enable driver for PCI systems")

Acked-by: Randy Dunlap <[email protected]>
Tested-by: Randy Dunlap <[email protected]> # build-tested

> ---
> arch/sparc/Kconfig | 4 ----
> 1 file changed, 4 deletions(-)
>
> diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
> index 734f23daecca..d08a5662ea60 100644
> --- a/arch/sparc/Kconfig
> +++ b/arch/sparc/Kconfig
> @@ -138,10 +138,6 @@ config HIGHMEM
> default y if SPARC32
> select KMAP_LOCAL
>
> -config GENERIC_ISA_DMA
> - bool
> - default y if SPARC32
> -
> config PGTABLE_LEVELS
> default 4 if 64BIT
> default 3
>

--
#Randy

2024-02-24 07:59:32

by Sam Ravnborg

[permalink] [raw]
Subject: Re: [PATCH 5/6] sparc32: Do not select GENERIC_ISA_DMA

Hi Marciej,

On Sat, Feb 24, 2024 at 05:29:43AM +0000, Maciej W. Rozycki wrote:
> On Sat, 24 Feb 2024, Maciej W. Rozycki wrote:
>
> > > sparc32 do not support generic isa dma, so do not select the symbol.
> > > Without this fix, the following patch would break the build with a
> > > missing prototype.
> >
> > Not according to my observations, kernel/dma.c is always built for
> > GENERIC_ISA_DMA configurations, so:
> >
> > kernel/dma.c:70:5: error: no previous prototype for 'request_dma' [-Werror=missing-prototypes]
> > 70 | int request_dma(unsigned int dmanr, const char * device_id)
> > | ^~~~~~~~~~~
> > kernel/dma.c:88:6: error: no previous prototype for 'free_dma' [-Werror=missing-prototypes]
> > 88 | void free_dma(unsigned int dmanr)
> > | ^~~~~~~~
> >
> > are issued regardless (and FAOD with PARPORT_PC unset).
> >
> > I can't speak for SPARC support for ISA DMA, but it seems to me like the
> > second sentence would best be removed, as would the Fixes: tag (in favour
> > to:
> >
> > Fixes: 0fcb70851fbf ("Makefile.extrawarn: turn on missing-prototypes globally")
> >
> > I presume), and possibly the messages quoted above included instead.

Thanks, I will update in v2.

>
> Actually I think ZONE_DMA should go too (it's linked to GENERIC_ISA_DMA,
> isn't it? -- cf. commit 5ac6da669e24 ("[PATCH] Set CONFIG_ZONE_DMA for
> arches with GENERIC_ISA_DMA")), and the whole thing use:
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
>
> The GENERIC_ISA_DMA option itself was added to arch/sparc/config.in with
> 2.5.31 as:
>
> define_bool CONFIG_GENERIC_ISA_DMA y
>
> despite of:
>
> define_bool CONFIG_ISA n
>
> for a reason not clear to me (BLK_DEV_FD? -- but on SPARC that uses some
> hacks to work in the absence of ISA DMA anyway).
>
> Am I missing anything here?
Nice find - the code below conforms you are right:

max_zone_pfn[ZONE_DMA] = max_low_pfn;
max_zone_pfn[ZONE_NORMAL] = max_low_pfn;

As they are set to the same value there is no smaller ZONE_DMA area.
I will add an extra patch for this in v2.

Sam

2024-02-24 11:24:34

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH 5/6] sparc32: Do not select GENERIC_ISA_DMA

On Sat, Feb 24, 2024, at 06:29, Maciej W. Rozycki wrote:
> On Sat, 24 Feb 2024, Maciej W. Rozycki wrote:
>
> The GENERIC_ISA_DMA option itself was added to arch/sparc/config.in with
> 2.5.31 as:
>
> define_bool CONFIG_GENERIC_ISA_DMA y
>
> despite of:
>
> define_bool CONFIG_ISA n

I think I've seen any combination of CONFIG_ISA (the 62/98 pin slots), CONFIG_GENERIC_ISA_DMA (the request_dma() interface) and
CONFIG_ISA_DMA_API (the set_dma_addr()/enable_dma() type interface),
but I agree that sparc should have none of the three as both
floppy and parport use some other interface.

> for a reason not clear to me (BLK_DEV_FD? -- but on SPARC that uses some
> hacks to work in the absence of ISA DMA anyway).
>
> Am I missing anything here?

I think it was part of the ISA DMA lookalike that got removed
in 334ae614772b ("sparc: Kill SBUS DVMA layer.") and should
have been changed back then.

Arnd

2024-02-24 17:16:06

by Sam Ravnborg

[permalink] [raw]
Subject: Re: [PATCH 5/6] sparc32: Do not select GENERIC_ISA_DMA

Hi Arnd,

On Sat, Feb 24, 2024 at 12:24:01PM +0100, Arnd Bergmann wrote:
> On Sat, Feb 24, 2024, at 06:29, Maciej W. Rozycki wrote:
> > On Sat, 24 Feb 2024, Maciej W. Rozycki wrote:
> >
> > The GENERIC_ISA_DMA option itself was added to arch/sparc/config.in with
> > 2.5.31 as:
> >
> > define_bool CONFIG_GENERIC_ISA_DMA y
> >
> > despite of:
> >
> > define_bool CONFIG_ISA n
>
> I think I've seen any combination of CONFIG_ISA (the 62/98 pin slots), CONFIG_GENERIC_ISA_DMA (the request_dma() interface) and
> CONFIG_ISA_DMA_API (the set_dma_addr()/enable_dma() type interface),
> but I agree that sparc should have none of the three as both
> floppy and parport use some other interface.
>
> > for a reason not clear to me (BLK_DEV_FD? -- but on SPARC that uses some
> > hacks to work in the absence of ISA DMA anyway).
> >
> > Am I missing anything here?
>
> I think it was part of the ISA DMA lookalike that got removed
> in 334ae614772b ("sparc: Kill SBUS DVMA layer.") and should
> have been changed back then.

Hmm, that may well be the case.

I checked and sparc32 do not set any ISA symbols anymore
so we should be OK now.

I decided to just drop the Fixes: tag to not confuse anyone.

Sam

2024-02-24 05:30:21

by Maciej W. Rozycki

[permalink] [raw]
Subject: Re: [PATCH 5/6] sparc32: Do not select GENERIC_ISA_DMA

On Sat, 24 Feb 2024, Maciej W. Rozycki wrote:

> > sparc32 do not support generic isa dma, so do not select the symbol.
> > Without this fix, the following patch would break the build with a
> > missing prototype.
>
> Not according to my observations, kernel/dma.c is always built for
> GENERIC_ISA_DMA configurations, so:
>
> kernel/dma.c:70:5: error: no previous prototype for 'request_dma' [-Werror=missing-prototypes]
> 70 | int request_dma(unsigned int dmanr, const char * device_id)
> | ^~~~~~~~~~~
> kernel/dma.c:88:6: error: no previous prototype for 'free_dma' [-Werror=missing-prototypes]
> 88 | void free_dma(unsigned int dmanr)
> | ^~~~~~~~
>
> are issued regardless (and FAOD with PARPORT_PC unset).
>
> I can't speak for SPARC support for ISA DMA, but it seems to me like the
> second sentence would best be removed, as would the Fixes: tag (in favour
> to:
>
> Fixes: 0fcb70851fbf ("Makefile.extrawarn: turn on missing-prototypes globally")
>
> I presume), and possibly the messages quoted above included instead.

Actually I think ZONE_DMA should go too (it's linked to GENERIC_ISA_DMA,
isn't it? -- cf. commit 5ac6da669e24 ("[PATCH] Set CONFIG_ZONE_DMA for
arches with GENERIC_ISA_DMA")), and the whole thing use:

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")

The GENERIC_ISA_DMA option itself was added to arch/sparc/config.in with
2.5.31 as:

define_bool CONFIG_GENERIC_ISA_DMA y

despite of:

define_bool CONFIG_ISA n

for a reason not clear to me (BLK_DEV_FD? -- but on SPARC that uses some
hacks to work in the absence of ISA DMA anyway).

Am I missing anything here?

Maciej

2024-02-24 03:02:31

by Maciej W. Rozycki

[permalink] [raw]
Subject: Re: [PATCH 6/6] sparc32: Fix parport build with sparc32

On Fri, 23 Feb 2024, Sam Ravnborg via B4 Relay wrote:

> include/asm/parport.h is sparc64 specific.
> Rename it to parport_64.h and use the generic version for sparc32.
>
> This fixed all{mod,yes}config build errors like:
>
> parport_pc.c:(.text):undefined-reference-to-ebus_dma_enable
> parport_pc.c:(.text):undefined-reference-to-ebus_dma_irq_enable
> parport_pc.c:(.text):undefined-reference-to-ebus_dma_register
>
> The errors occur as the sparc32 build references sparc64 symbols.
>
> Signed-off-by: Sam Ravnborg <[email protected]>
> Cc: "David S. Miller" <[email protected]>
> Cc: Andreas Larsson <[email protected]>
> Cc: Randy Dunlap <[email protected]>
> Cc: Maciej W. Rozycki <[email protected]>
> Closes: https://lore.kernel.org/r/[email protected]/
> Fixes: 66bcd06099bb ("parport_pc: Also enable driver for PCI systems")
> Cc: [email protected] # v5.18+
> ---

LGTM, it relies on SPARC never to enable ISA.

Reviewed-by: Maciej W. Rozycki <[email protected]>
Tested-by: Maciej W. Rozycki <[email protected]> # build-tested

The other changes in this patch series address issues that do not appear
with my ad-hoc SPARC test configuration, so I have no immediate way to
verify them.

Maciej

2024-02-24 02:55:12

by Maciej W. Rozycki

[permalink] [raw]
Subject: Re: [PATCH 5/6] sparc32: Do not select GENERIC_ISA_DMA

On Fri, 23 Feb 2024, Sam Ravnborg via B4 Relay wrote:

> sparc32 do not support generic isa dma, so do not select the symbol.
> Without this fix, the following patch would break the build with a
> missing prototype.

Not according to my observations, kernel/dma.c is always built for
GENERIC_ISA_DMA configurations, so:

kernel/dma.c:70:5: error: no previous prototype for 'request_dma' [-Werror=missing-prototypes]
70 | int request_dma(unsigned int dmanr, const char * device_id)
| ^~~~~~~~~~~
kernel/dma.c:88:6: error: no previous prototype for 'free_dma' [-Werror=missing-prototypes]
88 | void free_dma(unsigned int dmanr)
| ^~~~~~~~

are issued regardless (and FAOD with PARPORT_PC unset).

I can't speak for SPARC support for ISA DMA, but it seems to me like the
second sentence would best be removed, as would the Fixes: tag (in favour
to:

Fixes: 0fcb70851fbf ("Makefile.extrawarn: turn on missing-prototypes globally")

I presume), and possibly the messages quoted above included instead.

Maciej