From: Greg Kroah-Hartman Date: Sun, 22 Jan 2023 13:29:23 +0000 (+0100) Subject: 4.19-stable patches X-Git-Tag: v4.14.304~33 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1683030bec307382ae4a989f7469564bcbe0fe48;p=thirdparty%2Fkernel%2Fstable-queue.git 4.19-stable patches added patches: gsmi-fix-null-deref-in-gsmi_get_variable.patch serial-atmel-fix-incorrect-baudrate-setup.patch serial-pch_uart-pass-correct-sg-to-dma_unmap_sg.patch usb-gadget-f_ncm-fix-potential-null-ptr-deref-in-ncm_bitrate.patch usb-gadget-g_webcam-send-color-matching-descriptor-per-frame.patch usb-host-ehci-fsl-fix-module-alias.patch usb-serial-cp210x-add-scalance-lpe-9000-device-id.patch usb-storage-apply-ignore_uas-only-for-hiksemi-md202-on-rtl9210.patch usb-typec-altmodes-displayport-add-pin-assignment-helper.patch usb-typec-altmodes-displayport-fix-pin-assignment-calculation.patch --- diff --git a/queue-4.19/gsmi-fix-null-deref-in-gsmi_get_variable.patch b/queue-4.19/gsmi-fix-null-deref-in-gsmi_get_variable.patch new file mode 100644 index 00000000000..722340c446e --- /dev/null +++ b/queue-4.19/gsmi-fix-null-deref-in-gsmi_get_variable.patch @@ -0,0 +1,41 @@ +From a769b05eeed7accc4019a1ed9799dd72067f1ce8 Mon Sep 17 00:00:00 2001 +From: Khazhismel Kumykov +Date: Tue, 17 Jan 2023 17:02:12 -0800 +Subject: gsmi: fix null-deref in gsmi_get_variable + +From: Khazhismel Kumykov + +commit a769b05eeed7accc4019a1ed9799dd72067f1ce8 upstream. + +We can get EFI variables without fetching the attribute, so we must +allow for that in gsmi. + +commit 859748255b43 ("efi: pstore: Omit efivars caching EFI varstore +access layer") added a new get_variable call with attr=NULL, which +triggers panic in gsmi. + +Fixes: 74c5b31c6618 ("driver: Google EFI SMI") +Cc: stable +Signed-off-by: Khazhismel Kumykov +Link: https://lore.kernel.org/r/20230118010212.1268474-1-khazhy@google.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/firmware/google/gsmi.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +--- a/drivers/firmware/google/gsmi.c ++++ b/drivers/firmware/google/gsmi.c +@@ -343,9 +343,10 @@ static efi_status_t gsmi_get_variable(ef + memcpy(data, gsmi_dev.data_buf->start, *data_size); + + /* All variables are have the following attributes */ +- *attr = EFI_VARIABLE_NON_VOLATILE | +- EFI_VARIABLE_BOOTSERVICE_ACCESS | +- EFI_VARIABLE_RUNTIME_ACCESS; ++ if (attr) ++ *attr = EFI_VARIABLE_NON_VOLATILE | ++ EFI_VARIABLE_BOOTSERVICE_ACCESS | ++ EFI_VARIABLE_RUNTIME_ACCESS; + } + + spin_unlock_irqrestore(&gsmi_dev.lock, flags); diff --git a/queue-4.19/serial-atmel-fix-incorrect-baudrate-setup.patch b/queue-4.19/serial-atmel-fix-incorrect-baudrate-setup.patch new file mode 100644 index 00000000000..8603a1f4206 --- /dev/null +++ b/queue-4.19/serial-atmel-fix-incorrect-baudrate-setup.patch @@ -0,0 +1,53 @@ +From 5bfdd3c654bd879bff50c2e85e42f85ae698b42f Mon Sep 17 00:00:00 2001 +From: Tobias Schramm +Date: Mon, 9 Jan 2023 08:29:40 +0100 +Subject: serial: atmel: fix incorrect baudrate setup + +From: Tobias Schramm + +commit 5bfdd3c654bd879bff50c2e85e42f85ae698b42f upstream. + +Commit ba47f97a18f2 ("serial: core: remove baud_rates when serial console +setup") changed uart_set_options to select the correct baudrate +configuration based on the absolute error between requested baudrate and +available standard baudrate settings. +Prior to that commit the baudrate was selected based on which predefined +standard baudrate did not exceed the requested baudrate. +This change of selection logic was never reflected in the atmel serial +driver. Thus the comment left in the atmel serial driver is no longer +accurate. +Additionally the manual rounding up described in that comment and applied +via (quot - 1) requests an incorrect baudrate. Since uart_set_options uses +tty_termios_encode_baud_rate to determine the appropriate baudrate flags +this can cause baudrate selection to fail entirely because +tty_termios_encode_baud_rate will only select a baudrate if relative error +between requested and selected baudrate does not exceed +/-2%. +Fix that by requesting actual, exact baudrate used by the serial. + +Fixes: ba47f97a18f2 ("serial: core: remove baud_rates when serial console setup") +Cc: stable +Signed-off-by: Tobias Schramm +Acked-by: Richard Genoud +Link: https://lore.kernel.org/r/20230109072940.202936-1-t.schramm@manjaro.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/tty/serial/atmel_serial.c | 8 +------- + 1 file changed, 1 insertion(+), 7 deletions(-) + +--- a/drivers/tty/serial/atmel_serial.c ++++ b/drivers/tty/serial/atmel_serial.c +@@ -2511,13 +2511,7 @@ static void __init atmel_console_get_opt + else if (mr == ATMEL_US_PAR_ODD) + *parity = 'o'; + +- /* +- * The serial core only rounds down when matching this to a +- * supported baud rate. Make sure we don't end up slightly +- * lower than one of those, as it would make us fall through +- * to a much lower baud rate than we really want. +- */ +- *baud = port->uartclk / (16 * (quot - 1)); ++ *baud = port->uartclk / (16 * quot); + } + + static int __init atmel_console_setup(struct console *co, char *options) diff --git a/queue-4.19/serial-pch_uart-pass-correct-sg-to-dma_unmap_sg.patch b/queue-4.19/serial-pch_uart-pass-correct-sg-to-dma_unmap_sg.patch new file mode 100644 index 00000000000..433f28a2253 --- /dev/null +++ b/queue-4.19/serial-pch_uart-pass-correct-sg-to-dma_unmap_sg.patch @@ -0,0 +1,41 @@ +From e8914b52e5b024e4af3d810a935fe0805eee8a36 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= +Date: Tue, 3 Jan 2023 11:34:35 +0200 +Subject: serial: pch_uart: Pass correct sg to dma_unmap_sg() +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Ilpo Järvinen + +commit e8914b52e5b024e4af3d810a935fe0805eee8a36 upstream. + +A local variable sg is used to store scatterlist pointer in +pch_dma_tx_complete(). The for loop doing Tx byte accounting before +dma_unmap_sg() alters sg in its increment statement. Therefore, the +pointer passed into dma_unmap_sg() won't match to the one given to +dma_map_sg(). + +To fix the problem, use priv->sg_tx_p directly in dma_unmap_sg() +instead of the local variable. + +Fixes: da3564ee027e ("pch_uart: add multi-scatter processing") +Cc: stable@vger.kernel.org +Signed-off-by: Ilpo Järvinen +Link: https://lore.kernel.org/r/20230103093435.4396-1-ilpo.jarvinen@linux.intel.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/tty/serial/pch_uart.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/tty/serial/pch_uart.c ++++ b/drivers/tty/serial/pch_uart.c +@@ -792,7 +792,7 @@ static void pch_dma_tx_complete(void *ar + } + xmit->tail &= UART_XMIT_SIZE - 1; + async_tx_ack(priv->desc_tx); +- dma_unmap_sg(port->dev, sg, priv->orig_nent, DMA_TO_DEVICE); ++ dma_unmap_sg(port->dev, priv->sg_tx_p, priv->orig_nent, DMA_TO_DEVICE); + priv->tx_dma_use = 0; + priv->nent = 0; + priv->orig_nent = 0; diff --git a/queue-4.19/series b/queue-4.19/series index 8e38febada4..0830ec637b4 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -20,3 +20,13 @@ usb-core-hub-disable-autosuspend-for-ti-tusb8041.patch comedi-adv_pci1760-fix-pwm-instruction-handling.patch mmc-sunxi-mmc-fix-clock-refcount-imbalance-during-unbind.patch cifs-do-not-include-page-data-when-checking-signature.patch +usb-serial-cp210x-add-scalance-lpe-9000-device-id.patch +usb-host-ehci-fsl-fix-module-alias.patch +usb-typec-altmodes-displayport-add-pin-assignment-helper.patch +usb-typec-altmodes-displayport-fix-pin-assignment-calculation.patch +usb-gadget-g_webcam-send-color-matching-descriptor-per-frame.patch +usb-gadget-f_ncm-fix-potential-null-ptr-deref-in-ncm_bitrate.patch +usb-storage-apply-ignore_uas-only-for-hiksemi-md202-on-rtl9210.patch +serial-pch_uart-pass-correct-sg-to-dma_unmap_sg.patch +serial-atmel-fix-incorrect-baudrate-setup.patch +gsmi-fix-null-deref-in-gsmi_get_variable.patch diff --git a/queue-4.19/usb-gadget-f_ncm-fix-potential-null-ptr-deref-in-ncm_bitrate.patch b/queue-4.19/usb-gadget-f_ncm-fix-potential-null-ptr-deref-in-ncm_bitrate.patch new file mode 100644 index 00000000000..794d6c04856 --- /dev/null +++ b/queue-4.19/usb-gadget-f_ncm-fix-potential-null-ptr-deref-in-ncm_bitrate.patch @@ -0,0 +1,95 @@ +From c6ec929595c7443250b2a4faea988c62019d5cd2 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Maciej=20=C5=BBenczykowski?= +Date: Tue, 17 Jan 2023 05:18:39 -0800 +Subject: usb: gadget: f_ncm: fix potential NULL ptr deref in ncm_bitrate() +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Maciej Żenczykowski + +commit c6ec929595c7443250b2a4faea988c62019d5cd2 upstream. + +In Google internal bug 265639009 we've received an (as yet) unreproducible +crash report from an aarch64 GKI 5.10.149-android13 running device. + +AFAICT the source code is at: + https://android.googlesource.com/kernel/common/+/refs/tags/ASB-2022-12-05_13-5.10 + +The call stack is: + ncm_close() -> ncm_notify() -> ncm_do_notify() +with the crash at: + ncm_do_notify+0x98/0x270 +Code: 79000d0b b9000a6c f940012a f9400269 (b9405d4b) + +Which I believe disassembles to (I don't know ARM assembly, but it looks sane enough to me...): + + // halfword (16-bit) store presumably to event->wLength (at offset 6 of struct usb_cdc_notification) + 0B 0D 00 79 strh w11, [x8, #6] + + // word (32-bit) store presumably to req->Length (at offset 8 of struct usb_request) + 6C 0A 00 B9 str w12, [x19, #8] + + // x10 (NULL) was read here from offset 0 of valid pointer x9 + // IMHO we're reading 'cdev->gadget' and getting NULL + // gadget is indeed at offset 0 of struct usb_composite_dev + 2A 01 40 F9 ldr x10, [x9] + + // loading req->buf pointer, which is at offset 0 of struct usb_request + 69 02 40 F9 ldr x9, [x19] + + // x10 is null, crash, appears to be attempt to read cdev->gadget->max_speed + 4B 5D 40 B9 ldr w11, [x10, #0x5c] + +which seems to line up with ncm_do_notify() case NCM_NOTIFY_SPEED code fragment: + + event->wLength = cpu_to_le16(8); + req->length = NCM_STATUS_BYTECOUNT; + + /* SPEED_CHANGE data is up/down speeds in bits/sec */ + data = req->buf + sizeof *event; + data[0] = cpu_to_le32(ncm_bitrate(cdev->gadget)); + +My analysis of registers and NULL ptr deref crash offset + (Unable to handle kernel NULL pointer dereference at virtual address 000000000000005c) +heavily suggests that the crash is due to 'cdev->gadget' being NULL when executing: + data[0] = cpu_to_le32(ncm_bitrate(cdev->gadget)); +which calls: + ncm_bitrate(NULL) +which then calls: + gadget_is_superspeed(NULL) +which reads + ((struct usb_gadget *)NULL)->max_speed +and hits a panic. + +AFAICT, if I'm counting right, the offset of max_speed is indeed 0x5C. +(remember there's a GKI KABI reservation of 16 bytes in struct work_struct) + +It's not at all clear to me how this is all supposed to work... +but returning 0 seems much better than panic-ing... + +Cc: Felipe Balbi +Cc: Lorenzo Colitti +Cc: Carlos Llamas +Cc: stable@vger.kernel.org +Signed-off-by: Maciej Żenczykowski +Cc: stable +Link: https://lore.kernel.org/r/20230117131839.1138208-1-maze@google.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/gadget/function/f_ncm.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +--- a/drivers/usb/gadget/function/f_ncm.c ++++ b/drivers/usb/gadget/function/f_ncm.c +@@ -86,7 +86,9 @@ static inline struct f_ncm *func_to_ncm( + /* peak (theoretical) bulk transfer rate in bits-per-second */ + static inline unsigned ncm_bitrate(struct usb_gadget *g) + { +- if (gadget_is_superspeed(g) && g->speed >= USB_SPEED_SUPER_PLUS) ++ if (!g) ++ return 0; ++ else if (gadget_is_superspeed(g) && g->speed >= USB_SPEED_SUPER_PLUS) + return 4250000000U; + else if (gadget_is_superspeed(g) && g->speed == USB_SPEED_SUPER) + return 3750000000U; diff --git a/queue-4.19/usb-gadget-g_webcam-send-color-matching-descriptor-per-frame.patch b/queue-4.19/usb-gadget-g_webcam-send-color-matching-descriptor-per-frame.patch new file mode 100644 index 00000000000..436a5be05a0 --- /dev/null +++ b/queue-4.19/usb-gadget-g_webcam-send-color-matching-descriptor-per-frame.patch @@ -0,0 +1,59 @@ +From e95765e97d9cb93258a4840440d410fa6ff7e819 Mon Sep 17 00:00:00 2001 +From: Daniel Scally +Date: Fri, 16 Dec 2022 16:05:28 +0000 +Subject: usb: gadget: g_webcam: Send color matching descriptor per frame + +From: Daniel Scally + +commit e95765e97d9cb93258a4840440d410fa6ff7e819 upstream. + +Currently the color matching descriptor is only sent across the wire +a single time, following the descriptors for each format and frame. +According to the UVC 1.5 Specification 3.9.2.6 ("Color Matching +Descriptors"): + +"Only one instance is allowed for a given format and if present, +the Color Matching descriptor shall be placed following the Video +and Still Image Frame descriptors for that format". + +Add another reference to the color matching descriptor after the +yuyv frames so that it's correctly transmitted for that format +too. + +Fixes: a9914127e834 ("USB gadget: Webcam device") +Cc: stable +Signed-off-by: Daniel Scally +Reviewed-by: Laurent Pinchart +Reviewed-by: Kieran Bingham +Link: https://lore.kernel.org/r/20221216160528.479094-1-dan.scally@ideasonboard.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/gadget/legacy/webcam.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/drivers/usb/gadget/legacy/webcam.c ++++ b/drivers/usb/gadget/legacy/webcam.c +@@ -292,6 +292,7 @@ static const struct uvc_descriptor_heade + (const struct uvc_descriptor_header *) &uvc_format_yuv, + (const struct uvc_descriptor_header *) &uvc_frame_yuv_360p, + (const struct uvc_descriptor_header *) &uvc_frame_yuv_720p, ++ (const struct uvc_descriptor_header *) &uvc_color_matching, + (const struct uvc_descriptor_header *) &uvc_format_mjpg, + (const struct uvc_descriptor_header *) &uvc_frame_mjpg_360p, + (const struct uvc_descriptor_header *) &uvc_frame_mjpg_720p, +@@ -304,6 +305,7 @@ static const struct uvc_descriptor_heade + (const struct uvc_descriptor_header *) &uvc_format_yuv, + (const struct uvc_descriptor_header *) &uvc_frame_yuv_360p, + (const struct uvc_descriptor_header *) &uvc_frame_yuv_720p, ++ (const struct uvc_descriptor_header *) &uvc_color_matching, + (const struct uvc_descriptor_header *) &uvc_format_mjpg, + (const struct uvc_descriptor_header *) &uvc_frame_mjpg_360p, + (const struct uvc_descriptor_header *) &uvc_frame_mjpg_720p, +@@ -316,6 +318,7 @@ static const struct uvc_descriptor_heade + (const struct uvc_descriptor_header *) &uvc_format_yuv, + (const struct uvc_descriptor_header *) &uvc_frame_yuv_360p, + (const struct uvc_descriptor_header *) &uvc_frame_yuv_720p, ++ (const struct uvc_descriptor_header *) &uvc_color_matching, + (const struct uvc_descriptor_header *) &uvc_format_mjpg, + (const struct uvc_descriptor_header *) &uvc_frame_mjpg_360p, + (const struct uvc_descriptor_header *) &uvc_frame_mjpg_720p, diff --git a/queue-4.19/usb-host-ehci-fsl-fix-module-alias.patch b/queue-4.19/usb-host-ehci-fsl-fix-module-alias.patch new file mode 100644 index 00000000000..9a14c608755 --- /dev/null +++ b/queue-4.19/usb-host-ehci-fsl-fix-module-alias.patch @@ -0,0 +1,36 @@ +From 5d3d01ae15d2f37ed0325c99ab47ef0ae5d05f3c Mon Sep 17 00:00:00 2001 +From: Alexander Stein +Date: Fri, 20 Jan 2023 13:27:14 +0100 +Subject: usb: host: ehci-fsl: Fix module alias + +From: Alexander Stein + +commit 5d3d01ae15d2f37ed0325c99ab47ef0ae5d05f3c upstream. + +Commit ca07e1c1e4a6 ("drivers:usb:fsl:Make fsl ehci drv an independent +driver module") changed DRV_NAME which was used for MODULE_ALIAS as well. +Starting from this the module alias didn't match the platform device +name created in fsl-mph-dr-of.c +Change DRV_NAME to match the driver name for host mode in fsl-mph-dr-of. +This is needed for module autoloading on ls1021a. + +Fixes: ca07e1c1e4a6 ("drivers:usb:fsl:Make fsl ehci drv an independent driver module") +Cc: stable +Signed-off-by: Alexander Stein +Link: https://lore.kernel.org/r/20230120122714.3848784-1-alexander.stein@ew.tq-group.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/host/ehci-fsl.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/usb/host/ehci-fsl.c ++++ b/drivers/usb/host/ehci-fsl.c +@@ -28,7 +28,7 @@ + #include "ehci-fsl.h" + + #define DRIVER_DESC "Freescale EHCI Host controller driver" +-#define DRV_NAME "ehci-fsl" ++#define DRV_NAME "fsl-ehci" + + static struct hc_driver __read_mostly fsl_ehci_hc_driver; + diff --git a/queue-4.19/usb-serial-cp210x-add-scalance-lpe-9000-device-id.patch b/queue-4.19/usb-serial-cp210x-add-scalance-lpe-9000-device-id.patch new file mode 100644 index 00000000000..f8a15dd9674 --- /dev/null +++ b/queue-4.19/usb-serial-cp210x-add-scalance-lpe-9000-device-id.patch @@ -0,0 +1,30 @@ +From 3f9e76e31704a325170e5aec2243c8d084d74854 Mon Sep 17 00:00:00 2001 +From: Michael Adler +Date: Tue, 3 Jan 2023 14:48:50 +0100 +Subject: USB: serial: cp210x: add SCALANCE LPE-9000 device id + +From: Michael Adler + +commit 3f9e76e31704a325170e5aec2243c8d084d74854 upstream. + +Add the USB serial console device ID for Siemens SCALANCE LPE-9000 +which have a USB port for their serial console. + +Signed-off-by: Michael Adler +Cc: stable@vger.kernel.org +Signed-off-by: Johan Hovold +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/serial/cp210x.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/drivers/usb/serial/cp210x.c ++++ b/drivers/usb/serial/cp210x.c +@@ -61,6 +61,7 @@ static const struct usb_device_id id_tab + { USB_DEVICE(0x0846, 0x1100) }, /* NetGear Managed Switch M4100 series, M5300 series, M7100 series */ + { USB_DEVICE(0x08e6, 0x5501) }, /* Gemalto Prox-PU/CU contactless smartcard reader */ + { USB_DEVICE(0x08FD, 0x000A) }, /* Digianswer A/S , ZigBee/802.15.4 MAC Device */ ++ { USB_DEVICE(0x0908, 0x0070) }, /* Siemens SCALANCE LPE-9000 USB Serial Console */ + { USB_DEVICE(0x0908, 0x01FF) }, /* Siemens RUGGEDCOM USB Serial Console */ + { USB_DEVICE(0x0988, 0x0578) }, /* Teraoka AD2000 */ + { USB_DEVICE(0x0B00, 0x3070) }, /* Ingenico 3070 */ diff --git a/queue-4.19/usb-storage-apply-ignore_uas-only-for-hiksemi-md202-on-rtl9210.patch b/queue-4.19/usb-storage-apply-ignore_uas-only-for-hiksemi-md202-on-rtl9210.patch new file mode 100644 index 00000000000..26c6e3ef6e1 --- /dev/null +++ b/queue-4.19/usb-storage-apply-ignore_uas-only-for-hiksemi-md202-on-rtl9210.patch @@ -0,0 +1,77 @@ +From dbd24ec17b85b45f4e823d1aa5607721920f2b05 Mon Sep 17 00:00:00 2001 +From: Juhyung Park +Date: Tue, 17 Jan 2023 17:51:54 +0900 +Subject: usb-storage: apply IGNORE_UAS only for HIKSEMI MD202 on RTL9210 + +From: Juhyung Park + +commit dbd24ec17b85b45f4e823d1aa5607721920f2b05 upstream. + +The commit e00b488e813f ("usb-storage: Add Hiksemi USB3-FW to IGNORE_UAS") +blacklists UAS for all of RTL9210 enclosures. + +The RTL9210 controller was advertised with UAS since its release back in +2019 and was shipped with a lot of enclosure products with different +firmware combinations. + +Blacklist UAS only for HIKSEMI MD202. + +This should hopefully be replaced with more robust method than just +comparing strings. But with limited information [1] provided thus far +(dmesg when the device is plugged in, which includes manufacturer and +product, but no lsusb -v to compare against), this is the best we can do +for now. + +[1] https://lore.kernel.org/all/20230109115550.71688-1-qkrwngud825@gmail.com + +Fixes: e00b488e813f ("usb-storage: Add Hiksemi USB3-FW to IGNORE_UAS") +Cc: Alan Stern +Cc: Hongling Zeng +Cc: stable@vger.kernel.org +Signed-off-by: Juhyung Park +Acked-by: Oliver Neukum +Link: https://lore.kernel.org/r/20230117085154.123301-1-qkrwngud825@gmail.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/storage/uas-detect.h | 13 +++++++++++++ + drivers/usb/storage/unusual_uas.h | 7 ------- + 2 files changed, 13 insertions(+), 7 deletions(-) + +--- a/drivers/usb/storage/uas-detect.h ++++ b/drivers/usb/storage/uas-detect.h +@@ -116,6 +116,19 @@ static int uas_use_uas_driver(struct usb + if (le16_to_cpu(udev->descriptor.idVendor) == 0x0bc2) + flags |= US_FL_NO_ATA_1X; + ++ /* ++ * RTL9210-based enclosure from HIKSEMI, MD202 reportedly have issues ++ * with UAS. This isn't distinguishable with just idVendor and ++ * idProduct, use manufacturer and product too. ++ * ++ * Reported-by: Hongling Zeng ++ */ ++ if (le16_to_cpu(udev->descriptor.idVendor) == 0x0bda && ++ le16_to_cpu(udev->descriptor.idProduct) == 0x9210 && ++ (udev->manufacturer && !strcmp(udev->manufacturer, "HIKSEMI")) && ++ (udev->product && !strcmp(udev->product, "MD202"))) ++ flags |= US_FL_IGNORE_UAS; ++ + usb_stor_adjust_quirks(udev, &flags); + + if (flags & US_FL_IGNORE_UAS) { +--- a/drivers/usb/storage/unusual_uas.h ++++ b/drivers/usb/storage/unusual_uas.h +@@ -83,13 +83,6 @@ UNUSUAL_DEV(0x0bc2, 0x331a, 0x0000, 0x99 + USB_SC_DEVICE, USB_PR_DEVICE, NULL, + US_FL_NO_REPORT_LUNS), + +-/* Reported-by: Hongling Zeng */ +-UNUSUAL_DEV(0x0bda, 0x9210, 0x0000, 0x9999, +- "Hiksemi", +- "External HDD", +- USB_SC_DEVICE, USB_PR_DEVICE, NULL, +- US_FL_IGNORE_UAS), +- + /* Reported-by: Benjamin Tissoires */ + UNUSUAL_DEV(0x13fd, 0x3940, 0x0000, 0x9999, + "Initio Corporation", diff --git a/queue-4.19/usb-typec-altmodes-displayport-add-pin-assignment-helper.patch b/queue-4.19/usb-typec-altmodes-displayport-add-pin-assignment-helper.patch new file mode 100644 index 00000000000..3ee56583490 --- /dev/null +++ b/queue-4.19/usb-typec-altmodes-displayport-add-pin-assignment-helper.patch @@ -0,0 +1,73 @@ +From 582836e3cfab4faafbdc93bbec96fce036a08ee1 Mon Sep 17 00:00:00 2001 +From: Prashant Malani +Date: Wed, 11 Jan 2023 02:05:41 +0000 +Subject: usb: typec: altmodes/displayport: Add pin assignment helper + +From: Prashant Malani + +commit 582836e3cfab4faafbdc93bbec96fce036a08ee1 upstream. + +The code to extract a peripheral's currently supported Pin Assignments +is repeated in a couple of locations. Factor it out into a separate +function. + +This will also make it easier to add fixes (we only need to update 1 +location instead of 2). + +Fixes: c1e5c2f0cb8a ("usb: typec: altmodes/displayport: correct pin assignment for UFP receptacles") +Cc: stable@vger.kernel.org +Cc: Heikki Krogerus +Signed-off-by: Prashant Malani +Reviewed-by: Benson Leung +Reviewed-by: Heikki Krogerus +Link: https://lore.kernel.org/r/20230111020546.3384569-1-pmalani@chromium.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/typec/altmodes/displayport.c | 22 ++++++++++++++-------- + 1 file changed, 14 insertions(+), 8 deletions(-) + +--- a/drivers/usb/typec/altmodes/displayport.c ++++ b/drivers/usb/typec/altmodes/displayport.c +@@ -411,6 +411,18 @@ static const char * const pin_assignment + [DP_PIN_ASSIGN_F] = "F", + }; + ++/* ++ * Helper function to extract a peripheral's currently supported ++ * Pin Assignments from its DisplayPort alternate mode state. ++ */ ++static u8 get_current_pin_assignments(struct dp_altmode *dp) ++{ ++ if (DP_CONF_CURRENTLY(dp->data.conf) == DP_CONF_DFP_D) ++ return DP_CAP_UFP_D_PIN_ASSIGN(dp->alt->vdo); ++ else ++ return DP_CAP_DFP_D_PIN_ASSIGN(dp->alt->vdo); ++} ++ + static ssize_t + pin_assignment_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t size) +@@ -437,10 +449,7 @@ pin_assignment_store(struct device *dev, + goto out_unlock; + } + +- if (DP_CONF_CURRENTLY(dp->data.conf) == DP_CONF_DFP_D) +- assignments = DP_CAP_UFP_D_PIN_ASSIGN(dp->alt->vdo); +- else +- assignments = DP_CAP_DFP_D_PIN_ASSIGN(dp->alt->vdo); ++ assignments = get_current_pin_assignments(dp); + + if (!(DP_CONF_GET_PIN_ASSIGN(conf) & assignments)) { + ret = -EINVAL; +@@ -477,10 +486,7 @@ static ssize_t pin_assignment_show(struc + + cur = get_count_order(DP_CONF_GET_PIN_ASSIGN(dp->data.conf)); + +- if (DP_CONF_CURRENTLY(dp->data.conf) == DP_CONF_DFP_D) +- assignments = DP_CAP_UFP_D_PIN_ASSIGN(dp->alt->vdo); +- else +- assignments = DP_CAP_DFP_D_PIN_ASSIGN(dp->alt->vdo); ++ assignments = get_current_pin_assignments(dp); + + for (i = 0; assignments; assignments >>= 1, i++) { + if (assignments & 1) { diff --git a/queue-4.19/usb-typec-altmodes-displayport-fix-pin-assignment-calculation.patch b/queue-4.19/usb-typec-altmodes-displayport-fix-pin-assignment-calculation.patch new file mode 100644 index 00000000000..c9a9377173c --- /dev/null +++ b/queue-4.19/usb-typec-altmodes-displayport-fix-pin-assignment-calculation.patch @@ -0,0 +1,43 @@ +From 9682b41e52cc9f42f5c33caf410464392adaef04 Mon Sep 17 00:00:00 2001 +From: Prashant Malani +Date: Wed, 11 Jan 2023 02:05:42 +0000 +Subject: usb: typec: altmodes/displayport: Fix pin assignment calculation + +From: Prashant Malani + +commit 9682b41e52cc9f42f5c33caf410464392adaef04 upstream. + +Commit c1e5c2f0cb8a ("usb: typec: altmodes/displayport: correct pin +assignment for UFP receptacles") fixed the pin assignment calculation +to take into account whether the peripheral was a plug or a receptacle. + +But the "pin_assignments" sysfs logic was not updated. Address this by +using the macros introduced in the aforementioned commit in the sysfs +logic too. + +Fixes: c1e5c2f0cb8a ("usb: typec: altmodes/displayport: correct pin assignment for UFP receptacles") +Cc: stable@vger.kernel.org +Cc: Heikki Krogerus +Signed-off-by: Prashant Malani +Reviewed-by: Benson Leung +Reviewed-by: Heikki Krogerus +Link: https://lore.kernel.org/r/20230111020546.3384569-2-pmalani@chromium.org +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/typec/altmodes/displayport.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/drivers/usb/typec/altmodes/displayport.c ++++ b/drivers/usb/typec/altmodes/displayport.c +@@ -418,9 +418,9 @@ static const char * const pin_assignment + static u8 get_current_pin_assignments(struct dp_altmode *dp) + { + if (DP_CONF_CURRENTLY(dp->data.conf) == DP_CONF_DFP_D) +- return DP_CAP_UFP_D_PIN_ASSIGN(dp->alt->vdo); ++ return DP_CAP_PIN_ASSIGN_DFP_D(dp->alt->vdo); + else +- return DP_CAP_DFP_D_PIN_ASSIGN(dp->alt->vdo); ++ return DP_CAP_PIN_ASSIGN_UFP_D(dp->alt->vdo); + } + + static ssize_t