ACPI: watchdog: Allow disabling WDAT at boot
Subsystems (23)
Sasha Levin
maintainerPATCH 1/67 ACPI: watchdog: Allow disabling WDAT at boot
From: Jean Delvare <[email protected]>
[ Upstream commit 3f9e12e0df012c4a9a7fd7eb0d3ae69b459d6b2c ]
In case the WDAT interface is broken, give the user an option to ignore it to let a native driver bind to the watchdog device instead.
--- Documentation/admin-guide/kernel-parameters.txt | 4 ++++ drivers/acpi/acpi_watchdog.c | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-)
Documentation/admin-guide/kernel-parameters.txt +4 -0
@@ -136,6 +136,10 @@ dynamic table installation which will install SSDT tables to /sys/firmware/acpi/tables/dynamic. + acpi_no_watchdog [HW,ACPI,WDT] + Ignore the ACPI-based watchdog interface (WDAT) and let + a native driver control the watchdog device instead. + acpi_rsdp= [ACPI,EFI,KEXEC] Pass the RSDP address to the kernel, mostly used on machines running EFI runtime service to boot the
drivers/acpi/acpi_watchdog.c +11 -1
@@ -55,12 +55,14 @@ static bool acpi_watchdog_uses_rtc(const struct acpi_table_wdat *wdat) }#endif +static bool acpi_no_watchdog; +static const struct acpi_table_wdat *acpi_watchdog_get_wdat (void ) {const struct acpi_table_wdat *wdat =NULL ;acpi_status status; -if (acpi_disabled) +if (acpi_disabled || acpi_no_watchdog)return NULL ; status = acpi_get_table(ACPI_SIG_WDAT, 0,
@@ -88,6 +90,14 @@ bool acpi_has_watchdog(void) }EXPORT_SYMBOL_GPL (acpi_has_watchdog); +/* ACPI watchdog can be disabled on boot command line */ +static int __init disable_acpi_watchdog (char *str) +{ + acpi_no_watchdog = true; +return 1 ; +} +__setup ("acpi_no_watchdog" , disable_acpi_watchdog); +void __init acpi_watchdog_init (void ) {const struct acpi_wdat_entry *entries;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 2/67 HID: apple: Add support for recent firmware on Magic Keyboards
From: Mansour Behabadi <[email protected]>
[ Upstream commit e433be929e63265b7412478eb7ff271467aee2d7 ]
Magic Keyboards with more recent firmware (0x0100) report Fn key differently. Without this patch, Fn key may not behave as expected and may not be configurable via hid_apple fnmode module parameter.
--- drivers/hid/hid-apple.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/hid/hid-apple.c +2 -1
@@ -340,7 +340,8 @@ static int apple_input_mapping(struct hid_device *hdev, struct hid_input *hi, unsigned long **bit, int *max) {if (usage->hid == (HID_UP_CUSTOM |0x0003 ) || - usage->hid == (HID_UP_MSVENDOR |0x0003 )) { + usage->hid == (HID_UP_MSVENDOR |0x0003 ) || + usage->hid == (HID_UP_HPVENDOR2 |0x0003 )) {/* The fn key on Apple USB keyboards */ set_bit (EV_REP , hi->input->evbit);hid_map_usage_clear (hi, usage, bit, max,EV_KEY ,KEY_FN );
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 3/67 HID: core: fix off-by-one memset in hid_report_raw_event()
In reply to Sasha LevinFrom: Johan Korsnes <[email protected]>
[ Upstream commit 5ebdffd25098898aff1249ae2f7dbfddd76d8f8f ]
In case a report is greater than HID_MAX_BUFFER_SIZE, it is truncated, but the report-number byte is not correctly handled. This results in a off-by-one in the following memset, causing a kernel Oops and ensuing system crash.
Note: With commit 8ec321e96e05 ("HID: Fix slab-out-of-bounds read in hid_field_extract") I no longer hit the kernel Oops as we instead fail "controlled" at probe if there is a report too long in the HID report-descriptor. hid_report_raw_event() is an exported symbol, so presumabely we cannot always rely on this being the case.
function.")
--- drivers/hid/hid-core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/hid/hid-core.c +3 -1
@@ -1741,7 +1741,9 @@ int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, u32 size, rsize = ((report->size -1 ) >>3 ) +1 ; -if (rsize >HID_MAX_BUFFER_SIZE ) +if (report_enum->numbered && rsize >=HID_MAX_BUFFER_SIZE ) + rsize =HID_MAX_BUFFER_SIZE -1 ; +else if (rsize >HID_MAX_BUFFER_SIZE ) rsize =HID_MAX_BUFFER_SIZE ;if (csize < rsize) {
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 4/67 HID: core: increase HID report buffer size to 8KiB
In reply to Sasha LevinFrom: Johan Korsnes <[email protected]>
[ Upstream commit 84a4062632462c4320704fcdf8e99e89e94c0aba ]
We have a HID touch device that reports its opens and shorts test results in HID buffers of size 8184 bytes. The maximum size of the HID buffer is currently set to 4096 bytes, causing probe of this device to fail. With this patch we increase the maximum size of the HID buffer to 8192 bytes, making device probe and acquisition of said buffers succeed.
--- include/linux/hid.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/hid.h +1 -1
@@ -492,7 +492,7 @@ struct hid_report_enum { };#define HID_MIN_BUFFER_SIZE 64/* make sure there is at least a packet size of space */ -#define HID_MAX_BUFFER_SIZE 4096/* 4kb */ +#define HID_MAX_BUFFER_SIZE 8192/* 8kb */ #define HID_CONTROL_FIFO_SIZE 256/* to init devices with >100 reports */ #define HID_OUTPUT_FIFO_SIZE 64
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 5/67 HID: hiddev: Fix race in in hiddev_disconnect()
In reply to Sasha LevinFrom: "[email protected]" <[email protected]>
[ Upstream commit 5c02c447eaeda29d3da121a2e17b97ccaf579b51 ]
Syzbot reports that "hiddev" is used after it's free in hiddev_disconnect(). The hiddev_disconnect() function sets "hiddev->exist = 0;" so hiddev_release() can free it as soon as we drop the "existancelock" lock. This patch moves the mutex_unlock(&hiddev->existancelock) until after we have finished using it.
--- drivers/hid/usbhid/hiddev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/usbhid/hiddev.c +1 -1
@@ -932,9 +932,9 @@ void hiddev_disconnect(struct hid_device *hid) hiddev->exist =0 ;if (hiddev->open) { -mutex_unlock (&hiddev->existancelock);hid_hw_close (hiddev->hid);wake_up_interruptible (&hiddev->wait); +mutex_unlock (&hiddev->existancelock); }else {mutex_unlock (&hiddev->existancelock);kfree (hiddev);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 6/67 HID: alps: Fix an error handling path in 'alps_input_configured()'
In reply to Sasha LevinFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 8d2e77b39b8fecb794e19cd006a12f90b14dd077 ]
They are issues:
- if 'input_allocate_device()' fails and return NULL, there is no need to free anything and 'input_free_device()' call is a no-op. It can be axed.
- 'ret' is known to be 0 at this point, so we must set it to a meaningful value before returning
--- drivers/hid/hid-alps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/hid-alps.c +1 -1
@@ -730,7 +730,7 @@ static int alps_input_configured(struct hid_device *hdev, struct hid_input *hi)if (data->has_sp) { input2 =input_allocate_device ();if (!input2) { -input_free_device (input2); + ret = -ENOMEM ; goto exit; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 7/67 i2c: altera: Fix potential integer overflow
In reply to Sasha LevinFrom: "Gustavo A. R. Silva" <[email protected]>
[ Upstream commit 54498e8070e19e74498a72c7331348143e7e1f8c ]
Factor out 100 from the equation and do 32-bit arithmetic (3 * clk_mhz / 10) instead of 64-bit.
Notice that clk_mhz is MHz, so the multiplication will never wrap 32 bits and there is no need for div_u64().
Addresses-Coverity: 1458369 ("Unintentional integer overflow")
--- drivers/i2c/busses/i2c-altera.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-altera.c +1 -1
@@ -171,7 +171,7 @@ static void altr_i2c_init(struct altr_i2c_dev *idev)/* SCL Low Time */ writel (t_low, idev->base +ALTR_I2C_SCL_LOW );/* SDA Hold Time, 300ns */ -writel (div_u64 (300 * clk_mhz,1000 ), idev->base +ALTR_I2C_SDA_HOLD ); +writel (3 * clk_mhz /10 , idev->base +ALTR_I2C_SDA_HOLD );/* Mask all master interrupt bits */ altr_i2c_int_enable (idev,ALTR_I2C_ALL_IRQ , false);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 8/67 ACPI: watchdog: Set default timeout in probe
In reply to Sasha LevinFrom: Mika Westerberg <[email protected]>
[ Upstream commit cabe17d0173ab04bd3f87b8199ae75f43f1ea473 ]
If the BIOS default timeout for the watchdog is too small userspace may not have enough time to configure new timeout after opening the device before the system is already reset. For this reason program default timeout of 30 seconds in the driver probe and allow userspace to change this from command line or through module parameter (wdat_wdt.timeout).
--- drivers/watchdog/wdat_wdt.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
drivers/watchdog/wdat_wdt.c +23 -0
@@ -54,6 +54,13 @@ module_param(nowayout, bool, 0); MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); +#define WDAT_DEFAULT_TIMEOUT 30 + +static int timeout =WDAT_DEFAULT_TIMEOUT ; +module_param (timeout, int,0 ); +MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds (default=" + __MODULE_STRING(WDAT_DEFAULT_TIMEOUT) ")"); +static int wdat_wdt_read (struct wdat_wdt *wdat,const struct wdat_instruction *instr,u32 *value) {
@@ -438,6 +445,22 @@ static int wdat_wdt_probe(struct platform_device *pdev)platform_set_drvdata (pdev, wdat); +/* +* Set initial timeout so that userspace has time to configure the +* watchdog properly after it has opened the device. In some cases +* the BIOS default is too short and causes immediate reboot. +*/ +if (timeout *1000 < wdat->wdd.min_hw_heartbeat_ms || + timeout *1000 > wdat->wdd.max_hw_heartbeat_ms) { +dev_warn (dev,"Invalid timeout %d given, using %d\n" , + timeout,WDAT_DEFAULT_TIMEOUT ); + timeout =WDAT_DEFAULT_TIMEOUT ; + } + + ret =wdat_wdt_set_timeout (&wdat->wdd, timeout); +if (ret) +return ret; +watchdog_set_nowayout (&wdat->wdd, nowayout);return devm_watchdog_register_device (dev, &wdat->wdd); }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 9/67 HID: i2c-hid: add Trekstor Surfbook E11B to descriptor override
In reply to Sasha LevinFrom: Kai-Heng Feng <[email protected]>
[ Upstream commit be0aba826c4a6ba5929def1962a90d6127871969 ]
The Surfbook E11B uses the SIPODEV SP1064 touchpad, which does not supply descriptors, so it has to be added to the override list.
--- drivers/hid/i2c-hid/i2c-hid-dmi-quirks.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/hid/i2c-hid/i2c-hid-dmi-quirks.c +8 -0
@@ -341,6 +341,14 @@ static const struct dmi_system_id i2c_hid_dmi_desc_override_table[] = { }, .driver_data = (void *)&sipodev_desc }, + { + .ident = "Trekstor SURFBOOK E11B", + .matches = { +DMI_EXACT_MATCH (DMI_SYS_VENDOR ,"TREKSTOR" ), + DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "SURFBOOK E11B"), + }, + .driver_data = (void *)&sipodev_desc + }, { .ident ="Direkt-Tek DTLAPY116-2" , .matches = {
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 10/67 mips: vdso: fix 'jalr t9' crash in vdso code
In reply to Sasha LevinFrom: Victor Kamensky <[email protected]>
[ Upstream commit d3f703c4359ff06619b2322b91f69710453e6b6d ]
Observed that when kernel is built with Yocto mips64-poky-linux-gcc, and mips64-poky-linux-gnun32-gcc toolchain, resulting vdso contains 'jalr t9' instructions in its code and since in vdso case nobody sets GOT table code crashes when instruction reached. On other hand observed that when kernel is built mips-poky-linux-gcc toolchain, the same 'jalr t9' instruction are replaced with PC relative function calls using 'bal' instructions.
The difference boils down to -mrelax-pic-calls and -mexplicit-relocs gcc options that gets different default values depending on gcc target triplets and corresponding binutils. -mrelax-pic-calls got enabled by default only in mips-poky-linux-gcc case. MIPS binutils ld relies on R_MIPS_JALR relocation to convert 'jalr t9' into 'bal' and such relocation is generated only if -mrelax-pic-calls option is on.
Please note 'jalr t9' conversion to 'bal' can happen only to static functions. These static PIC calls use mips local GOT entries that are supposed to be filled with start of DSO value by run-time linker (missing in VDSO case) and they do not have dynamic relocations. Global mips GOT entries must have dynamic relocations and they should be prevented by cmd_vdso_check Makefile rule.
Solution call out -mrelax-pic-calls and -mexplicit-relocs options explicitly while compiling MIPS vdso code. That would get correct and consistent between different toolchains behaviour.
--- arch/mips/vdso/Makefile | 1 + 1 file changed, 1 insertion(+)
arch/mips/vdso/Makefile +1 -0
@@ -29,6 +29,7 @@ endif cflags-vdso := $(ccflags-vdso) \ $(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \ -O3 -g -fPIC -fno-strict-aliasing -fno-common -fno-builtin -G 0 \ + -mrelax-pic-calls -mexplicit-relocs \ -fno-stack-protector -fno-jump-tables -DDISABLE_BRANCH_PROFILING \ $(call cc-option, -fno-asynchronous-unwind-tables) \ $(call cc-option, -fno-stack-protector)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 11/67 MIPS: Disable VDSO time functionality on microMIPS
In reply to Sasha LevinFrom: Paul Burton <[email protected]>
[ Upstream commit 07015d7a103c4420b69a287b8ef4d2535c0f4106 ]
A check we're about to add to pick up on function calls that depend on bogus use of the GOT in the VDSO picked up on instances of such function calls in microMIPS builds. Since the code appears genuinely problematic, and given the relatively small amount of use & testing that microMIPS sees, go ahead & disable the VDSO for microMIPS builds.
--- arch/mips/vdso/Makefile | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
arch/mips/vdso/Makefile +17 -2
@@ -48,6 +48,8 @@ endif CFLAGS_REMOVE_vgettimeofday.o = -pg +DISABLE_VDSO := n + # # For the pre-R6 code in arch/mips/vdso/vdso.h for locating # the base address of VDSO, the linker will emit a R_MIPS_PC32
@@ -61,11 +63,24 @@ CFLAGS_REMOVE_vgettimeofday.o = -pg ifndef CONFIG_CPU_MIPSR6 ifeq ($(call ld-ifversion, -lt, 225000000, y),y) $(warning MIPS VDSO requires binutils >= 2.25) - obj-vdso-y := $(filter-out vgettimeofday.o, $(obj-vdso-y)) - ccflags-vdso += -DDISABLE_MIPS_VDSO + DISABLE_VDSO := y endif endif +# +# GCC (at least up to version 9.2) appears to emit function calls that make use +# of the GOT when targeting microMIPS, which we can't use in the VDSO due to +# the lack of relocations. As such, we disable the VDSO for microMIPS builds. +# +ifdef CONFIG_CPU_MICROMIPS + DISABLE_VDSO := y +endif + +ifeq ($(DISABLE_VDSO),y) + obj-vdso-y := $(filter-out vgettimeofday.o, $(obj-vdso-y)) + ccflags-vdso += -DDISABLE_MIPS_VDSO +endif + # VDSO linker flags. VDSO_LDFLAGS := \ -Wl,-Bsymbolic -Wl,--no-undefined -Wl,-soname=linux-vdso.so.1 \
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 12/67 mips: vdso: add build time check that no 'jalr t9' calls left
In reply to Sasha LevinFrom: Victor Kamensky <[email protected]>
[ Upstream commit 976c23af3ee5bd3447a7bfb6c356ceb4acf264a6 ]
vdso shared object cannot have GOT based PIC 'jalr t9' calls because nobody set GOT table in vdso. Contributing into vdso .o files are compiled in PIC mode and as result for internal static functions calls compiler will generate 'jalr t9' instructions. Those are supposed to be converted into PC relative 'bal' calls by linker when relocation are processed.
Mips global GOT entries do have dynamic relocations and they will be caught by cmd_vdso_check Makefile rule. Static PIC calls go through mips local GOT entries that do not have dynamic relocations. For those 'jalr t9' calls could be present but without dynamic relocations and they need to be converted to 'bal' calls by linker.
Add additional build time check to make sure that no 'jalr t9' slip through because of some toolchain misconfiguration that prevents 'jalr t9' to 'bal' conversion.
--- arch/mips/vdso/Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
arch/mips/vdso/Makefile +7 -1
@@ -93,12 +93,18 @@ GCOV_PROFILE := n UBSAN_SANITIZE := n KCOV_INSTRUMENT := n +# Check that we don't have PIC 'jalr t9' calls left +quiet_cmd_vdso_mips_check = VDSOCHK $@ + cmd_vdso_mips_check = if $(OBJDUMP) --disassemble $@ | egrep -h "jalr.*t9" > /dev/null; \ + then (echo >&2 "$@: PIC 'jalr t9' calls are not supported"; \ + rm -f $@; /bin/false); fi + # # Shared build commands. # quiet_cmd_vdsold_and_vdso_check = LD $@ - cmd_vdsold_and_vdso_check = $(cmd_vdsold); $(cmd_vdso_check) + cmd_vdsold_and_vdso_check = $(cmd_vdsold); $(cmd_vdso_check); $(cmd_vdso_mips_check) quiet_cmd_vdsold = VDSO $@ cmd_vdsold = $(CC) $(c_flags) $(VDSO_LDFLAGS) \
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 13/67 MIPS: cavium_octeon: Fix syncw generation.
In reply to Sasha LevinFrom: Mark Tomlinson <[email protected]>
[ Upstream commit 97e914b7de3c943011779b979b8093fdc0d85722 ]
The Cavium Octeon CPU uses a special sync instruction for implementing wmb, and due to a CPU bug, the instruction must appear twice. A macro had been defined to hide this:
#define __SYNC_rpt(type) (1 + (type == __SYNC_wmb))
which was intended to evaluate to 2 for __SYNC_wmb, and 1 for any other type of sync. However, this expression is evaluated by the assembler, and not the compiler, and the result of '==' in the assembler is 0 or -1, not 0 or 1 as it is in C. The net result was wmb() producing no code at all. The simple fix in this patch is to change the '+' to '-'.
--- arch/mips/include/asm/sync.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/mips/include/asm/sync.h +3 -1
@@ -155,9 +155,11 @@* effective barrier as noted by commit 6b07d38aaa52 ("MIPS: Octeon: Use * optimized memory barrier primitives."). Here we specify that the affected * sync instructions should be emitted twice. +* Note that this expression is evaluated by the assembler (not the compiler), +* and that the assembler evaluates '==' as 0 or -1, not 0 or 1. */ #ifdef CONFIG_CPU_CAVIUM_OCTEON -# define __SYNC_rpt (type) (1 + (type == __SYNC_wmb)) +# define __SYNC_rpt (type) (1 - (type == __SYNC_wmb))#else # define __SYNC_rpt (type) 1#endif
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 14/67 MIPS: VPE: Fix a double free and a memory leak in 'release_vpe()'
In reply to Sasha LevinFrom: Christophe JAILLET <[email protected]>
[ Upstream commit bef8e2dfceed6daeb6ca3e8d33f9c9d43b926580 ]
Pointer on the memory allocated by 'alloc_progmem()' is stored in 'v->load_addr'. So this is this memory that should be freed by 'release_progmem()'.
'release_progmem()' is only a call to 'kfree()'.
With the current code, there is both a double free and a memory leak. Fix it by passing the correct pointer to 'release_progmem()'.
--- arch/mips/kernel/vpe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/kernel/vpe.c +1 -1
@@ -134,7 +134,7 @@ void release_vpe(struct vpe *v) {list_del (&v->list);if (v->load_addr) -release_progmem (v); +release_progmem (v->load_addr);kfree (v); }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 15/67 HID: hid-bigbenff: fix general protection fault caused by double kfree
In reply to Sasha LevinFrom: Hanno Zulla <[email protected]>
[ Upstream commit 789a2c250340666220fa74bc6c8f58497e3863b3 ]
The struct *bigben was allocated via devm_kzalloc() and then used as a parameter in input_ff_create_memless(). This caused a double kfree during removal of the device, since both the managed resource API and ml_ff_destroy() in drivers/input/ff-memless.c would call kfree() on it.
--- drivers/hid/hid-bigbenff.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/hid/hid-bigbenff.c +8 -2
@@ -220,10 +220,16 @@ static void bigben_worker(struct work_struct *work)static int hid_bigben_play_effect (struct input_dev *dev,void *data,struct ff_effect *effect) { -struct bigben_device *bigben = data; +struct hid_device *hid =input_get_drvdata (dev); +struct bigben_device *bigben =hid_get_drvdata (hid);u8 right_motor_on;u8 left_motor_force; +if (!bigben) { +hid_err (hid,"no device data\n" ); +return 0 ; + } +if (effect->type !=FF_RUMBLE )return 0 ;
@@ -341,7 +347,7 @@ static int bigben_probe(struct hid_device *hid,INIT_WORK (&bigben->worker, bigben_worker); - error =input_ff_create_memless (hidinput->input, bigben, + error =input_ff_create_memless (hidinput->input,NULL , hid_bigben_play_effect);if (error)return error;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 16/67 HID: hid-bigbenff: call hid_hw_stop() in case of error
In reply to Sasha LevinFrom: Hanno Zulla <[email protected]>
[ Upstream commit 976a54d0f4202cb412a3b1fc7f117e1d97db35f3 ]
It's required to call hid_hw_stop() once hid_hw_start() was called previously, so error cases need to handle this. Also, hid_hw_close() is not necessary during removal.
--- drivers/hid/hid-bigbenff.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/hid/hid-bigbenff.c +10 -5
@@ -305,7 +305,6 @@ static void bigben_remove(struct hid_device *hid)struct bigben_device *bigben =hid_get_drvdata (hid);cancel_work_sync (&bigben->worker); -hid_hw_close (hid);hid_hw_stop (hid); }
@@ -350,7 +349,7 @@ static int bigben_probe(struct hid_device *hid, error =input_ff_create_memless (hidinput->input,NULL , hid_bigben_play_effect);if (error) -return error; + goto error_hw_stop; name_sz =strlen (dev_name (&hid->dev)) +strlen (":red:bigben#" ) +1 ;
@@ -360,8 +359,10 @@ static int bigben_probe(struct hid_device *hid,sizeof (struct led_classdev ) + name_sz,GFP_KERNEL ); -if (!led) -return -ENOMEM ; +if (!led) { + error = -ENOMEM ; + goto error_hw_stop; + } name = (void *)(&led[1 ]); snprintf(name, name_sz, "%s:red:bigben%d",
@@ -375,7 +376,7 @@ static int bigben_probe(struct hid_device *hid, bigben->leds[n] = led; error =devm_led_classdev_register (&hid->dev, led);if (error) -return error; + goto error_hw_stop; }/* initial state: LED1 is on, no rumble effect */
@@ -389,6 +390,10 @@ static int bigben_probe(struct hid_device *hid,hid_info (hid,"LED and force feedback support for BigBen gamepad\n" );return 0 ; + +error_hw_stop: +hid_hw_stop (hid); +return error; } static __u8 *bigben_report_fixup(struct hid_device *hid, __u8 *rdesc,
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 17/67 HID: hid-bigbenff: fix race condition for scheduled work during removal
In reply to Sasha LevinFrom: Hanno Zulla <[email protected]>
[ Upstream commit 4eb1b01de5b9d8596d6c103efcf1a15cfc1bedf7 ]
It's possible that there is scheduled work left while the device is already being removed, which can cause a kernel crash. Adding a flag will avoid this.
--- drivers/hid/hid-bigbenff.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/hid/hid-bigbenff.c +6 -0
@@ -174,6 +174,7 @@ static __u8 pid0902_rdesc_fixed[] = {struct bigben_device {struct hid_device *hid;struct hid_report *report; +bool removed;u8 led_state;/* LED1 = 1 .. LED4 = 8 */ u8 right_motor_on;/* right motor off/on 0/1 */ u8 left_motor_force;/* left motor force 0-255 */
@@ -190,6 +191,9 @@ static void bigben_worker(struct work_struct *work) struct bigben_device, worker);struct hid_field *report_field = bigben->report->field[0 ]; +if (bigben->removed) +return ; +if (bigben->work_led) { bigben->work_led = false; report_field->value[0 ] =0x01 ;/* 1 = led message */
@@ -304,6 +308,7 @@ static void bigben_remove(struct hid_device *hid) {struct bigben_device *bigben =hid_get_drvdata (hid); + bigben->removed = true;cancel_work_sync (&bigben->worker);hid_hw_stop (hid); }
@@ -324,6 +329,7 @@ static int bigben_probe(struct hid_device *hid,return -ENOMEM ;hid_set_drvdata (hid, bigben); bigben->hid = hid; + bigben->removed = false; error =hid_parse (hid);if (error) {
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 18/67 riscv: set pmp configuration if kernel is running in M-mode
In reply to Sasha LevinFrom: Greentime Hu <[email protected]>
[ Upstream commit c68a9032299e837b56d356de9250c93094f7e0e3 ]
When the kernel is running in S-mode, the expectation is that the bootloader or SBI layer will configure the PMP to allow the kernel to access physical memory. But, when the kernel is running in M-mode and is started with the ELF "loader", there's probably no bootloader or SBI layer involved to configure the PMP. Thus, we need to configure the PMP ourselves to enable the kernel to access all regions.
--- arch/riscv/include/asm/csr.h | 12 ++++++++++++ arch/riscv/kernel/head.S | 6 ++++++ 2 files changed, 18 insertions(+)
arch/riscv/include/asm/csr.h +12 -0
@@ -72,6 +72,16 @@#define EXC_LOAD_PAGE_FAULT 13#define EXC_STORE_PAGE_FAULT 15 +/* PMP configuration */ +#define PMP_R 0x01 +#define PMP_W 0x02 +#define PMP_X 0x04 +#define PMP_A 0x18 +#define PMP_A_TOR 0x08 +#define PMP_A_NA4 0x10 +#define PMP_A_NAPOT 0x18 +#define PMP_L 0x80 +/* symbolic CSR names: */ #define CSR_CYCLE 0xc00#define CSR_TIME 0xc01
@@ -100,6 +110,8 @@#define CSR_MCAUSE 0x342#define CSR_MTVAL 0x343#define CSR_MIP 0x344 +#define CSR_PMPCFG0 0x3a0 +#define CSR_PMPADDR0 0x3b0#define CSR_MHARTID 0xf14#ifdef CONFIG_RISCV_M_MODE
arch/riscv/kernel/head.S +6 -0
@@ -58,6 +58,12 @@ _start_kernel: /* Reset all registers except ra, a0, a1 */ call reset_regs + /* Setup a PMP to permit access to all of memory. */ + li a0, -1 + csrw CSR_PMPADDR0, a0 + li a0, (PMP_A_NAPOT | PMP_R | PMP_W | PMP_X) + csrw CSR_PMPCFG0, a0 + /* * The hartid in a0 is expected later on, and we have no firmware * to hand it to us.
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 19/67 RISC-V: Don't enable all interrupts in trap_init()
In reply to Sasha LevinFrom: Anup Patel <[email protected]>
[ Upstream commit 6a1ce99dc4bde564e4a072936f9d41f4a439140e ]
Historically, we have been enabling all interrupts for each HART in trap_init(). Ideally, we should only enable M-mode interrupts for M-mode kernel and S-mode interrupts for S-mode kernel in trap_init().
Currently, we get suprious S-mode interrupts on Kendryte K210 board running M-mode NO-MMU kernel because we are enabling all interrupts in trap_init(). To fix this, we only enable software and external interrupt in trap_init(). In future, trap_init() will only enable software interrupt and PLIC driver will enable external interrupt using CPU notifiers.
--- arch/riscv/kernel/traps.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/riscv/kernel/traps.c +2 -2
@@ -156,6 +156,6 @@ void __init trap_init(void)csr_write (CSR_SCRATCH ,0 );/* Set the exception vector address */ csr_write (CSR_TVEC , &handle_exception); -/* Enable all interrupts */ -csr_write (CSR_IE ,-1 ); +/* Enable interrupts */ +csr_write (CSR_IE ,IE_SIE |IE_EIE ); }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 20/67 MIPS: vdso: Wrap -mexplicit-relocs in cc-option
In reply to Sasha LevinFrom: Nathan Chancellor <[email protected]>
[ Upstream commit 72cf3b3df423c1bbd8fa1056fed009d3a260f8a9 ]
Clang does not support this option and errors out:
clang-11: error: unknown argument: '-mexplicit-relocs'
Clang does not appear to need this flag like GCC does because the jalr check that was added in commit 976c23af3ee5 ("mips: vdso: add build time check that no 'jalr t9' calls left") passes just fine with
$ make ARCH=mips CC=clang CROSS_COMPILE=mipsel-linux-gnu- malta_defconfig arch/mips/vdso/
even before commit d3f703c4359f ("mips: vdso: fix 'jalr t9' crash in vdso code").
-mrelax-pic-calls has been supported since clang 9, which is the earliest version that could build a working MIPS kernel, and it is the default for clang so just leave it be.
--- arch/mips/vdso/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/vdso/Makefile +1 -1
@@ -29,7 +29,7 @@ endif cflags-vdso := $(ccflags-vdso) \ $(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \ -O3 -g -fPIC -fno-strict-aliasing -fno-common -fno-builtin -G 0 \ - -mrelax-pic-calls -mexplicit-relocs \ + -mrelax-pic-calls $(call cc-option, -mexplicit-relocs) \ -fno-stack-protector -fno-jump-tables -DDISABLE_BRANCH_PROFILING \ $(call cc-option, -fno-asynchronous-unwind-tables) \ $(call cc-option, -fno-stack-protector)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 21/67 kunit: run kunit_tool from any directory
In reply to Sasha LevinFrom: Heidi Fahim <[email protected]>
[ Upstream commit be886ba90cce2fb2f5a4dbcda8f3be3fd1b2f484 ]
Implemented small fix so that the script changes work directories to the root of the linux kernel source tree from which kunit.py is run. This enables the user to run kunit from any working directory. Originally considered using os.path.join but this is more error prone as we would have to find all file path usages and modify them accordingly. Using os.chdir ensures that the entire script is run within /linux.
--- tools/testing/kunit/kunit.py | 12 ++++++++++++ 1 file changed, 12 insertions(+)
tools/testing/kunit/kunit.py +12 -0
@@ -24,6 +24,8 @@ KunitResult = namedtuple('KunitResult', ['status','result']) KunitRequest = namedtuple('KunitRequest', ['raw_output','timeout', 'jobs', 'build_dir', 'defconfig']) +KernelDirectoryPath = sys.argv[0].split('tools/testing/kunit/')[0] + class KunitStatus(Enum): SUCCESS = auto() CONFIG_FAILURE = auto()
@@ -35,6 +37,13 @@ def create_default_kunitconfig(): shutil.copyfile('arch/um/configs/kunit_defconfig', kunit_kernel.kunitconfig_path) +def get_kernel_root_path(): + parts = sys.argv[0] if not __file__ else __file__ + parts = os.path.realpath(parts).split('tools/testing/kunit') + if len(parts) != 2: + sys.exit(1) + return parts[0] + def run_tests(linux: kunit_kernel.LinuxSourceTree, request: KunitRequest) -> KunitResult: config_start = time.time()
@@ -114,6 +123,9 @@ def main(argv, linux=None): cli_args = parser.parse_args(argv) if cli_args.subcommand == 'run': + if get_kernel_root_path(): + os.chdir(get_kernel_root_path()) + if cli_args.build_dir: if not os.path.exists(cli_args.build_dir): os.mkdir(cli_args.build_dir)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 22/67 selftests/rseq: Fix out-of-tree compilation
In reply to Sasha LevinFrom: Michael Ellerman <[email protected]>
[ Upstream commit ef89d0545132d685f73da6f58b7e7fe002536f91 ]
Currently if you build with O=... the rseq tests don't build:
$ make O=$PWD/output -C tools/testing/selftests/ TARGETS=rseq make: Entering directory '/linux/tools/testing/selftests' ... make[1]: Entering directory '/linux/tools/testing/selftests/rseq' gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./ -shared -fPIC rseq.c -lpthread -o /linux/output/rseq/librseq.so gcc -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./ basic_test.c -lpthread -lrseq -o /linux/output/rseq/basic_test /usr/bin/ld: cannot find -lrseq collect2: error: ld returned 1 exit status
This is because the library search path points to the source directory, not the output.
We can fix it by changing the library search path to $(OUTPUT).
--- tools/testing/selftests/rseq/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/rseq/Makefile +1 -1
@@ -4,7 +4,7 @@ ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),) CLANG_FLAGS += -no-integrated-as endif -CFLAGS += -O2 -Wall -g -I./ -I../../../../usr/include/ -L./ -Wl,-rpath=./ \ +CFLAGS += -O2 -Wall -g -I./ -I../../../../usr/include/ -L$(OUTPUT) -Wl,-rpath=./ \ $(CLANG_FLAGS) LDLIBS += -lpthread
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 23/67 tracing: Fix number printing bug in print_synth_event()
In reply to Sasha LevinFrom: Tom Zanussi <[email protected]>
[ Upstream commit 784bd0847eda032ed2f3522f87250655a18c0190 ]
Fix a varargs-related bug in print_synth_event() which resulted in strange output and oopses on 32-bit x86 systems. The problem is that trace_seq_printf() expects the varargs to match the format string, but print_synth_event() was always passing u64 values regardless. This results in unspecified behavior when unpacking with va_arg() in trace_seq_printf().
Add a function that takes the size into account when calling trace_seq_printf().
Before:
modprobe-1731 [003] .... 919.039758: gen_synth_test: next_pid_field=777(null)next_comm_field=hula hoops ts_ns=1000000 ts_ms=1000 cpu=3(null)my_string_field=thneed my_int_field=598(null)
After:
insmod-1136 [001] .... 36.634590: gen_synth_test: next_pid_field=777 next_comm_field=hula hoops ts_ns=1000000 ts_ms=1000 cpu=1 my_string_field=thneed my_int_field=598
--- kernel/trace/trace_events_hist.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-)
kernel/trace/trace_events_hist.c +29 -3
@@ -811,6 +811,29 @@ static const char *synth_field_fmt(char *type)return fmt; } +static void print_synth_event_num_val (struct trace_seq *s, +char *print_fmt,char *name, +int size,u64 val,char *space) +{ +switch (size) { +case 1 : +trace_seq_printf (s, print_fmt, name, (u8 )val, space); +break ; + +case 2 : +trace_seq_printf (s, print_fmt, name, (u16 )val, space); +break ; + +case 4 : +trace_seq_printf (s, print_fmt, name, (u32 )val, space); +break ; + +default : +trace_seq_printf (s, print_fmt, name, val, space); +break ; + } +} +static enum print_line_t print_synth_event (struct trace_iterator *iter,int flags,struct trace_event *event)
@@ -849,10 +872,13 @@ static enum print_line_t print_synth_event(struct trace_iterator *iter, }else {struct trace_print_flags __flags[] = { __def_gfpflag_names, {-1 ,NULL } }; +char *space = (i == se->n_fields -1 ?"" :" " ); -trace_seq_printf (s, print_fmt, se->fields[i]->name, - entry->fields[n_u64], - i == se->n_fields -1 ?"" :" " ); +print_synth_event_num_val (s, print_fmt, + se->fields[i]->name, + se->fields[i]->size, + entry->fields[n_u64], + space);if (strcmp (se->fields[i]->type,"gfp_t" ) ==0 ) {trace_seq_puts (s," (" );
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 24/67 nl80211: fix potential leak in AP start
In reply to Sasha LevinFrom: Johannes Berg <[email protected]>
[ Upstream commit 9951ebfcdf2b97dbb28a5d930458424341e61aa2 ]
If nl80211_parse_he_obss_pd() fails, we leak the previously allocated ACL memory. Free it in this case.
--- net/wireless/nl80211.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/wireless/nl80211.c +2 -2
@@ -4799,8 +4799,7 @@ static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info) err =nl80211_parse_he_obss_pd ( info->attrs[NL80211_ATTR_HE_OBSS_PD ], ¶ms.he_obss_pd); -if (err) -return err; + goto out; }nl80211_calculate_ap_params (¶ms);
@@ -4822,6 +4821,7 @@ static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info) }wdev_unlock (wdev); +out:kfree (params.acl);return err;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 25/67 cfg80211: check reg_rule for NULL in handle_channel_custom()
In reply to Sasha LevinFrom: Johannes Berg <[email protected]>
[ Upstream commit a7ee7d44b57c9ae174088e53a668852b7f4f452d ]
We may end up with a NULL reg_rule after the loop in handle_channel_custom() if the bandwidth didn't fit, check if this is the case and bail out if so.
--- net/wireless/reg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/wireless/reg.c +1 -1
@@ -2276,7 +2276,7 @@ static void handle_channel_custom(struct wiphy *wiphy,break ; } -if (IS_ERR (reg_rule)) { +if (IS_ERR_OR_NULL (reg_rule)) {pr_debug ("Disabling freq %d MHz as custom regd has no rule that fits it\n" , chan->center_freq);if (wiphy->regulatory_flags ®ULATORY_WIPHY_SELF_MANAGED ) {
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 26/67 mac80211: Remove a redundant mutex unlock
In reply to Sasha LevinFrom: Andrei Otcheretianski <[email protected]>
[ Upstream commit 0daa63ed4c6c4302790ce67b7a90c0997ceb7514 ]
The below-mentioned commit changed the code to unlock *inside* the function, but previously the unlock was *outside*. It failed to remove the outer unlock, however, leading to double unlock.
Fix this.
--- net/mac80211/mlme.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
net/mac80211/mlme.c +1 -5
@@ -2959,7 +2959,7 @@ static void ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata, (auth_transaction == 2 && ifmgd->auth_data->expected_transaction == 2)) {if (!ieee80211_mark_sta_auth (sdata, bssid)) - goto out_err; +return ;/* ignore frame -- wait for timeout */ } else if (ifmgd->auth_data->algorithm == WLAN_AUTH_SAE && auth_transaction == 2) {sdata_info (sdata,"SAE peer confirmed\n" );
@@ -2967,10 +2967,6 @@ static void ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata, }cfg80211_rx_mlme_mgmt (sdata->dev, (u8 *)mgmt, len); -return ; - out_err: -mutex_unlock (&sdata->local->sta_mtx); -/* ignore frame -- wait for timeout */ }#define case_WLAN (type) \
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 27/67 scsi: libfc: free response frame from GPN_ID
In reply to Sasha LevinFrom: Igor Druzhinin <[email protected]>
[ Upstream commit ff6993bb79b9f99bdac0b5378169052931b65432 ]
fc_disc_gpn_id_resp() should be the last function using it so free it here to avoid memory leak.
--- drivers/scsi/libfc/fc_disc.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/scsi/libfc/fc_disc.c +2 -0
@@ -628,6 +628,8 @@ static void fc_disc_gpn_id_resp(struct fc_seq *sp, struct fc_frame *fp, } out:kref_put (&rdata->kref, fc_rport_destroy); +if (!IS_ERR (fp)) +fc_frame_free (fp); }/**
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 28/67 netfilter: ipset: Fix "INFO: rcu detected stall in hash_xxx" reports
In reply to Sasha LevinFrom: Jozsef Kadlecsik <[email protected]>
[ Upstream commit f66ee0410b1c3481ee75e5db9b34547b4d582465 ]
In the case of huge hash:* types of sets, due to the single spinlock of a set the processing of the whole set under spinlock protection could take too long.
There were four places where the whole hash table of the set was processed from bucket to bucket under holding the spinlock:
- During resizing a set, the original set was locked to exclude kernel side add/del element operations (userspace add/del is excluded by the nfnetlink mutex). The original set is actually just read during the resize, so the spinlocking is replaced with rcu locking of regions. However, thus there can be parallel kernel side add/del of entries. In order not to loose those operations a backlog is added and replayed after the successful resize.
- Garbage collection of timed out entries was also protected by the spinlock. In order not to lock too long, region locking is introduced and a single region is processed in one gc go. Also, the simple timer based gc running is replaced with a workqueue based solution. The internal book-keeping (number of elements, size of extensions) is moved to region level due to the region locking.
- Adding elements: when the max number of the elements is reached, the gc was called to evict the timed out entries. The new approach is that the gc is called just for the matching region, assuming that if the region (proportionally) seems to be full, then the whole set does. We could scan the other regions to check every entry under rcu locking, but for huge sets it'd mean a slowdown at adding elements.
- Listing the set header data: when the set was defined with timeout support, the garbage collector was called to clean up timed out entries to get the correct element numbers and set size values. Now the set is scanned to check non-timed out entries, without actually calling the gc for the whole set.
Thanks to Florian Westphal for helping me to solve the SOFTIRQ-safe -> SOFTIRQ-unsafe lock order issues during working on the patch.
--- include/linux/netfilter/ipset/ip_set.h | 11 +- net/netfilter/ipset/ip_set_core.c | 34 +- net/netfilter/ipset/ip_set_hash_gen.h | 633 +++++++++++++++++-------- 3 files changed, 472 insertions(+), 206 deletions(-)
include/linux/netfilter/ipset/ip_set.h +10 -1
@@ -121,6 +121,7 @@ struct ip_set_ext {u32 timeout;u8 packets_op;u8 bytes_op; +bool target; };struct ip_set ;
@@ -187,6 +188,14 @@ struct ip_set_type_variant {/* Return true if "b" set is the same as "a" * according to the create set parameters */ bool (*same_set)(const struct ip_set *a,const struct ip_set *b); +/* Region-locking is used */ +bool region_lock; +}; + +struct ip_set_region { +spinlock_t lock;/* Region lock */ +size_t ext_size;/* Size of the dynamic extensions */ +u32 elements;/* Number of elements vs timeout */ };/* The core set type structure */
@@ -501,7 +510,7 @@ ip_set_init_skbinfo(struct ip_set_skbinfo *skbinfo, }#define IP_SET_INIT_KEXT (skb, opt, set) \ - { .bytes = (skb)->len, .packets = 1, \ + { .bytes = (skb)->len, .packets = 1, .target = true,\ .timeout = ip_set_adt_opt_timeout(opt, set) }#define IP_SET_INIT_UEXT (set) \
net/netfilter/ipset/ip_set_core.c +24 -10
@@ -723,6 +723,20 @@ ip_set_rcu_get(struct net *net, ip_set_id_t index)return set; } +static inline void +ip_set_lock (struct ip_set *set) +{ +if (!set->variant->region_lock) +spin_lock_bh (&set->lock); +} + +static inline void +ip_set_unlock (struct ip_set *set) +{ +if (!set->variant->region_lock) +spin_unlock_bh (&set->lock); +} +int ip_set_test (ip_set_id_t index,const struct sk_buff *skb,const struct xt_action_param *par,struct ip_set_adt_opt *opt)
@@ -744,9 +758,9 @@ ip_set_test(ip_set_id_t index, const struct sk_buff *skb,if (ret == -EAGAIN ) {/* Type requests element to be completed */ pr_debug ("element must be completed, ADD is triggered\n" ); -spin_lock_bh (&set->lock); +ip_set_lock (set); set->variant->kadt (set, skb, par,IPSET_ADD , opt); -spin_unlock_bh (&set->lock); +ip_set_unlock (set); ret =1 ; }else {/* --return-nomatch: invert matched element */
@@ -775,9 +789,9 @@ ip_set_add(ip_set_id_t index, const struct sk_buff *skb, !(opt->family == set->family || set->family == NFPROTO_UNSPEC)) return -IPSET_ERR_TYPE_MISMATCH; -spin_lock_bh (&set->lock); +ip_set_lock (set); ret = set->variant->kadt (set, skb, par,IPSET_ADD , opt); -spin_unlock_bh (&set->lock); +ip_set_unlock (set);return ret; }
@@ -797,9 +811,9 @@ ip_set_del(ip_set_id_t index, const struct sk_buff *skb, !(opt->family == set->family || set->family == NFPROTO_UNSPEC)) return -IPSET_ERR_TYPE_MISMATCH; -spin_lock_bh (&set->lock); +ip_set_lock (set); ret = set->variant->kadt (set, skb, par,IPSET_DEL , opt); -spin_unlock_bh (&set->lock); +ip_set_unlock (set);return ret; }
@@ -1264,9 +1278,9 @@ ip_set_flush_set(struct ip_set *set) {pr_debug ("set: %s\n" , set->name); -spin_lock_bh (&set->lock); +ip_set_lock (set); set->variant->flush (set); -spin_unlock_bh (&set->lock); +ip_set_unlock (set); } static int ip_set_flush(struct net *net, struct sock *ctnl, struct sk_buff *skb,
@@ -1713,9 +1727,9 @@ call_ad(struct sock *ctnl, struct sk_buff *skb, struct ip_set *set,bool eexist = flags &IPSET_FLAG_EXIST , retried = false; do { - spin_lock_bh(&set->lock); + ip_set_lock(set); ret = set->variant->uadt(set, tb, adt, &lineno, flags, retried); - spin_unlock_bh(&set->lock); + ip_set_unlock(set); retried = true; } while (ret == -EAGAIN && set->variant->resize &&
net/netfilter/ipset/ip_set_hash_gen.h +438 -195
1,092 lines not on this page · raw message
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 29/67 netfilter: ipset: Fix forceadd evaluation path
In reply to Sasha LevinFrom: Jozsef Kadlecsik <[email protected]>
[ Upstream commit 8af1c6fbd9239877998c7f5a591cb2c88d41fb66 ]
When the forceadd option is enabled, the hash:* types should find and replace the first entry in the bucket with the new one if there are no reuseable (deleted or timed out) entries. However, the position index was just not set to zero and remained the invalid -1 if there were no reuseable entries.
--- net/netfilter/ipset/ip_set_hash_gen.h | 2 ++ 1 file changed, 2 insertions(+)
net/netfilter/ipset/ip_set_hash_gen.h +2 -0
@@ -931,6 +931,8 @@ mtype_add(struct ip_set *set, void *value, const struct ip_set_ext *ext, } }if (reuse || forceadd) { +if (j ==-1 ) + j =0 ; data =ahash_data (n, j, set->dsize);if (!deleted) {#ifdef IP_SET_HASH_WITH_NETS
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 30/67 vhost: Check docket sk_family instead of call getname
In reply to Sasha LevinFrom: Eugenio Pérez <[email protected]>
[ Upstream commit 42d84c8490f9f0931786f1623191fcab397c3d64 ]
Doing so, we save one call to get data we already have in the struct.
Also, since there is no guarantee that getname use sockaddr_ll parameter beyond its size, we add a little bit of security here. It should do not do beyond MAX_ADDR_LEN, but syzbot found that ax25_getname writes more (72 bytes, the size of full_sockaddr_ax25, versus 20 + 32 bytes of sockaddr_ll + MAX_ADDR_LEN in syzbot repro).
--- drivers/vhost/net.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/vhost/net.c +1 -9
@@ -1414,10 +1414,6 @@ static int vhost_net_release(struct inode *inode, struct file *f)static struct socket *get_raw_socket (int fd) { -struct { -struct sockaddr_ll sa; -char buf[MAX_ADDR_LEN ]; - } uaddr;int r;struct socket *sock =sockfd_lookup (fd, &r);
@@ -1430,11 +1426,7 @@ static struct socket *get_raw_socket(int fd) goto err; } - r = sock->ops->getname (sock, (struct sockaddr *)&uaddr.sa,0 ); -if (r <0 ) - goto err; - -if (uaddr.sa.sll_family !=AF_PACKET ) { +if (sock->sk->sk_family !=AF_PACKET ) { r = -EPFNOSUPPORT ; goto err; }
Signature · 6 lines
2.20.1 _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Sasha Levin
maintainerPATCH 31/67 net: usb: qmi_wwan: restore mtu min/max values after raw_ip switch
In reply to Sasha LevinFrom: Daniele Palmas <[email protected]>
[ Upstream commit eae7172f8141eb98e64e6e81acc9e9d5b2add127 ]
usbnet creates network interfaces with min_mtu = 0 and max_mtu = ETH_MAX_MTU.
These values are not modified by qmi_wwan when the network interface is created initially, allowing, for example, to set mtu greater than 1500.
When a raw_ip switch is done (raw_ip set to 'Y', then set to 'N') the mtu values for the network interface are set through ether_setup, with min_mtu = ETH_MIN_MTU and max_mtu = ETH_DATA_LEN, not allowing anymore to set mtu greater than 1500 (error: mtu greater than device maximum).
The patch restores the original min/max mtu values set by usbnet after a raw_ip switch.
--- drivers/net/usb/qmi_wwan.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/usb/qmi_wwan.c +3 -0
@@ -338,6 +338,9 @@ static void qmi_wwan_netdev_setup(struct net_device *net)netdev_dbg (net,"mode: raw IP\n" ); }else if (!net->header_ops) {/* don't bother if already set */ ether_setup (net); +/* Restoring min/max mtu values set originally by usbnet */ + net->min_mtu =0 ; + net->max_mtu =ETH_MAX_MTU ;clear_bit (EVENT_NO_IP_ALIGN , &dev->flags);netdev_dbg (net,"mode: Ethernet\n" ); }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 32/67 hv_netvsc: Fix unwanted wakeup in netvsc_attach()
In reply to Sasha LevinFrom: Haiyang Zhang <[email protected]>
[ Upstream commit f6f13c125e05603f68f5bf31f045b95e6d493598 ]
When netvsc_attach() is called by operations like changing MTU, etc., an extra wakeup may happen while netvsc_attach() calling rndis_filter_device_add() which sends rndis messages when queue is stopped in netvsc_detach(). The completion message will wake up queue 0.
We can reproduce the issue by changing MTU etc., then the wake_queue counter from "ethtool -S" will increase beyond stop_queue counter:
stop_queue: 0
wake_queue: 1
The issue causes queue wake up, and counter increment, no other ill effects in current code. So we didn't see any network problem for now.
To fix this, initialize tx_disable to true, and set it to false when the NIC is ready to be attached or registered.
--- drivers/net/hyperv/netvsc.c | 2 +- drivers/net/hyperv/netvsc_drv.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/net/hyperv/netvsc.c +1 -1
@@ -99,7 +99,7 @@ static struct netvsc_device *alloc_net_device(void)init_waitqueue_head (&net_device->wait_drain); net_device->destroy = false; - net_device->tx_disable = false; + net_device->tx_disable = true; net_device->max_pkt =RNDIS_MAX_PKT_DEFAULT ; net_device->pkt_align =RNDIS_PKT_ALIGN_DEFAULT ;
drivers/net/hyperv/netvsc_drv.c +3 -0
@@ -977,6 +977,7 @@ static int netvsc_attach(struct net_device *ndev, }/* In any case device is now ready */ + nvdev->tx_disable = false;netif_device_attach (ndev);/* Note: enable and attach happen when sub-channels setup */
@@ -2354,6 +2355,8 @@ static int netvsc_probe(struct hv_device *dev,else net->max_mtu =ETH_DATA_LEN ; + nvdev->tx_disable = false; + ret =register_netdevice (net);if (ret !=0 ) {pr_err ("Unable to register netdev.\n" );
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 33/67 net: ks8851-ml: Fix IRQ handling and locking
In reply to Sasha LevinFrom: Marek Vasut <[email protected]>
[ Upstream commit 44343418d0f2f623cb9da6f5000df793131cbe3b ]
The KS8851 requires that packet RX and TX are mutually exclusive. Currently, the driver hopes to achieve this by disabling interrupt from the card by writing the card registers and by disabling the interrupt on the interrupt controller. This however is racy on SMP.
Replace this approach by expanding the spinlock used around the ks_start_xmit() TX path to ks_irq() RX path to assure true mutual exclusion and remove the interrupt enabling/disabling, which is now not needed anymore. Furthermore, disable interrupts also in ks_net_stop(), which was missing before.
Note that a massive improvement here would be to re-use the KS8851 driver approach, which is to move the TX path into a worker thread, interrupt handling to threaded interrupt, and synchronize everything with mutexes, but that would be a much bigger rework, for a separate patch.
--- drivers/net/ethernet/micrel/ks8851_mll.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/net/ethernet/micrel/ks8851_mll.c +8 -6
@@ -548,14 +548,17 @@ static irqreturn_t ks_irq(int irq, void *pw) {struct net_device *netdev = pw;struct ks_net *ks =netdev_priv (netdev); +unsigned long flags;u16 status; +spin_lock_irqsave (&ks->statelock, flags);/*this should be the first in IRQ handler */ ks_save_cmd_reg (ks); status =ks_rdreg16 (ks,KS_ISR );if (unlikely (!status)) {ks_restore_cmd_reg (ks); +spin_unlock_irqrestore (&ks->statelock, flags);return IRQ_NONE ; }
@@ -581,6 +584,7 @@ static irqreturn_t ks_irq(int irq, void *pw) ks->netdev->stats.rx_over_errors++;/* this should be the last in IRQ handler*/ ks_restore_cmd_reg (ks); +spin_unlock_irqrestore (&ks->statelock, flags);return IRQ_HANDLED ; }
@@ -650,6 +654,7 @@ static int ks_net_stop(struct net_device *netdev)/* shutdown RX/TX QMU */ ks_disable_qmu (ks); +ks_disable_int (ks);/* set powermode to soft power down to save power */ ks_set_powermode (ks,PMECR_PM_SOFTDOWN );
@@ -706,10 +711,9 @@ static netdev_tx_t ks_start_xmit(struct sk_buff *skb, struct net_device *netdev) {netdev_tx_t retv =NETDEV_TX_OK ;struct ks_net *ks =netdev_priv (netdev); +unsigned long flags; -disable_irq (netdev->irq); -ks_disable_int (ks); -spin_lock (&ks->statelock); +spin_lock_irqsave (&ks->statelock, flags);/* Extra space are required: * 4 byte for alignment, 4 for status/length, 4 for CRC
@@ -723,9 +727,7 @@ static netdev_tx_t ks_start_xmit(struct sk_buff *skb, struct net_device *netdev)dev_kfree_skb (skb); }else retv =NETDEV_TX_BUSY ; -spin_unlock (&ks->statelock); -ks_enable_int (ks); -enable_irq (netdev->irq); +spin_unlock_irqrestore (&ks->statelock, flags);return retv; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 34/67 mac80211: rx: avoid RCU list traversal under mutex
In reply to Sasha LevinFrom: Madhuparna Bhowmik <[email protected]>
[ Upstream commit 253216ffb2a002a682c6f68bd3adff5b98b71de8 ]
local->sta_mtx is held in __ieee80211_check_fast_rx_iface(). No need to use list_for_each_entry_rcu() as it also requires a cond argument to avoid false lockdep warnings when not used in RCU read-side section (with CONFIG_PROVE_RCU_LIST). Therefore use list_for_each_entry();
--- net/mac80211/rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/rx.c +1 -1
@@ -4114,7 +4114,7 @@ void __ieee80211_check_fast_rx_iface(struct ieee80211_sub_if_data *sdata)lockdep_assert_held (&local->sta_mtx); -list_for_each_entry_rcu (sta, &local->sta_list, list) { +list_for_each_entry (sta, &local->sta_list, list) {if (sdata != sta->sdata && (!sta->sdata->bss || sta->sdata->bss != sdata->bss))continue ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 35/67 net: ll_temac: Fix race condition causing TX hang
In reply to Sasha LevinFrom: Esben Haabendal <[email protected]>
[ Upstream commit 84823ff80f7403752b59e00bb198724100dc611c ]
It is possible that the interrupt handler fires and frees up space in the TX ring in between checking for sufficient TX ring space and stopping the TX queue in temac_start_xmit. If this happens, the queue wake from the interrupt handler will occur before the queue is stopped, causing a lost wakeup and the adapter's transmit hanging.
To avoid this, after stopping the queue, check again whether there is sufficient space in the TX ring. If so, wake up the queue again.
This is a port of the similar fix in axienet driver,
commit 7de44285c1f6 ("net: axienet: Fix race condition causing TX hang").
--- drivers/net/ethernet/xilinx/ll_temac_main.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/net/ethernet/xilinx/ll_temac_main.c +16 -3
@@ -788,6 +788,9 @@ static void temac_start_xmit_done(struct net_device *ndev) stat =be32_to_cpu (cur_p->app0); } +/* Matches barrier in temac_start_xmit */ +smp_mb (); +netif_wake_queue (ndev); }
@@ -830,9 +833,19 @@ temac_start_xmit(struct sk_buff *skb, struct net_device *ndev) cur_p = &lp->tx_bd_v[lp->tx_bd_tail];if (temac_check_tx_bd_space (lp, num_frag +1 )) { -if (!netif_queue_stopped (ndev)) -netif_stop_queue (ndev); -return NETDEV_TX_BUSY ; +if (netif_queue_stopped (ndev)) +return NETDEV_TX_BUSY ; + +netif_stop_queue (ndev); + +/* Matches barrier in temac_start_xmit_done */ +smp_mb (); + +/* Space might have just been freed - check again */ +if (temac_check_tx_bd_space (lp, num_frag)) +return NETDEV_TX_BUSY ; + +netif_wake_queue (ndev); } cur_p->app0 =0 ;
Signature · 7 lines
2.20.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 36/67 net: ll_temac: Add more error handling of dma_map_single() calls
In reply to Sasha LevinFrom: Esben Haabendal <[email protected]>
[ Upstream commit d07c849cd2b97d6809430dfb7e738ad31088037a ]
This adds error handling to the remaining dma_map_single() calls, so that behavior is well defined if/when we run out of DMA memory.
--- drivers/net/ethernet/xilinx/ll_temac_main.c | 26 +++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-)
drivers/net/ethernet/xilinx/ll_temac_main.c +24 -2
@@ -367,6 +367,8 @@ static int temac_dma_bd_init(struct net_device *ndev) skb_dma_addr =dma_map_single (ndev->dev.parent, skb->data,XTE_MAX_JUMBO_FRAME_SIZE ,DMA_FROM_DEVICE ); +if (dma_mapping_error (ndev->dev.parent, skb_dma_addr)) + goto out; lp->rx_bd_v[i].phys =cpu_to_be32 (skb_dma_addr); lp->rx_bd_v[i].len =cpu_to_be32 (XTE_MAX_JUMBO_FRAME_SIZE ); lp->rx_bd_v[i].app0 =cpu_to_be32 (STS_CTRL_APP0_IRQONEND );
@@ -863,12 +865,13 @@ temac_start_xmit(struct sk_buff *skb, struct net_device *ndev) skb_dma_addr =dma_map_single (ndev->dev.parent, skb->data,skb_headlen (skb),DMA_TO_DEVICE ); cur_p->len =cpu_to_be32 (skb_headlen (skb)); +if (WARN_ON_ONCE (dma_mapping_error (ndev->dev.parent, skb_dma_addr))) +return NETDEV_TX_BUSY ; cur_p->phys =cpu_to_be32 (skb_dma_addr);ptr_to_txbd ((void *)skb, cur_p);for (ii =0 ; ii < num_frag; ii++) { - lp->tx_bd_tail++; -if (lp->tx_bd_tail >=TX_BD_NUM ) +if (++lp->tx_bd_tail >=TX_BD_NUM ) lp->tx_bd_tail =0 ; cur_p = &lp->tx_bd_v[lp->tx_bd_tail];
@@ -876,6 +879,25 @@ temac_start_xmit(struct sk_buff *skb, struct net_device *ndev)skb_frag_address (frag),skb_frag_size (frag), DMA_TO_DEVICE); +if (dma_mapping_error (ndev->dev.parent, skb_dma_addr)) { +if (--lp->tx_bd_tail <0 ) + lp->tx_bd_tail =TX_BD_NUM -1 ; + cur_p = &lp->tx_bd_v[lp->tx_bd_tail]; +while (--ii >=0 ) { + --frag; +dma_unmap_single (ndev->dev.parent, +be32_to_cpu (cur_p->phys), +skb_frag_size (frag), +DMA_TO_DEVICE ); +if (--lp->tx_bd_tail <0 ) + lp->tx_bd_tail =TX_BD_NUM -1 ; + cur_p = &lp->tx_bd_v[lp->tx_bd_tail]; + } +dma_unmap_single (ndev->dev.parent, +be32_to_cpu (cur_p->phys), +skb_headlen (skb),DMA_TO_DEVICE ); +return NETDEV_TX_BUSY ; + } cur_p->phys =cpu_to_be32 (skb_dma_addr); cur_p->len =cpu_to_be32 (skb_frag_size (frag)); cur_p->app0 =0 ;
Signature · 7 lines
2.20.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 37/67 net: ll_temac: Fix RX buffer descriptor handling on GFP_ATOMIC pressure
In reply to Sasha LevinFrom: Esben Haabendal <[email protected]>
[ Upstream commit 770d9c67974c4c71af4beb786dc43162ad2a15ba ]
Failures caused by GFP_ATOMIC memory pressure have been observed, and due to the missing error handling, results in kernel crash such as
[1876998.350133] kernel BUG at mm/slub.c:3952! [1876998.350141] invalid opcode: 0000 [#1] PREEMPT SMP PTI [1876998.350147] CPU: 2 PID: 0 Comm: swapper/2 Not tainted 5.3.0-scnxt #1 [1876998.350150] Hardware name: N/A N/A/COMe-bIP2, BIOS CCR2R920 03/01/2017 [1876998.350160] RIP: 0010:kfree+0x1ca/0x220 [1876998.350164] Code: 85 db 74 49 48 8b 95 68 01 00 00 48 31 c2 48 89 10 e9 d7 fe ff ff 49 8b 04 24 a9 00 00 01 00 75 0b 49 8b 44 24 08 a8 01 75 02 <0f> 0b 49 8b 04 24 31 f6 a9 00 00 01 00 74 06 41 0f b6 74 24 5b [1876998.350172] RSP: 0018:ffffc900000f0df0 EFLAGS: 00010246 [1876998.350177] RAX: ffffea00027f0708 RBX: ffff888008d78000 RCX: 0000000000391372 [1876998.350181] RDX: 0000000000000000 RSI: ffffe8ffffd01400 RDI: ffff888008d78000 [1876998.350185] RBP: ffff8881185a5d00 R08: ffffc90000087dd8 R09: 000000000000280a [1876998.350189] R10: 0000000000000002 R11: 0000000000000000 R12: ffffea0000235e00 [1876998.350193] R13: ffff8881185438a0 R14: 0000000000000000 R15: ffff888118543870 [1876998.350198] FS: 0000000000000000(0000) GS:ffff88811f300000(0000) knlGS:0000000000000000 [1876998.350203] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 s#1 Part1 [1876998.350206] CR2: 00007f8dac7b09f0 CR3: 000000011e20a006 CR4: 00000000001606e0 [1876998.350210] Call Trace: [1876998.350215] <IRQ> [1876998.350224] ? __netif_receive_skb_core+0x70a/0x920 [1876998.350229] kfree_skb+0x32/0xb0 [1876998.350234] __netif_receive_skb_core+0x70a/0x920 [1876998.350240] __netif_receive_skb_one_core+0x36/0x80 [1876998.350245] process_backlog+0x8b/0x150 [1876998.350250] net_rx_action+0xf7/0x340 [1876998.350255] __do_softirq+0x10f/0x353 [1876998.350262] irq_exit+0xb2/0xc0 [1876998.350265] do_IRQ+0x77/0xd0 [1876998.350271] common_interrupt+0xf/0xf [1876998.350274] </IRQ>
In order to handle such failures more graceful, this change splits the receive loop into one for consuming the received buffers, and one for allocating new buffers.
When GFP_ATOMIC allocations fail, the receive will continue with the buffers that is still there, and with the expectation that the allocations will succeed in a later call to receive.
--- drivers/net/ethernet/xilinx/ll_temac.h | 1 + drivers/net/ethernet/xilinx/ll_temac_main.c | 112 ++++++++++++++------ 2 files changed, 82 insertions(+), 31 deletions(-)
drivers/net/ethernet/xilinx/ll_temac.h +1 -0
@@ -375,6 +375,7 @@ struct temac_local {int tx_bd_next;int tx_bd_tail;int rx_bd_ci; +int rx_bd_tail;/* DMA channel control setup */ u32 tx_chnl_ctrl;
drivers/net/ethernet/xilinx/ll_temac_main.c +81 -31
159 lines not on this page · raw message
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 38/67 net: ll_temac: Handle DMA halt condition caused by buffer underrun
In reply to Sasha LevinFrom: Esben Haabendal <[email protected]>
[ Upstream commit 1d63b8d66d146deaaedbe16c80de105f685ea012 ]
The SDMA engine used by TEMAC halts operation when it has finished processing of the last buffer descriptor in the buffer ring. Unfortunately, no interrupt event is generated when this happens, so we need to setup another mechanism to make sure DMA operation is restarted when enough buffers have been added to the ring.
--- drivers/net/ethernet/xilinx/ll_temac.h | 3 ++ drivers/net/ethernet/xilinx/ll_temac_main.c | 58 +++++++++++++++++++-- 2 files changed, 56 insertions(+), 5 deletions(-)
drivers/net/ethernet/xilinx/ll_temac.h +3 -0
@@ -380,6 +380,9 @@ struct temac_local {/* DMA channel control setup */ u32 tx_chnl_ctrl;u32 rx_chnl_ctrl; +u8 coalesce_count_rx; + +struct delayed_work restart_work; };/* Wrappers for temac_ior()/temac_iow() function pointers above */
drivers/net/ethernet/xilinx/ll_temac_main.c +53 -5
121 lines not on this page · raw message
Signature · 7 lines
2.20.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Sasha Levin
maintainerPATCH 39/67 blk-mq: insert passthrough request into hctx->dispatch directly
In reply to Sasha LevinFrom: Ming Lei <[email protected]>
[ Upstream commit 01e99aeca3979600302913cef3f89076786f32c8 ]
For some reason, device may be in one situation which can't handle FS request, so STS_RESOURCE is always returned and the FS request will be added to hctx->dispatch. However passthrough request may be required at that time for fixing the problem. If passthrough request is added to scheduler queue, there isn't any chance for blk-mq to dispatch it given we prioritize requests in hctx->dispatch. Then the FS IO request may never be completed, and IO hang is caused.
So passthrough request has to be added to hctx->dispatch directly for fixing the IO hang.
Fix this issue by inserting passthrough request into hctx->dispatch directly together withing adding FS request to the tail of hctx->dispatch in blk_mq_dispatch_rq_list(). Actually we add FS request to tail of hctx->dispatch at default, see blk_mq_request_bypass_insert().
Then it becomes consistent with original legacy IO request path, in which passthrough request is always added to q->queue_head.
--- block/blk-flush.c | 2 +- block/blk-mq-sched.c | 22 +++++++++++++++------- block/blk-mq.c | 18 +++++++++++------- block/blk-mq.h | 3 ++- 4 files changed, 29 insertions(+), 16 deletions(-)
block/blk-flush.c +1 -1
@@ -412,7 +412,7 @@ void blk_insert_flush(struct request *rq)*/ if ((policy &REQ_FSEQ_DATA ) && !(policy & (REQ_FSEQ_PREFLUSH |REQ_FSEQ_POSTFLUSH ))) { -blk_mq_request_bypass_insert (rq, false); +blk_mq_request_bypass_insert (rq, false, false);return ; }
block/blk-mq-sched.c +15 -7
@@ -361,13 +361,19 @@ static bool blk_mq_sched_bypass_insert(struct blk_mq_hw_ctx *hctx, bool has_sched, struct request *rq) { -/* dispatch flush rq directly */ -if (rq->rq_flags &RQF_FLUSH_SEQ ) { -spin_lock (&hctx->lock); -list_add (&rq->queuelist, &hctx->dispatch); -spin_unlock (&hctx->lock); +/* +* dispatch flush and passthrough rq directly +* +* passthrough request has to be added to hctx->dispatch directly. +* For some reason, device may be in one situation which can't +* handle FS request, so STS_RESOURCE is always returned and the +* FS request will be added to hctx->dispatch. However passthrough +* request may be required at that time for fixing the problem. If +* passthrough request is added to scheduler queue, there isn't any +* chance to dispatch it given we prioritize requests in hctx->dispatch. +*/ +if ((rq->rq_flags &RQF_FLUSH_SEQ ) ||blk_rq_is_passthrough (rq))return true; - }if (has_sched) rq->rq_flags |=RQF_SORTED ;
@@ -391,8 +397,10 @@ void blk_mq_sched_insert_request(struct request *rq, bool at_head,WARN_ON (e && (rq->tag !=-1 )); -if (blk_mq_sched_bypass_insert (hctx, !!e, rq)) +if (blk_mq_sched_bypass_insert (hctx, !!e, rq)) { +blk_mq_request_bypass_insert (rq, at_head, false); goto run; + }if (e && e->type->ops.insert_requests) {LIST_HEAD (list);
block/blk-mq.c +11 -7
@@ -727,7 +727,7 @@ static void blk_mq_requeue_work(struct work_struct *work)* merge. */ if (rq->rq_flags &RQF_DONTPREP ) -blk_mq_request_bypass_insert (rq, false); +blk_mq_request_bypass_insert (rq, false, false);else blk_mq_sched_insert_request (rq, true, false, false); }
@@ -1278,7 +1278,7 @@ bool blk_mq_dispatch_rq_list(struct request_queue *q, struct list_head *list, q->mq_ops->commit_rqs (hctx);spin_lock (&hctx->lock); -list_splice_init (list, &hctx->dispatch); +list_splice_tail_init (list, &hctx->dispatch);spin_unlock (&hctx->lock);/*
@@ -1629,12 +1629,16 @@ void __blk_mq_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq,* Should only be used carefully, when the caller knows we want to * bypass a potential IO scheduler on the target device. */ -void blk_mq_request_bypass_insert (struct request *rq,bool run_queue) +void blk_mq_request_bypass_insert (struct request *rq,bool at_head, +bool run_queue) {struct blk_mq_hw_ctx *hctx = rq->mq_hctx;spin_lock (&hctx->lock); -list_add_tail (&rq->queuelist, &hctx->dispatch); +if (at_head) +list_add (&rq->queuelist, &hctx->dispatch); +else +list_add_tail (&rq->queuelist, &hctx->dispatch);spin_unlock (&hctx->lock);if (run_queue)
@@ -1824,7 +1828,7 @@ static blk_status_t __blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx,if (bypass_insert)return BLK_STS_RESOURCE ; -blk_mq_request_bypass_insert (rq, run_queue); +blk_mq_request_bypass_insert (rq, false, run_queue);return BLK_STS_OK ; }
@@ -1840,7 +1844,7 @@ static void blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx, ret =__blk_mq_try_issue_directly (hctx, rq, cookie, false, true);if (ret ==BLK_STS_RESOURCE || ret ==BLK_STS_DEV_RESOURCE ) -blk_mq_request_bypass_insert (rq, true); +blk_mq_request_bypass_insert (rq, false, true);else if (ret !=BLK_STS_OK )blk_mq_end_request (rq, ret);
@@ -1874,7 +1878,7 @@ void blk_mq_try_issue_list_directly(struct blk_mq_hw_ctx *hctx,if (ret !=BLK_STS_OK ) {if (ret ==BLK_STS_RESOURCE || ret ==BLK_STS_DEV_RESOURCE ) { -blk_mq_request_bypass_insert (rq, +blk_mq_request_bypass_insert (rq, false,list_empty (list));break ; }
block/blk-mq.h +2 -1
@@ -66,7 +66,8 @@ int blk_mq_alloc_rqs(struct blk_mq_tag_set *set, struct blk_mq_tags *tags,*/ void __blk_mq_insert_request (struct blk_mq_hw_ctx *hctx,struct request *rq,bool at_head); -void blk_mq_request_bypass_insert (struct request *rq,bool run_queue); +void blk_mq_request_bypass_insert (struct request *rq,bool at_head, +bool run_queue);void blk_mq_insert_requests (struct blk_mq_hw_ctx *hctx,struct blk_mq_ctx *ctx,struct list_head *list);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 40/67 io_uring: fix poll_list race for SETUP_IOPOLL|SETUP_SQPOLL
In reply to Sasha LevinFrom: Xiaoguang Wang <[email protected]>
[ Upstream commit bdcd3eab2a9ae0ac93f27275b6895dd95e5bf360 ]
After making ext4 support iopoll method:
let ext4_file_operations's iopoll method be iomap_dio_iopoll(),
we found fio can easily hang in fio_ioring_getevents() with below fio job:
rm -f testfile; sync;
sudo fio -name=fiotest -filename=testfile -iodepth=128 -thread
-rw=write -ioengine=io_uring -hipri=1 -sqthread_poll=1 -direct=1 -bs=4k -size=10G -numjobs=8 -runtime=2000 -group_reporting with IORING_SETUP_SQPOLL and IORING_SETUP_IOPOLL enabled.
There are two issues that results in this hang, one reason is that when IORING_SETUP_SQPOLL and IORING_SETUP_IOPOLL are enabled, fio does not use io_uring_enter to get completed events, it relies on kernel io_sq_thread to poll for completed events.
Another reason is that there is a race: when io_submit_sqes() in io_sq_thread() submits a batch of sqes, variable 'inflight' will record the number of submitted reqs, then io_sq_thread will poll for reqs which have been added to poll_list. But note, if some previous reqs have been punted to io worker, these reqs will won't be in poll_list timely. io_sq_thread() will only poll for a part of previous submitted reqs, and then find poll_list is empty, reset variable 'inflight' to be zero. If app just waits these deferred reqs and does not wake up io_sq_thread again, then hang happens.
For app that entirely relies on io_sq_thread to poll completed requests, let io_iopoll_req_issued() wake up io_sq_thread properly when adding new element to poll_list, and when io_sq_thread prepares to sleep, check whether poll_list is empty again, if not empty, continue to poll.
--- fs/io_uring.c | 59 +++++++++++++++++++++++---------------------------- 1 file changed, 27 insertions(+), 32 deletions(-)
fs/io_uring.c +27 -32
@@ -1435,6 +1435,10 @@ static void io_iopoll_req_issued(struct io_kiocb *req)list_add (&req->list, &ctx->poll_list); else list_add_tail(&req->list, &ctx->poll_list); + +if ((ctx->flags &IORING_SETUP_SQPOLL ) && +wq_has_sleeper (&ctx->sqo_wait)) +wake_up (&ctx->sqo_wait); }static void io_file_put (struct io_submit_state *state)
@@ -3847,9 +3851,8 @@ static int io_sq_thread(void *data)const struct cred *old_cred;mm_segment_t old_fs;DEFINE_WAIT (wait); -unsigned inflight;unsigned long timeout; -int ret; +int ret =0 ;complete (&ctx->completions[1 ]);
@@ -3857,39 +3860,19 @@ static int io_sq_thread(void *data)set_fs (USER_DS ); old_cred =override_creds (ctx->creds); - ret = timeout = inflight =0 ; + timeout = jiffies + ctx->sq_thread_idle;while (!kthread_should_park ()) {unsigned int to_submit; -if (inflight) { +if (!list_empty (&ctx->poll_list)) {unsigned nr_events =0 ; -if (ctx->flags &IORING_SETUP_IOPOLL ) { -/* -* inflight is the count of the maximum possible -* entries we submitted, but it can be smaller -* if we dropped some of them. If we don't have -* poll entries available, then we know that we -* have nothing left to poll for. Reset the -* inflight count to zero in that case. -*/ -mutex_lock (&ctx->uring_lock); -if (!list_empty (&ctx->poll_list)) -io_iopoll_getevents (ctx, &nr_events,0 ); -else - inflight =0 ; -mutex_unlock (&ctx->uring_lock); - }else { -/* -* Normal IO, just pretend everything completed. -* We don't have to poll completions for that. -*/ - nr_events = inflight; - } - - inflight -= nr_events; -if (!inflight) +mutex_lock (&ctx->uring_lock); +if (!list_empty (&ctx->poll_list)) +io_iopoll_getevents (ctx, &nr_events,0 ); +else timeout = jiffies + ctx->sq_thread_idle; +mutex_unlock (&ctx->uring_lock); } to_submit =io_sqring_entries (ctx);
@@ -3918,7 +3901,7 @@ static int io_sq_thread(void *data)* more IO, we should wait for the application to * reap events and wake us up. */ -if (inflight || +if (!list_empty (&ctx->poll_list) || (!time_after (jiffies, timeout) && ret != -EBUSY && !percpu_ref_is_dying (&ctx->refs))) {cond_resched ();
@@ -3928,6 +3911,19 @@ static int io_sq_thread(void *data)prepare_to_wait (&ctx->sqo_wait, &wait,TASK_INTERRUPTIBLE ); +/* +* While doing polled IO, before going to sleep, we need +* to check if there are new reqs added to poll_list, it +* is because reqs may have been punted to io worker and +* will be added to poll_list later, hence check the +* poll_list again. +*/ +if ((ctx->flags &IORING_SETUP_IOPOLL ) && + !list_empty_careful (&ctx->poll_list)) { +finish_wait (&ctx->sqo_wait, &wait); +continue ; + } +/* Tell userspace we may need a wakeup call */ ctx->rings->sq_flags |=IORING_SQ_NEED_WAKEUP ;/* make sure to read SQ tail after writing flags */
@@ -3956,8 +3952,7 @@ static int io_sq_thread(void *data)mutex_lock (&ctx->uring_lock); ret =io_submit_sqes (ctx, to_submit,NULL ,-1 , &cur_mm, true);mutex_unlock (&ctx->uring_lock); -if (ret >0 ) - inflight += ret; + timeout = jiffies + ctx->sq_thread_idle; }set_fs (old_fs);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 41/67 drm/amdgpu: fix memory leak during TDR test(v2)
In reply to Sasha LevinFrom: Monk Liu <[email protected]>
[ Upstream commit 4829f89855f1d3a3d8014e74cceab51b421503db ]
fix system memory leak
v2:
fix coding style
--- drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +5 -1
@@ -948,8 +948,12 @@ int smu_v11_0_init_max_sustainable_clocks(struct smu_context *smu)struct smu_11_0_max_sustainable_clocks *max_sustainable_clocks;int ret =0 ; - max_sustainable_clocks =kzalloc (sizeof (struct smu_11_0_max_sustainable_clocks ), +if (!smu->smu_table.max_sustainable_clocks) + max_sustainable_clocks =kzalloc (sizeof (struct smu_11_0_max_sustainable_clocks ),GFP_KERNEL ); +else + max_sustainable_clocks = smu->smu_table.max_sustainable_clocks; + smu->smu_table.max_sustainable_clocks = (void *)max_sustainable_clocks; max_sustainable_clocks->uclock = smu->smu_table.boot_values.uclk /100 ;
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 42/67 io_uring: pick up link work on submit reference drop
In reply to Sasha LevinFrom: Jens Axboe <[email protected]>
[ Upstream commit 2a44f46781617c5040372b59da33553a02b1f46d ]
If work completes inline, then we should pick up a dependent link item in __io_queue_sqe() as well. If we don't do so, we're forced to go async with that item, which is suboptimal.
This also fixes an issue with io_put_req_find_next(), which always looks up the next work item. That should only be done if we're dropping the last reference to the request, to prevent multiple lookups of the same work item.
Outside of being a fix, this also enables a good cleanup series for 5.7, where we never have to pass 'nxt' around or into the work handlers.
--- fs/io_uring.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/io_uring.c +4 -4
@@ -1099,10 +1099,10 @@ static void io_free_req(struct io_kiocb *req) __attribute__((nonnull))static void io_put_req_find_next (struct io_kiocb *req,struct io_kiocb **nxtptr) { -io_req_find_next (req, nxtptr); - -if (refcount_dec_and_test (&req->refs)) +if (refcount_dec_and_test (&req->refs)) { +io_req_find_next (req, nxtptr);__io_free_req (req); + } }static void io_put_req (struct io_kiocb *req)
@@ -3559,7 +3559,7 @@ static void __io_queue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe) err:/* drop submission reference */ -io_put_req (req); +io_put_req_find_next (req, &nxt);if (linked_timeout) {if (!ret)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 43/67 kbuild: fix DT binding schema rule to detect command line changes
In reply to Sasha LevinFrom: Masahiro Yamada <[email protected]>
[ Upstream commit 7a04960560640ac5b0b89461f7757322b57d0c7a ]
This if_change_rule is not working properly; it cannot detect any command line change.
The reason is because cmd-check in scripts/Kbuild.include compares $(cmd_$@) and $(cmd_$1), but cmd_dtc_dt_yaml does not exist here.
For if_change_rule to work properly, the stem part of cmd_* and rule_* must match. Because this cmd_and_fixdep invokes cmd_dtc, this rule must be named rule_dtc.
--- scripts/Makefile.lib | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/Makefile.lib +2 -2
@@ -291,13 +291,13 @@ DT_TMP_SCHEMA := $(objtree)/$(DT_BINDING_DIR)/processed-schema.yaml quiet_cmd_dtb_check = CHECK $@ cmd_dtb_check = $(DT_CHECKER) -u $(srctree)/$(DT_BINDING_DIR) -p $(DT_TMP_SCHEMA) $@ ; -define rule_dtc_dt_yaml +define rule_dtc $(call cmd_and_fixdep,dtc,yaml) $(call cmd,dtb_check) endef $(obj)/%.dt.yaml: $(src)/%.dts $(DTC) $(DT_TMP_SCHEMA) FORCE - $(call if_changed_rule,dtc_dt_yaml) + $(call if_changed_rule,dtc) dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 44/67 kbuild: add dtbs_check to PHONY
In reply to Sasha LevinFrom: Masahiro Yamada <[email protected]>
[ Upstream commit 964a596db8db8c77c9903dd05655696696e6b3ad ]
The dtbs_check should be a phony target, but currently it is not specified so.
'make dtbs_check' works even if a file named 'dtbs_check' exists because it depends on another phony target, scripts_dtc, but we should not rely on it.
Add dtbs_check to PHONY.
--- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
@@ -1239,7 +1239,7 @@ ifneq ($(dtstree),) %.dtb: include/config/kernel.release scripts_dtc $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@ -PHONY += dtbs dtbs_install dt_binding_check +PHONY += dtbs dtbs_install dtbs_check dt_binding_check dtbs dtbs_check: include/config/kernel.release scripts_dtc $(Q)$(MAKE) $(build)=$(dtstree)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 45/67 kbuild: add dt_binding_check to PHONY in a correct place
In reply to Sasha LevinFrom: Masahiro Yamada <[email protected]>
[ Upstream commit c473a8d03ea8e03ca9d649b0b6d72fbcf6212c05 ]
The dt_binding_check is added to PHONY, but it is invisible when $(dtstree) is empty. So, it is not specified as phony for ARCH=x86 etc.
Add it to PHONY outside the ifneq ... endif block.
--- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Makefile +2 -1
@@ -1239,7 +1239,7 @@ ifneq ($(dtstree),) %.dtb: include/config/kernel.release scripts_dtc $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@ -PHONY += dtbs dtbs_install dtbs_check dt_binding_check +PHONY += dtbs dtbs_install dtbs_check dtbs dtbs_check: include/config/kernel.release scripts_dtc $(Q)$(MAKE) $(build)=$(dtstree)
@@ -1259,6 +1259,7 @@ PHONY += scripts_dtc scripts_dtc: scripts_basic $(Q)$(MAKE) $(build)=scripts/dtc +PHONY += dt_binding_check dt_binding_check: scripts_dtc $(Q)$(MAKE) $(build)=Documentation/devicetree/bindings
Signature · 1 line
2.20.1