Re: [HELP/RFC] Moving ppc8xx microcode patch from micropatch.c to firmware

2015-07-01 Thread leroy christophe


Le 30/06/2015 22:38, christophe leroy a écrit :
I'm trying to move the 3 microcode patches included in 
arch/powerpc/sysdev/micropatch.c into the firmware directory in order 
to use request_firmware() and then be able to add additional 
micropatch that I need to relocate SMC2 on my MPC885.
I've now been able to get it compiled in, was due to Makefile item 
written fw_shipped- instead of fw-shipped-


I'm now facing an Oops for NULL pointer in kmem_cache_alloc() after a 
call to kzalloc(sizeof(*firmware), GFP_KERNEL) in 
_request_firmware_prepare() (drivers/base/firmware_class.c)


Is that due to cpm_reset() being called too early ? Shouldn't kzalloc() 
allocate memory from the bootmem pool in that case ?


[0.00] Unable to handle kernel paging request for data at 
address 0x

[0.00] Faulting instruction address: 0xc00a77cc
[0.00] Oops: Kernel access of bad area, sig: 11 [#1]
[0.00] PREEMPT CMPC885
[0.00] CPU: 0 PID: 0 Comm: swapper Not tainted 
3.18.17-local-knld-998-g9c4c6b6-svn-dirty #1022

[0.00] task: c04dc3d0 ti: c04fc000 task.ti: c04fc000
[0.00] NIP: c00a77cc LR: c01bc3b8 CTR: 
[0.00] REGS: c04fde20 TRAP: 0300   Not tainted 
(3.18.17-local-knld-998-g9c4c6b6-svn-dirty)

[0.00] MSR: 1032 ME,IR,DR,RI  CR: 93d55d35  XER: a000fb40
[0.00] DAR:  DSISR: c000
GPR00: c01bc3b8 c04fded0 c04dc3d0  80d0  0009 
01ff
GPR08:  0022 c051 0158 53d55d39   
07ff94e8
GPR16:  07bb5d70  07ff81f4 c0534468 c04fdf68  
0009
GPR24: 07ffb3a0  0001 80d0 07ffb3a0  c04fc000 
c0410878

[0.00] NIP [c00a77cc] kmem_cache_alloc+0x28/0x120
[0.00] LR [c01bc3b8] _request_firmware+0x58/0xa14
[0.00] Call Trace:
[0.00] [c04fded0] [c045f588] ___alloc_bootmem_nopanic+0x34/0x64 
(unreliable)

[0.00] [c04fdef0] [c01bc3b8] _request_firmware+0x58/0xa14
[0.00] [c04fdf60] [c0458678] cpm_load_patch+0x34/0xac
[0.00] [c04fdf80] [c0458620] cpm_reset+0x5c/0x80
[0.00] [c04fdf90] [c0458c1c] cmpc885_setup_arch+0x10/0x30
[0.00] [c04fdfa0] [c0457cbc] setup_arch+0x130/0x168
[0.00] [c04fdfb0] [c045469c] start_kernel+0x84/0x37c
[0.00] [c04fdff0] [c0002214] start_here+0x38/0x98
[0.00] Instruction dump:
[0.00] 7c832378 4e800020 7c0802a6 9421ffe0 bf61000c 90010024 
7c7d1b78 7c9b2378
[0.00] 543e0024 813e000c 39290001 913e000c 83fd 839f0004 
813e000c 3929

[0.00] ---[ end trace dc8fa200cb88537f ]---





I have written the below patch in order to test the principle, but the 
firmware never gets included in my kernel, allthough I have set the 
below CONFIG items:


# CONFIG_NO_UCODE_PATCH is not set
CONFIG_USB_SOF_UCODE_PATCH=y
# CONFIG_I2C_SPI_UCODE_PATCH is not set
# CONFIG_I2C_SPI_SMC1_UCODE_PATCH is not set
CONFIG_UCODE_PATCH=y
#
# Generic Driver Options
#
# CONFIG_UEVENT_HELPER is not set
CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y
# CONFIG_STANDALONE is not set
# CONFIG_PREVENT_FIRMWARE_BUILD is not set
CONFIG_FW_LOADER=y
CONFIG_FIRMWARE_IN_KERNEL=y
CONFIG_EXTRA_FIRMWARE=
CONFIG_FW_LOADER_USER_HELPER=y
CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y

Can anybody help in finding what's wrong there ?

Christophe

---
 arch/powerpc/sysdev/micropatch.c | 655 
++-

 firmware/Makefile|   3 +
 firmware/freescale/i2c_spi.bin.ihex  | 257 
 firmware/freescale/i2c_spi_smc1.bin.ihex | 257 
 firmware/freescale/usb_sof.bin.ihex  | 513 
 5 files changed, 1065 insertions(+), 620 deletions(-)
 create mode 100644 firmware/freescale/i2c_spi.bin.ihex
 create mode 100644 firmware/freescale/i2c_spi_smc1.bin.ihex
 create mode 100644 firmware/freescale/usb_sof.bin.ihex

diff --git a/arch/powerpc/sysdev/micropatch.c 
b/arch/powerpc/sysdev/micropatch.c

index 6727dc5..c24780c 100644
--- a/arch/powerpc/sysdev/micropatch.c
+++ b/arch/powerpc/sysdev/micropatch.c
@@ -12,6 +12,8 @@
 #include linux/string.h
 #include linux/mm.h
 #include linux/interrupt.h
+#include linux/firmware.h
+#include linux/module.h
 #include asm/irq.h
 #include asm/page.h
 #include asm/pgtable.h
@@ -19,652 +21,69 @@
 #include asm/cpm.h
 #include asm/cpm1.h

-/*
- * I2C/SPI relocation patch arrays.
- */
-
-#ifdef CONFIG_I2C_SPI_UCODE_PATCH
-
-static uint patch_2000[] __initdata = {
-0x7FFFEFD9,
-0x3FFD,
-0x7FFB49F7,
-0x7FF9,
-0x5FEFADF7,
-0x5F89ADF7,
-0x5FEFAFF7,
-0x5F89AFF7,
-0x3A9CFBC8,
-0xE7C0EDF0,
-0x77C1E1BB,
-0xF4DC7F1D,
-0xABAD932F,
-0x4E08FDCF,
-0x6E0FAFF8,
-0x7CCF76CF,
-0xFD1FF9CF,
-0xABF88DC6,
-0xAB5679F7,
-0xB0937383,
-0xDFCE79F7,
-0xB091E6BB,
-0xE5BBE74F,
-0xB3FA6F0F,
-0x6FFB76CE,
-0xEE0DF9CF,
-0x2BFBEFEF,
-0xCFEEF9CF,
-0x76CEAD24,
- 

[HELP/RFC] Moving ppc8xx microcode patch from micropatch.c to firmware

2015-06-30 Thread christophe leroy
I'm trying to move the 3 microcode patches included in 
arch/powerpc/sysdev/micropatch.c into the firmware directory in order to 
use request_firmware() and then be able to add additional micropatch 
that I need to relocate SMC2 on my MPC885.


I have written the below patch in order to test the principle, but the 
firmware never gets included in my kernel, allthough I have set the 
below CONFIG items:


# CONFIG_NO_UCODE_PATCH is not set
CONFIG_USB_SOF_UCODE_PATCH=y
# CONFIG_I2C_SPI_UCODE_PATCH is not set
# CONFIG_I2C_SPI_SMC1_UCODE_PATCH is not set
CONFIG_UCODE_PATCH=y
#
# Generic Driver Options
#
# CONFIG_UEVENT_HELPER is not set
CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y
# CONFIG_STANDALONE is not set
# CONFIG_PREVENT_FIRMWARE_BUILD is not set
CONFIG_FW_LOADER=y
CONFIG_FIRMWARE_IN_KERNEL=y
CONFIG_EXTRA_FIRMWARE=
CONFIG_FW_LOADER_USER_HELPER=y
CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y

Can anybody help in finding what's wrong there ?

Christophe

---
 arch/powerpc/sysdev/micropatch.c | 655 
++-

 firmware/Makefile|   3 +
 firmware/freescale/i2c_spi.bin.ihex  | 257 
 firmware/freescale/i2c_spi_smc1.bin.ihex | 257 
 firmware/freescale/usb_sof.bin.ihex  | 513 
 5 files changed, 1065 insertions(+), 620 deletions(-)
 create mode 100644 firmware/freescale/i2c_spi.bin.ihex
 create mode 100644 firmware/freescale/i2c_spi_smc1.bin.ihex
 create mode 100644 firmware/freescale/usb_sof.bin.ihex

diff --git a/arch/powerpc/sysdev/micropatch.c 
b/arch/powerpc/sysdev/micropatch.c

index 6727dc5..c24780c 100644
--- a/arch/powerpc/sysdev/micropatch.c
+++ b/arch/powerpc/sysdev/micropatch.c
@@ -12,6 +12,8 @@
 #include linux/string.h
 #include linux/mm.h
 #include linux/interrupt.h
+#include linux/firmware.h
+#include linux/module.h
 #include asm/irq.h
 #include asm/page.h
 #include asm/pgtable.h
@@ -19,652 +21,69 @@
 #include asm/cpm.h
 #include asm/cpm1.h

-/*
- * I2C/SPI relocation patch arrays.
- */
-
-#ifdef CONFIG_I2C_SPI_UCODE_PATCH
-
-static uint patch_2000[] __initdata = {
-0x7FFFEFD9,
-0x3FFD,
-0x7FFB49F7,
-0x7FF9,
-0x5FEFADF7,
-0x5F89ADF7,
-0x5FEFAFF7,
-0x5F89AFF7,
-0x3A9CFBC8,
-0xE7C0EDF0,
-0x77C1E1BB,
-0xF4DC7F1D,
-0xABAD932F,
-0x4E08FDCF,
-0x6E0FAF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,
-0x50B24978,
-0x47FD7F1D,
-0x7DFD70AD,
-0xEF717EC1,
-0x6BA47F01,
-0x2D267EFD,
-0x30DE5F5E,
-0xFFFD5F5E,
-0xFFEF5F5E,
-0xFFDF0CA0,
-0xAFED0A9E,
-0xAFDD0C3A,
-0x5F3AAFBD,
-0x7FBDB082,
-0x5F8247F8
-};
-
-static uint patch_2f00[] __initdata = {
-0x3E303430,
-0x34343737,
-0xABF7BF9B,
-0x994B4FBD,
-0xBD599493,
-0x349FFF37,
-0xFB9B177D,
-0xD9936956,
-0xBBFDD697,
-0xBDD2FD11,
-0x31DB9BB3,
-0x63139637,
-0x93733693,
-0x193137F7,
-0x331737AF,
-0x7BB9B999,
-0xBB197957,
-0x7FDFD3D5,
-0x73B773F7,
-0x37933B99,
-0x1D115316,
-0x99315315,
-0x31694BF4,
-0xFBDBD359,
-0x31497353,
-0x76956D69,
-0x7B9D9693,
-0x13131979,
-0x79376935
-};
-#endif
-
-/*
- * I2C/SPI/SMC1 relocation patch arrays.
- */
-
-#ifdef CONFIG_I2C_SPI_SMC1_UCODE_PATCH
+MODULE_FIRMWARE(freescale/i2c_spi.bin);
+MODULE_FIRMWARE(freescale/i2c_spi_smc1.bin);
+MODULE_FIRMWARE(freescale/usb_sof.bin);

-static uint patch_2000[] __initdata = {
-0x3fff,
-0x3ffd,
-0x3ffb,
-0x3ff9,
-0x5f13eff8,
-0x5eb5eff8,