From: Greg Kroah-Hartman Date: Thu, 11 Aug 2022 14:12:23 +0000 (+0200) Subject: 5.10-stable patches X-Git-Tag: v5.15.61~218 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=96a5b4e61efc3c647f3e1821ef7c78647a1e4fd5;p=thirdparty%2Fkernel%2Fstable-queue.git 5.10-stable patches added patches: add-barriers-to-buffer_uptodate-and-set_buffer_uptodate.patch hid-wacom-don-t-register-pad_input-for-touch-switch.patch hid-wacom-only-report-rotation-for-art-pen.patch --- diff --git a/queue-5.10/add-barriers-to-buffer_uptodate-and-set_buffer_uptodate.patch b/queue-5.10/add-barriers-to-buffer_uptodate-and-set_buffer_uptodate.patch new file mode 100644 index 00000000000..10da72ef68e --- /dev/null +++ b/queue-5.10/add-barriers-to-buffer_uptodate-and-set_buffer_uptodate.patch @@ -0,0 +1,77 @@ +From d4252071b97d2027d246f6a82cbee4d52f618b47 Mon Sep 17 00:00:00 2001 +From: Mikulas Patocka +Date: Tue, 9 Aug 2022 14:32:13 -0400 +Subject: add barriers to buffer_uptodate and set_buffer_uptodate + +From: Mikulas Patocka + +commit d4252071b97d2027d246f6a82cbee4d52f618b47 upstream. + +Let's have a look at this piece of code in __bread_slow: + + get_bh(bh); + bh->b_end_io = end_buffer_read_sync; + submit_bh(REQ_OP_READ, 0, bh); + wait_on_buffer(bh); + if (buffer_uptodate(bh)) + return bh; + +Neither wait_on_buffer nor buffer_uptodate contain any memory barrier. +Consequently, if someone calls sb_bread and then reads the buffer data, +the read of buffer data may be executed before wait_on_buffer(bh) on +architectures with weak memory ordering and it may return invalid data. + +Fix this bug by adding a memory barrier to set_buffer_uptodate and an +acquire barrier to buffer_uptodate (in a similar way as +folio_test_uptodate and folio_mark_uptodate). + +Signed-off-by: Mikulas Patocka +Reviewed-by: Matthew Wilcox (Oracle) +Cc: stable@vger.kernel.org +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman +--- + include/linux/buffer_head.h | 25 ++++++++++++++++++++++++- + 1 file changed, 24 insertions(+), 1 deletion(-) + +--- a/include/linux/buffer_head.h ++++ b/include/linux/buffer_head.h +@@ -117,7 +117,6 @@ static __always_inline int test_clear_bu + * of the form "mark_buffer_foo()". These are higher-level functions which + * do something in addition to setting a b_state bit. + */ +-BUFFER_FNS(Uptodate, uptodate) + BUFFER_FNS(Dirty, dirty) + TAS_BUFFER_FNS(Dirty, dirty) + BUFFER_FNS(Lock, locked) +@@ -135,6 +134,30 @@ BUFFER_FNS(Meta, meta) + BUFFER_FNS(Prio, prio) + BUFFER_FNS(Defer_Completion, defer_completion) + ++static __always_inline void set_buffer_uptodate(struct buffer_head *bh) ++{ ++ /* ++ * make it consistent with folio_mark_uptodate ++ * pairs with smp_load_acquire in buffer_uptodate ++ */ ++ smp_mb__before_atomic(); ++ set_bit(BH_Uptodate, &bh->b_state); ++} ++ ++static __always_inline void clear_buffer_uptodate(struct buffer_head *bh) ++{ ++ clear_bit(BH_Uptodate, &bh->b_state); ++} ++ ++static __always_inline int buffer_uptodate(const struct buffer_head *bh) ++{ ++ /* ++ * make it consistent with folio_test_uptodate ++ * pairs with smp_mb__before_atomic in set_buffer_uptodate ++ */ ++ return (smp_load_acquire(&bh->b_state) & (1UL << BH_Uptodate)) != 0; ++} ++ + #define bh_offset(bh) ((unsigned long)(bh)->b_data & ~PAGE_MASK) + + /* If we *know* page->private refers to buffer_heads */ diff --git a/queue-5.10/hid-wacom-don-t-register-pad_input-for-touch-switch.patch b/queue-5.10/hid-wacom-don-t-register-pad_input-for-touch-switch.patch new file mode 100644 index 00000000000..1af118ee109 --- /dev/null +++ b/queue-5.10/hid-wacom-don-t-register-pad_input-for-touch-switch.patch @@ -0,0 +1,107 @@ +From d6b675687a4ab4dba684716d97c8c6f81bf10905 Mon Sep 17 00:00:00 2001 +From: Ping Cheng +Date: Fri, 13 May 2022 14:52:37 -0700 +Subject: HID: wacom: Don't register pad_input for touch switch + +From: Ping Cheng + +commit d6b675687a4ab4dba684716d97c8c6f81bf10905 upstream. + +Touch switch state is received through WACOM_PAD_FIELD. However, it +is reported by touch_input. Don't register pad_input if no other pad +events require the interface. + +Cc: stable@vger.kernel.org +Signed-off-by: Ping Cheng +Reviewed-by: Jason Gerecke +Signed-off-by: Jiri Kosina +Signed-off-by: Greg Kroah-Hartman +--- + drivers/hid/wacom_sys.c | 2 +- + drivers/hid/wacom_wac.c | 43 +++++++++++++++++++++++++------------------ + 2 files changed, 26 insertions(+), 19 deletions(-) + +--- a/drivers/hid/wacom_sys.c ++++ b/drivers/hid/wacom_sys.c +@@ -2124,7 +2124,7 @@ static int wacom_register_inputs(struct + + error = wacom_setup_pad_input_capabilities(pad_input_dev, wacom_wac); + if (error) { +- /* no pad in use on this interface */ ++ /* no pad events using this interface */ + input_free_device(pad_input_dev); + wacom_wac->pad_input = NULL; + pad_input_dev = NULL; +--- a/drivers/hid/wacom_wac.c ++++ b/drivers/hid/wacom_wac.c +@@ -2016,7 +2016,6 @@ static void wacom_wac_pad_usage_mapping( + wacom_wac->has_mute_touch_switch = true; + usage->type = EV_SW; + usage->code = SW_MUTE_DEVICE; +- features->device_type |= WACOM_DEVICETYPE_PAD; + break; + case WACOM_HID_WD_TOUCHSTRIP: + wacom_map_usage(input, usage, field, EV_ABS, ABS_RX, 0); +@@ -2096,6 +2095,30 @@ static void wacom_wac_pad_event(struct h + wacom_wac->hid_data.inrange_state |= value; + } + ++ /* Process touch switch state first since it is reported through touch interface, ++ * which is indepentent of pad interface. In the case when there are no other pad ++ * events, the pad interface will not even be created. ++ */ ++ if ((equivalent_usage == WACOM_HID_WD_MUTE_DEVICE) || ++ (equivalent_usage == WACOM_HID_WD_TOUCHONOFF)) { ++ if (wacom_wac->shared->touch_input) { ++ bool *is_touch_on = &wacom_wac->shared->is_touch_on; ++ ++ if (equivalent_usage == WACOM_HID_WD_MUTE_DEVICE && value) ++ *is_touch_on = !(*is_touch_on); ++ else if (equivalent_usage == WACOM_HID_WD_TOUCHONOFF) ++ *is_touch_on = value; ++ ++ input_report_switch(wacom_wac->shared->touch_input, ++ SW_MUTE_DEVICE, !(*is_touch_on)); ++ input_sync(wacom_wac->shared->touch_input); ++ } ++ return; ++ } ++ ++ if (!input) ++ return; ++ + switch (equivalent_usage) { + case WACOM_HID_WD_TOUCHRING: + /* +@@ -2131,22 +2154,6 @@ static void wacom_wac_pad_event(struct h + input_event(input, usage->type, usage->code, 0); + break; + +- case WACOM_HID_WD_MUTE_DEVICE: +- case WACOM_HID_WD_TOUCHONOFF: +- if (wacom_wac->shared->touch_input) { +- bool *is_touch_on = &wacom_wac->shared->is_touch_on; +- +- if (equivalent_usage == WACOM_HID_WD_MUTE_DEVICE && value) +- *is_touch_on = !(*is_touch_on); +- else if (equivalent_usage == WACOM_HID_WD_TOUCHONOFF) +- *is_touch_on = value; +- +- input_report_switch(wacom_wac->shared->touch_input, +- SW_MUTE_DEVICE, !(*is_touch_on)); +- input_sync(wacom_wac->shared->touch_input); +- } +- break; +- + case WACOM_HID_WD_MODE_CHANGE: + if (wacom_wac->is_direct_mode != value) { + wacom_wac->is_direct_mode = value; +@@ -2776,7 +2783,7 @@ void wacom_wac_event(struct hid_device * + /* usage tests must precede field tests */ + if (WACOM_BATTERY_USAGE(usage)) + wacom_wac_battery_event(hdev, field, usage, value); +- else if (WACOM_PAD_FIELD(field) && wacom->wacom_wac.pad_input) ++ else if (WACOM_PAD_FIELD(field)) + wacom_wac_pad_event(hdev, field, usage, value); + else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input) + wacom_wac_pen_event(hdev, field, usage, value); diff --git a/queue-5.10/hid-wacom-only-report-rotation-for-art-pen.patch b/queue-5.10/hid-wacom-only-report-rotation-for-art-pen.patch new file mode 100644 index 00000000000..b0c388e594d --- /dev/null +++ b/queue-5.10/hid-wacom-only-report-rotation-for-art-pen.patch @@ -0,0 +1,88 @@ +From 7ccced33a0ba39b0103ae1dfbf7f1dffdc0a1bc2 Mon Sep 17 00:00:00 2001 +From: Ping Cheng +Date: Fri, 13 May 2022 14:51:56 -0700 +Subject: HID: wacom: Only report rotation for art pen + +From: Ping Cheng + +commit 7ccced33a0ba39b0103ae1dfbf7f1dffdc0a1bc2 upstream. + +The generic routine, wacom_wac_pen_event, turns rotation value 90 +degree anti-clockwise before posting the events. This non-zero +event trggers a non-zero ABS_Z event for non art pen tools. However, +HID_DG_TWIST is only supported by art pen. + +[jkosina@suse.cz: fix build: add missing brace] +Cc: stable@vger.kernel.org +Signed-off-by: Ping Cheng +Reviewed-by: Jason Gerecke +Signed-off-by: Jiri Kosina +Signed-off-by: Greg Kroah-Hartman +--- + drivers/hid/wacom_wac.c | 29 +++++++++++++++++++++-------- + 1 file changed, 21 insertions(+), 8 deletions(-) + +--- a/drivers/hid/wacom_wac.c ++++ b/drivers/hid/wacom_wac.c +@@ -638,9 +638,26 @@ static int wacom_intuos_id_mangle(int to + return (tool_id & ~0xFFF) << 4 | (tool_id & 0xFFF); + } + ++static bool wacom_is_art_pen(int tool_id) ++{ ++ bool is_art_pen = false; ++ ++ switch (tool_id) { ++ case 0x885: /* Intuos3 Marker Pen */ ++ case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */ ++ case 0x10804: /* Intuos4/5 13HD/24HD Art Pen */ ++ is_art_pen = true; ++ break; ++ } ++ return is_art_pen; ++} ++ + static int wacom_intuos_get_tool_type(int tool_id) + { +- int tool_type; ++ int tool_type = BTN_TOOL_PEN; ++ ++ if (wacom_is_art_pen(tool_id)) ++ return tool_type; + + switch (tool_id) { + case 0x812: /* Inking pen */ +@@ -655,12 +672,9 @@ static int wacom_intuos_get_tool_type(in + case 0x852: + case 0x823: /* Intuos3 Grip Pen */ + case 0x813: /* Intuos3 Classic Pen */ +- case 0x885: /* Intuos3 Marker Pen */ + case 0x802: /* Intuos4/5 13HD/24HD General Pen */ +- case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */ + case 0x8e2: /* IntuosHT2 pen */ + case 0x022: +- case 0x10804: /* Intuos4/5 13HD/24HD Art Pen */ + case 0x10842: /* MobileStudio Pro Pro Pen slim */ + case 0x14802: /* Intuos4/5 13HD/24HD Classic Pen */ + case 0x16802: /* Cintiq 13HD Pro Pen */ +@@ -718,10 +732,6 @@ static int wacom_intuos_get_tool_type(in + case 0x10902: /* Intuos4/5 13HD/24HD Airbrush */ + tool_type = BTN_TOOL_AIRBRUSH; + break; +- +- default: /* Unknown tool */ +- tool_type = BTN_TOOL_PEN; +- break; + } + return tool_type; + } +@@ -2312,6 +2322,9 @@ static void wacom_wac_pen_event(struct h + } + return; + case HID_DG_TWIST: ++ /* don't modify the value if the pen doesn't support the feature */ ++ if (!wacom_is_art_pen(wacom_wac->id[0])) return; ++ + /* + * Userspace expects pen twist to have its zero point when + * the buttons/finger is on the tablet's left. HID values diff --git a/queue-5.10/series b/queue-5.10/series index 74d2323f4f1..056313a33f8 100644 --- a/queue-5.10/series +++ b/queue-5.10/series @@ -8,3 +8,6 @@ alsa-hda-realtek-add-quirk-for-hp-spectre-x360-15-eb0xxx.patch wifi-mac80211_hwsim-fix-race-condition-in-pending-packet.patch wifi-mac80211_hwsim-add-back-erroneously-removed-cast.patch wifi-mac80211_hwsim-use-32-bit-skb-cookie.patch +add-barriers-to-buffer_uptodate-and-set_buffer_uptodate.patch +hid-wacom-only-report-rotation-for-art-pen.patch +hid-wacom-don-t-register-pad_input-for-touch-switch.patch