HID: do not use down_interruptible() when unbinding devices
Subsystems (13)
Sasha Levin
maintainerPATCH 1/59 HID: do not use down_interruptible() when unbinding devices
From: Dmitry Torokhov <[email protected]>
[ Upstream commit f2145f8dc566c4f3b5a8deb58dcd12bed4e20194 ]
Action of unbinding driver from a device is not cancellable and should not fail, and driver core does not pay attention to the result of "remove" method, therefore using down_interruptible() in hid_device_remove() does not make sense.
--- drivers/hid/hid-core.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/hid/hid-core.c +3 -7
@@ -2306,12 +2306,8 @@ static int hid_device_remove(struct device *dev) {struct hid_device *hdev =to_hid_device (dev);struct hid_driver *hdrv; -int ret =0 ; -if (down_interruptible (&hdev->driver_input_lock)) { - ret = -EINTR ; - goto end; - } +down (&hdev->driver_input_lock); hdev->io_started = false; hdrv = hdev->driver;
@@ -2326,8 +2322,8 @@ static int hid_device_remove(struct device *dev)if (!hdev->io_started)up (&hdev->driver_input_lock); -end: -return ret; + +return 0 ; } static ssize_t modalias_show(struct device *dev, struct device_attribute *a,
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 2/59 EDAC/ti: Add missing MODULE_DEVICE_TABLE
From: Bixuan Cui <[email protected]>
[ Upstream commit 0a37f32ba5272b2d4ec8c8d0f6b212b81b578f7e ]
The module misses MODULE_DEVICE_TABLE() for of_device_id tables and thus never autoloads on ID matches.
Add the missing declaration.
--- drivers/edac/ti_edac.c | 1 + 1 file changed, 1 insertion(+)
drivers/edac/ti_edac.c +1 -0
@@ -197,6 +197,7 @@ static const struct of_device_id ti_edac_of_match[] = { { .compatible = "ti,emif-dra7xx", .data = (void *)EMIF_TYPE_DRA7 }, {}, }; +MODULE_DEVICE_TABLE (of, ti_edac_of_match);static int _emif_get_id (struct device_node *node) {
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 3/59 ACPI: PM: s2idle: Add missing LPS0 functions for AMD
In reply to Sasha LevinFrom: Alex Deucher <[email protected]>
[ Upstream commit f59a905b962c34642e862b5edec35c0eda72d70d ]
These are supposedly not required for AMD platforms, but at least some HP laptops seem to require it to properly turn off the keyboard backlight.
Based on a patch from Marcin Bachry <[email protected]>.
--- drivers/acpi/x86/s2idle.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/acpi/x86/s2idle.c +4 -0
@@ -42,6 +42,8 @@ static const struct acpi_device_id lps0_device_ids[] = {/* AMD */ #define ACPI_LPS0_DSM_UUID_AMD "e3f32452-febc-43ce-9039-932122d37721" +#define ACPI_LPS0_ENTRY_AMD 2 +#define ACPI_LPS0_EXIT_AMD 3#define ACPI_LPS0_SCREEN_OFF_AMD 4#define ACPI_LPS0_SCREEN_ON_AMD 5
@@ -408,6 +410,7 @@ int acpi_s2idle_prepare_late(void)if (acpi_s2idle_vendor_amd ()) {acpi_sleep_run_lps0_dsm (ACPI_LPS0_SCREEN_OFF_AMD ); +acpi_sleep_run_lps0_dsm (ACPI_LPS0_ENTRY_AMD ); }else {acpi_sleep_run_lps0_dsm (ACPI_LPS0_SCREEN_OFF );acpi_sleep_run_lps0_dsm (ACPI_LPS0_ENTRY );
@@ -422,6 +425,7 @@ void acpi_s2idle_restore_early(void)return ;if (acpi_s2idle_vendor_amd ()) { +acpi_sleep_run_lps0_dsm (ACPI_LPS0_EXIT_AMD );acpi_sleep_run_lps0_dsm (ACPI_LPS0_SCREEN_ON_AMD ); }else {acpi_sleep_run_lps0_dsm (ACPI_LPS0_EXIT );
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 4/59 ACPI: scan: Rearrange dep_unmet initialization
In reply to Sasha LevinFrom: "Rafael J. Wysocki" <[email protected]>
[ Upstream commit 6d27975851b134be8d2a170437210c9719e524aa ]
The dep_unmet field in struct acpi_device is used to store the number of unresolved _DEP dependencies (that is, operation region dependencies for which there are no drivers present) for the ACPI device object represented by it.
That field is initialized to 1 for all ACPI device objects in acpi_add_single_object(), via acpi_init_device_object(), so as to avoid evaluating _STA prematurely for battery device objects in acpi_scan_init_status(), and it is "fixed up" in acpi_bus_check_add() after the acpi_add_single_object() called by it has returned.
This is not particularly straightforward and causes dep_unmet to remain 1 for device objects without dependencies created by invoking acpi_add_single_object() directly, outside acpi_bus_check_add().
For this reason, rearrange acpi_add_single_object() to initialize dep_unmet completely before calling acpi_scan_init_status(), which requires passing one extra bool argument to it, and update all of its callers accordingly.
--- drivers/acpi/scan.c | 60 +++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 32 deletions(-)
drivers/acpi/scan.c +28 -32
@@ -1671,8 +1671,20 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,device_initialize (&device->dev);dev_set_uevent_suppress (&device->dev, true);acpi_init_coherency (device); -/* Assume there are unmet deps to start with. */ - device->dep_unmet =1 ; +} + +static void acpi_scan_dep_init (struct acpi_device *adev) +{ +struct acpi_dep_data *dep; + +mutex_lock (&acpi_dep_list_lock); + +list_for_each_entry (dep, &acpi_dep_list, node) { +if (dep->consumer == adev->handle) + adev->dep_unmet++; + } + +mutex_unlock (&acpi_dep_list_lock); }void acpi_device_add_finalize (struct acpi_device *device)
@@ -1688,7 +1700,7 @@ static void acpi_scan_init_status(struct acpi_device *adev) }static int acpi_add_single_object (struct acpi_device **child, -acpi_handle handle,int type) +acpi_handle handle,int type,bool dep_init) {struct acpi_device *device;int result;
@@ -1703,8 +1715,12 @@ static int acpi_add_single_object(struct acpi_device **child,* acpi_bus_get_status() and use its quirk handling. Note that * this must be done before the get power-/wakeup_dev-flags calls. */ -if (type ==ACPI_BUS_TYPE_DEVICE || type ==ACPI_BUS_TYPE_PROCESSOR ) +if (type ==ACPI_BUS_TYPE_DEVICE || type ==ACPI_BUS_TYPE_PROCESSOR ) { +if (dep_init) +acpi_scan_dep_init (device); +acpi_scan_init_status (device); + }acpi_bus_get_power_flags (device);acpi_bus_get_wakeup_device_flags (device);
@@ -1886,22 +1902,6 @@ static u32 acpi_scan_check_dep(acpi_handle handle, bool check_dep)return count; } -static void acpi_scan_dep_init (struct acpi_device *adev) -{ -struct acpi_dep_data *dep; - - adev->dep_unmet =0 ; - -mutex_lock (&acpi_dep_list_lock); - -list_for_each_entry (dep, &acpi_dep_list, node) { -if (dep->consumer == adev->handle) - adev->dep_unmet++; - } - -mutex_unlock (&acpi_dep_list_lock); -} -static bool acpi_bus_scan_second_pass; static acpi_status acpi_bus_check_add(acpi_handle handle, bool check_dep,
@@ -1949,19 +1949,15 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, bool check_dep,return AE_OK ; } -acpi_add_single_object (&device, handle, type); -if (!device) -return AE_CTRL_DEPTH ; - -acpi_scan_init_hotplug (device);/* * If check_dep is true at this point, the device has no dependencies, * or the creation of the device object would have been postponed above. */ -if (check_dep) - device->dep_unmet =0 ; -else -acpi_scan_dep_init (device); +acpi_add_single_object (&device, handle, type, !check_dep); +if (!device) +return AE_CTRL_DEPTH ; + +acpi_scan_init_hotplug (device); out:if (!*adev_p)
@@ -2223,7 +2219,7 @@ int acpi_bus_register_early_device(int type)struct acpi_device *device =NULL ;int result; - result =acpi_add_single_object (&device,NULL , type); + result =acpi_add_single_object (&device,NULL , type, false);if (result)return result;
@@ -2243,7 +2239,7 @@ static int acpi_bus_scan_fixed(void)struct acpi_device *device =NULL ; result =acpi_add_single_object (&device,NULL , -ACPI_BUS_TYPE_POWER_BUTTON ); +ACPI_BUS_TYPE_POWER_BUTTON , false);if (result)return result;
@@ -2259,7 +2255,7 @@ static int acpi_bus_scan_fixed(void)struct acpi_device *device =NULL ; result =acpi_add_single_object (&device,NULL , -ACPI_BUS_TYPE_SLEEP_BUTTON ); +ACPI_BUS_TYPE_SLEEP_BUTTON , false);if (result)return result;
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 5/59 ACPI: processor idle: Fix up C-state latency if not ordered
In reply to Sasha LevinFrom: Mario Limonciello <[email protected]>
[ Upstream commit 65ea8f2c6e230bdf71fed0137cf9e9d1b307db32 ]
Generally, the C-state latency is provided by the _CST method or FADT, but some OEM platforms using AMD Picasso, Renoir, Van Gogh, and Cezanne set the C2 latency greater than C3's which causes the C2 state to be skipped.
That will block the core entering PC6, which prevents S0ix working properly on Linux systems.
In other operating systems, the latency values are not validated and this does not cause problems by skipping states.
To avoid this issue on Linux, detect when latencies are not an arithmetic progression and sort them.
--- drivers/acpi/processor_idle.c | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
drivers/acpi/processor_idle.c +40 -0
@@ -16,6 +16,7 @@#include <linux/acpi.h> #include <linux/dmi.h> #include <linux/sched.h> /* need_resched() */ +#include <linux/sort.h> #include <linux/tick.h> #include <linux/cpuidle.h> #include <linux/cpu.h>
@@ -384,10 +385,37 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr,return ; } +static int acpi_cst_latency_cmp (const void *a,const void *b) +{ +const struct acpi_processor_cx *x = a, *y = b; + +if (!(x->valid && y->valid)) +return 0 ; +if (x->latency > y->latency) +return 1 ; +if (x->latency < y->latency) +return -1 ; +return 0 ; +} +static void acpi_cst_latency_swap (void *a,void *b,int n) +{ +struct acpi_processor_cx *x = a, *y = b; +u32 tmp; + +if (!(x->valid && y->valid)) +return ; + tmp = x->latency; + x->latency = y->latency; + y->latency = tmp; +} +static int acpi_processor_power_verify (struct acpi_processor *pr) {unsigned int i;unsigned int working =0 ; +unsigned int last_latency =0 ; +unsigned int last_type =0 ; +bool buggy_latency = false; pr->power.timer_broadcast_on_state =INT_MAX ;
@@ -411,12 +439,24 @@ static int acpi_processor_power_verify(struct acpi_processor *pr) }if (!cx->valid)continue ; +if (cx->type >= last_type && cx->latency < last_latency) + buggy_latency = true; + last_latency = cx->latency; + last_type = cx->type;lapic_timer_check_state (i, pr, cx);tsc_check_state (cx->type); working++; } +if (buggy_latency) { +pr_notice ("FW issue: working around C-state latencies out of order\n" ); +sort (&pr->power.states[1 ], max_cstate, +sizeof (struct acpi_processor_cx ), + acpi_cst_latency_cmp, + acpi_cst_latency_swap); + } +lapic_timer_propagate_broadcast (pr);return (working);
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 6/59 hv_utils: Fix passing zero to 'PTR_ERR' warning
In reply to Sasha LevinFrom: YueHaibing <[email protected]>
[ Upstream commit c6a8625fa4c6b0a97860d053271660ccedc3d1b3 ]
Sparse warn this:
drivers/hv/hv_util.c:753 hv_timesync_init() warn:
passing zero to 'PTR_ERR'
Use PTR_ERR_OR_ZERO instead of PTR_ERR to fix this.
--- drivers/hv/hv_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hv/hv_util.c +2 -2
@@ -750,8 +750,8 @@ static int hv_timesync_init(struct hv_util_service *srv)*/ hv_ptp_clock =ptp_clock_register (&ptp_hyperv_info,NULL );if (IS_ERR_OR_NULL (hv_ptp_clock)) { -pr_err ("cannot register PTP clock: %ld\n" , -PTR_ERR (hv_ptp_clock)); +pr_err ("cannot register PTP clock: %d\n" , +PTR_ERR_OR_ZERO (hv_ptp_clock)); hv_ptp_clock =NULL ; }
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 7/59 lib: vsprintf: Fix handling of number field widths in vsscanf
In reply to Sasha LevinFrom: Richard Fitzgerald <[email protected]>
[ Upstream commit 900fdc4573766dd43b847b4f54bd4a1ee2bc7360 ]
The existing code attempted to handle numbers by doing a strto[u]l(), ignoring the field width, and then repeatedly dividing to extract the field out of the full converted value. If the string contains a run of valid digits longer than will fit in a long or long long, this would overflow and no amount of dividing can recover the correct value.
This patch fixes vsscanf() to obey number field widths when parsing the number.
A new _parse_integer_limit() is added that takes a limit for the number of characters to parse. The number field conversion in vsscanf is changed to use this new function.
If a number starts with a radix prefix, the field width must be long enough for at last one digit after the prefix. If not, it will be handled like this:
sscanf("0x4", "%1i", &i): i=0, scanning continues with the 'x' sscanf("0x4", "%2i", &i): i=0, scanning continues with the '4'
This is consistent with the observed behaviour of userland sscanf.
Note that this patch does NOT fix the problem of a single field value overflowing the target type. So for example:
sscanf("123456789abcdef", "%x", &i);Will not produce the correct result because the value obviously overflows INT_MAX. But sscanf will report a successful conversion.
Note that where a very large number is used to mean "unlimited", the value INT_MAX is used for consistency with the behaviour of vsnprintf().
--- lib/kstrtox.c | 13 ++++++-- lib/kstrtox.h | 2 ++ lib/vsprintf.c | 82 +++++++++++++++++++++++++++++--------------------- 3 files changed, 60 insertions(+), 37 deletions(-)
lib/kstrtox.c +10 -3
@@ -39,20 +39,22 @@ const char *_parse_integer_fixup_radix(const char *s, unsigned int *base)/* * Convert non-negative integer string representation in explicitly given radix -* to an integer. +* to an integer. A maximum of max_chars characters will be converted. +* * Return number of characters consumed maybe or-ed with overflow bit. * If overflow occurs, result integer (incorrect) is still returned. * * Don't you dare use this function. */ -unsigned int _parse_integer (const char *s,unsigned int base,unsigned long long *p) +unsigned int _parse_integer_limit (const char *s,unsigned int base,unsigned long long *p, +size_t max_chars) {unsigned long long res;unsigned int rv; res =0 ; rv =0 ; -while (1 ) { +while (max_chars--) {unsigned int c = *s;unsigned int lc = c |0x20 ;/* don't tolower() this line */ unsigned int val;
@@ -82,6 +84,11 @@ unsigned int _parse_integer(const char *s, unsigned int base, unsigned long longreturn rv; } +unsigned int _parse_integer (const char *s,unsigned int base,unsigned long long *p) +{ +return _parse_integer_limit (s, base, p,INT_MAX ); +} +static int _kstrtoull (const char *s,unsigned int base,unsigned long long *res) {unsigned long long _res;
lib/kstrtox.h +2 -0
@@ -4,6 +4,8 @@#define KSTRTOX_OVERFLOW (1U << 31)const char *_parse_integer_fixup_radix (const char *s,unsigned int *base); +unsigned int _parse_integer_limit (const char *s,unsigned int base,unsigned long long *res, +size_t max_chars);unsigned int _parse_integer (const char *s,unsigned int base,unsigned long long *res);#endif
lib/vsprintf.c +48 -34
113 lines not on this page · raw message
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 8/59 Input: goodix - platform/x86: touchscreen_dmi - Move upside down quirks to touchscreen_dmi.c
In reply to Sasha LevinFrom: Hans de Goede <[email protected]>
[ Upstream commit 5a6f0dbe621a5c20dc912ac474debf9f11129e03 ]
Move the DMI quirks for upside-down mounted Goodix touchscreens from drivers/input/touchscreen/goodix.c to drivers/platform/x86/touchscreen_dmi.c,
where all the other x86 touchscreen quirks live.
Note the touchscreen_dmi.c code attaches standard touchscreen device-properties to an i2c-client device based on a combination of a DMI match + a device-name match. I've verified that the: Teclast X98 Pro, WinBook TW100 and WinBook TW700 uses an ACPI devicename of "GDIX1001:00" based on acpidumps and/or dmesg output available on the web.
This patch was tested on a Teclast X89 tablet.
--- drivers/input/touchscreen/goodix.c | 52 ------------------------ drivers/platform/x86/touchscreen_dmi.c | 56 ++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 52 deletions(-)
drivers/input/touchscreen/goodix.c +0 -52
@@ -178,51 +178,6 @@ static const unsigned long goodix_irq_flags[] = { IRQ_TYPE_LEVEL_HIGH, }; -/* -* Those tablets have their coordinates origin at the bottom right -* of the tablet, as if rotated 180 degrees -*/ -static const struct dmi_system_id rotated_screen[] = { -#if defined(CONFIG_DMI) && defined(CONFIG_X86) - { - .ident ="Teclast X89" , - .matches = { -/* tPAD is too generic, also match on bios date */ -DMI_MATCH (DMI_BOARD_VENDOR ,"TECLAST" ), -DMI_MATCH (DMI_BOARD_NAME ,"tPAD" ), -DMI_MATCH (DMI_BIOS_DATE ,"12/19/2014" ), - }, - }, - { - .ident ="Teclast X98 Pro" , - .matches = { -/* -* Only match BIOS date, because the manufacturers -* BIOS does not report the board name at all -* (sometimes)... -*/ -DMI_MATCH (DMI_BOARD_VENDOR ,"TECLAST" ), -DMI_MATCH (DMI_BIOS_DATE ,"10/28/2015" ), - }, - }, - { - .ident ="WinBook TW100" , - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"WinBook" ), -DMI_MATCH (DMI_PRODUCT_NAME ,"TW100" ) - } - }, - { - .ident ="WinBook TW700" , - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"WinBook" ), -DMI_MATCH (DMI_PRODUCT_NAME ,"TW700" ) - }, - }, -#endif - {} -}; -static const struct dmi_system_id nine_bytes_report[] = { #if defined(CONFIG_DMI) && defined(CONFIG_X86) {
@@ -1123,13 +1078,6 @@ static int goodix_configure_dev(struct goodix_ts_data *ts) ABS_MT_POSITION_Y, ts->prop.max_y); } -if (dmi_check_system (rotated_screen)) { - ts->prop.invert_x = true; - ts->prop.invert_y = true; -dev_dbg (&ts->client->dev, -"Applying '180 degrees rotated screen' quirk\n" ); - } -if (dmi_check_system (nine_bytes_report)) { ts->contact_size =9 ;
drivers/platform/x86/touchscreen_dmi.c +56 -0
80 lines not on this page · raw message
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 9/59 platform/x86: touchscreen_dmi: Add an extra entry for the upside down Goodix touchscreen on Teclast X89 tablets
In reply to Sasha LevinFrom: Hans de Goede <[email protected]>
[ Upstream commit a22e3803f2a4d947ff0083a9448a169269ea0f62 ]
Teclast X89 tablets come in 2 versions, with Windows pre-installed and with Android pre-installed. These 2 versions have different DMI strings.
Add a match for the DMI strings used by the Android version BIOS.
Note the Android version BIOS has a bug in the DSDT where no IRQ is provided, so for the touchscreen to work a DSDT override fixing this is necessary as well.
--- drivers/platform/x86/touchscreen_dmi.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/platform/x86/touchscreen_dmi.c +8 -0
@@ -1347,6 +1347,14 @@ const struct dmi_system_id touchscreen_dmi_table[] = { DMI_MATCH(DMI_BOARD_NAME, "X3 Plus"), }, }, + { +/* Teclast X89 (Android version / BIOS) */ + .driver_data = (void *)&gdix1001_00_upside_down_data, + .matches = { +DMI_MATCH (DMI_BOARD_VENDOR ,"WISKY" ), + DMI_MATCH(DMI_BOARD_NAME, "3G062i"), + }, + }, {/* Teclast X89 (Windows version / BIOS) */ .driver_data = (void *)&gdix1001_01_upside_down_data,
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 10/59 platform/x86: touchscreen_dmi: Add info for the Goodix GT912 panel of TM800A550L tablets
In reply to Sasha LevinFrom: Hans de Goede <[email protected]>
[ Upstream commit fcd8cf0e3e48f4c66af82c8e799c37cb0cccffe0 ]
The Bay Trail Glavey TM800A550L tablet, which ships with Android installed from the factory, uses a GT912 touchscreen controller which needs to have its firmware uploaded by the OS to work (this is a first for a x86 based device with a Goodix touchscreen controller).
Add a touchscreen_dmi entry for this which specifies the filenames to use for the firmware and config files needed for this.
Note this matches on a GDIX1001 ACPI HID, while the original DSDT uses a HID of GODX0911. For the touchscreen to work on these devices a DSDT override is necessary to fix a missing IRQ and broken GPIO settings in the ACPI-resources for the touchscreen. This override also changes the HID to the standard GDIX1001 id typically used for Goodix touchscreens. The DSDT override is available here:
https://fedorapeople.org/~jwrdegoede/glavey-tm800a550l-dsdt-override/
--- drivers/platform/x86/touchscreen_dmi.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
drivers/platform/x86/touchscreen_dmi.c +21 -0
@@ -316,6 +316,18 @@ static const struct ts_dmi_data gdix1001_01_upside_down_data = { .properties = gdix1001_upside_down_props, }; +static const struct property_entry glavey_tm800a550l_props[] = { +PROPERTY_ENTRY_STRING ("firmware-name" ,"gt912-glavey-tm800a550l.fw" ), +PROPERTY_ENTRY_STRING ("goodix,config-name" ,"gt912-glavey-tm800a550l.cfg" ), +PROPERTY_ENTRY_U32 ("goodix,main-clk" ,54 ), + { } +}; + +static const struct ts_dmi_data glavey_tm800a550l_data = { + .acpi_name ="GDIX1001:00" , + .properties = glavey_tm800a550l_props, +}; +static const struct property_entry gp_electronic_t701_props[] = {PROPERTY_ENTRY_U32 ("touchscreen-size-x" ,960 ),PROPERTY_ENTRY_U32 ("touchscreen-size-y" ,640 ),
@@ -1055,6 +1067,15 @@ const struct dmi_system_id touchscreen_dmi_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "eSTAR BEAUTY HD Intel Quad core"), }, }, + { /* Glavey TM800A550L */ + .driver_data = (void *)&glavey_tm800a550l_data, + .matches = { +DMI_MATCH (DMI_BOARD_VENDOR ,"AMI Corporation" ), +DMI_MATCH (DMI_BOARD_NAME ,"Aptio CRB" ), +/* Above strings are too generic, also match on BIOS version */ + DMI_MATCH(DMI_BIOS_VERSION, "ZY-8-BI-PX4S70VTR400-X423B-005-D"), + }, + }, {/* GP-electronic T701 */ .driver_data = (void *)&gp_electronic_t701_data,
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 11/59 ACPI: EC: Make more Asus laptops use ECDT _GPE
In reply to Sasha LevinFrom: Chris Chiu <[email protected]>
[ Upstream commit 6306f0431914beaf220634ad36c08234006571d5 ]
More ASUS laptops have the _GPE define in the DSDT table with a different value than the _GPE number in the ECDT.
This is causing media keys not working on ASUS X505BA/BP, X542BA/BP
Add model info to the quirks list.
--- drivers/acpi/ec.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/acpi/ec.c +16 -0
@@ -1846,6 +1846,22 @@ static const struct dmi_system_id ec_dmi_table[] __initconst = { DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), DMI_MATCH(DMI_PRODUCT_NAME, "GL702VMK"),}, NULL}, { + ec_honor_ecdt_gpe, "ASUSTeK COMPUTER INC. X505BA", { + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), + DMI_MATCH(DMI_PRODUCT_NAME, "X505BA"),}, NULL}, + { + ec_honor_ecdt_gpe, "ASUSTeK COMPUTER INC. X505BP", { + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), + DMI_MATCH(DMI_PRODUCT_NAME, "X505BP"),}, NULL}, + { + ec_honor_ecdt_gpe, "ASUSTeK COMPUTER INC. X542BA", { + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), + DMI_MATCH(DMI_PRODUCT_NAME, "X542BA"),}, NULL}, + { + ec_honor_ecdt_gpe, "ASUSTeK COMPUTER INC. X542BP", { + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), + DMI_MATCH(DMI_PRODUCT_NAME, "X542BP"),}, NULL}, + { ec_honor_ecdt_gpe, "ASUS X550VXK", { DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), DMI_MATCH(DMI_PRODUCT_NAME, "X550VXK"),}, NULL},
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 12/59 block_dump: remove block_dump feature in mark_inode_dirty()
In reply to Sasha LevinFrom: "zhangyi (F)" <[email protected]>
[ Upstream commit 12e0613715e1cf305fffafaf0e89d810d9a85cc0 ]
block_dump is an old debugging interface, one of it's functions is used to print the information about who write which file on disk. If we enable block_dump through /proc/sys/vm/block_dump and turn on debug log level, we can gather information about write process name, target file name and disk from kernel message. This feature is realized in block_dump___mark_inode_dirty(), it print above information into kernel message directly when marking inode dirty, so it is noisy and can easily trigger log storm. At the same time, get the dentry refcount is also not safe, we found it will lead to deadlock on ext4 file system with data=journal mode.
After tracepoints has been introduced into the kernel, we got a tracepoint in __mark_inode_dirty(), which is a better replacement of block_dump___mark_inode_dirty(). The only downside is that it only trace the inode number and not a file name, but it probably doesn't matter because the original printed file name in block_dump is not accurate in some cases, and we can still find it through the inode number and device id. So this patch delete the dirting inode part of block_dump feature.
--- fs/fs-writeback.c | 25 ------------------------- 1 file changed, 25 deletions(-)
fs/fs-writeback.c +0 -25
@@ -2205,28 +2205,6 @@ int dirtytime_interval_handler(struct ctl_table *table, int write,return ret; } -static noinline void block_dump___mark_inode_dirty(struct inode *inode) -{ -if (inode->i_ino ||strcmp (inode->i_sb->s_id,"bdev" )) { -struct dentry *dentry; -const char *name ="?" ; - - dentry =d_find_alias (inode); -if (dentry) { -spin_lock (&dentry->d_lock); - name = (const char *) dentry->d_name.name; - } -printk (KERN_DEBUG -"%s(%d): dirtied inode %lu (%s) on %s\n" , - current->comm,task_pid_nr (current), inode->i_ino, - name, inode->i_sb->s_id); -if (dentry) { -spin_unlock (&dentry->d_lock); -dput (dentry); - } - } -} -/** * __mark_inode_dirty - internal function to mark an inode dirty *
@@ -2296,9 +2274,6 @@ void __mark_inode_dirty(struct inode *inode, int flags) (dirtytime && (inode->i_state & I_DIRTY_INODE))) return; -if (unlikely (block_dump)) -block_dump___mark_inode_dirty (inode); -spin_lock (&inode->i_lock);if (dirtytime && (inode->i_state &I_DIRTY_INODE )) goto out_unlock_inode;
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 13/59 blk-mq: grab rq->refcount before calling ->fn in blk_mq_tagset_busy_iter
In reply to Sasha LevinFrom: Ming Lei <[email protected]>
[ Upstream commit 2e315dc07df009c3e29d6926871f62a30cfae394 ]
Grab rq->refcount before calling ->fn in blk_mq_tagset_busy_iter(), and this way will prevent the request from being re-used when ->fn is running. The approach is same as what we do during handling timeout.
Fix request use-after-free(UAF) related with completion race or queue releasing:
- If one rq is referred before rq->q is frozen, then queue won't be frozen before the request is released during iteration.
- If one rq is referred after rq->q is frozen, refcount_inc_not_zero() will return false, and we won't iterate over this request.
However, still one request UAF not covered: refcount_inc_not_zero() may read one freed request, and it will be handled in next patch.
--- block/blk-mq-tag.c | 44 +++++++++++++++++++++++++++++++++----------- block/blk-mq.c | 14 +++++++++----- block/blk-mq.h | 1 + 3 files changed, 43 insertions(+), 16 deletions(-)
block/blk-mq-tag.c +33 -11
@@ -199,6 +199,16 @@ struct bt_iter_data {bool reserved; }; +static struct request *blk_mq_find_and_get_req (struct blk_mq_tags *tags, +unsigned int bitnr) +{ +struct request *rq = tags->rqs[bitnr]; + +if (!rq || !refcount_inc_not_zero (&rq->ref)) +return NULL ; +return rq; +} +static bool bt_iter (struct sbitmap *bitmap,unsigned int bitnr,void *data) {struct bt_iter_data *iter_data = data;
@@ -206,18 +216,22 @@ static bool bt_iter(struct sbitmap *bitmap, unsigned int bitnr, void *data)struct blk_mq_tags *tags = hctx->tags;bool reserved = iter_data->reserved;struct request *rq; +bool ret = true;if (!reserved) bitnr += tags->nr_reserved_tags; - rq = tags->rqs[bitnr]; -/* * We can hit rq == NULL here, because the tagging functions * test and set the bit before assigning ->rqs[]. */ -if (rq && rq->q == hctx->queue && rq->mq_hctx == hctx) -return iter_data->fn (hctx, rq, iter_data->data, reserved); -return true; + rq =blk_mq_find_and_get_req (tags, bitnr); +if (!rq) +return true; + +if (rq->q == hctx->queue && rq->mq_hctx == hctx) + ret = iter_data->fn (hctx, rq, iter_data->data, reserved); +blk_mq_put_rq_ref (rq); +return ret; }/**
@@ -264,6 +278,8 @@ static bool bt_tags_iter(struct sbitmap *bitmap, unsigned int bitnr, void *data)struct blk_mq_tags *tags = iter_data->tags;bool reserved = iter_data->flags &BT_TAG_ITER_RESERVED ;struct request *rq; +bool ret = true; +bool iter_static_rqs = !!(iter_data->flags &BT_TAG_ITER_STATIC_RQS );if (!reserved) bitnr += tags->nr_reserved_tags;
@@ -272,16 +288,19 @@ static bool bt_tags_iter(struct sbitmap *bitmap, unsigned int bitnr, void *data)* We can hit rq == NULL here, because the tagging functions * test and set the bit before assigning ->rqs[]. */ -if (iter_data->flags &BT_TAG_ITER_STATIC_RQS ) +if (iter_static_rqs) rq = tags->static_rqs[bitnr];else - rq = tags->rqs[bitnr]; + rq =blk_mq_find_and_get_req (tags, bitnr);if (!rq)return true; -if ((iter_data->flags &BT_TAG_ITER_STARTED ) && - !blk_mq_request_started (rq)) -return true; -return iter_data->fn (rq, iter_data->data, reserved); + +if (!(iter_data->flags &BT_TAG_ITER_STARTED ) || +blk_mq_request_started (rq)) + ret = iter_data->fn (rq, iter_data->data, reserved); +if (!iter_static_rqs) +blk_mq_put_rq_ref (rq); +return ret; }/**
@@ -348,6 +367,9 @@ void blk_mq_all_tag_iter(struct blk_mq_tags *tags, busy_tag_iter_fn *fn,* indicates whether or not @rq is a reserved request. Return * true to continue iterating tags, false to stop. * @priv: Will be passed as second argument to @fn. +* +* We grab one request reference before calling @fn and release it after +* @fn returns. */ void blk_mq_tagset_busy_iter (struct blk_mq_tag_set *tagset,busy_tag_iter_fn *fn,void *priv)
block/blk-mq.c +9 -5
@@ -909,6 +909,14 @@ static bool blk_mq_req_expired(struct request *rq, unsigned long *next)return false; } +void blk_mq_put_rq_ref (struct request *rq) +{ +if (is_flush_rq (rq, rq->mq_hctx)) + rq->end_io (rq,0 ); +else if (refcount_dec_and_test (&rq->ref)) +__blk_mq_free_request (rq); +} +static bool blk_mq_check_expired (struct blk_mq_hw_ctx *hctx,struct request *rq,void *priv,bool reserved) {
@@ -942,11 +950,7 @@ static bool blk_mq_check_expired(struct blk_mq_hw_ctx *hctx,if (blk_mq_req_expired (rq, next))blk_mq_rq_timed_out (rq, reserved); -if (is_flush_rq (rq, hctx)) - rq->end_io (rq,0 ); -else if (refcount_dec_and_test (&rq->ref)) -__blk_mq_free_request (rq); - +blk_mq_put_rq_ref (rq);return true; }
block/blk-mq.h +1 -0
@@ -47,6 +47,7 @@ void blk_mq_add_to_requeue_list(struct request *rq, bool at_head,void blk_mq_flush_busy_ctxs (struct blk_mq_hw_ctx *hctx,struct list_head *list);struct request *blk_mq_dequeue_from_ctx (struct blk_mq_hw_ctx *hctx,struct blk_mq_ctx *start); +void blk_mq_put_rq_ref (struct request *rq);/* * Internal helpers for allocating/freeing the request map
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 14/59 blk-mq: clear stale request in tags->rq[] before freeing one request pool
In reply to Sasha LevinFrom: Ming Lei <[email protected]>
[ Upstream commit bd63141d585bef14f4caf111f6d0e27fe2300ec6 ]
refcount_inc_not_zero() in bt_tags_iter() still may read one freed request.
Fix the issue by the following approach:
1) hold a per-tags spinlock when reading ->rqs[tag] and calling refcount_inc_not_zero in bt_tags_iter()
2) clearing stale request referred via ->rqs[tag] before freeing request pool, the per-tags spinlock is held for clearing stale ->rq[tag]
So after we cleared stale requests, bt_tags_iter() won't observe freed request any more, also the clearing will wait for pending request reference.
The idea of clearing ->rqs[] is borrowed from John Garry's previous patch and one recent David's patch.
--- block/blk-mq-tag.c | 9 +++++++-- block/blk-mq-tag.h | 6 ++++++ block/blk-mq.c | 46 +++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 54 insertions(+), 7 deletions(-)
block/blk-mq-tag.c +7 -2
@@ -202,10 +202,14 @@ struct bt_iter_data {static struct request *blk_mq_find_and_get_req (struct blk_mq_tags *tags,unsigned int bitnr) { -struct request *rq = tags->rqs[bitnr]; +struct request *rq; +unsigned long flags; +spin_lock_irqsave (&tags->lock, flags); + rq = tags->rqs[bitnr];if (!rq || !refcount_inc_not_zero (&rq->ref)) -return NULL ; + rq =NULL ; +spin_unlock_irqrestore (&tags->lock, flags);return rq; }
@@ -538,6 +542,7 @@ struct blk_mq_tags *blk_mq_init_tags(unsigned int total_tags, tags->nr_tags = total_tags; tags->nr_reserved_tags = reserved_tags; +spin_lock_init (&tags->lock);if (blk_mq_is_sbitmap_shared (flags))return tags;
block/blk-mq-tag.h +6 -0
@@ -20,6 +20,12 @@ struct blk_mq_tags {struct request **rqs;struct request **static_rqs;struct list_head page_list; + +/* +* used to clear request reference in rqs[] before freeing one +* request pool +*/ +spinlock_t lock; }; extern struct blk_mq_tags *blk_mq_init_tags(unsigned int nr_tags,
block/blk-mq.c +41 -5
64 lines not on this page · raw message
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 15/59 fs: dlm: fix srcu read lock usage
In reply to Sasha LevinFrom: Alexander Aring <[email protected]>
[ Upstream commit b38bc9c2b3171f4411d80015ecb876bc6f9bcd26 ]
This patch holds the srcu connection read lock in cases where we lookup the connections and accessing it. We don't hold the srcu lock in workers function where the scheduled worker is part of the connection itself. The connection should not be freed if any worker is scheduled or pending.
--- fs/dlm/lowcomms.c | 75 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 52 insertions(+), 23 deletions(-)
fs/dlm/lowcomms.c +52 -23
@@ -113,6 +113,7 @@ struct writequeue_entry {int len;int end;int users; +int idx;/* get()/commit() idx exchange */ struct connection *con; };
@@ -163,21 +164,14 @@ static inline int nodeid_hash(int nodeid)return nodeid & (CONN_HASH_SIZE -1 ); } -static struct connection *__find_con (int nodeid) +static struct connection *__find_con (int nodeid,int r) { -int r, idx;struct connection *con; - r =nodeid_hash (nodeid); - - idx =srcu_read_lock (&connections_srcu);hlist_for_each_entry_rcu (con, &connection_hash[r], list) { -if (con->nodeid == nodeid) { -srcu_read_unlock (&connections_srcu, idx); +if (con->nodeid == nodeid)return con; - } } -srcu_read_unlock (&connections_srcu, idx);return NULL ; }
@@ -216,7 +210,8 @@ static struct connection *nodeid2con(int nodeid, gfp_t alloc)struct connection *con, *tmp;int r, ret; - con =__find_con (nodeid); + r =nodeid_hash (nodeid); + con =__find_con (nodeid, r);if (con || !alloc)return con;
@@ -230,8 +225,6 @@ static struct connection *nodeid2con(int nodeid, gfp_t alloc)return NULL ; } - r =nodeid_hash (nodeid); -spin_lock (&connections_lock);/* Because multiple workqueues/threads calls this function it can * race on multiple cpu's. Instead of locking hot path __find_con()
@@ -239,7 +232,7 @@ static struct connection *nodeid2con(int nodeid, gfp_t alloc)* under protection of connections_lock. If this is the case we * abort our connection creation and return the existing connection. */ - tmp =__find_con (nodeid); + tmp =__find_con (nodeid, r);if (tmp) {spin_unlock (&connections_lock);kfree (con->rx_buf);
@@ -256,15 +249,13 @@ static struct connection *nodeid2con(int nodeid, gfp_t alloc)/* Loop round all connections */ static void foreach_conn (void (*conn_func)(struct connection *c)) { -int i, idx; +int i;struct connection *con; - idx =srcu_read_lock (&connections_srcu);for (i =0 ; i <CONN_HASH_SIZE ; i++) {hlist_for_each_entry_rcu (con, &connection_hash[i], list)conn_func (con); } -srcu_read_unlock (&connections_srcu, idx); }static struct dlm_node_addr *find_node_addr (int nodeid)
@@ -518,14 +509,21 @@ static void lowcomms_state_change(struct sock *sk)int dlm_lowcomms_connect_node (int nodeid) {struct connection *con; +int idx;if (nodeid ==dlm_our_nodeid ())return 0 ; + idx =srcu_read_lock (&connections_srcu); con =nodeid2con (nodeid,GFP_NOFS ); -if (!con) +if (!con) { +srcu_read_unlock (&connections_srcu, idx);return -ENOMEM ; + } +lowcomms_connect_sock (con); +srcu_read_unlock (&connections_srcu, idx); +return 0 ; }
@@ -864,7 +862,7 @@ static int accept_from_sock(struct listen_connection *con)int result;struct sockaddr_storage peeraddr;struct socket *newsock; -int len; +int len, idx;int nodeid;struct connection *newcon;struct connection *addcon;
@@ -907,8 +905,10 @@ static int accept_from_sock(struct listen_connection *con)* the same time and the connections cross on the wire. * In this case we store the incoming one in "othercon" */ + idx =srcu_read_lock (&connections_srcu); newcon =nodeid2con (nodeid,GFP_NOFS );if (!newcon) { +srcu_read_unlock (&connections_srcu, idx); result = -ENOMEM ; goto accept_err; }
@@ -924,6 +924,7 @@ static int accept_from_sock(struct listen_connection *con)if (!othercon) {log_print ("failed to allocate incoming socket" );mutex_unlock (&newcon->sock_mutex); +srcu_read_unlock (&connections_srcu, idx); result = -ENOMEM ; goto accept_err; }
@@ -932,6 +933,7 @@ static int accept_from_sock(struct listen_connection *con)if (result <0 ) {kfree (othercon);mutex_unlock (&newcon->sock_mutex); +srcu_read_unlock (&connections_srcu, idx); goto accept_err; }
@@ -966,6 +968,8 @@ static int accept_from_sock(struct listen_connection *con)if (!test_and_set_bit (CF_READ_PENDING , &addcon->flags))queue_work (recv_workqueue, &addcon->rwork); +srcu_read_unlock (&connections_srcu, idx); +return 0 ; accept_err:
@@ -1403,7 +1407,9 @@ static struct writequeue_entry *new_wq_entry(struct connection *con, int len,void *dlm_lowcomms_get_buffer (int nodeid,int len,gfp_t allocation,char **ppc) { +struct writequeue_entry *e;struct connection *con; +int idx;if (len >DEFAULT_BUFFER_SIZE || len <sizeof (struct dlm_header )) {
@@ -1413,11 +1419,23 @@ void *dlm_lowcomms_get_buffer(int nodeid, int len, gfp_t allocation, char **ppc)return NULL ; } + idx =srcu_read_lock (&connections_srcu); con =nodeid2con (nodeid, allocation); -if (!con) +if (!con) { +srcu_read_unlock (&connections_srcu, idx);return NULL ; + } + + e =new_wq_entry (con, len, allocation, ppc); +if (!e) { +srcu_read_unlock (&connections_srcu, idx); +return NULL ; + } + +/* we assume if successful commit must called */ + e->idx = idx; -return new_wq_entry (con, len, allocation, ppc); +return e; }void dlm_lowcomms_commit_buffer (void *mh)
@@ -1435,10 +1453,12 @@ void dlm_lowcomms_commit_buffer(void *mh)spin_unlock (&con->writequeue_lock);queue_work (send_workqueue, &con->swork); +srcu_read_unlock (&connections_srcu, e->idx);return ; out:spin_unlock (&con->writequeue_lock); +srcu_read_unlock (&connections_srcu, e->idx);return ; }
@@ -1532,8 +1552,10 @@ int dlm_lowcomms_close(int nodeid) {struct connection *con;struct dlm_node_addr *na; +int idx;log_print ("closing connection to node %d" , nodeid); + idx =srcu_read_lock (&connections_srcu); con =nodeid2con (nodeid,0 );if (con) {set_bit (CF_CLOSE , &con->flags);
@@ -1542,6 +1564,7 @@ int dlm_lowcomms_close(int nodeid)if (con->othercon)clean_one_writequeue (con->othercon); } +srcu_read_unlock (&connections_srcu, idx);spin_lock (&dlm_node_addrs_spin); na =find_node_addr (nodeid);
@@ -1621,6 +1644,8 @@ static void shutdown_conn(struct connection *con)void dlm_lowcomms_shutdown (void ) { +int idx; +/* Set all the flags to prevent any * socket activity. */
@@ -1633,7 +1658,9 @@ void dlm_lowcomms_shutdown(void)dlm_close_sock (&listen_con.sock); + idx =srcu_read_lock (&connections_srcu);foreach_conn (shutdown_conn); +srcu_read_unlock (&connections_srcu, idx); }static void _stop_conn (struct connection *con,bool and_other)
@@ -1682,7 +1709,7 @@ static void free_conn(struct connection *con)static void work_flush (void ) { -int ok, idx; +int ok;int i;struct connection *con;
@@ -1693,7 +1720,6 @@ static void work_flush(void)flush_workqueue (recv_workqueue);if (send_workqueue)flush_workqueue (send_workqueue); - idx =srcu_read_lock (&connections_srcu);for (i =0 ; i <CONN_HASH_SIZE && ok; i++) {hlist_for_each_entry_rcu (con, &connection_hash[i], list) {
@@ -1707,14 +1733,17 @@ static void work_flush(void) } } } -srcu_read_unlock (&connections_srcu, idx); }while (!ok); }void dlm_lowcomms_stop (void ) { +int idx; + + idx =srcu_read_lock (&connections_srcu);work_flush ();foreach_conn (free_conn); +srcu_read_unlock (&connections_srcu, idx);work_stop ();deinit_local (); }
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 16/59 fs: dlm: reconnect if socket error report occurs
In reply to Sasha LevinFrom: Alexander Aring <[email protected]>
[ Upstream commit ba868d9deaab2bb1c09e50650127823925154802 ]
This patch will change the reconnect handling that if an error occurs if a socket error callback is occurred. This will also handle reconnects in a non blocking connecting case which is currently missing. If error ECONNREFUSED is reported we delay the reconnect by one second.
--- fs/dlm/lowcomms.c | 60 ++++++++++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 21 deletions(-)
fs/dlm/lowcomms.c +39 -21
@@ -79,6 +79,8 @@ struct connection {#define CF_CLOSING 8#define CF_SHUTDOWN 9#define CF_CONNECTED 10 +#define CF_RECONNECT 11 +#define CF_DELAY_CONNECT 12struct list_head writequeue;/* List of outgoing writequeue_entries */ spinlock_t writequeue_lock;void (*connect_action) (struct connection *);/* What to do to connect */
@@ -87,6 +89,7 @@ struct connection {#define MAX_CONNECT_RETRIES 3struct hlist_node list;struct connection *othercon; +struct connection *sendcon;struct work_struct rwork;/* Receive workqueue */ struct work_struct swork;/* Send workqueue */ wait_queue_head_t shutdown_wait;/* wait for graceful shutdown */
@@ -585,6 +588,22 @@ static void lowcomms_error_report(struct sock *sk) dlm_config.ci_tcp_port, sk->sk_err, sk->sk_err_soft); } + +/* below sendcon only handling */ +if (test_bit (CF_IS_OTHERCON , &con->flags)) + con = con->sendcon; + +switch (sk->sk_err) { +case ECONNREFUSED : +set_bit (CF_DELAY_CONNECT , &con->flags); +break ; +default : +break ; + } + +if (!test_and_set_bit (CF_RECONNECT , &con->flags)) +queue_work (send_workqueue, &con->swork); + out:read_unlock_bh (&sk->sk_callback_lock);if (orig_report)
@@ -702,6 +721,8 @@ static void close_connection(struct connection *con, bool and_other, con->rx_leftover =0 ; con->retries =0 ;clear_bit (CF_CONNECTED , &con->flags); +clear_bit (CF_DELAY_CONNECT , &con->flags); +clear_bit (CF_RECONNECT , &con->flags);mutex_unlock (&con->sock_mutex);clear_bit (CF_CLOSING , &con->flags); }
@@ -840,18 +861,15 @@ static int receive_from_sock(struct connection *con) out_close:mutex_unlock (&con->sock_mutex); -if (ret != -EAGAIN ) { -/* Reconnect when there is something to send */ +if (ret ==0 ) {close_connection (con, false, true, false); -if (ret ==0 ) { -log_print ("connection %p got EOF from %d" , - con, con->nodeid); -/* handling for tcp shutdown */ -clear_bit (CF_SHUTDOWN , &con->flags); -wake_up (&con->shutdown_wait); -/* signal to breaking receive worker */ - ret =-1 ; - } +log_print ("connection %p got EOF from %d" , + con, con->nodeid); +/* handling for tcp shutdown */ +clear_bit (CF_SHUTDOWN , &con->flags); +wake_up (&con->shutdown_wait); +/* signal to breaking receive worker */ + ret =-1 ; }return ret; }
@@ -939,6 +957,7 @@ static int accept_from_sock(struct listen_connection *con)lockdep_set_subclass (&othercon->sock_mutex,1 ); newcon->othercon = othercon; + othercon->sendcon = newcon; }else {/* close other sock con if we have something new */ close_connection (othercon, false, true, false);
@@ -1503,7 +1522,7 @@ static void send_to_sock(struct connection *con)cond_resched (); goto out; }else if (ret <0 ) - goto send_error; + goto out; }/* Don't starve people filling buffers */
@@ -1520,14 +1539,6 @@ static void send_to_sock(struct connection *con)mutex_unlock (&con->sock_mutex);return ; -send_error: -mutex_unlock (&con->sock_mutex); -close_connection (con, false, false, true); -/* Requeue the send work. When the work daemon runs again, it will try -a new connection, then call this function again. */ -queue_work (send_workqueue, &con->swork); -return ; - out_connect:mutex_unlock (&con->sock_mutex);queue_work (send_workqueue, &con->swork);
@@ -1602,8 +1613,15 @@ static void process_send_sockets(struct work_struct *work) struct connection *con = container_of(work, struct connection, swork);clear_bit (CF_WRITE_PENDING , &con->flags); -if (con->sock ==NULL )/* not mutex protected so check it inside too */ + +if (test_and_clear_bit (CF_RECONNECT , &con->flags)) +close_connection (con, false, false, true); + +if (con->sock ==NULL ) {/* not mutex protected so check it inside too */ +if (test_and_clear_bit (CF_DELAY_CONNECT , &con->flags)) +msleep (1000 ); con->connect_action (con); + }if (!list_empty (&con->writequeue))send_to_sock (con); }
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 17/59 fs: dlm: cancel work sync othercon
In reply to Sasha LevinFrom: Alexander Aring <[email protected]>
[ Upstream commit c6aa00e3d20c2767ba3f57b64eb862572b9744b3 ]
These rx tx flags arguments are for signaling close_connection() from which worker they are called. Obviously the receive worker cannot cancel itself and vice versa for swork. For the othercon the receive worker should only be used, however to avoid deadlocks we should pass the same flags as the original close_connection() was called.
--- fs/dlm/lowcomms.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/dlm/lowcomms.c +1 -1
@@ -715,7 +715,7 @@ static void close_connection(struct connection *con, bool and_other,if (con->othercon && and_other) {/* Will only re-enter once. */ -close_connection (con->othercon, false, true, true); +close_connection (con->othercon, false, tx, rx); } con->rx_leftover =0 ;
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 18/59 fs: dlm: fix connection tcp EOF handling
In reply to Sasha LevinFrom: Alexander Aring <[email protected]>
[ Upstream commit 8aa31cbf20ad168c35dd83476629402aacbf5a44 ]
This patch fixes the EOF handling for TCP that if and EOF is received we will close the socket next time the writequeue runs empty. This is a half-closed socket functionality which doesn't exists in SCTP. The midcomms layer will do a half closed socket functionality on DLM side to solve this problem for the SCTP case. However there is still the last ack flying around but other reset functionality will take care of it if it got lost.
--- fs/dlm/lowcomms.c | 48 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-)
fs/dlm/lowcomms.c +43 -5
@@ -81,10 +81,13 @@ struct connection {#define CF_CONNECTED 10#define CF_RECONNECT 11#define CF_DELAY_CONNECT 12 +#define CF_EOF 13struct list_head writequeue;/* List of outgoing writequeue_entries */ spinlock_t writequeue_lock; +atomic_t writequeue_cnt;void (*connect_action) (struct connection *);/* What to do to connect */ void (*shutdown_action)(struct connection *con);/* What to do to shutdown */ +bool (*eof_condition)(struct connection *con);/* What to do to eof check */ int retries;#define MAX_CONNECT_RETRIES 3struct hlist_node list;
@@ -179,6 +182,11 @@ static struct connection *__find_con(int nodeid, int r)return NULL ; } +static bool tcp_eof_condition (struct connection *con) +{ +return atomic_read (&con->writequeue_cnt); +} +static int dlm_con_init (struct connection *con,int nodeid) { con->rx_buflen = dlm_config.ci_buffer_size;
@@ -190,6 +198,7 @@ static int dlm_con_init(struct connection *con, int nodeid)mutex_init (&con->sock_mutex);INIT_LIST_HEAD (&con->writequeue);spin_lock_init (&con->writequeue_lock); +atomic_set (&con->writequeue_cnt,0 );INIT_WORK (&con->swork, process_send_sockets);INIT_WORK (&con->rwork, process_recv_sockets);init_waitqueue_head (&con->shutdown_wait);
@@ -197,6 +206,7 @@ static int dlm_con_init(struct connection *con, int nodeid)if (dlm_config.ci_protocol ==0 ) { con->connect_action = tcp_connect_to_sock; con->shutdown_action = dlm_tcp_shutdown; + con->eof_condition = tcp_eof_condition; }else { con->connect_action = sctp_connect_to_sock; }
@@ -723,6 +733,7 @@ static void close_connection(struct connection *con, bool and_other,clear_bit (CF_CONNECTED , &con->flags);clear_bit (CF_DELAY_CONNECT , &con->flags);clear_bit (CF_RECONNECT , &con->flags); +clear_bit (CF_EOF , &con->flags);mutex_unlock (&con->sock_mutex);clear_bit (CF_CLOSING , &con->flags); }
@@ -860,16 +871,26 @@ static int receive_from_sock(struct connection *con)return -EAGAIN ; out_close: -mutex_unlock (&con->sock_mutex);if (ret ==0 ) { -close_connection (con, false, true, false);log_print ("connection %p got EOF from %d" , con, con->nodeid); -/* handling for tcp shutdown */ -clear_bit (CF_SHUTDOWN , &con->flags); -wake_up (&con->shutdown_wait); + +if (con->eof_condition && con->eof_condition (con)) { +set_bit (CF_EOF , &con->flags); +mutex_unlock (&con->sock_mutex); + }else { +mutex_unlock (&con->sock_mutex); +close_connection (con, false, true, false); + +/* handling for tcp shutdown */ +clear_bit (CF_SHUTDOWN , &con->flags); +wake_up (&con->shutdown_wait); + } +/* signal to breaking receive worker */ ret =-1 ; + }else { +mutex_unlock (&con->sock_mutex); }return ret; }
@@ -1020,6 +1041,7 @@ static void writequeue_entry_complete(struct writequeue_entry *e, int completed)if (e->len ==0 && e->users ==0 ) {list_del (&e->list); +atomic_dec (&e->con->writequeue_cnt);free_entry (e); } }
@@ -1416,6 +1438,7 @@ static struct writequeue_entry *new_wq_entry(struct connection *con, int len, *ppc =page_address (e->page); e->end += len; +atomic_inc (&con->writequeue_cnt);spin_lock (&con->writequeue_lock);list_add_tail (&e->list, &con->writequeue);
@@ -1535,6 +1558,21 @@ static void send_to_sock(struct connection *con)writequeue_entry_complete (e, ret); }spin_unlock (&con->writequeue_lock); + +/* close if we got EOF */ +if (test_and_clear_bit (CF_EOF , &con->flags)) { +mutex_unlock (&con->sock_mutex); +close_connection (con, false, false, true); + +/* handling for tcp shutdown */ +clear_bit (CF_SHUTDOWN , &con->flags); +wake_up (&con->shutdown_wait); + }else { +mutex_unlock (&con->sock_mutex); + } + +return ; + out:mutex_unlock (&con->sock_mutex);return ;
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 19/59 random32: Fix implicit truncation warning in prandom_seed_state()
In reply to Sasha LevinFrom: Richard Fitzgerald <[email protected]>
[ Upstream commit d327ea15a305024ef0085252fa3657bbb1ce25f5 ]
sparse generates the following warning:
include/linux/prandom.h:114:45: sparse: sparse: cast truncates bits from constant value
This is because the 64-bit seed value is manipulated and then placed in a u32, causing an implicit cast and truncation. A forced cast to u32 doesn't prevent this warning, which is reasonable because a typecast doesn't prove that truncation was expected.
Logical-AND the value with 0xffffffff to make explicit that truncation to 32-bit is intended.
--- include/linux/prandom.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/prandom.h +1 -1
@@ -111,7 +111,7 @@ static inline u32 __seed(u32 x, u32 m)*/ static inline void prandom_seed_state (struct rnd_state *state,u64 seed) { -u32 i = (seed >>32 ) ^ (seed <<10 ) ^ seed; +u32 i = ((seed >>32 ) ^ (seed <<10 ) ^ seed) &0xffffffffUL ; state->s1 =__seed (i,2U ); state->s2 =__seed (i,8U );
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 20/59 open: don't silently ignore unknown O-flags in openat2()
In reply to Sasha LevinFrom: Christian Brauner <[email protected]>
[ Upstream commit cfe80306a0dd6d363934913e47c3f30d71b721e5 ]
The new openat2() syscall verifies that no unknown O-flag values are set and returns an error to userspace if they are while the older open syscalls like open() and openat() simply ignore unknown flag values:
#define O_FLAG_CURRENTLY_INVALID (1 << 31)
struct open_how how = {
.flags = O_RDONLY | O_FLAG_CURRENTLY_INVALID,
.resolve = 0,
};
/* fails */
fd = openat2(-EBADF, "/dev/null", &how, sizeof(how));
/* succeeds */
fd = openat(-EBADF, "/dev/null", O_RDONLY | O_FLAG_CURRENTLY_INVALID);However, openat2() silently truncates the upper 32 bits meaning:
#define O_FLAG_CURRENTLY_INVALID_LOWER32 (1 << 31)
#define O_FLAG_CURRENTLY_INVALID_UPPER32 (1 << 40)
struct open_how how_lowe32 = {
.flags = O_RDONLY | O_FLAG_CURRENTLY_INVALID_LOWER32,
};
struct open_how how_upper32 = {
.flags = O_RDONLY | O_FLAG_CURRENTLY_INVALID_UPPER32,
};
/* fails */
fd = openat2(-EBADF, "/dev/null", &how_lower32, sizeof(how_lower32));
/* succeeds */
fd = openat2(-EBADF, "/dev/null", &how_upper32, sizeof(how_upper32));Fix this by preventing the immediate truncation in build_open_flags().
There's a snafu here though stripping FMODE_* directly from flags would cause the upper 32 bits to be truncated as well due to integer promotion rules since FMODE_* is unsigned int, O_* are signed ints (yuck).
In addition, struct open_flags currently defines flags to be 32 bit which is reasonable. If we simply were to bump it to 64 bit we would need to change a lot of code preemptively which doesn't seem worth it. So simply add a compile-time check verifying that all currently known O_* flags are within the 32 bit range and fail to build if they aren't anymore.
This change shouldn't regress old open syscalls since they silently truncate any unknown values anyway. It is a tiny semantic change for openat2() but it is very unlikely people pass ing > 32 bit unknown flags and the syscall is relatively new too.
--- fs/open.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
fs/open.c +11 -3
@@ -1002,12 +1002,20 @@ inline struct open_how build_open_how(int flags, umode_t mode)inline int build_open_flags (const struct open_how *how,struct open_flags *op) { -int flags = how->flags; +u64 flags = how->flags; +u64 strip =FMODE_NONOTIFY |O_CLOEXEC ;int lookup_flags =0 ;int acc_mode =ACC_MODE (flags); -/* Must never be set by userspace */ - flags &= ~(FMODE_NONOTIFY |O_CLOEXEC ); +BUILD_BUG_ON_MSG (upper_32_bits (VALID_OPEN_FLAGS ), +"struct open_flags doesn't yet handle flags > 32 bits" ); + +/* +* Strip flags that either shouldn't be set by userspace like +* FMODE_NONOTIFY or that aren't relevant in determining struct +* open_flags like O_CLOEXEC. +*/ + flags &= ~strip;/* * Older syscalls implicitly clear all of the invalid flags or argument
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 21/59 drivers: hv: Fix missing error code in vmbus_connect()
In reply to Sasha LevinFrom: Jiapeng Chong <[email protected]>
[ Upstream commit 9de6655cc5a6a1febc514465c87c24a0e96d8dba ]
Eliminate the follow smatch warning:
drivers/hv/connection.c:236 vmbus_connect() warn: missing error code 'ret'.
--- drivers/hv/connection.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/hv/connection.c +3 -1
@@ -232,8 +232,10 @@ int vmbus_connect(void)*/ for (i =0 ; ; i++) { -if (i ==ARRAY_SIZE (vmbus_versions)) +if (i ==ARRAY_SIZE (vmbus_versions)) { + ret = -EDOM ; goto cleanup; + } version = vmbus_versions[i];if (version > max_version)
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 22/59 fs: dlm: fix lowcomms_start error case
In reply to Sasha LevinFrom: Alexander Aring <[email protected]>
[ Upstream commit fcef0e6c27ce109d2c617aa12f0bfd9f7ff47d38 ]
This patch fixes the error path handling in lowcomms_start(). We need to cleanup some static allocated data structure and cleanup possible workqueue if these have started.
--- fs/dlm/lowcomms.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
fs/dlm/lowcomms.c +12 -3
@@ -1666,10 +1666,15 @@ static void process_send_sockets(struct work_struct *work)static void work_stop (void ) { -if (recv_workqueue) +if (recv_workqueue) {destroy_workqueue (recv_workqueue); -if (send_workqueue) + recv_workqueue =NULL ; + } + +if (send_workqueue) {destroy_workqueue (send_workqueue); + send_workqueue =NULL ; + } }static int work_start (void )
@@ -1686,6 +1691,7 @@ static int work_start(void)if (!send_workqueue) {log_print ("can't start dlm_send" );destroy_workqueue (recv_workqueue); + recv_workqueue =NULL ;return -ENOMEM ; }
@@ -1823,7 +1829,7 @@ int dlm_lowcomms_start(void) error =work_start ();if (error) - goto fail; + goto fail_local; dlm_allow_conn =1 ;
@@ -1840,6 +1846,9 @@ int dlm_lowcomms_start(void) fail_unlisten: dlm_allow_conn =0 ;dlm_close_sock (&listen_con.sock); +work_stop (); +fail_local: +deinit_local (); fail:return error; }
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 23/59 fs: dlm: fix memory leak when fenced
In reply to Sasha LevinFrom: Alexander Aring <[email protected]>
[ Upstream commit 700ab1c363c7b54c9ea3222379b33fc00ab02f7b ]
I got some kmemleak report when a node was fenced. The user space tool dlm_controld will therefore run some rmdir() in dlm configfs which was triggering some memleaks. This patch stores the sps and cms attributes which stores some handling for subdirectories of the configfs cluster entry and free them if they get released as the parent directory gets freed.
unreferenced object 0xffff88810d9e3e00 (size 192):
comm "dlm_controld", pid 342, jiffies 4294698126 (age 55438.801s) hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 73 70 61 63 65 73 00 00 ........spaces..
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<00000000db8b640b>] make_cluster+0x5d/0x360
[<000000006a571db4>] configfs_mkdir+0x274/0x730
[<00000000b094501c>] vfs_mkdir+0x27e/0x340
[<0000000058b0adaf>] do_mkdirat+0xff/0x1b0
[<00000000d1ffd156>] do_syscall_64+0x40/0x80
[<00000000ab1408c8>] entry_SYSCALL_64_after_hwframe+0x44/0xae
unreferenced object 0xffff88810d9e3a00 (size 192):
comm "dlm_controld", pid 342, jiffies 4294698126 (age 55438.801s)
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 63 6f 6d 6d 73 00 00 00 ........comms...
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<00000000a7ef6ad2>] make_cluster+0x82/0x360
[<000000006a571db4>] configfs_mkdir+0x274/0x730
[<00000000b094501c>] vfs_mkdir+0x27e/0x340
[<0000000058b0adaf>] do_mkdirat+0xff/0x1b0
[<00000000d1ffd156>] do_syscall_64+0x40/0x80
[<00000000ab1408c8>] entry_SYSCALL_64_after_hwframe+0x44/0xae--- fs/dlm/config.c | 9 +++++++++ 1 file changed, 9 insertions(+)
fs/dlm/config.c +9 -0
@@ -79,6 +79,9 @@ struct dlm_cluster {unsigned int cl_new_rsb_count;unsigned int cl_recover_callbacks;char cl_cluster_name[DLM_LOCKSPACE_LEN ]; + +struct dlm_spaces *sps; +struct dlm_comms *cms; };static struct dlm_cluster *config_item_to_cluster (struct config_item *i)
@@ -409,6 +412,9 @@ static struct config_group *make_cluster(struct config_group *g,if (!cl || !sps || !cms) goto fail; + cl->sps = sps; + cl->cms = cms; +config_group_init_type_name (&cl->group, name, &cluster_type);config_group_init_type_name (&sps->ss_group,"spaces" , &spaces_type);config_group_init_type_name (&cms->cs_group,"comms" , &comms_type);
@@ -458,6 +464,9 @@ static void drop_cluster(struct config_group *g, struct config_item *i)static void release_cluster (struct config_item *i) {struct dlm_cluster *cl =config_item_to_cluster (i); + +kfree (cl->sps); +kfree (cl->cms);kfree (cl); }
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 24/59 ACPICA: Fix memory leak caused by _CID repair function
In reply to Sasha LevinFrom: Erik Kaneda <[email protected]>
[ Upstream commit c27bac0314131b11bccd735f7e8415ac6444b667 ]
ACPICA commit 180cb53963aa876c782a6f52cc155d951b26051a
According to the ACPI spec, _CID returns a package containing hardware ID's. Each element of an ASL package contains a reference count from the parent package as well as the element itself.
Name (TEST, Package() {
"String object" // this package element has a reference count of 2
})
A memory leak was caused in the _CID repair function because it did not decrement the reference count created by the package. Fix the memory leak by calling acpi_ut_remove_reference on _CID package elements that represent a hardware ID (_HID).
--- drivers/acpi/acpica/nsrepair2.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/acpi/acpica/nsrepair2.c +7 -0
@@ -379,6 +379,13 @@ acpi_ns_repair_CID(struct acpi_evaluate_info *info, (*element_ptr)->common.reference_count = original_ref_count; + +/* +* The original_element holds a reference from the package object +* that represents _HID. Since a new element was created by _HID, +* remove the reference from the _CID package. +*/ +acpi_ut_remove_reference (original_element); } element_ptr++;
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 25/59 ACPI: bus: Call kobject_put() in acpi_init() error path
In reply to Sasha LevinFrom: Hanjun Guo <[email protected]>
[ Upstream commit 4ac7a817f1992103d4e68e9837304f860b5e7300 ]
Although the system will not be in a good condition or it will not boot if acpi_bus_init() fails, it is still necessary to put the kobject in the error path before returning to avoid leaking memory.
--- drivers/acpi/bus.c | 1 + 1 file changed, 1 insertion(+)
drivers/acpi/bus.c +1 -0
@@ -1321,6 +1321,7 @@ static int __init acpi_init(void) result =acpi_bus_init ();if (result) { +kobject_put (acpi_kobj);disable_acpi ();return result; }
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 26/59 ACPI: resources: Add checks for ACPI IRQ override
In reply to Sasha LevinFrom: Hui Wang <[email protected]>
[ Upstream commit 0ec4e55e9f571f08970ed115ec0addc691eda613 ]
The laptop keyboard doesn't work on many MEDION notebooks, but the keyboard works well under Windows and Unix.
Through debugging, we found this log in the dmesg:
ACPI: IRQ 1 override to edge, high
pnp 00:03: Plug and Play ACPI device, IDs PNP0303 (active)
And we checked the IRQ definition in the DSDT, it is:
IRQ (Level, ActiveLow, Exclusive, )
{1}
So the BIOS defines the keyboard IRQ to Level_Low, but the Linux kernel override it to Edge_High. If the Linux kernel is modified to skip the IRQ override, the keyboard will work normally.
From the existing comment in acpi_dev_get_irqresource(), the override function only needs to be called when IRQ() or IRQNoFlags() is used to populate the resource descriptor, and according to Section 6.4.2.1 of ACPI 6.4 [1], if IRQ() is empty or IRQNoFlags() is used, the IRQ is High true, edge sensitive and non-shareable. ACPICA also assumes that to be the case (see acpi_rs_set_irq[] in rsirq.c).
In accordance with the above, check 3 additional conditions (EdgeSensitive, ActiveHigh and Exclusive) when deciding whether or not to treat an ACPI_RESOURCE_TYPE_IRQ resource as "legacy", in which case the IRQ override is applicable to it.
--- drivers/acpi/resource.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/acpi/resource.c +8 -1
@@ -423,6 +423,13 @@ static void acpi_dev_get_irqresource(struct resource *res, u32 gsi, } } +static bool irq_is_legacy (struct acpi_resource_irq *irq) +{ +return irq->triggering ==ACPI_EDGE_SENSITIVE && + irq->polarity ==ACPI_ACTIVE_HIGH && + irq->shareable ==ACPI_EXCLUSIVE ; +} +/** * acpi_dev_resource_interrupt - Extract ACPI interrupt resource information. * @ares: Input ACPI resource object.
@@ -461,7 +468,7 @@ bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index, }acpi_dev_get_irqresource (res, irq->interrupts[index], irq->triggering, irq->polarity, - irq->shareable, true); + irq->shareable,irq_is_legacy (irq));break ;case ACPI_RESOURCE_TYPE_EXTENDED_IRQ : ext_irq = &ares->data.extended_irq;
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 27/59 HID: hid-input: add Surface Go battery quirk
In reply to Sasha LevinFrom: Zoltan Tamas Vajda <[email protected]>
[ Upstream commit b5539722eb832441f309642fe5102cc3536f92b8 ]
The Elantech touchscreen/digitizer in the Surface Go mistakenly reports having a battery. This results in a low battery message every time you try to use the pen.
This patch adds a quirk to ignore the non-existent battery and gets rid of the false low battery messages.
--- drivers/hid/hid-ids.h | 1 + drivers/hid/hid-input.c | 2 ++ 2 files changed, 3 insertions(+)
drivers/hid/hid-ids.h +1 -0
@@ -396,6 +396,7 @@#define USB_DEVICE_ID_HP_X2_10_COVER 0x0755#define I2C_DEVICE_ID_HP_SPECTRE_X360_15 0x2817#define USB_DEVICE_ID_ASUS_UX550_TOUCHSCREEN 0x2706 +#define I2C_DEVICE_ID_SURFACE_GO_TOUCHSCREEN 0x261A#define USB_VENDOR_ID_ELECOM 0x056e#define USB_DEVICE_ID_ELECOM_BM084 0x0061
drivers/hid/hid-input.c +2 -0
@@ -326,6 +326,8 @@ static const struct hid_device_id hid_battery_quirks[] = { HID_BATTERY_QUIRK_IGNORE }, {HID_I2C_DEVICE (USB_VENDOR_ID_ELAN ,I2C_DEVICE_ID_HP_SPECTRE_X360_15 ), HID_BATTERY_QUIRK_IGNORE }, + { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_SURFACE_GO_TOUCHSCREEN), + HID_BATTERY_QUIRK_IGNORE }, {} };
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 28/59 HID: sony: fix freeze when inserting ghlive ps3/wii dongles
In reply to Sasha LevinFrom: Pascal Giard <[email protected]>
[ Upstream commit fb1a79a6b6e1223ddb18f12aa35e36f832da2290 ]
This commit fixes a freeze on insertion of a Guitar Hero Live PS3/WiiU USB dongle. Indeed, with the current implementation, inserting one of those USB dongles will lead to a hard freeze. I apologize for not catching this earlier, it didn't occur on my old laptop.
While the issue was isolated to memory alloc/free, I could not figure out why it causes a freeze. So this patch fixes this issue by simplifying memory allocation and usage.
We remind that for the dongle to work properly, a control URB needs to be sent periodically. We used to alloc/free the URB each time this URB needed to be sent.
With this patch, the memory for the URB is allocated on the probe, reused for as long as the dongle is plugged in, and freed once the dongle is unplugged.
--- drivers/hid/hid-sony.c | 98 +++++++++++++++++++++--------------------- 1 file changed, 49 insertions(+), 49 deletions(-)
drivers/hid/hid-sony.c +49 -49
@@ -597,9 +597,8 @@ struct sony_sc {/* DS4 calibration data */ struct ds4_calibration_data ds4_calib_data[6 ];/* GH Live */ +struct urb *ghl_urb;struct timer_list ghl_poke_timer; -struct usb_ctrlrequest *ghl_cr; -u8 *ghl_databuf; };static void sony_set_leds (struct sony_sc *sc);
@@ -625,66 +624,54 @@ static inline void sony_schedule_work(struct sony_sc *sc,static void ghl_magic_poke_cb (struct urb *urb) { -if (urb) { -/* Free sc->ghl_cr and sc->ghl_databuf allocated in -* ghl_magic_poke() -*/ -kfree (urb->setup_packet); -kfree (urb->transfer_buffer); - } +struct sony_sc *sc = urb->context; + +if (urb->status <0 ) +hid_err (sc->hdev,"URB transfer failed : %d" , urb->status); + +mod_timer (&sc->ghl_poke_timer, jiffies +GHL_GUITAR_POKE_INTERVAL *HZ ); }static void ghl_magic_poke (struct timer_list *t) { +int ret;struct sony_sc *sc =from_timer (sc, t, ghl_poke_timer); -int ret; + ret =usb_submit_urb (sc->ghl_urb,GFP_ATOMIC ); +if (ret <0 ) +hid_err (sc->hdev,"usb_submit_urb failed: %d" , ret); +} + +static int ghl_init_urb (struct sony_sc *sc,struct usb_device *usbdev) +{ +struct usb_ctrlrequest *cr; +u16 poke_size; +u8 *databuf;unsigned int pipe; -struct urb *urb; -struct usb_device *usbdev =to_usb_device (sc->hdev->dev.parent->parent); -const u16 poke_size = -ARRAY_SIZE (ghl_ps3wiiu_magic_data); + poke_size =ARRAY_SIZE (ghl_ps3wiiu_magic_data); pipe =usb_sndctrlpipe (usbdev,0 ); -if (!sc->ghl_cr) { - sc->ghl_cr =kzalloc (sizeof (*sc->ghl_cr),GFP_ATOMIC ); -if (!sc->ghl_cr) - goto resched; - } - -if (!sc->ghl_databuf) { - sc->ghl_databuf =kzalloc (poke_size,GFP_ATOMIC ); -if (!sc->ghl_databuf) - goto resched; - } + cr =devm_kzalloc (&sc->hdev->dev,sizeof (*cr),GFP_ATOMIC ); +if (cr ==NULL ) +return -ENOMEM ; - urb =usb_alloc_urb (0 ,GFP_ATOMIC ); -if (!urb) - goto resched; + databuf =devm_kzalloc (&sc->hdev->dev, poke_size,GFP_ATOMIC ); +if (databuf ==NULL ) +return -ENOMEM ; - sc->ghl_cr->bRequestType = + cr->bRequestType =USB_RECIP_INTERFACE |USB_TYPE_CLASS |USB_DIR_OUT ; - sc->ghl_cr->bRequest =USB_REQ_SET_CONFIGURATION ; - sc->ghl_cr->wValue =cpu_to_le16 (ghl_ps3wiiu_magic_value); - sc->ghl_cr->wIndex =0 ; - sc->ghl_cr->wLength =cpu_to_le16 (poke_size); -memcpy (sc->ghl_databuf, ghl_ps3wiiu_magic_data, poke_size); - + cr->bRequest =USB_REQ_SET_CONFIGURATION ; + cr->wValue =cpu_to_le16 (ghl_ps3wiiu_magic_value); + cr->wIndex =0 ; + cr->wLength =cpu_to_le16 (poke_size); +memcpy (databuf, ghl_ps3wiiu_magic_data, poke_size);usb_fill_control_urb ( - urb, usbdev, pipe, - (unsigned char *) sc->ghl_cr, sc->ghl_databuf, - poke_size, ghl_magic_poke_cb,NULL ); - ret =usb_submit_urb (urb,GFP_ATOMIC ); -if (ret <0 ) { -kfree (sc->ghl_databuf); -kfree (sc->ghl_cr); - } -usb_free_urb (urb); - -resched: -/* Reschedule for next time */ -mod_timer (&sc->ghl_poke_timer, jiffies +GHL_GUITAR_POKE_INTERVAL *HZ ); + sc->ghl_urb, usbdev, pipe, + (unsigned char *) cr, databuf, poke_size, + ghl_magic_poke_cb, sc); +return 0 ; } static int guitar_mapping(struct hid_device *hdev, struct hid_input *hi,
@@ -2981,6 +2968,7 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)int ret;unsigned long quirks = id->driver_data;struct sony_sc *sc; +struct usb_device *usbdev;unsigned int connect_mask =HID_CONNECT_DEFAULT ;if (!strcmp (hdev->name,"FutureMax Dance Mat" ))
@@ -3000,6 +2988,7 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id) sc->quirks = quirks;hid_set_drvdata (hdev, sc); sc->hdev = hdev; + usbdev =to_usb_device (sc->hdev->dev.parent->parent); ret =hid_parse (hdev);if (ret) {
@@ -3042,6 +3031,15 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id) }if (sc->quirks &GHL_GUITAR_PS3WIIU ) { + sc->ghl_urb =usb_alloc_urb (0 ,GFP_ATOMIC ); +if (!sc->ghl_urb) +return -ENOMEM ; + ret =ghl_init_urb (sc, usbdev); +if (ret) { +hid_err (hdev,"error preparing URB\n" ); +return ret; + } +timer_setup (&sc->ghl_poke_timer, ghl_magic_poke,0 );mod_timer (&sc->ghl_poke_timer, jiffies +GHL_GUITAR_POKE_INTERVAL *HZ );
@@ -3054,8 +3052,10 @@ static void sony_remove(struct hid_device *hdev) {struct sony_sc *sc =hid_get_drvdata (hdev); -if (sc->quirks &GHL_GUITAR_PS3WIIU ) +if (sc->quirks &GHL_GUITAR_PS3WIIU ) {del_timer_sync (&sc->ghl_poke_timer); +usb_free_urb (sc->ghl_urb); + }hid_hw_close (hdev);
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 29/59 block: fix race between adding/removing rq qos and normal IO
In reply to Sasha LevinFrom: Ming Lei <[email protected]>
[ Upstream commit 2cafe29a8d03f02a3d16193bdaae2f3e82a423f9 ]
Yi reported several kernel panics on:
[16687.001777] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000008 ... [16687.163549] pc : __rq_qos_track+0x38/0x60
or
[ 997.690455] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000020 ... [ 997.850347] pc : __rq_qos_done+0x2c/0x50
Turns out it is caused by race between adding rq qos(wbt) and normal IO because rq_qos_add can be run when IO is being submitted, fix this issue by freezing queue before adding/deleting rq qos to queue.
rq_qos_exit() needn't to freeze queue because it is called after queue has been frozen.
iolatency calls rq_qos_add() during allocating queue, so freezing won't add delay because queue usage refcount works at atomic mode at that time.
iocost calls rq_qos_add() when writing cgroup attribute file, that is fine to freeze queue at that time since we usually freeze queue when storing to queue sysfs attribute, meantime iocost only exists on the root cgroup.
wbt_init calls it in blk_register_queue() and queue sysfs attribute store(queue_wb_lat_store() when write it 1st time in case of !BLK_WBT_MQ), the following patch will speedup the queue freezing in wbt_init.
--- block/blk-rq-qos.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
block/blk-rq-qos.h +24 -0
@@ -7,6 +7,7 @@#include <linux/blk_types.h> #include <linux/atomic.h> #include <linux/wait.h> +#include <linux/blk-mq.h> #include "blk-mq-debugfs.h"
@@ -99,8 +100,21 @@ static inline void rq_wait_init(struct rq_wait *rq_wait)static inline void rq_qos_add (struct request_queue *q,struct rq_qos *rqos) { +/* +* No IO can be in-flight when adding rqos, so freeze queue, which +* is fine since we only support rq_qos for blk-mq queue. +* +* Reuse ->queue_lock for protecting against other concurrent +* rq_qos adding/deleting +*/ +blk_mq_freeze_queue (q); + +spin_lock_irq (&q->queue_lock); rqos->next = q->rq_qos; q->rq_qos = rqos; +spin_unlock_irq (&q->queue_lock); + +blk_mq_unfreeze_queue (q);if (rqos->ops->debugfs_attrs)blk_mq_debugfs_register_rqos (rqos);
@@ -110,12 +124,22 @@ static inline void rq_qos_del(struct request_queue *q, struct rq_qos *rqos) {struct rq_qos **cur; +/* +* See comment in rq_qos_add() about freezing queue & using +* ->queue_lock. +*/ +blk_mq_freeze_queue (q); + +spin_lock_irq (&q->queue_lock);for (cur = &q->rq_qos; *cur; cur = &(*cur)->next) {if (*cur == rqos) { *cur = rqos->next;break ; } } +spin_unlock_irq (&q->queue_lock); + +blk_mq_unfreeze_queue (q);blk_mq_debugfs_unregister_rqos (rqos); }
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 30/59 platform/x86: asus-nb-wmi: Revert "Drop duplicate DMI quirk structures"
In reply to Sasha LevinFrom: "Luke D. Jones" <[email protected]>
[ Upstream commit 98c0c85b1040db24f0d04d3e1d315c6c7b05cc07 ]
This is a preparation revert for reverting the "add support for ASUS ROG Zephyrus G14 and G15" change. This reverts
commit 67186653c903 ("platform/x86: asus-nb-wmi: Drop duplicate DMI quirk structures")
--- drivers/platform/x86/asus-nb-wmi.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)
drivers/platform/x86/asus-nb-wmi.c +14 -9
@@ -110,7 +110,12 @@ static struct quirk_entry quirk_asus_forceals = { .wmi_force_als_set = true, }; -static struct quirk_entry quirk_asus_vendor_backlight = { +static struct quirk_entry quirk_asus_ga401i = { + .wmi_backlight_power = true, + .wmi_backlight_set_devstate = true, +}; + +static struct quirk_entry quirk_asus_ga502i = { .wmi_backlight_power = true, .wmi_backlight_set_devstate = true, };
@@ -432,7 +437,7 @@ static const struct dmi_system_id asus_quirks[] = {DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), DMI_MATCH(DMI_PRODUCT_NAME, "GA401IH"), }, - .driver_data = &quirk_asus_vendor_backlight, + .driver_data = &quirk_asus_ga401i, }, { .callback = dmi_matched,
@@ -441,7 +446,7 @@ static const struct dmi_system_id asus_quirks[] = {DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), DMI_MATCH(DMI_PRODUCT_NAME, "GA401II"), }, - .driver_data = &quirk_asus_vendor_backlight, + .driver_data = &quirk_asus_ga401i, }, { .callback = dmi_matched,
@@ -450,7 +455,7 @@ static const struct dmi_system_id asus_quirks[] = {DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), DMI_MATCH(DMI_PRODUCT_NAME, "GA401IU"), }, - .driver_data = &quirk_asus_vendor_backlight, + .driver_data = &quirk_asus_ga401i, }, { .callback = dmi_matched,
@@ -459,7 +464,7 @@ static const struct dmi_system_id asus_quirks[] = {DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), DMI_MATCH(DMI_PRODUCT_NAME, "GA401IV"), }, - .driver_data = &quirk_asus_vendor_backlight, + .driver_data = &quirk_asus_ga401i, }, { .callback = dmi_matched,
@@ -468,7 +473,7 @@ static const struct dmi_system_id asus_quirks[] = {DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), DMI_MATCH(DMI_PRODUCT_NAME, "GA401IVC"), }, - .driver_data = &quirk_asus_vendor_backlight, + .driver_data = &quirk_asus_ga401i, }, { .callback = dmi_matched,
@@ -477,7 +482,7 @@ static const struct dmi_system_id asus_quirks[] = {DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), DMI_MATCH(DMI_PRODUCT_NAME, "GA502II"), }, - .driver_data = &quirk_asus_vendor_backlight, + .driver_data = &quirk_asus_ga502i, }, { .callback = dmi_matched,
@@ -486,7 +491,7 @@ static const struct dmi_system_id asus_quirks[] = {DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), DMI_MATCH(DMI_PRODUCT_NAME, "GA502IU"), }, - .driver_data = &quirk_asus_vendor_backlight, + .driver_data = &quirk_asus_ga502i, }, { .callback = dmi_matched,
@@ -495,7 +500,7 @@ static const struct dmi_system_id asus_quirks[] = {DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), DMI_MATCH(DMI_PRODUCT_NAME, "GA502IV"), }, - .driver_data = &quirk_asus_vendor_backlight, + .driver_data = &quirk_asus_ga502i, }, { .callback = dmi_matched,
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 31/59 platform/x86: asus-nb-wmi: Revert "add support for ASUS ROG Zephyrus G14 and G15"
In reply to Sasha LevinFrom: "Luke D. Jones" <[email protected]>
[ Upstream commit 28117f3a5c3c8375a3304af76357d5bf9cf30f0b ]
The quirks added to asus-nb-wmi for the ASUS ROG Zephyrus G14 and G15 are wrong, they tell the asus-wmi code to use the vendor specific WMI backlight interface. But there is no such interface on these laptops.
As a side effect, these quirks stop the acpi_video driver to register since they make acpi_video_get_backlight_type() return acpi_backlight_vendor, leaving only the native AMD backlight driver in place, which is the one we want. This happy coincidence is being replaced with a new quirk in drivers/acpi/video_detect.c which actually sets the backlight_type to acpi_backlight_native fixinf this properly. This reverts
commit 13bceda68fb9 ("platform/x86: asus-nb-wmi: add support for ASUS ROG Zephyrus G14 and G15").
--- drivers/platform/x86/asus-nb-wmi.c | 82 ------------------------------ 1 file changed, 82 deletions(-)
drivers/platform/x86/asus-nb-wmi.c +0 -82
@@ -110,16 +110,6 @@ static struct quirk_entry quirk_asus_forceals = { .wmi_force_als_set = true, }; -static struct quirk_entry quirk_asus_ga401i = { - .wmi_backlight_power = true, - .wmi_backlight_set_devstate = true, -}; - -static struct quirk_entry quirk_asus_ga502i = { - .wmi_backlight_power = true, - .wmi_backlight_set_devstate = true, -}; -static struct quirk_entry quirk_asus_use_kbd_dock_devid = { .use_kbd_dock_devid = true, };
@@ -430,78 +420,6 @@ static const struct dmi_system_id asus_quirks[] = { }, .driver_data = &quirk_asus_forceals, }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA401IH", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA401IH"), - }, - .driver_data = &quirk_asus_ga401i, - }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA401II", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA401II"), - }, - .driver_data = &quirk_asus_ga401i, - }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA401IU", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA401IU"), - }, - .driver_data = &quirk_asus_ga401i, - }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA401IV", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA401IV"), - }, - .driver_data = &quirk_asus_ga401i, - }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA401IVC", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA401IVC"), - }, - .driver_data = &quirk_asus_ga401i, - }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA502II", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA502II"), - }, - .driver_data = &quirk_asus_ga502i, - }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA502IU", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA502IU"), - }, - .driver_data = &quirk_asus_ga502i, - }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA502IV", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA502IV"), - }, - .driver_data = &quirk_asus_ga502i, - }, { .callback = dmi_matched, .ident = "Asus Transformer T100TA / T100HA / T100CHI",
Signature · 1 line
2.30.2
Re: [PATCH AUTOSEL 5.13 31/59] platform/x86: asus-nb-wmi: Revert "add support for ASUS ROG Zephyrus G14 and G15"
Hi,
Quoted 17 lines · Sasha Levin
From: "Luke D. Jones" <[email protected]>
[ Upstream commit
28117f3a5c3c8375a3304af76357d5bf9cf30f0b]The quirks added to asus-nb-wmi for the ASUS ROG Zephyrus G14 and G15 are wrong, they tell the asus-wmi code to use the vendor specific WMI backlight interface. But there is no such interface on these laptops.
As a side effect, these quirks stop the
acpi_videodriver to register since they makeacpi_video_get_backlight_type()returnacpi_backlight_vendor, leaving only the native AMD backlight driver in place, which is the one we want. This happy coincidence is being replaced with a new quirk indrivers/acpi/video_detect.cwhich actually sets thebacklight_typetoacpi_backlight_nativefixinf this properly. This reverts
commit13bceda68fb9("platform/x86: asus-nb-wmi: add support for ASUS ROG Zephyrus G14 and G15").
Quoted 4 lines
Signed-off-by Luke D. Jones <[email protected]>Signed-off-by Hans de Goede <[email protected]>Signed-off-by Sasha Levin <[email protected]>
Note this should only be cherry-picked if commit 2dfbacc65d1d ("ACPI: video: use native backlight for GA401/GA502/GA503"):
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=2dfbacc65d1d2eae587ccb6b93f6280542641858
Is also being cherry-picked, since the quirk added in that commit replaces the quirks which are being reverted here.
Regards,
Hans
Quoted 105 lines
--- drivers/platform/x86/asus-nb-wmi.c | 82 ------------------------------ 1 file changed, 82 deletions(-)drivers/platform/x86/asus-nb-wmi.c +0
-82@@ -110,16 +110,6 @@ static struct quirk_entry quirk_asus_forceals = { .wmi_force_als_set = true, }; -static struct quirk_entry quirk_asus_ga401i = { - .wmi_backlight_power = true, - .wmi_backlight_set_devstate = true, -}; - -static struct quirk_entry quirk_asus_ga502i = { - .wmi_backlight_power = true, - .wmi_backlight_set_devstate = true, -}; -static struct quirk_entry quirk_asus_use_kbd_dock_devid = { .use_kbd_dock_devid = true, };@@ -430,78 +420,6 @@ static const struct dmi_system_id asus_quirks[] = { }, .driver_data = &quirk_asus_forceals, }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA401IH", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA401IH"), - }, - .driver_data = &quirk_asus_ga401i, - }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA401II", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA401II"), - }, - .driver_data = &quirk_asus_ga401i, - }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA401IU", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA401IU"), - }, - .driver_data = &quirk_asus_ga401i, - }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA401IV", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA401IV"), - }, - .driver_data = &quirk_asus_ga401i, - }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA401IVC", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA401IVC"), - }, - .driver_data = &quirk_asus_ga401i, - }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA502II", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA502II"), - }, - .driver_data = &quirk_asus_ga502i, - }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA502IU", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA502IU"), - }, - .driver_data = &quirk_asus_ga502i, - }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA502IV", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA502IV"), - }, - .driver_data = &quirk_asus_ga502i, - }, { .callback = dmi_matched, .ident = "Asus Transformer T100TA / T100HA / T100CHI",
Re: [PATCH AUTOSEL 5.13 31/59] platform/x86: asus-nb-wmi: Revert "add support for ASUS ROG Zephyrus G14 and G15"
Hi,
Quoted 25 lines · Hans de Goede
Hi,
Quoted 17 lines · Sasha Levin
From: "Luke D. Jones" <[email protected]>
[ Upstream commit
28117f3a5c3c8375a3304af76357d5bf9cf30f0b]The quirks added to asus-nb-wmi for the ASUS ROG Zephyrus G14 and G15 are wrong, they tell the asus-wmi code to use the vendor specific WMI backlight interface. But there is no such interface on these laptops.
As a side effect, these quirks stop the
acpi_videodriver to register since they makeacpi_video_get_backlight_type()returnacpi_backlight_vendor, leaving only the native AMD backlight driver in place, which is the one we want. This happy coincidence is being replaced with a new quirk indrivers/acpi/video_detect.cwhich actually sets thebacklight_typetoacpi_backlight_nativefixinf this properly. This reverts
commit13bceda68fb9("platform/x86: asus-nb-wmi: add support for ASUS ROG Zephyrus G14 and G15").Quoted 4 lines
Signed-off-by Luke D. Jones <[email protected]>Signed-off-by Hans de Goede <[email protected]>Signed-off-by Sasha Levin <[email protected]>
Quoted 6 lines
Note this should only be cherry-picked if commit
2dfbacc65d1d("ACPI: video: use native backlight for GA401/GA502/GA503"):
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=2dfbacc65d1d2eae587ccb6b93f6280542641858Is also being cherry-picked, since the quirk added in that commit replaces the quirks which are being reverted here.
p.s.
The same remark also replies to the 5.12 and 5.10 cherry-picks of this commit.
Quoted 105 lines
Quoted 105 lines
--- drivers/platform/x86/asus-nb-wmi.c | 82 ------------------------------ 1 file changed, 82 deletions(-)drivers/platform/x86/asus-nb-wmi.c +0
-82@@ -110,16 +110,6 @@ static struct quirk_entry quirk_asus_forceals = { .wmi_force_als_set = true, }; -static struct quirk_entry quirk_asus_ga401i = { - .wmi_backlight_power = true, - .wmi_backlight_set_devstate = true, -}; - -static struct quirk_entry quirk_asus_ga502i = { - .wmi_backlight_power = true, - .wmi_backlight_set_devstate = true, -}; -static struct quirk_entry quirk_asus_use_kbd_dock_devid = { .use_kbd_dock_devid = true, };@@ -430,78 +420,6 @@ static const struct dmi_system_id asus_quirks[] = { }, .driver_data = &quirk_asus_forceals, }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA401IH", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA401IH"), - }, - .driver_data = &quirk_asus_ga401i, - }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA401II", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA401II"), - }, - .driver_data = &quirk_asus_ga401i, - }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA401IU", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA401IU"), - }, - .driver_data = &quirk_asus_ga401i, - }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA401IV", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA401IV"), - }, - .driver_data = &quirk_asus_ga401i, - }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA401IVC", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA401IVC"), - }, - .driver_data = &quirk_asus_ga401i, - }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA502II", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA502II"), - }, - .driver_data = &quirk_asus_ga502i, - }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA502IU", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA502IU"), - }, - .driver_data = &quirk_asus_ga502i, - }, - { - .callback = dmi_matched, - .ident = "ASUSTeK COMPUTER INC. GA502IV", - .matches = { -DMI_MATCH (DMI_SYS_VENDOR ,"ASUSTeK COMPUTER INC." ), - DMI_MATCH(DMI_PRODUCT_NAME, "GA502IV"), - }, - .driver_data = &quirk_asus_ga502i, - }, { .callback = dmi_matched, .ident = "Asus Transformer T100TA / T100HA / T100CHI",
Sasha Levin
maintainerRe: [PATCH AUTOSEL 5.13 31/59] platform/x86: asus-nb-wmi: Revert "add support for ASUS ROG Zephyrus G14 and G15"
Quoted 32 lines · Hans de Goede
Hi,
Quoted 29 lines · Hans de Goede
Hi,
Quoted 17 lines · Sasha Levin
From: "Luke D. Jones" <[email protected]>
[ Upstream commit
28117f3a5c3c8375a3304af76357d5bf9cf30f0b]The quirks added to asus-nb-wmi for the ASUS ROG Zephyrus G14 and G15 are wrong, they tell the asus-wmi code to use the vendor specific WMI backlight interface. But there is no such interface on these laptops.
As a side effect, these quirks stop the
acpi_videodriver to register since they makeacpi_video_get_backlight_type()returnacpi_backlight_vendor, leaving only the native AMD backlight driver in place, which is the one we want. This happy coincidence is being replaced with a new quirk indrivers/acpi/video_detect.cwhich actually sets thebacklight_typetoacpi_backlight_nativefixinf this properly. This reverts
commit13bceda68fb9("platform/x86: asus-nb-wmi: add support for ASUS ROG Zephyrus G14 and G15").Quoted 4 lines
Signed-off-by Luke D. Jones <[email protected]>Signed-off-by Hans de Goede <[email protected]>Signed-off-by Sasha Levin <[email protected]>Note this should only be cherry-picked if commit
2dfbacc65d1d("ACPI: video: use native backlight for GA401/GA502/GA503"):
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=2dfbacc65d1d2eae587ccb6b93f6280542641858
Quoted 7 lines
Quoted 2 lines
Is also being cherry-picked, since the quirk added in that commit replaces the quirks which are being reverted here.
p.s.
The same remark also replies to the 5.12 and 5.10 cherry-picks of this commit.
I'll take it too, thanks!
Signature · 2 lines
Thanks, Sasha
Sasha Levin
maintainerPATCH 32/59 platform/x86: toshiba_acpi: Fix missing error code in toshiba_acpi_setup_keyboard()
In reply to Sasha LevinFrom: Jiapeng Chong <[email protected]>
[ Upstream commit 28e367127718a9cb85d615a71e152f7acee41bfc ]
The error code is missing in this code scenario, add the error code '-EINVAL' to the return value 'error'.
Eliminate the follow smatch warning:
drivers/platform/x86/toshiba_acpi.c:2834 toshiba_acpi_setup_keyboard()
warn: missing error code 'error'.
--- drivers/platform/x86/toshiba_acpi.c | 1 + 1 file changed, 1 insertion(+)
drivers/platform/x86/toshiba_acpi.c +1 -0
@@ -2831,6 +2831,7 @@ static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev)if (!dev->info_supported && !dev->system_event_supported) {pr_warn ("No hotkey query interface found\n" ); + error = -EINVAL ; goto err_remove_filter; }
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 33/59 nvme-pci: fix var. type for increasing cq_head
In reply to Sasha LevinFrom: JK Kim <[email protected]>
[ Upstream commit a0aac973a26d1ac814b9e131e209eb39472a67ce ]
nvmeq->cq_head is compared with nvmeq->q_depth and changed the value and cq_phase for handling the next cq db.
but, nvmeq->q_depth's type is u32 and max. value is 0x10000 when CQP.MSQE is 0xffff and io_queue_depth is 0x10000.
current temp. variable for comparing with nvmeq->q_depth is overflowed when previous nvmeq->cq_head is 0xffff.
in this case, nvmeq->cq_phase is not updated.
so, fix data type for temp. variable to u32.
--- drivers/nvme/host/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/pci.c +1 -1
@@ -1032,7 +1032,7 @@ static inline void nvme_handle_cqe(struct nvme_queue *nvmeq, u16 idx)static inline void nvme_update_cq_head (struct nvme_queue *nvmeq) { -u16 tmp = nvmeq->cq_head +1 ; +u32 tmp = nvmeq->cq_head +1 ;if (tmp == nvmeq->q_depth) { nvmeq->cq_head =0 ;
Signature · 7 lines
2.30.2 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Sasha Levin
maintainerPATCH 34/59 nvmet-fc: do not check for invalid target port in nvmet_fc_handle_fcp_rqst()
In reply to Sasha LevinFrom: Hannes Reinecke <[email protected]>
[ Upstream commit 2a4a910aa4f0acc428dc8d10227c42e14ed21d10 ]
When parsing a request in nvmet_fc_handle_fcp_rqst() we should not check for invalid target ports; if we do the command is aborted from the fcp layer, causing the host to assume a transport error. Rather we should still forward this request to the nvmet layer, which will then correctly fail the command with an appropriate error status.
--- drivers/nvme/target/fc.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/nvme/target/fc.c +2 -8
@@ -2510,13 +2510,6 @@ nvmet_fc_handle_fcp_rqst(struct nvmet_fc_tgtport *tgtport,u32 xfrlen =be32_to_cpu (cmdiu->data_len);int ret; -/* -* if there is no nvmet mapping to the targetport there -* shouldn't be requests. just terminate them. -*/ -if (!tgtport->pe) - goto transport_error; -/* * Fused commands are currently not supported in the linux * implementation.
@@ -2544,7 +2537,8 @@ nvmet_fc_handle_fcp_rqst(struct nvmet_fc_tgtport *tgtport, fod->req.cmd = &fod->cmdiubuf.sqe; fod->req.cqe = &fod->rspiubuf.cqe; - fod->req.port = tgtport->pe->port; +if (tgtport->pe) + fod->req.port = tgtport->pe->port;/* clear any response payload */ memset (&fod->rspiubuf,0 ,sizeof (fod->rspiubuf));
Signature · 7 lines
2.30.2 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Sasha Levin
maintainerPATCH 35/59 EDAC/Intel: Do not load EDAC driver when running as a guest
In reply to Sasha LevinFrom: "Luck, Tony" <[email protected]>
[ Upstream commit f0a029fff4a50eb01648810a77ba1873e829fdd4 ]
There's little to no point in loading an EDAC driver running in a guest:
1) The CPU model reported by CPUID may not represent actual h/w
2) The hypervisor likely does not pass in access to memory controller devices
3) Hypervisors generally do not pass corrected error details to guests
Add a check in each of the Intel EDAC drivers for X86_FEATURE_HYPERVISOR and simply return -ENODEV in the init routine.
--- drivers/edac/i10nm_base.c | 3 +++ drivers/edac/pnd2_edac.c | 3 +++ drivers/edac/sb_edac.c | 3 +++ drivers/edac/skx_base.c | 3 +++ 4 files changed, 12 insertions(+)
drivers/edac/i10nm_base.c +3 -0
@@ -278,6 +278,9 @@ static int __init i10nm_init(void)if (owner &&strncmp (owner,EDAC_MOD_STR ,sizeof (EDAC_MOD_STR )))return -EBUSY ; +if (cpu_feature_enabled (X86_FEATURE_HYPERVISOR )) +return -ENODEV ; + id =x86_match_cpu (i10nm_cpuids);if (!id)return -ENODEV ;
drivers/edac/pnd2_edac.c +3 -0
@@ -1554,6 +1554,9 @@ static int __init pnd2_init(void)if (owner &&strncmp (owner,EDAC_MOD_STR ,sizeof (EDAC_MOD_STR )))return -EBUSY ; +if (cpu_feature_enabled (X86_FEATURE_HYPERVISOR )) +return -ENODEV ; + id =x86_match_cpu (pnd2_cpuids);if (!id)return -ENODEV ;
drivers/edac/sb_edac.c +3 -0
@@ -3510,6 +3510,9 @@ static int __init sbridge_init(void)if (owner &&strncmp (owner,EDAC_MOD_STR ,sizeof (EDAC_MOD_STR )))return -EBUSY ; +if (cpu_feature_enabled (X86_FEATURE_HYPERVISOR )) +return -ENODEV ; + id =x86_match_cpu (sbridge_cpuids);if (!id)return -ENODEV ;
drivers/edac/skx_base.c +3 -0
@@ -656,6 +656,9 @@ static int __init skx_init(void)if (owner &&strncmp (owner,EDAC_MOD_STR ,sizeof (EDAC_MOD_STR )))return -EBUSY ; +if (cpu_feature_enabled (X86_FEATURE_HYPERVISOR )) +return -ENODEV ; + id =x86_match_cpu (skx_cpuids);if (!id)return -ENODEV ;
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 36/59 tools/power/x86/intel-speed-select: Fix uncore memory frequency display
In reply to Sasha LevinFrom: Srinivas Pandruvada <[email protected]>
[ Upstream commit 159f130f60f402273b235801d1fde3fc115c6795 ]
The uncore memory frequency value from the mailbox command CONFIG_TDP_GET_MEM_FREQ needs to be scaled based on the platform for display. There is no single constant multiplier.
This change introduces CPU model specific memory frequency multiplier.
--- tools/power/x86/intel-speed-select/isst-config.c | 16 ++++++++++++++++ tools/power/x86/intel-speed-select/isst-core.c | 15 +++++++++++++++ .../power/x86/intel-speed-select/isst-display.c | 2 +- tools/power/x86/intel-speed-select/isst.h | 2 ++ 4 files changed, 34 insertions(+), 1 deletion(-)
tools/power/x86/intel-speed-select/isst-config.c +16 -0
@@ -106,6 +106,22 @@ int is_skx_based_platform(void)return 0 ; } +int is_spr_platform (void ) +{ +if (cpu_model ==0x8F ) +return 1 ; + +return 0 ; +} + +int is_icx_platform (void ) +{ +if (cpu_model ==0x6A || cpu_model ==0x6C ) +return 1 ; + +return 0 ; +} +static int update_cpu_model (void ) {unsigned int ebx, ecx, edx;
tools/power/x86/intel-speed-select/isst-core.c +15 -0
@@ -201,6 +201,7 @@ void isst_get_uncore_mem_freq(int cpu, int config_index, {unsigned int resp;int ret; + ret =isst_send_mbox_command (cpu,CONFIG_TDP ,CONFIG_TDP_GET_MEM_FREQ ,0 , config_index, &resp);if (ret) {
@@ -209,6 +210,20 @@ void isst_get_uncore_mem_freq(int cpu, int config_index, } ctdp_level->mem_freq = resp &GENMASK (7 ,0 ); +if (is_spr_platform ()) { + ctdp_level->mem_freq *=200 ; + }else if (is_icx_platform ()) { +if (ctdp_level->mem_freq <7 ) { + ctdp_level->mem_freq = (12 - ctdp_level->mem_freq) *133.33 *2 *10 ; + ctdp_level->mem_freq /=10 ; +if (ctdp_level->mem_freq %10 >5 ) + ctdp_level->mem_freq++; + }else { + ctdp_level->mem_freq =0 ; + } + }else { + ctdp_level->mem_freq =0 ; + }debug_printf ("cpu:%d ctdp:%d CONFIG_TDP_GET_MEM_FREQ resp:%x uncore mem_freq:%d\n" , cpu, config_index, resp, ctdp_level->mem_freq);
tools/power/x86/intel-speed-select/isst-display.c +1 -1
@@ -446,7 +446,7 @@ void isst_ctdp_display_information(int cpu, FILE *outf, int tdp_level,if (ctdp_level->mem_freq) {snprintf (header,sizeof (header),"mem-frequency(MHz)" );snprintf (value,sizeof (value),"%d" , - ctdp_level->mem_freq *DISP_FREQ_MULTIPLIER ); + ctdp_level->mem_freq);format_and_print (outf, level +2 , header, value); }
tools/power/x86/intel-speed-select/isst.h +2 -0
@@ -257,5 +257,7 @@ extern int get_cpufreq_base_freq(int cpu);extern int isst_read_pm_config (int cpu,int *cp_state,int *cp_cap);extern void isst_display_error_info_message (int error,char *msg,int arg_valid,int arg);extern int is_skx_based_platform (void ); +extern int is_spr_platform (void ); +extern int is_icx_platform (void );extern void isst_trl_display_information (int cpu,FILE *outf,unsigned long long trl);#endif
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 37/59 PCI: hv: Add check for hyperv_initialized in init_hv_pci_drv()
In reply to Sasha LevinFrom: Haiyang Zhang <[email protected]>
[ Upstream commit 7d815f4afa87f2032b650ae1bba7534b550a6b8b ]
Add check for hv_is_hyperv_initialized() at the top of init_hv_pci_drv(), so if the pci-hyperv driver is force-loaded on non Hyper-V platforms, the init_hv_pci_drv() will exit immediately, without any side effects, like assignments to hvpci_block_ops, etc.
--- drivers/pci/controller/pci-hyperv.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/pci/controller/pci-hyperv.c +3 -0
@@ -3476,6 +3476,9 @@ static void __exit exit_hv_pci_drv(void)static int __init init_hv_pci_drv (void ) { +if (!hv_is_hyperv_initialized ()) +return -ENODEV ; +/* Set the invalid domain number's bit, so it will not be used */ set_bit (HVPCI_DOM_INVALID , hvpci_dom_map);
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 38/59 cifs: improve fallocate emulation
In reply to Sasha LevinFrom: Ronnie Sahlberg <[email protected]>
[ Upstream commit 966a3cb7c7db786452a87afdc3b48858fc4d4d6b ]
RHBZ: 1866684
We don't have a real fallocate in the SMB2 protocol so we used to emulate fallocate by simply switching the file to become non-sparse. But as that could potantially consume a lot more data than we intended to fallocate (large sparse file and fallocating a thin slice in the middle) we would only do this IFF the fallocate request was for virtually the entire file.
This patch improves this and starts allowing us to fallocate smaller chunks of a file by overwriting the region with 0, for the parts that are unallocated.
The method used is to first query the server for FSCTL_QUERY_ALLOCATED_RANGES to find what is unallocated in the fallocate range and then to only overwrite-with-zero the unallocated ranges to fill in the holes.
As overwriting-with-zero is different from just allocating blocks, and potentially much more expensive, we limit this to only allow fallocate ranges up to 1Mb in size.
--- fs/cifs/smb2ops.c | 133 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+)
fs/cifs/smb2ops.c +133 -0
@@ -3601,6 +3601,119 @@ static long smb3_punch_hole(struct file *file, struct cifs_tcon *tcon,return rc; } +static int smb3_simple_fallocate_write_range (unsigned int xid, +struct cifs_tcon *tcon, +struct cifsFileInfo *cfile, +loff_t off,loff_t len, +char *buf) +{ +struct cifs_io_parms io_parms = {0 }; +int nbytes; +struct kvec iov[2 ]; + + io_parms.netfid = cfile->fid.netfid; + io_parms.pid = current->tgid; + io_parms.tcon = tcon; + io_parms.persistent_fid = cfile->fid.persistent_fid; + io_parms.volatile_fid = cfile->fid.volatile_fid; + io_parms.offset = off; + io_parms.length = len; + +/* iov[0] is reserved for smb header */ + iov[1 ].iov_base = buf; + iov[1 ].iov_len = io_parms.length; +return SMB2_write (xid, &io_parms, &nbytes, iov,1 ); +} + +static int smb3_simple_fallocate_range (unsigned int xid, +struct cifs_tcon *tcon, +struct cifsFileInfo *cfile, +loff_t off,loff_t len) +{ +struct file_allocated_range_buffer in_data, *out_data =NULL , *tmp_data; +u32 out_data_len; +char *buf =NULL ; +loff_t l; +int rc; + + in_data.file_offset =cpu_to_le64 (off); + in_data.length =cpu_to_le64 (len); + rc =SMB2_ioctl (xid, tcon, cfile->fid.persistent_fid, + cfile->fid.volatile_fid, +FSCTL_QUERY_ALLOCATED_RANGES , true, + (char *)&in_data,sizeof (in_data), +1024 *sizeof (struct file_allocated_range_buffer ), + (char **)&out_data, &out_data_len); +if (rc) + goto out; +/* +* It is already all allocated +*/ +if (out_data_len ==0 ) + goto out; + + buf =kzalloc (1024 *1024 ,GFP_KERNEL ); +if (buf ==NULL ) { + rc = -ENOMEM ; + goto out; + } + + tmp_data = out_data; +while (len) { +/* +* The rest of the region is unmapped so write it all. +*/ +if (out_data_len ==0 ) { + rc =smb3_simple_fallocate_write_range (xid, tcon, + cfile, off, len, buf); + goto out; + } + +if (out_data_len <sizeof (struct file_allocated_range_buffer )) { + rc = -EINVAL ; + goto out; + } + +if (off <le64_to_cpu (tmp_data->file_offset)) { +/* +* We are at a hole. Write until the end of the region +* or until the next allocated data, +* whichever comes next. +*/ + l =le64_to_cpu (tmp_data->file_offset) - off; +if (len < l) + l = len; + rc =smb3_simple_fallocate_write_range (xid, tcon, + cfile, off, l, buf); +if (rc) + goto out; + off = off + l; + len = len - l; +if (len ==0 ) + goto out; + } +/* +* We are at a section of allocated data, just skip forward +* until the end of the data or the end of the region +* we are supposed to fallocate, whichever comes first. +*/ + l =le64_to_cpu (tmp_data->length); +if (len < l) + l = len; + off += l; + len -= l; + + tmp_data = &tmp_data[1 ]; + out_data_len -=sizeof (struct file_allocated_range_buffer ); + } + + out: +kfree (out_data); +kfree (buf); +return rc; +} + +static long smb3_simple_falloc (struct file *file,struct cifs_tcon *tcon,loff_t off,loff_t len,bool keep_size) {
@@ -3661,6 +3774,26 @@ static long smb3_simple_falloc(struct file *file, struct cifs_tcon *tcon, }if ((keep_size == true) || (i_size_read (inode) >= off + len)) { +/* +* At this point, we are trying to fallocate an internal +* regions of a sparse file. Since smb2 does not have a +* fallocate command we have two otions on how to emulate this. +* We can either turn the entire file to become non-sparse +* which we only do if the fallocate is for virtually +* the whole file, or we can overwrite the region with zeroes +* using SMB2_write, which could be prohibitevly expensive +* if len is large. +*/ +/* +* We are only trying to fallocate a small region so +* just write it with zero. +*/ +if (len <=1024 *1024 ) { + rc =smb3_simple_fallocate_range (xid, tcon, cfile, + off, len); + goto out; + } +/* * Check if falloc starts within first few pages of file * and ends within a few pages of the end of file to
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 39/59 cifs: fix check of dfs interlinks
In reply to Sasha LevinFrom: Paulo Alcantara <[email protected]>
[ Upstream commit 889c2a700799f3b6f82210925e1faf4a9b833c4a ]
Interlink is a special type of DFS link that resolves to a different DFS domain-based namespace. To determine whether it is an interlink or not, check if ReferralServers and StorageServers bits are set to 1 and 0 respectively in ReferralHeaderFlags, as specified in MS-DFSC 3.1.5.4.5 Determining Whether a Referral Response is an Interlink.
--- fs/cifs/dfs_cache.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
fs/cifs/dfs_cache.c +3 -4
@@ -25,8 +25,7 @@#define CACHE_HTABLE_SIZE 32#define CACHE_MAX_ENTRIES 64 -#define IS_INTERLINK_SET (v) ((v) & (DFSREF_REFERRAL_SERVER | \ - DFSREF_STORAGE_SERVER)) +#define IS_DFS_INTERLINK (v) (((v) & DFSREF_REFERRAL_SERVER) && !((v) & DFSREF_STORAGE_SERVER))struct cache_dfs_tgt {char *name;
@@ -171,7 +170,7 @@ static int dfscache_proc_show(struct seq_file *m, void *v)"cache entry: path=%s,type=%s,ttl=%d,etime=%ld,hdr_flags=0x%x,ref_flags=0x%x,interlink=%s,path_consumed=%d,expired=%s\n" , ce->path, ce->srvtype ==DFS_TYPE_ROOT ?"root" :"link" , ce->ttl, ce->etime.tv_nsec, ce->ref_flags, ce->hdr_flags, -IS_INTERLINK_SET (ce->hdr_flags) ?"yes" :"no" , +IS_DFS_INTERLINK (ce->hdr_flags) ?"yes" :"no" , ce->path_consumed, cache_entry_expired(ce) ? "yes" : "no");list_for_each_entry (t, &ce->tlist, list) {
@@ -240,7 +239,7 @@ static inline void dump_ce(const struct cache_entry *ce) ce->srvtype ==DFS_TYPE_ROOT ?"root" :"link" , ce->ttl, ce->etime.tv_nsec, ce->hdr_flags, ce->ref_flags, -IS_INTERLINK_SET (ce->hdr_flags) ?"yes" :"no" , +IS_DFS_INTERLINK (ce->hdr_flags) ?"yes" :"no" , ce->path_consumed, cache_entry_expired(ce) ? "yes" : "no");dump_tgts (ce);
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 40/59 cifs: retry lookup and readdir when EAGAIN is returned.
In reply to Sasha LevinFrom: Thiago Rafael Becker <[email protected]>
[ Upstream commit 6efa994e35a402ae4ae2161b6439c94b64816cee ]
According to the investigation performed by Jacob Shivers at Red Hat, cifs_lookup and cifs_readdir leak EAGAIN when the user session is deleted on the server. Fix this issue by implementing a retry with limits, as is implemented in cifs_revalidate_dentry_attr.
Reproducer based on the work by Jacob Shivers:
~~~
$ cat readdir-cifs-test.sh #!/bin/bash
# Install and configure powershell and sshd on the windows
# server as descibed in
# https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_overview
# This script uses expect(1)
USER=dude
SERVER=192.168.0.2
RPATH=root
PASS='password'
function debug_funcs {
for line in $@ ; do
echo "func $line +p" > /sys/kernel/debug/dynamic_debug/control
done
}
function setup {
echo 1 > /proc/fs/cifs/cifsFYI
debug_funcs wait_for_compound_request \
smb2_query_dir_first cifs_readdir \
compound_send_recv cifs_reconnect_tcon \
generic_ip_connect cifs_reconnect \
smb2_reconnect_server smb2_reconnect \
cifs_readv_from_socket cifs_readv_receive
tcpdump -i eth0 -w cifs.pcap host 192.168.2.182 & sleep 5
dmesg -C
}
function test_call {
if [[ $1 == 1 ]] ; then
tracer="strace -tt -f -s 4096 -o trace-$(date -Iseconds).txt"
fi
# Change the command here to anything appropriate
$tracer ls $2 > /dev/null
res=$?
if [[ $1 == 1 ]] ; then
if [[ $res == 0 ]] ; then
1>&2 echo success
else
1>&2 echo "failure ($res)"
fi
fi
}
mountpoint /mnt > /dev/null || mount -t cifs -o username=$USER,pass=$PASS //$SERVER/$RPATH /mnt test_call 0 /mnt/
/usr/bin/expect << EOF
set timeout 60
spawn ssh $USER@$SERVER
expect "yes/no" {
send "yes\r"
expect "*?assword" { send "$PASS\r" }
} "*?assword" { send "$PASS\r" } expect ">" { send "powershell close-smbsession -force\r" } expect ">" { send "exit\r" }
expect eof
EOF
sysctl -w vm.drop_caches=2 > /dev/null
sysctl -w vm.drop_caches=2 > /dev/null
setup
test_call 1 /mnt/
~~~
--- fs/cifs/dir.c | 4 ++++ fs/cifs/smb2ops.c | 5 +++++ 2 files changed, 9 insertions(+)
fs/cifs/dir.c +4 -0
@@ -630,6 +630,7 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,struct inode *newInode =NULL ;const char *full_path;void *page; +int retry_count =0 ; xid =get_xid ();
@@ -673,6 +674,7 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,cifs_dbg (FYI ,"Full path: %s inode = 0x%p\n" , full_path,d_inode (direntry)); +again:if (pTcon->posix_extensions) rc =smb311_posix_get_inode_info (&newInode, full_path, parent_dir_inode->i_sb, xid);else if (pTcon->unix_ext) {
@@ -687,6 +689,8 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,/* since paths are not looked up by component - the parent directories are presumed to be good here */ renew_parental_timestamps (direntry); + }else if (rc == -EAGAIN && retry_count++ <10 ) { + goto again; }else if (rc == -ENOENT ) {cifs_set_time (direntry, jiffies); newInode =NULL ;
fs/cifs/smb2ops.c +5 -0
@@ -2325,6 +2325,7 @@ smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon,struct smb2_query_directory_rsp *qd_rsp =NULL ;struct smb2_create_rsp *op_rsp =NULL ;struct TCP_Server_Info *server =cifs_pick_channel (tcon->ses); +int retry_count =0 ; utf16_path =cifs_convert_path_to_utf16 (path, cifs_sb);if (!utf16_path)
@@ -2372,10 +2373,14 @@ smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon,smb2_set_related (&rqst[1 ]); +again: rc =compound_send_recv (xid, tcon->ses, server, flags,2 , rqst, resp_buftype, rsp_iov); +if (rc == -EAGAIN && retry_count++ <10 ) + goto again; +/* If the open failed there is nothing to do */ op_rsp = (struct smb2_create_rsp *)rsp_iov[0 ].iov_base;if (op_rsp ==NULL || op_rsp->sync_hdr.Status !=STATUS_SUCCESS ) {
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 41/59 smb3: fix uninitialized value for port in witness protocol move
In reply to Sasha LevinFrom: Steve French <[email protected]>
[ Upstream commit ff93b71a3eff25fe9d4364ef13b6e01d935600c6 ]
Although in practice this can not occur (since IPv4 and IPv6 are the only two cases currently supported), it is cleaner to avoid uninitialized variable warnings.
Addresses smatch warning:
fs/cifs/cifs_swn.c:468 cifs_swn_store_swn_addr() error: uninitialized symbol 'port'.
--- fs/cifs/cifs_swn.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
fs/cifs/cifs_swn.c +3 -7
@@ -447,15 +447,13 @@ static int cifs_swn_store_swn_addr(const struct sockaddr_storage *new,const struct sockaddr_storage *old, struct sockaddr_storage *dst) { - __be16 port; + __be16 port = cpu_to_be16(CIFS_PORT);if (old->ss_family ==AF_INET ) {struct sockaddr_in *ipv4 = (struct sockaddr_in *)old; port = ipv4->sin_port; - } - -if (old->ss_family ==AF_INET6 ) { + }else if (old->ss_family ==AF_INET6 ) {struct sockaddr_in6 *ipv6 = (struct sockaddr_in6 *)old; port = ipv6->sin6_port;
@@ -465,9 +463,7 @@ static int cifs_swn_store_swn_addr(const struct sockaddr_storage *new,struct sockaddr_in *ipv4 = (struct sockaddr_in *)new; ipv4->sin_port = port; - } - -if (new->ss_family ==AF_INET6 ) { + }else if (new->ss_family ==AF_INET6 ) {struct sockaddr_in6 *ipv6 = (struct sockaddr_in6 *)new; ipv6->sin6_port = port;
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 42/59 cifs: fix SMB1 error path in cifs_get_file_info_unix
In reply to Sasha LevinFrom: Steve French <[email protected]>
[ Upstream commit e39df24169a2ceb0d359eb3a05ff982711f2eb32 ]
We were trying to fill in uninitialized file attributes in the error case.
Addresses-Coverity: 139689 ("Uninitialized variables")
--- fs/cifs/inode.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/cifs/inode.c +4 -1
@@ -367,9 +367,12 @@ cifs_get_file_info_unix(struct file *filp) }else if (rc == -EREMOTE ) {cifs_create_dfs_fattr (&fattr, inode->i_sb); rc =0 ; - } + }else + goto cifs_gfiunix_out; rc =cifs_fattr_to_inode (inode, &fattr); + +cifs_gfiunix_out:free_xid (xid);return rc; }
Signature · 1 line
2.30.2