From 3b0950af21e02a8c902ce1143ac5563fadcdfb3e Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Sun, 12 Jan 2020 18:17:05 +0100 Subject: [PATCH 01/11] m68k: amiga: Fix Denise detection on OCS The "default" statement for detecting an original Denise chip seems to be misplaced, causing original Denise chips not being detected. Fix this by moving it from the outer to the inner "switch" statement. Fortunately no code relies on this, but the detected version is printed during boot, and available through /proc/hardware. Signed-off-by: Geert Uytterhoeven Link: https://lore.kernel.org/r/20200112171705.22600-1-geert@linux-m68k.org --- arch/m68k/amiga/config.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/m68k/amiga/config.c b/arch/m68k/amiga/config.c index 8f23b2fab64c..9c1afa143d05 100644 --- a/arch/m68k/amiga/config.c +++ b/arch/m68k/amiga/config.c @@ -278,11 +278,11 @@ static void __init amiga_identify(void) case 0x08: AMIGAHW_SET(LISA); break; + default: + AMIGAHW_SET(DENISE); + break; } break; - default: - AMIGAHW_SET(DENISE); - break; } switch ((amiga_custom.vposr>>8) & 0x7f) { case 0x00: From ea2abe2fd59a73b26c01e9a3bb83efc46e44face Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Mon, 13 Jul 2020 09:24:29 +0200 Subject: [PATCH 02/11] zorro: Fix address space collision message with RAM expansion boards When booting Linux on an Amiga with BigRAMPlus Zorro expansion board: zorro: Address space collision on device Zorro device 12128600 (Individual Computers) [??? 0x50000000-] This happens because the address space occupied by the BigRAMPlus Zorro device is already in use, as it is part of system RAM. Hence the message is harmless. Zorro memory expansion boards have the ERTF_MEMLIST flag set, which tells AmigaOS to link the board's RAM into the free memory list. While we could skip registering the board resource if this flag is set, that may cause issues with Zorro II RAM excluded in a memfile. Hence fix the issue by just ignoring the error if ERTF_MEMLIST is set. Reported-by: John Paul Adrian Glaubitz Signed-off-by: Geert Uytterhoeven Link: https://lore.kernel.org/r/20200713072429.6182-1-geert@linux-m68k.org --- drivers/zorro/zorro.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/zorro/zorro.c b/drivers/zorro/zorro.c index 47c733817903..1b9928648583 100644 --- a/drivers/zorro/zorro.c +++ b/drivers/zorro/zorro.c @@ -181,7 +181,7 @@ static int __init amiga_zorro_probe(struct platform_device *pdev) z->resource.name = z->name; r = zorro_find_parent_resource(pdev, z); error = request_resource(r, &z->resource); - if (error) + if (error && !(z->rom.er_Type & ERTF_MEMLIST)) dev_err(&bus->dev, "Address space collision on device %s %pR\n", z->name, &z->resource); From c75e59e401b66971d166780c9fad5f741db2c54e Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 20 Jul 2020 13:43:14 +0200 Subject: [PATCH 03/11] m68k: Use get_kernel_nofault() in show_registers() Use the proper get_kernel_nofault() helper to access an unsafe kernel pointer without faulting instead of playing with set_fs() and get_user(). Signed-off-by: Christoph Hellwig Link: https://lore.kernel.org/r/20200720114314.196686-1-hch@lst.de Signed-off-by: Geert Uytterhoeven --- arch/m68k/kernel/traps.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/arch/m68k/kernel/traps.c b/arch/m68k/kernel/traps.c index 546e81935fe8..9e1261462bcc 100644 --- a/arch/m68k/kernel/traps.c +++ b/arch/m68k/kernel/traps.c @@ -845,7 +845,6 @@ static void show_trace(unsigned long *stack, const char *loglvl) void show_registers(struct pt_regs *regs) { struct frame *fp = (struct frame *)regs; - mm_segment_t old_fs = get_fs(); u16 c, *cp; unsigned long addr; int i; @@ -918,10 +917,9 @@ void show_registers(struct pt_regs *regs) show_stack(NULL, (unsigned long *)addr, KERN_INFO); pr_info("Code:"); - set_fs(KERNEL_DS); cp = (u16 *)regs->pc; for (i = -8; i < 16; i++) { - if (get_user(c, cp + i) && i >= 0) { + if (get_kernel_nofault(c, cp + i) && i >= 0) { pr_cont(" Bad PC value."); break; } @@ -930,7 +928,6 @@ void show_registers(struct pt_regs *regs) else pr_cont(" <%04x>", c); } - set_fs(old_fs); pr_cont("\n"); } From 5661bccb70ef134502b9d2e80a19465ad943b022 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Thu, 23 Jul 2020 09:25:51 +1000 Subject: [PATCH 04/11] m68k: Correct some typos in comments Signed-off-by: Finn Thain Link: https://lore.kernel.org/r/f54e99e9bd1e25ad70a6a1d7a7ec9ab2b4e50d68.1595460351.git.fthain@telegraphics.com.au Signed-off-by: Geert Uytterhoeven --- arch/m68k/kernel/head.S | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/m68k/kernel/head.S b/arch/m68k/kernel/head.S index 29de2b3108ea..493c95db0e51 100644 --- a/arch/m68k/kernel/head.S +++ b/arch/m68k/kernel/head.S @@ -57,7 +57,7 @@ * Of course, readability is a subjective issue, so it will never be * argued that that goal was accomplished. It was merely a goal. * A key way to help make code more readable is to give good - * documentation. So, the first thing you will find is exaustive + * documentation. So, the first thing you will find is exhaustive * write-ups on the structure of the file, and the features of the * functional subroutines. * @@ -1304,7 +1304,7 @@ L(mmu_fixup_done): * mmu_engage * * This chunk of code performs the gruesome task of engaging the MMU. - * The reason its gruesome is because when the MMU becomes engaged it + * The reason it's gruesome is because when the MMU becomes engaged it * maps logical addresses to physical addresses. The Program Counter * register is then passed through the MMU before the next instruction * is fetched (the instruction following the engage MMU instruction). @@ -1369,7 +1369,7 @@ L(mmu_fixup_done): /* * After this point no new memory is allocated and * the start of available memory is stored in availmem. - * (The bootmem allocator requires now the physicall address.) + * (The bootmem allocator requires now the physical address.) */ movel L(memory_start),availmem @@ -1547,7 +1547,7 @@ func_return get_bi_record * seven bits of the logical address (LA) are used as an * index into the "root table." Each entry in the root * table has a bit which specifies if it's a valid pointer to a - * pointer table. Each entry defines a 32KMeg range of memory. + * pointer table. Each entry defines a 32Meg range of memory. * If an entry is invalid then that logical range of 32M is * invalid and references to that range of memory (when the MMU * is enabled) will fault. If the entry is valid, then it does @@ -1584,7 +1584,7 @@ func_return get_bi_record * bits 17..12 - index into the Page Table * bits 11..0 - offset into a particular 4K page * - * The algorithms which follows do one thing: they abstract + * The algorithms which follow do one thing: they abstract * the MMU hardware. For example, there are three kinds of * cache settings that are relevant. Either, memory is * being mapped in which case it is either Kernel Code (or @@ -2082,7 +2082,7 @@ func_return mmu_map_tt * mmu_map * * This routine will map a range of memory using a pointer - * table and allocating the pages on the fly from the kernel. + * table and allocate the pages on the fly from the kernel. * The pointer table does not have to be already linked into * the root table, this routine will do that if necessary. * @@ -2528,7 +2528,7 @@ func_start mmu_get_root_table_entry,%d0/%a1 /* Find the start of free memory, get_bi_record does this for us, * as the bootinfo structure is located directly behind the kernel - * and and we simply search for the last entry. + * we simply search for the last entry. */ get_bi_record BI_LAST addw #PAGESIZE-1,%a0 @@ -2654,7 +2654,7 @@ func_start mmu_get_page_table_entry,%d0/%a1 jne 2f /* If the page table entry doesn't exist, we allocate a complete new - * page and use it as one continues big page table which can cover + * page and use it as one continuous big page table which can cover * 4MB of memory, nearly almost all mappings have that alignment. */ get_new_page From 62148d98590191f0515e89e7a6eed47bc5c51ae8 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Wed, 26 Aug 2020 14:29:23 +0200 Subject: [PATCH 05/11] m68k: Revive _TIF_* masks While the core m68k code does not use the _TIF_* masks anymore, there exists generic code that relies on their presence. Fortunately none of that code is used on m68k, currently. Re-add the various _TIF_* masks, which were removed in commit cddafa3500fde4a0 ("m68k/m68knommu: merge MMU and non-MMU thread_info.h"), to avoid future nasty surprises. Signed-off-by: Geert Uytterhoeven Acked-by: Greg Ungerer Link: https://lore.kernel.org/r/20200826122923.22821-1-geert@linux-m68k.org --- arch/m68k/include/asm/thread_info.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/m68k/include/asm/thread_info.h b/arch/m68k/include/asm/thread_info.h index 015f1ca38305..3689c6718c88 100644 --- a/arch/m68k/include/asm/thread_info.h +++ b/arch/m68k/include/asm/thread_info.h @@ -68,4 +68,12 @@ static inline struct thread_info *current_thread_info(void) #define TIF_MEMDIE 16 /* is terminating due to OOM killer */ #define TIF_RESTORE_SIGMASK 18 /* restore signal mask in do_signal */ +#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) +#define _TIF_SIGPENDING (1 << TIF_SIGPENDING) +#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) +#define _TIF_DELAYED_TRACE (1 << TIF_DELAYED_TRACE) +#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) +#define _TIF_MEMDIE (1 << TIF_MEMDIE) +#define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK) + #endif /* _ASM_M68K_THREAD_INFO_H */ From d473de0f883db0801c78a86b34dd1fddf8ba2ca3 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Wed, 26 Aug 2020 14:51:24 +0200 Subject: [PATCH 06/11] m68k: amiga: Clean up Amiga hardware configuration Move the generic Amiga hardware configuration section out of the switch statement, which allows to replace all ugly jumps by break statements. Signed-off-by: Geert Uytterhoeven Link: https://lore.kernel.org/r/20200826125124.23863-1-geert@linux-m68k.org --- arch/m68k/amiga/config.c | 118 +++++++++++++++++++-------------------- 1 file changed, 58 insertions(+), 60 deletions(-) diff --git a/arch/m68k/amiga/config.c b/arch/m68k/amiga/config.c index 9c1afa143d05..bee9f240f35d 100644 --- a/arch/m68k/amiga/config.c +++ b/arch/m68k/amiga/config.c @@ -214,7 +214,7 @@ static void __init amiga_identify(void) switch (amiga_model) { case AMI_UNKNOWN: - goto Generic; + break; case AMI_600: case AMI_1200: @@ -227,7 +227,7 @@ static void __init amiga_identify(void) case AMI_2000: case AMI_2500: AMIGAHW_SET(A2000_CLK); /* Is this correct for all models? */ - goto Generic; + break; case AMI_3000: case AMI_3000T: @@ -238,7 +238,7 @@ static void __init amiga_identify(void) AMIGAHW_SET(A3000_SCSI); AMIGAHW_SET(A3000_CLK); AMIGAHW_SET(ZORRO3); - goto Generic; + break; case AMI_4000T: AMIGAHW_SET(A4000_SCSI); @@ -247,68 +247,12 @@ static void __init amiga_identify(void) AMIGAHW_SET(A4000_IDE); AMIGAHW_SET(A3000_CLK); AMIGAHW_SET(ZORRO3); - goto Generic; + break; case AMI_CDTV: case AMI_CD32: AMIGAHW_SET(CD_ROM); AMIGAHW_SET(A2000_CLK); /* Is this correct? */ - goto Generic; - - Generic: - AMIGAHW_SET(AMI_VIDEO); - AMIGAHW_SET(AMI_BLITTER); - AMIGAHW_SET(AMI_AUDIO); - AMIGAHW_SET(AMI_FLOPPY); - AMIGAHW_SET(AMI_KEYBOARD); - AMIGAHW_SET(AMI_MOUSE); - AMIGAHW_SET(AMI_SERIAL); - AMIGAHW_SET(AMI_PARALLEL); - AMIGAHW_SET(CHIP_RAM); - AMIGAHW_SET(PAULA); - - switch (amiga_chipset) { - case CS_OCS: - case CS_ECS: - case CS_AGA: - switch (amiga_custom.deniseid & 0xf) { - case 0x0c: - AMIGAHW_SET(DENISE_HR); - break; - case 0x08: - AMIGAHW_SET(LISA); - break; - default: - AMIGAHW_SET(DENISE); - break; - } - break; - } - switch ((amiga_custom.vposr>>8) & 0x7f) { - case 0x00: - AMIGAHW_SET(AGNUS_PAL); - break; - case 0x10: - AMIGAHW_SET(AGNUS_NTSC); - break; - case 0x20: - case 0x21: - AMIGAHW_SET(AGNUS_HR_PAL); - break; - case 0x30: - case 0x31: - AMIGAHW_SET(AGNUS_HR_NTSC); - break; - case 0x22: - case 0x23: - AMIGAHW_SET(ALICE_PAL); - break; - case 0x32: - case 0x33: - AMIGAHW_SET(ALICE_NTSC); - break; - } - AMIGAHW_SET(ZORRO); break; case AMI_DRACO: @@ -318,6 +262,60 @@ static void __init amiga_identify(void) panic("Unknown Amiga Model"); } + AMIGAHW_SET(AMI_VIDEO); + AMIGAHW_SET(AMI_BLITTER); + AMIGAHW_SET(AMI_AUDIO); + AMIGAHW_SET(AMI_FLOPPY); + AMIGAHW_SET(AMI_KEYBOARD); + AMIGAHW_SET(AMI_MOUSE); + AMIGAHW_SET(AMI_SERIAL); + AMIGAHW_SET(AMI_PARALLEL); + AMIGAHW_SET(CHIP_RAM); + AMIGAHW_SET(PAULA); + + switch (amiga_chipset) { + case CS_OCS: + case CS_ECS: + case CS_AGA: + switch (amiga_custom.deniseid & 0xf) { + case 0x0c: + AMIGAHW_SET(DENISE_HR); + break; + case 0x08: + AMIGAHW_SET(LISA); + break; + default: + AMIGAHW_SET(DENISE); + break; + } + break; + } + switch ((amiga_custom.vposr>>8) & 0x7f) { + case 0x00: + AMIGAHW_SET(AGNUS_PAL); + break; + case 0x10: + AMIGAHW_SET(AGNUS_NTSC); + break; + case 0x20: + case 0x21: + AMIGAHW_SET(AGNUS_HR_PAL); + break; + case 0x30: + case 0x31: + AMIGAHW_SET(AGNUS_HR_NTSC); + break; + case 0x22: + case 0x23: + AMIGAHW_SET(ALICE_PAL); + break; + case 0x32: + case 0x33: + AMIGAHW_SET(ALICE_NTSC); + break; + } + AMIGAHW_SET(ZORRO); + #define AMIGAHW_ANNOUNCE(name, str) \ if (AMIGAHW_PRESENT(name)) \ pr_cont(str) From dc072012bc94287e3cc43e1429c5d72b2e6f4972 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Wed, 26 Aug 2020 14:52:59 +0200 Subject: [PATCH 07/11] m68k: Sort selects in main Kconfig Sort the list of select statements in the main Kconfig file for the m68k architecture, to avoid conflicts when modifying this list. Signed-off-by: Geert Uytterhoeven Link: https://lore.kernel.org/r/20200826125259.24069-1-geert@linux-m68k.org --- arch/m68k/Kconfig | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig index 6f2f38d05772..93bbb74ea876 100644 --- a/arch/m68k/Kconfig +++ b/arch/m68k/Kconfig @@ -6,32 +6,32 @@ config M68K select ARCH_HAS_BINFMT_FLAT select ARCH_HAS_DMA_PREP_COHERENT if HAS_DMA && MMU && !COLDFIRE select ARCH_HAS_SYNC_DMA_FOR_DEVICE if HAS_DMA + select ARCH_HAVE_NMI_SAFE_CMPXCHG if RMW_INSNS select ARCH_MIGHT_HAVE_PC_PARPORT if ISA select ARCH_NO_PREEMPT if !COLDFIRE + select ARCH_WANT_IPC_PARSE_VERSION select BINFMT_FLAT_ARGVP_ENVP_ON_STACK select DMA_DIRECT_REMAP if HAS_DMA && MMU && !COLDFIRE - select HAVE_IDE + select GENERIC_ATOMIC64 + select GENERIC_CPU_DEVICES + select GENERIC_IOMAP + select GENERIC_IRQ_SHOW + select GENERIC_STRNCPY_FROM_USER if MMU + select GENERIC_STRNLEN_USER if MMU select HAVE_AOUT if MMU select HAVE_ASM_MODVERSIONS select HAVE_DEBUG_BUGVERBOSE - select GENERIC_IRQ_SHOW - select GENERIC_ATOMIC64 - select NO_DMA if !MMU && !COLDFIRE - select HAVE_UID16 - select VIRT_TO_BUS - select ARCH_HAVE_NMI_SAFE_CMPXCHG if RMW_INSNS - select GENERIC_CPU_DEVICES - select GENERIC_IOMAP - select GENERIC_STRNCPY_FROM_USER if MMU - select GENERIC_STRNLEN_USER if MMU - select ARCH_WANT_IPC_PARSE_VERSION select HAVE_FUTEX_CMPXCHG if MMU && FUTEX + select HAVE_IDE select HAVE_MOD_ARCH_SPECIFIC + select HAVE_UID16 + select MMU_GATHER_NO_RANGE if MMU select MODULES_USE_ELF_REL select MODULES_USE_ELF_RELA - select OLD_SIGSUSPEND3 + select NO_DMA if !MMU && !COLDFIRE select OLD_SIGACTION - select MMU_GATHER_NO_RANGE if MMU + select OLD_SIGSUSPEND3 + select VIRT_TO_BUS config CPU_BIG_ENDIAN def_bool y From 41f1bf37a63ecdb06b7b96646579170ddbe9def1 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Wed, 26 Aug 2020 15:01:03 +0200 Subject: [PATCH 08/11] m68k: mm: Use PAGE_ALIGNED() helper Use the existing PAGE_ALIGNED() helper instead of open-coding the same operation. Signed-off-by: Geert Uytterhoeven Link: https://lore.kernel.org/r/20200826130103.25381-1-geert@linux-m68k.org --- arch/m68k/mm/motorola.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/m68k/mm/motorola.c b/arch/m68k/mm/motorola.c index 2bb006bdc31c..a9bdde54ca35 100644 --- a/arch/m68k/mm/motorola.c +++ b/arch/m68k/mm/motorola.c @@ -226,7 +226,7 @@ static pte_t * __init kernel_page_table(void) { pte_t *pte_table = last_pte_table; - if (((unsigned long)last_pte_table & ~PAGE_MASK) == 0) { + if (PAGE_ALIGNED(last_pte_table)) { pte_table = (pte_t *)memblock_alloc_low(PAGE_SIZE, PAGE_SIZE); if (!pte_table) { panic("%s: Failed to allocate %lu bytes align=%lx\n", @@ -274,7 +274,7 @@ static pmd_t * __init kernel_ptr_table(void) } last_pmd_table += PTRS_PER_PMD; - if (((unsigned long)last_pmd_table & ~PAGE_MASK) == 0) { + if (PAGE_ALIGNED(last_pmd_table)) { last_pmd_table = (pmd_t *)memblock_alloc_low(PAGE_SIZE, PAGE_SIZE); if (!last_pmd_table) From 7e158826564fbbb7284dabbaf71b6c3227845f51 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Wed, 26 Aug 2020 15:04:44 +0200 Subject: [PATCH 09/11] m68k: mm: Remove superfluous memblock_alloc*() casts The return type of memblock_alloc*() is a void pointer, so there is no need to cast it to "void *" or some other pointer type, before assigning it to a pointer variable. Signed-off-by: Geert Uytterhoeven Reviewed-by: Mike Rapoport Acked-by: Greg Ungerer Link: https://lore.kernel.org/r/20200826130444.25618-1-geert@linux-m68k.org --- arch/m68k/mm/mcfmmu.c | 2 +- arch/m68k/mm/motorola.c | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/arch/m68k/mm/mcfmmu.c b/arch/m68k/mm/mcfmmu.c index 2b9cb4a62281..eac9dde65193 100644 --- a/arch/m68k/mm/mcfmmu.c +++ b/arch/m68k/mm/mcfmmu.c @@ -42,7 +42,7 @@ void __init paging_init(void) unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 }; int i; - empty_zero_page = (void *) memblock_alloc(PAGE_SIZE, PAGE_SIZE); + empty_zero_page = memblock_alloc(PAGE_SIZE, PAGE_SIZE); if (!empty_zero_page) panic("%s: Failed to allocate %lu bytes align=0x%lx\n", __func__, PAGE_SIZE, PAGE_SIZE); diff --git a/arch/m68k/mm/motorola.c b/arch/m68k/mm/motorola.c index a9bdde54ca35..3a653f0a4188 100644 --- a/arch/m68k/mm/motorola.c +++ b/arch/m68k/mm/motorola.c @@ -227,7 +227,7 @@ static pte_t * __init kernel_page_table(void) pte_t *pte_table = last_pte_table; if (PAGE_ALIGNED(last_pte_table)) { - pte_table = (pte_t *)memblock_alloc_low(PAGE_SIZE, PAGE_SIZE); + pte_table = memblock_alloc_low(PAGE_SIZE, PAGE_SIZE); if (!pte_table) { panic("%s: Failed to allocate %lu bytes align=%lx\n", __func__, PAGE_SIZE, PAGE_SIZE); @@ -275,8 +275,7 @@ static pmd_t * __init kernel_ptr_table(void) last_pmd_table += PTRS_PER_PMD; if (PAGE_ALIGNED(last_pmd_table)) { - last_pmd_table = (pmd_t *)memblock_alloc_low(PAGE_SIZE, - PAGE_SIZE); + last_pmd_table = memblock_alloc_low(PAGE_SIZE, PAGE_SIZE); if (!last_pmd_table) panic("%s: Failed to allocate %lu bytes align=%lx\n", __func__, PAGE_SIZE, PAGE_SIZE); From 352e04291115af2a74c271e0cd3643a632af6b7a Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 26 Aug 2020 20:52:12 +0200 Subject: [PATCH 10/11] m68k: Replace HTTP links with HTTPS ones Rationale: Reduces attack surface on kernel devs opening the links for MITM as HTTPS traffic is much harder to manipulate. Deterministic algorithm: For each file: If not .svg: For each line: If doesn't contain `\bxmlns\b`: For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`: If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`: If both the HTTP and HTTPS versions return 200 OK and serve the same content: Replace HTTP with HTTPS. Signed-off-by: Alexander A. Klimov Link: https://lore.kernel.org/r/20200826185212.3139-1-grandmaster@al2klimov.de Signed-off-by: Geert Uytterhoeven --- arch/m68k/mac/macboing.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/m68k/mac/macboing.c b/arch/m68k/mac/macboing.c index 388780797f7d..4de6229c7bfd 100644 --- a/arch/m68k/mac/macboing.c +++ b/arch/m68k/mac/macboing.c @@ -116,7 +116,7 @@ static void mac_init_asc( void ) * support 16-bit stereo output, but only mono input." * * Technical Information Library (TIL) article number 16405. - * http://support.apple.com/kb/TA32601 + * https://support.apple.com/kb/TA32601 * * --David Kilzer */ From 50c5feeea0af99a4401fd54fd72bec1333a496ca Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Thu, 24 Sep 2020 08:48:04 +1000 Subject: [PATCH 11/11] ide/macide: Convert Mac IDE driver to platform driver Add platform devices for the Mac IDE controller variants. Convert the macide module into a platform driver to support two of those variants. For the third, use a generic "pata_platform" driver instead. This enables automatic loading of the appropriate module and begins the process of replacing the driver with libata alternatives. Signed-off-by: Finn Thain Tested-by: Stan Johnson Cc: Bartlomiej Zolnierkiewicz Cc: Joshua Thompson References: commit 5ed0794cde593 ("m68k/atari: Convert Falcon IDE drivers to platform drivers") References: commit 7ad19a99ad431 ("ide: officially deprecated the legacy IDE driver") Link: https://lore.kernel.org/r/edd106dad1bbea32500601c6071f37a9f02a8004.1600901284.git.fthain@telegraphics.com.au Signed-off-by: Geert Uytterhoeven --- arch/m68k/configs/mac_defconfig | 1 + arch/m68k/configs/multi_defconfig | 1 + arch/m68k/mac/config.c | 41 +++++++++++++++++++ drivers/ide/Kconfig | 7 ++-- drivers/ide/macide.c | 66 ++++++++++++++++++++----------- 5 files changed, 90 insertions(+), 26 deletions(-) diff --git a/arch/m68k/configs/mac_defconfig b/arch/m68k/configs/mac_defconfig index 522dcf624aa5..3cd76bfaee03 100644 --- a/arch/m68k/configs/mac_defconfig +++ b/arch/m68k/configs/mac_defconfig @@ -317,6 +317,7 @@ CONFIG_DUMMY_IRQ=m CONFIG_IDE=y CONFIG_IDE_GD_ATAPI=y CONFIG_BLK_DEV_IDECD=y +CONFIG_BLK_DEV_PLATFORM=y CONFIG_BLK_DEV_MAC_IDE=y CONFIG_RAID_ATTRS=m CONFIG_SCSI=y diff --git a/arch/m68k/configs/multi_defconfig b/arch/m68k/configs/multi_defconfig index 2433409f4369..c3d6faa7894f 100644 --- a/arch/m68k/configs/multi_defconfig +++ b/arch/m68k/configs/multi_defconfig @@ -346,6 +346,7 @@ CONFIG_DUMMY_IRQ=m CONFIG_IDE=y CONFIG_IDE_GD_ATAPI=y CONFIG_BLK_DEV_IDECD=y +CONFIG_BLK_DEV_PLATFORM=y CONFIG_BLK_DEV_GAYLE=y CONFIG_BLK_DEV_BUDDHA=y CONFIG_BLK_DEV_FALCON_IDE=y diff --git a/arch/m68k/mac/config.c b/arch/m68k/mac/config.c index 5c9f3a2d6538..43fc29180cb5 100644 --- a/arch/m68k/mac/config.c +++ b/arch/m68k/mac/config.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -940,6 +941,26 @@ static const struct resource mac_scsi_ccl_rsrc[] __initconst = { }, }; +static const struct resource mac_ide_quadra_rsrc[] __initconst = { + DEFINE_RES_MEM(0x50F1A000, 0x104), + DEFINE_RES_IRQ(IRQ_NUBUS_F), +}; + +static const struct resource mac_ide_pb_rsrc[] __initconst = { + DEFINE_RES_MEM(0x50F1A000, 0x104), + DEFINE_RES_IRQ(IRQ_NUBUS_C), +}; + +static const struct resource mac_pata_baboon_rsrc[] __initconst = { + DEFINE_RES_MEM(0x50F1A000, 0x38), + DEFINE_RES_MEM(0x50F1A038, 0x04), + DEFINE_RES_IRQ(IRQ_BABOON_1), +}; + +static const struct pata_platform_info mac_pata_baboon_data __initconst = { + .ioport_shift = 2, +}; + int __init mac_platform_init(void) { phys_addr_t swim_base = 0; @@ -1048,6 +1069,26 @@ int __init mac_platform_init(void) break; } + /* + * IDE device + */ + + switch (macintosh_config->ide_type) { + case MAC_IDE_QUADRA: + platform_device_register_simple("mac_ide", -1, + mac_ide_quadra_rsrc, ARRAY_SIZE(mac_ide_quadra_rsrc)); + break; + case MAC_IDE_PB: + platform_device_register_simple("mac_ide", -1, + mac_ide_pb_rsrc, ARRAY_SIZE(mac_ide_pb_rsrc)); + break; + case MAC_IDE_BABOON: + platform_device_register_resndata(NULL, "pata_platform", -1, + mac_pata_baboon_rsrc, ARRAY_SIZE(mac_pata_baboon_rsrc), + &mac_pata_baboon_data, sizeof(mac_pata_baboon_data)); + break; + } + /* * Ethernet device */ diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig index 973ed4b684ce..19abf11c84c8 100644 --- a/drivers/ide/Kconfig +++ b/drivers/ide/Kconfig @@ -744,9 +744,10 @@ config BLK_DEV_MAC_IDE depends on MAC help This is the IDE driver for the on-board IDE interface on some m68k - Macintosh models. It supports both the `Quadra style' (used in - Quadra/ Centris 630 and Performa 588 models) and `Powerbook style' - (used in the Powerbook 150 and 190 models) IDE interface. + Macintosh models, namely Quadra/Centris 630, Performa 588 and + Powerbook 150. The IDE interface on the Powerbook 190 is not + supported by this driver and requires BLK_DEV_PLATFORM or + PATA_PLATFORM. Say Y if you have such an Macintosh model and want to use IDE devices (hard disks, CD-ROM drives, etc.) that are connected to the diff --git a/drivers/ide/macide.c b/drivers/ide/macide.c index adc5fe9daafc..8d2bf73bc548 100644 --- a/drivers/ide/macide.c +++ b/drivers/ide/macide.c @@ -18,10 +18,11 @@ #include #include #include +#include #include -#include -#include + +#define DRV_NAME "mac_ide" #define IDE_BASE 0x50F1A000 /* Base address of IDE controller */ @@ -100,42 +101,61 @@ static const char *mac_ide_name[] = * Probe for a Macintosh IDE interface */ -static int __init macide_init(void) +static int mac_ide_probe(struct platform_device *pdev) { - unsigned long base; - int irq; + struct resource *mem, *irq; struct ide_hw hw, *hws[] = { &hw }; struct ide_port_info d = macide_port_info; + struct ide_host *host; + int rc; if (!MACH_IS_MAC) return -ENODEV; - switch (macintosh_config->ide_type) { - case MAC_IDE_QUADRA: - base = IDE_BASE; - irq = IRQ_NUBUS_F; - break; - case MAC_IDE_PB: - base = IDE_BASE; - irq = IRQ_NUBUS_C; - break; - case MAC_IDE_BABOON: - base = BABOON_BASE; - d.port_ops = NULL; - irq = IRQ_BABOON_1; - break; - default: + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!mem) return -ENODEV; + + irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); + if (!irq) + return -ENODEV; + + if (!devm_request_mem_region(&pdev->dev, mem->start, + resource_size(mem), DRV_NAME)) { + dev_err(&pdev->dev, "resources busy\n"); + return -EBUSY; } printk(KERN_INFO "ide: Macintosh %s IDE controller\n", mac_ide_name[macintosh_config->ide_type - 1]); - macide_setup_ports(&hw, base, irq); + macide_setup_ports(&hw, mem->start, irq->start); - return ide_host_add(&d, hws, 1, NULL); + rc = ide_host_add(&d, hws, 1, &host); + if (rc) + return rc; + + platform_set_drvdata(pdev, host); + return 0; } -module_init(macide_init); +static int mac_ide_remove(struct platform_device *pdev) +{ + struct ide_host *host = platform_get_drvdata(pdev); + ide_host_remove(host); + return 0; +} + +static struct platform_driver mac_ide_driver = { + .driver = { + .name = DRV_NAME, + }, + .probe = mac_ide_probe, + .remove = mac_ide_remove, +}; + +module_platform_driver(mac_ide_driver); + +MODULE_ALIAS("platform:" DRV_NAME); MODULE_LICENSE("GPL");