From afbf7e4a0e24ae8f45e5667638de6b537a3a78d0 Mon Sep 17 00:00:00 2001 From: liutianyu1250 Date: Tue, 23 Jul 2024 11:34:23 +0800 Subject: [PATCH 1/9] mmc: phytium-mci: check start_cmd bit ensure HLE not happen Need polling for 0 on the start_cmd bit before mmc_ops_request, otherwise will happen hardware locked error(HLE) because the controller cannot load a command issued by software. And cause card can't be identifed. Signed-off-by: liutianyu1250 --- drivers/mmc/host/phytium-mci.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/mmc/host/phytium-mci.c b/drivers/mmc/host/phytium-mci.c index 4a938fea360..b511d893be2 100644 --- a/drivers/mmc/host/phytium-mci.c +++ b/drivers/mmc/host/phytium-mci.c @@ -873,6 +873,13 @@ static void phytium_mci_ops_request(struct mmc_host *mmc, struct mmc_request *mr if (rc == -ETIMEDOUT) pr_debug("%s %d, timeout mci_status: 0x%08x\n", __func__, __LINE__, data); + rc = readl_relaxed_poll_timeout(host->base + MCI_CMD, + data, + !(data & MCI_CMD_START), + 0, 500 * 1000); + if (rc == -ETIMEDOUT) + pr_debug("%s %d, timeout mci_cmd.start_cmd bit clear: 0x%08x\n", __func__, __LINE__, data); + dev_dbg(host->dev, "%s %d: cmd:%d arg:0x%x\n", __func__, __LINE__, mrq->cmd->opcode, mrq->cmd->arg); -- Gitee From 12e1058ec27d8af3f448f9a4a9267c42da4d61bc Mon Sep 17 00:00:00 2001 From: Huangjie Date: Fri, 26 Jul 2024 11:03:57 +0800 Subject: [PATCH 2/9] drivers: drm/phytium: add backlight class device to driver kconfig dependencies when set DRM_PHYTIUM as Y and BACKLIGHT_CLASS_DEVICE as M caused ld error below: phytium_panel.c:395:(.text+0xaec): undefined reference to `backlight_device_register' Signed-off-by: Huangjie --- drivers/gpu/drm/phytium/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/phytium/Kconfig b/drivers/gpu/drm/phytium/Kconfig index e1b91e6a2ca..d8375914610 100644 --- a/drivers/gpu/drm/phytium/Kconfig +++ b/drivers/gpu/drm/phytium/Kconfig @@ -6,6 +6,7 @@ config DRM_PHYTIUM select DRM_DISPLAY_HELPER select DRM_DISPLAY_DP_HELPER select DRM_DISPLAY_HDCP_HELPER + select BACKLIGHT_CLASS_DEVICE help Choose this option if you have a phytium graphics card. This driver provides kernel mode setting and buffer management to userspace. -- Gitee From a9e2b925b2ce21ee82325b143b6b02403581df32 Mon Sep 17 00:00:00 2001 From: liutianyu1250 Date: Fri, 2 Aug 2024 16:20:59 +0800 Subject: [PATCH 3/9] arm64: configs: add phytium_debug.config Add debug config fragment. We can use in this way: make phytium_defconfig phytium_debug.config Signed-off-by: liutianyu1250 --- arch/arm64/configs/phytium_debug.config | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 arch/arm64/configs/phytium_debug.config diff --git a/arch/arm64/configs/phytium_debug.config b/arch/arm64/configs/phytium_debug.config new file mode 100644 index 00000000000..db780427ede --- /dev/null +++ b/arch/arm64/configs/phytium_debug.config @@ -0,0 +1,9 @@ +CONFIG_PRINTK_CALLER=y +CONFIG_DYNAMIC_DEBUG=y +# CONFIG_DEBUG_INFO_REDUCED is not set +CONFIG_DEBUG_INFO_BTF=y +CONFIG_MODULE_ALLOW_BTF_MISMATCH=y +CONFIG_FTRACE=y +CONFIG_FUNCTION_TRACER=y +CONFIG_FTRACE_SYSCALLS=y +CONFIG_KPROBES=y -- Gitee From 8726720395794663156a1349be11af1d8404e8e2 Mon Sep 17 00:00:00 2001 From: liutianyu1250 Date: Mon, 19 Aug 2024 14:43:22 +0800 Subject: [PATCH 4/9] arm64: phytium_defconfig: select PHYTIUM_I3C_MASTER Signed-off-by: liutianyu1250 --- arch/arm64/configs/phytium_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/configs/phytium_defconfig b/arch/arm64/configs/phytium_defconfig index ae607101b90..0e9274df28f 100644 --- a/arch/arm64/configs/phytium_defconfig +++ b/arch/arm64/configs/phytium_defconfig @@ -400,7 +400,7 @@ CONFIG_I2C_PHYTIUM_PLATFORM=y CONFIG_I2C_RK3X=y CONFIG_I2C_CROS_EC_TUNNEL=y CONFIG_I3C=y -CONFIG_CDNS_I3C_MASTER=y +CONFIG_PHYTIUM_I3C_MASTER=y CONFIG_SPI=y CONFIG_SPI_CADENCE_QUADSPI=y CONFIG_SPI_DESIGNWARE=m -- Gitee From 7b41d84951236cfab9f3d3b81afc53d63799241b Mon Sep 17 00:00:00 2001 From: INAGAKI Hiroshi Date: Sun, 21 Apr 2024 16:39:52 +0900 Subject: [PATCH 5/9] block: fix and simplify blkdevparts= cmdline parsing Fix the cmdline parsing of the "blkdevparts=" parameter using strsep(), which makes the code simpler. Before commit 146afeb235cc ("block: use strscpy() to instead of strncpy()"), we used a strncpy() to copy a block device name and partition names. The commit simply replaced a strncpy() and NULL termination with a strscpy(). It did not update calculations of length passed to strscpy(). While the length passed to strncpy() is just a length of valid characters without NULL termination ('\0'), strscpy() takes it as a length of the destination buffer, including a NULL termination. Since the source buffer is not necessarily NULL terminated, the current code copies "length - 1" characters and puts a NULL character in the destination buffer. It replaces the last character with NULL and breaks the parsing. As an example, that buffer will be passed to parse_parts() and breaks parsing sub-partitions due to the missing ')' at the end, like the following. example (Check Point V-80 & OpenWrt): - Linux Kernel 6.6 [ 0.000000] Kernel command line: console=ttyS0,115200 earlycon=uart8250,mmio32,0xf0512000 crashkernel=30M mvpp2x.queue_mode=1 blkdevparts=mmcblk1:48M@10M(kernel-1),1M(dtb-1),720M(rootfs-1),48M(kernel-2),1M(dtb-2),720M(rootfs-2),300M(default_sw),650M(logs),1M(preset_cfg),1M(adsl),-(storage) maxcpus=4 ... [ 0.884016] mmc1: new HS200 MMC card at address 0001 [ 0.889951] mmcblk1: mmc1:0001 004GA0 3.69 GiB [ 0.895043] cmdline partition format is invalid. [ 0.895704] mmcblk1: p1 [ 0.903447] mmcblk1boot0: mmc1:0001 004GA0 2.00 MiB [ 0.908667] mmcblk1boot1: mmc1:0001 004GA0 2.00 MiB [ 0.913765] mmcblk1rpmb: mmc1:0001 004GA0 512 KiB, chardev (248:0) 1. "48M@10M(kernel-1),..." is passed to strscpy() with length=17 from parse_parts() 2. strscpy() returns -E2BIG and the destination buffer has "48M@10M(kernel-1\0" 3. "48M@10M(kernel-1\0" is passed to parse_subpart() 4. parse_subpart() fails to find ')' when parsing a partition name, and returns error - Linux Kernel 6.1 [ 0.000000] Kernel command line: console=ttyS0,115200 earlycon=uart8250,mmio32,0xf0512000 crashkernel=30M mvpp2x.queue_mode=1 blkdevparts=mmcblk1:48M@10M(kernel-1),1M(dtb-1),720M(rootfs-1),48M(kernel-2),1M(dtb-2),720M(rootfs-2),300M(default_sw),650M(logs),1M(preset_cfg),1M(adsl),-(storage) maxcpus=4 ... [ 0.953142] mmc1: new HS200 MMC card at address 0001 [ 0.959114] mmcblk1: mmc1:0001 004GA0 3.69 GiB [ 0.964259] mmcblk1: p1(kernel-1) p2(dtb-1) p3(rootfs-1) p4(kernel-2) p5(dtb-2) 6(rootfs-2) p7(default_sw) p8(logs) p9(preset_cfg) p10(adsl) p11(storage) [ 0.979174] mmcblk1boot0: mmc1:0001 004GA0 2.00 MiB [ 0.984674] mmcblk1boot1: mmc1:0001 004GA0 2.00 MiB [ 0.989926] mmcblk1rpmb: mmc1:0001 004GA0 512 KiB, chardev (248:0 By the way, strscpy() takes a length of destination buffer and it is often confusing when copying characters with a specified length. Using strsep() helps to separate the string by the specified character. Then, we can use strscpy() naturally with the size of the destination buffer. Separating the string on the fly is also useful to omit the redundant string copy, reducing memory usage and improve the code readability. Fixes: 146afeb235cc ("block: use strscpy() to instead of strncpy()") Suggested-by: Naohiro Aota Signed-off-by: INAGAKI Hiroshi Reviewed-by: Daniel Golle Link: https://lore.kernel.org/r/20240421074005.565-1-musashino.open@gmail.com Signed-off-by: Jens Axboe --- block/partitions/cmdline.c | 49 ++++++++++---------------------------- 1 file changed, 12 insertions(+), 37 deletions(-) diff --git a/block/partitions/cmdline.c b/block/partitions/cmdline.c index c03bc105e57..152c85df92b 100644 --- a/block/partitions/cmdline.c +++ b/block/partitions/cmdline.c @@ -70,8 +70,8 @@ static int parse_subpart(struct cmdline_subpart **subpart, char *partdef) } if (*partdef == '(') { - int length; - char *next = strchr(++partdef, ')'); + partdef++; + char *next = strsep(&partdef, ")"); if (!next) { pr_warn("cmdline partition format is invalid."); @@ -79,11 +79,7 @@ static int parse_subpart(struct cmdline_subpart **subpart, char *partdef) goto fail; } - length = min_t(int, next - partdef, - sizeof(new_subpart->name) - 1); - strscpy(new_subpart->name, partdef, length); - - partdef = ++next; + strscpy(new_subpart->name, next, sizeof(new_subpart->name)); } else new_subpart->name[0] = '\0'; @@ -117,14 +113,12 @@ static void free_subpart(struct cmdline_parts *parts) } } -static int parse_parts(struct cmdline_parts **parts, const char *bdevdef) +static int parse_parts(struct cmdline_parts **parts, char *bdevdef) { int ret = -EINVAL; char *next; - int length; struct cmdline_subpart **next_subpart; struct cmdline_parts *newparts; - char buf[BDEVNAME_SIZE + 32 + 4]; *parts = NULL; @@ -132,28 +126,19 @@ static int parse_parts(struct cmdline_parts **parts, const char *bdevdef) if (!newparts) return -ENOMEM; - next = strchr(bdevdef, ':'); + next = strsep(&bdevdef, ":"); if (!next) { pr_warn("cmdline partition has no block device."); goto fail; } - length = min_t(int, next - bdevdef, sizeof(newparts->name) - 1); - strscpy(newparts->name, bdevdef, length); + strscpy(newparts->name, next, sizeof(newparts->name)); newparts->nr_subparts = 0; next_subpart = &newparts->subpart; - while (next && *(++next)) { - bdevdef = next; - next = strchr(bdevdef, ','); - - length = (!next) ? (sizeof(buf) - 1) : - min_t(int, next - bdevdef, sizeof(buf) - 1); - - strscpy(buf, bdevdef, length); - - ret = parse_subpart(next_subpart, buf); + while ((next = strsep(&bdevdef, ","))) { + ret = parse_subpart(next_subpart, next); if (ret) goto fail; @@ -199,24 +184,17 @@ static int cmdline_parts_parse(struct cmdline_parts **parts, *parts = NULL; - next = pbuf = buf = kstrdup(cmdline, GFP_KERNEL); + pbuf = buf = kstrdup(cmdline, GFP_KERNEL); if (!buf) return -ENOMEM; next_parts = parts; - while (next && *pbuf) { - next = strchr(pbuf, ';'); - if (next) - *next = '\0'; - - ret = parse_parts(next_parts, pbuf); + while ((next = strsep(&pbuf, ";"))) { + ret = parse_parts(next_parts, next); if (ret) goto fail; - if (next) - pbuf = ++next; - next_parts = &(*next_parts)->next_parts; } @@ -250,7 +228,6 @@ static struct cmdline_parts *bdev_parts; static int add_part(int slot, struct cmdline_subpart *subpart, struct parsed_partitions *state) { - int label_min; struct partition_meta_info *info; char tmp[sizeof(info->volname) + 4]; @@ -262,9 +239,7 @@ static int add_part(int slot, struct cmdline_subpart *subpart, info = &state->parts[slot].info; - label_min = min_t(int, sizeof(info->volname) - 1, - sizeof(subpart->name)); - strscpy(info->volname, subpart->name, label_min); + strscpy(info->volname, subpart->name, sizeof(info->volname)); snprintf(tmp, sizeof(tmp), "(%s)", info->volname); strlcat(state->pp_buf, tmp, PAGE_SIZE); -- Gitee From f2d578f9ce929a787a89d2a1047dd57d7d42c300 Mon Sep 17 00:00:00 2001 From: liutianyu1250 Date: Fri, 23 Aug 2024 09:47:15 +0800 Subject: [PATCH 6/9] arm64: phytium_defconfig: enable exfat fs Signed-off-by: liutianyu1250 --- arch/arm64/configs/phytium_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/configs/phytium_defconfig b/arch/arm64/configs/phytium_defconfig index 0e9274df28f..144d50df984 100644 --- a/arch/arm64/configs/phytium_defconfig +++ b/arch/arm64/configs/phytium_defconfig @@ -896,6 +896,7 @@ CONFIG_CUSE=m CONFIG_OVERLAY_FS=m CONFIG_ISO9660_FS=y CONFIG_VFAT_FS=y +CONFIG_EXFAT_FS=m CONFIG_TMPFS_POSIX_ACL=y CONFIG_HUGETLBFS=y CONFIG_EFIVAR_FS=y -- Gitee From ef606f8edfeb6702d7c654bbb3e6cb9ceac62fc2 Mon Sep 17 00:00:00 2001 From: liutianyu1250 Date: Fri, 23 Aug 2024 09:51:16 +0800 Subject: [PATCH 7/9] arm64: phytium_defconfig: enable zram Signed-off-by: liutianyu1250 --- arch/arm64/configs/phytium_defconfig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm64/configs/phytium_defconfig b/arch/arm64/configs/phytium_defconfig index 144d50df984..a943a241b61 100644 --- a/arch/arm64/configs/phytium_defconfig +++ b/arch/arm64/configs/phytium_defconfig @@ -210,6 +210,7 @@ CONFIG_MTD_NAND_BRCMNAND_IPROC=m CONFIG_MTD_SPI_NOR=y CONFIG_MTD_UBI=m CONFIG_OF_CONFIGFS=y +CONFIG_ZRAM=m CONFIG_BLK_DEV_LOOP=y CONFIG_BLK_DEV_NBD=m CONFIG_VIRTIO_BLK=y @@ -923,6 +924,9 @@ CONFIG_CRYPTO_TEST=m CONFIG_CRYPTO_DES=m CONFIG_CRYPTO_ECHAINIV=y CONFIG_CRYPTO_MICHAEL_MIC=m +CONFIG_CRYPTO_842=m +CONFIG_CRYPTO_LZ4=m +CONFIG_CRYPTO_LZ4HC=m CONFIG_CRYPTO_ANSI_CPRNG=y CONFIG_CRYPTO_USER_API_RNG=m CONFIG_CRYPTO_CHACHA20_NEON=m -- Gitee From c01014ad5b63f5d5d935a1605d42e9b6f2b73335 Mon Sep 17 00:00:00 2001 From: Huangjie Date: Mon, 29 Jul 2024 15:33:34 +0800 Subject: [PATCH 8/9] drivers: dma: add module version for phytium gdma driver Signed-off-by: Huangjie --- drivers/dma/phytium/phytium-gdmac.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/dma/phytium/phytium-gdmac.c b/drivers/dma/phytium/phytium-gdmac.c index b3488bfb66b..ac8dd74b44c 100644 --- a/drivers/dma/phytium/phytium-gdmac.c +++ b/drivers/dma/phytium/phytium-gdmac.c @@ -29,6 +29,7 @@ #include #include "phytium-gdmac.h" +#define PHYTIUM_GDMA_DRIVER_VERSION "1.0.0" static inline struct phytium_gdma_device *to_gdma_device(struct dma_chan *chan) { @@ -1031,3 +1032,4 @@ module_exit(phytium_gdma_exit); MODULE_LICENSE("GPL v2"); MODULE_DESCRIPTION("Phytium gdma Controller platform driver"); MODULE_AUTHOR("HuangJie "); +MODULE_VERSION(PHYTIUM_GDMA_DRIVER_VERSION); -- Gitee From 662bfb88959757471794bd9a6089d373903898f3 Mon Sep 17 00:00:00 2001 From: Huangjie Date: Mon, 2 Sep 2024 17:58:49 +0800 Subject: [PATCH 9/9] drivers: drm/phytium: fix fb dev mmap problem Signed-off-by: Huangjie --- drivers/gpu/drm/phytium/phytium_fbdev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/phytium/phytium_fbdev.c b/drivers/gpu/drm/phytium/phytium_fbdev.c index adce24d159b..8c424fc35e0 100644 --- a/drivers/gpu/drm/phytium/phytium_fbdev.c +++ b/drivers/gpu/drm/phytium/phytium_fbdev.c @@ -37,7 +37,8 @@ static const struct fb_ops phytium_fbdev_ops = { .fb_mmap = phytium_fbdev_mmap, .fb_destroy = phytium_fbdev_destroy, DRM_FB_HELPER_DEFAULT_OPS, - FB_DEFAULT_IOMEM_OPS, + __FB_DEFAULT_IOMEM_OPS_RDWR, + __FB_DEFAULT_IOMEM_OPS_DRAW, }; static int -- Gitee