Merge Official Source
Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
LINUX_VERSION-5.15 = .107
|
||||
LINUX_KERNEL_HASH-5.15.107 = 19370e769045681f52cceedb14ecda97e89b1b058133a0c8ad45d35ffbc5afa8
|
||||
LINUX_VERSION-5.15 = .108
|
||||
LINUX_KERNEL_HASH-5.15.108 = 8beb69ada46f1cbca2f4cf901ec078846035c1cd925d9471422f65aff74243ba
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
#include <mtd.h>
|
||||
#include <linux/mtd/mtd.h>
|
||||
@@ -25,7 +32,19 @@ int board_init(void)
|
||||
@@ -25,7 +32,22 @@ int board_init(void)
|
||||
|
||||
int board_late_init(void)
|
||||
{
|
||||
@@ -27,7 +27,10 @@
|
||||
+ if (!button_get_by_label(CONFIG_RESET_BUTTON_LABEL, &dev)) {
|
||||
+ puts("reset button found\n");
|
||||
+#ifdef CONFIG_RESET_BUTTON_SETTLE_DELAY
|
||||
+ mdelay(CONFIG_RESET_BUTTON_SETTLE_DELAY);
|
||||
+ if (CONFIG_RESET_BUTTON_SETTLE_DELAY > 0) {
|
||||
+ button_get_state(dev);
|
||||
+ mdelay(CONFIG_RESET_BUTTON_SETTLE_DELAY);
|
||||
+ }
|
||||
+#endif
|
||||
+ if (button_get_state(dev) == BUTTON_ON) {
|
||||
+ puts("button pushed, resetting environment\n");
|
||||
@@ -40,7 +43,7 @@
|
||||
}
|
||||
--- a/arch/arm/mach-mediatek/Kconfig
|
||||
+++ b/arch/arm/mach-mediatek/Kconfig
|
||||
@@ -140,4 +140,8 @@ config MTK_BROM_HEADER_INFO
|
||||
@@ -140,4 +140,11 @@ config MTK_BROM_HEADER_INFO
|
||||
|
||||
source "board/mediatek/mt7629/Kconfig"
|
||||
|
||||
@@ -48,4 +51,7 @@
|
||||
+ string "Button to trigger factory reset"
|
||||
+ default "reset"
|
||||
+
|
||||
+config RESET_BUTTON_SETTLE_DELAY
|
||||
+ int "Delay to wait for button to settle"
|
||||
+ default 0
|
||||
endif
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
@@ -41,3 +50,22 @@ int mmc_get_env_dev(void)
|
||||
@@ -41,3 +50,25 @@ int mmc_get_env_dev(void)
|
||||
return mmc_get_boot_dev();
|
||||
}
|
||||
#endif
|
||||
@@ -30,7 +30,10 @@
|
||||
+ if (!button_get_by_label(CONFIG_RESET_BUTTON_LABEL, &dev)) {
|
||||
+ puts("reset button found\n");
|
||||
+#ifdef CONFIG_RESET_BUTTON_SETTLE_DELAY
|
||||
+ mdelay(CONFIG_RESET_BUTTON_SETTLE_DELAY);
|
||||
+ if (CONFIG_RESET_BUTTON_SETTLE_DELAY > 0) {
|
||||
+ button_get_state(dev);
|
||||
+ mdelay(CONFIG_RESET_BUTTON_SETTLE_DELAY);
|
||||
+ }
|
||||
+#endif
|
||||
+ if (button_get_state(dev) == BUTTON_ON) {
|
||||
+ puts("button pushed, resetting environment\n");
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
#include <mtd.h>
|
||||
#include <linux/mtd/mtd.h>
|
||||
@@ -24,7 +31,19 @@ int board_init(void)
|
||||
@@ -24,7 +31,22 @@ int board_init(void)
|
||||
|
||||
int board_late_init(void)
|
||||
{
|
||||
@@ -28,7 +28,10 @@
|
||||
+ if (!button_get_by_label(CONFIG_RESET_BUTTON_LABEL, &dev)) {
|
||||
+ puts("reset button found\n");
|
||||
+#ifdef CONFIG_RESET_BUTTON_SETTLE_DELAY
|
||||
+ mdelay(CONFIG_RESET_BUTTON_SETTLE_DELAY);
|
||||
+ if (CONFIG_RESET_BUTTON_SETTLE_DELAY > 0) {
|
||||
+ button_get_state(dev);
|
||||
+ mdelay(CONFIG_RESET_BUTTON_SETTLE_DELAY);
|
||||
+ }
|
||||
+#endif
|
||||
+ if (button_get_state(dev) == BUTTON_ON) {
|
||||
+ puts("button pushed, resetting environment\n");
|
||||
|
||||
@@ -213,7 +213,15 @@
|
||||
+_set_bmf=setenv _set_bmf ; setenv bootmenu_${_menu_next} "Reset all settings to factory defaults.=run reset_factory ; reset" ; setenv _menu_next
|
||||
--- a/arch/arm/dts/mt7623n-bananapi-bpi-r2.dts
|
||||
+++ b/arch/arm/dts/mt7623n-bananapi-bpi-r2.dts
|
||||
@@ -66,6 +66,15 @@
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
+#include <dt-bindings/input/linux-event-codes.h>
|
||||
#include "mt7623.dtsi"
|
||||
#include "mt7623-u-boot.dtsi"
|
||||
|
||||
@@ -66,6 +67,16 @@
|
||||
default-state = "off";
|
||||
};
|
||||
};
|
||||
@@ -224,6 +232,7 @@
|
||||
+ factory {
|
||||
+ label = "factory";
|
||||
+ gpios = <&gpio 256 GPIO_ACTIVE_LOW>;
|
||||
+ linux,code = <KEY_RESTART>;
|
||||
+ };
|
||||
+ };
|
||||
};
|
||||
|
||||
@@ -191,3 +191,52 @@
|
||||
+_update_bootdev=setenv _update_bootdev ; setenv bootargs "$console root=/dev/mmcblk0p65"
|
||||
+_switch_to_menu=setenv _switch_to_menu ; setenv bootdelay 3 ; setenv bootmenu_delay 3 ; setenv bootmenu_0 $bootmenu_0d ; setenv bootmenu_0d ; run _bootmenu_update_title
|
||||
+_bootmenu_update_title=setenv _bootmenu_update_title ; setenv bootmenu_title "$bootmenu_title [33m$ver[0m"
|
||||
--- a/arch/arm/dts/mt7623a-unielec-u7623-02-emmc.dts
|
||||
+++ b/arch/arm/dts/mt7623a-unielec-u7623-02-emmc.dts
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
+#include <dt-bindings/input/linux-event-codes.h>
|
||||
#include "mt7623.dtsi"
|
||||
#include "mt7623-u-boot.dtsi"
|
||||
|
||||
@@ -50,6 +51,18 @@
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
+ gpio-keys {
|
||||
+ compatible = "gpio-keys";
|
||||
+ pinctrl-names = "default";
|
||||
+ pinctrl-0 = <&key_pins_a>;
|
||||
+
|
||||
+ factory {
|
||||
+ label = "factory";
|
||||
+ gpios = <&gpio 256 GPIO_ACTIVE_LOW>;
|
||||
+ linux,code = <KEY_RESTART>;
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
leds {
|
||||
compatible = "gpio-leds";
|
||||
|
||||
@@ -109,6 +122,19 @@
|
||||
};
|
||||
};
|
||||
|
||||
+ key_pins_a: keys-alt {
|
||||
+ mux {
|
||||
+ function = "gpio";
|
||||
+ groups = "msdc3";
|
||||
+ };
|
||||
+
|
||||
+ conf {
|
||||
+ pins = "MSDC0E_DAT0", "MSDC0E_DAT1";
|
||||
+ input-enable;
|
||||
+ bias-pull-up;
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
mmc0_pins_default: mmc0default {
|
||||
mux {
|
||||
function = "msdc";
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
--- a/arch/arm/dts/mt7622-bananapi-bpi-r64.dts
|
||||
+++ b/arch/arm/dts/mt7622-bananapi-bpi-r64.dts
|
||||
@@ -20,6 +20,7 @@
|
||||
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
+#include <dt-bindings/input/linux-event-codes.h>
|
||||
#include "mt7622.dtsi"
|
||||
#include "mt7622-u-boot.dtsi"
|
||||
|
||||
@@ -20,6 +21,7 @@
|
||||
|
||||
aliases {
|
||||
spi0 = &snfi;
|
||||
@@ -8,7 +16,7 @@
|
||||
};
|
||||
|
||||
memory@40000000 {
|
||||
@@ -27,6 +28,42 @@
|
||||
@@ -27,6 +29,44 @@
|
||||
reg = <0x40000000 0x40000000>;
|
||||
};
|
||||
|
||||
@@ -18,11 +26,13 @@
|
||||
+ reset {
|
||||
+ label = "reset";
|
||||
+ gpios = <&gpio 0 GPIO_ACTIVE_LOW>;
|
||||
+ linux,code = <KEY_RESTART>;
|
||||
+ };
|
||||
+
|
||||
+ wps {
|
||||
+ label = "wps";
|
||||
+ gpios = <&gpio 102 GPIO_ACTIVE_LOW>;
|
||||
+ linux,code = <KEY_WPS_BUTTON>;
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
@@ -51,7 +61,7 @@
|
||||
reg_1p8v: regulator-1p8v {
|
||||
compatible = "regulator-fixed";
|
||||
regulator-name = "fixed-1.8V";
|
||||
@@ -182,6 +219,7 @@
|
||||
@@ -182,6 +222,7 @@
|
||||
};
|
||||
|
||||
&uart0 {
|
||||
@@ -59,7 +69,7 @@
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
@@ -197,7 +235,7 @@
|
||||
@@ -197,7 +238,7 @@
|
||||
status = "okay";
|
||||
bus-width = <8>;
|
||||
max-frequency = <50000000>;
|
||||
@@ -68,7 +78,7 @@
|
||||
vmmc-supply = <®_3p3v>;
|
||||
vqmmc-supply = <®_3p3v>;
|
||||
non-removable;
|
||||
@@ -208,7 +246,7 @@
|
||||
@@ -208,7 +249,7 @@
|
||||
pinctrl-0 = <&mmc1_pins_default>;
|
||||
status = "okay";
|
||||
bus-width = <4>;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/arch/arm/dts/mt7622-bananapi-bpi-r64.dts
|
||||
+++ b/arch/arm/dts/mt7622-bananapi-bpi-r64.dts
|
||||
@@ -19,7 +19,7 @@
|
||||
@@ -20,7 +20,7 @@
|
||||
};
|
||||
|
||||
aliases {
|
||||
@@ -9,7 +9,7 @@
|
||||
ethernet0 = ð
|
||||
};
|
||||
|
||||
@@ -205,17 +205,11 @@
|
||||
@@ -208,17 +208,11 @@
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/arch/arm/dts/mt7623n-bananapi-bpi-r2.dts
|
||||
+++ b/arch/arm/dts/mt7623n-bananapi-bpi-r2.dts
|
||||
@@ -50,19 +50,19 @@
|
||||
@@ -51,19 +51,19 @@
|
||||
|
||||
blue {
|
||||
label = "bpi-r2:pio:blue";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/arch/arm/dts/mt7623n-bananapi-bpi-r2.dts
|
||||
+++ b/arch/arm/dts/mt7623n-bananapi-bpi-r2.dts
|
||||
@@ -243,6 +243,7 @@
|
||||
@@ -245,6 +245,7 @@
|
||||
&uart0 {
|
||||
pinctrl-names = "default";
|
||||
pinctrl-0 = <&uart0_pins_a>;
|
||||
|
||||
@@ -144,7 +144,7 @@
|
||||
+CONFIG_USB_STORAGE=y
|
||||
--- /dev/null
|
||||
+++ b/arch/arm/dts/mt7622-linksys-e8450-ubi.dts
|
||||
@@ -0,0 +1,194 @@
|
||||
@@ -0,0 +1,197 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0
|
||||
+/*
|
||||
+ * Copyright (c) 2019 MediaTek Inc.
|
||||
@@ -152,6 +152,7 @@
|
||||
+ */
|
||||
+
|
||||
+/dts-v1/;
|
||||
+#include <dt-bindings/input/linux-event-codes.h>
|
||||
+#include "mt7622.dtsi"
|
||||
+#include "mt7622-u-boot.dtsi"
|
||||
+
|
||||
@@ -175,11 +176,13 @@
|
||||
+ factory {
|
||||
+ label = "reset";
|
||||
+ gpios = <&gpio 0 GPIO_ACTIVE_LOW>;
|
||||
+ linux,code = <KEY_RESTART>;
|
||||
+ };
|
||||
+
|
||||
+ wps {
|
||||
+ label = "wps";
|
||||
+ gpios = <&gpio 102 GPIO_ACTIVE_LOW>;
|
||||
+ linux,code = <KEY_WPS_BUTTON>;
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
|
||||
@@ -158,6 +158,7 @@
|
||||
+ */
|
||||
+
|
||||
+/dts-v1/;
|
||||
+#include <dt-bindings/input/linux-event-codes.h>
|
||||
+#include "mt7622.dtsi"
|
||||
+#include "mt7622-u-boot.dtsi"
|
||||
+
|
||||
@@ -178,12 +179,11 @@
|
||||
+
|
||||
+ gpio-keys {
|
||||
+ compatible = "gpio-keys";
|
||||
+ u-boot,dm-pre-reloc;
|
||||
+
|
||||
+ reset {
|
||||
+ label = "reset";
|
||||
+ gpios = <&gpio 62 GPIO_ACTIVE_LOW>;
|
||||
+ u-boot,dm-pre-reloc;
|
||||
+ linux,code = <KEY_RESTART>;
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
|
||||
@@ -851,7 +851,7 @@
|
||||
+
|
||||
--- /dev/null
|
||||
+++ b/arch/arm/dts/mt7986a-bpi-r3-sd.dts
|
||||
@@ -0,0 +1,270 @@
|
||||
@@ -0,0 +1,272 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0
|
||||
+/*
|
||||
+ * Copyright (c) 2021 MediaTek Inc.
|
||||
@@ -859,6 +859,7 @@
|
||||
+ */
|
||||
+
|
||||
+/dts-v1/;
|
||||
+#include <dt-bindings/input/linux-event-codes.h>
|
||||
+#include "mt7986.dtsi"
|
||||
+#include <dt-bindings/gpio/gpio.h>
|
||||
+
|
||||
@@ -893,6 +894,7 @@
|
||||
+ wps {
|
||||
+ label = "reset";
|
||||
+ gpios = <&gpio 10 GPIO_ACTIVE_LOW>;
|
||||
+ linux,code = <KEY_RESTART>;
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
|
||||
@@ -183,7 +183,7 @@
|
||||
+CONFIG_SERVERIP="192.168.1.254"
|
||||
--- /dev/null
|
||||
+++ b/arch/arm/dts/mt7986a-xiaomi_redmi-ax6000.dts
|
||||
@@ -0,0 +1,153 @@
|
||||
@@ -0,0 +1,156 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0
|
||||
+/*
|
||||
+ * Copyright (c) 2021 MediaTek Inc.
|
||||
@@ -191,6 +191,7 @@
|
||||
+ */
|
||||
+
|
||||
+/dts-v1/;
|
||||
+#include <dt-bindings/input/linux-event-codes.h>
|
||||
+#include "mt7986.dtsi"
|
||||
+#include <dt-bindings/gpio/gpio.h>
|
||||
+
|
||||
@@ -210,10 +211,12 @@
|
||||
+ factory {
|
||||
+ label = "reset";
|
||||
+ gpios = <&gpio 9 GPIO_ACTIVE_LOW>;
|
||||
+ linux,code = <KEY_RESTART>;
|
||||
+ };
|
||||
+ mesh {
|
||||
+ label = "mesh";
|
||||
+ gpios = <&gpio 10 GPIO_ACTIVE_LOW>;
|
||||
+ linux,code = <KEY_WPS_BUTTON>;
|
||||
+ };
|
||||
+ };
|
||||
+};
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=ksmbd
|
||||
PKG_VERSION:=3.4.7
|
||||
PKG_VERSION:=3.4.8
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=https://github.com/cifsd-team/ksmbd/releases/download/$(PKG_VERSION)
|
||||
PKG_HASH:=ed9ecb2232046054bf0c1fef41690890f99d93b1d72b7e7d158746ac9be18c7f
|
||||
PKG_HASH:=209bfba4dc5c50007942a3ec24f86a7f7c628618ac07f79c62e3404dc247d495
|
||||
|
||||
PKG_LICENSE:=GPL-2.0-or-later
|
||||
PKG_LICENSE_FILES:=COPYING
|
||||
|
||||
@@ -283,7 +283,7 @@ Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
|
||||
void __user *argp = (void __user *)arg;
|
||||
long ret = 0;
|
||||
|
||||
@@ -1182,6 +1207,15 @@ static long do_fb_ioctl(struct fb_info *
|
||||
@@ -1184,6 +1209,15 @@ static long do_fb_ioctl(struct fb_info *
|
||||
unlock_fb_info(info);
|
||||
console_unlock();
|
||||
break;
|
||||
@@ -299,7 +299,7 @@ Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
|
||||
default:
|
||||
lock_fb_info(info);
|
||||
fb = info->fbops;
|
||||
@@ -1321,6 +1355,7 @@ static long fb_compat_ioctl(struct file
|
||||
@@ -1323,6 +1357,7 @@ static long fb_compat_ioctl(struct file
|
||||
case FBIOPAN_DISPLAY:
|
||||
case FBIOGET_CON2FBMAP:
|
||||
case FBIOPUT_CON2FBMAP:
|
||||
|
||||
@@ -25,7 +25,7 @@ Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
|
||||
|
||||
--- a/MAINTAINERS
|
||||
+++ b/MAINTAINERS
|
||||
@@ -17538,6 +17538,14 @@ T: git git://linuxtv.org/media_tree.git
|
||||
@@ -17537,6 +17537,14 @@ T: git git://linuxtv.org/media_tree.git
|
||||
F: Documentation/devicetree/bindings/media/i2c/sony,imx412.yaml
|
||||
F: drivers/media/i2c/imx412.c
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
|
||||
+...
|
||||
--- a/MAINTAINERS
|
||||
+++ b/MAINTAINERS
|
||||
@@ -17552,6 +17552,7 @@ M: Raspberry Pi Kernel Maintenance <kern
|
||||
@@ -17551,6 +17551,7 @@ M: Raspberry Pi Kernel Maintenance <kern
|
||||
L: linux-media@vger.kernel.org
|
||||
S: Maintained
|
||||
T: git git://linuxtv.org/media_tree.git
|
||||
|
||||
@@ -132,7 +132,7 @@ Signed-off-by: Lee Jackson <info@arducam.com>
|
||||
+...
|
||||
--- a/MAINTAINERS
|
||||
+++ b/MAINTAINERS
|
||||
@@ -17556,6 +17556,14 @@ F: Documentation/devicetree/bindings/med
|
||||
@@ -17555,6 +17555,14 @@ F: Documentation/devicetree/bindings/med
|
||||
F: Documentation/devicetree/bindings/media/i2c/imx477.yaml
|
||||
F: drivers/media/i2c/imx477.c
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ Link: https://patchwork.freedesktop.org/patch/msgid/20220227124713.39766-6-noral
|
||||
|
||||
--- a/MAINTAINERS
|
||||
+++ b/MAINTAINERS
|
||||
@@ -5981,6 +5981,14 @@ T: git git://anongit.freedesktop.org/drm
|
||||
@@ -5980,6 +5980,14 @@ T: git git://anongit.freedesktop.org/drm
|
||||
F: Documentation/devicetree/bindings/display/multi-inno,mi0283qt.txt
|
||||
F: drivers/gpu/drm/tiny/mi0283qt.c
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ This reverts commit 2388f826cdc9af2651991adc0feb79de9bdf2232.
|
||||
|
||||
--- a/drivers/video/fbdev/core/fbmem.c
|
||||
+++ b/drivers/video/fbdev/core/fbmem.c
|
||||
@@ -1629,14 +1629,7 @@ static void do_remove_conflicting_frameb
|
||||
@@ -1631,14 +1631,7 @@ static void do_remove_conflicting_frameb
|
||||
* If it's not a platform device, at least print a warning. A
|
||||
* fix would add code to remove the device from the system.
|
||||
*/
|
||||
|
||||
@@ -20,7 +20,7 @@ This reverts commit c894ac44786cfed383a6c6b20c1bfb12eb96018a.
|
||||
#include <linux/seq_file.h>
|
||||
#include <linux/console.h>
|
||||
#include <linux/kmod.h>
|
||||
@@ -1606,36 +1605,18 @@ static void do_remove_conflicting_frameb
|
||||
@@ -1608,36 +1607,18 @@ static void do_remove_conflicting_frameb
|
||||
/* check all firmware fbs and kick off if the base addr overlaps */
|
||||
for_each_registered_fb(i) {
|
||||
struct apertures_struct *gen_aper;
|
||||
@@ -58,7 +58,7 @@ This reverts commit c894ac44786cfed383a6c6b20c1bfb12eb96018a.
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1973,13 +1954,9 @@ EXPORT_SYMBOL(register_framebuffer);
|
||||
@@ -1975,13 +1956,9 @@ EXPORT_SYMBOL(register_framebuffer);
|
||||
void
|
||||
unregister_framebuffer(struct fb_info *fb_info)
|
||||
{
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
From 1e020e1b96afdecd20680b5b5be2a6ffc3d27628 Mon Sep 17 00:00:00 2001
|
||||
From: Zhihao Cheng <chengzhihao1@huawei.com>
|
||||
Date: Mon, 6 Mar 2023 09:33:08 +0800
|
||||
Subject: [PATCH] ubi: Fix failure attaching when vid_hdr offset equals to
|
||||
(sub)page size
|
||||
|
||||
Following process will make ubi attaching failed since commit
|
||||
1b42b1a36fc946 ("ubi: ensure that VID header offset ... size"):
|
||||
|
||||
ID="0xec,0xa1,0x00,0x15" # 128M 128KB 2KB
|
||||
modprobe nandsim id_bytes=$ID
|
||||
flash_eraseall /dev/mtd0
|
||||
modprobe ubi mtd="0,2048" # set vid_hdr offset as 2048 (one page)
|
||||
(dmesg):
|
||||
ubi0 error: ubi_attach_mtd_dev [ubi]: VID header offset 2048 too large.
|
||||
UBI error: cannot attach mtd0
|
||||
UBI error: cannot initialize UBI, error -22
|
||||
|
||||
Rework original solution, the key point is making sure
|
||||
'vid_hdr_shift + UBI_VID_HDR_SIZE < ubi->vid_hdr_alsize',
|
||||
so we should check vid_hdr_shift rather not vid_hdr_offset.
|
||||
Then, ubi still support (sub)page aligined VID header offset.
|
||||
|
||||
Fixes: 1b42b1a36fc946 ("ubi: ensure that VID header offset ... size")
|
||||
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
|
||||
Tested-by: Nicolas Schichan <nschichan@freebox.fr>
|
||||
Tested-by: Miquel Raynal <miquel.raynal@bootlin.com> # v5.10, v4.19
|
||||
Signed-off-by: Richard Weinberger <richard@nod.at>
|
||||
---
|
||||
drivers/mtd/ubi/build.c | 21 +++++++++++++++------
|
||||
1 file changed, 15 insertions(+), 6 deletions(-)
|
||||
|
||||
--- a/drivers/mtd/ubi/build.c
|
||||
+++ b/drivers/mtd/ubi/build.c
|
||||
@@ -664,12 +664,6 @@ static int io_init(struct ubi_device *ub
|
||||
ubi->ec_hdr_alsize = ALIGN(UBI_EC_HDR_SIZE, ubi->hdrs_min_io_size);
|
||||
ubi->vid_hdr_alsize = ALIGN(UBI_VID_HDR_SIZE, ubi->hdrs_min_io_size);
|
||||
|
||||
- if (ubi->vid_hdr_offset && ((ubi->vid_hdr_offset + UBI_VID_HDR_SIZE) >
|
||||
- ubi->vid_hdr_alsize)) {
|
||||
- ubi_err(ubi, "VID header offset %d too large.", ubi->vid_hdr_offset);
|
||||
- return -EINVAL;
|
||||
- }
|
||||
-
|
||||
dbg_gen("min_io_size %d", ubi->min_io_size);
|
||||
dbg_gen("max_write_size %d", ubi->max_write_size);
|
||||
dbg_gen("hdrs_min_io_size %d", ubi->hdrs_min_io_size);
|
||||
@@ -687,6 +681,21 @@ static int io_init(struct ubi_device *ub
|
||||
ubi->vid_hdr_aloffset;
|
||||
}
|
||||
|
||||
+ /*
|
||||
+ * Memory allocation for VID header is ubi->vid_hdr_alsize
|
||||
+ * which is described in comments in io.c.
|
||||
+ * Make sure VID header shift + UBI_VID_HDR_SIZE not exceeds
|
||||
+ * ubi->vid_hdr_alsize, so that all vid header operations
|
||||
+ * won't access memory out of bounds.
|
||||
+ */
|
||||
+ if ((ubi->vid_hdr_shift + UBI_VID_HDR_SIZE) > ubi->vid_hdr_alsize) {
|
||||
+ ubi_err(ubi, "Invalid VID header offset %d, VID header shift(%d)"
|
||||
+ " + VID header size(%zu) > VID header aligned size(%d).",
|
||||
+ ubi->vid_hdr_offset, ubi->vid_hdr_shift,
|
||||
+ UBI_VID_HDR_SIZE, ubi->vid_hdr_alsize);
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+
|
||||
/* Similar for the data offset */
|
||||
ubi->leb_start = ubi->vid_hdr_offset + UBI_VID_HDR_SIZE;
|
||||
ubi->leb_start = ALIGN(ubi->leb_start, ubi->min_io_size);
|
||||
@@ -1,85 +0,0 @@
|
||||
From: Liang Chen <liangchen.linux@gmail.com>
|
||||
Date: Thu, 13 Apr 2023 17:03:53 +0800
|
||||
Subject: [PATCH] skbuff: Fix a race between coalescing and releasing SKBs
|
||||
|
||||
Commit 1effe8ca4e34 ("skbuff: fix coalescing for page_pool fragment
|
||||
recycling") allowed coalescing to proceed with non page pool page and page
|
||||
pool page when @from is cloned, i.e.
|
||||
|
||||
to->pp_recycle --> false
|
||||
from->pp_recycle --> true
|
||||
skb_cloned(from) --> true
|
||||
|
||||
However, it actually requires skb_cloned(@from) to hold true until
|
||||
coalescing finishes in this situation. If the other cloned SKB is
|
||||
released while the merging is in process, from_shinfo->nr_frags will be
|
||||
set to 0 toward the end of the function, causing the increment of frag
|
||||
page _refcount to be unexpectedly skipped resulting in inconsistent
|
||||
reference counts. Later when SKB(@to) is released, it frees the page
|
||||
directly even though the page pool page is still in use, leading to
|
||||
use-after-free or double-free errors. So it should be prohibited.
|
||||
|
||||
The double-free error message below prompted us to investigate:
|
||||
BUG: Bad page state in process swapper/1 pfn:0e0d1
|
||||
page:00000000c6548b28 refcount:-1 mapcount:0 mapping:0000000000000000
|
||||
index:0x2 pfn:0xe0d1
|
||||
flags: 0xfffffc0000000(node=0|zone=1|lastcpupid=0x1fffff)
|
||||
raw: 000fffffc0000000 0000000000000000 ffffffff00000101 0000000000000000
|
||||
raw: 0000000000000002 0000000000000000 ffffffffffffffff 0000000000000000
|
||||
page dumped because: nonzero _refcount
|
||||
|
||||
CPU: 1 PID: 0 Comm: swapper/1 Tainted: G E 6.2.0+
|
||||
Call Trace:
|
||||
<IRQ>
|
||||
dump_stack_lvl+0x32/0x50
|
||||
bad_page+0x69/0xf0
|
||||
free_pcp_prepare+0x260/0x2f0
|
||||
free_unref_page+0x20/0x1c0
|
||||
skb_release_data+0x10b/0x1a0
|
||||
napi_consume_skb+0x56/0x150
|
||||
net_rx_action+0xf0/0x350
|
||||
? __napi_schedule+0x79/0x90
|
||||
__do_softirq+0xc8/0x2b1
|
||||
__irq_exit_rcu+0xb9/0xf0
|
||||
common_interrupt+0x82/0xa0
|
||||
</IRQ>
|
||||
<TASK>
|
||||
asm_common_interrupt+0x22/0x40
|
||||
RIP: 0010:default_idle+0xb/0x20
|
||||
|
||||
Fixes: 53e0961da1c7 ("page_pool: add frag page recycling support in page pool")
|
||||
Signed-off-by: Liang Chen <liangchen.linux@gmail.com>
|
||||
Reviewed-by: Eric Dumazet <edumazet@google.com>
|
||||
Link: https://lore.kernel.org/r/20230413090353.14448-1-liangchen.linux@gmail.com
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
|
||||
--- a/net/core/skbuff.c
|
||||
+++ b/net/core/skbuff.c
|
||||
@@ -5397,18 +5397,18 @@ bool skb_try_coalesce(struct sk_buff *to
|
||||
if (skb_cloned(to))
|
||||
return false;
|
||||
|
||||
- /* In general, avoid mixing slab allocated and page_pool allocated
|
||||
- * pages within the same SKB. However when @to is not pp_recycle and
|
||||
- * @from is cloned, we can transition frag pages from page_pool to
|
||||
- * reference counted.
|
||||
- *
|
||||
- * On the other hand, don't allow coalescing two pp_recycle SKBs if
|
||||
- * @from is cloned, in case the SKB is using page_pool fragment
|
||||
+ /* In general, avoid mixing page_pool and non-page_pool allocated
|
||||
+ * pages within the same SKB. Additionally avoid dealing with clones
|
||||
+ * with page_pool pages, in case the SKB is using page_pool fragment
|
||||
* references (PP_FLAG_PAGE_FRAG). Since we only take full page
|
||||
* references for cloned SKBs at the moment that would result in
|
||||
* inconsistent reference counts.
|
||||
+ * In theory we could take full references if @from is cloned and
|
||||
+ * !@to->pp_recycle but its tricky (due to potential race with
|
||||
+ * the clone disappearing) and rare, so not worth dealing with.
|
||||
*/
|
||||
- if (to->pp_recycle != (from->pp_recycle && !skb_cloned(from)))
|
||||
+ if (to->pp_recycle != from->pp_recycle ||
|
||||
+ (from->pp_recycle && skb_cloned(from)))
|
||||
return false;
|
||||
|
||||
if (len <= skb_tailroom(to)) {
|
||||
@@ -32,7 +32,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
|
||||
--- a/MAINTAINERS
|
||||
+++ b/MAINTAINERS
|
||||
@@ -11790,6 +11790,14 @@ L: netdev@vger.kernel.org
|
||||
@@ -11789,6 +11789,14 @@ L: netdev@vger.kernel.org
|
||||
S: Maintained
|
||||
F: drivers/net/ethernet/mediatek/
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
|
||||
--- a/drivers/net/phy/sfp.c
|
||||
+++ b/drivers/net/phy/sfp.c
|
||||
@@ -234,6 +234,7 @@ struct sfp {
|
||||
@@ -240,6 +240,7 @@ struct sfp {
|
||||
bool need_poll;
|
||||
|
||||
struct mutex st_mutex; /* Protects state */
|
||||
@@ -28,7 +28,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
unsigned int state_soft_mask;
|
||||
unsigned int state;
|
||||
struct delayed_work poll;
|
||||
@@ -499,17 +500,18 @@ static void sfp_soft_set_state(struct sf
|
||||
@@ -505,17 +506,18 @@ static void sfp_soft_set_state(struct sf
|
||||
static void sfp_soft_start_poll(struct sfp *sfp)
|
||||
{
|
||||
const struct sfp_eeprom_id *id = &sfp->id;
|
||||
@@ -56,7 +56,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
|
||||
if (sfp->state_soft_mask & (SFP_F_LOS | SFP_F_TX_FAULT) &&
|
||||
!sfp->need_poll)
|
||||
@@ -523,10 +525,11 @@ static void sfp_soft_stop_poll(struct sf
|
||||
@@ -529,10 +531,11 @@ static void sfp_soft_stop_poll(struct sf
|
||||
|
||||
static unsigned int sfp_get_state(struct sfp *sfp)
|
||||
{
|
||||
@@ -71,7 +71,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
state |= sfp_soft_get_state(sfp);
|
||||
|
||||
return state;
|
||||
@@ -1940,6 +1943,15 @@ static int sfp_sm_mod_probe(struct sfp *
|
||||
@@ -1942,6 +1945,15 @@ static int sfp_sm_mod_probe(struct sfp *
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
@@ -87,7 +87,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
if (!memcmp(id.base.vendor_name, "ALCATELLUCENT ", 16) &&
|
||||
!memcmp(id.base.vendor_pn, "3FE46541AA ", 16))
|
||||
sfp->module_t_start_up = T_START_UP_BAD_GPON;
|
||||
@@ -2565,6 +2577,8 @@ static int sfp_probe(struct platform_dev
|
||||
@@ -2568,6 +2580,8 @@ static int sfp_probe(struct platform_dev
|
||||
return PTR_ERR(sfp->gpio[i]);
|
||||
}
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
ret = ops->module_insert(bus->upstream, id);
|
||||
--- a/drivers/net/phy/sfp.c
|
||||
+++ b/drivers/net/phy/sfp.c
|
||||
@@ -253,6 +253,8 @@ struct sfp {
|
||||
@@ -259,6 +259,8 @@ struct sfp {
|
||||
unsigned int module_t_start_up;
|
||||
bool tx_fault_ignore;
|
||||
|
||||
@@ -151,7 +151,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
#if IS_ENABLED(CONFIG_HWMON)
|
||||
struct sfp_diag diag;
|
||||
struct delayed_work hwmon_probe;
|
||||
@@ -309,6 +311,93 @@ static const struct of_device_id sfp_of_
|
||||
@@ -315,6 +317,93 @@ static const struct of_device_id sfp_of_
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, sfp_of_match);
|
||||
|
||||
@@ -245,7 +245,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
static unsigned long poll_jiffies;
|
||||
|
||||
static unsigned int sfp_gpio_get_state(struct sfp *sfp)
|
||||
@@ -1964,6 +2053,8 @@ static int sfp_sm_mod_probe(struct sfp *
|
||||
@@ -1966,6 +2055,8 @@ static int sfp_sm_mod_probe(struct sfp *
|
||||
else
|
||||
sfp->tx_fault_ignore = false;
|
||||
|
||||
@@ -254,7 +254,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2075,7 +2166,8 @@ static void sfp_sm_module(struct sfp *sf
|
||||
@@ -2077,7 +2168,8 @@ static void sfp_sm_module(struct sfp *sf
|
||||
break;
|
||||
|
||||
/* Report the module insertion to the upstream device */
|
||||
|
||||
@@ -15,7 +15,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
|
||||
--- a/drivers/net/phy/sfp.c
|
||||
+++ b/drivers/net/phy/sfp.c
|
||||
@@ -311,6 +311,11 @@ static const struct of_device_id sfp_of_
|
||||
@@ -317,6 +317,11 @@ static const struct of_device_id sfp_of_
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, sfp_of_match);
|
||||
|
||||
@@ -27,7 +27,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
static void sfp_quirk_2500basex(const struct sfp_eeprom_id *id,
|
||||
unsigned long *modes)
|
||||
{
|
||||
@@ -341,6 +346,7 @@ static const struct sfp_quirk sfp_quirks
|
||||
@@ -347,6 +352,7 @@ static const struct sfp_quirk sfp_quirks
|
||||
.vendor = "ALCATELLUCENT",
|
||||
.part = "3FE46541AA",
|
||||
.modes = sfp_quirk_2500basex,
|
||||
@@ -35,7 +35,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
}, {
|
||||
// Huawei MA5671A can operate at 2500base-X, but report 1.2GBd
|
||||
// NRZ in their EEPROM
|
||||
@@ -2041,11 +2047,7 @@ static int sfp_sm_mod_probe(struct sfp *
|
||||
@@ -2043,11 +2049,7 @@ static int sfp_sm_mod_probe(struct sfp *
|
||||
if (sfp->gpio[GPIO_LOS])
|
||||
sfp->state_hw_mask |= SFP_F_LOS;
|
||||
|
||||
@@ -48,7 +48,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
|
||||
if (!memcmp(id.base.vendor_name, "HUAWEI ", 16) &&
|
||||
!memcmp(id.base.vendor_pn, "MA5671A ", 16))
|
||||
@@ -2054,6 +2056,8 @@ static int sfp_sm_mod_probe(struct sfp *
|
||||
@@ -2056,6 +2058,8 @@ static int sfp_sm_mod_probe(struct sfp *
|
||||
sfp->tx_fault_ignore = false;
|
||||
|
||||
sfp->quirk = sfp_lookup_quirk(&id);
|
||||
|
||||
@@ -13,7 +13,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
|
||||
--- a/drivers/net/phy/sfp.c
|
||||
+++ b/drivers/net/phy/sfp.c
|
||||
@@ -316,6 +316,11 @@ static void sfp_fixup_long_startup(struc
|
||||
@@ -322,6 +322,11 @@ static void sfp_fixup_long_startup(struc
|
||||
sfp->module_t_start_up = T_START_UP_BAD_GPON;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
static void sfp_quirk_2500basex(const struct sfp_eeprom_id *id,
|
||||
unsigned long *modes)
|
||||
{
|
||||
@@ -353,6 +358,7 @@ static const struct sfp_quirk sfp_quirks
|
||||
@@ -359,6 +364,7 @@ static const struct sfp_quirk sfp_quirks
|
||||
.vendor = "HUAWEI",
|
||||
.part = "MA5671A",
|
||||
.modes = sfp_quirk_2500basex,
|
||||
@@ -33,7 +33,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
}, {
|
||||
// Lantech 8330-262D-E can operate at 2500base-X, but
|
||||
// incorrectly report 2500MBd NRZ in their EEPROM
|
||||
@@ -2049,11 +2055,7 @@ static int sfp_sm_mod_probe(struct sfp *
|
||||
@@ -2051,11 +2057,7 @@ static int sfp_sm_mod_probe(struct sfp *
|
||||
|
||||
sfp->module_t_start_up = T_START_UP;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
linkmode_or(support, support, modes);
|
||||
--- a/drivers/net/phy/sfp.c
|
||||
+++ b/drivers/net/phy/sfp.c
|
||||
@@ -321,6 +321,15 @@ static void sfp_fixup_ignore_tx_fault(st
|
||||
@@ -327,6 +327,15 @@ static void sfp_fixup_ignore_tx_fault(st
|
||||
sfp->tx_fault_ignore = true;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
static void sfp_quirk_2500basex(const struct sfp_eeprom_id *id,
|
||||
unsigned long *modes)
|
||||
{
|
||||
@@ -353,6 +362,10 @@ static const struct sfp_quirk sfp_quirks
|
||||
@@ -359,6 +368,10 @@ static const struct sfp_quirk sfp_quirks
|
||||
.modes = sfp_quirk_2500basex,
|
||||
.fixup = sfp_fixup_long_startup,
|
||||
}, {
|
||||
@@ -55,7 +55,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
// Huawei MA5671A can operate at 2500base-X, but report 1.2GBd
|
||||
// NRZ in their EEPROM
|
||||
.vendor = "HUAWEI",
|
||||
@@ -369,16 +382,18 @@ static const struct sfp_quirk sfp_quirks
|
||||
@@ -375,16 +388,18 @@ static const struct sfp_quirk sfp_quirks
|
||||
.vendor = "UBNT",
|
||||
.part = "UF-INSTANT",
|
||||
.modes = sfp_quirk_ubnt_uf_instant,
|
||||
|
||||
@@ -24,7 +24,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
|
||||
--- a/drivers/net/phy/sfp.c
|
||||
+++ b/drivers/net/phy/sfp.c
|
||||
@@ -366,6 +366,10 @@ static const struct sfp_quirk sfp_quirks
|
||||
@@ -372,6 +372,10 @@ static const struct sfp_quirk sfp_quirks
|
||||
.part = "HL-GSFP",
|
||||
.fixup = sfp_fixup_halny_gsfp,
|
||||
}, {
|
||||
|
||||
@@ -19,7 +19,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
|
||||
--- a/MAINTAINERS
|
||||
+++ b/MAINTAINERS
|
||||
@@ -17962,6 +17962,11 @@ L: netdev@vger.kernel.org
|
||||
@@ -17961,6 +17961,11 @@ L: netdev@vger.kernel.org
|
||||
S: Maintained
|
||||
F: drivers/net/ethernet/dlink/sundance.c
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
|
||||
--- a/MAINTAINERS
|
||||
+++ b/MAINTAINERS
|
||||
@@ -12362,6 +12362,14 @@ S: Supported
|
||||
@@ -12361,6 +12361,14 @@ S: Supported
|
||||
F: Documentation/devicetree/bindings/mtd/atmel-nand.txt
|
||||
F: drivers/mtd/nand/raw/atmel/*
|
||||
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
From: Yousong Zhou <yszhou4tech@gmail.com>
|
||||
Subject: [PATCH] ath79: add nvmem cell mac-address-ascii support
|
||||
Subject: [PATCH] of: net: add nvmem cell mac-address-ascii support
|
||||
|
||||
This is needed for devices with mac address stored in ascii format, e.g.
|
||||
HiWiFi HC6361 to be ported in the following patch.
|
||||
This is needed for devices with mac address stored in ascii format,
|
||||
e.g. HiWiFi HC6361 to be ported in the following patch.
|
||||
|
||||
Submitted-by: Yousong Zhou <yszhou4tech@gmail.com>
|
||||
---
|
||||
net/ethernet/eth.c | 83 ++++++++++++------
|
||||
net/core/of_net.c | 83 ++++++++++++------
|
||||
1 files changed, 72 insertions(+), 11 deletions(-)
|
||||
|
||||
--- a/net/ethernet/eth.c
|
||||
+++ b/net/ethernet/eth.c
|
||||
@@ -539,6 +539,63 @@ int eth_platform_get_mac_address(struct
|
||||
--- a/drivers/of/of_net.c
|
||||
+++ b/drivers/of/of_net.c
|
||||
@@ -57,13 +57,70 @@ static int of_get_mac_addr(struct device
|
||||
return -ENODEV;
|
||||
}
|
||||
EXPORT_SYMBOL(eth_platform_get_mac_address);
|
||||
|
||||
+static void *nvmem_cell_get_mac_address(struct nvmem_cell *cell)
|
||||
+{
|
||||
@@ -72,35 +72,40 @@ Submitted-by: Yousong Zhou <yszhou4tech@gmail.com>
|
||||
+ },
|
||||
+};
|
||||
+
|
||||
/**
|
||||
* Obtain the MAC address from an nvmem cell named 'mac-address' associated
|
||||
* with given device.
|
||||
@@ -550,21 +607,28 @@ EXPORT_SYMBOL(eth_platform_get_mac_addre
|
||||
*/
|
||||
int nvmem_get_mac_address(struct device *dev, void *addrbuf)
|
||||
static int of_get_mac_addr_nvmem(struct device_node *np, u8 *addr)
|
||||
{
|
||||
struct platform_device *pdev = of_find_device_by_node(np);
|
||||
+ struct nvmem_cell_mac_address_property *property;
|
||||
struct nvmem_cell *cell;
|
||||
const void *mac;
|
||||
- size_t len;
|
||||
+ int i;
|
||||
+
|
||||
- int ret;
|
||||
+ int ret, i;
|
||||
|
||||
/* Try lookup by device first, there might be a nvmem_cell_lookup
|
||||
* associated with a given device.
|
||||
@@ -74,17 +131,26 @@ static int of_get_mac_addr_nvmem(struct
|
||||
return ret;
|
||||
}
|
||||
|
||||
- cell = of_nvmem_cell_get(np, "mac-address");
|
||||
+ for (i = 0; i < ARRAY_SIZE(nvmem_cell_mac_address_properties); i++) {
|
||||
+ property = &nvmem_cell_mac_address_properties[i];
|
||||
+ cell = nvmem_cell_get(dev, property->name);
|
||||
+ /* For -EPROBE_DEFER don't try other properties. We'll get back to this one. */
|
||||
+ cell = of_nvmem_cell_get(np, property->name);
|
||||
+ /* For -EPROBE_DEFER don't try other properties.
|
||||
+ * We'll get back to this one.
|
||||
+ */
|
||||
+ if (!IS_ERR(cell) || PTR_ERR(cell) == -EPROBE_DEFER)
|
||||
+ break;
|
||||
+ }
|
||||
|
||||
- cell = nvmem_cell_get(dev, "mac-address");
|
||||
+
|
||||
if (IS_ERR(cell))
|
||||
return PTR_ERR(cell);
|
||||
|
||||
- mac = nvmem_cell_read(cell, &len);
|
||||
+ mac = property->read(cell);
|
||||
nvmem_cell_put(cell);
|
||||
-
|
||||
|
||||
if (IS_ERR(mac))
|
||||
return PTR_ERR(mac);
|
||||
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
From: Yousong Zhou <yszhou4tech@gmail.com>
|
||||
Subject: [PATCH] ath79: add nvmem cell mac-address-ascii support
|
||||
Subject: [PATCH] of: net: add nvmem cell mac-address-ascii support
|
||||
|
||||
This is needed for devices with mac address stored in ascii format, e.g.
|
||||
HiWiFi HC6361 to be ported in the following patch.
|
||||
This is needed for devices with mac address stored in ascii format,
|
||||
e.g. HiWiFi HC6361 to be ported in the following patch.
|
||||
|
||||
Submitted-by: Yousong Zhou <yszhou4tech@gmail.com>
|
||||
---
|
||||
net/ethernet/eth.c | 83 ++++++++++++------
|
||||
net/core/of_net.c | 83 ++++++++++++------
|
||||
1 files changed, 72 insertions(+), 11 deletions(-)
|
||||
|
||||
--- a/net/ethernet/eth.c
|
||||
+++ b/net/ethernet/eth.c
|
||||
@@ -538,6 +538,63 @@ int eth_platform_get_mac_address(struct
|
||||
--- a/net/core/of_net.c
|
||||
+++ b/net/core/of_net.c
|
||||
@@ -57,13 +57,70 @@ static int of_get_mac_addr(struct device
|
||||
return -ENODEV;
|
||||
}
|
||||
EXPORT_SYMBOL(eth_platform_get_mac_address);
|
||||
|
||||
+static void *nvmem_cell_get_mac_address(struct nvmem_cell *cell)
|
||||
+{
|
||||
@@ -72,35 +72,40 @@ Submitted-by: Yousong Zhou <yszhou4tech@gmail.com>
|
||||
+ },
|
||||
+};
|
||||
+
|
||||
/**
|
||||
* nvmem_get_mac_address - Obtain the MAC address from an nvmem cell named
|
||||
* 'mac-address' associated with given device.
|
||||
@@ -549,21 +606,28 @@ EXPORT_SYMBOL(eth_platform_get_mac_addre
|
||||
*/
|
||||
int nvmem_get_mac_address(struct device *dev, void *addrbuf)
|
||||
static int of_get_mac_addr_nvmem(struct device_node *np, u8 *addr)
|
||||
{
|
||||
struct platform_device *pdev = of_find_device_by_node(np);
|
||||
+ struct nvmem_cell_mac_address_property *property;
|
||||
struct nvmem_cell *cell;
|
||||
const void *mac;
|
||||
- size_t len;
|
||||
+ int i;
|
||||
+
|
||||
- int ret;
|
||||
+ int ret, i;
|
||||
|
||||
/* Try lookup by device first, there might be a nvmem_cell_lookup
|
||||
* associated with a given device.
|
||||
@@ -74,17 +131,26 @@ static int of_get_mac_addr_nvmem(struct
|
||||
return ret;
|
||||
}
|
||||
|
||||
- cell = of_nvmem_cell_get(np, "mac-address");
|
||||
+ for (i = 0; i < ARRAY_SIZE(nvmem_cell_mac_address_properties); i++) {
|
||||
+ property = &nvmem_cell_mac_address_properties[i];
|
||||
+ cell = nvmem_cell_get(dev, property->name);
|
||||
+ /* For -EPROBE_DEFER don't try other properties. We'll get back to this one. */
|
||||
+ cell = of_nvmem_cell_get(np, property->name);
|
||||
+ /* For -EPROBE_DEFER don't try other properties.
|
||||
+ * We'll get back to this one.
|
||||
+ */
|
||||
+ if (!IS_ERR(cell) || PTR_ERR(cell) == -EPROBE_DEFER)
|
||||
+ break;
|
||||
+ }
|
||||
|
||||
- cell = nvmem_cell_get(dev, "mac-address");
|
||||
+
|
||||
if (IS_ERR(cell))
|
||||
return PTR_ERR(cell);
|
||||
|
||||
- mac = nvmem_cell_read(cell, &len);
|
||||
+ mac = property->read(cell);
|
||||
nvmem_cell_put(cell);
|
||||
-
|
||||
|
||||
if (IS_ERR(mac))
|
||||
return PTR_ERR(mac);
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
|
||||
--- a/drivers/net/phy/sfp.c
|
||||
+++ b/drivers/net/phy/sfp.c
|
||||
@@ -377,6 +377,11 @@ static const struct sfp_quirk sfp_quirks
|
||||
@@ -383,6 +383,11 @@ static const struct sfp_quirk sfp_quirks
|
||||
.modes = sfp_quirk_2500basex,
|
||||
.fixup = sfp_fixup_ignore_tx_fault,
|
||||
}, {
|
||||
@@ -38,7 +38,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
// Lantech 8330-262D-E can operate at 2500base-X, but
|
||||
// incorrectly report 2500MBd NRZ in their EEPROM
|
||||
.vendor = "Lantech",
|
||||
@@ -2310,7 +2315,8 @@ static void sfp_sm_main(struct sfp *sfp,
|
||||
@@ -2312,7 +2317,8 @@ static void sfp_sm_main(struct sfp *sfp,
|
||||
* or t_start_up, so assume there is a fault.
|
||||
*/
|
||||
sfp_sm_fault(sfp, SFP_S_INIT_TX_FAULT,
|
||||
@@ -48,7 +48,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
} else if (event == SFP_E_TIMEOUT || event == SFP_E_TX_CLEAR) {
|
||||
init_done:
|
||||
sfp->sm_phy_retries = R_PHY_RETRY;
|
||||
@@ -2533,10 +2539,12 @@ static void sfp_check_state(struct sfp *
|
||||
@@ -2535,10 +2541,12 @@ static void sfp_check_state(struct sfp *
|
||||
mutex_lock(&sfp->st_mutex);
|
||||
state = sfp_get_state(sfp);
|
||||
changed = state ^ sfp->state;
|
||||
|
||||
@@ -854,7 +854,7 @@ Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
|
||||
+};
|
||||
--- a/MAINTAINERS
|
||||
+++ b/MAINTAINERS
|
||||
@@ -7527,6 +7527,14 @@ F: drivers/ptp/ptp_qoriq.c
|
||||
@@ -7526,6 +7526,14 @@ F: drivers/ptp/ptp_qoriq.c
|
||||
F: drivers/ptp/ptp_qoriq_debugfs.c
|
||||
F: include/linux/fsl/ptp_qoriq.h
|
||||
|
||||
|
||||
@@ -120,6 +120,7 @@
|
||||
mod-def0-gpios = <&pio 49 GPIO_ACTIVE_LOW>;
|
||||
tx-disable-gpios = <&pio 20 GPIO_ACTIVE_HIGH>;
|
||||
tx-fault-gpios = <&pio 7 GPIO_ACTIVE_HIGH>;
|
||||
maximum-power-milliwatt = <3000>;
|
||||
};
|
||||
|
||||
/* SFP2 cage (LAN) */
|
||||
@@ -139,6 +140,7 @@
|
||||
mod-def0-gpios = <&pio 47 GPIO_ACTIVE_LOW>;
|
||||
tx-disable-gpios = <&pio 15 GPIO_ACTIVE_HIGH>;
|
||||
tx-fault-gpios = <&pio 48 GPIO_ACTIVE_HIGH>;
|
||||
maximum-power-milliwatt = <3000>;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -9,16 +9,16 @@ mediatek_setup_interfaces()
|
||||
|
||||
case $board in
|
||||
asus,tuf-ax4200)
|
||||
CI_UBIPART="UBI_DEV"
|
||||
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "eth1"
|
||||
;;
|
||||
mediatek,mt7986a-rfb|\
|
||||
mediatek,mt7986b-rfb)
|
||||
ucidef_set_interfaces_lan_wan "lan0 lan1 lan2 lan3" eth1
|
||||
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" eth1
|
||||
;;
|
||||
bananapi,bpi-r3)
|
||||
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4 sfp2" "eth1 wan"
|
||||
ucidef_set_interface_macaddr "wan" "$(macaddr_add $(cat /sys/class/net/eth0/address) 1)"
|
||||
;;
|
||||
mediatek,mt7986a-rfb)
|
||||
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4 lan6" "eth1 wan"
|
||||
;;
|
||||
mediatek,mt7986b-rfb)
|
||||
ucidef_set_interfaces_lan_wan "lan0 lan1 lan2 lan3" eth1
|
||||
;;
|
||||
xiaomi,redmi-router-ax6000|\
|
||||
xiaomi,redmi-router-ax6000-stock|\
|
||||
@@ -45,6 +45,9 @@ mediatek_setup_macs()
|
||||
wan_mac="${addr}"
|
||||
lan_mac="${addr}"
|
||||
;;
|
||||
bananapi,bpi-r3)
|
||||
wan_mac=$(macaddr_add $(cat /sys/class/net/eth0/address) 1)
|
||||
;;
|
||||
xiaomi,redmi-router-ax6000|\
|
||||
xiaomi,redmi-router-ax6000-stock|\
|
||||
xiaomi,redmi-router-ax6000-ubootmod)
|
||||
|
||||
@@ -47,6 +47,7 @@ CONFIG_BLK_MQ_PCI=y
|
||||
CONFIG_BLK_PM=y
|
||||
CONFIG_BSD_PROCESS_ACCT=y
|
||||
CONFIG_BSD_PROCESS_ACCT_V3=y
|
||||
CONFIG_CC_HAVE_SHADOW_CALL_STACK=y
|
||||
CONFIG_CC_HAVE_STACKPROTECTOR_SYSREG=y
|
||||
CONFIG_CLKSRC_MMIO=y
|
||||
CONFIG_CLONE_BACKWARDS=y
|
||||
@@ -177,6 +178,7 @@ CONFIG_HARDIRQS_SW_RESEND=y
|
||||
CONFIG_HAS_DMA=y
|
||||
CONFIG_HAS_IOMEM=y
|
||||
CONFIG_HAS_IOPORT_MAP=y
|
||||
CONFIG_HWMON=y
|
||||
CONFIG_HW_RANDOM=y
|
||||
CONFIG_HW_RANDOM_MTK=y
|
||||
CONFIG_I2C=y
|
||||
@@ -297,6 +299,7 @@ CONFIG_PCI_DOMAINS=y
|
||||
CONFIG_PCI_DOMAINS_GENERIC=y
|
||||
CONFIG_PCI_MSI=y
|
||||
CONFIG_PCI_MSI_IRQ_DOMAIN=y
|
||||
CONFIG_PCS_MTK_LYNXI=y
|
||||
CONFIG_PERF_EVENTS=y
|
||||
CONFIG_PGTABLE_LEVELS=3
|
||||
CONFIG_PHYLIB=y
|
||||
@@ -398,11 +401,11 @@ CONFIG_SYSCTL_EXCEPTION_TRACE=y
|
||||
CONFIG_THERMAL=y
|
||||
CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE=y
|
||||
CONFIG_THERMAL_EMERGENCY_POWEROFF_DELAY_MS=0
|
||||
CONFIG_THERMAL_EMULATION=y
|
||||
CONFIG_THERMAL_GOV_BANG_BANG=y
|
||||
CONFIG_THERMAL_GOV_FAIR_SHARE=y
|
||||
CONFIG_THERMAL_GOV_STEP_WISE=y
|
||||
CONFIG_THERMAL_GOV_USER_SPACE=y
|
||||
CONFIG_THERMAL_HWMON=y
|
||||
CONFIG_THERMAL_OF=y
|
||||
CONFIG_THERMAL_WRITABLE_TRIPS=y
|
||||
CONFIG_THREAD_INFO_IN_TASK=y
|
||||
|
||||
@@ -17,7 +17,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
|
||||
--- a/MAINTAINERS
|
||||
+++ b/MAINTAINERS
|
||||
@@ -11798,6 +11798,14 @@ S: Maintained
|
||||
@@ -11797,6 +11797,14 @@ S: Maintained
|
||||
F: drivers/net/pcs/pcs-mtk-lynxi.c
|
||||
F: include/linux/pcs/pcs-mtk-lynxi.h
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ Cc: Robert Marko <robert.marko@sartura.hr>
|
||||
|
||||
--- a/MAINTAINERS
|
||||
+++ b/MAINTAINERS
|
||||
@@ -9064,6 +9064,22 @@ F: include/net/nl802154.h
|
||||
@@ -9063,6 +9063,22 @@ F: include/net/nl802154.h
|
||||
F: net/ieee802154/
|
||||
F: net/mac802154/
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
led-boot = &led_usb;
|
||||
led-failsafe = &led_usb;
|
||||
led-upgrade = &led_usb;
|
||||
label-mac-device = &gmac0;
|
||||
};
|
||||
|
||||
leds {
|
||||
@@ -79,12 +80,32 @@
|
||||
label = "Config";
|
||||
reg = <0x80000 0x80000>;
|
||||
read-only;
|
||||
|
||||
compatible = "nvmem-cells";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
|
||||
macaddr_config_8014: macaddr@8014 {
|
||||
reg = <0x8014 0x11>;
|
||||
};
|
||||
|
||||
macaddr_config_8036: macaddr@8036 {
|
||||
reg = <0x8036 0x11>;
|
||||
};
|
||||
};
|
||||
|
||||
factory: partition@100000 {
|
||||
label = "Factory";
|
||||
reg = <0x100000 0x40000>;
|
||||
read-only;
|
||||
|
||||
compatible = "nvmem-cells";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
|
||||
macaddr_factory_4: macaddr@4 {
|
||||
reg = <0x4 0x6>;
|
||||
};
|
||||
};
|
||||
|
||||
partition@140000 {
|
||||
@@ -115,10 +136,18 @@
|
||||
};
|
||||
};
|
||||
|
||||
&gmac0 {
|
||||
nvmem-cells = <&macaddr_config_8014>;
|
||||
nvmem-cell-names = "mac-address-ascii";
|
||||
};
|
||||
|
||||
&gmac1 {
|
||||
status = "okay";
|
||||
label = "wan";
|
||||
phy-handle = <ðphy4>;
|
||||
|
||||
nvmem-cells = <&macaddr_config_8036>;
|
||||
nvmem-cell-names = "mac-address-ascii";
|
||||
};
|
||||
|
||||
&mdio {
|
||||
@@ -157,13 +186,3 @@
|
||||
function = "gpio";
|
||||
};
|
||||
};
|
||||
|
||||
&factory {
|
||||
compatible = "nvmem-cells";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
|
||||
macaddr_factory_4: macaddr@4 {
|
||||
reg = <0x4 0x6>;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -284,11 +284,6 @@ ramips_setup_macs()
|
||||
wan_mac=$(macaddr_add "$lan_mac" 1)
|
||||
label_mac=$lan_mac
|
||||
;;
|
||||
raisecom,msg1500-x-00)
|
||||
lan_mac=$(mtd_get_mac_ascii Config protest_lan_mac)
|
||||
wan_mac=$(mtd_get_mac_ascii Config protest_wan_mac)
|
||||
label_mac=$lan_mac
|
||||
;;
|
||||
yuncore,ax820)
|
||||
label_mac=$(mtd_get_mac_binary Factory 0x4)
|
||||
;;
|
||||
|
||||
@@ -147,8 +147,7 @@ case "$board" in
|
||||
;;
|
||||
raisecom,msg1500-x-00)
|
||||
[ "$PHYNBR" = "0" ] && \
|
||||
macaddr_setbit_la "$(mtd_get_mac_ascii Config protest_lan_mac)" \
|
||||
> /sys${DEVPATH}/macaddress
|
||||
macaddr_setbit_la "$(get_mac_label)" > /sys${DEVPATH}/macaddress
|
||||
;;
|
||||
snr,snr-cpe-me2-sfp)
|
||||
hw_mac_addr="$(mtd_get_mac_binary factory 0x8004)"
|
||||
|
||||
@@ -32,7 +32,7 @@ Signed-off-by: Guenter Roeck <linux@roeck-us.net>
|
||||
|
||||
--- a/MAINTAINERS
|
||||
+++ b/MAINTAINERS
|
||||
@@ -15899,6 +15899,13 @@ S: Maintained
|
||||
@@ -15898,6 +15898,13 @@ S: Maintained
|
||||
F: include/sound/rt*.h
|
||||
F: sound/soc/codecs/rt*
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>
|
||||
|
||||
--- a/drivers/net/phy/sfp.c
|
||||
+++ b/drivers/net/phy/sfp.c
|
||||
@@ -2151,6 +2151,13 @@ static void sfp_sm_module(struct sfp *sf
|
||||
@@ -2153,6 +2153,13 @@ static void sfp_sm_module(struct sfp *sf
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>
|
||||
|
||||
--- a/drivers/net/phy/sfp.c
|
||||
+++ b/drivers/net/phy/sfp.c
|
||||
@@ -543,32 +543,72 @@ static int sfp_i2c_write(struct sfp *sfp
|
||||
@@ -549,32 +549,72 @@ static int sfp_i2c_write(struct sfp *sfp
|
||||
return ret == ARRAY_SIZE(msgs) ? len : 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -106,6 +106,7 @@ $(curdir)/isl/compile := $(curdir)/gmp/compile
|
||||
$(curdir)/liblzo/compile := $(curdir)/cmake/compile
|
||||
$(curdir)/libressl/compile := $(curdir)/pkgconf/compile
|
||||
$(curdir)/libtool/compile := $(curdir)/automake/compile $(curdir)/missing-macros/compile
|
||||
$(curdir)/lz4/compile := $(curdir)/meson/compile
|
||||
$(curdir)/lzma-old/compile := $(curdir)/zlib/compile
|
||||
$(curdir)/lzop/compile := $(curdir)/cmake/compile $(curdir)/liblzo/compile
|
||||
$(curdir)/llvm-bpf/compile := $(curdir)/cmake/compile
|
||||
|
||||
@@ -17,33 +17,21 @@ PKG_HASH:=0b0e3aa07c8c063ddf40b082bdf7e37a1562bda40a0ff5272957f3e987e0e54b
|
||||
PKG_LICENSE:=BSD-2-Clause
|
||||
PKG_LICENSE_FILES:=LICENSE lib/LICENSE
|
||||
|
||||
HOST_BUILD_PARALLEL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/host-build.mk
|
||||
include $(INCLUDE_DIR)/meson.mk
|
||||
|
||||
MESON_HOST_BUILD_DIR:=$(HOST_BUILD_DIR)/contrib/meson/openwrt-build
|
||||
|
||||
# Always optimize for speed
|
||||
HOST_CFLAGS := $(filter-out -O%,$(HOST_CFLAGS)) -O3
|
||||
|
||||
HOST_MAKE_FLAGS+=PREFIX=$(HOST_BUILD_PREFIX) \
|
||||
ENABLE_DOCS=1
|
||||
|
||||
define Host/Configure
|
||||
endef
|
||||
|
||||
define Host/Compile
|
||||
$(call Host/Compile/Default,default)
|
||||
endef
|
||||
|
||||
define Host/Install
|
||||
$(call Host/Compile/Default,install)
|
||||
endef
|
||||
|
||||
define Host/Uninstall
|
||||
$(call Host/Compile/Default,uninstall)
|
||||
$(call Host/Compile/Default,clean)
|
||||
endef
|
||||
|
||||
define Host/Clean
|
||||
endef
|
||||
MESON_HOST_ARGS += \
|
||||
-Ddefault_library=static \
|
||||
-Ddebug-level=0 \
|
||||
-Dunstable=false \
|
||||
-Dprograms=true \
|
||||
-Dtests=false \
|
||||
-Dcontrib=false \
|
||||
-Dexamples=false
|
||||
|
||||
$(eval $(call HostBuild))
|
||||
|
||||
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
|
||||
PKG_NAME:=squashfs4
|
||||
PKG_CPE_ID:=cpe:/a:phillip_lougher:squashfs
|
||||
PKG_VERSION:=4.6.1
|
||||
PKG_RELEASE=2
|
||||
PKG_RELEASE=3
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://github.com/plougher/squashfs-tools
|
||||
@@ -26,6 +26,7 @@ define Host/Compile
|
||||
$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR)/squashfs-tools \
|
||||
XZ_SUPPORT=1 \
|
||||
LZMA_XZ_SUPPORT=1 \
|
||||
XZ_EXTENDED_OPTIONS=1 \
|
||||
EXTRA_CFLAGS="-I$(STAGING_DIR_HOST)/include" \
|
||||
mksquashfs unsquashfs
|
||||
endef
|
||||
|
||||
@@ -0,0 +1,898 @@
|
||||
From 5fb9fdfb8757fc9afb6318a3dcf9dce0a97de352 Mon Sep 17 00:00:00 2001
|
||||
From: Phillip Lougher <phillip@squashfs.org.uk>
|
||||
Date: Wed, 19 Apr 2023 18:35:53 +0100
|
||||
Subject: [PATCH] xz_wrapper: make new OpenWrt extended options non-default
|
||||
|
||||
The reason why these options are being made non-default are
|
||||
described here:
|
||||
|
||||
https://github.com/plougher/squashfs-tools/pull/218#issuecomment-1515197256
|
||||
|
||||
The new options can be enabled by editing the Makefile or by defining
|
||||
XZ_EXTENDED_OPTIONS on the Make command line, e.g.
|
||||
|
||||
% CONFIG=1 XZ_SUPPORT=1 XZ_EXTENDED_OPTIONS=1 make
|
||||
|
||||
Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
|
||||
---
|
||||
squashfs-tools/Makefile | 12 +
|
||||
squashfs-tools/xz_wrapper.c | 117 +----
|
||||
squashfs-tools/xz_wrapper_extended.c | 664 +++++++++++++++++++++++++++
|
||||
3 files changed, 679 insertions(+), 114 deletions(-)
|
||||
create mode 100644 squashfs-tools/xz_wrapper_extended.c
|
||||
|
||||
--- a/squashfs-tools/Makefile
|
||||
+++ b/squashfs-tools/Makefile
|
||||
@@ -39,6 +39,10 @@ GZIP_SUPPORT = 1
|
||||
#
|
||||
#XZ_SUPPORT = 1
|
||||
|
||||
+# Enable support for OpenWrt extended compression options by uncommenting
|
||||
+# next line. Do not do this unless you understand the implications.
|
||||
+#XZ_EXTENDED_OPTIONS = 1
|
||||
+
|
||||
|
||||
############ Building LZO support ##############
|
||||
#
|
||||
@@ -197,6 +201,7 @@ INSTALL_MANPAGES_DIR ?= $(INSTALL_PREFIX
|
||||
LZMA_XZ_SUPPORT ?= 0
|
||||
LZMA_SUPPORT ?= 0
|
||||
LZMA_DIR ?= ../../../../LZMA/lzma465
|
||||
+XZ_EXTENDED_OPTIONS ?= 0
|
||||
endif
|
||||
|
||||
|
||||
@@ -248,8 +253,13 @@ endif
|
||||
|
||||
ifeq ($(XZ_SUPPORT),1)
|
||||
CFLAGS += -DXZ_SUPPORT
|
||||
+ifeq ($(XZ_EXTENDED_OPTIONS),1)
|
||||
+MKSQUASHFS_OBJS += xz_wrapper_extended.o
|
||||
+UNSQUASHFS_OBJS += xz_wrapper_extended.o
|
||||
+else
|
||||
MKSQUASHFS_OBJS += xz_wrapper.o
|
||||
UNSQUASHFS_OBJS += xz_wrapper.o
|
||||
+endif
|
||||
LIBS += -llzma
|
||||
COMPRESSORS += xz
|
||||
endif
|
||||
@@ -428,6 +438,8 @@ lz4_wrapper.o: lz4_wrapper.c squashfs_fs
|
||||
|
||||
xz_wrapper.o: xz_wrapper.c squashfs_fs.h xz_wrapper.h compressor.h
|
||||
|
||||
+xz_wrapper_extended.o: xz_wrapper_extended.c squashfs_fs.h xz_wrapper.h compressor.h
|
||||
+
|
||||
unsquashfs: $(UNSQUASHFS_OBJS)
|
||||
$(CC) $(LDFLAGS) $(EXTRA_LDFLAGS) $(UNSQUASHFS_OBJS) $(LIBS) -o $@
|
||||
ln -sf unsquashfs sqfscat
|
||||
--- a/squashfs-tools/xz_wrapper.c
|
||||
+++ b/squashfs-tools/xz_wrapper.c
|
||||
@@ -44,10 +44,7 @@ static struct bcj bcj[] = {
|
||||
static int filter_count = 1;
|
||||
static int dictionary_size = 0;
|
||||
static float dictionary_percent = 0;
|
||||
-static int preset = LZMA_PRESET_DEFAULT;
|
||||
-static int lc = -1;
|
||||
-static int lp = -1;
|
||||
-static int pb = -1;
|
||||
+
|
||||
|
||||
/*
|
||||
* This function is called by the options parsing code in mksquashfs.c
|
||||
@@ -56,11 +53,6 @@ static int pb = -1;
|
||||
* Two specific options are supported:
|
||||
* -Xbcj
|
||||
* -Xdict-size
|
||||
- * -Xpreset
|
||||
- * -Xe
|
||||
- * -Xlc
|
||||
- * -Xlp
|
||||
- * -Xpb
|
||||
*
|
||||
* This function returns:
|
||||
* >=0 (number of additional args parsed) on success
|
||||
@@ -149,85 +141,6 @@ static int xz_options(char *argv[], int
|
||||
}
|
||||
|
||||
return 1;
|
||||
- } else if(strcmp(argv[0], "-Xpreset") == 0) {
|
||||
- char *b;
|
||||
- long val;
|
||||
-
|
||||
- if(argc < 2) {
|
||||
- fprintf(stderr, "xz: -Xpreset missing preset-level "
|
||||
- "(valid value 0-9)\n");
|
||||
- goto failed;
|
||||
- }
|
||||
-
|
||||
- val = strtol(argv[1], &b, 10);
|
||||
- if (*b != '\0' || (int) val < 0 || (int) val & ~LZMA_PRESET_LEVEL_MASK) {
|
||||
- fprintf(stderr, "xz: -Xpreset can't be "
|
||||
- "negative or more than the max preset\n");
|
||||
- goto failed;
|
||||
- }
|
||||
-
|
||||
- preset &= ~LZMA_PRESET_LEVEL_MASK;
|
||||
- preset |= (int) val;
|
||||
-
|
||||
- return 1;
|
||||
- } else if(strcmp(argv[0], "-Xe") == 0) {
|
||||
- preset |= LZMA_PRESET_EXTREME;
|
||||
-
|
||||
- return 0;
|
||||
- } else if(strcmp(argv[0], "-Xlc") == 0) {
|
||||
- char *b;
|
||||
- long val;
|
||||
-
|
||||
- if(argc < 2) {
|
||||
- fprintf(stderr, "xz: -Xlc missing value\n");
|
||||
- goto failed;
|
||||
- }
|
||||
-
|
||||
- val = strtol(argv[1], &b, 10);
|
||||
- if (*b != '\0' || (int) val < LZMA_LCLP_MIN || (int) val > LZMA_LCLP_MAX) {
|
||||
- fprintf(stderr, "xz: -Xlc invalid value\n");
|
||||
- goto failed;
|
||||
- }
|
||||
-
|
||||
- lc = (int) val;
|
||||
-
|
||||
- return 1;
|
||||
- } else if(strcmp(argv[0], "-Xlp") == 0) {
|
||||
- char *b;
|
||||
- long val;
|
||||
-
|
||||
- if(argc < 2) {
|
||||
- fprintf(stderr, "xz: -Xlp missing value\n");
|
||||
- goto failed;
|
||||
- }
|
||||
-
|
||||
- val = strtol(argv[1], &b, 10);
|
||||
- if (*b != '\0' || (int) val < LZMA_LCLP_MIN || (int) val > LZMA_LCLP_MAX) {
|
||||
- fprintf(stderr, "xz: -Xlp invalid value\n");
|
||||
- goto failed;
|
||||
- }
|
||||
-
|
||||
- lp = (int) val;
|
||||
-
|
||||
- return 1;
|
||||
- } else if(strcmp(argv[0], "-Xpb") == 0) {
|
||||
- char *b;
|
||||
- long val;
|
||||
-
|
||||
- if(argc < 2) {
|
||||
- fprintf(stderr, "xz: -Xpb missing value\n");
|
||||
- goto failed;
|
||||
- }
|
||||
-
|
||||
- val = strtol(argv[1], &b, 10);
|
||||
- if (*b != '\0' || (int) val < LZMA_PB_MIN || (int) val > LZMA_PB_MAX) {
|
||||
- fprintf(stderr, "xz: -Xpb invalid value\n");
|
||||
- goto failed;
|
||||
- }
|
||||
-
|
||||
- pb = (int) val;
|
||||
-
|
||||
- return 1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
@@ -533,20 +446,11 @@ static int xz_compress(void *strm, void
|
||||
for(i = 0; i < stream->filters; i++) {
|
||||
struct filter *filter = &stream->filter[i];
|
||||
|
||||
- if(lzma_lzma_preset(&stream->opt, preset))
|
||||
+ if(lzma_lzma_preset(&stream->opt, LZMA_PRESET_DEFAULT))
|
||||
goto failed;
|
||||
|
||||
stream->opt.dict_size = stream->dictionary_size;
|
||||
|
||||
- if (lc >= 0)
|
||||
- stream->opt.lc = lc;
|
||||
-
|
||||
- if (lp >= 0)
|
||||
- stream->opt.lp = lp;
|
||||
-
|
||||
- if (pb >= 0)
|
||||
- stream->opt.pb = pb;
|
||||
-
|
||||
filter->length = 0;
|
||||
res = lzma_stream_buffer_encode(filter->filter,
|
||||
LZMA_CHECK_CRC32, NULL, src, size, filter->buffer,
|
||||
@@ -617,28 +521,13 @@ static void xz_usage(FILE *stream)
|
||||
fprintf(stream, " header as either 2^n or as 2^n+2^(n+1).\n\t\t");
|
||||
fprintf(stream, "Example dict-sizes are 75%%, 50%%, 37.5%%, 25%%, or");
|
||||
fprintf(stream, " 32K, 16K, 8K\n\t\tetc.\n");
|
||||
- fprintf(stream, "\t -Xpreset <preset-level>\n");
|
||||
- fprintf(stream, "\t\tUse <preset-value> as the custom preset to use");
|
||||
- fprintf(stream, " on compress.\n\t\t<preset-level> should be 0 .. 9");
|
||||
- fprintf(stream, " (default 6)\n");
|
||||
- fprintf(stream, "\t -Xe\n");
|
||||
- fprintf(stream, "\t\tEnable additional compression settings by passing");
|
||||
- fprintf(stream, " the EXTREME\n\t\tflag to the compression flags.\n");
|
||||
- fprintf(stream, "\t -Xlc <value>\n");
|
||||
- fprintf(stream, "\t -Xlp <value>\n");
|
||||
- fprintf(stream, "\t -Xpb <value>\n");
|
||||
}
|
||||
|
||||
|
||||
static int option_args(char *option)
|
||||
{
|
||||
if(strcmp(option, "-Xbcj") == 0 ||
|
||||
- strcmp(option, "-Xdict-size") == 0 ||
|
||||
- strcmp(option, "-Xpreset") == 0 ||
|
||||
- strcmp(option, "-Xe") == 0 ||
|
||||
- strcmp(option, "-Xlc") == 0 ||
|
||||
- strcmp(option, "-Xlp") == 0 ||
|
||||
- strcmp(option, "-Xpb") == 0)
|
||||
+ strcmp(option, "-Xdict-size") == 0)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
--- /dev/null
|
||||
+++ b/squashfs-tools/xz_wrapper_extended.c
|
||||
@@ -0,0 +1,664 @@
|
||||
+/*
|
||||
+ * Copyright (c) 2010, 2011, 2012, 2013, 2021, 2022
|
||||
+ * Phillip Lougher <phillip@squashfs.org.uk>
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or
|
||||
+ * modify it under the terms of the GNU General Public License
|
||||
+ * as published by the Free Software Foundation; either version 2,
|
||||
+ * or (at your option) any later version.
|
||||
+ *
|
||||
+ * This program is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
+ * GNU General Public License for more details.
|
||||
+ *
|
||||
+ * You should have received a copy of the GNU General Public License
|
||||
+ * along with this program; if not, write to the Free Software
|
||||
+ * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
+ *
|
||||
+ * xz_wrapper_extended.c
|
||||
+ *
|
||||
+ * Support for XZ (LZMA2) compression using XZ Utils liblzma
|
||||
+ * http://tukaani.org/xz/
|
||||
+ *
|
||||
+ * This file supports OpenWrt extended XZ compression options.
|
||||
+ */
|
||||
+
|
||||
+#include <stdio.h>
|
||||
+#include <string.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <lzma.h>
|
||||
+
|
||||
+#include "squashfs_fs.h"
|
||||
+#include "xz_wrapper.h"
|
||||
+#include "compressor.h"
|
||||
+
|
||||
+static struct bcj bcj[] = {
|
||||
+ { "x86", LZMA_FILTER_X86, 0 },
|
||||
+ { "powerpc", LZMA_FILTER_POWERPC, 0 },
|
||||
+ { "ia64", LZMA_FILTER_IA64, 0 },
|
||||
+ { "arm", LZMA_FILTER_ARM, 0 },
|
||||
+ { "armthumb", LZMA_FILTER_ARMTHUMB, 0 },
|
||||
+ { "sparc", LZMA_FILTER_SPARC, 0 },
|
||||
+ { NULL, LZMA_VLI_UNKNOWN, 0 }
|
||||
+};
|
||||
+
|
||||
+static int filter_count = 1;
|
||||
+static int dictionary_size = 0;
|
||||
+static float dictionary_percent = 0;
|
||||
+static int preset = LZMA_PRESET_DEFAULT;
|
||||
+static int lc = -1;
|
||||
+static int lp = -1;
|
||||
+static int pb = -1;
|
||||
+
|
||||
+/*
|
||||
+ * This function is called by the options parsing code in mksquashfs.c
|
||||
+ * to parse any -X compressor option.
|
||||
+ *
|
||||
+ * Two specific options are supported:
|
||||
+ * -Xbcj
|
||||
+ * -Xdict-size
|
||||
+ * -Xpreset
|
||||
+ * -Xe
|
||||
+ * -Xlc
|
||||
+ * -Xlp
|
||||
+ * -Xpb
|
||||
+ *
|
||||
+ * This function returns:
|
||||
+ * >=0 (number of additional args parsed) on success
|
||||
+ * -1 if the option was unrecognised, or
|
||||
+ * -2 if the option was recognised, but otherwise bad in
|
||||
+ * some way (e.g. invalid parameter)
|
||||
+ *
|
||||
+ * Note: this function sets internal compressor state, but does not
|
||||
+ * pass back the results of the parsing other than success/failure.
|
||||
+ * The xz_dump_options() function is called later to get the options in
|
||||
+ * a format suitable for writing to the filesystem.
|
||||
+ */
|
||||
+static int xz_options(char *argv[], int argc)
|
||||
+{
|
||||
+ int i;
|
||||
+ char *name;
|
||||
+
|
||||
+ if(strcmp(argv[0], "-Xbcj") == 0) {
|
||||
+ if(argc < 2) {
|
||||
+ fprintf(stderr, "xz: -Xbcj missing filter\n");
|
||||
+ goto failed;
|
||||
+ }
|
||||
+
|
||||
+ name = argv[1];
|
||||
+ while(name[0] != '\0') {
|
||||
+ for(i = 0; bcj[i].name; i++) {
|
||||
+ int n = strlen(bcj[i].name);
|
||||
+ if((strncmp(name, bcj[i].name, n) == 0) &&
|
||||
+ (name[n] == '\0' ||
|
||||
+ name[n] == ',')) {
|
||||
+ if(bcj[i].selected == 0) {
|
||||
+ bcj[i].selected = 1;
|
||||
+ filter_count++;
|
||||
+ }
|
||||
+ name += name[n] == ',' ? n + 1 : n;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ if(bcj[i].name == NULL) {
|
||||
+ fprintf(stderr, "xz: -Xbcj unrecognised "
|
||||
+ "filter\n");
|
||||
+ goto failed;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return 1;
|
||||
+ } else if(strcmp(argv[0], "-Xdict-size") == 0) {
|
||||
+ char *b;
|
||||
+ float size;
|
||||
+
|
||||
+ if(argc < 2) {
|
||||
+ fprintf(stderr, "xz: -Xdict-size missing dict-size\n");
|
||||
+ goto failed;
|
||||
+ }
|
||||
+
|
||||
+ size = strtof(argv[1], &b);
|
||||
+ if(*b == '%') {
|
||||
+ if(size <= 0 || size > 100) {
|
||||
+ fprintf(stderr, "xz: -Xdict-size percentage "
|
||||
+ "should be 0 < dict-size <= 100\n");
|
||||
+ goto failed;
|
||||
+ }
|
||||
+
|
||||
+ dictionary_percent = size;
|
||||
+ dictionary_size = 0;
|
||||
+ } else {
|
||||
+ if((float) ((int) size) != size) {
|
||||
+ fprintf(stderr, "xz: -Xdict-size can't be "
|
||||
+ "fractional unless a percentage of the"
|
||||
+ " block size\n");
|
||||
+ goto failed;
|
||||
+ }
|
||||
+
|
||||
+ dictionary_percent = 0;
|
||||
+ dictionary_size = (int) size;
|
||||
+
|
||||
+ if(*b == 'k' || *b == 'K')
|
||||
+ dictionary_size *= 1024;
|
||||
+ else if(*b == 'm' || *b == 'M')
|
||||
+ dictionary_size *= 1024 * 1024;
|
||||
+ else if(*b != '\0') {
|
||||
+ fprintf(stderr, "xz: -Xdict-size invalid "
|
||||
+ "dict-size\n");
|
||||
+ goto failed;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return 1;
|
||||
+ } else if(strcmp(argv[0], "-Xpreset") == 0) {
|
||||
+ char *b;
|
||||
+ long val;
|
||||
+
|
||||
+ if(argc < 2) {
|
||||
+ fprintf(stderr, "xz: -Xpreset missing preset-level "
|
||||
+ "(valid value 0-9)\n");
|
||||
+ goto failed;
|
||||
+ }
|
||||
+
|
||||
+ val = strtol(argv[1], &b, 10);
|
||||
+ if (*b != '\0' || (int) val < 0 || (int) val & ~LZMA_PRESET_LEVEL_MASK) {
|
||||
+ fprintf(stderr, "xz: -Xpreset can't be "
|
||||
+ "negative or more than the max preset\n");
|
||||
+ goto failed;
|
||||
+ }
|
||||
+
|
||||
+ preset &= ~LZMA_PRESET_LEVEL_MASK;
|
||||
+ preset |= (int) val;
|
||||
+
|
||||
+ return 1;
|
||||
+ } else if(strcmp(argv[0], "-Xe") == 0) {
|
||||
+ preset |= LZMA_PRESET_EXTREME;
|
||||
+
|
||||
+ return 0;
|
||||
+ } else if(strcmp(argv[0], "-Xlc") == 0) {
|
||||
+ char *b;
|
||||
+ long val;
|
||||
+
|
||||
+ if(argc < 2) {
|
||||
+ fprintf(stderr, "xz: -Xlc missing value\n");
|
||||
+ goto failed;
|
||||
+ }
|
||||
+
|
||||
+ val = strtol(argv[1], &b, 10);
|
||||
+ if (*b != '\0' || (int) val < LZMA_LCLP_MIN || (int) val > LZMA_LCLP_MAX) {
|
||||
+ fprintf(stderr, "xz: -Xlc invalid value\n");
|
||||
+ goto failed;
|
||||
+ }
|
||||
+
|
||||
+ lc = (int) val;
|
||||
+
|
||||
+ return 1;
|
||||
+ } else if(strcmp(argv[0], "-Xlp") == 0) {
|
||||
+ char *b;
|
||||
+ long val;
|
||||
+
|
||||
+ if(argc < 2) {
|
||||
+ fprintf(stderr, "xz: -Xlp missing value\n");
|
||||
+ goto failed;
|
||||
+ }
|
||||
+
|
||||
+ val = strtol(argv[1], &b, 10);
|
||||
+ if (*b != '\0' || (int) val < LZMA_LCLP_MIN || (int) val > LZMA_LCLP_MAX) {
|
||||
+ fprintf(stderr, "xz: -Xlp invalid value\n");
|
||||
+ goto failed;
|
||||
+ }
|
||||
+
|
||||
+ lp = (int) val;
|
||||
+
|
||||
+ return 1;
|
||||
+ } else if(strcmp(argv[0], "-Xpb") == 0) {
|
||||
+ char *b;
|
||||
+ long val;
|
||||
+
|
||||
+ if(argc < 2) {
|
||||
+ fprintf(stderr, "xz: -Xpb missing value\n");
|
||||
+ goto failed;
|
||||
+ }
|
||||
+
|
||||
+ val = strtol(argv[1], &b, 10);
|
||||
+ if (*b != '\0' || (int) val < LZMA_PB_MIN || (int) val > LZMA_PB_MAX) {
|
||||
+ fprintf(stderr, "xz: -Xpb invalid value\n");
|
||||
+ goto failed;
|
||||
+ }
|
||||
+
|
||||
+ pb = (int) val;
|
||||
+
|
||||
+ return 1;
|
||||
+ }
|
||||
+
|
||||
+ return -1;
|
||||
+
|
||||
+failed:
|
||||
+ return -2;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+/*
|
||||
+ * This function is called after all options have been parsed.
|
||||
+ * It is used to do post-processing on the compressor options using
|
||||
+ * values that were not expected to be known at option parse time.
|
||||
+ *
|
||||
+ * In this case block_size may not be known until after -Xdict-size has
|
||||
+ * been processed (in the case where -b is specified after -Xdict-size)
|
||||
+ *
|
||||
+ * This function returns 0 on successful post processing, or
|
||||
+ * -1 on error
|
||||
+ */
|
||||
+static int xz_options_post(int block_size)
|
||||
+{
|
||||
+ /*
|
||||
+ * if -Xdict-size has been specified use this to compute the datablock
|
||||
+ * dictionary size
|
||||
+ */
|
||||
+ if(dictionary_size || dictionary_percent) {
|
||||
+ int n;
|
||||
+
|
||||
+ if(dictionary_size) {
|
||||
+ if(dictionary_size > block_size) {
|
||||
+ fprintf(stderr, "xz: -Xdict-size is larger than"
|
||||
+ " block_size\n");
|
||||
+ goto failed;
|
||||
+ }
|
||||
+ } else
|
||||
+ dictionary_size = block_size * dictionary_percent / 100;
|
||||
+
|
||||
+ if(dictionary_size < 8192) {
|
||||
+ fprintf(stderr, "xz: -Xdict-size should be 8192 bytes "
|
||||
+ "or larger\n");
|
||||
+ goto failed;
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * dictionary_size must be storable in xz header as either
|
||||
+ * 2^n or as 2^n+2^(n+1)
|
||||
+ */
|
||||
+ n = ffs(dictionary_size) - 1;
|
||||
+ if(dictionary_size != (1 << n) &&
|
||||
+ dictionary_size != ((1 << n) + (1 << (n + 1)))) {
|
||||
+ fprintf(stderr, "xz: -Xdict-size is an unsupported "
|
||||
+ "value, dict-size must be storable in xz "
|
||||
+ "header\n");
|
||||
+ fprintf(stderr, "as either 2^n or as 2^n+2^(n+1). "
|
||||
+ "Example dict-sizes are 75%%, 50%%, 37.5%%, "
|
||||
+ "25%%,\n");
|
||||
+ fprintf(stderr, "or 32K, 16K, 8K etc.\n");
|
||||
+ goto failed;
|
||||
+ }
|
||||
+
|
||||
+ } else
|
||||
+ /* No -Xdict-size specified, use defaults */
|
||||
+ dictionary_size = block_size;
|
||||
+
|
||||
+ return 0;
|
||||
+
|
||||
+failed:
|
||||
+ return -1;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+/*
|
||||
+ * This function is called by mksquashfs to dump the parsed
|
||||
+ * compressor options in a format suitable for writing to the
|
||||
+ * compressor options field in the filesystem (stored immediately
|
||||
+ * after the superblock).
|
||||
+ *
|
||||
+ * This function returns a pointer to the compression options structure
|
||||
+ * to be stored (and the size), or NULL if there are no compression
|
||||
+ * options
|
||||
+ */
|
||||
+static void *xz_dump_options(int block_size, int *size)
|
||||
+{
|
||||
+ static struct comp_opts comp_opts;
|
||||
+ int flags = 0, i;
|
||||
+
|
||||
+ /*
|
||||
+ * don't store compressor specific options in file system if the
|
||||
+ * default options are being used - no compressor options in the
|
||||
+ * file system means the default options are always assumed
|
||||
+ *
|
||||
+ * Defaults are:
|
||||
+ * metadata dictionary size: SQUASHFS_METADATA_SIZE
|
||||
+ * datablock dictionary size: block_size
|
||||
+ * 1 filter
|
||||
+ */
|
||||
+ if(dictionary_size == block_size && filter_count == 1)
|
||||
+ return NULL;
|
||||
+
|
||||
+ for(i = 0; bcj[i].name; i++)
|
||||
+ flags |= bcj[i].selected << i;
|
||||
+
|
||||
+ comp_opts.dictionary_size = dictionary_size;
|
||||
+ comp_opts.flags = flags;
|
||||
+
|
||||
+ SQUASHFS_INSWAP_COMP_OPTS(&comp_opts);
|
||||
+
|
||||
+ *size = sizeof(comp_opts);
|
||||
+ return &comp_opts;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+/*
|
||||
+ * This function is a helper specifically for the append mode of
|
||||
+ * mksquashfs. Its purpose is to set the internal compressor state
|
||||
+ * to the stored compressor options in the passed compressor options
|
||||
+ * structure.
|
||||
+ *
|
||||
+ * In effect this function sets up the compressor options
|
||||
+ * to the same state they were when the filesystem was originally
|
||||
+ * generated, this is to ensure on appending, the compressor uses
|
||||
+ * the same compression options that were used to generate the
|
||||
+ * original filesystem.
|
||||
+ *
|
||||
+ * Note, even if there are no compressor options, this function is still
|
||||
+ * called with an empty compressor structure (size == 0), to explicitly
|
||||
+ * set the default options, this is to ensure any user supplied
|
||||
+ * -X options on the appending mksquashfs command line are over-ridden
|
||||
+ *
|
||||
+ * This function returns 0 on sucessful extraction of options, and
|
||||
+ * -1 on error
|
||||
+ */
|
||||
+static int xz_extract_options(int block_size, void *buffer, int size)
|
||||
+{
|
||||
+ struct comp_opts *comp_opts = buffer;
|
||||
+ int flags, i, n;
|
||||
+
|
||||
+ if(size == 0) {
|
||||
+ /* set defaults */
|
||||
+ dictionary_size = block_size;
|
||||
+ flags = 0;
|
||||
+ } else {
|
||||
+ /* check passed comp opts struct is of the correct length */
|
||||
+ if(size != sizeof(struct comp_opts))
|
||||
+ goto failed;
|
||||
+
|
||||
+ SQUASHFS_INSWAP_COMP_OPTS(comp_opts);
|
||||
+
|
||||
+ dictionary_size = comp_opts->dictionary_size;
|
||||
+ flags = comp_opts->flags;
|
||||
+
|
||||
+ /*
|
||||
+ * check that the dictionary size seems correct - the dictionary
|
||||
+ * size should 2^n or 2^n+2^(n+1)
|
||||
+ */
|
||||
+ n = ffs(dictionary_size) - 1;
|
||||
+ if(dictionary_size != (1 << n) &&
|
||||
+ dictionary_size != ((1 << n) + (1 << (n + 1))))
|
||||
+ goto failed;
|
||||
+ }
|
||||
+
|
||||
+ filter_count = 1;
|
||||
+ for(i = 0; bcj[i].name; i++) {
|
||||
+ if((flags >> i) & 1) {
|
||||
+ bcj[i].selected = 1;
|
||||
+ filter_count ++;
|
||||
+ } else
|
||||
+ bcj[i].selected = 0;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+
|
||||
+failed:
|
||||
+ fprintf(stderr, "xz: error reading stored compressor options from "
|
||||
+ "filesystem!\n");
|
||||
+
|
||||
+ return -1;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static void xz_display_options(void *buffer, int size)
|
||||
+{
|
||||
+ struct comp_opts *comp_opts = buffer;
|
||||
+ int dictionary_size, flags, printed;
|
||||
+ int i, n;
|
||||
+
|
||||
+ /* check passed comp opts struct is of the correct length */
|
||||
+ if(size != sizeof(struct comp_opts))
|
||||
+ goto failed;
|
||||
+
|
||||
+ SQUASHFS_INSWAP_COMP_OPTS(comp_opts);
|
||||
+
|
||||
+ dictionary_size = comp_opts->dictionary_size;
|
||||
+ flags = comp_opts->flags;
|
||||
+
|
||||
+ /*
|
||||
+ * check that the dictionary size seems correct - the dictionary
|
||||
+ * size should 2^n or 2^n+2^(n+1)
|
||||
+ */
|
||||
+ n = ffs(dictionary_size) - 1;
|
||||
+ if(dictionary_size != (1 << n) &&
|
||||
+ dictionary_size != ((1 << n) + (1 << (n + 1))))
|
||||
+ goto failed;
|
||||
+
|
||||
+ printf("\tDictionary size %d\n", dictionary_size);
|
||||
+
|
||||
+ printed = 0;
|
||||
+ for(i = 0; bcj[i].name; i++) {
|
||||
+ if((flags >> i) & 1) {
|
||||
+ if(printed)
|
||||
+ printf(", ");
|
||||
+ else
|
||||
+ printf("\tFilters selected: ");
|
||||
+ printf("%s", bcj[i].name);
|
||||
+ printed = 1;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if(!printed)
|
||||
+ printf("\tNo filters specified\n");
|
||||
+ else
|
||||
+ printf("\n");
|
||||
+
|
||||
+ return;
|
||||
+
|
||||
+failed:
|
||||
+ fprintf(stderr, "xz: error reading stored compressor options from "
|
||||
+ "filesystem!\n");
|
||||
+}
|
||||
+
|
||||
+
|
||||
+/*
|
||||
+ * This function is called by mksquashfs to initialise the
|
||||
+ * compressor, before compress() is called.
|
||||
+ *
|
||||
+ * This function returns 0 on success, and
|
||||
+ * -1 on error
|
||||
+ */
|
||||
+static int xz_init(void **strm, int block_size, int datablock)
|
||||
+{
|
||||
+ int i, j, filters = datablock ? filter_count : 1;
|
||||
+ struct filter *filter = malloc(filters * sizeof(struct filter));
|
||||
+ struct xz_stream *stream;
|
||||
+
|
||||
+ if(filter == NULL)
|
||||
+ goto failed;
|
||||
+
|
||||
+ stream = *strm = malloc(sizeof(struct xz_stream));
|
||||
+ if(stream == NULL)
|
||||
+ goto failed2;
|
||||
+
|
||||
+ stream->filter = filter;
|
||||
+ stream->filters = filters;
|
||||
+
|
||||
+ memset(filter, 0, filters * sizeof(struct filter));
|
||||
+
|
||||
+ stream->dictionary_size = datablock ? dictionary_size :
|
||||
+ SQUASHFS_METADATA_SIZE;
|
||||
+
|
||||
+ filter[0].filter[0].id = LZMA_FILTER_LZMA2;
|
||||
+ filter[0].filter[0].options = &stream->opt;
|
||||
+ filter[0].filter[1].id = LZMA_VLI_UNKNOWN;
|
||||
+
|
||||
+ for(i = 0, j = 1; datablock && bcj[i].name; i++) {
|
||||
+ if(bcj[i].selected) {
|
||||
+ filter[j].buffer = malloc(block_size);
|
||||
+ if(filter[j].buffer == NULL)
|
||||
+ goto failed3;
|
||||
+ filter[j].filter[0].id = bcj[i].id;
|
||||
+ filter[j].filter[1].id = LZMA_FILTER_LZMA2;
|
||||
+ filter[j].filter[1].options = &stream->opt;
|
||||
+ filter[j].filter[2].id = LZMA_VLI_UNKNOWN;
|
||||
+ j++;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+
|
||||
+failed3:
|
||||
+ for(i = 1; i < filters; i++)
|
||||
+ free(filter[i].buffer);
|
||||
+ free(stream);
|
||||
+
|
||||
+failed2:
|
||||
+ free(filter);
|
||||
+
|
||||
+failed:
|
||||
+ return -1;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static int xz_compress(void *strm, void *dest, void *src, int size,
|
||||
+ int block_size, int *error)
|
||||
+{
|
||||
+ int i;
|
||||
+ lzma_ret res = 0;
|
||||
+ struct xz_stream *stream = strm;
|
||||
+ struct filter *selected = NULL;
|
||||
+
|
||||
+ stream->filter[0].buffer = dest;
|
||||
+
|
||||
+ for(i = 0; i < stream->filters; i++) {
|
||||
+ struct filter *filter = &stream->filter[i];
|
||||
+
|
||||
+ if(lzma_lzma_preset(&stream->opt, preset))
|
||||
+ goto failed;
|
||||
+
|
||||
+ stream->opt.dict_size = stream->dictionary_size;
|
||||
+
|
||||
+ if (lc >= 0)
|
||||
+ stream->opt.lc = lc;
|
||||
+
|
||||
+ if (lp >= 0)
|
||||
+ stream->opt.lp = lp;
|
||||
+
|
||||
+ if (pb >= 0)
|
||||
+ stream->opt.pb = pb;
|
||||
+
|
||||
+ filter->length = 0;
|
||||
+ res = lzma_stream_buffer_encode(filter->filter,
|
||||
+ LZMA_CHECK_CRC32, NULL, src, size, filter->buffer,
|
||||
+ &filter->length, block_size);
|
||||
+
|
||||
+ if(res == LZMA_OK) {
|
||||
+ if(!selected || selected->length > filter->length)
|
||||
+ selected = filter;
|
||||
+ } else if(res != LZMA_BUF_ERROR)
|
||||
+ goto failed;
|
||||
+ }
|
||||
+
|
||||
+ if(!selected)
|
||||
+ /*
|
||||
+ * Output buffer overflow. Return out of buffer space
|
||||
+ */
|
||||
+ return 0;
|
||||
+
|
||||
+ if(selected->buffer != dest)
|
||||
+ memcpy(dest, selected->buffer, selected->length);
|
||||
+
|
||||
+ return (int) selected->length;
|
||||
+
|
||||
+failed:
|
||||
+ /*
|
||||
+ * All other errors return failure, with the compressor
|
||||
+ * specific error code in *error
|
||||
+ */
|
||||
+ *error = res;
|
||||
+ return -1;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static int xz_uncompress(void *dest, void *src, int size, int outsize,
|
||||
+ int *error)
|
||||
+{
|
||||
+ size_t src_pos = 0;
|
||||
+ size_t dest_pos = 0;
|
||||
+ uint64_t memlimit = MEMLIMIT;
|
||||
+
|
||||
+ lzma_ret res = lzma_stream_buffer_decode(&memlimit, 0, NULL,
|
||||
+ src, &src_pos, size, dest, &dest_pos, outsize);
|
||||
+
|
||||
+ if(res == LZMA_OK && size == (int) src_pos)
|
||||
+ return (int) dest_pos;
|
||||
+ else {
|
||||
+ *error = res;
|
||||
+ return -1;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static void xz_usage(FILE *stream)
|
||||
+{
|
||||
+ fprintf(stream, "\t -Xbcj filter1,filter2,...,filterN\n");
|
||||
+ fprintf(stream, "\t\tCompress using filter1,filter2,...,filterN in");
|
||||
+ fprintf(stream, " turn\n\t\t(in addition to no filter), and choose");
|
||||
+ fprintf(stream, " the best compression.\n");
|
||||
+ fprintf(stream, "\t\tAvailable filters: x86, arm, armthumb,");
|
||||
+ fprintf(stream, " powerpc, sparc, ia64\n");
|
||||
+ fprintf(stream, "\t -Xdict-size <dict-size>\n");
|
||||
+ fprintf(stream, "\t\tUse <dict-size> as the XZ dictionary size. The");
|
||||
+ fprintf(stream, " dictionary size\n\t\tcan be specified as a");
|
||||
+ fprintf(stream, " percentage of the block size, or as an\n\t\t");
|
||||
+ fprintf(stream, "absolute value. The dictionary size must be less");
|
||||
+ fprintf(stream, " than or equal\n\t\tto the block size and 8192 bytes");
|
||||
+ fprintf(stream, " or larger. It must also be\n\t\tstorable in the xz");
|
||||
+ fprintf(stream, " header as either 2^n or as 2^n+2^(n+1).\n\t\t");
|
||||
+ fprintf(stream, "Example dict-sizes are 75%%, 50%%, 37.5%%, 25%%, or");
|
||||
+ fprintf(stream, " 32K, 16K, 8K\n\t\tetc.\n");
|
||||
+ fprintf(stream, "\t -Xpreset <preset-level>\n");
|
||||
+ fprintf(stream, "\t\tUse <preset-value> as the custom preset to use");
|
||||
+ fprintf(stream, " on compress.\n\t\t<preset-level> should be 0 .. 9");
|
||||
+ fprintf(stream, " (default 6)\n");
|
||||
+ fprintf(stream, "\t -Xe\n");
|
||||
+ fprintf(stream, "\t\tEnable additional compression settings by passing");
|
||||
+ fprintf(stream, " the EXTREME\n\t\tflag to the compression flags.\n");
|
||||
+ fprintf(stream, "\t -Xlc <value>\n");
|
||||
+ fprintf(stream, "\t -Xlp <value>\n");
|
||||
+ fprintf(stream, "\t -Xpb <value>\n");
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static int option_args(char *option)
|
||||
+{
|
||||
+ if(strcmp(option, "-Xbcj") == 0 ||
|
||||
+ strcmp(option, "-Xdict-size") == 0 ||
|
||||
+ strcmp(option, "-Xpreset") == 0 ||
|
||||
+ strcmp(option, "-Xe") == 0 ||
|
||||
+ strcmp(option, "-Xlc") == 0 ||
|
||||
+ strcmp(option, "-Xlp") == 0 ||
|
||||
+ strcmp(option, "-Xpb") == 0)
|
||||
+ return 1;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+struct compressor xz_comp_ops = {
|
||||
+ .init = xz_init,
|
||||
+ .compress = xz_compress,
|
||||
+ .uncompress = xz_uncompress,
|
||||
+ .options = xz_options,
|
||||
+ .options_post = xz_options_post,
|
||||
+ .dump_options = xz_dump_options,
|
||||
+ .extract_options = xz_extract_options,
|
||||
+ .display_options = xz_display_options,
|
||||
+ .usage = xz_usage,
|
||||
+ .option_args = option_args,
|
||||
+ .id = XZ_COMPRESSION,
|
||||
+ .name = "xz",
|
||||
+ .supported = 1
|
||||
+};
|
||||
Reference in New Issue
Block a user