iommu/amd: Fix error handling for pdev_pri_ats_enable()
Subsystems (9)
Sasha Levin
maintainerPATCH 1/20 iommu/amd: Fix error handling for pdev_pri_ats_enable()
From: Vasant Hegde <[email protected]>
[ Upstream commit 080920e52148b4fbbf9360d5345fdcd7846e4841 ]
Current code throws kernel warning if it fails to enable pasid/pri [1]. Do not call pci_disable_[pasid/pri] if pci_enable_[pasid/pri] failed.
[1] https://lore.kernel.org/linux-iommu/[email protected]/
--- drivers/iommu/amd_iommu.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/iommu/amd_iommu.c +7 -5
@@ -2120,17 +2120,17 @@ static int pdev_iommuv2_enable(struct pci_dev *pdev)/* Only allow access to user-accessible pages */ ret =pci_enable_pasid (pdev,0 );if (ret) - goto out_err; +return ret;/* First reset the PRI state of the device */ ret =pci_reset_pri (pdev);if (ret) - goto out_err; + goto out_err_pasid;/* Enable PRI */ ret =pci_enable_pri (pdev, reqs);if (ret) - goto out_err; + goto out_err_pasid;if (reset_enable) { ret =pri_reset_while_enabled (pdev);
@@ -2140,12 +2140,14 @@ static int pdev_iommuv2_enable(struct pci_dev *pdev) ret =pci_enable_ats (pdev,PAGE_SHIFT );if (ret) - goto out_err; + goto out_err_pri;return 0 ; -out_err: +out_err_pri:pci_disable_pri (pdev); + +out_err_pasid:pci_disable_pasid (pdev);return ret;
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 2/20 media: uvcvideo: Handle cameras with invalid descriptors
From: Ricardo Ribalda <[email protected]>
[ Upstream commit 41ddb251c68ac75c101d3a50a68c4629c9055e4c ]
If the source entity does not contain any pads, do not create a link.
--- drivers/media/usb/uvc/uvc_entity.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/usb/uvc/uvc_entity.c +1 -1
@@ -37,7 +37,7 @@ static int uvc_mc_create_links(struct uvc_video_chain *chain,continue ; remote =uvc_entity_by_id (chain->dev, entity->baSourceID[i]); -if (remote ==NULL ) +if (remote ==NULL || remote->num_pads ==0 )return -EINVAL ; source = (UVC_ENTITY_TYPE (remote) ==UVC_TT_STREAMING )
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 3/20 media: uvcvideo: Handle errors from calls to usb_string
In reply to Sasha LevinFrom: Guenter Roeck <[email protected]>
[ Upstream commit 4867bb590ae445bcfaa711a86b603c97e94574b3 ]
On a Webcam from Quanta, we see the following error.
usb 3-5: New USB device found, idVendor=0408, idProduct=30d2, bcdDevice= 0.03 usb 3-5: New USB device strings: Mfr=3, Product=1, SerialNumber=2 usb 3-5: Product: USB2.0 HD UVC WebCam
usb 3-5: Manufacturer: Quanta
usb 3-5: SerialNumber: 0x0001
...
uvcvideo: Found UVC 1.10 device USB2.0 HD UVC WebCam (0408:30d2)
uvcvideo: Failed to initialize entity for entity 5
uvcvideo: Failed to register entities (-22).
The Webcam reports an entity of type UVC_VC_EXTENSION_UNIT. It reports a string index of '7' associated with that entity. The attempt to read that string from the camera fails with error -32 (-EPIPE). usb_string() returns that error, but it is ignored. As result, the entity name is empty. This later causes v4l2_device_register_subdev() to return -EINVAL, and no entities are registered as result.
While this appears to be a firmware problem with the camera, the kernel should still handle the situation gracefully. To do that, check the return value from usb_string(). If it reports an error, assign the entity's default name.
--- drivers/media/usb/uvc/uvc_driver.c | 48 ++++++++++++------------------ 1 file changed, 19 insertions(+), 29 deletions(-)
drivers/media/usb/uvc/uvc_driver.c +19 -29
@@ -1060,10 +1060,8 @@ static int uvc_parse_vendor_control(struct uvc_device *dev, + n;memcpy (unit->extension.bmControls, &buffer[23 +p],2 *n); -if (buffer[24 +p+2 *n] !=0 ) -usb_string (udev, buffer[24 +p+2 *n], unit->name, -sizeof (unit->name)); -else +if (buffer[24 +p+2 *n] ==0 || +usb_string (udev, buffer[24 +p+2 *n], unit->name,sizeof (unit->name)) <0 )sprintf (unit->name,"Extension %u" , buffer[3 ]);list_add_tail (&unit->list, &dev->entities);
@@ -1188,15 +1186,15 @@ static int uvc_parse_standard_control(struct uvc_device *dev,memcpy (term->media.bmTransportModes, &buffer[10 +n], p); } -if (buffer[7 ] !=0 ) -usb_string (udev, buffer[7 ], term->name, -sizeof (term->name)); -else if (UVC_ENTITY_TYPE (term) ==UVC_ITT_CAMERA ) -sprintf (term->name,"Camera %u" , buffer[3 ]); -else if (UVC_ENTITY_TYPE (term) ==UVC_ITT_MEDIA_TRANSPORT_INPUT ) -sprintf (term->name,"Media %u" , buffer[3 ]); -else -sprintf (term->name,"Input %u" , buffer[3 ]); +if (buffer[7 ] ==0 || +usb_string (udev, buffer[7 ], term->name,sizeof (term->name)) <0 ) { +if (UVC_ENTITY_TYPE (term) ==UVC_ITT_CAMERA ) +sprintf (term->name,"Camera %u" , buffer[3 ]); +if (UVC_ENTITY_TYPE (term) ==UVC_ITT_MEDIA_TRANSPORT_INPUT ) +sprintf (term->name,"Media %u" , buffer[3 ]); +else +sprintf (term->name,"Input %u" , buffer[3 ]); + }list_add_tail (&term->list, &dev->entities);break ;
@@ -1228,10 +1226,8 @@ static int uvc_parse_standard_control(struct uvc_device *dev,memcpy (term->baSourceID, &buffer[7 ],1 ); -if (buffer[8 ] !=0 ) -usb_string (udev, buffer[8 ], term->name, -sizeof (term->name)); -else +if (buffer[8 ] ==0 || +usb_string (udev, buffer[8 ], term->name,sizeof (term->name)) <0 )sprintf (term->name,"Output %u" , buffer[3 ]);list_add_tail (&term->list, &dev->entities);
@@ -1253,10 +1249,8 @@ static int uvc_parse_standard_control(struct uvc_device *dev,memcpy (unit->baSourceID, &buffer[5 ], p); -if (buffer[5 +p] !=0 ) -usb_string (udev, buffer[5 +p], unit->name, -sizeof (unit->name)); -else +if (buffer[5 +p] ==0 || +usb_string (udev, buffer[5 +p], unit->name,sizeof (unit->name)) <0 )sprintf (unit->name,"Selector %u" , buffer[3 ]);list_add_tail (&unit->list, &dev->entities);
@@ -1286,10 +1280,8 @@ static int uvc_parse_standard_control(struct uvc_device *dev,if (dev->uvc_version >=0x0110 ) unit->processing.bmVideoStandards = buffer[9 +n]; -if (buffer[8 +n] !=0 ) -usb_string (udev, buffer[8 +n], unit->name, -sizeof (unit->name)); -else +if (buffer[8 +n] ==0 || +usb_string (udev, buffer[8 +n], unit->name,sizeof (unit->name)) <0 )sprintf (unit->name,"Processing %u" , buffer[3 ]);list_add_tail (&unit->list, &dev->entities);
@@ -1317,10 +1309,8 @@ static int uvc_parse_standard_control(struct uvc_device *dev, unit->extension.bmControls = (u8 *)unit +sizeof (*unit);memcpy (unit->extension.bmControls, &buffer[23 +p], n); -if (buffer[23 +p+n] !=0 ) -usb_string (udev, buffer[23 +p+n], unit->name, -sizeof (unit->name)); -else +if (buffer[23 +p+n] ==0 || +usb_string (udev, buffer[23 +p+n], unit->name,sizeof (unit->name)) <0 )sprintf (unit->name,"Extension %u" , buffer[3 ]);list_add_tail (&unit->list, &dev->entities);
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 4/20 media: uvcvideo: Quirk for autosuspend in Logitech B910 and C910
In reply to Sasha LevinFrom: Ricardo Ribalda <[email protected]>
[ Upstream commit 136effa754b57632f99574fc4a3433e0cfc031d9 ]
Logitech B910 and C910 firmware are unable to recover from a USB autosuspend. When it resumes, the device is in a state where it only produces invalid frames. Eg:
$ echo 0xFFFF > /sys/module/uvcvideo/parameters/trace # enable verbose log $ yavta -c1 -n1 --file='frame#.jpg' --format MJPEG --size=1920x1080 /dev/video1 [350438.435219] uvcvideo: uvc_v4l2_open [350438.529794] uvcvideo: Resuming interface 2 [350438.529801] uvcvideo: Resuming interface 3 [350438.529991] uvcvideo: Trying format 0x47504a4d (MJPG): 1920x1080. [350438.529996] uvcvideo: Using default frame interval 33333.3 us (30.0 fps). [350438.551496] uvcvideo: uvc_v4l2_mmap [350438.555890] uvcvideo: Device requested 3060 B/frame bandwidth. [350438.555896] uvcvideo: Selecting alternate setting 11 (3060 B/frame bandwidth). [350438.556362] uvcvideo: Allocated 5 URB buffers of 32x3060 bytes each. [350439.316468] uvcvideo: Marking buffer as bad (error bit set). [350439.316475] uvcvideo: Frame complete (EOF found). [350439.316477] uvcvideo: EOF in empty payload. [350439.316484] uvcvideo: frame 1 stats: 149/261/417 packets, 1/149/417 pts (early initial), 416/417 scr, last pts/stc/sof 2976325734/2978107243/249 [350439.384510] uvcvideo: Marking buffer as bad (error bit set). [350439.384516] uvcvideo: Frame complete (EOF found). [350439.384518] uvcvideo: EOF in empty payload. [350439.384525] uvcvideo: frame 2 stats: 265/379/533 packets, 1/265/533 pts (early initial), 532/533 scr, last pts/stc/sof 2979524454/2981305193/316 [350439.448472] uvcvideo: Marking buffer as bad (error bit set). [350439.448478] uvcvideo: Frame complete (EOF found). [350439.448480] uvcvideo: EOF in empty payload. [350439.448487] uvcvideo: frame 3 stats: 265/377/533 packets, 1/265/533 pts (early initial), 532/533 scr, last pts/stc/sof 2982723174/2984503144/382 ...(loop)...
The devices can leave this invalid state if the alternate setting of the streaming interface is toggled.
This patch adds a quirk for this device so it can be autosuspended properly.
lsusb -v:
Bus 001 Device 049: ID 046d:0821 Logitech, Inc. HD Webcam C910 Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 239 Miscellaneous Device
bDeviceSubClass 2
bDeviceProtocol 1 Interface Association
bMaxPacketSize0 64
idVendor 0x046d Logitech, Inc.
idProduct 0x0821 HD Webcam C910
bcdDevice 0.10
iManufacturer 0 iProduct 0 iSerial 1 390022B0 bNumConfigurations 1
--- drivers/media/usb/uvc/uvc_driver.c | 18 ++++++++++++++++++ drivers/media/usb/uvc/uvc_video.c | 11 +++++++++++ drivers/media/usb/uvc/uvcvideo.h | 1 + 3 files changed, 30 insertions(+)
drivers/media/usb/uvc/uvc_driver.c +18 -0
@@ -2462,6 +2462,24 @@ static const struct usb_device_id uvc_ids[] = { .bInterfaceSubClass = 1, .bInterfaceProtocol = 0, .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax }, +/* Logitech, Webcam C910 */ + { .match_flags = USB_DEVICE_ID_MATCH_DEVICE + | USB_DEVICE_ID_MATCH_INT_INFO, + .idVendor = 0x046d, + .idProduct = 0x0821, + .bInterfaceClass = USB_CLASS_VIDEO, + .bInterfaceSubClass = 1, + .bInterfaceProtocol = 0, + .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_WAKE_AUTOSUSPEND)}, + /* Logitech, Webcam B910 */ + { .match_flags = USB_DEVICE_ID_MATCH_DEVICE + | USB_DEVICE_ID_MATCH_INT_INFO, + .idVendor = 0x046d, + .idProduct = 0x0823, + .bInterfaceClass = USB_CLASS_VIDEO, + .bInterfaceSubClass = 1, + .bInterfaceProtocol = 0, + .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_WAKE_AUTOSUSPEND)}, /* Logitech Quickcam Fusion */ { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
drivers/media/usb/uvc/uvc_video.c +11 -0
@@ -1903,6 +1903,17 @@ static int uvc_video_start_transfer(struct uvc_streaming *stream,uvc_trace (UVC_TRACE_VIDEO ,"Selecting alternate setting %u " "(%u B/frame bandwidth).\n" , altsetting, best_psize); +/* +* Some devices, namely the Logitech C910 and B910, are unable +* to recover from a USB autosuspend, unless the alternate +* setting of the streaming interface is toggled. +*/ +if (stream->dev->quirks &UVC_QUIRK_WAKE_AUTOSUSPEND ) { +usb_set_interface (stream->dev->udev, intfnum, + altsetting); +usb_set_interface (stream->dev->udev, intfnum,0 ); + } + ret =usb_set_interface (stream->dev->udev, intfnum, altsetting);if (ret <0 )return ret;
drivers/media/usb/uvc/uvcvideo.h +1 -0
@@ -199,6 +199,7 @@#define UVC_QUIRK_RESTORE_CTRLS_ON_INIT 0x00000400#define UVC_QUIRK_FORCE_Y8 0x00000800#define UVC_QUIRK_FORCE_BPP 0x00001000 +#define UVC_QUIRK_WAKE_AUTOSUSPEND 0x00002000/* Format flags */ #define UVC_FMT_FLAG_COMPRESSED 0x00000001
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 5/20 media: uvcvideo: Silence memcpy() run-time false positive warnings
In reply to Sasha LevinFrom: Kees Cook <[email protected]>
[ Upstream commit b839212988575c701aab4d3d9ca15e44c87e383c ]
The memcpy() in uvc_video_decode_meta() intentionally copies across the length and flags members and into the trailing buf flexible array. Split the copy so that the compiler can better reason about (the lack of) buffer overflows here. Avoid the run-time false positive warning:
memcpy: detected field-spanning write (size 12) of single field "&meta->length" at drivers/media/usb/uvc/uvc_video.c:1355 (size 1)
Additionally fix a typo in the documentation for struct uvc_meta_buf.
--- drivers/media/usb/uvc/uvc_video.c | 4 +++- include/uapi/linux/uvcvideo.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/media/usb/uvc/uvc_video.c +3 -1
@@ -1308,7 +1308,9 @@ static void uvc_video_decode_meta(struct uvc_streaming *stream,if (has_scr)memcpy (stream->clock.last_scr, scr,6 ); -memcpy (&meta->length, mem, length); + meta->length = mem[0 ]; + meta->flags = mem[1 ]; +memcpy (meta->buf, &mem[2 ], length -2 ); meta_buf->bytesused += length +sizeof (meta->ns) +sizeof (meta->sof); uvc_trace(UVC_TRACE_FRAME,
include/uapi/linux/uvcvideo.h +1 -1
@@ -86,7 +86,7 @@ struct uvc_xu_control_query {* struct. The first two fields are added by the driver, they can be used for * clock synchronisation. The rest is an exact copy of a UVC payload header. * Only complete objects with complete buffers are included. Therefore it's -* always sizeof(meta->ts) + sizeof(meta->sof) + meta->length bytes large. +* always sizeof(meta->ns) + sizeof(meta->sof) + meta->length bytes large. */ struct uvc_meta_buf {__u64 ns;
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 6/20 staging: emxx_udc: Add checks for dma_alloc_coherent()
In reply to Sasha LevinFrom: Yuan Can <[email protected]>
[ Upstream commit f6510a93cfd8c6c79b4dda0f2967cdc6df42eff4 ]
As the dma_alloc_coherent may return NULL, the return value needs to be checked to avoid NULL poineter dereference.
--- drivers/staging/emxx_udc/emxx_udc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/staging/emxx_udc/emxx_udc.c +6 -1
@@ -2593,10 +2593,15 @@ static int nbu2ss_ep_queue(struct usb_ep *_ep, req->unaligned = false;if (req->unaligned) { -if (!ep->virt_buf) +if (!ep->virt_buf) { ep->virt_buf =dma_alloc_coherent (udc->dev,PAGE_SIZE , &ep->phys_buf,GFP_ATOMIC |GFP_DMA ); +if (!ep->virt_buf) { +spin_unlock_irqrestore (&udc->lock, flags); +return -ENOMEM ; + } + }if (ep->epnum >0 ) {if (ep->direct ==USB_DIR_IN ) memcpy(ep->virt_buf, req->req.buf,
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 7/20 tty: fix out-of-bounds access in tty_driver_lookup_tty()
In reply to Sasha LevinFrom: Sven Schnelle <[email protected]>
[ Upstream commit db4df8e9d79e7d37732c1a1b560958e8dadfefa1 ]
When specifying an invalid console= device like console=tty3270, tty_driver_lookup_tty() returns the tty struct without checking whether index is a valid number.
To reproduce:
qemu-system-x86_64 -enable-kvm -nographic -serial mon:stdio \
-kernel ../linux-build-x86/arch/x86/boot/bzImage \
-append "console=ttyS0 console=tty3270"
This crashes with:
[ 0.770599] BUG: kernel NULL pointer dereference, address: 00000000000000ef [ 0.771265] #PF: supervisor read access in kernel mode [ 0.771773] #PF: error_code(0x0000) - not-present page [ 0.772609] Oops: 0000 [#1] PREEMPT SMP PTI [ 0.774878] RIP: 0010:tty_open+0x268/0x6f0 [ 0.784013] chrdev_open+0xbd/0x230 [ 0.784444] ? cdev_device_add+0x80/0x80 [ 0.784920] do_dentry_open+0x1e0/0x410 [ 0.785389] path_openat+0xca9/0x1050 [ 0.785813] do_filp_open+0xaa/0x150 [ 0.786240] file_open_name+0x133/0x1b0 [ 0.786746] filp_open+0x27/0x50 [ 0.787244] console_on_rootfs+0x14/0x4d [ 0.787800] kernel_init_freeable+0x1e4/0x20d [ 0.788383] ? rest_init+0xc0/0xc0 [ 0.788881] kernel_init+0x11/0x120 [ 0.789356] ret_from_fork+0x22/0x30
--- drivers/tty/tty_io.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/tty/tty_io.c +5 -3
@@ -1156,14 +1156,16 @@ static struct tty_struct *tty_driver_lookup_tty(struct tty_driver *driver, {struct tty_struct *tty; -if (driver->ops->lookup) +if (driver->ops->lookup) {if (!file) tty =ERR_PTR (-EIO );else tty = driver->ops->lookup (driver, file, idx); -else + }else { +if (idx >= driver->num) +return ERR_PTR (-EINVAL ); tty = driver->ttys[idx]; - + }if (!IS_ERR (tty))tty_kref_get (tty);return tty;
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 8/20 tty: serial: fsl_lpuart: disable the CTS when send break signal
In reply to Sasha LevinFrom: Sherry Sun <[email protected]>
[ Upstream commit c4c81db5cf8bc53d6160c3abf26d382c841aa434 ]
LPUART IP has a bug that it treats the CTS as higher priority than the break signal, which cause the break signal sending through UARTCTRL_SBK may impacted by the CTS input if the HW flow control is enabled.
Add this workaround patch to fix the IP bug, we can disable CTS before asserting SBK to avoid any interference from CTS, and re-enable it when break off.
Such as for the bluetooth chip power save feature, host can let the BT chip get into sleep state by sending a UART break signal, and wake it up by turning off the UART break. If the BT chip enters the sleep mode successfully, it will pull up the CTS line, if the BT chip is woken up, it will pull down the CTS line. If without this workaround patch, the UART TX pin cannot send the break signal successfully as it affected by the BT CTS pin. After adding this patch, the BT power save feature can work well.
--- drivers/tty/serial/fsl_lpuart.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-)
drivers/tty/serial/fsl_lpuart.c +22 -2
@@ -1370,12 +1370,32 @@ static void lpuart_break_ctl(struct uart_port *port, int break_state)static void lpuart32_break_ctl (struct uart_port *port,int break_state) { -unsigned long temp; +unsigned long temp, modem; +struct tty_struct *tty; +unsigned int cflag =0 ; + + tty =tty_port_tty_get (&port->state->port); +if (tty) { + cflag = tty->termios.c_cflag; +tty_kref_put (tty); + } temp =lpuart32_read (port,UARTCTRL ) & ~UARTCTRL_SBK ; + modem =lpuart32_read (port,UARTMODIR ); -if (break_state !=0 ) +if (break_state !=0 ) { temp |=UARTCTRL_SBK ; +/* +* LPUART CTS has higher priority than SBK, need to disable CTS before +* asserting SBK to avoid any interference if flow control is enabled. +*/ +if (cflag &CRTSCTS && modem &UARTMODIR_TXCTSE ) +lpuart32_write (port, modem & ~UARTMODIR_TXCTSE ,UARTMODIR ); + }else { +/* Re-enable the CTS when break off. */ +if (cflag &CRTSCTS && !(modem &UARTMODIR_TXCTSE )) +lpuart32_write (port, modem |UARTMODIR_TXCTSE ,UARTMODIR ); + }lpuart32_write (port, temp,UARTCTRL ); }
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 9/20 mei: bus-fixup:upon error print return values of send and receive
In reply to Sasha LevinFrom: Alexander Usyskin <[email protected]>
[ Upstream commit 4b8659e2c258e4fdac9ccdf06cc20c0677894ef9 ]
For easier debugging, upon error, print also return values from __mei_cl_recv() and __mei_cl_send() functions.
--- drivers/misc/mei/bus-fixup.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/misc/mei/bus-fixup.c +4 -4
@@ -178,7 +178,7 @@ static int mei_fwver(struct mei_cl_device *cldev) ret =__mei_cl_send (cldev->cl, buf,sizeof (struct mkhi_msg_hdr ),MEI_CL_IO_TX_BLOCKING );if (ret <0 ) { -dev_err (&cldev->dev,"Could not send ReqFWVersion cmd\n" ); +dev_err (&cldev->dev,"Could not send ReqFWVersion cmd ret = %d\n" , ret);return ret; }
@@ -190,7 +190,7 @@ static int mei_fwver(struct mei_cl_device *cldev)* Should be at least one version block, * error out if nothing found */ -dev_err (&cldev->dev,"Could not read FW version\n" ); +dev_err (&cldev->dev,"Could not read FW version ret = %d\n" , bytes_recv);return -EIO ; }
@@ -339,7 +339,7 @@ static int mei_nfc_if_version(struct mei_cl *cl, ret =__mei_cl_send (cl, (u8 *)&cmd,sizeof (struct mei_nfc_cmd ),MEI_CL_IO_TX_BLOCKING );if (ret <0 ) { -dev_err (bus->dev,"Could not send IF version cmd\n" ); +dev_err (bus->dev,"Could not send IF version cmd ret = %d\n" , ret);return ret; }
@@ -354,7 +354,7 @@ static int mei_nfc_if_version(struct mei_cl *cl, ret =0 ; bytes_recv =__mei_cl_recv (cl, (u8 *)reply, if_version_length,0 ,0 );if (bytes_recv <0 || (size_t )bytes_recv < if_version_length) { -dev_err (bus->dev,"Could not read IF version\n" ); +dev_err (bus->dev,"Could not read IF version ret = %d\n" , bytes_recv); ret = -EIO ; goto err; }
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 10/20 parport_pc: Set up mode and ECR masks for Oxford Semiconductor devices
In reply to Sasha LevinFrom: "Maciej W. Rozycki" <[email protected]>
[ Upstream commit c087df8d1e7dc2e764d11234d84b5af46d500f16 ]
No Oxford Semiconductor PCI or PCIe parallel port device supports the Parallel Port FIFO mode. All support the PS/2 Parallel Port mode and the Enhanced Parallel Port mode via the ECR register. The original 5V PCI OX16PCI954 device does not support the Extended Capabilities Port mode, the Test mode or the Configuration mode, but all the other OxSemi devices do, including in particular the 3.3V PCI OXmPCI954 device and the universal voltage PCI OXuPCI954 device. All the unsupported modes are marked reserved in the relevant datasheets.
Accordingly enable the `base_hi' BAR for the 954 devices to enable PS2 and EPP mode support via the ECR register, however mask the COMPAT mode and, until we have a way to determine what chip variant it is that we poke at, also the ECP mode, and mask the COMPAT mode only for all the remaining OxSemi devices, fixing errors like:
parport0: FIFO is stuck
FIFO write timed out
and a non-functional port when the Parallel Port FIFO mode is selected.
Complementing the fix apply an ECR mask for all these devices, which are documented to only permit writing to the mode field of the ECR register with a bit pattern of 00001 required to be written to bits 4:0 on mode field writes. No nFault or service interrupts are implemented, which will therefore never have to be enabled, though bit 2 does report the FIFO threshold status to be polled for in the ECP mode where supported.
We have a documented case of writing 1 to bit 2 causing a lock-up with at least one OX12PCI840 device (from old drivers/parport/ChangeLog):
2001-10-10 Tim Waugh <[email protected]>
* parport_pc.c: Support for OX12PCI840 PCI card (reported by [email protected]). Lock-ups diagnosed by Ronnie Arosa (and now we just don't trust its ECR).
which commit adbd321a17cc ("parport_pc: add base_hi BAR for oxsemi_840") must have broken and by applying an ECR mask here we prevent the lock-up from triggering. This could have been the reason for requiring 00001 to be written to bits 4:0 of ECR.
Update the inline comment accordingly; it has come from Linux 2.4.12 back in 2001 and predates the introduction of OXmPCI954 and OXuPCI954 devices that do support ECP.
References:
[1] "OX16PCI954 Integrated Quad UART and PCI interface", Oxford Semiconductor Ltd., Data Sheet Revision 1.3, Feb. 1999, Chapter 9 "Bidirectional Parallel Port", pp. 53-55
[2] "OX16PCI952 Data Sheet, Integrated High Performance Dual UARTs,
Parallel Port and 5.0v PCI interface", Oxford Semiconductor Ltd.,
DS_B008A_00, Datasheet rev 1.1, June 2001, Chapter 8 "Bi-directional
Parallel Port", pp. 52-56[3] "OXmPCI954 DATA SHEET Integrated High Performance Quad UARTs, 8-bit Local Bus/Parallel Port. 3.3v PCI/miniPCI interface.", Oxford Semiconductor Ltd., DS-0019, June 2005, Chapter 10 "Bidirectional Parallel Port", pp. 86-90
[4] "OXmPCI952 Data Sheet, Integrated High Performance Dual UARTs, 8-bit Local Bus/Parallel Port. 3.3v PCI/miniPCI interface.", Oxford Semiconductor Ltd., DS-0020, June 2005, Chapter 8 "Bidirectional Parallel Port", pp. 73-77
[5] "OX12PCI840 Integrated Parallel Port and PCI interface", Oxford Semiconductor Ltd., DS-0021, Jun 2005, Chapter 5 "Bi-directional Parallel Port", pp. 18-21
[6] "OXPCIe952 PCI Express Bridge to Dual Serial & Parallel Port", Oxford Semiconductor, Inc., DS-0046, Mar 06 08, Chapter "Parallel Port Function", pp. 59-62
[7] "OXPCIe840 PCI Express Bridge to Parallel Port", Oxford Semiconductor, Inc., DS-0049, Mar 06 08, Chapter "Parallel Port Function", pp. 15-18
[8] "OXuPCI954 Data Sheet, Integrated High Performance Quad UARTs, 8-bit Local Bus/Parallel Port, 3.3 V and 5 V (Universal Voltage) PCI Interface.", Oxford Semiconductor, Inc., DS-0058, 26 Jan 2009, Chapter 8 "Bidirectional Parallel Port", pp. 62-65
[9] "OXuPCI952 Data Sheet, Integrated High Performance Dual UARTs, 8-bit Local Bus/Parallel Port, 3.3 V and 5.0 V Universal Voltage PCI Interface.", Oxford Semiconductor, Inc., DS-0059, Sep 2007, Chapter 8 "Bidirectional Parallel Port", pp. 61-64
--- drivers/parport/parport_pc.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
drivers/parport/parport_pc.c +13 -6
@@ -2692,12 +2692,19 @@ static struct parport_pc_pci { /* titan_010l */ { 1, { { 3, -1 }, } }, /* avlab_1p */ { 1, { { 0, 1}, } }, /* avlab_2p */ { 2, { { 0, 1}, { 2, 3 },} }, - /* The Oxford Semi cards are unusual: 954 doesn't support ECP, - * and 840 locks up if you write 1 to bit 2! */ - /* oxsemi_952 */ { 1, { { 0, 1 }, } }, - /* oxsemi_954 */ { 1, { { 0, -1 }, } }, - /* oxsemi_840 */ { 1, { { 0, 1 }, } }, - /* oxsemi_pcie_pport */ { 1, { { 0, 1 }, } }, + /* The Oxford Semi cards are unusual: older variants of 954 don't + * support ECP, and 840 locks up if you write 1 to bit 2! None + * implement nFault or service interrupts and all require 00001 + * bit pattern to be used for bits 4:0 with ECR writes. */ + /* oxsemi_952 */ { 1, { { 0, 1 }, }, + PARPORT_MODE_COMPAT, ECR_MODE_MASK }, + /* oxsemi_954 */ { 1, { { 0, 1 }, }, + PARPORT_MODE_ECP | + PARPORT_MODE_COMPAT, ECR_MODE_MASK }, + /* oxsemi_840 */ { 1, { { 0, 1 }, }, + PARPORT_MODE_COMPAT, ECR_MODE_MASK }, + /* oxsemi_pcie_pport */ { 1, { { 0, 1 }, }, + PARPORT_MODE_COMPAT, ECR_MODE_MASK }, /* aks_0100 */ { 1, { { 0, -1 }, } }, /* mobility_pp */ { 1, { { 0, 1 }, } },
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 11/20 tools/iio/iio_utils:fix memory leak
In reply to Sasha LevinFrom: Yulong Zhang <[email protected]>
[ Upstream commit f2edf0c819a4823cd6c288801ce737e8d4fcde06 ]
1. fopen sysfs without fclose.
2. asprintf filename without free.
3. if asprintf return error,do not need to free the buffer.
--- tools/iio/iio_utils.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-)
tools/iio/iio_utils.c +6 -17
@@ -262,6 +262,7 @@ int iioutils_get_param_float(float *output, const char *param_name,if (fscanf (sysfsfp,"%f" , output) !=1 ) ret = errno ? -errno : -ENODATA ; +fclose (sysfsfp);break ; } error_free_filename:
@@ -342,9 +343,9 @@ int build_channel_array(const char *device_dir, } sysfsfp =fopen (filename,"r" ); +free (filename);if (!sysfsfp) { ret = -errno; -free (filename); goto error_close_dir; }
@@ -354,7 +355,6 @@ int build_channel_array(const char *device_dir,if (fclose (sysfsfp))perror ("build_channel_array(): Failed to close file" ); -free (filename); goto error_close_dir; }if (ret ==1 )
@@ -362,11 +362,9 @@ int build_channel_array(const char *device_dir,if (fclose (sysfsfp)) { ret = -errno; -free (filename); goto error_close_dir; } -free (filename); } *ci_array =malloc (sizeof (**ci_array) * (*counter));
@@ -392,9 +390,9 @@ int build_channel_array(const char *device_dir, } sysfsfp =fopen (filename,"r" ); +free (filename);if (!sysfsfp) { ret = -errno; -free (filename); count--; goto error_cleanup_array; }
@@ -402,20 +400,17 @@ int build_channel_array(const char *device_dir, errno =0 ;if (fscanf (sysfsfp,"%i" , ¤t_enabled) !=1 ) { ret = errno ? -errno : -ENODATA ; -free (filename); count--; goto error_cleanup_array; }if (fclose (sysfsfp)) { ret = -errno; -free (filename); count--; goto error_cleanup_array; }if (!current_enabled) { -free (filename); count--;continue ; }
@@ -426,7 +421,6 @@ int build_channel_array(const char *device_dir,strlen (ent->d_name) - strlen("_en"));if (!current->name) { -free (filename); ret = -ENOMEM ; count--; goto error_cleanup_array;
@@ -436,7 +430,6 @@ int build_channel_array(const char *device_dir, ret =iioutils_break_up_name (current->name, ¤t->generic_name);if (ret) { -free (filename);free (current->name); count--; goto error_cleanup_array;
@@ -447,17 +440,16 @@ int build_channel_array(const char *device_dir, scan_el_dir, current->name);if (ret <0 ) { -free (filename); ret = -ENOMEM ; goto error_cleanup_array; } sysfsfp =fopen (filename,"r" ); +free (filename);if (!sysfsfp) { ret = -errno; -fprintf (stderr,"failed to open %s\n" , - filename); -free (filename); +fprintf (stderr,"failed to open %s/%s_index\n" , + scan_el_dir, current->name); goto error_cleanup_array; }
@@ -467,17 +459,14 @@ int build_channel_array(const char *device_dir,if (fclose (sysfsfp))perror ("build_channel_array(): Failed to close file" ); -free (filename); goto error_cleanup_array; }if (fclose (sysfsfp)) { ret = -errno; -free (filename); goto error_cleanup_array; } -free (filename);/* Find the scale */ ret = iioutils_get_param_float(¤t->scale, "scale",
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 12/20 iio: accel: mma9551_core: Prevent uninitialized variable in mma9551_read_status_word()
In reply to Sasha LevinFrom: Harshit Mogalapalli <[email protected]>
[ Upstream commit e56d2c34ce9dc122b1a618172ec0e05e50adb9e9 ]
Smatch Warns: drivers/iio/accel/mma9551_core.c:357
mma9551_read_status_word() error: uninitialized symbol 'v'.
When (offset >= 1 << 12) is true mma9551_transfer() will return -EINVAL without 'v' being initialized, so check for the error and return.
Note: Not a bug as such because the caller checks return value and doesn't not use this parameter in the problem case.
--- drivers/iio/accel/mma9551_core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/iio/accel/mma9551_core.c +4 -1
@@ -354,9 +354,12 @@ int mma9551_read_status_word(struct i2c_client *client, u8 app_id, ret =mma9551_transfer (client, app_id,MMA9551_CMD_READ_STATUS , reg,NULL ,0 , (u8 *)&v,2 ); +if (ret <0 ) +return ret; + *val =be16_to_cpu (v); -return ret; +return 0 ; }EXPORT_SYMBOL (mma9551_read_status_word);
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 13/20 iio: accel: mma9551_core: Prevent uninitialized variable in mma9551_read_config_word()
In reply to Sasha LevinFrom: Harshit Mogalapalli <[email protected]>
[ Upstream commit 64a68158738ec8f520347144352f7a09bdb9e169 ]
Smatch Warns:drivers/iio/accel/mma9551_core.c:299
mma9551_read_config_word() error: uninitialized symbol 'v'.
When (offset >= 1 << 12) is true mma9551_transfer() will return -EINVAL without 'v' being initialized, so check for the error and return.
Note: No actual bug as caller checks the return value and does not use the parameter in the problem case.
--- drivers/iio/accel/mma9551_core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/iio/accel/mma9551_core.c +4 -1
@@ -296,9 +296,12 @@ int mma9551_read_config_word(struct i2c_client *client, u8 app_id, ret =mma9551_transfer (client, app_id,MMA9551_CMD_READ_CONFIG , reg,NULL ,0 , (u8 *)&v,2 ); +if (ret <0 ) +return ret; + *val =be16_to_cpu (v); -return ret; +return 0 ; }EXPORT_SYMBOL (mma9551_read_config_word);
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 14/20 firmware: coreboot: framebuffer: Ignore reserved pixel color bits
In reply to Sasha LevinFrom: Alper Nebi Yasak <[email protected]>
[ Upstream commit e6acaf25cba14661211bb72181c35dd13b24f5b3 ]
The coreboot framebuffer doesn't support transparency, its 'reserved' bit field is merely padding for byte/word alignment of pixel colors [1]. When trying to match the framebuffer to a simplefb format, the kernel driver unnecessarily requires the format's transparency bit field to exactly match this padding, even if the former is zero-width.
Due to a coreboot bug [2] (fixed upstream), some boards misreport the reserved field's size as equal to its position (0x18 for both on a 'Lick' Chromebook), and the driver fails to probe where it would have otherwise worked fine with e.g. the a8r8g8b8 or x8r8g8b8 formats.
Remove the transparency comparison with reserved bits. When the bits-per-pixel and other color components match, transparency will already be in a subset of the reserved field. Not forcing it to match reserved bits allows the driver to work on the boards which misreport the reserved field. It also enables using simplefb formats that don't have transparency bits, although this doesn't currently happen due to format support and ordering in linux/platform_data/simplefb.h.
[1] https://review.coreboot.org/plugins/gitiles/coreboot/+/4.19/src/commonlib/include/commonlib/coreboot_tables.h#255
[2] https://review.coreboot.org/plugins/gitiles/coreboot/+/4.13/src/drivers/intel/fsp2_0/graphics.c#82
--- drivers/firmware/google/framebuffer-coreboot.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/firmware/google/framebuffer-coreboot.c +1 -3
@@ -43,9 +43,7 @@ static int framebuffer_probe(struct coreboot_device *dev) fb->green_mask_pos == formats[i].green.offset && fb->green_mask_size == formats[i].green.length && fb->blue_mask_pos == formats[i].blue.offset && - fb->blue_mask_size == formats[i].blue.length && - fb->reserved_mask_pos == formats[i].transp.offset && - fb->reserved_mask_size == formats[i].transp.length) + fb->blue_mask_size == formats[i].blue.length) pdata.format = formats[i].name; }if (!pdata.format)
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 15/20 usb: host: xhci: mvebu: Iterate over array indexes instead of using pointer math
In reply to Sasha LevinFrom: Kees Cook <[email protected]>
[ Upstream commit 0fbd2cda92cdb00f72080665554a586f88bca821 ]
Walking the dram->cs array was seen as accesses beyond the first array item by the compiler. Instead, use the array index directly. This allows for run-time bounds checking under CONFIG_UBSAN_BOUNDS as well. Seen with GCC 13 with -fstrict-flex-arrays:
In function 'xhci_mvebu_mbus_config',
inlined from 'xhci_mvebu_mbus_init_quirk' at ../drivers/usb/host/xhci-mvebu.c:66:2:../drivers/usb/host/xhci-mvebu.c:37:28: warning: array subscript 0 is outside array bounds of 'const struct mbus_dram_window[0]' [-Warray-bounds=]
37 | writel(((cs->size - 1) & 0xffff0000) | (cs->mbus_attr << 8) |
| ~~^~~~~~
--- drivers/usb/host/xhci-mvebu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/xhci-mvebu.c +1 -1
@@ -33,7 +33,7 @@ static void xhci_mvebu_mbus_config(void __iomem *base,/* Program each DRAM CS in a seperate window */ for (win =0 ; win < dram->num_cs; win++) { -const struct mbus_dram_window *cs = dram->cs + win; +const struct mbus_dram_window *cs = &dram->cs[win]; writel(((cs->size - 1) & 0xffff0000) | (cs->mbus_attr << 8) | (dram->mbus_dram_target_id << 4) | 1,
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 16/20 USB: ene_usb6250: Allocate enough memory for full object
In reply to Sasha LevinFrom: Kees Cook <[email protected]>
[ Upstream commit ce33e64c1788912976b61314b56935abd4bc97ef ]
The allocation of PageBuffer is 512 bytes in size, but the dereferencing of struct ms_bootblock_idi (also size 512) happens at a calculated offset within the allocation, which means the object could potentially extend beyond the end of the allocation. Avoid this case by just allocating enough space to catch any accesses beyond the end. Seen with GCC 13:
../drivers/usb/storage/ene_ub6250.c: In function 'ms_lib_process_bootblock':../drivers/usb/storage/ene_ub6250.c:1050:44: warning: array subscript 'struct ms_bootblock_idi[0]' is partly outside array bounds of 'unsigned char[512]' [-Warray-bounds=]
1050 | if (le16_to_cpu(idi->wIDIgeneralConfiguration) != MS_IDI_GENERAL_CONF)
| ^~../include/uapi/linux/byteorder/little_endian.h:37:51: note: in definition of macro '__le16_to_cpu'
37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
| ^../drivers/usb/storage/ene_ub6250.c:1050:29: note: in expansion of macro 'le16_to_cpu'
1050 | if (le16_to_cpu(idi->wIDIgeneralConfiguration) != MS_IDI_GENERAL_CONF)
| ^~~~~~~~~~~
In file included from ../drivers/usb/storage/ene_ub6250.c:5:
In function 'kmalloc',
inlined from 'ms_lib_process_bootblock' at ../drivers/usb/storage/ene_ub6250.c:942:15:
../include/linux/slab.h:580:24: note: at offset [256, 512] into object of size 512 allocated by 'kmalloc_trace'
580 | return kmalloc_trace(
| ^~~~~~~~~~~~~~
581 | kmalloc_caches[kmalloc_type(flags)][index],
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
582 | flags, size);
| ~~~~~~~~~~~~--- drivers/usb/storage/ene_ub6250.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/storage/ene_ub6250.c +1 -1
@@ -938,7 +938,7 @@ static int ms_lib_process_bootblock(struct us_data *us, u16 PhyBlock, u8 *PageDastruct ms_lib_type_extdat ExtraData;struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; - PageBuffer =kmalloc (MS_BYTES_PER_PAGE ,GFP_KERNEL ); + PageBuffer =kzalloc (MS_BYTES_PER_PAGE *2 ,GFP_KERNEL );if (PageBuffer ==NULL )return (u32)-1 ;
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 17/20 usb: uvc: Enumerate valid values for color matching
In reply to Sasha LevinFrom: Daniel Scally <[email protected]>
[ Upstream commit e16cab9c1596e251761d2bfb5e1467950d616963 ]
The color matching descriptors defined in the UVC Specification contain 3 fields with discrete numeric values representing particular settings. Enumerate those values so that later code setting them can be more readable.
--- include/uapi/linux/usb/video.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
include/uapi/linux/usb/video.h +30 -0
@@ -179,6 +179,36 @@#define UVC_CONTROL_CAP_AUTOUPDATE (1 << 3)#define UVC_CONTROL_CAP_ASYNCHRONOUS (1 << 4) +/* 3.9.2.6 Color Matching Descriptor Values */ +enum uvc_color_primaries_values { +UVC_COLOR_PRIMARIES_UNSPECIFIED , +UVC_COLOR_PRIMARIES_BT_709_SRGB , +UVC_COLOR_PRIMARIES_BT_470_2_M , +UVC_COLOR_PRIMARIES_BT_470_2_B_G , +UVC_COLOR_PRIMARIES_SMPTE_170M , +UVC_COLOR_PRIMARIES_SMPTE_240M , +}; + +enum uvc_transfer_characteristics_values { +UVC_TRANSFER_CHARACTERISTICS_UNSPECIFIED , +UVC_TRANSFER_CHARACTERISTICS_BT_709 , +UVC_TRANSFER_CHARACTERISTICS_BT_470_2_M , +UVC_TRANSFER_CHARACTERISTICS_BT_470_2_B_G , +UVC_TRANSFER_CHARACTERISTICS_SMPTE_170M , +UVC_TRANSFER_CHARACTERISTICS_SMPTE_240M , +UVC_TRANSFER_CHARACTERISTICS_LINEAR , +UVC_TRANSFER_CHARACTERISTICS_SRGB , +}; + +enum uvc_matrix_coefficients { +UVC_MATRIX_COEFFICIENTS_UNSPECIFIED , +UVC_MATRIX_COEFFICIENTS_BT_709 , +UVC_MATRIX_COEFFICIENTS_FCC , +UVC_MATRIX_COEFFICIENTS_BT_470_2_B_G , +UVC_MATRIX_COEFFICIENTS_SMPTE_170M , +UVC_MATRIX_COEFFICIENTS_SMPTE_240M , +}; +/* ------------------------------------------------------------------------ * UVC structures */
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 18/20 kernel/fail_function: fix memory leak with using debugfs_lookup()
In reply to Sasha LevinFrom: Greg Kroah-Hartman <[email protected]>
[ Upstream commit 2bb3669f576559db273efe49e0e69f82450efbca ]
When calling debugfs_lookup() the result must have dput() called on it, otherwise the memory will leak over time. To make things simpler, just call debugfs_lookup_and_remove() instead which handles all of the logic at once.
--- kernel/fail_function.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
kernel/fail_function.c +1 -4
@@ -163,10 +163,7 @@ static void fei_debugfs_add_attr(struct fei_attr *attr)static void fei_debugfs_remove_attr (struct fei_attr *attr) { -struct dentry *dir; - - dir =debugfs_lookup (attr->kp.symbol_name, fei_debugfs_dir); -debugfs_remove_recursive (dir); +debugfs_lookup_and_remove (attr->kp.symbol_name, fei_debugfs_dir); }static int fei_kprobe_handler (struct kprobe *kp,struct pt_regs *regs)
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 19/20 PCI: Add ACS quirk for Wangxun NICs
In reply to Sasha LevinFrom: Mengyuan Lou <[email protected]>
[ Upstream commit a2b9b123ccac913e9f9b80337d687a2fe786a634 ]
Wangxun has verified there is no peer-to-peer between functions for the below selection of SFxxx, RP1000 and RP2000 NICS. They may be multi-function devices, but the hardware does not advertise ACS capability.
Add an ACS quirk for these devices so the functions can be in independent IOMMU groups.
--- drivers/pci/quirks.c | 22 ++++++++++++++++++++++ include/linux/pci_ids.h | 2 ++ 2 files changed, 24 insertions(+)
drivers/pci/quirks.c +22 -0
@@ -4843,6 +4843,26 @@ static int pci_quirk_brcm_acs(struct pci_dev *dev, u16 acs_flags) PCI_ACS_SV | PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF); } +/* +* Wangxun 10G/1G NICs have no ACS capability, and on multi-function +* devices, peer-to-peer transactions are not be used between the functions. +* So add an ACS quirk for below devices to isolate functions. +* SFxxx 1G NICs(em). +* RP1000/RP2000 10G NICs(sp). +*/ +static int pci_quirk_wangxun_nic_acs (struct pci_dev *dev,u16 acs_flags) +{ +switch (dev->device) { + case 0x0100 ... 0x010F: +case 0x1001 : +case 0x2001 : +return pci_acs_ctrl_enabled (acs_flags, +PCI_ACS_SV |PCI_ACS_RR |PCI_ACS_CR |PCI_ACS_UF ); + } + +return false; +} + static const struct pci_dev_acs_enabled { u16 vendor; u16 device;
@@ -4988,6 +5008,8 @@ static const struct pci_dev_acs_enabled { { PCI_VENDOR_ID_NXP, 0x8d9b, pci_quirk_nxp_rp_acs },/* Zhaoxin Root/Downstream Ports */ { PCI_VENDOR_ID_ZHAOXIN, PCI_ANY_ID, pci_quirk_zhaoxin_pcie_ports_acs }, +/* Wangxun nics */ + { PCI_VENDOR_ID_WANGXUN, PCI_ANY_ID, pci_quirk_wangxun_nic_acs }, { 0 } };
include/linux/pci_ids.h +2 -0
@@ -3024,6 +3024,8 @@#define PCI_DEVICE_ID_INTEL_VMD_9A0B 0x9a0b#define PCI_DEVICE_ID_INTEL_S21152BB 0xb152 +#define PCI_VENDOR_ID_WANGXUN 0x8088 +#define PCI_VENDOR_ID_SCALEMP 0x8686#define PCI_DEVICE_ID_SCALEMP_VSMP_CTL 0x1010
Signature · 1 line
2.39.2
Sasha Levin
maintainerPATCH 20/20 phy: rockchip-typec: Fix unsigned comparison with less than zero
In reply to Sasha LevinFrom: Jiapeng Chong <[email protected]>
[ Upstream commit f765c59c5a72546a2d74a92ae5d0eb0329d8e247 ]
The dp and ufp are defined as bool type, the return value type of function extcon_get_state should be int, so the type of dp and ufp are modified to int.
./drivers/phy/rockchip/phy-rockchip-typec.c:827:12-14: WARNING: Unsigned expression compared with zero: dp > 0.
--- drivers/phy/rockchip/phy-rockchip-typec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/phy/rockchip/phy-rockchip-typec.c +1 -2
@@ -808,9 +808,8 @@ static int tcphy_get_mode(struct rockchip_typec_phy *tcphy)struct extcon_dev *edev = tcphy->extcon;union extcon_property_value property;unsigned int id; -bool ufp, dp;u8 mode; -int ret; +int ret, ufp, dp;if (!edev)return MODE_DFP_USB ;
Signature · 7 lines
2.39.2 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy