6.1.16-rc1 review
Subsystems (18)
Greg Kroah-Hartman
maintainerPATCH 444/885 drivers: base: transport_class: fix possible memory leak
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit a86367803838b369fe5486ac18771d14723c258c ]
Current some drivers(like iscsi) call transport_register_device() failed, they don't call transport_destroy_device() to release the memory allocated in transport_setup_device(), because they don't know what was done, it should be internal thing to release the resource in register function. So fix this leak by calling destroy function inside register function.
--- include/linux/transport_class.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
include/linux/transport_class.h +7 -1
@@ -70,8 +70,14 @@ void transport_destroy_device(struct device *);static inline int transport_register_device (struct device *dev) { +int ret; +transport_setup_device (dev); -return transport_add_device (dev); + ret =transport_add_device (dev); +if (ret) +transport_destroy_device (dev); + +return ret; } static inline void
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 445/885 drivers: base: transport_class: fix resource leak when transport_add_device() fails
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit e5da06b27ff5a148e42265c8e306670a9d913969 ]
The normal call sequence of using transport class is:
Add path:transport_setup_device()
transport_setup_classdev() // call sas_host_setup() heretransport_add_device() // if fails, need call transport_destroy_device()transport_configure_device()
Remove path:transport_remove_device()
transport_remove_classdev // call sas_host_remove() heretransport_destroy_device()
If transport_add_device() fails, need call transport_destroy_device() to free memory, but in this case, ->remove() is not called, and the resources allocated in ->setup() are leaked. So fix these leaks by calling ->remove() in transport_add_class_device() if it returns error.
--- drivers/base/transport_class.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/base/transport_class.c +16 -1
@@ -155,12 +155,27 @@ static int transport_add_class_device(struct attribute_container *cont,struct device *dev, struct device *classdev) { + struct transport_class *tclass = class_to_transport_class(cont->class);int error =attribute_container_add_class_device (classdev);struct transport_container *tcont =attribute_container_to_transport_container (cont); -if (!error && tcont->statistics) +if (error) + goto err_remove; + +if (tcont->statistics) { error =sysfs_create_group (&classdev->kobj, tcont->statistics); +if (error) + goto err_del; + } + +return 0 ; + +err_del: +attribute_container_class_device_del (classdev); +err_remove: +if (tclass->remove) + tclass->remove (tcont, dev, classdev);return error; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 446/885 firmware: dmi-sysfs: Fix null-ptr-deref in dmi_sysfs_register_handle
In reply to Greg Kroah-HartmanFrom: Chen Zhongjin <[email protected]>
[ Upstream commit 18e126e97c961f7a93823795c879d7c085fe5098 ]
KASAN reported a null-ptr-deref error:
KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f] CPU: 0 PID: 1373 Comm: modprobe Hardware name: QEMU Standard PC (i440FX + PIIX, 1996) RIP: 0010:dmi_sysfs_entry_release ... Call Trace: <TASK> kobject_put dmi_sysfs_register_handle (drivers/firmware/dmi-sysfs.c:540) dmi_sysfs dmi_decode_table (drivers/firmware/dmi_scan.c:133) dmi_walk (drivers/firmware/dmi_scan.c:1115) dmi_sysfs_init (drivers/firmware/dmi-sysfs.c:149) dmi_sysfs do_one_initcall (init/main.c:1296) ... Kernel panic - not syncing: Fatal exception Kernel Offset: 0x4000000 from 0xffffffff81000000 ---[ end Kernel panic - not syncing: Fatal exception ]---
It is because previous patch added kobject_put() to release the memory which will call dmi_sysfs_entry_release() and list_del().
However, list_add_tail(entry->list) is called after the error block, so the list_head is uninitialized and cannot be deleted.
Move error handling to after list_add_tail to fix this.
--- drivers/firmware/dmi-sysfs.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/firmware/dmi-sysfs.c +5 -5
@@ -603,16 +603,16 @@ static void __init dmi_sysfs_register_handle(const struct dmi_header *dh, *ret =kobject_init_and_add (&entry->kobj, &dmi_sysfs_entry_ktype,NULL ,"%d-%d" , dh->type, entry->instance); -if (*ret) { -kobject_put (&entry->kobj); -return ; - } -/* Thread on the global list for cleanup */ spin_lock (&entry_list_lock);list_add_tail (&entry->list, &entry_list);spin_unlock (&entry_list_lock); +if (*ret) { +kobject_put (&entry->kobj); +return ; + } +/* Handle specializations by type */ switch (dh->type) {case DMI_ENTRY_SYSTEM_EVENT_LOG :
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 447/885 fotg210-udc: Add missing completion handler
In reply to Greg Kroah-HartmanFrom: Fabian Vogt <[email protected]>
[ Upstream commit e55f67391fa986f7357edba0ca59e668d99c3a5f ]
This is used when responding to GET_STATUS requests. Without this, it crashes on completion.
--- drivers/usb/gadget/udc/fotg210-udc.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/usb/gadget/udc/fotg210-udc.c +16 -0
@@ -706,6 +706,20 @@ static int fotg210_is_epnstall(struct fotg210_ep *ep)return value &INOUTEPMPSR_STL_EP ?1 :0 ; } +/* For EP0 requests triggered by this driver (currently GET_STATUS response) */ +static void fotg210_ep0_complete (struct usb_ep *_ep,struct usb_request *req) +{ +struct fotg210_ep *ep; +struct fotg210_udc *fotg210; + + ep = container_of(_ep, struct fotg210_ep, ep); + fotg210 = ep->fotg210; + +if (req->status || req->actual != req->length) { +dev_warn (&fotg210->gadget.dev,"EP0 request failed: %d\n" , req->status); + } +} +static void fotg210_get_status (struct fotg210_udc *fotg210,struct usb_ctrlrequest *ctrl) {
@@ -1171,6 +1185,8 @@ static int fotg210_udc_probe(struct platform_device *pdev)if (fotg210->ep0_req ==NULL ) goto err_map; + fotg210->ep0_req->complete = fotg210_ep0_complete; +fotg210_init (fotg210);fotg210_disable_unplug (fotg210);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 448/885 dmaengine: dw-edma: Fix missing src/dst address of interleaved xfers
In reply to Greg Kroah-HartmanFrom: Serge Semin <[email protected]>
[ Upstream commit 13b6299cf66165a442089fa895a7f70250703584 ]
Interleaved DMA transfer support was added by 85e7518f42c8 ("dmaengine:
dw-edma: Add device_prep_interleave_dma() support"), but depending on the selected channel, either source or destination address are left uninitialized which was obviously wrong.
Initialize the destination address of the eDMA burst descriptors for DEV_TO_MEM interleaved operations and the source address for MEM_TO_DEV operations.
--- drivers/dma/dw-edma/dw-edma-core.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/dma/dw-edma/dw-edma-core.c +4 -0
@@ -455,6 +455,8 @@ dw_edma_device_transfer(struct dw_edma_transfer *xfer)* and destination addresses are increased * by the same portion (data length) */ + }else if (xfer->type ==EDMA_XFER_INTERLEAVED ) { + burst->dar = dst_addr; } }else { burst->dar = dst_addr;
@@ -470,6 +472,8 @@ dw_edma_device_transfer(struct dw_edma_transfer *xfer)* and destination addresses are increased * by the same portion (data length) */ + }else if (xfer->type ==EDMA_XFER_INTERLEAVED ) { + burst->sar = src_addr; } }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 449/885 fpga: microchip-spi: move SPI I/O buffers out of stack
In reply to Greg Kroah-HartmanFrom: Ivan Bornyakov <[email protected]>
[ Upstream commit 1da53d23a41c5f77963984d8da5623ed56918ada ]
As spi-summary doc says:
Quoted 3 lines
I/O buffers use the usual Linux rules, and must be DMA-safe. You'd normally allocate them from the heap or free page pool. Don't use the stack, or anything that's declared "static".
Replace spi_write() with spi_write_then_read(), which is dma-safe for on-stack buffers. Use cacheline aligned buffers for transfers used in spi_sync_transfer().
Although everything works OK with stack-located I/O buffers, better follow the doc to be safe.
--- drivers/fpga/microchip-spi.c | 93 ++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 46 deletions(-)
drivers/fpga/microchip-spi.c +47 -46
@@ -42,46 +42,55 @@struct mpf_priv {struct spi_device *spi;bool program_mode; +u8 tx__aligned(ARCH_KMALLOC_MINALIGN) ; +u8 rx; }; -static int mpf_read_status (struct spi_device *spi) +static int mpf_read_status (struct mpf_priv *priv) { -u8 status =0 , status_command =MPF_SPI_READ_STATUS ; -struct spi_transfer xfers[2 ] = {0 }; -int ret; -/* * HW status is returned on MISO in the first byte after CS went * active. However, first reading can be inadequate, so we submit * two identical SPI transfers and use result of the later one. */ - xfers[0 ].tx_buf = &status_command; - xfers[1 ].tx_buf = &status_command; - xfers[0 ].rx_buf = &status; - xfers[1 ].rx_buf = &status; - xfers[0 ].len =1 ; - xfers[1 ].len =1 ; - xfers[0 ].cs_change =1 ; +struct spi_transfer xfers[2 ] = { + { + .tx_buf = &priv->tx, + .rx_buf = &priv->rx, + .len =1 , + .cs_change =1 , + }, { + .tx_buf = &priv->tx, + .rx_buf = &priv->rx, + .len =1 , + }, + }; +u8 status; +int ret; + + priv->tx =MPF_SPI_READ_STATUS ; + + ret =spi_sync_transfer (priv->spi, xfers,2 ); +if (ret) +return ret; - ret =spi_sync_transfer (spi, xfers,2 ); + status = priv->rx;if ((status &MPF_STATUS_SPI_VIOLATION ) || (status &MPF_STATUS_SPI_ERROR )) - ret = -EIO ; +return -EIO ; -return ret ? : status; +return status; }static enum fpga_mgr_states mpf_ops_state (struct fpga_manager *mgr) {struct mpf_priv *priv = mgr->priv; -struct spi_device *spi;bool program_mode;int status; - spi = priv->spi; program_mode = priv->program_mode; - status =mpf_read_status (spi); + status =mpf_read_status (priv);if (!program_mode && !status)return FPGA_MGR_STATE_OPERATING ;
@@ -186,12 +195,12 @@ static int mpf_ops_parse_header(struct fpga_manager *mgr, }/* Poll HW status until busy bit is cleared and mask bits are set. */ -static int mpf_poll_status (struct spi_device *spi,u8 mask) +static int mpf_poll_status (struct mpf_priv *priv,u8 mask) {int status, retries =MPF_STATUS_POLL_RETRIES ;while (retries--) { - status =mpf_read_status (spi); + status =mpf_read_status (priv);if (status <0 )return status;
@@ -205,32 +214,32 @@ static int mpf_poll_status(struct spi_device *spi, u8 mask)return -EBUSY ; } -static int mpf_spi_write (struct spi_device *spi,const void *buf,size_t buf_size) +static int mpf_spi_write (struct mpf_priv *priv,const void *buf,size_t buf_size) { -int status =mpf_poll_status (spi,0 ); +int status =mpf_poll_status (priv,0 );if (status <0 )return status; -return spi_write (spi, buf, buf_size); +return spi_write_then_read (priv->spi, buf, buf_size,NULL ,0 ); } -static int mpf_spi_write_then_read (struct spi_device *spi, +static int mpf_spi_write_then_read (struct mpf_priv *priv,const void *txbuf,size_t txbuf_size,void *rxbuf,size_t rxbuf_size) {const u8 read_command[] = {MPF_SPI_READ_DATA };int ret; - ret =mpf_spi_write (spi, txbuf, txbuf_size); + ret =mpf_spi_write (priv, txbuf, txbuf_size);if (ret)return ret; - ret =mpf_poll_status (spi,MPF_STATUS_READY ); + ret =mpf_poll_status (priv,MPF_STATUS_READY );if (ret <0 )return ret; -return spi_write_then_read (spi, read_command,sizeof (read_command), +return spi_write_then_read (priv->spi, read_command,sizeof (read_command), rxbuf, rxbuf_size); }
@@ -242,7 +251,6 @@ static int mpf_ops_write_init(struct fpga_manager *mgr,const u8 isc_en_command[] = {MPF_SPI_ISC_ENABLE };struct mpf_priv *priv = mgr->priv;struct device *dev = &mgr->dev; -struct spi_device *spi;u32 isc_ret =0 ;int ret;
@@ -251,9 +259,7 @@ static int mpf_ops_write_init(struct fpga_manager *mgr,return -EOPNOTSUPP ; } - spi = priv->spi; - - ret =mpf_spi_write_then_read (spi, isc_en_command,sizeof (isc_en_command), + ret =mpf_spi_write_then_read (priv, isc_en_command,sizeof (isc_en_command), &isc_ret,sizeof (isc_ret));if (ret || isc_ret) { dev_err(dev, "Failed to enable ISC: spi_ret %d, isc_ret %u\n",
@@ -261,7 +267,7 @@ static int mpf_ops_write_init(struct fpga_manager *mgr,return -EFAULT ; } - ret =mpf_spi_write (spi, program_mode,sizeof (program_mode)); + ret =mpf_spi_write (priv, program_mode,sizeof (program_mode));if (ret) {dev_err (dev,"Failed to enter program mode: %d\n" , ret);return ret;
@@ -274,11 +280,9 @@ static int mpf_ops_write_init(struct fpga_manager *mgr,static int mpf_ops_write (struct fpga_manager *mgr,const char *buf,size_t count) { -u8 spi_frame_command[] = {MPF_SPI_FRAME };struct spi_transfer xfers[2 ] = {0 };struct mpf_priv *priv = mgr->priv;struct device *dev = &mgr->dev; -struct spi_device *spi;int ret, i;if (count %MPF_SPI_FRAME_SIZE ) {
@@ -287,18 +291,18 @@ static int mpf_ops_write(struct fpga_manager *mgr, const char *buf, size_t countreturn -EINVAL ; } - spi = priv->spi; - - xfers[0 ].tx_buf = spi_frame_command; - xfers[0 ].len =sizeof (spi_frame_command); + xfers[0 ].tx_buf = &priv->tx; + xfers[0 ].len =1 ;for (i =0 ; i < count /MPF_SPI_FRAME_SIZE ; i++) { xfers[1 ].tx_buf = buf + i *MPF_SPI_FRAME_SIZE ; xfers[1 ].len =MPF_SPI_FRAME_SIZE ; - ret =mpf_poll_status (spi,0 ); -if (ret >=0 ) - ret =spi_sync_transfer (spi, xfers,ARRAY_SIZE (xfers)); + ret =mpf_poll_status (priv,0 ); +if (ret >=0 ) { + priv->tx =MPF_SPI_FRAME ; + ret =spi_sync_transfer (priv->spi, xfers,ARRAY_SIZE (xfers)); + }if (ret) { dev_err(dev, "Failed to write bitstream frame %d/%zu\n",
@@ -317,12 +321,9 @@ static int mpf_ops_write_complete(struct fpga_manager *mgr,const u8 release_command[] = {MPF_SPI_RELEASE };struct mpf_priv *priv = mgr->priv;struct device *dev = &mgr->dev; -struct spi_device *spi;int ret; - spi = priv->spi; - - ret =mpf_spi_write (spi, isc_dis_command,sizeof (isc_dis_command)); + ret =mpf_spi_write (priv, isc_dis_command,sizeof (isc_dis_command));if (ret) {dev_err (dev,"Failed to disable ISC: %d\n" , ret);return ret;
@@ -330,7 +331,7 @@ static int mpf_ops_write_complete(struct fpga_manager *mgr,usleep_range (1000 ,2000 ); - ret =mpf_spi_write (spi, release_command,sizeof (release_command)); + ret =mpf_spi_write (priv, release_command,sizeof (release_command));if (ret) {dev_err (dev,"Failed to exit program mode: %d\n" , ret);return ret;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 450/885 fpga: microchip-spi: rewrite status polling in a time measurable way
In reply to Greg Kroah-HartmanFrom: Ivan Bornyakov <[email protected]>
[ Upstream commit 88e705697e801299a13ecaf2ba54599964fe711c ]
Original busy loop with retries count in mpf_poll_status() is not too reliable, as it takes different times on different systems. Replace it with read_poll_timeout() macro.
While at it, fix polling stop condition to met function's original intention declared in the comment. The issue with original polling stop condition is that it stops if any of mask bits is set, while intention was to stop if all mask bits is set. This was not noticible because only MPF_STATUS_READY is passed as mask argument and it is BIT(1).
--- drivers/fpga/microchip-spi.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-)
drivers/fpga/microchip-spi.c +17 -15
@@ -6,6 +6,7 @@#include <asm/unaligned.h> #include <linux/delay.h> #include <linux/fpga/fpga-mgr.h> +#include <linux/iopoll.h> #include <linux/module.h> #include <linux/of_device.h> #include <linux/spi/spi.h>
@@ -33,7 +34,7 @@#define MPF_BITS_PER_COMPONENT_SIZE 22 -#define MPF_STATUS_POLL_RETRIES 10000 +#define MPF_STATUS_POLL_TIMEOUT (2 * USEC_PER_SEC)#define MPF_STATUS_BUSY BIT(0)#define MPF_STATUS_READY BIT(1)#define MPF_STATUS_SPI_VIOLATION BIT(2)
@@ -194,24 +195,25 @@ static int mpf_ops_parse_header(struct fpga_manager *mgr,return 0 ; } -/* Poll HW status until busy bit is cleared and mask bits are set. */ static int mpf_poll_status (struct mpf_priv *priv,u8 mask) { -int status, retries =MPF_STATUS_POLL_RETRIES ; +int ret, status; -while (retries--) { - status =mpf_read_status (priv); -if (status <0 ) -return status; - -if (status &MPF_STATUS_BUSY ) -continue ; - -if (!mask || (status & mask)) -return status; - } +/* +* Busy poll HW status. Polling stops if any of the following +* conditions are met: +* - timeout is reached +* - mpf_read_status() returns an error +* - busy bit is cleared AND mask bits are set +*/ + ret =read_poll_timeout (mpf_read_status, status, + (status <0 ) || + ((status & (MPF_STATUS_BUSY | mask)) == mask), +0 ,MPF_STATUS_POLL_TIMEOUT , false, priv); +if (ret <0 ) +return ret; -return -EBUSY ; +return status; }static int mpf_spi_write (struct mpf_priv *priv,const void *buf,size_t buf_size)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 451/885 usb: early: xhci-dbc: Fix a potential out-of-bound memory access
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit a4a97ab3db5c081eb6e7dba91306adefb461e0bd ]
If xdbc_bulk_write() fails, the values in 'buf' can be anything. So the string is not guaranteed to be NULL terminated when xdbc_trace() is called.
Reserve an extra byte, which will be zeroed automatically because 'buf' is a static variable, in order to avoid troubles, should it happen.
--- drivers/usb/early/xhci-dbc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/early/xhci-dbc.c +2 -1
@@ -874,7 +874,8 @@ static int xdbc_bulk_write(const char *bytes, int size)static void early_xdbc_write (struct console *con,const char *str,u32 n) { -static char buf[XDBC_MAX_PACKET ]; +/* static variables are zeroed, so buf is always NULL terminated */ +static char buf[XDBC_MAX_PACKET +1 ];int chunk, ret;int use_cr =0 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 452/885 tty: serial: fsl_lpuart: Fix the wrong RXWATER setting for rx dma case
In reply to Greg Kroah-HartmanFrom: Sherry Sun <[email protected]>
[ Upstream commit 9ad9df8447547febe9dd09b040f4528a09e495f0 ]
The RXWATER value must be greater than 0 according to the LPUART reference manual. And when the number of datawords in the receive FIFO is greater than RXWATER, an interrupt or a DMA request is generated, so no need to set the different value for lpuart interrupt case and dma case. Here delete the wrong RXWATER setting for dma case directly.
--- drivers/tty/serial/fsl_lpuart.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/tty/serial/fsl_lpuart.c +0 -6
@@ -1684,12 +1684,6 @@ static void lpuart32_configure(struct lpuart_port *sport) {unsigned long temp; -if (sport->lpuart_dma_rx_use) { -/* RXWATER must be 0 */ - temp =lpuart32_read (&sport->port,UARTWATER ); - temp &= ~(UARTWATER_WATER_MASK <<UARTWATER_RXWATER_OFF ); -lpuart32_write (&sport->port, temp,UARTWATER ); - } temp =lpuart32_read (&sport->port,UARTCTRL );if (!sport->lpuart_dma_rx_use) temp |=UARTCTRL_RIE ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 453/885 RDMA/cxgb4: add null-ptr-check after ip_dev_find()
In reply to Greg Kroah-HartmanFrom: Nikita Zhandarovich <[email protected]>
[ Upstream commit ef42520240aacfc0d46c8d780c051d135a8dc9b7 ]
ip_dev_find() may return NULL and assign it to pdev which is dereferenced later.
Fix this by checking the return value of ip_dev_find() for NULL similar to the way it is done with other instances of said function.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/infiniband/hw/cxgb4/cm.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/infiniband/hw/cxgb4/cm.c +4 -0
@@ -4144,6 +4144,10 @@ static int rx_pkt(struct c4iw_dev *dev, struct sk_buff *skb)if (neigh->dev->flags &IFF_LOOPBACK ) { pdev =ip_dev_find (&init_net, iph->daddr); +if (!pdev) { +pr_err ("%s - failed to find device!\n" , __func__); + goto free_dst; + } e =cxgb4_l2t_get (dev->rdev.lldi.l2t, neigh, pdev,0 ); pi = (struct port_info *)netdev_priv (pdev);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 454/885 usb: musb: mediatek: dont unregister something that wasnt registered
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit ba883de971d1ad018f3083d9195b8abe54d87407 ]
This function only calls mtk_otg_switch_init() when the ->port_mode is MUSB_OTG so the clean up code should only call mtk_otg_switch_exit() for that mode.
--- drivers/usb/musb/mediatek.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/musb/mediatek.c +2 -1
@@ -294,7 +294,8 @@ static int mtk_musb_init(struct musb *musb) err_phy_power_on:phy_exit (glue->phy); err_phy_init: -mtk_otg_switch_exit (glue); +if (musb->port_mode ==MUSB_OTG ) +mtk_otg_switch_exit (glue);return ret; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 455/885 usb: gadget: configfs: Restrict symlink creation is UDC already binded
In reply to Greg Kroah-HartmanFrom: Udipto Goswami <[email protected]>
[ Upstream commit 89e7252d6c7e7eeb31971cd7df987316ecc64ff5 ]
During enumeration or composition switch,a userspace process agnostic of the conventions of configs can try to create function symlinks even after the UDC is bound to current config which is not correct. Potentially it can create duplicates within the current config.
Prevent this by adding a check if udc_name already exists, then bail out of cfg_link.
Following is an example:
Step1:
ln -s X1 ffs.a
-->cfg_link
--> usb_get_function(ffs.a)
->ffs_alloc CFG->FUNC_LIST: <ffs.a> C->FUNCTION: <empty>
Step2:
echo udc.name > /config/usb_gadget/g1/UDC
--> UDC_store
->composite_bind ->usb_add_function CFG->FUNC_LIST: <empty> C->FUNCTION: <ffs.a>
Step3:
ln -s Y1 ffs.a
-->cfg_link
-->usb_get_function(ffs.a)
->ffs_alloc CFG->FUNC_LIST: <ffs.a> C->FUNCTION: <ffs.a>
both the lists corresponds to the same function instance ffs.a but the usb_function* pointer is different because in step 3 ffs_alloc has created a new reference to usb_function* for ffs.a and added it to cfg_list.
Step4:
Now a composition switch involving <ffs.b,ffs.a> is executed.
the composition switch will involve 3 things:
1. unlinking the previous functions existing
2. creating new symlinks
3. writing UDC
However, the composition switch is generally taken care by userspace process which creates the symlinks in its own nomenclature(X*) and removes only those.
So it won't be able to remove Y1 which user had created by own.
Due to this the new symlinks cannot be created for ffs.a since the entry already exists in CFG->FUNC_LIST.
The state of the CFG->FUNC_LIST is as follows:
CFG->FUNC_LIST: <ffs.a>
--- drivers/usb/gadget/configfs.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/usb/gadget/configfs.c +6 -0
@@ -429,6 +429,12 @@ static int config_usb_cfg_link(* from another gadget or a random directory. * Also a function instance can only be linked once. */ + +if (gi->composite.gadget_driver.udc_name) { + ret = -EINVAL ; + goto out; + } +list_for_each_entry (iter, &gi->available_func, cfs_list) {if (iter != fi)continue ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 456/885 phy: mediatek: remove temporary variable @mask_
In reply to Greg Kroah-HartmanFrom: Chunfeng Yun <[email protected]>
[ Upstream commit 49094d928618309877c50e589f23e639a3b0c453 ]
Remove the temporary @mask_, this may cause build warning when use clang compiler for powerpc, but can't reproduce it when compile for arm64. the build warning is caused by:
"warning: result of comparison of constant 18446744073709551615 with expression of type (aka 'unsigned long') is always false [-Wtautological-constant-out-of-range-compare]"
More information provided in below lore link.
After removing @mask_, there is a "CHECK:MACRO_ARG_REUSE" when run checkpatch.pl, but due to @mask is constant, no reuse problem will happen.
--- drivers/phy/mediatek/phy-mtk-io.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/phy/mediatek/phy-mtk-io.h +2 -2
@@ -39,8 +39,8 @@ static inline void mtk_phy_update_bits(void __iomem *reg, u32 mask, u32 val)/* field @mask shall be constant and continuous */ #define mtk_phy_update_field (reg, mask, val) \ ({ \ - typeof(mask) mask_ = (mask); \ - mtk_phy_update_bits(reg, mask_, FIELD_PREP(mask_, val)); \ + BUILD_BUG_ON_MSG(!__builtin_constant_p(mask), "mask is not constant"); \ + mtk_phy_update_bits(reg, mask, FIELD_PREP(mask, val)); \ })#endif
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 457/885 PCI: mt7621: Delay phy ports initialization
In reply to Greg Kroah-HartmanFrom: Sergio Paracuellos <[email protected]>
[ Upstream commit 0cb2a8f3456ff1cc51d571e287a48e8fddc98ec2 ]
Some devices like ZBT WE1326 and ZBT WF3526-P and some Netgear models need to delay phy port initialization after calling the mt7621_pcie_init_port() driver function to get into reliable boots for both warm and hard resets.
The delay required to detect the ports seems to be in the range [75-100] milliseconds.
If the ports are not detected the controller is not functional.
There is no datasheet or something similar to really understand why this extra delay is needed only for these devices and it is not for most of the boards that are built on mt7621 SoC.
This issue has been reported by openWRT community and the complete discussion is in [0]. The 100 milliseconds delay has been tested in all devices to validate it.
Add the extra 100 milliseconds delay to fix the issue.
[0]: https://github.com/openwrt/openwrt/pull/11220
--- drivers/pci/controller/pcie-mt7621.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pci/controller/pcie-mt7621.c +2 -0
@@ -60,6 +60,7 @@#define PCIE_PORT_LINKUP BIT(0)#define PCIE_PORT_CNT 3 +#define INIT_PORTS_DELAY_MS 100#define PERST_DELAY_MS 100/**
@@ -369,6 +370,7 @@ static int mt7621_pcie_init_ports(struct mt7621_pcie *pcie) } } +msleep (INIT_PORTS_DELAY_MS );mt7621_pcie_reset_ep_deassert (pcie); tmp =NULL ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 458/885 iommu: dart: Add suspend/resume support
In reply to Greg Kroah-HartmanFrom: Hector Martin <[email protected]>
[ Upstream commit 3d68bbb81b1a64e279180eee1ed0e2c590b5029e ]
We need to save/restore the TCR/TTBR registers, since they are lost on power gate.
Stable-dep-of: cf5c1c87c239 ("iommu/dart: Fix apple_dart_device_group for PCI groups")
--- drivers/iommu/apple-dart.c | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)
drivers/iommu/apple-dart.c +43 -0
@@ -121,6 +121,9 @@ struct apple_dart {struct iommu_group *sid2group[DART_MAX_STREAMS ];struct iommu_device iommu; + +u32 save_tcr[DART_MAX_STREAMS ]; +u32 save_ttbr[DART_MAX_STREAMS ][DART_MAX_TTBR ]; };/*
@@ -932,6 +935,45 @@ static const struct apple_dart_hw apple_dart_hw_t6000 = { .fmt = APPLE_DART2, }; +static __maybe_unused int apple_dart_suspend (struct device *dev) +{ +struct apple_dart *dart =dev_get_drvdata (dev); +unsigned int sid, idx; + +for (sid =0 ; sid <DART_MAX_STREAMS ; sid++) { + dart->save_tcr[sid] =readl_relaxed (dart->regs +DART_TCR (sid)); +for (idx =0 ; idx <DART_MAX_TTBR ; idx++) + dart->save_ttbr[sid][idx] = +readl (dart->regs +DART_TTBR (sid, idx)); + } + +return 0 ; +} + +static __maybe_unused int apple_dart_resume (struct device *dev) +{ +struct apple_dart *dart =dev_get_drvdata (dev); +unsigned int sid, idx; +int ret; + + ret =apple_dart_hw_reset (dart); +if (ret) { +dev_err (dev,"Failed to reset DART on resume\n" ); +return ret; + } + +for (sid =0 ; sid <DART_MAX_STREAMS ; sid++) { +for (idx =0 ; idx <DART_MAX_TTBR ; idx++) +writel (dart->save_ttbr[sid][idx], + dart->regs +DART_TTBR (sid, idx)); +writel (dart->save_tcr[sid], dart->regs +DART_TCR (sid)); + } + +return 0 ; +} + +DEFINE_SIMPLE_DEV_PM_OPS (apple_dart_pm_ops, apple_dart_suspend, apple_dart_resume); +static const struct of_device_id apple_dart_of_match[] = { { .compatible ="apple,t8103-dart" , .data = &apple_dart_hw_t8103 }, { .compatible ="apple,t6000-dart" , .data = &apple_dart_hw_t6000 },
@@ -944,6 +986,7 @@ static struct platform_driver apple_dart_driver = { .name = "apple-dart", .of_match_table = apple_dart_of_match, .suppress_bind_attrs = true, + .pm = pm_sleep_ptr(&apple_dart_pm_ops), }, .probe = apple_dart_probe, .remove = apple_dart_remove,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 459/885 iommu: dart: Support >64 stream IDs
In reply to Greg Kroah-HartmanFrom: Hector Martin <[email protected]>
[ Upstream commit 510d4072df7fcf27dcd2dc1942d58b2cc02b03f2 ]
T8110 DARTs have up to 256 SIDs, so we need to switch to a bitmap to handle them properly.
Stable-dep-of: cf5c1c87c239 ("iommu/dart: Fix apple_dart_device_group for PCI groups")
--- drivers/iommu/apple-dart.c | 114 +++++++++++++++++++++++-------------- 1 file changed, 71 insertions(+), 43 deletions(-)
drivers/iommu/apple-dart.c +71 -43
@@ -34,11 +34,10 @@#include "dma-iommu.h" -#define DART_MAX_STREAMS 16 +#define DART_MAX_STREAMS 256#define DART_MAX_TTBR 4#define MAX_DARTS_PER_DEVICE 2 -#define DART_STREAM_ALL 0xffff#define DART_PARAMS1 0x00#define DART_PARAMS_PAGE_SHIFT GENMASK(27, 24)
@@ -85,6 +84,8 @@struct apple_dart_hw {u32 oas;enum io_pgtable_fmt fmt; + +int max_sid_count; };/*
@@ -116,6 +117,7 @@ struct apple_dart {spinlock_t lock;u32 pgsize; +u32 num_streams; u32 supports_bypass : 1; u32 force_bypass : 1;
@@ -143,11 +145,11 @@ struct apple_dart {*/ struct apple_dart_stream_map {struct apple_dart *dart; -unsigned long sidmap; + DECLARE_BITMAP(sidmap, DART_MAX_STREAMS); };struct apple_dart_atomic_stream_map {struct apple_dart *dart; -atomic64_t sidmap; +atomic_long_t sidmap[BITS_TO_LONGS (DART_MAX_STREAMS )]; };/*
@@ -205,50 +207,55 @@ static struct apple_dart_domain *to_dart_domain(struct iommu_domain *dom)static void apple_dart_hw_enable_translation (struct apple_dart_stream_map *stream_map) { +struct apple_dart *dart = stream_map->dart;int sid; -for_each_set_bit (sid, &stream_map->sidmap,DART_MAX_STREAMS ) +for_each_set_bit (sid, stream_map->sidmap, dart->num_streams)writel (DART_TCR_TRANSLATE_ENABLE , - stream_map->dart->regs +DART_TCR (sid)); + dart->regs +DART_TCR (sid)); }static void apple_dart_hw_disable_dma (struct apple_dart_stream_map *stream_map) { +struct apple_dart *dart = stream_map->dart;int sid; -for_each_set_bit (sid, &stream_map->sidmap,DART_MAX_STREAMS ) -writel (0 , stream_map->dart->regs +DART_TCR (sid)); +for_each_set_bit (sid, stream_map->sidmap, dart->num_streams) +writel (0 , dart->regs +DART_TCR (sid)); }static void apple_dart_hw_enable_bypass (struct apple_dart_stream_map *stream_map) { +struct apple_dart *dart = stream_map->dart;int sid;WARN_ON (!stream_map->dart->supports_bypass); -for_each_set_bit (sid, &stream_map->sidmap,DART_MAX_STREAMS ) +for_each_set_bit (sid, stream_map->sidmap, dart->num_streams)writel (DART_TCR_BYPASS0_ENABLE |DART_TCR_BYPASS1_ENABLE , - stream_map->dart->regs +DART_TCR (sid)); + dart->regs +DART_TCR (sid)); }static void apple_dart_hw_set_ttbr (struct apple_dart_stream_map *stream_map,u8 idx,phys_addr_t paddr) { +struct apple_dart *dart = stream_map->dart;int sid;WARN_ON (paddr & ((1 <<DART_TTBR_SHIFT ) -1 )); -for_each_set_bit (sid, &stream_map->sidmap,DART_MAX_STREAMS ) +for_each_set_bit (sid, stream_map->sidmap, dart->num_streams)writel (DART_TTBR_VALID | (paddr >>DART_TTBR_SHIFT ), - stream_map->dart->regs +DART_TTBR (sid, idx)); + dart->regs +DART_TTBR (sid, idx)); }static void apple_dart_hw_clear_ttbr (struct apple_dart_stream_map *stream_map,u8 idx) { +struct apple_dart *dart = stream_map->dart;int sid; -for_each_set_bit (sid, &stream_map->sidmap,DART_MAX_STREAMS ) -writel (0 , stream_map->dart->regs +DART_TTBR (sid, idx)); +for_each_set_bit (sid, stream_map->sidmap, dart->num_streams) +writel (0 , dart->regs +DART_TTBR (sid, idx)); } static void
@@ -270,7 +277,7 @@ apple_dart_hw_stream_command(struct apple_dart_stream_map *stream_map,spin_lock_irqsave (&stream_map->dart->lock, flags); -writel (stream_map->sidmap, stream_map->dart->regs +DART_STREAM_SELECT ); +writel (stream_map->sidmap[0 ], stream_map->dart->regs +DART_STREAM_SELECT );writel (command, stream_map->dart->regs +DART_STREAM_COMMAND ); ret = readl_poll_timeout_atomic(
@@ -283,7 +290,7 @@ apple_dart_hw_stream_command(struct apple_dart_stream_map *stream_map,if (ret) {dev_err (stream_map->dart->dev,"busy bit did not clear after command %x for streams %lx\n" , - command, stream_map->sidmap); + command, stream_map->sidmap[0 ]);return ret; }
@@ -301,6 +308,7 @@ static int apple_dart_hw_reset(struct apple_dart *dart) {u32 config;struct apple_dart_stream_map stream_map; +int i; config =readl (dart->regs +DART_CONFIG );if (config &DART_CONFIG_LOCK ) {
@@ -310,12 +318,14 @@ static int apple_dart_hw_reset(struct apple_dart *dart) } stream_map.dart = dart; - stream_map.sidmap =DART_STREAM_ALL ; +bitmap_zero (stream_map.sidmap,DART_MAX_STREAMS ); +bitmap_set (stream_map.sidmap,0 , dart->num_streams);apple_dart_hw_disable_dma (&stream_map);apple_dart_hw_clear_all_ttbrs (&stream_map);/* enable all streams globally since TCR is used to control isolation */ -writel (DART_STREAM_ALL , dart->regs +DART_STREAMS_ENABLE ); +for (i =0 ; i <BITS_TO_U32 (dart->num_streams); i++) +writel (U32_MAX , dart->regs +DART_STREAMS_ENABLE +4 * i);/* clear any pending errors before the interrupt is unmasked */ writel (readl (dart->regs +DART_ERROR ), dart->regs +DART_ERROR );
@@ -325,13 +335,16 @@ static int apple_dart_hw_reset(struct apple_dart *dart)static void apple_dart_domain_flush_tlb (struct apple_dart_domain *domain) { -int i; +int i, j;struct apple_dart_atomic_stream_map *domain_stream_map;struct apple_dart_stream_map stream_map;for_each_stream_map (i, domain, domain_stream_map) { stream_map.dart = domain_stream_map->dart; - stream_map.sidmap =atomic64_read (&domain_stream_map->sidmap); + +for (j =0 ; j <BITS_TO_LONGS (stream_map.dart->num_streams); j++) + stream_map.sidmap[j] =atomic_long_read (&domain_stream_map->sidmap[j]); +apple_dart_hw_invalidate_tlb (&stream_map); } }
@@ -416,7 +429,7 @@ static int apple_dart_finalize_domain(struct iommu_domain *domain,struct apple_dart *dart = cfg->stream_maps[0 ].dart;struct io_pgtable_cfg pgtbl_cfg;int ret =0 ; -int i; +int i, j;mutex_lock (&dart_domain->init_lock);
@@ -425,8 +438,9 @@ static int apple_dart_finalize_domain(struct iommu_domain *domain,for (i =0 ; i <MAX_DARTS_PER_DEVICE ; ++i) { dart_domain->stream_maps[i].dart = cfg->stream_maps[i].dart; -atomic64_set (&dart_domain->stream_maps[i].sidmap, - cfg->stream_maps[i].sidmap); +for (j =0 ; j <BITS_TO_LONGS (dart->num_streams); j++) +atomic_long_set (&dart_domain->stream_maps[i].sidmap[j], + cfg->stream_maps[i].sidmap[j]); } pgtbl_cfg = (struct io_pgtable_cfg ){
@@ -461,7 +475,7 @@ apple_dart_mod_streams(struct apple_dart_atomic_stream_map *domain_maps,struct apple_dart_stream_map *master_maps, bool add_streams) { - int i; + int i, j;for (i =0 ; i <MAX_DARTS_PER_DEVICE ; ++i) {if (domain_maps[i].dart != master_maps[i].dart)
@@ -471,12 +485,14 @@ apple_dart_mod_streams(struct apple_dart_atomic_stream_map *domain_maps,for (i =0 ; i <MAX_DARTS_PER_DEVICE ; ++i) {if (!domain_maps[i].dart)break ; -if (add_streams) -atomic64_or (master_maps[i].sidmap, - &domain_maps[i].sidmap); -else -atomic64_and (~master_maps[i].sidmap, - &domain_maps[i].sidmap); +for (j =0 ; j <BITS_TO_LONGS (domain_maps[i].dart->num_streams); j++) { +if (add_streams) +atomic_long_or (master_maps[i].sidmap[j], + &domain_maps[i].sidmap[j]); +else +atomic_long_and (~master_maps[i].sidmap[j], + &domain_maps[i].sidmap[j]); + } }return 0 ;
@@ -640,14 +656,14 @@ static int apple_dart_of_xlate(struct device *dev, struct of_phandle_args *args)for (i =0 ; i <MAX_DARTS_PER_DEVICE ; ++i) {if (cfg->stream_maps[i].dart == dart) { - cfg->stream_maps[i].sidmap |=1 << sid; +set_bit (sid, cfg->stream_maps[i].sidmap);return 0 ; } }for (i =0 ; i <MAX_DARTS_PER_DEVICE ; ++i) {if (!cfg->stream_maps[i].dart) { cfg->stream_maps[i].dart = dart; - cfg->stream_maps[i].sidmap =1 << sid; +set_bit (sid, cfg->stream_maps[i].sidmap);return 0 ; } }
@@ -666,7 +682,7 @@ static void apple_dart_release_group(void *iommu_data)mutex_lock (&apple_dart_groups_lock);for_each_stream_map (i, group_master_cfg, stream_map) -for_each_set_bit (sid, &stream_map->sidmap,DART_MAX_STREAMS ) +for_each_set_bit (sid, stream_map->sidmap, stream_map->dart->num_streams) stream_map->dart->sid2group[sid] =NULL ;kfree (iommu_data);
@@ -685,7 +701,7 @@ static struct iommu_group *apple_dart_device_group(struct device *dev)mutex_lock (&apple_dart_groups_lock);for_each_stream_map (i, cfg, stream_map) { -for_each_set_bit (sid, &stream_map->sidmap,DART_MAX_STREAMS ) { +for_each_set_bit (sid, stream_map->sidmap, stream_map->dart->num_streams) {struct iommu_group *stream_group = stream_map->dart->sid2group[sid];
@@ -724,7 +740,7 @@ static struct iommu_group *apple_dart_device_group(struct device *dev) apple_dart_release_group);for_each_stream_map (i, cfg, stream_map) -for_each_set_bit (sid, &stream_map->sidmap,DART_MAX_STREAMS ) +for_each_set_bit (sid, stream_map->sidmap, stream_map->dart->num_streams) stream_map->dart->sid2group[sid] = group; res = group;
@@ -869,16 +885,26 @@ static int apple_dart_probe(struct platform_device *pdev)if (ret)return ret; - ret =apple_dart_hw_reset (dart); -if (ret) - goto err_clk_disable; - dart_params[0 ] =readl (dart->regs +DART_PARAMS1 ); dart_params[1 ] =readl (dart->regs +DART_PARAMS2 ); dart->pgsize =1 <<FIELD_GET (DART_PARAMS_PAGE_SHIFT , dart_params[0 ]); dart->supports_bypass = dart_params[1 ] &DART_PARAMS_BYPASS_SUPPORT ; + + dart->num_streams = dart->hw->max_sid_count; + +if (dart->num_streams >DART_MAX_STREAMS ) { +dev_err (&pdev->dev,"Too many streams (%d > %d)\n" , + dart->num_streams,DART_MAX_STREAMS ); + ret = -EINVAL ; + goto err_clk_disable; + } + dart->force_bypass = dart->pgsize >PAGE_SIZE ; + ret =apple_dart_hw_reset (dart); +if (ret) + goto err_clk_disable; + ret =request_irq (dart->irq, apple_dart_irq,IRQF_SHARED ,"apple-dart fault handler" , dart);if (ret)
@@ -897,8 +923,8 @@ static int apple_dart_probe(struct platform_device *pdev)dev_info ( &pdev->dev, -"DART [pagesize %x, bypass support: %d, bypass forced: %d] initialized\n" , - dart->pgsize, dart->supports_bypass, dart->force_bypass); +"DART [pagesize %x, %d streams, bypass support: %d, bypass forced: %d] initialized\n" , + dart->pgsize, dart->num_streams, dart->supports_bypass, dart->force_bypass);return 0 ; err_sysfs_remove:
@@ -929,10 +955,12 @@ static int apple_dart_remove(struct platform_device *pdev)static const struct apple_dart_hw apple_dart_hw_t8103 = { .oas =36 , .fmt =APPLE_DART , + .max_sid_count =16 , };static const struct apple_dart_hw apple_dart_hw_t6000 = { .oas =42 , .fmt =APPLE_DART2 , + .max_sid_count =16 , };static __maybe_unused int apple_dart_suspend (struct device *dev)
@@ -940,7 +968,7 @@ static __maybe_unused int apple_dart_suspend(struct device *dev)struct apple_dart *dart =dev_get_drvdata (dev);unsigned int sid, idx; -for (sid =0 ; sid <DART_MAX_STREAMS ; sid++) { +for (sid =0 ; sid < dart->num_streams; sid++) { dart->save_tcr[sid] =readl_relaxed (dart->regs +DART_TCR (sid));for (idx =0 ; idx <DART_MAX_TTBR ; idx++) dart->save_ttbr[sid][idx] =
@@ -962,7 +990,7 @@ static __maybe_unused int apple_dart_resume(struct device *dev)return ret; } -for (sid =0 ; sid <DART_MAX_STREAMS ; sid++) { +for (sid =0 ; sid < dart->num_streams; sid++) {for (idx =0 ; idx <DART_MAX_TTBR ; idx++)writel (dart->save_ttbr[sid][idx], dart->regs +DART_TTBR (sid, idx));
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 460/885 iommu/dart: Fix apple_dart_device_group for PCI groups
In reply to Greg Kroah-HartmanFrom: Sven Peter <[email protected]>
[ Upstream commit cf5c1c87c2391649e05e58ecc6dfc3dc5ebebc05 ]
pci_device_group() can return an already existing IOMMU group if the PCI device's pagetables have to be shared with another one due to bus toplogy, isolation features and/or DMA alias quirks. apple_dart_device_group() however assumes that the group has just been created and overwrites its iommudata which will eventually lead to apple_dart_release_group leaving stale entries in sid2group. Fix that by merging the iommudata if the returned group already exists.
--- drivers/iommu/apple-dart.c | 51 ++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 7 deletions(-)
drivers/iommu/apple-dart.c +44 -7
@@ -689,6 +689,29 @@ static void apple_dart_release_group(void *iommu_data)mutex_unlock (&apple_dart_groups_lock); } +static int apple_dart_merge_master_cfg (struct apple_dart_master_cfg *dst, +struct apple_dart_master_cfg *src) +{ +/* +* We know that this function is only called for groups returned from +* pci_device_group and that all Apple Silicon platforms never spread +* PCIe devices from the same bus across multiple DARTs such that we can +* just assume that both src and dst only have the same single DART. +*/ +if (src->stream_maps[1 ].dart) +return -EINVAL ; +if (dst->stream_maps[1 ].dart) +return -EINVAL ; +if (src->stream_maps[0 ].dart != dst->stream_maps[0 ].dart) +return -EINVAL ; + +bitmap_or (dst->stream_maps[0 ].sidmap, + dst->stream_maps[0 ].sidmap, + src->stream_maps[0 ].sidmap, + dst->stream_maps[0 ].dart->num_streams); +return 0 ; +} +static struct iommu_group *apple_dart_device_group (struct device *dev) {int i, sid;
@@ -730,14 +753,28 @@ static struct iommu_group *apple_dart_device_group(struct device *dev)if (!group) goto out; - group_master_cfg =kmemdup (cfg,sizeof (*group_master_cfg),GFP_KERNEL ); -if (!group_master_cfg) { -iommu_group_put (group); - goto out; - } + group_master_cfg =iommu_group_get_iommudata (group); +if (group_master_cfg) { +int ret; -iommu_group_set_iommudata (group, group_master_cfg, - apple_dart_release_group); + ret =apple_dart_merge_master_cfg (group_master_cfg, cfg); +if (ret) { +dev_err (dev,"Failed to merge DART IOMMU grups.\n" ); +iommu_group_put (group); + res =ERR_PTR (ret); + goto out; + } + }else { + group_master_cfg =kmemdup (cfg,sizeof (*group_master_cfg), +GFP_KERNEL ); +if (!group_master_cfg) { +iommu_group_put (group); + goto out; + } + +iommu_group_set_iommudata (group, group_master_cfg, + apple_dart_release_group); + }for_each_stream_map (i, cfg, stream_map)for_each_set_bit (sid, stream_map->sidmap, stream_map->dart->num_streams)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 461/885 iommu/vt-d: Set No Execute Enable bit in PASID table entry
In reply to Greg Kroah-HartmanFrom: Lu Baolu <[email protected]>
[ Upstream commit e06d24435596c8afcaa81c0c498f5b0ec4ee2b7c ]
Setup No Execute Enable bit (Bit 133) of a scalable mode PASID entry. This is to allow the use of XD bit of the first level page table.
--- drivers/iommu/intel/pasid.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/iommu/intel/pasid.c +11 -0
@@ -362,6 +362,16 @@ static inline void pasid_set_page_snoop(struct pasid_entry *pe, bool value)pasid_set_bits (&pe->val[1 ],1 <<23 , value <<23 ); } +/* +* Setup No Execute Enable bit (Bit 133) of a scalable mode PASID +* entry. It is required when XD bit of the first level page table +* entry is about to be set. +*/ +static inline void pasid_set_nxe (struct pasid_entry *pe) +{ +pasid_set_bits (&pe->val[2 ],1 <<5 ,1 <<5 ); +} +/* * Setup the Page Snoop (PGSNP) field (Bit 88) of a scalable mode * PASID entry.
@@ -555,6 +565,7 @@ int intel_pasid_setup_first_level(struct intel_iommu *iommu,pasid_set_domain_id (pte, did);pasid_set_address_width (pte, iommu->agaw);pasid_set_page_snoop (pte, !!ecap_smpwc (iommu->ecap)); +pasid_set_nxe (pte);/* Setup Present and PASID Granular Transfer Type: */ pasid_set_translation_type (pte,PASID_ENTRY_PGTT_FL_ONLY );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 462/885 power: supply: remove faulty cooling logic
In reply to Greg Kroah-HartmanFrom: Andreas Kemnade <[email protected]>
[ Upstream commit c85c191694cb1cf290b11059b3d2de8a2732ffd0 ]
The rn5t618 power driver fails to register
a cooling device because POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX is missing but availability is not checked before registering cooling device. After improved error checking in the thermal code, the registration of the power supply fails entirely.
Checking for availability of _MAX before registering cooling device fixes the rn5t618 problem. But the whole logic feels questionable.
First, the logic is inverted here:
the code tells: max_current = max_cooling but
0 = max_cooling, so there needs to be some inversion
in the code which cannot be found. Comparing with other cooling devices, it can be found that value for fan speed is not inverted, value for cpufreq cooling is inverted (similar situation as here lowest frequency = max cooling)
Second, analyzing usage of _MAX: it is seems that maximum capabilities of charging controller are specified and not of the battery. Probably there is not too much mismatch in the drivers actually implementing that. So nothing has exploded yet. So there is no easy and safe way to specifify a max cooling value now.
Conclusion for now (as a regression fix) just remove the cooling device registration and do it properly later on.
--- drivers/power/supply/power_supply_core.c | 93 ------------------------ 1 file changed, 93 deletions(-)
drivers/power/supply/power_supply_core.c +0 -93
@@ -1187,83 +1187,6 @@ static void psy_unregister_thermal(struct power_supply *psy) thermal_zone_device_unregister(psy->tzd); } -/* thermal cooling device callbacks */ -static int ps_get_max_charge_cntl_limit (struct thermal_cooling_device *tcd, -unsigned long *state) -{ -struct power_supply *psy; -union power_supply_propval val; -int ret; - - psy = tcd->devdata; - ret =power_supply_get_property (psy, -POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX , &val); -if (ret) -return ret; - - *state = val.intval; - -return ret; -} - -static int ps_get_cur_charge_cntl_limit (struct thermal_cooling_device *tcd, -unsigned long *state) -{ -struct power_supply *psy; -union power_supply_propval val; -int ret; - - psy = tcd->devdata; - ret =power_supply_get_property (psy, -POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT , &val); -if (ret) -return ret; - - *state = val.intval; - -return ret; -} - -static int ps_set_cur_charge_cntl_limit (struct thermal_cooling_device *tcd, -unsigned long state) -{ -struct power_supply *psy; -union power_supply_propval val; -int ret; - - psy = tcd->devdata; - val.intval = state; - ret = psy->desc->set_property (psy, -POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT , &val); - -return ret; -} - -static const struct thermal_cooling_device_ops psy_tcd_ops = { - .get_max_state = ps_get_max_charge_cntl_limit, - .get_cur_state = ps_get_cur_charge_cntl_limit, - .set_cur_state = ps_set_cur_charge_cntl_limit, -}; - -static int psy_register_cooler (struct power_supply *psy) -{ -/* Register for cooling device if psy can control charging */ -if (psy_has_property (psy->desc,POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT )) { - psy->tcd =thermal_cooling_device_register ( - (char *)psy->desc->name, - psy, &psy_tcd_ops); -return PTR_ERR_OR_ZERO (psy->tcd); - } - -return 0 ; -} - -static void psy_unregister_cooler (struct power_supply *psy) -{ -if (IS_ERR_OR_NULL (psy->tcd)) -return ; -thermal_cooling_device_unregister (psy->tcd); -}#else static int psy_register_thermal (struct power_supply *psy) {
@@ -1273,15 +1196,6 @@ static int psy_register_thermal(struct power_supply *psy)static void psy_unregister_thermal (struct power_supply *psy) { } - -static int psy_register_cooler (struct power_supply *psy) -{ -return 0 ; -} - -static void psy_unregister_cooler (struct power_supply *psy) -{ -}#endif static struct power_supply *__must_check
@@ -1355,10 +1269,6 @@ __power_supply_register(struct device *parent,if (rc) goto register_thermal_failed; - rc =psy_register_cooler (psy); -if (rc) - goto register_cooler_failed; - rc =power_supply_create_triggers (psy);if (rc) goto create_triggers_failed;
@@ -1388,8 +1298,6 @@ __power_supply_register(struct device *parent, add_hwmon_sysfs_failed:power_supply_remove_triggers (psy); create_triggers_failed: -psy_unregister_cooler (psy); -register_cooler_failed:psy_unregister_thermal (psy); register_thermal_failed: wakeup_init_failed:
@@ -1541,7 +1449,6 @@ void power_supply_unregister(struct power_supply *psy)sysfs_remove_link (&psy->dev.kobj,"powers" );power_supply_remove_hwmon_sysfs (psy);power_supply_remove_triggers (psy); -psy_unregister_cooler (psy);psy_unregister_thermal (psy);device_init_wakeup (&psy->dev, false);device_unregister (&psy->dev);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 463/885 RDMA/cxgb4: Fix potential null-ptr-deref in pass_establish()
In reply to Greg Kroah-HartmanFrom: Nikita Zhandarovich <[email protected]>
[ Upstream commit 283861a4c52c1ea4df3dd1b6fc75a50796ce3524 ]
If get_ep_from_tid() fails to lookup non-NULL value for ep, ep is dereferenced later regardless of whether it is empty. This patch adds a simple sanity check to fix the issue.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/infiniband/hw/cxgb4/cm.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/infiniband/hw/cxgb4/cm.c +3 -0
@@ -2676,6 +2676,9 @@ static int pass_establish(struct c4iw_dev *dev, struct sk_buff *skb)u16 tcp_opt =ntohs (req->tcp_opt); ep =get_ep_from_tid (dev, tid); +if (!ep) +return 0 ; +pr_debug ("ep %p tid %u\n" , ep, ep->hwtid); ep->snd_seq =be32_to_cpu (req->snd_isn); ep->rcv_seq =be32_to_cpu (req->rcv_isn);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 464/885 usb: max-3421: Fix setting of I/O pins
In reply to Greg Kroah-HartmanFrom: Mark Tomlinson <[email protected]>
[ Upstream commit a7efe3fc7cbe27c6eb2c2a3ab612194f8f800f4c ]
To update the I/O pins, the registers are read/modified/written. The read operation incorrectly always read the first register. Although wrong, there wasn't any impact as all the output pins are always written, and the inputs are read only anyway.
--- drivers/usb/host/max3421-hcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/max3421-hcd.c +1 -1
@@ -1436,7 +1436,7 @@ max3421_spi_thread(void *dev_id)* use spi_wr_buf(). */ for (i =0 ; i <ARRAY_SIZE (max3421_hcd->iopins); ++i) { -u8 val =spi_rd8 (hcd,MAX3421_REG_IOPINS1 ); +u8 val =spi_rd8 (hcd,MAX3421_REG_IOPINS1 + i); val = ((val &0xf0 ) | (max3421_hcd->iopins[i] &0x0f ));
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 465/885 RDMA/irdma: Cap MSIX used to online CPUs + 1
In reply to Greg Kroah-HartmanFrom: Mustafa Ismail <[email protected]>
[ Upstream commit 9cd9842c46996ef62173c36619c746f57416bcb0 ]
The irdma driver can use a maximum number of msix vectors equal to num_online_cpus() + 1 and the kernel warning stack below is shown if that number is exceeded.
The kernel throws a warning as the driver tries to update the affinity hint with a CPU mask greater than the max CPU IDs. Fix this by capping the MSIX vectors to num_online_cpus() + 1.
WARNING: CPU: 7 PID: 23655 at include/linux/cpumask.h:106 irdma_cfg_ceq_vector+0x34c/0x3f0 [irdma] RIP: 0010:irdma_cfg_ceq_vector+0x34c/0x3f0 [irdma] Call Trace: irdma_rt_init_hw+0xa62/0x1290 [irdma] ? irdma_alloc_local_mac_entry+0x1a0/0x1a0 [irdma] ? __is_kernel_percpu_address+0x63/0x310 ? rcu_read_lock_held_common+0xe/0xb0 ? irdma_lan_unregister_qset+0x280/0x280 [irdma] ? irdma_request_reset+0x80/0x80 [irdma] ? ice_get_qos_params+0x84/0x390 [ice] irdma_probe+0xa40/0xfc0 [irdma] ? rcu_read_lock_bh_held+0xd0/0xd0 ? irdma_remove+0x140/0x140 [irdma] ? rcu_read_lock_sched_held+0x62/0xe0 ? down_write+0x187/0x3d0 ? auxiliary_match_id+0xf0/0x1a0 ? irdma_remove+0x140/0x140 [irdma] auxiliary_bus_probe+0xa6/0x100 __driver_probe_device+0x4a4/0xd50 ? __device_attach_driver+0x2c0/0x2c0 driver_probe_device+0x4a/0x110 __driver_attach+0x1aa/0x350 bus_for_each_dev+0x11d/0x1b0 ? subsys_dev_iter_init+0xe0/0xe0 bus_add_driver+0x3b1/0x610 driver_register+0x18e/0x410 ? 0xffffffffc0b88000 irdma_init_module+0x50/0xaa [irdma] do_one_initcall+0x103/0x5f0 ? perf_trace_initcall_level+0x420/0x420 ? do_init_module+0x4e/0x700 ? __kasan_kmalloc+0x7d/0xa0 ? kmem_cache_alloc_trace+0x188/0x2b0 ? kasan_unpoison+0x21/0x50 do_init_module+0x1d1/0x700 load_module+0x3867/0x5260 ? layout_and_allocate+0x3990/0x3990 ? rcu_read_lock_held_common+0xe/0xb0 ? rcu_read_lock_sched_held+0x62/0xe0 ? rcu_read_lock_bh_held+0xd0/0xd0 ? __vmalloc_node_range+0x46b/0x890 ? lock_release+0x5c8/0xba0 ? alloc_vm_area+0x120/0x120 ? selinux_kernel_module_from_file+0x2a5/0x300 ? __inode_security_revalidate+0xf0/0xf0 ? __do_sys_init_module+0x1db/0x260 __do_sys_init_module+0x1db/0x260 ? load_module+0x5260/0x5260 ? do_syscall_64+0x22/0x450 do_syscall_64+0xa5/0x450 entry_SYSCALL_64_after_hwframe+0x66/0xdb
--- drivers/infiniband/hw/irdma/hw.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/infiniband/hw/irdma/hw.c +2 -0
@@ -483,6 +483,8 @@ static int irdma_save_msix_info(struct irdma_pci_f *rf) iw_qvlist->num_vectors = rf->msix_count;if (rf->msix_count <=num_online_cpus ()) rf->msix_shared = true; +else if (rf->msix_count >num_online_cpus () +1 ) + rf->msix_count =num_online_cpus () +1 ; pmsix = rf->msix_entries;for (i =0 , ceq_idx =0 ; i < rf->msix_count; i++, iw_qvinfo++) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 466/885 serial: fsl_lpuart: fix RS485 RTS polariy inverse issue
In reply to Greg Kroah-HartmanFrom: Shenwei Wang <[email protected]>
[ Upstream commit 3957b9501a5a8fa709ae4a47483714491471f6db ]
The previous 'commit 846651eca073 ("serial: fsl_lpuart: RS485 RTS polariy is inverse")' only fixed the inverse issue on lpuart 8bit platforms.
This is a follow-up patch to fix the RS485 polarity inverse issue on lpuart 32bit platforms.
--- drivers/tty/serial/fsl_lpuart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/fsl_lpuart.c +2 -2
@@ -1393,9 +1393,9 @@ static int lpuart32_config_rs485(struct uart_port *port, struct ktermios *termio* Note: UART is assumed to be active high. */ if (rs485->flags &SER_RS485_RTS_ON_SEND ) - modem &= ~UARTMODEM_TXRTSPOL ; -else if (rs485->flags &SER_RS485_RTS_AFTER_SEND ) modem |=UARTMODEM_TXRTSPOL ; +else if (rs485->flags &SER_RS485_RTS_AFTER_SEND ) + modem &= ~UARTMODEM_TXRTSPOL ; }lpuart32_write (&sport->port, modem,UARTMODIR );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 467/885 tty: serial: imx: Handle RS485 DE signal active high
In reply to Greg Kroah-HartmanFrom: Marek Vasut <[email protected]>
[ Upstream commit 79d0224f6bf296d04cd843cfc49921b19c97bb09 ]
The default polarity of RS485 DE signal is active high. This driver does not handle such case properly. Currently, when a pin is multiplexed as a UART CTS_B on boot, this pin is pulled HIGH by the i.MX UART CTS circuit, which activates DE signal on the RS485 transceiver and thus behave as if the RS485 was transmitting data, so the system blocks the RS485 bus when it starts and until user application takes over. This behavior is not OK. The problem consists of two separate parts.
First, the i.MX UART IP requires UCR1 UARTEN and UCR2 RXEN to be set for UCR2 CTSC and CTS bits to have any effect. The UCR2 CTSC bit permits the driver to set CTS (RTS_B or RS485 DE signal) to either level sychronous to the internal UART IP clock. Compared to other options, like GPIO CTS control, this has the benefit of being synchronous to the UART IP clock and thus without glitches or bus delays. The reason for the CTS design is likely because when the Receiver is disabled, the UART IP can never indicate that it is ready to receive data by assering CTS signal, so the CTS is always pulled HIGH by default.
When the port is closed by user space, imx_uart_stop_rx() clears UCR2 RXEN bit, and imx_uart_shutdown() clears UCR1 UARTEN bit. This disables UART Receiver and UART itself, and forces CTS signal HIGH, which leads to the RS485 bus being blocked because RS485 DE is incorrectly active.
The proposed solution for this problem is to keep the Receiver running even after the port is closed, but in loopback mode. This disconnects the RX FIFO input from the RXD external signal, and since UCR2 TXEN is cleared, the UART Transmitter is disabled, so nothing can feed data in the RX FIFO. Because the Receiver is still enabled, the UCR2 CTSC and CTS bits still have effect and the CTS (RS485 DE) control is retained.
Note that in case of RS485 DE signal active low, there is no problem and no special handling is necessary. The CTS signal defaults to HIGH, thus the RS485 is by default set to Receive and the bus is not blocked.
Note that while there is the possibility to control CTS using GPIO with either CTS polarity, this has the downside of not being synchronous to the UART IP clock and thus glitchy and susceptible to slow DE switching.
Second, on boot, before the UART driver probe callback is called, the driver core triggers pinctrl_init_done() and configures the IOMUXC to default state. At this point, UCR1 UARTEN and UCR2 RXEN are both still cleared, but UART CTS_B (RS485 DE) is configured as CTS function, thus the RTS signal is pulled HIGH by the UART IP CTS circuit.
One part of the solution here is to enable UCR1 UARTEN and UCR2 RXEN and UTS loopback in this driver probe callback, thus unblocking the CTSC and CTS control early on. But this is still too late, since the pin control is already configured and CTS has been pulled HIGH for a short period of time.
When Linux kernel boots and this driver is bound, the pin control is set to special "init" state if the state is available, and driver can switch the "default" state afterward when ready. This state can be used to set the CTS line as a GPIO in DT temporarily, and a GPIO hog can force such GPIO to LOW, thus keeping the RS485 DE line LOW early on boot. Once the driver takes over and UCR1 UARTEN and UCR2 RXEN and UTS loopback are all enabled, the driver can switch to "default" pin control state and control the CTS line as function instead. DT binding example is below:
"
&gpio6 {
rts-init-hog {
gpio-hog;
gpios = <5 0>;
output-low;
line-name = "rs485-de"; };
};
&uart5 { /* DHCOM UART2 */
pinctrl-0 = <&pinctrl_uart5>;
pinctrl-1 = <&pinctrl_uart5_init>;
pinctrl-names = "default", "init";
...
};pinctrl_uart5_init: uart5-init-grp {
fsl,pins = <
...
MX6QDL_PAD_CSI0_DAT19__GPIO6_IO05 0x30b1
Quoted 1 line
;
};
pinctrl_uart5: uart5-grp {
fsl,pins = <
...
MX6QDL_PAD_CSI0_DAT19__UART5_CTS_B 0x30b1
Quoted 1 line
;
};
"
Stable-dep-of: ef25e16ea967 ("tty: serial: imx: disable Ageing Timer interrupt request irq")
--- drivers/tty/serial/imx.c | 64 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 58 insertions(+), 6 deletions(-)
drivers/tty/serial/imx.c +58 -6
@@ -489,7 +489,7 @@ static void imx_uart_stop_tx(struct uart_port *port)static void imx_uart_stop_rx (struct uart_port *port) {struct imx_port *sport = (struct imx_port *)port; -u32 ucr1, ucr2, ucr4; +u32 ucr1, ucr2, ucr4, uts; ucr1 =imx_uart_readl (sport,UCR1 ); ucr2 =imx_uart_readl (sport,UCR2 );
@@ -505,7 +505,18 @@ static void imx_uart_stop_rx(struct uart_port *port)imx_uart_writel (sport, ucr1,UCR1 );imx_uart_writel (sport, ucr4,UCR4 ); - ucr2 &= ~UCR2_RXEN ; +/* See SER_RS485_ENABLED/UTS_LOOP comment in imx_uart_probe() */ +if (port->rs485.flags &SER_RS485_ENABLED && + port->rs485.flags &SER_RS485_RTS_ON_SEND && + sport->have_rtscts && !sport->have_rtsgpio) { + uts =imx_uart_readl (sport,imx_uart_uts_reg (sport)); + uts |=UTS_LOOP ; +imx_uart_writel (sport, uts,imx_uart_uts_reg (sport)); + ucr2 |=UCR2_RXEN ; + }else { + ucr2 &= ~UCR2_RXEN ; + } +imx_uart_writel (sport, ucr2,UCR2 ); }
@@ -1393,7 +1404,7 @@ static int imx_uart_startup(struct uart_port *port)int retval, i;unsigned long flags;int dma_is_inited =0 ; -u32 ucr1, ucr2, ucr3, ucr4; +u32 ucr1, ucr2, ucr3, ucr4, uts; retval =clk_prepare_enable (sport->clk_per);if (retval)
@@ -1498,6 +1509,11 @@ static int imx_uart_startup(struct uart_port *port)imx_uart_writel (sport, ucr2,UCR2 ); } +/* See SER_RS485_ENABLED/UTS_LOOP comment in imx_uart_probe() */ + uts =imx_uart_readl (sport,imx_uart_uts_reg (sport)); + uts &= ~UTS_LOOP ; +imx_uart_writel (sport, uts,imx_uart_uts_reg (sport)); +spin_unlock_irqrestore (&sport->port.lock, flags);return 0 ;
@@ -1507,7 +1523,7 @@ static void imx_uart_shutdown(struct uart_port *port) {struct imx_port *sport = (struct imx_port *)port;unsigned long flags; -u32 ucr1, ucr2, ucr4; +u32 ucr1, ucr2, ucr4, uts;if (sport->dma_is_enabled) {dmaengine_terminate_sync (sport->dma_chan_tx);
@@ -1551,7 +1567,18 @@ static void imx_uart_shutdown(struct uart_port *port)spin_lock_irqsave (&sport->port.lock, flags); ucr1 =imx_uart_readl (sport,UCR1 ); - ucr1 &= ~(UCR1_TRDYEN |UCR1_RRDYEN |UCR1_RTSDEN |UCR1_UARTEN |UCR1_RXDMAEN |UCR1_ATDMAEN ); + ucr1 &= ~(UCR1_TRDYEN |UCR1_RRDYEN |UCR1_RTSDEN |UCR1_RXDMAEN |UCR1_ATDMAEN ); +/* See SER_RS485_ENABLED/UTS_LOOP comment in imx_uart_probe() */ +if (port->rs485.flags &SER_RS485_ENABLED && + port->rs485.flags &SER_RS485_RTS_ON_SEND && + sport->have_rtscts && !sport->have_rtsgpio) { + uts =imx_uart_readl (sport,imx_uart_uts_reg (sport)); + uts |=UTS_LOOP ; +imx_uart_writel (sport, uts,imx_uart_uts_reg (sport)); + ucr1 |=UCR1_UARTEN ; + }else { + ucr1 &= ~UCR1_UARTEN ; + }imx_uart_writel (sport, ucr1,UCR1 ); ucr4 =imx_uart_readl (sport,UCR4 );
@@ -2213,7 +2240,7 @@ static int imx_uart_probe(struct platform_device *pdev)void __iomem *base;u32 dma_buf_conf[2 ];int ret =0 ; -u32 ucr1; +u32 ucr1, ucr2, uts;struct resource *res;int txirq, rxirq, rtsirq;
@@ -2350,6 +2377,31 @@ static int imx_uart_probe(struct platform_device *pdev) ucr1 &= ~(UCR1_ADEN |UCR1_TRDYEN |UCR1_IDEN |UCR1_RRDYEN |UCR1_RTSDEN );imx_uart_writel (sport, ucr1,UCR1 ); +/* +* In case RS485 is enabled without GPIO RTS control, the UART IP +* is used to control CTS signal. Keep both the UART and Receiver +* enabled, otherwise the UART IP pulls CTS signal always HIGH no +* matter how the UCR2 CTSC and CTS bits are set. To prevent any +* data from being fed into the RX FIFO, enable loopback mode in +* UTS register, which disconnects the RX path from external RXD +* pin and connects it to the Transceiver, which is disabled, so +* no data can be fed to the RX FIFO that way. +*/ +if (sport->port.rs485.flags &SER_RS485_ENABLED && + sport->have_rtscts && !sport->have_rtsgpio) { + uts =imx_uart_readl (sport,imx_uart_uts_reg (sport)); + uts |=UTS_LOOP ; +imx_uart_writel (sport, uts,imx_uart_uts_reg (sport)); + + ucr1 =imx_uart_readl (sport,UCR1 ); + ucr1 |=UCR1_UARTEN ; +imx_uart_writel (sport, ucr1,UCR1 ); + + ucr2 =imx_uart_readl (sport,UCR2 ); + ucr2 |=UCR2_RXEN ; +imx_uart_writel (sport, ucr2,UCR2 ); + } +if (!imx_uart_is_imx1 (sport) && sport->dte_mode) {/* * The DCEDTE bit changes the direction of DSR, DCD, DTR and RI
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 468/885 tty: serial: imx: disable Ageing Timer interrupt request irq
In reply to Greg Kroah-HartmanFrom: Peng Fan <[email protected]>
[ Upstream commit ef25e16ea9674b713a68c3bda821556ce9901254 ]
There maybe pending USR interrupt before requesting irq, however uart_add_one_port has not executed, so there will be kernel panic:
[ 0.795668] Unable to handle kernel NULL pointer dereference at virtual addre ss 0000000000000080 [ 0.802701] Mem abort info: [ 0.805367] ESR = 0x0000000096000004 [ 0.808950] EC = 0x25: DABT (current EL), IL = 32 bits [ 0.814033] SET = 0, FnV = 0 [ 0.816950] EA = 0, S1PTW = 0 [ 0.819950] FSC = 0x04: level 0 translation fault [ 0.824617] Data abort info: [ 0.827367] ISV = 0, ISS = 0x00000004 [ 0.831033] CM = 0, WnR = 0 [ 0.833866] [0000000000000080] user address but active_mm is swapper [ 0.839951] Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP [ 0.845953] Modules linked in: [ 0.848869] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.1.1+g56321e101aca #1 [ 0.855617] Hardware name: Freescale i.MX8MP EVK (DT) [ 0.860452] pstate: 000000c5 (nzcv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 0.867117] pc : __imx_uart_rxint.constprop.0+0x11c/0x2c0 [ 0.872283] lr : imx_uart_int+0xf8/0x1ec
The issue only happends in the inmate linux when Jailhouse hypervisor enabled. The test procedure is:
while true; do
jailhouse enable imx8mp.cell
jailhouse cell linux xxxx
sleep 10
jailhouse cell destroy 1
jailhouse disable
sleep 5
done
And during the upper test, press keys to the 2nd linux console. When jailhouse cell destroy 1, the 2nd linux has no chance to put the uart to a quiese state, so USR1/2 may has pending interrupts. Then when jailhosue cell linux xx to start 2nd linux again, the issue trigger.
In order to disable irqs before requesting them, both UCR1 and UCR2 irqs should be disabled, so here fix that, disable the Ageing Timer interrupt in UCR2 as UCR1 does.
--- drivers/tty/serial/imx.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/tty/serial/imx.c +5 -0
@@ -2377,6 +2377,11 @@ static int imx_uart_probe(struct platform_device *pdev) ucr1 &= ~(UCR1_ADEN |UCR1_TRDYEN |UCR1_IDEN |UCR1_RRDYEN |UCR1_RTSDEN );imx_uart_writel (sport, ucr1,UCR1 ); +/* Disable Ageing Timer interrupt */ + ucr2 =imx_uart_readl (sport,UCR2 ); + ucr2 &= ~UCR2_ATEN ; +imx_uart_writel (sport, ucr2,UCR2 ); +/* * In case RS485 is enabled without GPIO RTS control, the UART IP * is used to control CTS signal. Keep both the UART and Receiver
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 469/885 driver core: fw_devlink: Add DL_FLAG_CYCLE support to device links
In reply to Greg Kroah-HartmanFrom: Saravana Kannan <[email protected]>
[ Upstream commit 67cad5c67019c38126b749621665b6723d3ae7e6 ]
fw_devlink uses DL_FLAG_SYNC_STATE_ONLY device link flag for two purposes:
1. To allow a parent device to proxy its child device's dependency on a supplier so that the supplier doesn't get its sync_state() callback before the child device/consumer can be added and probed. In this usage scenario, we need to ignore cycles for ensure correctness of sync_state() callbacks.
2. When there are dependency cycles in firmware, we don't know which of those dependencies are valid. So, we have to ignore them all wrt probe ordering while still making sure the sync_state() callbacks come correctly.
However, when detecting dependency cycles, there can be multiple dependency cycles between two devices that we need to detect. For example:
A -> B -> A and A -> C -> B -> A.
To detect multiple cycles correct, we need to be able to differentiate DL_FLAG_SYNC_STATE_ONLY device links used for (1) vs (2) above.
To allow this differentiation, add a DL_FLAG_CYCLE that can be use to mark use case (2). We can then use the DL_FLAG_CYCLE to decide which DL_FLAG_SYNC_STATE_ONLY device links to follow when looking for dependency cycles.
--- drivers/base/core.c | 28 ++++++++++++++++++---------- include/linux/device.h | 1 + 2 files changed, 19 insertions(+), 10 deletions(-)
drivers/base/core.c +18 -10
@@ -271,6 +271,12 @@ static bool device_is_ancestor(struct device *dev, struct device *target)return false; } +static inline bool device_link_flag_is_sync_state_only (u32 flags) +{ +return (flags & ~(DL_FLAG_INFERRED |DL_FLAG_CYCLE )) == + (DL_FLAG_SYNC_STATE_ONLY |DL_FLAG_MANAGED ); +} +/** * device_is_dependent - Check if one device depends on another one * @dev: Device to check dependencies for.
@@ -297,8 +303,7 @@ int device_is_dependent(struct device *dev, void *target)return ret;list_for_each_entry (link, &dev->links.consumers, s_node) { -if ((link->flags & ~DL_FLAG_INFERRED ) == - (DL_FLAG_SYNC_STATE_ONLY |DL_FLAG_MANAGED )) +if (device_link_flag_is_sync_state_only (link->flags))continue ;if (link->consumer == target)
@@ -371,8 +376,7 @@ static int device_reorder_to_tail(struct device *dev, void *not_used)device_for_each_child (dev,NULL , device_reorder_to_tail);list_for_each_entry (link, &dev->links.consumers, s_node) { -if ((link->flags & ~DL_FLAG_INFERRED ) == - (DL_FLAG_SYNC_STATE_ONLY |DL_FLAG_MANAGED )) +if (device_link_flag_is_sync_state_only (link->flags))continue ;device_reorder_to_tail (link->consumer,NULL ); }
@@ -633,7 +637,8 @@ postcore_initcall(devlink_class_init);DL_FLAG_AUTOREMOVE_SUPPLIER | \DL_FLAG_AUTOPROBE_CONSUMER | \DL_FLAG_SYNC_STATE_ONLY | \ - DL_FLAG_INFERRED) +DL_FLAG_INFERRED | \ + DL_FLAG_CYCLE) #define DL_ADD_VALID_FLAGS (DL_MANAGED_LINK_FLAGS | DL_FLAG_STATELESS | \DL_FLAG_PM_RUNTIME |DL_FLAG_RPM_ACTIVE )
@@ -702,8 +707,6 @@ struct device_link *device_link_add(struct device *consumer,if (!consumer || !supplier || consumer == supplier || flags & ~DL_ADD_VALID_FLAGS || (flags &DL_FLAG_STATELESS && flags &DL_MANAGED_LINK_FLAGS ) || - (flags &DL_FLAG_SYNC_STATE_ONLY && - (flags & ~DL_FLAG_INFERRED ) !=DL_FLAG_SYNC_STATE_ONLY ) || (flags &DL_FLAG_AUTOPROBE_CONSUMER && flags & (DL_FLAG_AUTOREMOVE_CONSUMER |DL_FLAG_AUTOREMOVE_SUPPLIER )))
@@ -719,6 +722,10 @@ struct device_link *device_link_add(struct device *consumer,if (!(flags &DL_FLAG_STATELESS )) flags |=DL_FLAG_MANAGED ; +if (flags &DL_FLAG_SYNC_STATE_ONLY && + !device_link_flag_is_sync_state_only (flags)) +return NULL ; +device_links_write_lock ();device_pm_lock ();
@@ -1671,7 +1678,7 @@ static void fw_devlink_relax_link(struct device_link *link)if (!(link->flags &DL_FLAG_INFERRED ))return ; -if (link->flags == (DL_FLAG_MANAGED |FW_DEVLINK_FLAGS_PERMISSIVE )) +if (device_link_flag_is_sync_state_only (link->flags))return ;pm_runtime_drop_link (link);
@@ -1795,8 +1802,8 @@ static int fw_devlink_relax_cycle(struct device *con, void *sup)return ret;list_for_each_entry (link, &con->links.consumers, s_node) { -if ((link->flags & ~DL_FLAG_INFERRED ) == - (DL_FLAG_SYNC_STATE_ONLY |DL_FLAG_MANAGED )) +if (!(link->flags &DL_FLAG_CYCLE ) && +device_link_flag_is_sync_state_only (link->flags))continue ;if (!fw_devlink_relax_cycle (link->consumer, sup))
@@ -1805,6 +1812,7 @@ static int fw_devlink_relax_cycle(struct device *con, void *sup) ret =1 ;fw_devlink_relax_link (link); + link->flags |=DL_FLAG_CYCLE ; }return ret; }
include/linux/device.h +1 -0
@@ -327,6 +327,7 @@ enum device_link_state {#define DL_FLAG_MANAGED BIT(6)#define DL_FLAG_SYNC_STATE_ONLY BIT(7)#define DL_FLAG_INFERRED BIT(8) +#define DL_FLAG_CYCLE BIT(9)/** * enum dl_dev_state - Device driver presence tracking information.
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 470/885 driver core: fw_devlink: Dont purge child fwnodes consumer links
In reply to Greg Kroah-HartmanFrom: Saravana Kannan <[email protected]>
[ Upstream commit 3a2dbc510c437ca392516b0105bad8e7970e6614 ]
When a device X is bound successfully to a driver, if it has a child firmware node Y that doesn't have a struct device created by then, we delete fwnode links where the child firmware node Y is the supplier. We did this to avoid blocking the consumers of the child firmware node Y from deferring probe indefinitely.
While that a step in the right direction, it's better to make the consumers of the child firmware node Y to be consumers of the device X because device X is probably implementing whatever functionality is represented by child firmware node Y. By doing this, we capture the device dependencies more accurately and ensure better probe/suspend/resume ordering.
Stable-dep-of: 6a6dfdf8b3ff ("driver core: fw_devlink: Allow marking a fwnode link as being part of a cycle")
--- drivers/base/core.c | 97 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 79 insertions(+), 18 deletions(-)
drivers/base/core.c +79 -18
@@ -53,11 +53,12 @@ static LIST_HEAD(deferred_sync);static unsigned int defer_sync_state_count =1 ;static DEFINE_MUTEX (fwnode_link_lock);static bool fw_devlink_is_permissive (void ); +static void __fw_devlink_link_to_consumers (struct device *dev);static bool fw_devlink_drv_reg_done;static bool fw_devlink_best_effort;/** -* fwnode_link_add - Create a link between two fwnode_handles. +* __fwnode_link_add - Create a link between two fwnode_handles. * @con: Consumer end of the link. * @sup: Supplier end of the link. *
@@ -73,22 +74,18 @@ static bool fw_devlink_best_effort;* Attempts to create duplicate links between the same pair of fwnode handles * are ignored and there is no reference counting. */ -int fwnode_link_add (struct fwnode_handle *con,struct fwnode_handle *sup) +static int __fwnode_link_add (struct fwnode_handle *con, +struct fwnode_handle *sup) {struct fwnode_link *link; -int ret =0 ; - -mutex_lock (&fwnode_link_lock);list_for_each_entry (link, &sup->consumers, s_hook)if (link->consumer == con) - goto out; +return 0 ; link =kzalloc (sizeof (*link),GFP_KERNEL ); -if (!link) { - ret = -ENOMEM ; - goto out; - } +if (!link) +return -ENOMEM ; link->supplier = sup;INIT_LIST_HEAD (&link->s_hook);
@@ -99,9 +96,17 @@ int fwnode_link_add(struct fwnode_handle *con, struct fwnode_handle *sup)list_add (&link->c_hook, &con->suppliers);pr_debug ("%pfwP Linked as a fwnode consumer to %pfwP\n" , con, sup); -out: -mutex_unlock (&fwnode_link_lock); +return 0 ; +} + +int fwnode_link_add (struct fwnode_handle *con,struct fwnode_handle *sup) +{ +int ret; + +mutex_lock (&fwnode_link_lock); + ret =__fwnode_link_add (con, sup); +mutex_unlock (&fwnode_link_lock);return ret; }
@@ -180,6 +185,51 @@ void fw_devlink_purge_absent_suppliers(struct fwnode_handle *fwnode) }EXPORT_SYMBOL_GPL (fw_devlink_purge_absent_suppliers); +/** +* __fwnode_links_move_consumers - Move consumer from @from to @to fwnode_handle +* @from: move consumers away from this fwnode +* @to: move consumers to this fwnode +* +* Move all consumer links from @from fwnode to @to fwnode. +*/ +static void __fwnode_links_move_consumers (struct fwnode_handle *from, +struct fwnode_handle *to) +{ +struct fwnode_link *link, *tmp; + +list_for_each_entry_safe (link, tmp, &from->consumers, s_hook) { +__fwnode_link_add (link->consumer, to); +__fwnode_link_del (link); + } +} + +/** +* __fw_devlink_pickup_dangling_consumers - Pick up dangling consumers +* @fwnode: fwnode from which to pick up dangling consumers +* @new_sup: fwnode of new supplier +* +* If the @fwnode has a corresponding struct device and the device supports +* probing (that is, added to a bus), then we want to let fw_devlink create +* MANAGED device links to this device, so leave @fwnode and its descendant's +* fwnode links alone. +* +* Otherwise, move its consumers to the new supplier @new_sup. +*/ +static void __fw_devlink_pickup_dangling_consumers (struct fwnode_handle *fwnode, +struct fwnode_handle *new_sup) +{ +struct fwnode_handle *child; + +if (fwnode->dev && fwnode->dev->bus) +return ; + + fwnode->flags |=FWNODE_FLAG_NOT_DEVICE ; +__fwnode_links_move_consumers (fwnode, new_sup); + +fwnode_for_each_available_child_node (fwnode, child) +__fw_devlink_pickup_dangling_consumers (child, new_sup); +} +#ifdef CONFIG_SRCU static DEFINE_MUTEX (device_links_lock);DEFINE_STATIC_SRCU (device_links_srcu);
@@ -1273,16 +1323,23 @@ void device_links_driver_bound(struct device *dev)* them. So, fw_devlink no longer needs to create device links to any * of the device's suppliers. * -* Also, if a child firmware node of this bound device is not added as -* a device by now, assume it is never going to be added and make sure -* other devices don't defer probe indefinitely by waiting for such a -* child device. +* Also, if a child firmware node of this bound device is not added as a +* device by now, assume it is never going to be added. Make this bound +* device the fallback supplier to the dangling consumers of the child +* firmware node because this bound device is probably implementing the +* child firmware node functionality and we don't want the dangling +* consumers to defer probe indefinitely waiting for a device for the +* child firmware node. */ if (dev->fwnode && dev->fwnode->dev == dev) {struct fwnode_handle *child;fwnode_links_purge_suppliers (dev->fwnode); +mutex_lock (&fwnode_link_lock);fwnode_for_each_available_child_node (dev->fwnode, child) -fw_devlink_purge_absent_suppliers (child); +__fw_devlink_pickup_dangling_consumers (child, + dev->fwnode); +__fw_devlink_link_to_consumers (dev); +mutex_unlock (&fwnode_link_lock); }device_remove_file (dev, &dev_attr_waiting_for_supplier);
@@ -1862,7 +1919,11 @@ static int fw_devlink_create_devlink(struct device *con, fwnode_is_ancestor_of(sup_handle, con->fwnode))return -EINVAL ; - sup_dev =get_dev_from_fwnode (sup_handle); +if (sup_handle->flags &FWNODE_FLAG_NOT_DEVICE ) + sup_dev =fwnode_get_next_parent_dev (sup_handle); +else + sup_dev =get_dev_from_fwnode (sup_handle); +if (sup_dev) {/* * If it's one of those drivers that don't actually bind to
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 471/885 driver core: fw_devlink: Allow marking a fwnode link as being part of a cycle
In reply to Greg Kroah-HartmanFrom: Saravana Kannan <[email protected]>
[ Upstream commit 6a6dfdf8b3ff337be5a447e9f4e71969f18370ad ]
To improve detection and handling of dependency cycles, we need to be able to mark fwnode links as being part of cycles. fwnode links marked as being part of a cycle should not block their consumers from probing.
--- drivers/base/core.c | 50 +++++++++++++++++++++++++++++++++--------- include/linux/fwnode.h | 11 +++++++++- 2 files changed, 50 insertions(+), 11 deletions(-)
drivers/base/core.c +40 -10
@@ -75,13 +75,15 @@ static bool fw_devlink_best_effort;* are ignored and there is no reference counting. */ static int __fwnode_link_add (struct fwnode_handle *con, -struct fwnode_handle *sup) +struct fwnode_handle *sup,u8 flags) {struct fwnode_link *link;list_for_each_entry (link, &sup->consumers, s_hook) -if (link->consumer == con) +if (link->consumer == con) { + link->flags |= flags;return 0 ; + } link =kzalloc (sizeof (*link),GFP_KERNEL );if (!link)
@@ -91,6 +93,7 @@ static int __fwnode_link_add(struct fwnode_handle *con,INIT_LIST_HEAD (&link->s_hook); link->consumer = con;INIT_LIST_HEAD (&link->c_hook); + link->flags = flags;list_add (&link->s_hook, &sup->consumers);list_add (&link->c_hook, &con->suppliers);
@@ -105,7 +108,7 @@ int fwnode_link_add(struct fwnode_handle *con, struct fwnode_handle *sup)int ret;mutex_lock (&fwnode_link_lock); - ret =__fwnode_link_add (con, sup); + ret =__fwnode_link_add (con, sup,0 );mutex_unlock (&fwnode_link_lock);return ret; }
@@ -125,6 +128,19 @@ static void __fwnode_link_del(struct fwnode_link *link)kfree (link); } +/** +* __fwnode_link_cycle - Mark a fwnode link as being part of a cycle. +* @link: the fwnode_link to be marked +* +* The fwnode_link_lock needs to be held when this function is called. +*/ +static void __fwnode_link_cycle (struct fwnode_link *link) +{ +pr_debug ("%pfwf: Relaxing link with %pfwf\n" , + link->consumer, link->supplier); + link->flags |=FWLINK_FLAG_CYCLE ; +} +/** * fwnode_links_purge_suppliers - Delete all supplier links of fwnode_handle. * @fwnode: fwnode whose supplier links need to be deleted
@@ -198,7 +214,7 @@ static void __fwnode_links_move_consumers(struct fwnode_handle *from,struct fwnode_link *link, *tmp;list_for_each_entry_safe (link, tmp, &from->consumers, s_hook) { -__fwnode_link_add (link->consumer, to); +__fwnode_link_add (link->consumer, to, link->flags);__fwnode_link_del (link); } }
@@ -1040,6 +1056,21 @@ static bool dev_is_best_effort(struct device *dev) (dev->fwnode && (dev->fwnode->flags &FWNODE_FLAG_BEST_EFFORT )); } +static struct fwnode_handle *fwnode_links_check_suppliers ( +struct fwnode_handle *fwnode) +{ +struct fwnode_link *link; + +if (!fwnode ||fw_devlink_is_permissive ()) +return NULL ; + +list_for_each_entry (link, &fwnode->suppliers, c_hook) +if (!(link->flags &FWLINK_FLAG_CYCLE )) +return link->supplier; + +return NULL ; +} +/** * device_links_check_suppliers - Check presence of supplier drivers. * @dev: Consumer device.
@@ -1067,11 +1098,8 @@ int device_links_check_suppliers(struct device *dev)* probe. */ mutex_lock (&fwnode_link_lock); -if (dev->fwnode && !list_empty (&dev->fwnode->suppliers) && - !fw_devlink_is_permissive ()) { - sup_fw =list_first_entry (&dev->fwnode->suppliers, - struct fwnode_link, - c_hook)->supplier; + sup_fw =fwnode_links_check_suppliers (dev->fwnode); +if (sup_fw) {if (!dev_is_best_effort (dev)) { fwnode_ret = -EPROBE_DEFER ; dev_err_probe(dev, -EPROBE_DEFER,
@@ -1260,7 +1288,9 @@ static ssize_t waiting_for_supplier_show(struct device *dev,bool val;device_lock (dev); - val = !list_empty (&dev->fwnode->suppliers); +mutex_lock (&fwnode_link_lock); + val = !!fwnode_links_check_suppliers (dev->fwnode); +mutex_unlock (&fwnode_link_lock);device_unlock (dev);return sysfs_emit (buf,"%u\n" , val); }
include/linux/fwnode.h +10 -1
@@ -18,7 +18,7 @@ struct fwnode_operations;struct device ;/* -* fwnode link flags +* fwnode flags * * LINKS_ADDED: The fwnode has already be parsed to add fwnode links. * NOT_DEVICE: The fwnode will never be populated as a struct device.
@@ -36,6 +36,7 @@ struct device;#define FWNODE_FLAG_INITIALIZED BIT(2)#define FWNODE_FLAG_NEEDS_CHILD_BOUND_ON_ADD BIT(3)#define FWNODE_FLAG_BEST_EFFORT BIT(4) +#define FWNODE_FLAG_VISITED BIT(5)struct fwnode_handle {struct fwnode_handle *secondary;
@@ -46,11 +47,19 @@ struct fwnode_handle {u8 flags; }; +/* +* fwnode link flags +* +* CYCLE: The fwnode link is part of a cycle. Don't defer probe. +*/ +#define FWLINK_FLAG_CYCLE BIT(0) +struct fwnode_link {struct fwnode_handle *supplier;struct list_head s_hook;struct fwnode_handle *consumer;struct list_head c_hook; +u8 flags; };/**
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 472/885 driver core: fw_devlink: Consolidate device link flag computation
In reply to Greg Kroah-HartmanFrom: Saravana Kannan <[email protected]>
[ Upstream commit cd115c0409f283edde94bd5a9a42dc42bee0aba8 ]
Consolidate the code that computes the flags to be used when creating a device link from a fwnode link.
--- drivers/base/core.c | 28 +++++++++++++++------------- include/linux/fwnode.h | 1 - 2 files changed, 15 insertions(+), 14 deletions(-)
drivers/base/core.c +15 -13
@@ -1726,8 +1726,11 @@ static int __init fw_devlink_strict_setup(char *arg) }early_param ("fw_devlink.strict" , fw_devlink_strict_setup); -u32 fw_devlink_get_flags (void ) +static inline u32 fw_devlink_get_flags (u8 fwlink_flags) { +if (fwlink_flags &FWLINK_FLAG_CYCLE ) +return FW_DEVLINK_FLAGS_PERMISSIVE |DL_FLAG_CYCLE ; +return fw_devlink_flags; }
@@ -1908,7 +1911,7 @@ static int fw_devlink_relax_cycle(struct device *con, void *sup)* fw_devlink_create_devlink - Create a device link from a consumer to fwnode * @con: consumer device for the device link * @sup_handle: fwnode handle of supplier -* @flags: devlink flags +* @link: fwnode link that's being converted to a device link * * This function will try to create a device link between the consumer device * @con and the supplier device represented by @sup_handle.
@@ -1925,10 +1928,17 @@ static int fw_devlink_relax_cycle(struct device *con, void *sup)* possible to do that in the future */ static int fw_devlink_create_devlink (struct device *con, -struct fwnode_handle *sup_handle,u32 flags) +struct fwnode_handle *sup_handle, +struct fwnode_link *link) {struct device *sup_dev;int ret =0 ; +u32 flags; + +if (con->fwnode == link->consumer) + flags =fw_devlink_get_flags (link->flags); +else + flags =FW_DEVLINK_FLAGS_PERMISSIVE ;/* * In some cases, a device P might also be a supplier to its child node
@@ -2054,7 +2064,6 @@ static void __fw_devlink_link_to_consumers(struct device *dev)struct fwnode_link *link, *tmp;list_for_each_entry_safe (link, tmp, &fwnode->consumers, s_hook) { -u32 dl_flags =fw_devlink_get_flags ();struct device *con_dev;bool own_link = true;int ret;
@@ -2084,14 +2093,13 @@ static void __fw_devlink_link_to_consumers(struct device *dev) con_dev =NULL ; }else { own_link = false; - dl_flags =FW_DEVLINK_FLAGS_PERMISSIVE ; } }if (!con_dev)continue ; - ret =fw_devlink_create_devlink (con_dev, fwnode, dl_flags); + ret =fw_devlink_create_devlink (con_dev, fwnode, link);put_device (con_dev);if (!own_link || ret == -EAGAIN )continue ;
@@ -2132,19 +2140,13 @@ static void __fw_devlink_link_to_suppliers(struct device *dev,bool own_link = (dev->fwnode == fwnode);struct fwnode_link *link, *tmp;struct fwnode_handle *child =NULL ; -u32 dl_flags; - -if (own_link) - dl_flags =fw_devlink_get_flags (); -else - dl_flags =FW_DEVLINK_FLAGS_PERMISSIVE ;list_for_each_entry_safe (link, tmp, &fwnode->suppliers, c_hook) {int ret;struct device *sup_dev;struct fwnode_handle *sup = link->supplier; - ret =fw_devlink_create_devlink (dev, sup, dl_flags); + ret =fw_devlink_create_devlink (dev, sup, link);if (!own_link || ret == -EAGAIN )continue ;
include/linux/fwnode.h +0 -1
@@ -207,7 +207,6 @@ static inline void fwnode_dev_initialized(struct fwnode_handle *fwnode, fwnode->flags &= ~FWNODE_FLAG_INITIALIZED ; } -extern u32 fw_devlink_get_flags (void );extern bool fw_devlink_is_strict (void );int fwnode_link_add (struct fwnode_handle *con,struct fwnode_handle *sup);void fwnode_links_purge (struct fwnode_handle *fwnode);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 473/885 driver core: fw_devlink: Improve check for fwnode with no device/driver
In reply to Greg Kroah-HartmanFrom: Saravana Kannan <[email protected]>
[ Upstream commit 411c0d58ca6faa9bc4b9f5382118a31c7bb92a6f ]
fw_devlink shouldn't defer the probe of a device to wait on a supplier that'll never have a struct device or will never be probed by a driver. We currently check if a supplier falls into this category, but don't check its ancestors. We need to check the ancestors too because if the ancestor will never probe, then the supplier will never probe either.
Stable-dep-of: 3fb16866b51d ("driver core: fw_devlink: Make cycle detection more robust")
--- drivers/base/core.c | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-)
drivers/base/core.c +38 -2
@@ -1907,6 +1907,35 @@ static int fw_devlink_relax_cycle(struct device *con, void *sup)return ret; } +static bool fwnode_init_without_drv (struct fwnode_handle *fwnode) +{ +struct device *dev; +bool ret; + +if (!(fwnode->flags &FWNODE_FLAG_INITIALIZED )) +return false; + + dev =get_dev_from_fwnode (fwnode); + ret = !dev || dev->links.status ==DL_DEV_NO_DRIVER ; +put_device (dev); + +return ret; +} + +static bool fwnode_ancestor_init_without_drv (struct fwnode_handle *fwnode) +{ +struct fwnode_handle *parent; + +fwnode_for_each_parent_node (fwnode, parent) { +if (fwnode_init_without_drv (parent)) { +fwnode_handle_put (parent); +return true; + } + } + +return false; +} +/** * fw_devlink_create_devlink - Create a device link from a consumer to fwnode * @con: consumer device for the device link
@@ -1995,9 +2024,16 @@ static int fw_devlink_create_devlink(struct device *con, goto out; } -/* Supplier that's already initialized without a struct device. */ -if (sup_handle->flags &FWNODE_FLAG_INITIALIZED ) +/* +* Supplier or supplier's ancestor already initialized without a struct +* device or being probed by a driver. +*/ +if (fwnode_init_without_drv (sup_handle) || +fwnode_ancestor_init_without_drv (sup_handle)) { +dev_dbg (con,"Not linking %pfwP - Might never probe\n" , + sup_handle);return -EINVAL ; + }/* * DL_FLAG_SYNC_STATE_ONLY doesn't block probing and supports
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 474/885 driver core: fw_devlink: Make cycle detection more robust
In reply to Greg Kroah-HartmanFrom: Saravana Kannan <[email protected]>
[ Upstream commit 3fb16866b51ded6c016b664caad53f8d4fd9dc56 ]
fw_devlink could only detect a single and simple cycle because it relied mainly on device link cycle detection code that only checked for cycles between devices. The expectation was that the firmware wouldn't have complicated cycles and multiple cycles between devices. That expectation has been proven to be wrong.
For example, fw_devlink could handle:
+-+ +-+ |A+------> |B+ +-+ +++ ^ | | | +----------+
But it couldn't handle even something as "simple" as:
+---------------------+ | | v | +-+ +-+ +++ |A+------> |B+------> |C| +-+ +++ +-+ ^ | | | +----------+
But firmware has even more complicated cycles like:
+---------------------+
| |
v |
+-+ +---+ +++
+--+A+------>| B +-----> |C|<--+
| +-+ ++--+ +++ |
| ^ | ^ | |
| | | | | |
| +---------+ +---------+ |
| |
+------------------------------+And this is without including parent child dependencies or nodes in the cycle that are just firmware nodes that'll never have a struct device created for them.
The proper way to treat these devices it to not force any probe ordering between them, while still enforce dependencies between node in the cycles (A, B and C) and their consumers.
So this patch goes all out and just deals with all types of cycles. It does this by:
1. Following dependencies across device links, parent-child and fwnode links.
2. When it find cycles, it mark the device links and fwnode links as such instead of just deleting them or making the indistinguishable from proxy SYNC_STATE_ONLY device links.
This way, when new nodes get added, we can immediately find and mark any new cycles whether the new node is a device or firmware node.
--- drivers/base/core.c | 248 +++++++++++++++++++++++--------------------- 1 file changed, 129 insertions(+), 119 deletions(-)
drivers/base/core.c +129 -119
@@ -1865,47 +1865,6 @@ static void fw_devlink_unblock_consumers(struct device *dev)device_links_write_unlock (); } -/** -* fw_devlink_relax_cycle - Convert cyclic links to SYNC_STATE_ONLY links -* @con: Device to check dependencies for. -* @sup: Device to check against. -* -* Check if @sup depends on @con or any device dependent on it (its child or -* its consumer etc). When such a cyclic dependency is found, convert all -* device links created solely by fw_devlink into SYNC_STATE_ONLY device links. -* This is the equivalent of doing fw_devlink=permissive just between the -* devices in the cycle. We need to do this because, at this point, fw_devlink -* can't tell which of these dependencies is not a real dependency. -* -* Return 1 if a cycle is found. Otherwise, return 0. -*/ -static int fw_devlink_relax_cycle (struct device *con,void *sup) -{ -struct device_link *link; -int ret; - -if (con == sup) -return 1 ; - - ret =device_for_each_child (con, sup, fw_devlink_relax_cycle); -if (ret) -return ret; - -list_for_each_entry (link, &con->links.consumers, s_node) { -if (!(link->flags &DL_FLAG_CYCLE ) && -device_link_flag_is_sync_state_only (link->flags)) -continue ; - -if (!fw_devlink_relax_cycle (link->consumer, sup)) -continue ; - - ret =1 ; - -fw_devlink_relax_link (link); - link->flags |=DL_FLAG_CYCLE ; - } -return ret; -}static bool fwnode_init_without_drv (struct fwnode_handle *fwnode) {
@@ -1936,6 +1895,111 @@ static bool fwnode_ancestor_init_without_drv(struct fwnode_handle *fwnode)return false; } +/** +* __fw_devlink_relax_cycles - Relax and mark dependency cycles. +* @con: Potential consumer device. +* @sup_handle: Potential supplier's fwnode. +* +* Needs to be called with fwnode_lock and device link lock held. +* +* Check if @sup_handle or any of its ancestors or suppliers direct/indirectly +* depend on @con. This function can detect multiple cyles between @sup_handle +* and @con. When such dependency cycles are found, convert all device links +* created solely by fw_devlink into SYNC_STATE_ONLY device links. Also, mark +* all fwnode links in the cycle with FWLINK_FLAG_CYCLE so that when they are +* converted into a device link in the future, they are created as +* SYNC_STATE_ONLY device links. This is the equivalent of doing +* fw_devlink=permissive just between the devices in the cycle. We need to do +* this because, at this point, fw_devlink can't tell which of these +* dependencies is not a real dependency. +* +* Return true if one or more cycles were found. Otherwise, return false. +*/ +static bool __fw_devlink_relax_cycles (struct device *con, +struct fwnode_handle *sup_handle) +{ +struct device *sup_dev =NULL , *par_dev =NULL ; +struct fwnode_link *link; +struct device_link *dev_link; +bool ret = false; + +if (!sup_handle) +return false; + +/* +* We aren't trying to find all cycles. Just a cycle between con and +* sup_handle. +*/ +if (sup_handle->flags &FWNODE_FLAG_VISITED ) +return false; + + sup_handle->flags |=FWNODE_FLAG_VISITED ; + + sup_dev =get_dev_from_fwnode (sup_handle); + +/* Termination condition. */ +if (sup_dev == con) { + ret = true; + goto out; + } + +/* +* If sup_dev is bound to a driver and @con hasn't started binding to a +* driver, sup_dev can't be a consumer of @con. So, no need to check +* further. +*/ +if (sup_dev && sup_dev->links.status ==DL_DEV_DRIVER_BOUND && + con->links.status ==DL_DEV_NO_DRIVER ) { + ret = false; + goto out; + } + +list_for_each_entry (link, &sup_handle->suppliers, c_hook) { +if (__fw_devlink_relax_cycles (con, link->supplier)) { +__fwnode_link_cycle (link); + ret = true; + } + } + +/* +* Give priority to device parent over fwnode parent to account for any +* quirks in how fwnodes are converted to devices. +*/ +if (sup_dev) + par_dev =get_device (sup_dev->parent); +else + par_dev =fwnode_get_next_parent_dev (sup_handle); + +if (par_dev &&__fw_devlink_relax_cycles (con, par_dev->fwnode)) + ret = true; + +if (!sup_dev) + goto out; + +list_for_each_entry (dev_link, &sup_dev->links.suppliers, c_node) { +/* +* Ignore a SYNC_STATE_ONLY flag only if it wasn't marked as +* such due to a cycle. +*/ +if (device_link_flag_is_sync_state_only (dev_link->flags) && + !(dev_link->flags &DL_FLAG_CYCLE )) +continue ; + +if (__fw_devlink_relax_cycles (con, + dev_link->supplier->fwnode)) { +fw_devlink_relax_link (dev_link); + dev_link->flags |=DL_FLAG_CYCLE ; + ret = true; + } + } + +out: + sup_handle->flags &= ~FWNODE_FLAG_VISITED ; +put_device (sup_dev); +put_device (par_dev); +return ret; +} +/** * fw_devlink_create_devlink - Create a device link from a consumer to fwnode * @con: consumer device for the device link
@@ -1988,6 +2052,21 @@ static int fw_devlink_create_devlink(struct device *con, fwnode_is_ancestor_of(sup_handle, con->fwnode))return -EINVAL ; +/* +* SYNC_STATE_ONLY device links don't block probing and supports cycles. +* So cycle detection isn't necessary and shouldn't be done. +*/ +if (!(flags &DL_FLAG_SYNC_STATE_ONLY )) { +device_links_write_lock (); +if (__fw_devlink_relax_cycles (con, sup_handle)) { +__fwnode_link_cycle (link); + flags =fw_devlink_get_flags (link->flags); +dev_info (con,"Fixed dependency cycle(s) with %pfwf\n" , + sup_handle); + } +device_links_write_unlock (); + } +if (sup_handle->flags &FWNODE_FLAG_NOT_DEVICE ) sup_dev =fwnode_get_next_parent_dev (sup_handle);else
@@ -2001,23 +2080,16 @@ static int fw_devlink_create_devlink(struct device *con,*/ if (sup_dev->links.status ==DL_DEV_NO_DRIVER && sup_handle->flags &FWNODE_FLAG_INITIALIZED ) { +dev_dbg (con, +"Not linking %pfwf - dev might never probe\n" , + sup_handle); ret = -EINVAL ; goto out; } -/* -* If this fails, it is due to cycles in device links. Just -* give up on this link and treat it as invalid. -*/ -if (!device_link_add (con, sup_dev, flags) && - !(flags &DL_FLAG_SYNC_STATE_ONLY )) { -dev_info (con,"Fixing up cyclic dependency with %s\n" , -dev_name (sup_dev)); -device_links_write_lock (); -fw_devlink_relax_cycle (con, sup_dev); -device_links_write_unlock (); -device_link_add (con, sup_dev, -FW_DEVLINK_FLAGS_PERMISSIVE ); +if (!device_link_add (con, sup_dev, flags)) { +dev_err (con,"Failed to create device link with %s\n" , +dev_name (sup_dev)); ret = -EINVAL ; }
@@ -2030,49 +2102,12 @@ static int fw_devlink_create_devlink(struct device *con,*/ if (fwnode_init_without_drv (sup_handle) ||fwnode_ancestor_init_without_drv (sup_handle)) { -dev_dbg (con,"Not linking %pfwP - Might never probe\n" , +dev_dbg (con,"Not linking %pfwf - might never become dev\n" , sup_handle);return -EINVAL ; } -/* -* DL_FLAG_SYNC_STATE_ONLY doesn't block probing and supports -* cycles. So cycle detection isn't necessary and shouldn't be -* done. -*/ -if (flags &DL_FLAG_SYNC_STATE_ONLY ) -return -EAGAIN ; - -/* -* If we can't find the supplier device from its fwnode, it might be -* due to a cyclic dependency between fwnodes. Some of these cycles can -* be broken by applying logic. Check for these types of cycles and -* break them so that devices in the cycle probe properly. -* -* If the supplier's parent is dependent on the consumer, then the -* consumer and supplier have a cyclic dependency. Since fw_devlink -* can't tell which of the inferred dependencies are incorrect, don't -* enforce probe ordering between any of the devices in this cyclic -* dependency. Do this by relaxing all the fw_devlink device links in -* this cycle and by treating the fwnode link between the consumer and -* the supplier as an invalid dependency. -*/ - sup_dev =fwnode_get_next_parent_dev (sup_handle); -if (sup_dev &&device_is_dependent (con, sup_dev)) { -dev_info (con,"Fixing up cyclic dependency with %pfwP (%s)\n" , - sup_handle,dev_name (sup_dev)); -device_links_write_lock (); -fw_devlink_relax_cycle (con, sup_dev); -device_links_write_unlock (); - ret = -EINVAL ; - }else { -/* -* Can't check for cycles or no cycles. So let's try -* again later. -*/ - ret = -EAGAIN ; - } - + ret = -EAGAIN ; out:put_device (sup_dev);return ret;
@@ -2155,10 +2190,7 @@ static void __fw_devlink_link_to_consumers(struct device *dev)* * The function creates normal (non-SYNC_STATE_ONLY) device links between @dev * and the real suppliers of @dev. Once these device links are created, the -* fwnode links are deleted. When such device links are successfully created, -* this function is called recursively on those supplier devices. This is -* needed to detect and break some invalid cycles in fwnode links. See -* fw_devlink_create_devlink() for more details. +* fwnode links are deleted. * * In addition, it also looks at all the suppliers of the entire fwnode tree * because some of the child devices of @dev that have not been added yet
@@ -2179,7 +2211,6 @@ static void __fw_devlink_link_to_suppliers(struct device *dev,list_for_each_entry_safe (link, tmp, &fwnode->suppliers, c_hook) {int ret; -struct device *sup_dev;struct fwnode_handle *sup = link->supplier; ret =fw_devlink_create_devlink (dev, sup, link);
@@ -2187,27 +2218,6 @@ static void __fw_devlink_link_to_suppliers(struct device *dev,continue ;__fwnode_link_del (link); - -/* If no device link was created, nothing more to do. */ -if (ret) -continue ; - -/* -* If a device link was successfully created to a supplier, we -* now need to try and link the supplier to all its suppliers. -* -* This is needed to detect and delete false dependencies in -* fwnode links that haven't been converted to a device link -* yet. See comments in fw_devlink_create_devlink() for more -* details on the false dependency. -* -* Without deleting these false dependencies, some devices will -* never probe because they'll keep waiting for their false -* dependency fwnode links to be converted to device links. -*/ - sup_dev =get_dev_from_fwnode (sup); -__fw_devlink_link_to_suppliers (sup_dev, sup_dev->fwnode); -put_device (sup_dev); }/*
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 475/885 mtd: mtdpart: Dont create platform device thatll never probe
In reply to Greg Kroah-HartmanFrom: Saravana Kannan <[email protected]>
[ Upstream commit fb42378dcc7f247df56f0ecddfdae85487495fbc ]
These "nvmem-cells" platform devices never get probed because there's no platform driver for it and it's never used anywhere else. So it's a waste of memory. These devices also cause fw_devlink to block nvmem consumers of "nvmem-cells" partition from probing because the supplier device never probes.
So stop creating platform devices for nvmem-cells partitions to avoid wasting memory and to avoid blocking probing of consumers.
--- drivers/mtd/mtdpart.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/mtd/mtdpart.c +10 -0
@@ -577,6 +577,7 @@ static int mtd_part_of_parse(struct mtd_info *master, {struct mtd_part_parser *parser;struct device_node *np; +struct device_node *child;struct property *prop;struct device *dev;const char *compat;
@@ -594,6 +595,15 @@ static int mtd_part_of_parse(struct mtd_info *master,else np =of_get_child_by_name (np,"partitions" ); +/* +* Don't create devices that are added to a bus but will never get +* probed. That'll cause fw_devlink to block probing of consumers of +* this partition until the partition device is probed. +*/ +for_each_child_of_node (np, child) +if (of_device_is_compatible (child,"nvmem-cells" )) +of_node_set_flag (child,OF_POPULATED ); +of_property_for_each_string (np,"compatible" , prop, compat) { parser =mtd_part_get_compatible_parser (compat);if (!parser)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 476/885 usb: host: fsl-mph-dr-of: reuse device_set_of_node_from_dev
In reply to Greg Kroah-HartmanFrom: Alexander Stein <[email protected]>
[ Upstream commit e2ffae3ed92a9f768902c1cf82642c3a09cd0345 ]
This sets both of_node fields and takes a of_node reference as well.
--- drivers/usb/host/fsl-mph-dr-of.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/host/fsl-mph-dr-of.c +1 -2
@@ -112,8 +112,7 @@ static struct platform_device *fsl_usb2_device_register( goto error; } - pdev->dev.of_node = ofdev->dev.of_node; - pdev->dev.of_node_reused = true; +device_set_of_node_from_dev (&pdev->dev, &ofdev->dev); retval =platform_device_add (pdev);if (retval)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 477/885 dmaengine: dw-edma: Fix readq_ch() return value truncation
In reply to Greg Kroah-HartmanFrom: Serge Semin <[email protected]>
[ Upstream commit 5fdca4a995bcd4cf61bda40af154a730589dc524 ]
Previously, readq_ch() did a 64-bit readq(), but truncated the result by storing it in the u32 "value". Change "value" to u64 to avoid the truncation.
Note: the method is currently unused, so the bug hasn't caused any problem so far.
--- drivers/dma/dw-edma/dw-edma-v0-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/dw-edma/dw-edma-v0-core.c +1 -1
@@ -192,7 +192,7 @@ static inline void writeq_ch(struct dw_edma *dw, enum dw_edma_dir dir, u16 ch,static inline u64 readq_ch (struct dw_edma *dw,enum dw_edma_dir dir,u16 ch,const void __iomem *addr) { -u32 value; +u64 value;if (dw->chip->mf ==EDMA_MF_EDMA_LEGACY ) {u32 viewport_sel;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 478/885 PCI: Fix dropping valid root bus resources with .end = zero
In reply to Greg Kroah-HartmanFrom: Geert Uytterhoeven <[email protected]>
[ Upstream commit 9d8ba74a181b1c81def21168795ed96cbe6f05ed ]
On r8a7791/koelsch:
kmemleak: 1 new suspected memory leaks (see /sys/kernel/debug/kmemleak)
# cat /sys/kernel/debug/kmemleak
unreferenced object 0xc3a34e00 (size 64):
comm "swapper/0", pid 1, jiffies 4294937460 (age 199.080s)
hex dump (first 32 bytes):
b4 5d 81 f0 b4 5d 81 f0 c0 b0 a2 c3 00 00 00 00 .]...]..........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<fe3aa979>] __kmalloc+0xf0/0x140
[<34bd6bc0>] resource_list_create_entry+0x18/0x38
[<767046bc>] pci_add_resource_offset+0x20/0x68
[<b3f3edf2>] devm_of_pci_get_host_bridge_resources.constprop.0+0xb0/0x390When coalescing two resources for a contiguous aperture, the second resource is enlarged to cover the full contiguous range, while the first resource is marked invalid. This invalidation is done by clearing the flags, start, and end members.
When adding the initial resources to the bus later, invalid resources are skipped. Unfortunately, the check for an invalid resource considers only the end member, causing false positives.
E.g. on r8a7791/koelsch, root bus resource 0 ("bus 00") is skipped, and no longer registered with pci_bus_insert_busn_res() (causing the memory leak), nor printed:
pci-rcar-gen2 ee090000.pci: host bridge /soc/pci@ee090000 ranges:
pci-rcar-gen2 ee090000.pci: MEM 0x00ee080000..0x00ee08ffff -> 0x00ee080000
pci-rcar-gen2 ee090000.pci: PCI: revision 11 pci-rcar-gen2 ee090000.pci: PCI host bridge to bus 0000:00
-pci_bus 0000:00: root bus resource [bus 00]
pci_bus 0000:00: root bus resource [mem 0xee080000-0xee08ffff]
Fix this by only skipping resources where all of the flags, start, and end members are zero.
--- drivers/pci/probe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/probe.c +1 -1
@@ -994,7 +994,7 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge)resource_list_for_each_entry_safe (window, n, &resources) { offset = window->offset; res = window->res; -if (!res->end) +if (!res->flags && !res->start && !res->end)continue ;list_move_tail (&window->node, &bridge->windows);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 479/885 phy: rockchip-typec: fix tcphy_get_mode error case
In reply to Greg Kroah-HartmanFrom: Neill Kapron <[email protected]>
[ Upstream commit 4ca651df07183e29cdad7272255e23aec0169a1b ]
The existing logic in tcphy_get_mode() can cause the phy to be incorrectly configured to USB UFP or DisplayPort mode when extcon_get_state returns an error code.
extcon_get_state() can return 0, 1, or a negative error code.
It is possible to get into the failing state with an extcon driver which does not support the extcon connector id specified as the second argument to extcon_get_state().
tcphy_get_mode()
->extcon_get_state()
-->find_cable_index_by_id()
--->return -EINVAL;
--- drivers/phy/rockchip/phy-rockchip-typec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/phy/rockchip/phy-rockchip-typec.c +2 -2
@@ -821,10 +821,10 @@ static int tcphy_get_mode(struct rockchip_typec_phy *tcphy) mode =MODE_DFP_USB ; id =EXTCON_USB_HOST ; -if (ufp) { +if (ufp >0 ) { mode =MODE_UFP_USB ; id =EXTCON_USB ; - }else if (dp) { + }else if (dp >0 ) { mode =MODE_DFP_DP ; id =EXTCON_DISP_DP ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 480/885 PCI: qcom: Fix host-init error handling
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
[ Upstream commit 997e010de9134474dbfde52be03efd7d1bce902d ]
Implement the new host_deinit() callback so that the PHY is powered off and regulators and clocks are disabled also on late host-init errors.
--- drivers/pci/controller/dwc/pcie-qcom.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/pci/controller/dwc/pcie-qcom.c +12 -1
@@ -1527,8 +1527,19 @@ static int qcom_pcie_host_init(struct dw_pcie_rp *pp)return ret; } +static void qcom_pcie_host_deinit (struct dw_pcie_rp *pp) +{ +struct dw_pcie *pci =to_dw_pcie_from_pp (pp); +struct qcom_pcie *pcie =to_qcom_pcie (pci); + +qcom_ep_reset_assert (pcie); +phy_power_off (pcie->phy); + pcie->cfg->ops->deinit (pcie); +} +static const struct dw_pcie_host_ops qcom_pcie_dw_ops = { - .host_init = qcom_pcie_host_init, + .host_init = qcom_pcie_host_init, + .host_deinit = qcom_pcie_host_deinit, };/* Qcom IP rev.: 2.1.0 Synopsys IP rev.: 4.01a */
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 481/885 iw_cxgb4: Fix potential NULL dereference in c4iw_fill_res_cm_id_entry()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 4ca446b127c568b59cb8d9748b6f70499624bb18 ]
This condition needs to match the previous "if (epcp->state == LISTEN) {" exactly to avoid a NULL dereference of either "listen_ep" or "ep". The problem is that "epcp" has been re-assigned so just testing "if (epcp->state == LISTEN) {" a second time is not sufficient.
--- drivers/infiniband/hw/cxgb4/restrack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/cxgb4/restrack.c +1 -1
@@ -238,7 +238,7 @@ int c4iw_fill_res_cm_id_entry(struct sk_buff *msg,if (rdma_nl_put_driver_u64_hex (msg,"history" , epcp->history)) goto err_cancel_table; -if (epcp->state ==LISTEN ) { +if (listen_ep) {if (rdma_nl_put_driver_u32 (msg,"stid" , listen_ep->stid)) goto err_cancel_table;if (rdma_nl_put_driver_u32 (msg,"backlog" , listen_ep->backlog))
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 482/885 iommu: Fix error unwind in iommu_group_alloc()
In reply to Greg Kroah-HartmanFrom: Jason Gunthorpe <[email protected]>
[ Upstream commit 4daa861174d56023c2068ddb03de0752f07fa199 ]
If either iommu_group_grate_file() fails then theiommu_group is leaked.
Destroy it on these error paths.
Found by kselftest/iommu/iommufd_fail_nth
--- drivers/iommu/iommu.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/iommu/iommu.c +6 -2
@@ -749,12 +749,16 @@ struct iommu_group *iommu_group_alloc(void) ret =iommu_group_create_file (group, &iommu_group_attr_reserved_regions); -if (ret) +if (ret) { +kobject_put (group->devices_kobj);return ERR_PTR (ret); + } ret =iommu_group_create_file (group, &iommu_group_attr_type); -if (ret) +if (ret) { +kobject_put (group->devices_kobj);return ERR_PTR (ret); + }pr_debug ("Allocated group %d\n" , group->id);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 483/885 iommu/amd: Do not identity map v2 capable device when snp is enabled
In reply to Greg Kroah-HartmanFrom: Vasant Hegde <[email protected]>
[ Upstream commit 18792e99ea2fea27c72eb1ecca1879e5e6be304d ]
Flow:
- Booted system with SNP enabled, memory encryption off and IOMMU DMA translation mode
- AMD driver detects v2 capable device and amd_iommu_def_domain_type() returns identity mode
- amd_iommu_domain_alloc() returns NULL an SNP is enabled
- System will fail to register device
On SNP enabled system, passthrough mode is not supported. IOMMU default domain is set to translation mode. We need to return zero from amd_iommu_def_domain_type() so that it allocates translation domain.
--- drivers/iommu/amd/iommu.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/iommu/amd/iommu.c +9 -4
@@ -2394,12 +2394,17 @@ static int amd_iommu_def_domain_type(struct device *dev)return 0 ;/* -* Do not identity map IOMMUv2 capable devices when memory encryption is -* active, because some of those devices (AMD GPUs) don't have the -* encryption bit in their DMA-mask and require remapping. +* Do not identity map IOMMUv2 capable devices when: +* - memory encryption is active, because some of those devices +* (AMD GPUs) don't have the encryption bit in their DMA-mask +* and require remapping. +* - SNP is enabled, because it prohibits DTE[Mode]=0. */ -if (!cc_platform_has (CC_ATTR_MEM_ENCRYPT ) && dev_data->iommu_v2) +if (dev_data->iommu_v2 && + !cc_platform_has (CC_ATTR_MEM_ENCRYPT ) && + !amd_iommu_snp_en) {return IOMMU_DOMAIN_IDENTITY ; + }return 0 ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 484/885 dmaengine: sf-pdma: pdma_desc memory leak fix
In reply to Greg Kroah-HartmanFrom: Shravan Chippa <[email protected]>
[ Upstream commit b02e07015a5ac7bbc029da931ae17914b8ae0339 ]
Commit b2cc5c465c2c ("dmaengine: sf-pdma: Add multithread support for a DMA channel") changed sf_pdma_prep_dma_memcpy() to unconditionally allocate a new sf_pdma_desc each time it is called.
The driver previously recycled descs, by checking the in_use flag, only allocating additional descs if the existing one was in use. This logic was removed in commit b2cc5c465c2c ("dmaengine: sf-pdma: Add multithread support for a DMA channel"), but sf_pdma_free_desc() was not changed to handle the new behaviour.
As a result, each time sf_pdma_prep_dma_memcpy() is called, the previous descriptor is leaked, over time leading to memory starvation:
unreferenced object 0xffffffe008447300 (size 192):
comm "irq/39-mchp_dsc", pid 343, jiffies 4294906910 (age 981.200s) hex dump (first 32 bytes):
00 00 00 ff 00 00 00 00 b8 c1 00 00 00 00 00 00 ................
00 00 70 08 10 00 00 00 00 00 00 c0 00 00 00 00 ..p.............
backtrace:
[<00000000064a04f4>] kmemleak_alloc+0x1e/0x28
[<00000000018927a7>] kmem_cache_alloc+0x11e/0x178
[<000000002aea8d16>] sf_pdma_prep_dma_memcpy+0x40/0x112Add the missing kfree() to sf_pdma_free_desc(), and remove the redundant in_use flag.
--- drivers/dma/sf-pdma/sf-pdma.c | 3 +-- drivers/dma/sf-pdma/sf-pdma.h | 1 - 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/dma/sf-pdma/sf-pdma.c +1 -2
@@ -96,7 +96,6 @@ sf_pdma_prep_dma_memcpy(struct dma_chan *dchan, dma_addr_t dest, dma_addr_t src,if (!desc)return NULL ; - desc->in_use = true; desc->dirn =DMA_MEM_TO_MEM ; desc->async_tx =vchan_tx_prep (&chan->vchan, &desc->vdesc, flags);
@@ -290,7 +289,7 @@ static void sf_pdma_free_desc(struct virt_dma_desc *vdesc)struct sf_pdma_desc *desc; desc =to_sf_pdma_desc (vdesc); - desc->in_use = false; +kfree (desc); }static void sf_pdma_donebh_tasklet (struct tasklet_struct *t)
drivers/dma/sf-pdma/sf-pdma.h +0 -1
@@ -78,7 +78,6 @@ struct sf_pdma_desc {u64 src_addr;struct virt_dma_desc vdesc;struct sf_pdma_chan *chan; -bool in_use;enum dma_transfer_direction dirn;struct dma_async_tx_descriptor *async_tx; };
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 485/885 dmaengine: dw-axi-dmac: Do not dereference NULL structure
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
[ Upstream commit be4d46edeee4b2459d2f53f37ada88bbfb634b6c ]
If "vdesc" is NULL, it cannot be used with vd_to_axi_desc(). Leave "bytes" unchanged at 0. Seen under GCC 13 with -Warray-bounds:
../drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c: In function 'dma_chan_tx_status':../drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c:329:46: warning: array subscript 0 is outside array bounds of 'struct virt_dma_desc[46116860184273879]' [-Warray-bounds=]
329 | bytes = vd_to_axi_desc(vdesc)->length;
| ^~
--- drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 2 -- 1 file changed, 2 deletions(-)
drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c +0 -2
@@ -325,8 +325,6 @@ dma_chan_tx_status(struct dma_chan *dchan, dma_cookie_t cookie, len =vd_to_axi_desc (vdesc)->hw_desc[0 ].len; completed_length = completed_blocks * len; bytes = length - completed_length; - }else { - bytes =vd_to_axi_desc (vdesc)->length; }spin_unlock_irqrestore (&chan->vc.lock, flags);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 486/885 dmaengine: ptdma: check for null desc before calling pt_cmd_callback
In reply to Greg Kroah-HartmanFrom: Eric Pilmore <[email protected]>
[ Upstream commit 928469986171a6f763b34b039427f5667ba3fd50 ]
Resolves a panic that can occur on AMD systems, typically during host shutdown, after the PTDMA driver had been exercised. The issue was the pt_issue_pending() function is mistakenly assuming that there will be at least one descriptor in the Submitted queue when the function is called. However, it is possible that both the Submitted and Issued queues could be empty, which could result in pt_cmd_callback() being mistakenly called with a NULL pointer.
Ref: Bugzilla Bug 216856.
--- drivers/dma/ptdma/ptdma-dmaengine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/ptdma/ptdma-dmaengine.c +1 -1
@@ -254,7 +254,7 @@ static void pt_issue_pending(struct dma_chan *dma_chan)spin_unlock_irqrestore (&chan->vc.lock, flags);/* If there was nothing active, start processing */ -if (engine_is_idle) +if (engine_is_idle && desc)pt_cmd_callback (desc,0 ); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 487/885 iommu/vt-d: Fix error handling in sva enable/disable paths
In reply to Greg Kroah-HartmanFrom: Lu Baolu <[email protected]>
[ Upstream commit 60b1daa3b168fbc648ae2ad28a84759223e49e18 ]
Roll back all previous actions in error paths of intel_iommu_enable_sva() and intel_iommu_disable_sva().
--- drivers/iommu/intel/iommu.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/iommu/intel/iommu.c +12 -4
@@ -4636,8 +4636,12 @@ static int intel_iommu_enable_sva(struct device *dev)return -EINVAL ; ret =iopf_queue_add_device (iommu->iopf_queue, dev); -if (!ret) - ret =iommu_register_device_fault_handler (dev, iommu_queue_iopf, dev); +if (ret) +return ret; + + ret =iommu_register_device_fault_handler (dev, iommu_queue_iopf, dev); +if (ret) +iopf_queue_remove_device (iommu->iopf_queue, dev);return ret; }
@@ -4649,8 +4653,12 @@ static int intel_iommu_disable_sva(struct device *dev)int ret; ret =iommu_unregister_device_fault_handler (dev); -if (!ret) - ret =iopf_queue_remove_device (iommu->iopf_queue, dev); +if (ret) +return ret; + + ret =iopf_queue_remove_device (iommu->iopf_queue, dev); +if (ret) +iommu_register_device_fault_handler (dev, iommu_queue_iopf, dev);return ret; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 488/885 iommu/vt-d: Allow to use flush-queue when first level is default
In reply to Greg Kroah-HartmanFrom: Tina Zhang <[email protected]>
[ Upstream commit 257ec290741924f8df678927d0dfecb1deebb9c5 ]
Commit 29b32839725f ("iommu/vt-d: Do not use flush-queue when caching-mode is on") forced default domains to be strict mode as long as IOMMU caching-mode is flagged. The reason for doing this is that when vIOMMU uses VT-d caching mode to synchronize shadowing page tables, the strict mode shows better performance.
However, this optimization is orthogonal to the first-level page table because the Intel VT-d architecture does not define the caching mode of the first-level page table. Refer to VT-d spec, section 6.1, "When the CM field is reported as Set, any software updates to remapping structures other than first-stage mapping (including updates to not- present entries or present entries whose programming resulted in translation faults) requires explicit invalidation of the caches." Exclude the first-level page table from this optimization.
Generally using first-stage translation in vIOMMU implies nested translation enabled in the physical IOMMU. In this case the first-stage page table is wholly captured by the guest. The vIOMMU only needs to transfer the cache invalidations on vIOMMU to the physical IOMMU. Forcing the default domain to strict mode will cause more frequent cache invalidations, resulting in performance degradation. In a real performance benchmark test measured by iperf receive, the performance result on Sapphire Rapids 100Gb NIC shows:
w/ this fix ~51 Gbits/s, w/o this fix ~39.3 Gbits/s.
Theoretically a first-stage IOMMU page table can still be shadowed in absence of the caching mode, e.g. with host write-protecting guest IOMMU page table to synchronize changed PTEs with the physical IOMMU page table. In this case the shadowing overhead is decoupled from emulating IOTLB invalidation then the overhead of the latter part is solely decided by the frequency of IOTLB invalidations. Hence allowing guest default dma domain to be lazy can also benefit the overall performance by reducing the total VM-exit numbers.
--- drivers/iommu/intel/iommu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iommu/intel/iommu.c +2 -1
@@ -4051,7 +4051,8 @@ int __init intel_iommu_init(void)* is likely to be much lower than the overhead of synchronizing * the virtual and physical IOMMU page-tables. */ -if (cap_caching_mode (iommu->cap)) { +if (cap_caching_mode (iommu->cap) && + !first_level_by_default (IOMMU_DOMAIN_DMA )) {pr_info_once ("IOMMU batching disallowed due to virtualization\n" );iommu_set_dma_strict (); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 489/885 RDMA/rxe: cleanup some error handling in rxe_verbs.c
In reply to Greg Kroah-HartmanFrom: Yunsheng Lin <[email protected]>
[ Upstream commit 692373d186205dfb1b56f35f22702412d94d9420 ]
Instead of 'goto and return', just return directly to simplify the error handling, and avoid some unnecessary return value check.
Stable-dep-of: a77a52385e9a ("RDMA/rxe: Fix missing memory barriers in rxe_queue.h")
--- drivers/infiniband/sw/rxe/rxe_verbs.c | 80 ++++++++------------------- 1 file changed, 23 insertions(+), 57 deletions(-)
drivers/infiniband/sw/rxe/rxe_verbs.c +23 -57
@@ -238,7 +238,6 @@ static int rxe_destroy_ah(struct ib_ah *ibah, u32 flags)static int post_one_recv (struct rxe_rq *rq,const struct ib_recv_wr *ibwr) { -int err;int i;u32 length;struct rxe_recv_wqe *recv_wqe;
@@ -246,15 +245,11 @@ static int post_one_recv(struct rxe_rq *rq, const struct ib_recv_wr *ibwr)int full; full =queue_full (rq->queue,QUEUE_TYPE_TO_DRIVER ); -if (unlikely (full)) { - err = -ENOMEM ; - goto err1; - } +if (unlikely (full)) +return -ENOMEM ; -if (unlikely (num_sge > rq->max_sge)) { - err = -EINVAL ; - goto err1; - } +if (unlikely (num_sge > rq->max_sge)) +return -EINVAL ; length =0 ;for (i =0 ; i < num_sge; i++)
@@ -275,9 +270,6 @@ static int post_one_recv(struct rxe_rq *rq, const struct ib_recv_wr *ibwr)queue_advance_producer (rq->queue,QUEUE_TYPE_TO_DRIVER );return 0 ; - -err1: -return err; } static int rxe_create_srq(struct ib_srq *ibsrq, struct ib_srq_init_attr *init,
@@ -343,10 +335,7 @@ static int rxe_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,if (err)return err; - err =rxe_srq_from_attr (rxe, srq, attr, mask, &ucmd, udata); -if (err) -return err; -return 0 ; +return rxe_srq_from_attr (rxe, srq, attr, mask, &ucmd, udata); }static int rxe_query_srq (struct ib_srq *ibsrq,struct ib_srq_attr *attr)
@@ -453,11 +442,11 @@ static int rxe_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, err =rxe_qp_chk_attr (rxe, qp, attr, mask);if (err) - goto err1; +return err; err =rxe_qp_from_attr (qp, attr, mask, udata);if (err) - goto err1; +return err;if ((mask &IB_QP_AV ) && (attr->ah_attr.ah_flags &IB_AH_GRH )) qp->src_port = rdma_get_udp_sport(attr->ah_attr.grh.flow_label,
@@ -465,9 +454,6 @@ static int rxe_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, qp->attr.dest_qp_num);return 0 ; - -err1: -return err; } static int rxe_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
@@ -501,24 +487,21 @@ static int validate_send_wr(struct rxe_qp *qp, const struct ib_send_wr *ibwr,struct rxe_sq *sq = &qp->sq;if (unlikely (num_sge > sq->max_sge)) - goto err1; +return -EINVAL ;if (unlikely (mask &WR_ATOMIC_MASK )) {if (length <8 ) - goto err1; +return -EINVAL ;if (atomic_wr (ibwr)->remote_addr &0x7 ) - goto err1; +return -EINVAL ; }if (unlikely ((ibwr->send_flags &IB_SEND_INLINE ) && (length > sq->max_inline))) - goto err1; +return -EINVAL ;return 0 ; - -err1: -return -EINVAL ; } static void init_send_wr(struct rxe_qp *qp, struct rxe_send_wr *wr,
@@ -735,14 +718,12 @@ static int rxe_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,if (unlikely ((qp_state (qp) <IB_QPS_INIT ) || !qp->valid)) { *bad_wr = wr; - err = -EINVAL ; - goto err1; +return -EINVAL ; }if (unlikely (qp->srq)) { *bad_wr = wr; - err = -EINVAL ; - goto err1; +return -EINVAL ; }spin_lock_irqsave (&rq->producer_lock, flags);
@@ -761,7 +742,6 @@ static int rxe_post_recv(struct ib_qp *ibqp, const struct ib_recv_wr *wr,if (qp->resp.state ==QP_STATE_ERROR )rxe_run_task (&qp->resp.task,1 ); -err1:return err; }
@@ -826,16 +806,9 @@ static int rxe_resize_cq(struct ib_cq *ibcq, int cqe, struct ib_udata *udata) err =rxe_cq_chk_attr (rxe, cq, cqe,0 );if (err) - goto err1; - - err =rxe_cq_resize_queue (cq, cqe, uresp, udata); -if (err) - goto err1; - -return 0 ; +return err; -err1: -return err; +return rxe_cq_resize_queue (cq, cqe, uresp, udata); }static int rxe_poll_cq (struct ib_cq *ibcq,int num_entries,struct ib_wc *wc)
@@ -921,26 +894,22 @@ static struct ib_mr *rxe_reg_user_mr(struct ib_pd *ibpd,struct rxe_mr *mr; mr =rxe_alloc (&rxe->mr_pool); -if (!mr) { - err = -ENOMEM ; - goto err2; - } - +if (!mr) +return ERR_PTR (-ENOMEM );rxe_get (pd); mr->ibmr.pd = ibpd; err =rxe_mr_init_user (rxe, start, length, iova, access, mr);if (err) - goto err3; + goto err1;rxe_finalize (mr);return &mr->ibmr; -err3: +err1:rxe_cleanup (mr); -err2:return ERR_PTR (err); }
@@ -956,25 +925,22 @@ static struct ib_mr *rxe_alloc_mr(struct ib_pd *ibpd, enum ib_mr_type mr_type,return ERR_PTR (-EINVAL ); mr =rxe_alloc (&rxe->mr_pool); -if (!mr) { - err = -ENOMEM ; - goto err1; - } +if (!mr) +return ERR_PTR (-ENOMEM );rxe_get (pd); mr->ibmr.pd = ibpd; err =rxe_mr_init_fast (max_num_sg, mr);if (err) - goto err2; + goto err1;rxe_finalize (mr);return &mr->ibmr; -err2: -rxe_cleanup (mr); err1: +rxe_cleanup (mr);return ERR_PTR (err); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 490/885 RDMA/rxe: Fix missing memory barriers in rxe_queue.h
In reply to Greg Kroah-HartmanFrom: Bob Pearson <[email protected]>
[ Upstream commit a77a52385e9a761f896a88a4162e69fb7ccafe3f ]
An earlier patch which introduced smp_load_acquire/smp_store_release into rxe_queue.h incorrectly assumed that surrounding spin-locks in rxe_verbs.c around queue updates for kernel ulps was sufficient to protect the passing of data through the queues between the ulp and the rxe tasklets. But this was incorrect. The typical sequence was
ulp rxe requester tasklet
------------------------ ---------------------
spin_lock_irqsave() wqe = queue_head(queue)
if (!queue_full(q)) { if (!wqe)
spin_unlock_irqrestore return;
return -ENOMEM
} <process wqe>
wqe = queue_producer_addr(q)
<fill in wqe> queue_advance_consumer(queue)
queue_advance_producer(q)
spin_unlock_irqrestore()queue_head() calls queue_empty() which calls smp_load_acquire() For user space apps queue_advance_producer() calls smp_store_release() so that there is a memory barrier between the producer and the consumer but for kernel ulps queue_advance_produce() just incremented the producer index because the lock function is a release function. But to work the barrier has to come between filling in the wqe and updating the producer index. This patch adds the missing barriers. It also changes the enum names for the ulp queue types to
QUEUE_TYPE_FROM/TO_ULP instead of QUEUE_TYPE_TO/FROM_DRIVER
which is very ambiguous. This bug is suspected as the cause of very rare lockups in a very high scale storage application. It is a bug in any case and should be corrected.
--- drivers/infiniband/sw/rxe/rxe_queue.h | 108 ++++++++++++++++---------- drivers/infiniband/sw/rxe/rxe_verbs.c | 20 ++--- 2 files changed, 76 insertions(+), 52 deletions(-)
drivers/infiniband/sw/rxe/rxe_queue.h +66 -42
@@ -35,19 +35,26 @@/** * enum queue_type - type of queue * @QUEUE_TYPE_TO_CLIENT: Queue is written by rxe driver and -* read by client. Used by rxe driver only. +* read by client which may be a user space +* application or a kernel ulp. +* Used by rxe internals only. * @QUEUE_TYPE_FROM_CLIENT: Queue is written by client and -* read by rxe driver. Used by rxe driver only. -* @QUEUE_TYPE_TO_DRIVER: Queue is written by client and -* read by rxe driver. Used by kernel client only. -* @QUEUE_TYPE_FROM_DRIVER: Queue is written by rxe driver and -* read by client. Used by kernel client only. +* read by rxe driver. +* Used by rxe internals only. +* @QUEUE_TYPE_FROM_ULP: Queue is written by kernel ulp and +* read by rxe driver. +* Used by kernel verbs APIs only on +* behalf of ulps. +* @QUEUE_TYPE_TO_ULP: Queue is written by rxe driver and +* read by kernel ulp. +* Used by kernel verbs APIs only on +* behalf of ulps. */ enum queue_type {QUEUE_TYPE_TO_CLIENT ,QUEUE_TYPE_FROM_CLIENT , -QUEUE_TYPE_TO_DRIVER , -QUEUE_TYPE_FROM_DRIVER , +QUEUE_TYPE_FROM_ULP , +QUEUE_TYPE_TO_ULP , };struct rxe_queue_buf ;
@@ -62,9 +69,9 @@ struct rxe_queue {u32 index_mask;enum queue_type type;/* private copy of index for shared queues between -* kernel space and user space. Kernel reads and writes +* driver and clients. Driver reads and writes * this copy and then replicates to rxe_queue_buf -* for read access by user space. +* for read access by clients. */ u32 index; };
@@ -97,19 +104,21 @@ static inline u32 queue_get_producer(const struct rxe_queue *q,switch (type) {case QUEUE_TYPE_FROM_CLIENT : -/* protect user index */ +/* used by rxe, client owns the index */ prod =smp_load_acquire (&q->buf->producer_index);break ;case QUEUE_TYPE_TO_CLIENT : +/* used by rxe which owns the index */ prod = q->index;break ; -case QUEUE_TYPE_FROM_DRIVER : -/* protect driver index */ - prod =smp_load_acquire (&q->buf->producer_index); -break ; -case QUEUE_TYPE_TO_DRIVER : +case QUEUE_TYPE_FROM_ULP : +/* used by ulp which owns the index */ prod = q->buf->producer_index;break ; +case QUEUE_TYPE_TO_ULP : +/* used by ulp, rxe owns the index */ + prod =smp_load_acquire (&q->buf->producer_index); +break ; }return prod;
@@ -122,19 +131,21 @@ static inline u32 queue_get_consumer(const struct rxe_queue *q,switch (type) {case QUEUE_TYPE_FROM_CLIENT : +/* used by rxe which owns the index */ cons = q->index;break ;case QUEUE_TYPE_TO_CLIENT : -/* protect user index */ +/* used by rxe, client owns the index */ cons =smp_load_acquire (&q->buf->consumer_index);break ; -case QUEUE_TYPE_FROM_DRIVER : - cons = q->buf->consumer_index; -break ; -case QUEUE_TYPE_TO_DRIVER : -/* protect driver index */ +case QUEUE_TYPE_FROM_ULP : +/* used by ulp, rxe owns the index */ cons =smp_load_acquire (&q->buf->consumer_index);break ; +case QUEUE_TYPE_TO_ULP : +/* used by ulp which owns the index */ + cons = q->buf->consumer_index; +break ; }return cons;
@@ -172,24 +183,31 @@ static inline void queue_advance_producer(struct rxe_queue *q,switch (type) {case QUEUE_TYPE_FROM_CLIENT : -pr_warn ("%s: attempt to advance client index\n" , - __func__); +/* used by rxe, client owns the index */ +if (WARN_ON (1 )) +pr_warn ("%s: attempt to advance client index\n" , + __func__);break ;case QUEUE_TYPE_TO_CLIENT : +/* used by rxe which owns the index */ prod = q->index; prod = (prod +1 ) & q->index_mask; q->index = prod; -/* protect user index */ +/* release so client can read it safely */ smp_store_release (&q->buf->producer_index, prod);break ; -case QUEUE_TYPE_FROM_DRIVER : -pr_warn ("%s: attempt to advance driver index\n" , - __func__); -break ; -case QUEUE_TYPE_TO_DRIVER : +case QUEUE_TYPE_FROM_ULP : +/* used by ulp which owns the index */ prod = q->buf->producer_index; prod = (prod +1 ) & q->index_mask; - q->buf->producer_index = prod; +/* release so rxe can read it safely */ +smp_store_release (&q->buf->producer_index, prod); +break ; +case QUEUE_TYPE_TO_ULP : +/* used by ulp, rxe owns the index */ +if (WARN_ON (1 )) +pr_warn ("%s: attempt to advance driver index\n" , + __func__);break ; } }
@@ -201,24 +219,30 @@ static inline void queue_advance_consumer(struct rxe_queue *q,switch (type) {case QUEUE_TYPE_FROM_CLIENT : - cons = q->index; - cons = (cons +1 ) & q->index_mask; +/* used by rxe which owns the index */ + cons = (q->index +1 ) & q->index_mask; q->index = cons; -/* protect user index */ +/* release so client can read it safely */ smp_store_release (&q->buf->consumer_index, cons);break ;case QUEUE_TYPE_TO_CLIENT : -pr_warn ("%s: attempt to advance client index\n" , - __func__); +/* used by rxe, client owns the index */ +if (WARN_ON (1 )) +pr_warn ("%s: attempt to advance client index\n" , + __func__); +break ; +case QUEUE_TYPE_FROM_ULP : +/* used by ulp, rxe owns the index */ +if (WARN_ON (1 )) +pr_warn ("%s: attempt to advance driver index\n" , + __func__);break ; -case QUEUE_TYPE_FROM_DRIVER : +case QUEUE_TYPE_TO_ULP : +/* used by ulp which owns the index */ cons = q->buf->consumer_index; cons = (cons +1 ) & q->index_mask; - q->buf->consumer_index = cons; -break ; -case QUEUE_TYPE_TO_DRIVER : -pr_warn ("%s: attempt to advance driver index\n" , - __func__); +/* release so rxe can read it safely */ +smp_store_release (&q->buf->consumer_index, cons);break ; } }
drivers/infiniband/sw/rxe/rxe_verbs.c +10 -10
@@ -244,7 +244,7 @@ static int post_one_recv(struct rxe_rq *rq, const struct ib_recv_wr *ibwr)int num_sge = ibwr->num_sge;int full; - full =queue_full (rq->queue,QUEUE_TYPE_TO_DRIVER ); + full =queue_full (rq->queue,QUEUE_TYPE_FROM_ULP );if (unlikely (full))return -ENOMEM ;
@@ -255,7 +255,7 @@ static int post_one_recv(struct rxe_rq *rq, const struct ib_recv_wr *ibwr)for (i =0 ; i < num_sge; i++) length += ibwr->sg_list[i].length; - recv_wqe =queue_producer_addr (rq->queue,QUEUE_TYPE_TO_DRIVER ); + recv_wqe =queue_producer_addr (rq->queue,QUEUE_TYPE_FROM_ULP ); recv_wqe->wr_id = ibwr->wr_id; memcpy(recv_wqe->dma.sge, ibwr->sg_list,
@@ -267,7 +267,7 @@ static int post_one_recv(struct rxe_rq *rq, const struct ib_recv_wr *ibwr) recv_wqe->dma.cur_sge =0 ; recv_wqe->dma.sge_offset =0 ; -queue_advance_producer (rq->queue,QUEUE_TYPE_TO_DRIVER ); +queue_advance_producer (rq->queue,QUEUE_TYPE_FROM_ULP );return 0 ; }
@@ -622,17 +622,17 @@ static int post_one_send(struct rxe_qp *qp, const struct ib_send_wr *ibwr,spin_lock_irqsave (&qp->sq.sq_lock, flags); - full =queue_full (sq->queue,QUEUE_TYPE_TO_DRIVER ); + full =queue_full (sq->queue,QUEUE_TYPE_FROM_ULP );if (unlikely (full)) {spin_unlock_irqrestore (&qp->sq.sq_lock, flags);return -ENOMEM ; } - send_wqe =queue_producer_addr (sq->queue,QUEUE_TYPE_TO_DRIVER ); + send_wqe =queue_producer_addr (sq->queue,QUEUE_TYPE_FROM_ULP );init_send_wqe (qp, ibwr, mask, length, send_wqe); -queue_advance_producer (sq->queue,QUEUE_TYPE_TO_DRIVER ); +queue_advance_producer (sq->queue,QUEUE_TYPE_FROM_ULP );spin_unlock_irqrestore (&qp->sq.sq_lock, flags);
@@ -820,12 +820,12 @@ static int rxe_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc)spin_lock_irqsave (&cq->cq_lock, flags);for (i =0 ; i < num_entries; i++) { - cqe =queue_head (cq->queue,QUEUE_TYPE_FROM_DRIVER ); + cqe =queue_head (cq->queue,QUEUE_TYPE_TO_ULP );if (!cqe)break ;memcpy (wc++, &cqe->ibwc,sizeof (*wc)); -queue_advance_consumer (cq->queue,QUEUE_TYPE_FROM_DRIVER ); +queue_advance_consumer (cq->queue,QUEUE_TYPE_TO_ULP ); }spin_unlock_irqrestore (&cq->cq_lock, flags);
@@ -837,7 +837,7 @@ static int rxe_peek_cq(struct ib_cq *ibcq, int wc_cnt)struct rxe_cq *cq =to_rcq (ibcq);int count; - count =queue_count (cq->queue,QUEUE_TYPE_FROM_DRIVER ); + count =queue_count (cq->queue,QUEUE_TYPE_TO_ULP );return (count > wc_cnt) ? wc_cnt : count; }
@@ -853,7 +853,7 @@ static int rxe_req_notify_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags)if (cq->notify !=IB_CQ_NEXT_COMP ) cq->notify = flags &IB_CQ_SOLICITED_MASK ; - empty =queue_empty (cq->queue,QUEUE_TYPE_FROM_DRIVER ); + empty =queue_empty (cq->queue,QUEUE_TYPE_TO_ULP );if ((flags &IB_CQ_REPORT_MISSED_EVENTS ) && !empty) ret =1 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 491/885 IB/hfi1: Fix math bugs in hfi1_can_pin_pages()
In reply to Greg Kroah-HartmanFrom: Patrick Kelsey <[email protected]>
[ Upstream commit a0d198f79a8d033bd46605b779859193649f1f99 ]
Fix arithmetic and logic errors in hfi1_can_pin_pages() that would allow hfi1 to attempt pinning pages in cases where it should not because of resource limits or lack of required capability.
--- drivers/infiniband/hw/hfi1/user_pages.c | 61 ++++++++++++++++--------- 1 file changed, 40 insertions(+), 21 deletions(-)
drivers/infiniband/hw/hfi1/user_pages.c +40 -21
@@ -29,33 +29,52 @@ MODULE_PARM_DESC(cache_size, "Send and receive side cache size limit (in MB)");bool hfi1_can_pin_pages (struct hfi1_devdata *dd,struct mm_struct *mm,u32 nlocked,u32 npages) { -unsigned long ulimit =rlimit (RLIMIT_MEMLOCK ), pinned, cache_limit, - size = (cache_size * (1UL <<20 ));/* convert to bytes */ -unsigned int usr_ctxts = - dd->num_rcv_contexts - dd->first_dyn_alloc_ctxt; -bool can_lock =capable (CAP_IPC_LOCK ); +unsigned long ulimit_pages; +unsigned long cache_limit_pages; +unsigned int usr_ctxts;/* -* Calculate per-cache size. The calculation below uses only a quarter -* of the available per-context limit. This leaves space for other -* pinning. Should we worry about shared ctxts? +* Perform RLIMIT_MEMLOCK based checks unless CAP_IPC_LOCK is present. */ - cache_limit = (ulimit / usr_ctxts) /4 ; - -/* If ulimit isn't set to "unlimited" and is smaller than cache_size. */ -if (ulimit != (-1UL ) && size > cache_limit) - size = cache_limit; - -/* Convert to number of pages */ - size =DIV_ROUND_UP (size,PAGE_SIZE ); - - pinned =atomic64_read (&mm->pinned_vm); +if (!capable (CAP_IPC_LOCK )) { + ulimit_pages = +DIV_ROUND_DOWN_ULL (rlimit (RLIMIT_MEMLOCK ),PAGE_SIZE ); + +/* +* Pinning these pages would exceed this process's locked memory +* limit. +*/ +if (atomic64_read (&mm->pinned_vm) + npages > ulimit_pages) +return false; + +/* +* Only allow 1/4 of the user's RLIMIT_MEMLOCK to be used for HFI +* caches. This fraction is then equally distributed among all +* existing user contexts. Note that if RLIMIT_MEMLOCK is +* 'unlimited' (-1), the value of this limit will be > 2^42 pages +* (2^64 / 2^12 / 2^8 / 2^2). +* +* The effectiveness of this check may be reduced if I/O occurs on +* some user contexts before all user contexts are created. This +* check assumes that this process is the only one using this +* context (e.g., the corresponding fd was not passed to another +* process for concurrent access) as there is no per-context, +* per-process tracking of pinned pages. It also assumes that each +* user context has only one cache to limit. +*/ + usr_ctxts = dd->num_rcv_contexts - dd->first_dyn_alloc_ctxt; +if (nlocked + npages > (ulimit_pages / usr_ctxts /4 )) +return false; + } -/* First, check the absolute limit against all pinned pages. */ -if (pinned + npages >= ulimit && !can_lock) +/* +* Pinning these pages would exceed the size limit for this cache. +*/ + cache_limit_pages = cache_size * (1024 *1024 ) /PAGE_SIZE ; +if (nlocked + npages > cache_limit_pages)return false; -return ((nlocked + npages) <= size) || can_lock; +return true; } int hfi1_acquire_user_pages(struct mm_struct *mm, unsigned long vaddr, size_t npages,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 492/885 IB/hfi1: Fix sdma.h tx->num_descs off-by-one errors
In reply to Greg Kroah-HartmanFrom: Patrick Kelsey <[email protected]>
[ Upstream commit fd8958efe8779d3db19c9124fce593ce681ac709 ]
Fix three sources of error involving struct sdma_txreq.num_descs.
When _extend_sdma_tx_descs() extends the descriptor array, it uses the value of tx->num_descs to determine how many existing entries from the tx's original, internal descriptor array to copy to the newly allocated one. As this value was incremented before the call, the copy loop will access one entry past the internal descriptor array, copying its contents into the corresponding slot in the new array.
If the call to _extend_sdma_tx_descs() fails, _pad_smda_tx_descs() then invokes __sdma_tx_clean() which uses the value of tx->num_desc to drive a loop that unmaps all descriptor entries in use. As this value was incremented before the call, the unmap loop will invoke sdma_unmap_desc() on a descriptor entry whose contents consist of whatever random data was copied into it during (1), leading to cascading further calls into the kernel and driver using arbitrary data.
_sdma_close_tx() was using tx->num_descs instead of tx->num_descs - 1.
Fix all of the above by:
- Only increment .num_descs after .descp is extended.
- Use .num_descs - 1 instead of .num_descs for last .descp entry.
--- drivers/infiniband/hw/hfi1/sdma.c | 4 ++-- drivers/infiniband/hw/hfi1/sdma.h | 15 +++++++-------- 2 files changed, 9 insertions(+), 10 deletions(-)
drivers/infiniband/hw/hfi1/sdma.c +2 -2
@@ -3160,8 +3160,7 @@ int _pad_sdma_tx_descs(struct hfi1_devdata *dd, struct sdma_txreq *tx) {int rval =0 ; - tx->num_desc++; -if ((unlikely (tx->num_desc == tx->desc_limit))) { +if ((unlikely (tx->num_desc +1 == tx->desc_limit))) { rval =_extend_sdma_tx_descs (dd, tx);if (rval) {__sdma_txclean (dd, tx);
@@ -3174,6 +3173,7 @@ int _pad_sdma_tx_descs(struct hfi1_devdata *dd, struct sdma_txreq *tx)SDMA_MAP_NONE , dd->sdma_pad_phys, sizeof(u32) - (tx->packet_len & (sizeof(u32) - 1))); + tx->num_desc++;_sdma_close_tx (dd, tx);return rval; }
drivers/infiniband/hw/hfi1/sdma.h +7 -8
@@ -631,14 +631,13 @@ static inline void sdma_txclean(struct hfi1_devdata *dd, struct sdma_txreq *tx)static inline void _sdma_close_tx (struct hfi1_devdata *dd,struct sdma_txreq *tx) { - tx->descp[tx->num_desc].qw[0 ] |= -SDMA_DESC0_LAST_DESC_FLAG ; - tx->descp[tx->num_desc].qw[1 ] |= - dd->default_desc1; +u16 last_desc = tx->num_desc -1 ; + + tx->descp[last_desc].qw[0 ] |=SDMA_DESC0_LAST_DESC_FLAG ; + tx->descp[last_desc].qw[1 ] |= dd->default_desc1;if (tx->flags &SDMA_TXREQ_F_URGENT ) - tx->descp[tx->num_desc].qw[1 ] |= - (SDMA_DESC1_HEAD_TO_HOST_FLAG | -SDMA_DESC1_INT_REQ_FLAG ); + tx->descp[last_desc].qw[1 ] |= (SDMA_DESC1_HEAD_TO_HOST_FLAG | +SDMA_DESC1_INT_REQ_FLAG ); } static inline int _sdma_txadd_daddr(
@@ -655,6 +654,7 @@ static inline int _sdma_txadd_daddr( type, addr, len);WARN_ON (len > tx->tlen); + tx->num_desc++; tx->tlen -= len;/* special cases for last */ if (!tx->tlen) {
@@ -666,7 +666,6 @@ static inline int _sdma_txadd_daddr(_sdma_close_tx (dd, tx); } } - tx->num_desc++;return rval; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 493/885 Revert "remoteproc: qcom_q6v5_mss: map/unmap metadata region before/after use"
In reply to Greg Kroah-HartmanFrom: Christoph Hellwig <[email protected]>
[ Upstream commit a899d542b687c9b04ccbd9eefabc829ba5fef791 ]
This reverts commit fc156629b23a21181e473e60341e3a78af25a1d4.
This commit manages to do three API violations at once:
- dereference the return value of dma_alloc_attrs with the DMA_ATTR_NO_KERNEL_MAPPING mapping, which is clearly forbidden and will do the wrong thing on various dma mapping implementations. The fact that dma-direct uses a struct page as a cookie is an undocumented implementation detail
- include dma-map-ops.h and use pgprot_dmacoherent despite a clear comment documenting that this is not acceptable
- use of the VM_DMA_COHERENT for something that is not the dma-mapping code
- use of VM_FLUSH_RESET_PERMS for vmap, while it is only supported for vmalloc
Stable-dep-of: 57f72170a2b2 ("remoteproc: qcom_q6v5_mss: Use a carveout to authenticate modem headers")
--- drivers/remoteproc/qcom_q6v5_mss.c | 38 +++++------------------------- 1 file changed, 6 insertions(+), 32 deletions(-)
drivers/remoteproc/qcom_q6v5_mss.c +6 -32
@@ -10,7 +10,6 @@#include <linux/clk.h> #include <linux/delay.h> #include <linux/devcoredump.h> -#include <linux/dma-map-ops.h> #include <linux/dma-mapping.h> #include <linux/interrupt.h> #include <linux/kernel.h>
@@ -933,52 +932,27 @@ static void q6v5proc_halt_axi_port(struct q6v5 *qproc,static int q6v5_mpss_init_image (struct q6v5 *qproc,const struct firmware *fw,const char *fw_name) { -unsigned long dma_attrs =DMA_ATTR_FORCE_CONTIGUOUS |DMA_ATTR_NO_KERNEL_MAPPING ; -unsigned long flags =VM_DMA_COHERENT |VM_FLUSH_RESET_PERMS ; -struct page **pages; -struct page *page; +unsigned long dma_attrs =DMA_ATTR_FORCE_CONTIGUOUS ;dma_addr_t phys;void *metadata;int mdata_perm;int xferop_ret;size_t size; -void *vaddr; -int count; +void *ptr;int ret; -int i; metadata =qcom_mdt_read_metadata (fw, &size, fw_name, qproc->dev);if (IS_ERR (metadata))return PTR_ERR (metadata); - page =dma_alloc_attrs (qproc->dev, size, &phys,GFP_KERNEL , dma_attrs); -if (!page) { + ptr =dma_alloc_attrs (qproc->dev, size, &phys,GFP_KERNEL , dma_attrs); +if (!ptr) {kfree (metadata);dev_err (qproc->dev,"failed to allocate mdt buffer\n" );return -ENOMEM ; } - count =PAGE_ALIGN (size) >>PAGE_SHIFT ; - pages =kmalloc_array (count,sizeof (struct page *),GFP_KERNEL ); -if (!pages) { - ret = -ENOMEM ; - goto free_dma_attrs; - } - -for (i =0 ; i < count; i++) - pages[i] =nth_page (page, i); - - vaddr =vmap (pages, count, flags,pgprot_dmacoherent (PAGE_KERNEL )); -kfree (pages); -if (!vaddr) { -dev_err (qproc->dev,"unable to map memory region: %pa+%zx\n" , &phys, size); - ret = -EBUSY ; - goto free_dma_attrs; - } - -memcpy (vaddr, metadata, size); - -vunmap (vaddr); +memcpy (ptr, metadata, size);/* Hypervisor mapping to access metadata by modem */ mdata_perm =BIT (QCOM_SCM_VMID_HLOS );
@@ -1008,7 +982,7 @@ static int q6v5_mpss_init_image(struct q6v5 *qproc, const struct firmware *fw, "mdt buffer not reclaimed system may become unstable\n"); free_dma_attrs: -dma_free_attrs (qproc->dev, size, page, phys, dma_attrs); +dma_free_attrs (qproc->dev, size, ptr, phys, dma_attrs);kfree (metadata);return ret <0 ? ret :0 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 494/885 remoteproc: qcom_q6v5_mss: Use a carveout to authenticate modem headers
In reply to Greg Kroah-HartmanFrom: Sibi Sankar <[email protected]>
[ Upstream commit 57f72170a2b2a362c35bb9407fc844eac5afdec1 ]
Any access to the dynamically allocated metadata region by the application processor after assigning it to the remote Q6 will result in a XPU violation. Fix this by replacing the dynamically allocated memory region with a no-map carveout and unmap the modem metadata memory region before passing control to the remote Q6.
--- drivers/remoteproc/qcom_q6v5_mss.c | 59 +++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 6 deletions(-)
drivers/remoteproc/qcom_q6v5_mss.c +53 -6
@@ -17,6 +17,7 @@#include <linux/module.h> #include <linux/of_address.h> #include <linux/of_device.h> +#include <linux/of_reserved_mem.h> #include <linux/platform_device.h> #include <linux/pm_domain.h> #include <linux/pm_runtime.h>
@@ -210,6 +211,9 @@ struct q6v5 {size_t mba_size;size_t dp_size; +phys_addr_t mdata_phys; +size_t mdata_size; +phys_addr_t mpss_phys;phys_addr_t mpss_reloc;size_t mpss_size;
@@ -945,15 +949,35 @@ static int q6v5_mpss_init_image(struct q6v5 *qproc, const struct firmware *fw,if (IS_ERR (metadata))return PTR_ERR (metadata); - ptr =dma_alloc_attrs (qproc->dev, size, &phys,GFP_KERNEL , dma_attrs); -if (!ptr) { -kfree (metadata); -dev_err (qproc->dev,"failed to allocate mdt buffer\n" ); -return -ENOMEM ; +if (qproc->mdata_phys) { +if (size > qproc->mdata_size) { + ret = -EINVAL ; +dev_err (qproc->dev,"metadata size outside memory range\n" ); + goto free_metadata; + } + + phys = qproc->mdata_phys; + ptr =memremap (qproc->mdata_phys, size,MEMREMAP_WC ); +if (!ptr) { + ret = -EBUSY ; +dev_err (qproc->dev,"unable to map memory region: %pa+%zx\n" , + &qproc->mdata_phys, size); + goto free_metadata; + } + }else { + ptr =dma_alloc_attrs (qproc->dev, size, &phys,GFP_KERNEL , dma_attrs); +if (!ptr) { + ret = -ENOMEM ; +dev_err (qproc->dev,"failed to allocate mdt buffer\n" ); + goto free_metadata; + } }memcpy (ptr, metadata, size); +if (qproc->mdata_phys) +memunmap (ptr); +/* Hypervisor mapping to access metadata by modem */ mdata_perm =BIT (QCOM_SCM_VMID_HLOS ); ret = q6v5_xfer_mem_ownership(qproc, &mdata_perm, false, true,
@@ -982,7 +1006,9 @@ static int q6v5_mpss_init_image(struct q6v5 *qproc, const struct firmware *fw, "mdt buffer not reclaimed system may become unstable\n"); free_dma_attrs: -dma_free_attrs (qproc->dev, size, ptr, phys, dma_attrs); +if (!qproc->mdata_phys) +dma_free_attrs (qproc->dev, size, ptr, phys, dma_attrs); +free_metadata:kfree (metadata);return ret <0 ? ret :0 ;
@@ -1810,6 +1836,7 @@ static int q6v5_init_reset(struct q6v5 *qproc)static int q6v5_alloc_memory_region (struct q6v5 *qproc) {struct device_node *child; +struct reserved_mem *rmem;struct device_node *node;struct resource r;int ret;
@@ -1856,6 +1883,26 @@ static int q6v5_alloc_memory_region(struct q6v5 *qproc) qproc->mpss_phys = qproc->mpss_reloc = r.start; qproc->mpss_size =resource_size (&r); +if (!child) { + node =of_parse_phandle (qproc->dev->of_node,"memory-region" ,2 ); + }else { + child =of_get_child_by_name (qproc->dev->of_node,"metadata" ); + node =of_parse_phandle (child,"memory-region" ,0 ); +of_node_put (child); + } + +if (!node) +return 0 ; + + rmem =of_reserved_mem_lookup (node); +if (!rmem) { +dev_err (qproc->dev,"unable to resolve metadata region\n" ); +return -EINVAL ; + } + + qproc->mdata_phys = rmem->base; + qproc->mdata_size = rmem->size; +return 0 ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 495/885 media: ti: cal: fix possible memory leak in cal_ctx_create()
In reply to Greg Kroah-HartmanFrom: Gaosheng Cui <[email protected]>
[ Upstream commit 7acd650a0484d92985a0d6d867d980c6dd019885 ]
The memory of ctx is allocated in cal_ctx_create(), but it will not be freed when cal_ctx_v4l2_init() fails, so add kfree() when cal_ctx_v4l2_init() fails to fix it.
--- drivers/media/platform/ti/cal/cal.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/platform/ti/cal/cal.c +3 -1
@@ -1050,8 +1050,10 @@ static struct cal_ctx *cal_ctx_create(struct cal_dev *cal, int inst) ctx->cport = inst; ret =cal_ctx_v4l2_init (ctx); -if (ret) +if (ret) { +kfree (ctx);return NULL ; + }return ctx; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 496/885 media: platform: ti: Add missing check for devm_regulator_get
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit da8e05f84a11c3cc3b0ba0a3c62d20e358002d99 ]
Add check for the return value of devm_regulator_get since it may return error pointer.
--- drivers/media/platform/ti/omap3isp/isp.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/media/platform/ti/omap3isp/isp.c +9 -0
@@ -2308,7 +2308,16 @@ static int isp_probe(struct platform_device *pdev)/* Regulators */ isp->isp_csiphy1.vdd =devm_regulator_get (&pdev->dev,"vdd-csiphy1" ); +if (IS_ERR (isp->isp_csiphy1.vdd)) { + ret =PTR_ERR (isp->isp_csiphy1.vdd); + goto error; + } + isp->isp_csiphy2.vdd =devm_regulator_get (&pdev->dev,"vdd-csiphy2" ); +if (IS_ERR (isp->isp_csiphy2.vdd)) { + ret =PTR_ERR (isp->isp_csiphy2.vdd); + goto error; + }/* Clocks *
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 497/885 media: imx: imx7-media-csi: fix missing clk_disable_unprepare() in imx7_csi_init()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit cea606d9e996a77eed57fc60709e0728341450e3 ]
Add missing clk_disable_unprepare(), if imx7_csi_dma_setup() fails in imx7_csi_init().
--- drivers/staging/media/imx/imx7-media-csi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/staging/media/imx/imx7-media-csi.c +3 -1
@@ -638,8 +638,10 @@ static int imx7_csi_init(struct imx7_csi *csi)imx7_csi_configure (csi); ret =imx7_csi_dma_setup (csi); -if (ret <0 ) +if (ret <0 ) { +clk_disable_unprepare (csi->mclk);return ret; + }return 0 ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 498/885 powerpc: Remove linker flag from KBUILD_AFLAGS
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
[ Upstream commit 31f48f16264bc70962fb3e7ec62da64d0a2ba04a ]
When clang's -Qunused-arguments is dropped from KBUILD_CPPFLAGS, it points out that KBUILD_AFLAGS contains a linker flag, which will be unused:
clang: error: -Wl,-a32: 'linker' input unused [-Werror,-Wunused-command-line-argument]
This was likely supposed to be '-Wa,-a$(BITS)'. However, this change is unnecessary, as all supported versions of clang and gcc will pass '-a64' or '-a32' to GNU as based on the value of '-m'; the behavior of the latest stable release of the oldest supported major version of each compiler is shown below and each compiler's latest release exhibits the same behavior (GCC 12.2.0 and Clang 15.0.6).
$ powerpc64-linux-gcc --version | head -1 powerpc64-linux-gcc (GCC) 5.5.0
$ powerpc64-linux-gcc -m64 -### -x assembler-with-cpp -c -o /dev/null /dev/null &| grep 'as ' .../as -a64 -mppc64 -many -mbig -o /dev/null /tmp/cctwuBzZ.s
$ powerpc64-linux-gcc -m32 -### -x assembler-with-cpp -c -o /dev/null /dev/null &| grep 'as ' .../as -a32 -mppc -many -mbig -o /dev/null /tmp/ccaZP4mF.sg
$ clang --version | head -1 Ubuntu clang version 11.1.0-++20211011094159+1fdec59bffc1-1~exp1~20211011214622.5
$ clang --target=powerpc64-linux-gnu -fno-integrated-as -m64 -### \
-x assembler-with-cpp -c -o /dev/null /dev/null &| grep gnu-as
"/usr/bin/powerpc64-linux-gnu-as" "-a64" "-mppc64" "-many" "-o" "/dev/null" "/tmp/null-80267c.s" $ clang --target=powerpc64-linux-gnu -fno-integrated-as -m64 -### \
-x assembler-with-cpp -c -o /dev/null /dev/null &| grep gnu-as
"/usr/bin/powerpc64-linux-gnu-as" "-a32" "-mppc" "-many" "-o" "/dev/null" "/tmp/null-ab8f8d.s"Remove this flag altogether to avoid future issues.
--- arch/powerpc/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/Makefile +1 -1
@@ -90,7 +90,7 @@ aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian ifeq ($(HAS_BIARCH),y) KBUILD_CFLAGS += -m$(BITS) -KBUILD_AFLAGS += -m$(BITS) -Wl,-a$(BITS) +KBUILD_AFLAGS += -m$(BITS) KBUILD_LDFLAGS += -m elf$(BITS)$(LDEMULATION) endif
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 499/885 s390/vdso: Drop -shared from KBUILD_CFLAGS_64
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
[ Upstream commit fd8589dce8107e2ce62e92f76089654462dd67b4 ]
When clang's -Qunused-arguments is dropped from KBUILD_CPPFLAGS, it points out that there is a linking phase flag added to CFLAGS, which will only be used for compiling
clang-16: error: argument unused during compilation: '-shared' [-Werror,-Wunused-command-line-argument]
'-shared' is already present in ldflags-y so it can just be dropped.
--- arch/s390/kernel/vdso64/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kernel/vdso64/Makefile +1 -1
@@ -25,7 +25,7 @@ KBUILD_AFLAGS_64 := $(filter-out -m64,$(KBUILD_AFLAGS)) KBUILD_AFLAGS_64 += -m64 -s KBUILD_CFLAGS_64 := $(filter-out -m64,$(KBUILD_CFLAGS)) -KBUILD_CFLAGS_64 += -m64 -fPIC -shared -fno-common -fno-builtin +KBUILD_CFLAGS_64 += -m64 -fPIC -fno-common -fno-builtin ldflags-y := -fPIC -shared -soname=linux-vdso64.so.1 \ --hash-style=both --build-id=sha1 -T
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 500/885 builddeb: clean generated package content
In reply to Greg Kroah-HartmanFrom: Bastian Germann <[email protected]>
[ Upstream commit c9f9cf2560e40b62015c6c4a04be60f55ce5240e ]
For each binary Debian package, a directory with the package name is created in the debian directory. Correct the generated file matches in the package's clean target, which were renamed without adjusting the target.
--- scripts/package/mkdebian | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/package/mkdebian +1 -1
@@ -236,7 +236,7 @@ binary-arch: build-arch KBUILD_BUILD_VERSION=${revision} -f \$(srctree)/Makefile intdeb-pkg clean: - rm -rf debian/*tmp debian/files + rm -rf debian/files debian/linux-* \$(MAKE) clean binary: binary-arch
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 501/885 media: max9286: Fix memleak in max9286_v4l2_register()
In reply to Greg Kroah-HartmanFrom: Shang XiaoJing <[email protected]>
[ Upstream commit 8636c5fc7658c7c6299fb8b352d24ea4b9ba99e2 ]
There is a kmemleak when testing the media/i2c/max9286.c with bpf mock device:
kmemleak: 5 new suspected memory leaks (see /sys/kernel/debug/kmemleak)
unreferenced object 0xffff88810defc400 (size 256):
comm "python3", pid 278, jiffies 4294737563 (age 31.978s) hex dump (first 32 bytes):
28 06 a7 0a 81 88 ff ff 00 fe 22 12 81 88 ff ff (.........".....
10 c4 ef 0d 81 88 ff ff 10 c4 ef 0d 81 88 ff ff ................
backtrace:
[<00000000191de6a7>] __kmalloc_node+0x44/0x1b0
[<000000002f4912b7>] kvmalloc_node+0x34/0x180
[<0000000057dc4cae>] v4l2_ctrl_new+0x325/0x10f0 [videodev]
[<0000000026030272>] v4l2_ctrl_new_std+0x16f/0x210 [videodev]
[<00000000f0d9ea2f>] max9286_probe+0x76e/0xbff [max9286]
[<00000000ea8f6455>] i2c_device_probe+0x28d/0x680
[<0000000087529af3>] really_probe+0x17c/0x3f0
[<00000000b08be526>] __driver_probe_device+0xe3/0x170
[<000000004382edea>] driver_probe_device+0x49/0x120
[<000000007bde528a>] __device_attach_driver+0xf7/0x150
[<000000009f9c6ab4>] bus_for_each_drv+0x114/0x180
[<00000000c8aaf588>] __device_attach+0x1e5/0x2d0
[<0000000041cc06b9>] bus_probe_device+0x126/0x140
[<000000002309860d>] device_add+0x810/0x1130
[<000000002827bf98>] i2c_new_client_device+0x359/0x4f0
[<00000000593bdc85>] of_i2c_register_device+0xf1/0x110max9286_v4l2_register() calls v4l2_ctrl_new_std(), but won't free the created v412_ctrl when fwnode_graph_get_endpoint_by_id() failed, which causes the memleak. Call v4l2_ctrl_handler_free() to free the v412_ctrl.
--- drivers/media/i2c/max9286.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/i2c/max9286.c +1 -0
@@ -932,6 +932,7 @@ static int max9286_v4l2_register(struct max9286_priv *priv) err_put_node:fwnode_handle_put (ep); err_async: +v4l2_ctrl_handler_free (&priv->ctrls);max9286_v4l2_notifier_unregister (priv);return ret;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 502/885 media: ov2740: Fix memleak in ov2740_init_controls()
In reply to Greg Kroah-HartmanFrom: Shang XiaoJing <[email protected]>
[ Upstream commit 2d899592ed7829d0d5140853bac4d58742a6b8af ]
There is a kmemleak when testing the media/i2c/ov2740.c with bpf mock device:
unreferenced object 0xffff8881090e19e0 (size 16):
comm "51-i2c-ov2740", pid 278, jiffies 4294781584 (age 23.613s) hex dump (first 16 bytes):
00 f3 7c 0b 81 88 ff ff 80 75 6a 09 81 88 ff ff ..|......uj.....
backtrace:
[<000000004e9fad8f>] __kmalloc_node+0x44/0x1b0
[<0000000039c802f4>] kvmalloc_node+0x34/0x180
[<000000009b8b5c63>] v4l2_ctrl_handler_init_class+0x11d/0x180
[videodev]
[<0000000038644056>] ov2740_probe+0x37d/0x84f [ov2740]
[<0000000092489f59>] i2c_device_probe+0x28d/0x680
[<000000001038babe>] really_probe+0x17c/0x3f0
[<0000000098c7af1c>] __driver_probe_device+0xe3/0x170
[<00000000e1b3dc24>] device_driver_attach+0x34/0x80
[<000000005a04a34d>] bind_store+0x10b/0x1a0
[<00000000ce25d4f2>] drv_attr_store+0x49/0x70
[<000000007d9f4e9a>] sysfs_kf_write+0x8c/0xb0
[<00000000be6cff0f>] kernfs_fop_write_iter+0x216/0x2e0
[<0000000031ddb40a>] vfs_write+0x658/0x810
[<0000000041beecdd>] ksys_write+0xd6/0x1b0
[<0000000023755840>] do_syscall_64+0x38/0x90
[<00000000b2cc2da2>] entry_SYSCALL_64_after_hwframe+0x63/0xcdov2740_init_controls() won't clean all the allocated resources in fail path, which may causes the memleaks. Add v4l2_ctrl_handler_free() to prevent memleak.
--- drivers/media/i2c/ov2740.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/i2c/ov2740.c +3 -1
@@ -630,8 +630,10 @@ static int ov2740_init_controls(struct ov2740 *ov2740)V4L2_CID_TEST_PATTERN ,ARRAY_SIZE (ov2740_test_pattern_menu) -1 , 0, 0, ov2740_test_pattern_menu); -if (ctrl_hdlr->error) +if (ctrl_hdlr->error) { +v4l2_ctrl_handler_free (ctrl_hdlr);return ctrl_hdlr->error; + } ov2740->sd.ctrl_handler = ctrl_hdlr;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 503/885 media: ov5675: Fix memleak in ov5675_init_controls()
In reply to Greg Kroah-HartmanFrom: Shang XiaoJing <[email protected]>
[ Upstream commit dd74ed6c213003533e3abf4c204374ef01d86978 ]
There is a kmemleak when testing the media/i2c/ov5675.c with bpf mock device:
AssertionError: unreferenced object 0xffff888107362160 (size 16):
comm "python3", pid 277, jiffies 4294832798 (age 20.722s) hex dump (first 16 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<00000000abe7d67c>] __kmalloc_node+0x44/0x1b0
[<000000008a725aac>] kvmalloc_node+0x34/0x180
[<000000009a53cd11>] v4l2_ctrl_handler_init_class+0x11d/0x180
[videodev]
[<0000000055b46db0>] ov5675_probe+0x38b/0x897 [ov5675]
[<00000000153d886c>] i2c_device_probe+0x28d/0x680
[<000000004afb7e8f>] really_probe+0x17c/0x3f0
[<00000000ff2f18e4>] __driver_probe_device+0xe3/0x170
[<000000000a001029>] driver_probe_device+0x49/0x120
[<00000000e39743c7>] __device_attach_driver+0xf7/0x150
[<00000000d32fd070>] bus_for_each_drv+0x114/0x180
[<000000009083ac41>] __device_attach+0x1e5/0x2d0
[<0000000015b4a830>] bus_probe_device+0x126/0x140
[<000000007813deaf>] device_add+0x810/0x1130
[<000000007becb867>] i2c_new_client_device+0x386/0x540
[<000000007f9cf4b4>] of_i2c_register_device+0xf1/0x110
[<00000000ebfdd032>] of_i2c_notify+0xfc/0x1f0ov5675_init_controls() won't clean all the allocated resources in fail path, which may causes the memleaks. Add v4l2_ctrl_handler_free() to prevent memleak.
--- drivers/media/i2c/ov5675.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/i2c/ov5675.c +3 -1
@@ -820,8 +820,10 @@ static int ov5675_init_controls(struct ov5675 *ov5675)v4l2_ctrl_new_std (ctrl_hdlr, &ov5675_ctrl_ops,V4L2_CID_VFLIP ,0 ,1 ,1 ,0 ); -if (ctrl_hdlr->error) +if (ctrl_hdlr->error) { +v4l2_ctrl_handler_free (ctrl_hdlr);return ctrl_hdlr->error; + } ov5675->sd.ctrl_handler = ctrl_hdlr;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 504/885 media: ov5640: Fix soft reset sequence and timings
In reply to Greg Kroah-HartmanFrom: Jai Luthra <[email protected]>
[ Upstream commit decea0a98b7ac04536c7d659f74783e8d67a06c0 ]
Move the register-based reset out of the init_setting[] and into the powerup_sequence function. The sensor is power cycled and reset using the gpio pins so the soft reset is not always necessary.
This also ensures that soft reset honors the timing sequence from the datasheet [1].
[1] https://cdn.sparkfun.com/datasheets/Sensors/LightImaging/OV5640_datasheet.pdf
--- drivers/media/i2c/ov5640.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-)
drivers/media/i2c/ov5640.c +24 -10
@@ -50,6 +50,7 @@#define OV5640_REG_SYS_CTRL0 0x3008#define OV5640_REG_SYS_CTRL0_SW_PWDN 0x42#define OV5640_REG_SYS_CTRL0_SW_PWUP 0x02 +#define OV5640_REG_SYS_CTRL0_SW_RST 0x82#define OV5640_REG_CHIP_ID 0x300a#define OV5640_REG_IO_MIPI_CTRL00 0x300e#define OV5640_REG_PAD_OUTPUT_ENABLE01 0x3017
@@ -532,7 +533,7 @@ static const struct v4l2_mbus_framefmt ov5640_default_fmt = { };static const struct reg_value ov5640_init_setting[] = { - {0x3103 ,0x11 ,0 ,0 }, {0x3008 ,0x82 ,0 ,5 }, {0x3008 ,0x42 ,0 ,0 }, + {0x3103 ,0x11 ,0 ,0 }, {0x3103 ,0x03 ,0 ,0 }, {0x3630 ,0x36 ,0 ,0 }, {0x3631 ,0x0e ,0 ,0 }, {0x3632 ,0xe2 ,0 ,0 }, {0x3633 ,0x12 ,0 ,0 }, {0x3621 ,0xe0 ,0 ,0 }, {0x3704 ,0xa0 ,0 ,0 }, {0x3703 ,0x5a ,0 ,0 },
@@ -2429,19 +2430,32 @@ static void ov5640_reset(struct ov5640_dev *sensor)if (!sensor->reset_gpio)return ; -gpiod_set_value_cansleep (sensor->reset_gpio,0 ); +if (sensor->pwdn_gpio) { +gpiod_set_value_cansleep (sensor->reset_gpio,0 ); -/* camera power cycle */ -ov5640_power (sensor, false); -usleep_range (5000 ,10000 ); -ov5640_power (sensor, true); -usleep_range (5000 ,10000 ); +/* camera power cycle */ +ov5640_power (sensor, false); +usleep_range (5000 ,10000 ); +ov5640_power (sensor, true); +usleep_range (5000 ,10000 ); -gpiod_set_value_cansleep (sensor->reset_gpio,1 ); -usleep_range (1000 ,2000 ); +gpiod_set_value_cansleep (sensor->reset_gpio,1 ); +usleep_range (1000 ,2000 ); -gpiod_set_value_cansleep (sensor->reset_gpio,0 ); +gpiod_set_value_cansleep (sensor->reset_gpio,0 ); + }else { +/* software reset */ +ov5640_write_reg (sensor,OV5640_REG_SYS_CTRL0 , +OV5640_REG_SYS_CTRL0_SW_RST ); + }usleep_range (20000 ,25000 ); + +/* +* software standby: allows registers programming; +* exit at restore_mode() for CSI, s_stream(1) for DVP +*/ +ov5640_write_reg (sensor,OV5640_REG_SYS_CTRL0 , +OV5640_REG_SYS_CTRL0_SW_PWDN ); }static int ov5640_set_power_on (struct ov5640_dev *sensor)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 505/885 media: ov5640: Handle delays when no reset_gpio set
In reply to Greg Kroah-HartmanFrom: Jai Luthra <[email protected]>
[ Upstream commit d7ff69139908842adf824be4f50c7e9ac5886c04 ]
Some module manufacturers [1][2] don't expose the RESETB and PWDN pins of the sensor directly through the 15-pin FFC connector. Instead wiring ~PWDN gpio to the sensor pins with appropriate delays.
In such cases, reset_gpio will not be available to the driver, but it will still be toggled when the sensor is powered on, and thus we should still honor the wait time of >= 5ms + 1ms + 20ms (see figure 2-3 in [3]) before attempting any i/o operations over SCCB.
Also, rename the function to ov5640_powerup_sequence to better match the datasheet (section 2.7).
[1] https://digilent.com/reference/_media/reference/add-ons/pcam-5c/pcam_5c_sch.pdf
[2] https://www.alinx.com/public/upload/file/AN5641_User_Manual.pdf
[3] https://cdn.sparkfun.com/datasheets/Sensors/LightImaging/OV5640_datasheet.pdf
--- drivers/media/i2c/ov5640.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
drivers/media/i2c/ov5640.c +16 -6
@@ -2425,11 +2425,22 @@ static void ov5640_power(struct ov5640_dev *sensor, bool enable)gpiod_set_value_cansleep (sensor->pwdn_gpio, enable ?0 :1 ); } -static void ov5640_reset (struct ov5640_dev *sensor) +/* +* From section 2.7 power up sequence: +* t0 + t1 + t2 >= 5ms Delay from DOVDD stable to PWDN pull down +* t3 >= 1ms Delay from PWDN pull down to RESETB pull up +* t4 >= 20ms Delay from RESETB pull up to SCCB (i2c) stable +* +* Some modules don't expose RESETB/PWDN pins directly, instead providing a +* "PWUP" GPIO which is wired through appropriate delays and inverters to the +* pins. +* +* In such cases, this gpio should be mapped to pwdn_gpio in the driver, and we +* should still toggle the pwdn_gpio below with the appropriate delays, while +* the calls to reset_gpio will be ignored. +*/ +static void ov5640_powerup_sequence (struct ov5640_dev *sensor) { -if (!sensor->reset_gpio) -return ; -if (sensor->pwdn_gpio) {gpiod_set_value_cansleep (sensor->reset_gpio,0 );
@@ -2478,8 +2489,7 @@ static int ov5640_set_power_on(struct ov5640_dev *sensor) goto xclk_off; } -ov5640_reset (sensor); -ov5640_power (sensor, true); +ov5640_powerup_sequence (sensor); ret =ov5640_init_slave_id (sensor);if (ret)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 506/885 media: mc: Get media_device directly from pad
In reply to Greg Kroah-HartmanFrom: Laurent Pinchart <[email protected]>
[ Upstream commit a967a3a788028f541e4db54beabcebc3648997db ]
Various functions access the media_device from a pad by going through the entity the pad belongs to. Remove the level of indirection and get the media_device from the pad directly.
--- drivers/media/mc/mc-entity.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/media/mc/mc-entity.c +4 -4
@@ -703,7 +703,7 @@ static int media_pipeline_populate(struct media_pipeline *pipe,__must_check int __media_pipeline_start (struct media_pad *pad,struct media_pipeline *pipe) { -struct media_device *mdev = pad->entity->graph_obj.mdev; +struct media_device *mdev = pad->graph_obj.mdev;struct media_pipeline_pad *err_ppad;struct media_pipeline_pad *ppad;int ret;
@@ -851,7 +851,7 @@ EXPORT_SYMBOL_GPL(__media_pipeline_start);__must_check int media_pipeline_start (struct media_pad *pad,struct media_pipeline *pipe) { -struct media_device *mdev = pad->entity->graph_obj.mdev; +struct media_device *mdev = pad->graph_obj.mdev;int ret;mutex_lock (&mdev->graph_mutex);
@@ -888,7 +888,7 @@ EXPORT_SYMBOL_GPL(__media_pipeline_stop);void media_pipeline_stop (struct media_pad *pad) { -struct media_device *mdev = pad->entity->graph_obj.mdev; +struct media_device *mdev = pad->graph_obj.mdev;mutex_lock (&mdev->graph_mutex);__media_pipeline_stop (pad);
@@ -898,7 +898,7 @@ EXPORT_SYMBOL_GPL(media_pipeline_stop);__must_check int media_pipeline_alloc_start (struct media_pad *pad) { -struct media_device *mdev = pad->entity->graph_obj.mdev; +struct media_device *mdev = pad->graph_obj.mdev;struct media_pipeline *new_pipe =NULL ;struct media_pipeline *pipe;int ret;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 507/885 media: i2c: ov772x: Fix memleak in ov772x_probe()
In reply to Greg Kroah-HartmanFrom: Yuan Can <[email protected]>
[ Upstream commit 7485edb2b6ca5960205c0a49bedfd09bba30e521 ]
A memory leak was reported when testing ov772x with bpf mock device:
AssertionError: unreferenced object 0xffff888109afa7a8 (size 8):
comm "python3", pid 279, jiffies 4294805921 (age 20.681s) hex dump (first 8 bytes):
80 22 88 15 81 88 ff ff ."......
backtrace:
[<000000009990b438>] __kmalloc_node+0x44/0x1b0
[<000000009e32f7d7>] kvmalloc_node+0x34/0x180
[<00000000faf48134>] v4l2_ctrl_handler_init_class+0x11d/0x180 [videodev]
[<00000000da376937>] ov772x_probe+0x1c3/0x68c [ov772x]
[<000000003f0d225e>] i2c_device_probe+0x28d/0x680
[<00000000e0b6db89>] really_probe+0x17c/0x3f0
[<000000001b19fcee>] __driver_probe_device+0xe3/0x170
[<0000000048370519>] driver_probe_device+0x49/0x120
[<000000005ead07a0>] __device_attach_driver+0xf7/0x150
[<0000000043f452b8>] bus_for_each_drv+0x114/0x180
[<00000000358e5596>] __device_attach+0x1e5/0x2d0
[<0000000043f83c5d>] bus_probe_device+0x126/0x140
[<00000000ee0f3046>] device_add+0x810/0x1130
[<00000000e0278184>] i2c_new_client_device+0x359/0x4f0
[<0000000070baf34f>] of_i2c_register_device+0xf1/0x110
[<00000000a9f2159d>] of_i2c_notify+0x100/0x160
unreferenced object 0xffff888119825c00 (size 256):
comm "python3", pid 279, jiffies 4294805921 (age 20.681s)
hex dump (first 32 bytes):
00 b4 a5 17 81 88 ff ff 00 5e 82 19 81 88 ff ff .........^......
10 5c 82 19 81 88 ff ff 10 5c 82 19 81 88 ff ff .\.......\......
backtrace:
[<000000009990b438>] __kmalloc_node+0x44/0x1b0
[<000000009e32f7d7>] kvmalloc_node+0x34/0x180
[<0000000073d88e0b>] v4l2_ctrl_new.cold+0x19b/0x86f [videodev]
[<00000000b1f576fb>] v4l2_ctrl_new_std+0x16f/0x210 [videodev]
[<00000000caf7ac99>] ov772x_probe+0x1fa/0x68c [ov772x]
[<000000003f0d225e>] i2c_device_probe+0x28d/0x680
[<00000000e0b6db89>] really_probe+0x17c/0x3f0
[<000000001b19fcee>] __driver_probe_device+0xe3/0x170
[<0000000048370519>] driver_probe_device+0x49/0x120
[<000000005ead07a0>] __device_attach_driver+0xf7/0x150
[<0000000043f452b8>] bus_for_each_drv+0x114/0x180
[<00000000358e5596>] __device_attach+0x1e5/0x2d0
[<0000000043f83c5d>] bus_probe_device+0x126/0x140
[<00000000ee0f3046>] device_add+0x810/0x1130
[<00000000e0278184>] i2c_new_client_device+0x359/0x4f0
[<0000000070baf34f>] of_i2c_register_device+0xf1/0x110The reason is that if priv->hdl.error is set, ov772x_probe() jumps to the error_mutex_destroy without doing v4l2_ctrl_handler_free(), and all resources allocated in v4l2_ctrl_handler_init() and v4l2_ctrl_new_std() are leaked.
--- drivers/media/i2c/ov772x.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/media/i2c/ov772x.c +1 -2
@@ -1462,7 +1462,7 @@ static int ov772x_probe(struct i2c_client *client) priv->subdev.ctrl_handler = &priv->hdl;if (priv->hdl.error) { ret = priv->hdl.error; - goto error_mutex_destroy; + goto error_ctrl_free; } priv->clk =clk_get (&client->dev,NULL );
@@ -1515,7 +1515,6 @@ static int ov772x_probe(struct i2c_client *client)clk_put (priv->clk); error_ctrl_free:v4l2_ctrl_handler_free (&priv->hdl); -error_mutex_destroy:mutex_destroy (&priv->lock);return ret;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 508/885 media: i2c: imx219: Split common registers from mode tables
In reply to Greg Kroah-HartmanFrom: Adam Ford <[email protected]>
[ Upstream commit 8508455961d5a9e8907bcfd8dcd58f19d9b6ce47 ]
There are four modes, and each mode has a table of registers. Some of the registers are common to all modes, so create new tables for these common registers to reduce duplicate code.
Stable-dep-of: ef86447e775f ("media: i2c: imx219: Fix binning for RAW8 capture")
--- drivers/media/i2c/imx219.c | 206 +++++++++++-------------------------- 1 file changed, 59 insertions(+), 147 deletions(-)
drivers/media/i2c/imx219.c +59 -147
@@ -145,23 +145,61 @@ struct imx219_mode {struct imx219_reg_list reg_list; }; -/* -* Register sets lifted off the i2C interface from the Raspberry Pi firmware -* driver. -* 3280x2464 = mode 2, 1920x1080 = mode 1, 1640x1232 = mode 4, 640x480 = mode 7. -*/ -static const struct imx219_reg mode_3280x2464_regs[] = { - {0x0100 ,0x00 }, +static const struct imx219_reg imx219_common_regs[] = { + {0x0100 ,0x00 },/* Mode Select */ + +/* To Access Addresses 3000-5fff, send the following commands */ {0x30eb ,0x0c }, {0x30eb ,0x05 }, {0x300a ,0xff }, {0x300b ,0xff }, {0x30eb ,0x05 }, {0x30eb ,0x09 }, - {0x0114 ,0x01 }, - {0x0128 ,0x00 }, - {0x012a ,0x18 }, + +/* PLL Clock Table */ + {0x0301 ,0x05 },/* VTPXCK_DIV */ + {0x0303 ,0x01 },/* VTSYSCK_DIV */ + {0x0304 ,0x03 },/* PREPLLCK_VT_DIV 0x03 = AUTO set */ + {0x0305 ,0x03 },/* PREPLLCK_OP_DIV 0x03 = AUTO set */ + {0x0306 ,0x00 },/* PLL_VT_MPY */ + {0x0307 ,0x39 }, + {0x030b ,0x01 },/* OP_SYS_CLK_DIV */ + {0x030c ,0x00 },/* PLL_OP_MPY */ + {0x030d ,0x72 }, + +/* Undocumented registers */ + {0x455e ,0x00 }, + {0x471e ,0x4b }, + {0x4767 ,0x0f }, + {0x4750 ,0x14 }, + {0x4540 ,0x00 }, + {0x47b4 ,0x14 }, + {0x4713 ,0x30 }, + {0x478b ,0x10 }, + {0x478f ,0x10 }, + {0x4793 ,0x10 }, + {0x4797 ,0x0e }, + {0x479b ,0x0e }, + +/* Frame Bank Register Group "A" */ + {0x0162 ,0x0d },/* Line_Length_A */ + {0x0163 ,0x78 }, + {0x0170 ,0x01 },/* X_ODD_INC_A */ + {0x0171 ,0x01 },/* Y_ODD_INC_A */ + +/* Output setup registers */ + {0x0114 ,0x01 },/* CSI 2-Lane Mode */ + {0x0128 ,0x00 },/* DPHY Auto Mode */ + {0x012a ,0x18 },/* EXCK_Freq */ {0x012b ,0x00 }, +}; + +/* +* Register sets lifted off the i2C interface from the Raspberry Pi firmware +* driver. +* 3280x2464 = mode 2, 1920x1080 = mode 1, 1640x1232 = mode 4, 640x480 = mode 7. +*/ +static const struct imx219_reg mode_3280x2464_regs[] = { {0x0164 ,0x00 }, {0x0165 ,0x00 }, {0x0166 ,0x0c },
@@ -174,53 +212,15 @@ static const struct imx219_reg mode_3280x2464_regs[] = { {0x016d, 0xd0}, {0x016e, 0x09}, {0x016f, 0xa0}, - {0x0170, 0x01}, - {0x0171, 0x01}, - {0x0174, 0x00}, + {0x0174, 0x00}, /* No-Binning */ {0x0175, 0x00}, - {0x0301, 0x05}, - {0x0303, 0x01}, - {0x0304, 0x03}, - {0x0305, 0x03}, - {0x0306, 0x00}, - {0x0307, 0x39}, - {0x030b, 0x01}, - {0x030c, 0x00}, - {0x030d, 0x72}, {0x0624, 0x0c}, {0x0625, 0xd0}, {0x0626, 0x09}, {0x0627, 0xa0}, - {0x455e, 0x00}, - {0x471e, 0x4b}, - {0x4767, 0x0f}, - {0x4750, 0x14}, - {0x4540, 0x00}, - {0x47b4, 0x14}, - {0x4713, 0x30}, - {0x478b, 0x10}, - {0x478f, 0x10}, - {0x4793, 0x10}, - {0x4797, 0x0e}, - {0x479b, 0x0e}, - {0x0162, 0x0d}, - {0x0163, 0x78}, };static const struct imx219_reg mode_1920_1080_regs[] = { - {0x0100 ,0x00 }, - {0x30eb ,0x05 }, - {0x30eb ,0x0c }, - {0x300a ,0xff }, - {0x300b ,0xff }, - {0x30eb ,0x05 }, - {0x30eb ,0x09 }, - {0x0114 ,0x01 }, - {0x0128 ,0x00 }, - {0x012a ,0x18 }, - {0x012b ,0x00 }, - {0x0162 ,0x0d }, - {0x0163 ,0x78 }, {0x0164 ,0x02 }, {0x0165 ,0xa8 }, {0x0166, 0x0a},
@@ -233,49 +233,15 @@ static const struct imx219_reg mode_1920_1080_regs[] = { {0x016d, 0x80}, {0x016e, 0x04}, {0x016f, 0x38}, - {0x0170, 0x01}, - {0x0171, 0x01}, - {0x0174, 0x00}, + {0x0174, 0x00}, /* No-Binning */ {0x0175, 0x00}, - {0x0301, 0x05}, - {0x0303, 0x01}, - {0x0304, 0x03}, - {0x0305, 0x03}, - {0x0306, 0x00}, - {0x0307, 0x39}, - {0x030b, 0x01}, - {0x030c, 0x00}, - {0x030d, 0x72}, {0x0624, 0x07}, {0x0625, 0x80}, {0x0626, 0x04}, {0x0627, 0x38}, - {0x455e, 0x00}, - {0x471e, 0x4b}, - {0x4767, 0x0f}, - {0x4750, 0x14}, - {0x4540, 0x00}, - {0x47b4, 0x14}, - {0x4713, 0x30}, - {0x478b, 0x10}, - {0x478f, 0x10}, - {0x4793, 0x10}, - {0x4797, 0x0e}, - {0x479b, 0x0e}, };static const struct imx219_reg mode_1640_1232_regs[] = { - {0x0100 ,0x00 }, - {0x30eb ,0x0c }, - {0x30eb ,0x05 }, - {0x300a ,0xff }, - {0x300b ,0xff }, - {0x30eb ,0x05 }, - {0x30eb ,0x09 }, - {0x0114 ,0x01 }, - {0x0128 ,0x00 }, - {0x012a ,0x18 }, - {0x012b ,0x00 }, {0x0164 ,0x00 }, {0x0165 ,0x00 }, {0x0166, 0x0c},
@@ -288,53 +254,15 @@ static const struct imx219_reg mode_1640_1232_regs[] = { {0x016d, 0x68}, {0x016e, 0x04}, {0x016f, 0xd0}, - {0x0170, 0x01}, - {0x0171, 0x01}, - {0x0174, 0x01}, + {0x0174, 0x01}, /* x2-Binning */ {0x0175, 0x01}, - {0x0301, 0x05}, - {0x0303, 0x01}, - {0x0304, 0x03}, - {0x0305, 0x03}, - {0x0306, 0x00}, - {0x0307, 0x39}, - {0x030b, 0x01}, - {0x030c, 0x00}, - {0x030d, 0x72}, {0x0624, 0x06}, {0x0625, 0x68}, {0x0626, 0x04}, {0x0627, 0xd0}, - {0x455e, 0x00}, - {0x471e, 0x4b}, - {0x4767, 0x0f}, - {0x4750, 0x14}, - {0x4540, 0x00}, - {0x47b4, 0x14}, - {0x4713, 0x30}, - {0x478b, 0x10}, - {0x478f, 0x10}, - {0x4793, 0x10}, - {0x4797, 0x0e}, - {0x479b, 0x0e}, - {0x0162, 0x0d}, - {0x0163, 0x78}, };static const struct imx219_reg mode_640_480_regs[] = { - {0x0100 ,0x00 }, - {0x30eb ,0x05 }, - {0x30eb ,0x0c }, - {0x300a ,0xff }, - {0x300b ,0xff }, - {0x30eb ,0x05 }, - {0x30eb ,0x09 }, - {0x0114 ,0x01 }, - {0x0128 ,0x00 }, - {0x012a ,0x18 }, - {0x012b ,0x00 }, - {0x0162 ,0x0d }, - {0x0163 ,0x78 }, {0x0164 ,0x03 }, {0x0165 ,0xe8 }, {0x0166, 0x08},
@@ -347,35 +275,12 @@ static const struct imx219_reg mode_640_480_regs[] = { {0x016d, 0x80}, {0x016e, 0x01}, {0x016f, 0xe0}, - {0x0170, 0x01}, - {0x0171, 0x01}, - {0x0174, 0x03}, + {0x0174, 0x03}, /* x2-analog binning */ {0x0175, 0x03}, - {0x0301, 0x05}, - {0x0303, 0x01}, - {0x0304, 0x03}, - {0x0305, 0x03}, - {0x0306, 0x00}, - {0x0307, 0x39}, - {0x030b, 0x01}, - {0x030c, 0x00}, - {0x030d, 0x72}, {0x0624, 0x06}, {0x0625, 0x68}, {0x0626, 0x04}, {0x0627, 0xd0}, - {0x455e, 0x00}, - {0x471e, 0x4b}, - {0x4767, 0x0f}, - {0x4750, 0x14}, - {0x4540, 0x00}, - {0x47b4, 0x14}, - {0x4713, 0x30}, - {0x478b, 0x10}, - {0x478f, 0x10}, - {0x4793, 0x10}, - {0x4797, 0x0e}, - {0x479b, 0x0e}, }; static const struct imx219_reg raw8_framefmt_regs[] = {
@@ -1041,6 +946,13 @@ static int imx219_start_streaming(struct imx219 *imx219)if (ret <0 )return ret; +/* Send all registers that are common to all modes */ + ret =imx219_write_regs (imx219, imx219_common_regs,ARRAY_SIZE (imx219_common_regs)); +if (ret) { +dev_err (&client->dev,"%s failed to send mfg header\n" , __func__); + goto err_rpm_put; + } +/* Apply default values of current mode */ reg_list = &imx219->mode->reg_list; ret =imx219_write_regs (imx219, reg_list->regs, reg_list->num_of_regs);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 509/885 media: i2c: imx219: Fix binning for RAW8 capture
In reply to Greg Kroah-HartmanFrom: Jai Luthra <[email protected]>
[ Upstream commit ef86447e775fb1f2ced00d4c7fff2c0a1c63f165 ]
2x2 binning works fine for RAW10 capture, but for RAW8 1232p mode it leads to corrupted frames [1][2].
Using the special 2x2 analog binning mode fixes the issue, but causes artefacts for RAW10 1232p capture. So here we choose the binning mode depending upon the frame format selected.
As both binning modes work fine for 480p RAW8 and RAW10 capture, it can share the same code path as 1232p for selecting binning mode.
[1] https://forums.raspberrypi.com/viewtopic.php?t=332103
[2] https://github.com/raspberrypi/libcamera-apps/issues/281
--- drivers/media/i2c/imx219.c | 57 ++++++++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 8 deletions(-)
drivers/media/i2c/imx219.c +49 -8
@@ -89,6 +89,12 @@#define IMX219_REG_ORIENTATION 0x0172 +/* Binning Mode */ +#define IMX219_REG_BINNING_MODE 0x0174 +#define IMX219_BINNING_NONE 0x0000 +#define IMX219_BINNING_2X2 0x0101 +#define IMX219_BINNING_2X2_ANALOG 0x0303 +/* Test Pattern Control */ #define IMX219_REG_TEST_PATTERN 0x0600#define IMX219_TEST_PATTERN_DISABLE 0
@@ -143,6 +149,9 @@ struct imx219_mode {/* Default register values */ struct imx219_reg_list reg_list; + +/* 2x2 binning is used */ +bool binning; };static const struct imx219_reg imx219_common_regs[] = {
@@ -212,8 +221,6 @@ static const struct imx219_reg mode_3280x2464_regs[] = { {0x016d, 0xd0}, {0x016e, 0x09}, {0x016f, 0xa0}, - {0x0174, 0x00}, /* No-Binning */ - {0x0175, 0x00}, {0x0624, 0x0c}, {0x0625, 0xd0}, {0x0626, 0x09},
@@ -233,8 +240,6 @@ static const struct imx219_reg mode_1920_1080_regs[] = { {0x016d, 0x80}, {0x016e, 0x04}, {0x016f, 0x38}, - {0x0174, 0x00}, /* No-Binning */ - {0x0175, 0x00}, {0x0624, 0x07}, {0x0625, 0x80}, {0x0626, 0x04},
@@ -254,8 +259,6 @@ static const struct imx219_reg mode_1640_1232_regs[] = { {0x016d, 0x68}, {0x016e, 0x04}, {0x016f, 0xd0}, - {0x0174, 0x01}, /* x2-Binning */ - {0x0175, 0x01}, {0x0624, 0x06}, {0x0625, 0x68}, {0x0626, 0x04},
@@ -275,8 +278,6 @@ static const struct imx219_reg mode_640_480_regs[] = { {0x016d, 0x80}, {0x016e, 0x01}, {0x016f, 0xe0}, - {0x0174, 0x03}, /* x2-analog binning */ - {0x0175, 0x03}, {0x0624, 0x06}, {0x0625, 0x68}, {0x0626, 0x04},
@@ -390,6 +391,7 @@ static const struct imx219_mode supported_modes[] = { .num_of_regs = ARRAY_SIZE(mode_3280x2464_regs), .regs = mode_3280x2464_regs, }, + .binning = false, }, {/* 1080P 30fps cropped */
@@ -406,6 +408,7 @@ static const struct imx219_mode supported_modes[] = { .num_of_regs = ARRAY_SIZE(mode_1920_1080_regs), .regs = mode_1920_1080_regs, }, + .binning = false, }, {/* 2x2 binned 30fps mode */
@@ -422,6 +425,7 @@ static const struct imx219_mode supported_modes[] = { .num_of_regs = ARRAY_SIZE(mode_1640_1232_regs), .regs = mode_1640_1232_regs, }, + .binning = true, }, {/* 640x480 30fps mode */
@@ -438,6 +442,7 @@ static const struct imx219_mode supported_modes[] = { .num_of_regs = ARRAY_SIZE(mode_640_480_regs), .regs = mode_640_480_regs, }, + .binning = true, }, };
@@ -884,6 +889,35 @@ static int imx219_set_framefmt(struct imx219 *imx219)return -EINVAL ; } +static int imx219_set_binning (struct imx219 *imx219) +{ +if (!imx219->mode->binning) { +return imx219_write_reg (imx219,IMX219_REG_BINNING_MODE , +IMX219_REG_VALUE_16BIT , +IMX219_BINNING_NONE ); + } + +switch (imx219->fmt.code) { +case MEDIA_BUS_FMT_SRGGB8_1X8 : +case MEDIA_BUS_FMT_SGRBG8_1X8 : +case MEDIA_BUS_FMT_SGBRG8_1X8 : +case MEDIA_BUS_FMT_SBGGR8_1X8 : +return imx219_write_reg (imx219,IMX219_REG_BINNING_MODE , +IMX219_REG_VALUE_16BIT , +IMX219_BINNING_2X2_ANALOG ); + +case MEDIA_BUS_FMT_SRGGB10_1X10 : +case MEDIA_BUS_FMT_SGRBG10_1X10 : +case MEDIA_BUS_FMT_SGBRG10_1X10 : +case MEDIA_BUS_FMT_SBGGR10_1X10 : +return imx219_write_reg (imx219,IMX219_REG_BINNING_MODE , +IMX219_REG_VALUE_16BIT , +IMX219_BINNING_2X2 ); + } + +return -EINVAL ; +} +static const struct v4l2_rect * __imx219_get_pad_crop(struct imx219 *imx219, struct v4l2_subdev_state *sd_state,
@@ -968,6 +1002,13 @@ static int imx219_start_streaming(struct imx219 *imx219) goto err_rpm_put; } + ret =imx219_set_binning (imx219); +if (ret) { +dev_err (&client->dev,"%s failed to set binning: %d\n" , + __func__, ret); + goto err_rpm_put; + } +/* Apply customized values from user */ ret =__v4l2_ctrl_handler_setup (imx219->sd.ctrl_handler);if (ret)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 510/885 media: platform: mtk-mdp3: Fix return value check in mdp_probe()
In reply to Greg Kroah-HartmanFrom: Qiheng Lin <[email protected]>
[ Upstream commit 1963689bed4d500236938d90c91cdd5e63c1eb28 ]
In case of error, the function mtk_mutex_get() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR(). And also fix the err_free_mutex case.
--- drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c +4 -3
@@ -207,8 +207,8 @@ static int mdp_probe(struct platform_device *pdev) }for (i =0 ; i <MDP_PIPE_MAX ; i++) { mdp->mdp_mutex[i] =mtk_mutex_get (&mm_pdev->dev); -if (!mdp->mdp_mutex[i]) { - ret = -ENODEV ; +if (IS_ERR (mdp->mdp_mutex[i])) { + ret =PTR_ERR (mdp->mdp_mutex[i]); goto err_free_mutex; } }
@@ -289,7 +289,8 @@ static int mdp_probe(struct platform_device *pdev)mdp_comp_destroy (mdp); err_free_mutex:for (i =0 ; i <MDP_PIPE_MAX ; i++) -mtk_mutex_put (mdp->mdp_mutex[i]); +if (!IS_ERR_OR_NULL (mdp->mdp_mutex[i])) +mtk_mutex_put (mdp->mdp_mutex[i]); err_destroy_device:kfree (mdp); err_return:
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 511/885 media: camss: csiphy-3ph: avoid undefined behavior
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 05fb9ace34b8645cb76f7e3a21b5c7b754329cae ]
Marking a case of the switch statement as unreachable means the compiler treats it as undefined behavior, which is then caught by an objtool warning:
drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.o: warning: objtool: csiphy_lanes_enable() falls through to next function csiphy_lanes_disable()
Instead of simply continuing execution at a random place of the driver, print a warning and return from to the caller, which makes it possible to understand what happens and avoids the warning.
--- drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c +2 -1
@@ -429,7 +429,8 @@ static void csiphy_gen2_config_lanes(struct csiphy_device *csiphy, array_size =ARRAY_SIZE (lane_regs_sm8250[0 ]);break ;default : -unreachable (); +WARN (1 ,"unknown cspi version\n" ); +return ; }for (l =0 ; l <5 ; l++) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 512/885 media: platform: mtk-mdp3: remove unused VIDEO_MEDIATEK_VPU config
In reply to Greg Kroah-HartmanFrom: Moudy Ho <[email protected]>
[ Upstream commit 9195a860ef0a384d2ca2065cc61a0cc80d620de5 ]
Since REMOTEPROC completely replaces the VIDEO_MEDIATEK_VPU in MDP3, unused config should be removed to avoid compilation warnings reported on i386 or x86_64.
Warning messages:
WARNING: unmet direct dependencies detected for VIDEO_MEDIATEK_VPU
Depends on [n]: MEDIA_SUPPORT [=y] && MEDIA_PLATFORM_SUPPORT [=y]
&& MEDIA_PLATFORM_DRIVERS [=y] && V4L_MEM2MEM_DRIVERS [=n] &&
VIDEO_DEV [=y] && (ARCH_MEDIATEK || COMPILE_TEST [=y])
Selected by [y]:
- VIDEO_MEDIATEK_MDP3 [=y] && MEDIA_SUPPORT [=y] &&
MEDIA_PLATFORM_SUPPORT [=y] && MEDIA_PLATFORM_DRIVERS [=y] &&
(MTK_IOMMU [=n] || COMPILE_TEST [=y]) && VIDEO_DEV [=y] &&
(ARCH_MEDIATEK || COMPILE_TEST [=y]) && HAS_DMA [=y] && REMOTEPROC
[=y]Stable-dep-of: e3f7feb6d893 ("media: platform: mtk-mdp3: fix Kconfig dependencies")
--- drivers/media/platform/mediatek/mdp3/Kconfig | 1 - 1 file changed, 1 deletion(-)
drivers/media/platform/mediatek/mdp3/Kconfig +0 -1
@@ -9,7 +9,6 @@ config VIDEO_MEDIATEK_MDP3 select VIDEOBUF2_DMA_CONTIG select V4L2_MEM2MEM_DEV select MTK_MMSYS - select VIDEO_MEDIATEK_VPU select MTK_CMDQ select MTK_SCP default n
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 513/885 media: platform: mtk-mdp3: fix Kconfig dependencies
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit e3f7feb6d89311f369dd4ad903ea62e45328cdbe ]
The new mdp3 driver uses 'select' to force-enable a couple of drivers it depends on. This is error-prone and likely to cause dependency loops as well as warnings like:
WARNING: unmet direct dependencies detected for VIDEO_MEDIATEK_VPU
Depends on [n]: MEDIA_SUPPORT [=m] && MEDIA_PLATFORM_SUPPORT [=y] && MEDIA_PLATFORM_DRIVERS [=y] && V4L_MEM2MEM_DRIVERS [=n] && VIDEO_DEV [=m] && (ARCH_MEDIATEK [=y] || COMPILE_TEST [=y])
Selected by [m]:
- VIDEO_MEDIATEK_MDP3 [=m] && MEDIA_SUPPORT [=m] && MEDIA_PLATFORM_SUPPORT [=y] && MEDIA_PLATFORM_DRIVERS [=y] && (MTK_IOMMU [=m] || COMPILE_TEST [=y]) && VIDEO_DEV [=m] && (ARCH_MEDIATEK [=y] || COMPILE_TEST [=y]) && HAS_DMA [=y] && REMOTEPROC [=y]
This specific warning was already addressed in a previous patch, but there are similar unnecessary 'select' statements, so turn those into 'depends on'. This also means the dependency on ARCH_MEDIATEK is redundant and can be dropped.
--- drivers/media/platform/mediatek/mdp3/Kconfig | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/media/platform/mediatek/mdp3/Kconfig +3 -4
@@ -3,14 +3,13 @@ config VIDEO_MEDIATEK_MDP3 tristate "MediaTek MDP v3 driver" depends on MTK_IOMMU || COMPILE_TEST depends on VIDEO_DEV - depends on ARCH_MEDIATEK || COMPILE_TEST depends on HAS_DMA depends on REMOTEPROC + depends on MTK_MMSYS + depends on MTK_CMDQ + depends on MTK_SCP select VIDEOBUF2_DMA_CONTIG select V4L2_MEM2MEM_DEV - select MTK_MMSYS - select MTK_CMDQ - select MTK_SCP default n help It is a v4l2 driver and present in MediaTek MT8183 SoC.
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 514/885 media: v4l2-jpeg: correct the skip count in jpeg_parse_app14_data
In reply to Greg Kroah-HartmanFrom: Ming Qian <[email protected]>
[ Upstream commit 41959c4f973b837a12061b84d3a436fc64c73a30 ]
The curr pointer has advanced 14 bytes in jpeg_parse_app14_data.
1. jpeg_get_word_be(stream), it goes forward 2 bytes.
2. jpeg_skip(stream, 11), it goes forward 11 bytes.
3. jpeg_get_byte(stream), it goes forward 1 bytes.
so the remain bytes of this segment should be (lp - 2 - 11 - 1), but not (lp - 2 - 11).
if driver skip 1 extra bytes, the following parsing may go wrong.
--- drivers/media/v4l2-core/v4l2-jpeg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/v4l2-core/v4l2-jpeg.c +1 -1
@@ -474,7 +474,7 @@ static int jpeg_parse_app14_data(struct jpeg_stream *stream, *tf = ret;/* skip the rest of the segment, this ensures at least it is complete */ - skip = lp -2 -11 ; + skip = lp -2 -11 -1 ;return jpeg_skip (stream, skip); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 515/885 media: v4l2-jpeg: ignore the unknown APP14 marker
In reply to Greg Kroah-HartmanFrom: Ming Qian <[email protected]>
[ Upstream commit 251c0ea6efd3c3ea0f8a55fdd96c749a98639bd3 ]
The legal identifier of APP14 is "Adobe\0",
but sometimes it may be
"This is an unknown APP marker . Compliant decoders must ignore it." In this case, just ignore it.
It won't affect the decode result.
--- drivers/media/v4l2-core/v4l2-jpeg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/v4l2-core/v4l2-jpeg.c +1 -1
@@ -460,7 +460,7 @@ static int jpeg_parse_app14_data(struct jpeg_stream *stream,/* Check for "Adobe\0" in Ap1..6 */ if (stream->curr +6 > stream->end ||strncmp (stream->curr,"Adobe\0" ,6 )) -return -EINVAL ; +return jpeg_skip (stream, lp -2 );/* get to Ap12 */ ret =jpeg_skip (stream,11 );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 516/885 media: hantro: Fix JPEG encoder ENUM_FRMSIZE on RK3399
In reply to Greg Kroah-HartmanFrom: Nicolas Dufresne <[email protected]>
[ Upstream commit 29bd426764dee14a09e37700406f4a5920825fcc ]
Since 79c987de8b354, enumerating framesize on format set with "MODE_NONE" (any raw formats) is reporting an invalid frmsize.
Size: Stepwise 0x0 - 0x0 with step 0/0
Before this change, the driver would return EINVAL, which is also invalid but worked in GStreamer. The original intent was not to implement it, hence the -ENOTTY return in this change. While drivers should implement ENUM_FRMSIZE for all formats and queues, this change is limited in scope to fix the regression.
This fixes taking picture in Gnome Cheese software, or any software using GSteamer to encode JPEG with hardware acceleration.
--- drivers/media/platform/verisilicon/hantro_v4l2.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/media/platform/verisilicon/hantro_v4l2.c +5 -2
@@ -161,8 +161,11 @@ static int vidioc_enum_framesizes(struct file *file, void *priv, }/* For non-coded formats check if postprocessing scaling is possible */ -if (fmt->codec_mode ==HANTRO_MODE_NONE &&hantro_needs_postproc (ctx, fmt)) { -return hanto_postproc_enum_framesizes (ctx, fsize); +if (fmt->codec_mode ==HANTRO_MODE_NONE ) { +if (hantro_needs_postproc (ctx, fmt)) +return hanto_postproc_enum_framesizes (ctx, fsize); +else +return -ENOTTY ; }else if (fsize->index !=0 ) {vpu_debug (0 ,"invalid frame size index (expected 0, got %d)\n" , fsize->index);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 517/885 media: imx-jpeg: Apply clk_bulk api instead of operating specific clk
In reply to Greg Kroah-HartmanFrom: Ming Qian <[email protected]>
[ Upstream commit 61fe43dc9f454bc3caa99dbdd8f5fa3ba813981a ]
using the api of clk_bulk can simplify the code. and the clock of the jpeg codec may be changed, the clk_bulk api can be compatible with the future change.
--- .../media/platform/nxp/imx-jpeg/mxc-jpeg.c | 35 +++++-------------- .../media/platform/nxp/imx-jpeg/mxc-jpeg.h | 4 +-- 2 files changed, 10 insertions(+), 29 deletions(-)
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c +8 -27
@@ -2202,19 +2202,12 @@ static int mxc_jpeg_probe(struct platform_device *pdev) jpeg->mode = mode;/* Get clocks */ - jpeg->clk_ipg =devm_clk_get (dev,"ipg" ); -if (IS_ERR (jpeg->clk_ipg)) { -dev_err (dev,"failed to get clock: ipg\n" ); - ret =PTR_ERR (jpeg->clk_ipg); - goto err_clk; - } - - jpeg->clk_per =devm_clk_get (dev,"per" ); -if (IS_ERR (jpeg->clk_per)) { -dev_err (dev,"failed to get clock: per\n" ); - ret =PTR_ERR (jpeg->clk_per); + ret =devm_clk_bulk_get_all (&pdev->dev, &jpeg->clks); +if (ret <0 ) { +dev_err (dev,"failed to get clock\n" ); goto err_clk; } + jpeg->num_clks = ret; ret =mxc_jpeg_attach_pm_domains (jpeg);if (ret <0 ) {
@@ -2311,32 +2304,20 @@ static int mxc_jpeg_runtime_resume(struct device *dev)struct mxc_jpeg_dev *jpeg =dev_get_drvdata (dev);int ret; - ret =clk_prepare_enable (jpeg->clk_ipg); -if (ret <0 ) { -dev_err (dev,"failed to enable clock: ipg\n" ); - goto err_ipg; - } - - ret =clk_prepare_enable (jpeg->clk_per); + ret =clk_bulk_prepare_enable (jpeg->num_clks, jpeg->clks);if (ret <0 ) { -dev_err (dev,"failed to enable clock: per\n" ); - goto err_per; +dev_err (dev,"failed to enable clock\n" ); +return ret; }return 0 ; - -err_per: -clk_disable_unprepare (jpeg->clk_ipg); -err_ipg: -return ret; }static int mxc_jpeg_runtime_suspend (struct device *dev) {struct mxc_jpeg_dev *jpeg =dev_get_drvdata (dev); -clk_disable_unprepare (jpeg->clk_ipg); -clk_disable_unprepare (jpeg->clk_per); +clk_bulk_disable_unprepare (jpeg->num_clks, jpeg->clks);return 0 ; }
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.h +2 -2
@@ -114,8 +114,8 @@ struct mxc_jpeg_dev {spinlock_t hw_lock;/* hardware access lock */ unsigned int mode;struct mutex lock;/* v4l2 ioctls serialization */ -struct clk *clk_ipg; -struct clk *clk_per; +struct clk_bulk_data *clks; +int num_clks;struct platform_device *pdev;struct device *dev;void __iomem *base_reg;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 518/885 media: amphion: correct the unspecified color space
In reply to Greg Kroah-HartmanFrom: Ming Qian <[email protected]>
[ Upstream commit 809060c8a357e020010dd8f797a5efd3c5432b13 ]
in the E.2.1 of Rec. ITU-T H.264 (06/2019),
0 of colour primaries is reserved, and 2 is unspecified. driver can map V4L2_COLORSPACE_LAST to 0,
and map V4L2_COLORSPACE_DEFAULT to 2.
v4l2_xfer_func and v4l2_ycbcr_encoding are similar case.
--- drivers/media/platform/amphion/vpu_color.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/platform/amphion/vpu_color.c +3 -3
@@ -17,7 +17,7 @@#include "vpu_helpers.h" static const u8 colorprimaries[] = { -0 , +V4L2_COLORSPACE_LAST ,V4L2_COLORSPACE_REC709 ,/*Rec. ITU-R BT.709-6*/ 0 ,0 ,
@@ -31,7 +31,7 @@ static const u8 colorprimaries[] = { };static const u8 colortransfers[] = { -0 , +V4L2_XFER_FUNC_LAST ,V4L2_XFER_FUNC_709 ,/*Rec. ITU-R BT.709-6*/ 0 ,0 ,
@@ -53,7 +53,7 @@ static const u8 colortransfers[] = { };static const u8 colormatrixcoefs[] = { -0 , +V4L2_YCBCR_ENC_LAST ,V4L2_YCBCR_ENC_709 ,/*Rec. ITU-R BT.709-6*/ 0 ,0 ,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 519/885 media: drivers/media/v4l2-core/v4l2-h264 : add detection of null pointers
In reply to Greg Kroah-HartmanFrom: Dong Chuanjian <[email protected]>
[ Upstream commit be3ae7cf4326e95bb1d5413b63baabc26f4a1324 ]
When the pointer variable is judged to be null, null is returned directly.
[hverkuil: fix two checkpatch warnings]
--- drivers/media/v4l2-core/v4l2-h264.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/media/v4l2-core/v4l2-h264.c +4 -0
@@ -305,6 +305,8 @@ static const char *format_ref_list_p(const struct v4l2_h264_reflist_builder *buiint n =0 , i; *out_str =kmalloc (tmp_str_size,GFP_KERNEL ); +if (!(*out_str)) +return NULL ; n +=snprintf (*out_str + n, tmp_str_size - n,"|" );
@@ -343,6 +345,8 @@ static const char *format_ref_list_b(const struct v4l2_h264_reflist_builder *buiint n =0 , i; *out_str =kmalloc (tmp_str_size,GFP_KERNEL ); +if (!(*out_str)) +return NULL ; n +=snprintf (*out_str + n, tmp_str_size - n,"|" );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 520/885 media: rc: Fix use-after-free bugs caused by ene_tx_irqsim()
In reply to Greg Kroah-HartmanFrom: Duoming Zhou <[email protected]>
[ Upstream commit 29b0589a865b6f66d141d79b2dd1373e4e50fe17 ]
When the ene device is detaching, function ene_remove() will be called. But there is no function to cancel tx_sim_timer in ene_remove(), the timer handler ene_tx_irqsim() could race with ene_remove(). As a result, the UAF bugs could happen, the process is shown below.
(cleanup routine) | (timer routine)
| mod_timer(&dev->tx_sim_timer, ..)
ene_remove() | (wait a time)
| ene_tx_irqsim()
| dev->hw_lock //USE
| ene_tx_sample(dev) //USEFix by adding del_timer_sync(&dev->tx_sim_timer) in ene_remove(), The tx_sim_timer could stop before ene device is deallocated.
What's more, The rc_unregister_device() and del_timer_sync() should be called first in ene_remove() and the deallocated functions such as free_irq(), release_region() and so on should be called behind them. Because the rc_unregister_device() is well synchronized. Otherwise, race conditions may happen. The situations that may lead to race conditions are shown below.
Firstly, the rx receiver is disabled with ene_rx_disable() before rc_unregister_device() in ene_remove(), which means it can be enabled again if a process opens /dev/lirc0 between ene_rx_disable() and rc_unregister_device().
Secondly, the irqaction descriptor is freed by free_irq() before the rc device is unregistered, which means irqaction descriptor may be accessed again after it is deallocated.
Thirdly, the timer can call ene_tx_sample() that can write to the io ports, which means the io ports could be accessed again after they are deallocated by release_region().
Therefore, the rc_unregister_device() and del_timer_sync() should be called first in ene_remove().
Suggested by: Sean Young <[email protected]>
--- drivers/media/rc/ene_ir.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/rc/ene_ir.c +2 -1
@@ -1106,6 +1106,8 @@ static void ene_remove(struct pnp_dev *pnp_dev)struct ene_device *dev =pnp_get_drvdata (pnp_dev);unsigned long flags; +rc_unregister_device (dev->rdev); +del_timer_sync (&dev->tx_sim_timer);spin_lock_irqsave (&dev->hw_lock, flags);ene_rx_disable (dev);ene_rx_restore_hw_buffer (dev);
@@ -1113,7 +1115,6 @@ static void ene_remove(struct pnp_dev *pnp_dev)free_irq (dev->irq, dev);release_region (dev->hw_io,ENE_IO_SIZE ); -rc_unregister_device (dev->rdev);kfree (dev); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 521/885 media: atomisp: Only set default_run_mode on first open of a stream/asd
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit 60ec70a71a9f9975a5d2dd4a7d97c20da0e41976 ]
Calling v4l2_ctrl_s_ctrl(asd->run_mode, pipe->default_run_mode) when the stream is already active (through another /dev/video# node) causes the stream to stop.
Move the call to set the default run-mode so that it is only done on the first open of one of the 4 /dev/video# nodes of one of the 2 streams (atomisp-sub-devices / asd-s).
--- drivers/staging/media/atomisp/pci/atomisp_fops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_fops.c +2 -2
@@ -741,13 +741,13 @@ static int atomisp_open(struct file *file) goto done;atomisp_subdev_init_struct (asd); +/* Ensure that a mode is set */ +v4l2_ctrl_s_ctrl (asd->run_mode, pipe->default_run_mode); done: pipe->users++;mutex_unlock (&isp->mutex); -/* Ensure that a mode is set */ -v4l2_ctrl_s_ctrl (asd->run_mode, pipe->default_run_mode);return 0 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 522/885 media: i2c: ov7670: 0 instead of -EINVAL was returned
In reply to Greg Kroah-HartmanFrom: Hans Verkuil <[email protected]>
[ Upstream commit 6a4c664539e6de9b32b65ddcf767ec1bcc1d7f8a ]
If the media bus is unsupported, then return -EINVAL. Instead it returned 'ret' which happened to be 0.
This fixes a smatch warning:
ov7670.c:1843 ov7670_parse_dt() warn: missing error code? 'ret'
--- drivers/media/i2c/ov7670.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/ov7670.c +1 -1
@@ -1841,7 +1841,7 @@ static int ov7670_parse_dt(struct device *dev,if (bus_cfg.bus_type !=V4L2_MBUS_PARALLEL ) {dev_err (dev,"Unsupported media bus type\n" ); -return ret; +return -EINVAL ; } info->mbus_config = bus_cfg.bus.parallel.flags;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 523/885 media: usb: siano: Fix use after free bugs caused by do_submit_urb
In reply to Greg Kroah-HartmanFrom: Duoming Zhou <[email protected]>
[ Upstream commit ebad8e731c1c06adf04621d6fd327b860c0861b5 ]
There are UAF bugs caused by do_submit_urb(). One of the KASan reports is shown below:
[ 36.403605] BUG: KASAN: use-after-free in worker_thread+0x4a2/0x890 [ 36.406105] Read of size 8 at addr ffff8880059600e8 by task kworker/0:2/49 [ 36.408316] [ 36.408867] CPU: 0 PID: 49 Comm: kworker/0:2 Not tainted 6.2.0-rc3-15798-g5a41237ad1d4-dir8 [ 36.411696] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g15584 [ 36.416157] Workqueue: 0x0 (events) [ 36.417654] Call Trace: [ 36.418546] <TASK> [ 36.419320] dump_stack_lvl+0x96/0xd0 [ 36.420522] print_address_description+0x75/0x350 [ 36.421992] print_report+0x11b/0x250 [ 36.423174] ? _raw_spin_lock_irqsave+0x87/0xd0 [ 36.424806] ? __virt_addr_valid+0xcf/0x170 [ 36.426069] ? worker_thread+0x4a2/0x890 [ 36.427355] kasan_report+0x131/0x160 [ 36.428556] ? worker_thread+0x4a2/0x890 [ 36.430053] worker_thread+0x4a2/0x890 [ 36.431297] ? worker_clr_flags+0x90/0x90 [ 36.432479] kthread+0x166/0x190 [ 36.433493] ? kthread_blkcg+0x50/0x50 [ 36.434669] ret_from_fork+0x22/0x30 [ 36.435923] </TASK> [ 36.436684] [ 36.437215] Allocated by task 24: [ 36.438289] kasan_set_track+0x50/0x80 [ 36.439436] __kasan_kmalloc+0x89/0xa0 [ 36.440566] smsusb_probe+0x374/0xc90 [ 36.441920] usb_probe_interface+0x2d1/0x4c0 [ 36.443253] really_probe+0x1d5/0x580 [ 36.444539] __driver_probe_device+0xe3/0x130 [ 36.446085] driver_probe_device+0x49/0x220 [ 36.447423] __device_attach_driver+0x19e/0x1b0 [ 36.448931] bus_for_each_drv+0xcb/0x110 [ 36.450217] __device_attach+0x132/0x1f0 [ 36.451470] bus_probe_device+0x59/0xf0 [ 36.452563] device_add+0x4ec/0x7b0 [ 36.453830] usb_set_configuration+0xc63/0xe10 [ 36.455230] usb_generic_driver_probe+0x3b/0x80 [ 36.456166] printk: console [ttyGS0] disabled [ 36.456569] usb_probe_device+0x90/0x110 [ 36.459523] really_probe+0x1d5/0x580 [ 36.461027] __driver_probe_device+0xe3/0x130 [ 36.462465] driver_probe_device+0x49/0x220 [ 36.463847] __device_attach_driver+0x19e/0x1b0 [ 36.465229] bus_for_each_drv+0xcb/0x110 [ 36.466466] __device_attach+0x132/0x1f0 [ 36.467799] bus_probe_device+0x59/0xf0 [ 36.469010] device_add+0x4ec/0x7b0 [ 36.470125] usb_new_device+0x863/0xa00 [ 36.471374] hub_event+0x18c7/0x2220 [ 36.472746] process_one_work+0x34c/0x5b0 [ 36.474041] worker_thread+0x4b7/0x890 [ 36.475216] kthread+0x166/0x190 [ 36.476267] ret_from_fork+0x22/0x30 [ 36.477447] [ 36.478160] Freed by task 24: [ 36.479239] kasan_set_track+0x50/0x80 [ 36.480512] kasan_save_free_info+0x2b/0x40 [ 36.481808] ____kasan_slab_free+0x122/0x1a0 [ 36.483173] __kmem_cache_free+0xc4/0x200 [ 36.484563] smsusb_term_device+0xcd/0xf0 [ 36.485896] smsusb_probe+0xc85/0xc90 [ 36.486976] usb_probe_interface+0x2d1/0x4c0 [ 36.488303] really_probe+0x1d5/0x580 [ 36.489498] __driver_probe_device+0xe3/0x130 [ 36.491140] driver_probe_device+0x49/0x220 [ 36.492475] __device_attach_driver+0x19e/0x1b0 [ 36.493988] bus_for_each_drv+0xcb/0x110 [ 36.495171] __device_attach+0x132/0x1f0 [ 36.496617] bus_probe_device+0x59/0xf0 [ 36.497875] device_add+0x4ec/0x7b0 [ 36.498972] usb_set_configuration+0xc63/0xe10 [ 36.500264] usb_generic_driver_probe+0x3b/0x80 [ 36.501740] usb_probe_device+0x90/0x110 [ 36.503084] really_probe+0x1d5/0x580 [ 36.504241] __driver_probe_device+0xe3/0x130 [ 36.505548] driver_probe_device+0x49/0x220 [ 36.506766] __device_attach_driver+0x19e/0x1b0 [ 36.508368] bus_for_each_drv+0xcb/0x110 [ 36.509646] __device_attach+0x132/0x1f0 [ 36.510911] bus_probe_device+0x59/0xf0 [ 36.512103] device_add+0x4ec/0x7b0 [ 36.513215] usb_new_device+0x863/0xa00 [ 36.514736] hub_event+0x18c7/0x2220 [ 36.516130] process_one_work+0x34c/0x5b0 [ 36.517396] worker_thread+0x4b7/0x890 [ 36.518591] kthread+0x166/0x190 [ 36.519599] ret_from_fork+0x22/0x30 [ 36.520851] [ 36.521405] Last potentially related work creation: [ 36.523143] kasan_save_stack+0x3f/0x60 [ 36.524275] kasan_record_aux_stack_noalloc+0x9d/0xb0 [ 36.525831] insert_work+0x25/0x130 [ 36.527039] __queue_work+0x4d4/0x620 [ 36.528236] queue_work_on+0x72/0xb0 [ 36.529344] __usb_hcd_giveback_urb+0x13f/0x1b0 [ 36.530819] dummy_timer+0x350/0x1a40 [ 36.532149] call_timer_fn+0x2c/0x190 [ 36.533567] expire_timers+0x69/0x1f0 [ 36.534736] __run_timers+0x289/0x2d0 [ 36.535841] run_timer_softirq+0x2d/0x60 [ 36.537110] __do_softirq+0x116/0x380 [ 36.538377] [ 36.538950] Second to last potentially related work creation: [ 36.540855] kasan_save_stack+0x3f/0x60 [ 36.542084] kasan_record_aux_stack_noalloc+0x9d/0xb0 [ 36.543592] insert_work+0x25/0x130 [ 36.544891] __queue_work+0x4d4/0x620 [ 36.546168] queue_work_on+0x72/0xb0 [ 36.547328] __usb_hcd_giveback_urb+0x13f/0x1b0 [ 36.548805] dummy_timer+0x350/0x1a40 [ 36.550116] call_timer_fn+0x2c/0x190 [ 36.551570] expire_timers+0x69/0x1f0 [ 36.552762] __run_timers+0x289/0x2d0 [ 36.553916] run_timer_softirq+0x2d/0x60 [ 36.555118] __do_softirq+0x116/0x380 [ 36.556239] [ 36.556807] The buggy address belongs to the object at ffff888005960000 [ 36.556807] which belongs to the cache kmalloc-4k of size 4096 [ 36.560652] The buggy address is located 232 bytes inside of [ 36.560652] 4096-byte region [ffff888005960000, ffff888005961000) [ 36.564791] [ 36.565355] The buggy address belongs to the physical page: [ 36.567212] page:000000004f0a0731 refcount:1 mapcount:0 mapping:0000000000000000 index:0x00 [ 36.570534] head:000000004f0a0731 order:3 compound_mapcount:0 subpages_mapcount:0 compound0 [ 36.573717] flags: 0x100000000010200(slab|head|node=0|zone=1) [ 36.575481] raw: 0100000000010200 ffff888001042140 dead000000000122 0000000000000000 [ 36.577842] raw: 0000000000000000 0000000000040004 00000001ffffffff 0000000000000000 [ 36.580175] page dumped because: kasan: bad access detected [ 36.581994] [ 36.582548] Memory state around the buggy address: [ 36.583983] ffff88800595ff80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc [ 36.586240] ffff888005960000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb [ 36.588884] >ffff888005960080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb [ 36.591071] ^ [ 36.593295] ffff888005960100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb [ 36.595705] ffff888005960180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb [ 36.598026] ================================================================== [ 36.600224] Disabling lock debugging due to kernel taint [ 36.602681] general protection fault, probably for non-canonical address 0x43600a000000060I [ 36.607129] CPU: 0 PID: 49 Comm: kworker/0:2 Tainted: G B 6.2.0-rc3-15798-8 [ 36.611115] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g15584 [ 36.615026] Workqueue: events do_submit_urb [ 36.616290] RIP: 0010:_raw_spin_lock_irqsave+0x8a/0xd0 [ 36.618107] Code: 24 00 00 00 00 48 89 df be 04 00 00 00 e8 9e b5 c6 fe 48 89 ef be 04 00 5 [ 36.623522] RSP: 0018:ffff888004b6fcf0 EFLAGS: 00010046 [ 36.625072] RAX: 0000000000000000 RBX: 043600a000000060 RCX: ffffffff9fc0e0d7 [ 36.627206] RDX: 0000000000000000 RSI: dffffc0000000000 RDI: ffff888004b6fcf0 [ 36.629813] RBP: ffff888004b6fcf0 R08: dffffc0000000000 R09: ffffed100096df9f [ 36.631974] R10: dfffe9100096dfa0 R11: 1ffff1100096df9e R12: ffff888005960020 [ 36.634285] R13: ffff8880059600f0 R14: 0000000000000246 R15: 0000000000000001 [ 36.636438] FS: 0000000000000000(0000) GS:ffff88806d600000(0000) knlGS:0000000000000000 [ 36.639092] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 36.640951] CR2: 00007f07476819a3 CR3: 0000000004a34000 CR4: 00000000000006f0 [ 36.643411] Call Trace: [ 36.644215] <TASK> [ 36.644902] smscore_getbuffer+0x3e/0x1e0 [ 36.646147] do_submit_urb+0x4f/0x190 [ 36.647449] process_one_work+0x34c/0x5b0 [ 36.648777] worker_thread+0x4b7/0x890 [ 36.649984] ? worker_clr_flags+0x90/0x90 [ 36.651166] kthread+0x166/0x190 [ 36.652151] ? kthread_blkcg+0x50/0x50 [ 36.653547] ret_from_fork+0x22/0x30 [ 36.655051] </TASK> [ 36.655733] Modules linked in: [ 36.656787] ---[ end trace 0000000000000000 ]--- [ 36.658328] RIP: 0010:_raw_spin_lock_irqsave+0x8a/0xd0 [ 36.660045] Code: 24 00 00 00 00 48 89 df be 04 00 00 00 e8 9e b5 c6 fe 48 89 ef be 04 00 5 [ 36.665730] RSP: 0018:ffff888004b6fcf0 EFLAGS: 00010046 [ 36.667448] RAX: 0000000000000000 RBX: 043600a000000060 RCX: ffffffff9fc0e0d7 [ 36.669675] RDX: 0000000000000000 RSI: dffffc0000000000 RDI: ffff888004b6fcf0 [ 36.672645] RBP: ffff888004b6fcf0 R08: dffffc0000000000 R09: ffffed100096df9f [ 36.674921] R10: dfffe9100096dfa0 R11: 1ffff1100096df9e R12: ffff888005960020 [ 36.677034] R13: ffff8880059600f0 R14: 0000000000000246 R15: 0000000000000001 [ 36.679184] FS: 0000000000000000(0000) GS:ffff88806d600000(0000) knlGS:0000000000000000 [ 36.681655] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 36.683383] CR2: 00007f07476819a3 CR3: 0000000004a34000 CR4: 00000000000006f0 [ 36.685733] Kernel panic - not syncing: Fatal exception [ 36.688585] Kernel Offset: 0x1d400000 from 0xffffffff81000000 (relocation range: 0xfffffff) [ 36.692199] ---[ end Kernel panic - not syncing: Fatal exception ]---
When the siano device is plugged in, it may call the following functions to initialize the device.
smsusb_probe()-->smsusb_init_device()-->smscore_start_device().
When smscore_start_device() gets failed, the function smsusb_term_device() will be called and smsusb_device_t will be deallocated. Although we use usb_kill_urb() in smsusb_stop_streaming() to cancel transfer requests and wait for them to finish, the worker threads that are scheduled by smsusb_onresponse() may be still running. As a result, the UAF bugs could happen.
We add cancel_work_sync() in smsusb_stop_streaming() in order that the worker threads could finish before the smsusb_device_t is deallocated.
--- drivers/media/usb/siano/smsusb.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/usb/siano/smsusb.c +1 -0
@@ -179,6 +179,7 @@ static void smsusb_stop_streaming(struct smsusb_device_t *dev)for (i =0 ; i <MAX_URBS ; i++) {usb_kill_urb (&dev->surbs[i].urb); +cancel_work_sync (&dev->surbs[i].wq);if (dev->surbs[i].cb) {smscore_putbuffer (dev->coredev, dev->surbs[i].cb);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 524/885 media: saa7134: Use video_unregister_device for radio_dev
In reply to Greg Kroah-HartmanFrom: Tasos Sahanidis <[email protected]>
[ Upstream commit bc7635c6435c77a0c168e2cc6535740adfaff4e4 ]
The radio device doesn't use vb2, thus calling vb2_video_unregister_device() which results in the following warning being printed on module unload.
WARNING: CPU: 1 PID: 215963 at drivers/media/common/videobuf2/videobuf2-v4l2.c:1236 vb2_video_unregister_device+0xc6/0xe0 [videobuf2_v4l2]
--- drivers/media/pci/saa7134/saa7134-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/pci/saa7134/saa7134-core.c +1 -1
@@ -978,7 +978,7 @@ static void saa7134_unregister_video(struct saa7134_dev *dev) }if (dev->radio_dev) {if (video_is_registered (dev->radio_dev)) -vb2_video_unregister_device (dev->radio_dev); +video_unregister_device (dev->radio_dev);else video_device_release (dev->radio_dev); dev->radio_dev =NULL ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 525/885 rpmsg: glink: Avoid infinite loop on intent for missing channel
In reply to Greg Kroah-HartmanFrom: Bjorn Andersson <[email protected]>
[ Upstream commit 3e74ec2f39362bffbd42854acbb67c7f4cb808f9 ]
In the event that an intent advertisement arrives on an unknown channel the fifo is not advanced, resulting in the same message being handled over and over.
--- drivers/rpmsg/qcom_glink_native.c | 1 + 1 file changed, 1 insertion(+)
drivers/rpmsg/qcom_glink_native.c +1 -0
@@ -954,6 +954,7 @@ static void qcom_glink_handle_intent(struct qcom_glink *glink,spin_unlock_irqrestore (&glink->idr_lock, flags);if (!channel) {dev_err (glink->dev,"intents for non-existing channel\n" ); +qcom_glink_rx_advance (glink,ALIGN (msglen,8 ));return ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 526/885 rpmsg: glink: Release driver_override
In reply to Greg Kroah-HartmanFrom: Bjorn Andersson <[email protected]>
[ Upstream commit fb80ef67e8ff6a00d3faad4cb348dafdb8eccfd8 ]
Upon termination of the rpmsg_device, driver_override needs to be freed to avoid leaking the potentially assigned string.
--- drivers/rpmsg/qcom_glink_native.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/rpmsg/qcom_glink_native.c +2 -0
@@ -1447,6 +1447,7 @@ static void qcom_glink_rpdev_release(struct device *dev) {struct rpmsg_device *rpdev =to_rpmsg_device (dev); +kfree (rpdev->driver_override);kfree (rpdev); }
@@ -1690,6 +1691,7 @@ static void qcom_glink_device_release(struct device *dev)/* Release qcom_glink_alloc_channel() reference */ kref_put (&channel->refcount, qcom_glink_channel_release); +kfree (rpdev->driver_override);kfree (rpdev); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 527/885 ARM: OMAP2+: omap4-common: Fix refcount leak bug
In reply to Greg Kroah-HartmanFrom: Liang He <[email protected]>
[ Upstream commit 7c32919a378782c95c72bc028b5c30dfe8c11f82 ]
In omap4_sram_init(), of_find_compatible_node() will return a node pointer with refcount incremented. We should use of_node_put() when it is not used anymore.
Message-Id: <[email protected]>
--- arch/arm/mach-omap2/omap4-common.c | 1 + 1 file changed, 1 insertion(+)
arch/arm/mach-omap2/omap4-common.c +1 -0
@@ -140,6 +140,7 @@ static int __init omap4_sram_init(void) __func__); else sram_sync = (void __iomem *)gen_pool_alloc (sram_pool,PAGE_SIZE ); +of_node_put (np);return 0 ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 528/885 arm64: dts: qcom: msm8996: Add additional A2NoC clocks
In reply to Greg Kroah-HartmanFrom: Konrad Dybcio <[email protected]>
[ Upstream commit 67fb53745e0b38275fa0b422b6a3c6c1c028c9a2 ]
On eMMC devices, the UFS clocks aren't started in the bootloader (or well, at least it should not be, as that would just leak power..), which results in platform reboots when trying to access the unclocked UFS hardware, which unfortunately happens on each and every boot, as interconnect calls sync_state and goes over each and every path.
--- arch/arm64/boot/dts/qcom/msm8996.dtsi | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/qcom/msm8996.dtsi +4 -2
@@ -829,9 +829,11 @@ a2noc: interconnect@583000 { compatible = "qcom,msm8996-a2noc"; reg = <0x00583000 0x7000>; #interconnect-cells = <1>; - clock-names = "bus", "bus_a"; + clock-names = "bus", "bus_a", "aggre2_ufs_axi", "ufs_axi"; clocks = <&rpmcc RPM_SMD_AGGR2_NOC_CLK>, - <&rpmcc RPM_SMD_AGGR2_NOC_A_CLK>; + <&rpmcc RPM_SMD_AGGR2_NOC_A_CLK>, + <&gcc GCC_AGGRE2_UFS_AXI_CLK>, + <&gcc GCC_UFS_AXI_CLK>; }; mnoc: interconnect@5a4000 {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 529/885 udf: Define EFSCORRUPTED error code
In reply to Greg Kroah-HartmanFrom: Jan Kara <[email protected]>
[ Upstream commit 3d2d7e61553dbcc8ba45201d8ae4f383742c8202 ]
Similarly to other filesystems define EFSCORRUPTED error code for reporting internal filesystem corruption.
--- fs/udf/udf_sb.h | 2 ++ 1 file changed, 2 insertions(+)
fs/udf/udf_sb.h +2 -0
@@ -51,6 +51,8 @@#define MF_DUPLICATE_MD 0x01#define MF_MIRROR_FE_LOADED 0x02 +#define EFSCORRUPTED EUCLEAN +struct udf_meta_data {__u32 s_meta_file_loc;__u32 s_mirror_file_loc;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 530/885 context_tracking: Fix noinstr vs KASAN
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
[ Upstream commit 0e26e1de0032779e43929174339429c16307a299 ]
Low level noinstr context-tracking code is calling out to instrumented code on KASAN:
vmlinux.o: warning: objtool: __ct_user_enter+0x72: call to __kasan_check_write() leaves .noinstr.text section vmlinux.o: warning: objtool: __ct_user_exit+0x47: call to __kasan_check_write() leaves .noinstr.text section
Use even lower level atomic methods to avoid the instrumentation.
--- kernel/context_tracking.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
kernel/context_tracking.c +6 -6
@@ -510,7 +510,7 @@ void noinstr __ct_user_enter(enum ctx_state state)* In this we case we don't care about any concurrency/ordering. */ if (!IS_ENABLED (CONFIG_CONTEXT_TRACKING_IDLE )) -atomic_set (&ct->state, state); +arch_atomic_set (&ct->state, state); }else {/* * Even if context tracking is disabled on this CPU, because it's outside
@@ -527,7 +527,7 @@ void noinstr __ct_user_enter(enum ctx_state state)*/ if (!IS_ENABLED (CONFIG_CONTEXT_TRACKING_IDLE )) {/* Tracking for vtime only, no concurrent RCU EQS accounting */ -atomic_set (&ct->state, state); +arch_atomic_set (&ct->state, state); }else {/* * Tracking for vtime and RCU EQS. Make sure we don't race
@@ -535,7 +535,7 @@ void noinstr __ct_user_enter(enum ctx_state state)* RCU only requires RCU_DYNTICKS_IDX increments to be fully * ordered. */ -atomic_add (state, &ct->state); +arch_atomic_add (state, &ct->state); } } }
@@ -630,12 +630,12 @@ void noinstr __ct_user_exit(enum ctx_state state)* In this we case we don't care about any concurrency/ordering. */ if (!IS_ENABLED (CONFIG_CONTEXT_TRACKING_IDLE )) -atomic_set (&ct->state,CONTEXT_KERNEL ); +arch_atomic_set (&ct->state,CONTEXT_KERNEL ); }else {if (!IS_ENABLED (CONFIG_CONTEXT_TRACKING_IDLE )) {/* Tracking for vtime only, no concurrent RCU EQS accounting */ -atomic_set (&ct->state,CONTEXT_KERNEL ); +arch_atomic_set (&ct->state,CONTEXT_KERNEL ); }else {/* * Tracking for vtime and RCU EQS. Make sure we don't race
@@ -643,7 +643,7 @@ void noinstr __ct_user_exit(enum ctx_state state)* RCU only requires RCU_DYNTICKS_IDX increments to be fully * ordered. */ -atomic_sub (state, &ct->state); +arch_atomic_sub (state, &ct->state); } } }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 531/885 exit: Detect and fix irq disabled state in oops
In reply to Greg Kroah-HartmanFrom: Nicholas Piggin <[email protected]>
[ Upstream commit 001c28e57187570e4b5aa4492c7a957fb6d65d7b ]
If a task oopses with irqs disabled, this can cause various cascading problems in the oops path such as sleep-from-invalid warnings, and potentially worse.
Since commit 0258b5fd7c712 ("coredump: Limit coredumps to a single thread group"), the unconditional irq enable in coredump_task_exit() will "fix" the irq state to be enabled early in do_exit(), so currently this may not be triggerable, but that is coincidental and fragile.
Detect and fix the irqs_disabled() condition in the oops path before calling do_exit(), similarly to the way in_atomic() is handled.
--- kernel/exit.c | 7 +++++++ 1 file changed, 7 insertions(+)
kernel/exit.c +7 -0
@@ -807,6 +807,8 @@ void __noreturn do_exit(long code)struct task_struct *tsk = current;int group_dead; +WARN_ON (irqs_disabled ()); +synchronize_group_exit (tsk, code);WARN_ON (tsk->plug);
@@ -938,6 +940,11 @@ void __noreturn make_task_dead(int signr)if (unlikely (!tsk->pid))panic ("Attempted to kill the idle task!" ); +if (unlikely (irqs_disabled ())) { +pr_info ("note: %s[%d] exited with irqs disabled\n" , + current->comm,task_pid_nr (current)); +local_irq_enable (); + }if (unlikely (in_atomic ())) { pr_info("note: %s[%d] exited with preempt_count %d\n", current->comm, task_pid_nr(current),
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 532/885 ARM: dts: exynos: Use Exynos5420 compatible for the MIPI video phy
In reply to Greg Kroah-HartmanFrom: Markuss Broks <[email protected]>
[ Upstream commit 5d5aa219a790d61cad2c38e1aa32058f16ad2f0b ]
For some reason, the driver adding support for Exynos5420 MIPI phy back in 2016 wasn't used on Exynos5420, which caused a kernel panic. Add the proper compatible for it.
--- arch/arm/boot/dts/exynos5420.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/exynos5420.dtsi +1 -1
@@ -592,7 +592,7 @@ dp_phy: dp-video-phy { }; mipi_phy: mipi-video-phy { - compatible = "samsung,s5pv210-mipi-video-phy"; + compatible = "samsung,exynos5420-mipi-video-phy"; syscon = <&pmu_system_controller>; #phy-cells = <1>; };
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 533/885 fs: Use CHECK_DATA_CORRUPTION() when kernel bugs are detected
In reply to Greg Kroah-HartmanFrom: Jann Horn <[email protected]>
[ Upstream commit 47d586913f2abec4d240bae33417f537fda987ec ]
Currently, filp_close() and generic_shutdown_super() use printk() to log messages when bugs are detected. This is problematic because infrastructure like syzkaller has no idea that this message indicates a bug. In addition, some people explicitly want their kernels to BUG() when kernel data corruption has been detected (CONFIG_BUG_ON_DATA_CORRUPTION). And finally, when generic_shutdown_super() detects remaining inodes on a system without CONFIG_BUG_ON_DATA_CORRUPTION, it would be nice if later accesses to a busy inode would at least crash somewhat cleanly rather than walking through freed memory.
To address all three, use CHECK_DATA_CORRUPTION() when kernel bugs are detected.
--- fs/open.c | 5 +++-- fs/super.c | 21 +++++++++++++++++---- include/linux/poison.h | 3 +++ 3 files changed, 23 insertions(+), 6 deletions(-)
fs/open.c +3 -2
@@ -1411,8 +1411,9 @@ int filp_close(struct file *filp, fl_owner_t id) {int retval =0 ; -if (!file_count (filp)) { -printk (KERN_ERR "VFS: Close: file count is 0\n" ); +if (CHECK_DATA_CORRUPTION (file_count (filp) ==0 , +"VFS: Close: file count is 0 (f_op=%ps)" , + filp->f_op)) {return 0 ; }
fs/super.c +17 -4
@@ -491,10 +491,23 @@ void generic_shutdown_super(struct super_block *sb)if (sop->put_super) sop->put_super (sb); -if (!list_empty (&sb->s_inodes)) { -printk ("VFS: Busy inodes after unmount of %s. " -"Self-destruct in 5 seconds. Have a nice day...\n" , - sb->s_id); +if (CHECK_DATA_CORRUPTION (!list_empty (&sb->s_inodes), +"VFS: Busy inodes after unmount of %s (%s)" , + sb->s_id, sb->s_type->name)) { +/* +* Adding a proper bailout path here would be hard, but +* we can at least make it more likely that a later +* iput_final() or such crashes cleanly. +*/ +struct inode *inode; + +spin_lock (&sb->s_inode_list_lock); +list_for_each_entry (inode, &sb->s_inodes, i_sb_list) { + inode->i_op =VFS_PTR_POISON ; + inode->i_sb =VFS_PTR_POISON ; + inode->i_mapping =VFS_PTR_POISON ; + } +spin_unlock (&sb->s_inode_list_lock); } }spin_lock (&sb_lock);
include/linux/poison.h +3 -0
@@ -84,4 +84,7 @@/********** kernel/bpf/ **********/ #define BPF_PTR_POISON ((void *)(0xeB9FUL + POISON_POINTER_DELTA)) +/********** VFS **********/ +#define VFS_PTR_POISON ((void *)(0xF5 + POISON_POINTER_DELTA)) +#endif
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 534/885 blk-iocost: fix divide by 0 error in calc_lcoefs()
In reply to Greg Kroah-HartmanFrom: Li Nan <[email protected]>
[ Upstream commit 984af1e66b4126cf145153661cc24c213e2ec231 ]
echo max of u64 to cost.model can cause divide by 0 error.
# echo 8:0 rbps=18446744073709551615 > /sys/fs/cgroup/io.cost.model
divide error: 0000 [#1] PREEMPT SMP
RIP: 0010:calc_lcoefs+0x4c/0xc0 Call Trace: <TASK> ioc_refresh_params+0x2b3/0x4f0 ioc_cost_model_write+0x3cb/0x4c0 ? _copy_from_iter+0x6d/0x6c0 ? kernfs_fop_write_iter+0xfc/0x270 cgroup_file_write+0xa0/0x200 kernfs_fop_write_iter+0x17d/0x270 vfs_write+0x414/0x620 ksys_write+0x73/0x160 __x64_sys_write+0x1e/0x30 do_syscall_64+0x35/0x80 entry_SYSCALL_64_after_hwframe+0x63/0xcd
calc_lcoefs() uses the input value of cost.model in DIV_ROUND_UP_ULL, overflow would happen if bps plus IOC_PAGE_SIZE is greater than ULLONG_MAX, it can cause divide by 0 error.
Fix the problem by setting basecost
--- block/blk-iocost.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
block/blk-iocost.c +8 -3
@@ -865,9 +865,14 @@ static void calc_lcoefs(u64 bps, u64 seqiops, u64 randiops, *page = *seqio = *randio =0 ; -if (bps) - *page =DIV64_U64_ROUND_UP (VTIME_PER_SEC , -DIV_ROUND_UP_ULL (bps,IOC_PAGE_SIZE )); +if (bps) { +u64 bps_pages =DIV_ROUND_UP_ULL (bps,IOC_PAGE_SIZE ); + +if (bps_pages) + *page =DIV64_U64_ROUND_UP (VTIME_PER_SEC , bps_pages); +else + *page =1 ; + }if (seqiops) { v =DIV64_U64_ROUND_UP (VTIME_PER_SEC , seqiops);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 535/885 blk-cgroup: dropping parent refcount after pd_free_fn() is done
In reply to Greg Kroah-HartmanFrom: Yu Kuai <[email protected]>
[ Upstream commit c7241babf0855d8a6180cd1743ff0ec34de40b4e ]
Some cgroup policies will access parent pd through child pd even after pd_offline_fn() is done. If pd_free_fn() for parent is called before child, then UAF can be triggered. Hence it's better to guarantee the order of pd_free_fn().
Currently refcount of parent blkg is dropped in __blkg_release(), which is before pd_free_fn() is called in blkg_free_work_fn() while blkg_free_work_fn() is called asynchronously.
This patch make sure pd_free_fn() called from removing cgroup is ordered by delaying dropping parent refcount after calling pd_free_fn() for child.
BTW, pd_free_fn() will also be called from blkcg_deactivate_policy() from deleting device, and following patches will guarantee the order.
--- block/blk-cgroup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
block/blk-cgroup.c +2 -2
@@ -93,6 +93,8 @@ static void blkg_free_workfn(struct work_struct *work)if (blkg->pd[i]) blkcg_policy[i]->pd_free_fn (blkg->pd[i]); +if (blkg->parent) +blkg_put (blkg->parent);if (blkg->q)blk_put_queue (blkg->q);free_percpu (blkg->iostat_cpu);
@@ -127,8 +129,6 @@ static void __blkg_release(struct rcu_head *rcu)/* release the blkcg and parent blkg refs this blkg has been holding */ css_put (&blkg->blkcg->css); -if (blkg->parent) -blkg_put (blkg->parent);blkg_free (blkg); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 536/885 blk-cgroup: synchronize pd_free_fn() from blkg_free_workfn() and blkcg_deactivate_policy()
In reply to Greg Kroah-HartmanFrom: Yu Kuai <[email protected]>
[ Upstream commit f1c006f1c6850c14040f8337753a63119bba39b9 ]
Currently parent pd can be freed before child pd:
t1: remove cgroup C1blkcg_destroy_blkgs
blkg_destroy
list_del_init(&blkg->q_node)
// remove blkg from queue list
percpu_ref_kill(&blkg->refcnt)
blkg_release
call_rcu
t2: from t1__blkg_release
blkg_free
schedule_work
t4: deactivate policy blkcg_deactivate_policy pd_free_fn // parent of C1 is freed first
t3: from t2
blkg_free_workfn
pd_free_fn
If policy(for example, ioc_timer_fn() from iocost) access parent pd from child pd after pd_offline_fn(), then UAF can be triggered.
Fix the problem by delaying 'list_del_init(&blkg->q_node)' from blkg_destroy() to blkg_free_workfn(), and using a new disk level mutex to synchronize blkg_free_workfn() and blkcg_deactivate_policy().
--- block/blk-cgroup.c | 35 +++++++++++++++++++++++++++++------ include/linux/blkdev.h | 1 + 2 files changed, 30 insertions(+), 6 deletions(-)
block/blk-cgroup.c +29 -6
@@ -87,16 +87,32 @@ static void blkg_free_workfn(struct work_struct *work) { struct blkcg_gq *blkg = container_of(work, struct blkcg_gq, free_work); +struct request_queue *q = blkg->q;int i; +/* +* pd_free_fn() can also be called from blkcg_deactivate_policy(), +* in order to make sure pd_free_fn() is called in order, the deletion +* of the list blkg->q_node is delayed to here from blkg_destroy(), and +* blkcg_mutex is used to synchronize blkg_free_workfn() and +* blkcg_deactivate_policy(). +*/ +if (q) +mutex_lock (&q->blkcg_mutex); +for (i =0 ; i <BLKCG_MAX_POLS ; i++)if (blkg->pd[i]) blkcg_policy[i]->pd_free_fn (blkg->pd[i]);if (blkg->parent)blkg_put (blkg->parent); -if (blkg->q) -blk_put_queue (blkg->q); + +if (q) { +list_del_init (&blkg->q_node); +mutex_unlock (&q->blkcg_mutex); +blk_put_queue (q); + } +free_percpu (blkg->iostat_cpu);percpu_ref_exit (&blkg->refcnt);kfree (blkg);
@@ -425,9 +441,14 @@ static void blkg_destroy(struct blkcg_gq *blkg)lockdep_assert_held (&blkg->q->queue_lock);lockdep_assert_held (&blkcg->lock); -/* Something wrong if we are trying to remove same group twice */ -WARN_ON_ONCE (list_empty (&blkg->q_node)); -WARN_ON_ONCE (hlist_unhashed (&blkg->blkcg_node)); +/* +* blkg stays on the queue list until blkg_free_workfn(), see details in +* blkg_free_workfn(), hence this function can be called from +* blkcg_destroy_blkgs() first and again from blkg_destroy_all() before +* blkg_free_workfn(). +*/ +if (hlist_unhashed (&blkg->blkcg_node)) +return ;for (i =0 ; i <BLKCG_MAX_POLS ; i++) {struct blkcg_policy *pol = blkcg_policy[i];
@@ -439,7 +460,6 @@ static void blkg_destroy(struct blkcg_gq *blkg) blkg->online = false;radix_tree_delete (&blkcg->blkg_tree, blkg->q->id); -list_del_init (&blkg->q_node);hlist_del_init_rcu (&blkg->blkcg_node);/*
@@ -1226,6 +1246,7 @@ int blkcg_init_disk(struct gendisk *disk)int ret;INIT_LIST_HEAD (&q->blkg_list); +mutex_init (&q->blkcg_mutex); new_blkg =blkg_alloc (&blkcg_root, disk,GFP_KERNEL );if (!new_blkg)
@@ -1463,6 +1484,7 @@ void blkcg_deactivate_policy(struct request_queue *q,if (queue_is_mq (q))blk_mq_freeze_queue (q); +mutex_lock (&q->blkcg_mutex);spin_lock_irq (&q->queue_lock);__clear_bit (pol->plid, q->blkcg_pols);
@@ -1481,6 +1503,7 @@ void blkcg_deactivate_policy(struct request_queue *q, }spin_unlock_irq (&q->queue_lock); +mutex_unlock (&q->blkcg_mutex);if (queue_is_mq (q))blk_mq_unfreeze_queue (q);
include/linux/blkdev.h +1 -0
@@ -487,6 +487,7 @@ struct request_queue {DECLARE_BITMAP (blkcg_pols,BLKCG_MAX_POLS );struct blkcg_gq *root_blkg;struct list_head blkg_list; +struct mutex blkcg_mutex;#endif struct queue_limits limits;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 537/885 trace/blktrace: fix memory leak with using debugfs_lookup()
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
[ Upstream commit 83e8864fee26f63a7435e941b7c36a20fd6fe93e ]
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/trace/blktrace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/trace/blktrace.c +2 -2
@@ -320,8 +320,8 @@ static void blk_trace_free(struct request_queue *q, struct blk_trace *bt)* under 'q->debugfs_dir', thus lookup and remove them. */ if (!bt->dir) { -debugfs_remove (debugfs_lookup ("dropped" , q->debugfs_dir)); -debugfs_remove (debugfs_lookup ("msg" , q->debugfs_dir)); +debugfs_lookup_and_remove ("dropped" , q->debugfs_dir); +debugfs_lookup_and_remove ("msg" , q->debugfs_dir); }else {debugfs_remove (bt->dir); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 538/885 btrfs: scrub: improve tree block error reporting
In reply to Greg Kroah-HartmanFrom: Qu Wenruo <[email protected]>
[ Upstream commit 28232909ba43561887508a6ef46d7f33a648f375 ]
[BUG]
When debugging a scrub related metadata error, it turns out that our metadata error reporting is not ideal.
The only 3 error messages are:
- BTRFS error (device dm-2): bdev /dev/mapper/test-scratch1 errs: wr 0, rd 0, flush 0, corrupt 0, gen 1 Showing we have metadata generation mismatch errors.
- BTRFS error (device dm-2): unable to fixup (regular) error at logical 7110656 on dev /dev/mapper/test-scratch1 Showing which tree blocks are corrupted.
- BTRFS warning (device dm-2): checksum/header error at logical 24772608 on dev /dev/mapper/test-scratch2, physical 3801088: metadata node (level 1) in tree 5 Showing which physical range the corrupted metadata is at.
We have to combine the above 3 to know we have a corrupted metadata with generation mismatch.
And this is already the better case, if we have other problems, like fsid mismatch, we can not even know the cause.
[CAUSE]
The problem is caused by the fact that, scrub_checksum_tree_block() never outputs any error message.
It just return two bits for scrub: sblock->header_error, and sblock->generation_error.
And later we report error in scrub_print_warning(), but unfortunately we only have two bits, there is not really much thing we can done to print any detailed errors.
[FIX]
This patch will do the following to enhance the error reporting of metadata scrub:
- Add extra warning (ratelimited) for every error we hit This can help us to distinguish the different types of errors. Some errors can help us to know what's going wrong immediately, like bytenr mismatch.
- Re-order the checks
Currently we check bytenr first, then immediately generation. This can lead to false generation mismatch reports, while the fsid mismatches.
Here is the new output for the bug I'm debugging (we forgot to writeback tree blocks for commit roots):
BTRFS warning (device dm-2): tree block 24117248 mirror 1 has bad fsid, has b77cd862-f150-4c71-90ec-7baf0544d83f want 17df6abf-23cd-445f-b350-5b3e40bfd2fc BTRFS warning (device dm-2): tree block 24117248 mirror 0 has bad fsid, has b77cd862-f150-4c71-90ec-7baf0544d83f want 17df6abf-23cd-445f-b350-5b3e40bfd2fc
Now we can immediately know it's some tree blocks didn't even get written back, other than the original confusing generation mismatch.
--- fs/btrfs/scrub.c | 49 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 9 deletions(-)
fs/btrfs/scrub.c +40 -9
@@ -2036,20 +2036,33 @@ static int scrub_checksum_tree_block(struct scrub_block *sblock)* a) don't have an extent buffer and * b) the page is already kmapped */ -if (sblock->logical !=btrfs_stack_header_bytenr (h)) +if (sblock->logical !=btrfs_stack_header_bytenr (h)) { sblock->header_error =1 ; - -if (sector->generation !=btrfs_stack_header_generation (h)) { - sblock->header_error =1 ; - sblock->generation_error =1 ; +btrfs_warn_rl (fs_info, +"tree block %llu mirror %u has bad bytenr, has %llu want %llu" , + sblock->logical, sblock->mirror_num, +btrfs_stack_header_bytenr (h), + sblock->logical); + goto out; } -if (!scrub_check_fsid (h->fsid, sector)) +if (!scrub_check_fsid (h->fsid, sector)) { sblock->header_error =1 ; +btrfs_warn_rl (fs_info, +"tree block %llu mirror %u has bad fsid, has %pU want %pU" , + sblock->logical, sblock->mirror_num, + h->fsid, sblock->dev->fs_devices->fsid); + goto out; + } -if (memcmp (h->chunk_tree_uuid, fs_info->chunk_tree_uuid, -BTRFS_UUID_SIZE )) +if (memcmp (h->chunk_tree_uuid, fs_info->chunk_tree_uuid,BTRFS_UUID_SIZE )) { sblock->header_error =1 ; +btrfs_warn_rl (fs_info, +"tree block %llu mirror %u has bad chunk tree uuid, has %pU want %pU" , + sblock->logical, sblock->mirror_num, + h->chunk_tree_uuid, fs_info->chunk_tree_uuid); + goto out; + } shash->tfm = fs_info->csum_shash;crypto_shash_init (shash);
@@ -2062,9 +2075,27 @@ static int scrub_checksum_tree_block(struct scrub_block *sblock) }crypto_shash_final (shash, calculated_csum); -if (memcmp (calculated_csum, on_disk_csum, sctx->fs_info->csum_size)) +if (memcmp (calculated_csum, on_disk_csum, sctx->fs_info->csum_size)) { sblock->checksum_error =1 ; +btrfs_warn_rl (fs_info, +"tree block %llu mirror %u has bad csum, has " CSUM_FMT " want " CSUM_FMT , + sblock->logical, sblock->mirror_num, +CSUM_FMT_VALUE (fs_info->csum_size, on_disk_csum), +CSUM_FMT_VALUE (fs_info->csum_size, calculated_csum)); + goto out; + } + +if (sector->generation !=btrfs_stack_header_generation (h)) { + sblock->header_error =1 ; + sblock->generation_error =1 ; +btrfs_warn_rl (fs_info, +"tree block %llu mirror %u has bad generation, has %llu want %llu" , + sblock->logical, sblock->mirror_num, +btrfs_stack_header_generation (h), + sector->generation); + } +out:return sblock->header_error || sblock->checksum_error; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 539/885 arm64: zynqmp: Enable hs termination flag for USB dwc3 controller
In reply to Greg Kroah-HartmanFrom: Michael Grzeschik <[email protected]>
[ Upstream commit 32405e532d358a2f9d4befae928b9883c8597616 ]
Since we need to support legacy phys with the dwc3 controller, we enable this quirk on the zynqmp platforms.
--- arch/arm64/boot/dts/xilinx/zynqmp.dtsi | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/boot/dts/xilinx/zynqmp.dtsi +2 -0
@@ -825,6 +825,7 @@ dwc3_0: usb@fe200000 { clock-names = "bus_early", "ref"; iommus = <&smmu 0x860>; snps,quirk-frame-length-adjustment = <0x20>; + snps,resume-hs-terminations; /* dma-coherent; */ }; };
@@ -851,6 +852,7 @@ dwc3_1: usb@fe300000 { clock-names = "bus_early", "ref"; iommus = <&smmu 0x861>; snps,quirk-frame-length-adjustment = <0x20>; + snps,resume-hs-terminations; /* dma-coherent; */ }; };
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 540/885 cpuidle, intel_idle: Fix CPUIDLE_FLAG_INIT_XSTATE
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
[ Upstream commit 821ad23d0eaff73ef599ece39ecc77482df20a8c ]
Fix instrumentation bugs objtool found:
vmlinux.o: warning: objtool: intel_idle_s2idle+0xd5: call to fpu_idle_fpregs() leaves .noinstr.text section vmlinux.o: warning: objtool: intel_idle_xstate+0x11: call to fpu_idle_fpregs() leaves .noinstr.text section vmlinux.o: warning: objtool: fpu_idle_fpregs+0x9: call to xfeatures_in_use() leaves .noinstr.text section
--- arch/x86/include/asm/fpu/xcr.h | 4 ++-- arch/x86/include/asm/special_insns.h | 2 +- arch/x86/kernel/fpu/core.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)
arch/x86/include/asm/fpu/xcr.h +2 -2
@@ -5,7 +5,7 @@#define XCR_XFEATURE_ENABLED_MASK 0x00000000#define XCR_XFEATURE_IN_USE_MASK 0x00000001 -static inline u64 xgetbv (u32 index) +static __always_inline u64 xgetbv(u32 index) {u32 eax, edx;
@@ -27,7 +27,7 @@ static inline void xsetbv(u32 index, u64 value)* * Callers should check X86_FEATURE_XGETBV1. */ -static inline u64 xfeatures_in_use (void ) +static __always_inline u64 xfeatures_in_use(void) {return xgetbv (XCR_XFEATURE_IN_USE_MASK ); }
arch/x86/include/asm/special_insns.h +1 -1
@@ -295,7 +295,7 @@ static inline int enqcmds(void __iomem *dst, const void *src)return 0 ; } -static inline void tile_release (void ) +static __always_inline void tile_release(void) {/* * Instruction opcode for TILERELEASE; supported in binutils
arch/x86/kernel/fpu/core.c +2 -2
@@ -853,12 +853,12 @@ int fpu__exception_code(struct fpu *fpu, int trap_nr)* Initialize register state that may prevent from entering low-power idle. * This function will be invoked from the cpuidle driver only when needed. */ -void fpu_idle_fpregs (void ) +noinstr void fpu_idle_fpregs(void) {/* Note: AMX_TILE being enabled implies XGETBV1 support */ if (cpu_feature_enabled (X86_FEATURE_AMX_TILE ) && (xfeatures_in_use () &XFEATURE_MASK_XTILE )) {tile_release (); -fpregs_deactivate (¤t->thread.fpu); +__this_cpu_write (fpu_fpregs_owner_ctx,NULL ); } }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 541/885 x86/fpu: Dont set TIF_NEED_FPU_LOAD for PF_IO_WORKER threads
In reply to Greg Kroah-HartmanFrom: Jens Axboe <[email protected]>
[ Upstream commit cb3ea4b7671b7cfbac3ee609976b790aebd0bbda ]
We don't set it on PF_KTHREAD threads as they never return to userspace, and PF_IO_WORKER threads are identical in that regard. As they keep running in the kernel until they die, skip setting the FPU flag on them.
More of a cosmetic thing that was found while debugging and issue and pondering why the FPU flag is set on these threads.
--- arch/x86/include/asm/fpu/sched.h | 2 +- arch/x86/kernel/fpu/context.h | 2 +- arch/x86/kernel/fpu/core.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/include/asm/fpu/sched.h +1 -1
@@ -39,7 +39,7 @@ extern void fpu_flush_thread(void);static inline void switch_fpu_prepare (struct fpu *old_fpu,int cpu) {if (cpu_feature_enabled (X86_FEATURE_FPU ) && - !(current->flags &PF_KTHREAD )) { + !(current->flags & (PF_KTHREAD |PF_IO_WORKER ))) {save_fpregs_to_fpstate (old_fpu);/* * The save operation preserved register state, so the
arch/x86/kernel/fpu/context.h +1 -1
@@ -57,7 +57,7 @@ static inline void fpregs_restore_userregs(void)struct fpu *fpu = ¤t->thread.fpu;int cpu =smp_processor_id (); -if (WARN_ON_ONCE (current->flags &PF_KTHREAD )) +if (WARN_ON_ONCE (current->flags & (PF_KTHREAD |PF_IO_WORKER )))return ;if (!fpregs_state_valid (fpu, cpu)) {
arch/x86/kernel/fpu/core.c +1 -1
@@ -426,7 +426,7 @@ void kernel_fpu_begin_mask(unsigned int kfpu_mask)this_cpu_write (in_kernel_fpu, true); -if (!(current->flags &PF_KTHREAD ) && +if (!(current->flags & (PF_KTHREAD |PF_IO_WORKER )) && !test_thread_flag (TIF_NEED_FPU_LOAD )) {set_thread_flag (TIF_NEED_FPU_LOAD );save_fpregs_to_fpstate (¤t->thread.fpu);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 542/885 cpuidle: drivers: firmware: psci: Dont instrument suspend code
In reply to Greg Kroah-HartmanFrom: Mark Rutland <[email protected]>
[ Upstream commit 393e2ea30aec634b37004d401863428e120d5e1b ]
The PSCI suspend code is currently instrumentable, which is not safe as instrumentation (e.g. ftrace) may try to make use of RCU during idle periods when RCU is not watching.
To fix this we need to ensure that psci_suspend_finisher() and anything it calls are not instrumented. We can do this fairly simply by marking psci_suspend_finisher() and the psci*_cpu_suspend() functions as noinstr, and the underlying helper functions as __always_inline.
When CONFIG_DEBUG_VIRTUAL=y, __pa_symbol() can expand to an out-of-line instrumented function, so we must use __pa_symbol_nodebug() within psci_suspend_finisher().
The raw SMCCC invocation functions are written in assembly, and are not subject to compiler instrumentation.
--- drivers/firmware/psci/psci.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-)
drivers/firmware/psci/psci.c +19 -12
@@ -108,9 +108,10 @@ bool psci_power_state_is_valid(u32 state)return !(state & ~valid_mask); } -static unsigned long __invoke_psci_fn_hvc (unsigned long function_id, -unsigned long arg0,unsigned long arg1, -unsigned long arg2) +static __always_inline unsigned long +__invoke_psci_fn_hvc (unsigned long function_id, +unsigned long arg0,unsigned long arg1, +unsigned long arg2) {struct arm_smccc_res res;
@@ -118,9 +119,10 @@ static unsigned long __invoke_psci_fn_hvc(unsigned long function_id,return res.a0; } -static unsigned long __invoke_psci_fn_smc (unsigned long function_id, -unsigned long arg0,unsigned long arg1, -unsigned long arg2) +static __always_inline unsigned long +__invoke_psci_fn_smc (unsigned long function_id, +unsigned long arg0,unsigned long arg1, +unsigned long arg2) {struct arm_smccc_res res;
@@ -128,7 +130,7 @@ static unsigned long __invoke_psci_fn_smc(unsigned long function_id,return res.a0; } -static int psci_to_linux_errno (int errno) +static __always_inline int psci_to_linux_errno(int errno) {switch (errno) {case PSCI_RET_SUCCESS :
@@ -169,7 +171,8 @@ int psci_set_osi_mode(bool enable)return psci_to_linux_errno (err); } -static int __psci_cpu_suspend (u32 fn,u32 state,unsigned long entry_point) +static __always_inline int +__psci_cpu_suspend (u32 fn,u32 state,unsigned long entry_point) {int err;
@@ -177,13 +180,15 @@ static int __psci_cpu_suspend(u32 fn, u32 state, unsigned long entry_point)return psci_to_linux_errno (err); } -static int psci_0_1_cpu_suspend (u32 state,unsigned long entry_point) +static __always_inline int +psci_0_1_cpu_suspend (u32 state,unsigned long entry_point) {return __psci_cpu_suspend (psci_0_1_function_ids.cpu_suspend, state, entry_point); } -static int psci_0_2_cpu_suspend (u32 state,unsigned long entry_point) +static __always_inline int +psci_0_2_cpu_suspend (u32 state,unsigned long entry_point) { return __psci_cpu_suspend(PSCI_FN_NATIVE(0_2, CPU_SUSPEND), state, entry_point);
@@ -450,10 +455,12 @@ late_initcall(psci_debugfs_init)#endif #ifdef CONFIG_CPU_IDLE -static int psci_suspend_finisher (unsigned long state) +static noinstr int psci_suspend_finisher(unsigned long state) {u32 power_state = state; -phys_addr_t pa_cpu_resume =__pa_symbol (cpu_resume); +phys_addr_t pa_cpu_resume; + + pa_cpu_resume =__pa_symbol_nodebug ((unsigned long )cpu_resume);return psci_ops.cpu_suspend (power_state, pa_cpu_resume); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 543/885 cpuidle: lib/bug: Disable rcu_is_watching() during WARN/BUG
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
[ Upstream commit 5a5d7e9badd2cb8065db171961bd30bd3595e4b6 ]
In order to avoid WARN/BUG from generating nested or even recursive warnings, force rcu_is_watching() true during WARN/lockdep_rcu_suspicious().
Notably things like unwinding the stack can trigger rcu_dereference() warnings, which then triggers more unwinding which then triggers more warnings etc..
--- include/linux/context_tracking.h | 27 +++++++++++++++++++++++++++ kernel/locking/lockdep.c | 3 +++ kernel/panic.c | 5 +++++ lib/bug.c | 15 ++++++++++++++- 4 files changed, 49 insertions(+), 1 deletion(-)
include/linux/context_tracking.h +27 -0
@@ -130,9 +130,36 @@ static __always_inline unsigned long ct_state_inc(int incby)return arch_atomic_add_return (incby,this_cpu_ptr (&context_tracking.state)); } +static __always_inline bool warn_rcu_enter(void) +{ +bool ret = false; + +/* +* Horrible hack to shut up recursive RCU isn't watching fail since +* lots of the actual reporting also relies on RCU. +*/ +preempt_disable_notrace (); +if (rcu_dynticks_curr_cpu_in_eqs ()) { + ret = true; +ct_state_inc (RCU_DYNTICKS_IDX ); + } + +return ret; +} + +static __always_inline void warn_rcu_exit(bool rcu) +{ +if (rcu) +ct_state_inc (RCU_DYNTICKS_IDX ); +preempt_enable_notrace (); +} +#else static inline void ct_idle_enter (void ) { }static inline void ct_idle_exit (void ) { } + +static __always_inline bool warn_rcu_enter(void) { return false; } +static __always_inline void warn_rcu_exit(bool rcu) { }#endif /* !CONFIG_CONTEXT_TRACKING_IDLE */ #endif
kernel/locking/lockdep.c +3 -0
@@ -55,6 +55,7 @@#include <linux/rcupdate.h> #include <linux/kprobes.h> #include <linux/lockdep.h> +#include <linux/context_tracking.h> #include <asm/sections.h>
@@ -6555,6 +6556,7 @@ void lockdep_rcu_suspicious(const char *file, const int line, const char *s) {struct task_struct *curr = current;int dl =READ_ONCE (debug_locks); +bool rcu =warn_rcu_enter ();/* Note: the following can be executed concurrently, so be careful. */ pr_warn ("\n" );
@@ -6595,5 +6597,6 @@ void lockdep_rcu_suspicious(const char *file, const int line, const char *s)lockdep_print_held_locks (curr);pr_warn ("\nstack backtrace:\n" );dump_stack (); +warn_rcu_exit (rcu); }EXPORT_SYMBOL_GPL (lockdep_rcu_suspicious);
kernel/panic.c +5 -0
@@ -33,6 +33,7 @@#include <linux/ratelimit.h> #include <linux/debugfs.h> #include <linux/sysfs.h> +#include <linux/context_tracking.h> #include <trace/events/error_report.h> #include <asm/sections.h>
@@ -678,6 +679,7 @@ void __warn(const char *file, int line, void *caller, unsigned taint,void warn_slowpath_fmt (const char *file,int line,unsigned taint,const char *fmt, ...) { +bool rcu =warn_rcu_enter ();struct warn_args args;pr_warn (CUT_HERE );
@@ -692,11 +694,13 @@ void warn_slowpath_fmt(const char *file, int line, unsigned taint,va_start (args.args, fmt);__warn (file, line,__builtin_return_address (0 ), taint,NULL , &args);va_end (args.args); + warn_rcu_exit(rcu); }EXPORT_SYMBOL (warn_slowpath_fmt);#else void __warn_printk (const char *fmt, ...) { +bool rcu =warn_rcu_enter ();va_list args;pr_warn (CUT_HERE );
@@ -704,6 +708,7 @@ void __warn_printk(const char *fmt, ...)va_start (args, fmt);vprintk (fmt, args);va_end (args); + warn_rcu_exit(rcu); }EXPORT_SYMBOL (__warn_printk);#endif
lib/bug.c +14 -1
@@ -47,6 +47,7 @@#include <linux/sched.h> #include <linux/rculist.h> #include <linux/ftrace.h> +#include <linux/context_tracking.h> extern struct bug_entry __start___bug_table[], __stop___bug_table[];
@@ -153,7 +154,7 @@ struct bug_entry *find_bug(unsigned long bugaddr)return module_find_bug (bugaddr); } -enum bug_trap_type report_bug (unsigned long bugaddr,struct pt_regs *regs) +static enum bug_trap_type __report_bug (unsigned long bugaddr,struct pt_regs *regs) {struct bug_entry *bug;const char *file;
@@ -209,6 +210,18 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)return BUG_TRAP_TYPE_BUG ; } +enum bug_trap_type report_bug (unsigned long bugaddr,struct pt_regs *regs) +{ +enum bug_trap_type ret; +bool rcu = false; + + rcu =warn_rcu_enter (); + ret =__report_bug (bugaddr, regs); +warn_rcu_exit (rcu); + +return ret; +} +static void clear_once_table (struct bug_entry *start,struct bug_entry *end) {struct bug_entry *bug;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 544/885 perf/x86/intel/uncore: Add Meteor Lake support
In reply to Greg Kroah-HartmanFrom: Kan Liang <[email protected]>
[ Upstream commit c828441f21ddc819a28b5723a72e3c840e9de1c6 ]
The uncore subsystem for Meteor Lake is similar to the previous Alder Lake. The main difference is that MTL provides PMU support for different tiles, while ADL only provides PMU support for the whole package. On ADL, there are CBOX, ARB, and clockbox uncore PMON units. On MTL, they are split into CBOX/HAC_CBOX, ARB/HAC_ARB, and cncu/sncu which provides a fixed counter for clockticks. Also, new MSR addresses are introduced on MTL.
The IMC uncore PMON is the same as Alder Lake. Add new PCIIDs of IMC for Meteor Lake.
--- arch/x86/events/intel/uncore.c | 7 ++ arch/x86/events/intel/uncore.h | 1 + arch/x86/events/intel/uncore_snb.c | 161 +++++++++++++++++++++++++++++ 3 files changed, 169 insertions(+)
arch/x86/events/intel/uncore.c +7 -0
@@ -1765,6 +1765,11 @@ static const struct intel_uncore_init_fun adl_uncore_init __initconst = { .mmio_init = adl_uncore_mmio_init, }; +static const struct intel_uncore_init_fun mtl_uncore_init__initconst = { + .cpu_init = mtl_uncore_cpu_init, + .mmio_init = adl_uncore_mmio_init, +}; +static const struct intel_uncore_init_fun icx_uncore_init__initconst = { .cpu_init = icx_uncore_cpu_init, .pci_init = icx_uncore_pci_init,
@@ -1832,6 +1837,8 @@ static const struct x86_cpu_id intel_uncore_match[] __initconst = {X86_MATCH_INTEL_FAM6_MODEL (RAPTORLAKE , &adl_uncore_init),X86_MATCH_INTEL_FAM6_MODEL (RAPTORLAKE_P , &adl_uncore_init),X86_MATCH_INTEL_FAM6_MODEL (RAPTORLAKE_S , &adl_uncore_init), +X86_MATCH_INTEL_FAM6_MODEL (METEORLAKE , &mtl_uncore_init), +X86_MATCH_INTEL_FAM6_MODEL (METEORLAKE_L , &mtl_uncore_init),X86_MATCH_INTEL_FAM6_MODEL (SAPPHIRERAPIDS_X , &spr_uncore_init),X86_MATCH_INTEL_FAM6_MODEL (EMERALDRAPIDS_X , &spr_uncore_init), X86_MATCH_INTEL_FAM6_MODEL(ATOM_TREMONT_D, &snr_uncore_init),
arch/x86/events/intel/uncore.h +1 -0
@@ -587,6 +587,7 @@ void skl_uncore_cpu_init(void);void icl_uncore_cpu_init (void );void tgl_uncore_cpu_init (void );void adl_uncore_cpu_init (void ); +void mtl_uncore_cpu_init (void );void tgl_uncore_mmio_init (void );void tgl_l_uncore_mmio_init (void );void adl_uncore_mmio_init (void );
arch/x86/events/intel/uncore_snb.c +161 -0
185 lines not on this page · raw message
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 545/885 wifi: ath9k: Fix use-after-free in ath9k_hif_usb_disconnect()
In reply to Greg Kroah-HartmanFrom: Minsuk Kang <[email protected]>
[ Upstream commit f099c5c9e2ba08a379bd354a82e05ef839ae29ac ]
This patch fixes a use-after-free in ath9k that occurs in ath9k_hif_usb_disconnect() when ath9k_destroy_wmi() is trying to access 'drv_priv' that has already been freed by ieee80211_free_hw(), called by ath9k_htc_hw_deinit(). The patch moves ath9k_destroy_wmi() before ieee80211_free_hw(). Note that urbs from the driver should be killed before freeing 'wmi' with ath9k_destroy_wmi() as their callbacks will access 'wmi'.
Found by a modified version of syzkaller.
==================================================================
BUG: KASAN: use-after-free in ath9k_destroy_wmi+0x38/0x40
Read of size 8 at addr ffff8881069132a0 by task kworker/0:1/7
CPU: 0 PID: 7 Comm: kworker/0:1 Tainted: G O 5.14.0+ #131
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014
Workqueue: usb_hub_wq hub_event
Call Trace:
dump_stack_lvl+0x8e/0xd1
print_address_description.constprop.0.cold+0x93/0x334
? ath9k_destroy_wmi+0x38/0x40
? ath9k_destroy_wmi+0x38/0x40
kasan_report.cold+0x83/0xdf
? ath9k_destroy_wmi+0x38/0x40
ath9k_destroy_wmi+0x38/0x40
ath9k_hif_usb_disconnect+0x329/0x3f0
? ath9k_hif_usb_suspend+0x120/0x120
? usb_disable_interface+0xfc/0x180
usb_unbind_interface+0x19b/0x7e0
? usb_autoresume_device+0x50/0x50
device_release_driver_internal+0x44d/0x520
bus_remove_device+0x2e5/0x5a0
device_del+0x5b2/0xe30
? __device_link_del+0x370/0x370
? usb_remove_ep_devs+0x43/0x80
? remove_intf_ep_devs+0x112/0x1a0
usb_disable_device+0x1e3/0x5a0
usb_disconnect+0x267/0x870
hub_event+0x168d/0x3950
? rcu_read_lock_sched_held+0xa1/0xd0
? hub_port_debounce+0x2e0/0x2e0
? check_irq_usage+0x860/0xf20
? drain_workqueue+0x281/0x360
? lock_release+0x640/0x640
? rcu_read_lock_sched_held+0xa1/0xd0
? rcu_read_lock_bh_held+0xb0/0xb0
? lockdep_hardirqs_on_prepare+0x273/0x3e0
process_one_work+0x92b/0x1460
? pwq_dec_nr_in_flight+0x330/0x330
? rwlock_bug.part.0+0x90/0x90
worker_thread+0x95/0xe00
? __kthread_parkme+0x115/0x1e0
? process_one_work+0x1460/0x1460
kthread+0x3a1/0x480
? set_kthread_struct+0x120/0x120
ret_from_fork+0x1f/0x30
The buggy address belongs to the page:
page:ffffea00041a44c0 refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x106913
flags: 0x200000000000000(node=0|zone=2)
raw: 0200000000000000 0000000000000000 dead000000000122 0000000000000000
raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as freed
page last allocated via order 3, migratetype Unmovable, gfp_mask 0x40dc0(GFP_KERNEL|__GFP_COMP|__GFP_ZERO), pid 7, ts 38347963444, free_ts 41399957635
prep_new_page+0x1aa/0x240
get_page_from_freelist+0x159a/0x27c0
__alloc_pages+0x2da/0x6a0
alloc_pages+0xec/0x1e0
kmalloc_order+0x39/0xf0
kmalloc_order_trace+0x19/0x120
__kmalloc+0x308/0x390
wiphy_new_nm+0x6f5/0x1dd0
ieee80211_alloc_hw_nm+0x36d/0x2230
ath9k_htc_probe_device+0x9d/0x1e10
ath9k_htc_hw_init+0x34/0x50
ath9k_hif_usb_firmware_cb+0x25f/0x4e0
request_firmware_work_func+0x131/0x240
process_one_work+0x92b/0x1460
worker_thread+0x95/0xe00
kthread+0x3a1/0x480
page last free stack trace:
free_pcp_prepare+0x3d3/0x7f0
free_unref_page+0x1e/0x3d0
device_release+0xa4/0x240
kobject_put+0x186/0x4c0
put_device+0x20/0x30
ath9k_htc_disconnect_device+0x1cf/0x2c0
ath9k_htc_hw_deinit+0x26/0x30
ath9k_hif_usb_disconnect+0x2d9/0x3f0
usb_unbind_interface+0x19b/0x7e0
device_release_driver_internal+0x44d/0x520
bus_remove_device+0x2e5/0x5a0
device_del+0x5b2/0xe30
usb_disable_device+0x1e3/0x5a0
usb_disconnect+0x267/0x870
hub_event+0x168d/0x3950
process_one_work+0x92b/0x1460
Memory state around the buggy address:
ffff888106913180: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff888106913200: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff888106913280: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
^
ffff888106913300: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff888106913380: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================--- drivers/net/wireless/ath/ath9k/hif_usb.c | 2 -- drivers/net/wireless/ath/ath9k/htc_drv_init.c | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath9k/hif_usb.c +0 -2
@@ -1424,8 +1424,6 @@ static void ath9k_hif_usb_disconnect(struct usb_interface *interface)if (hif_dev->flags &HIF_USB_READY ) {ath9k_htc_hw_deinit (hif_dev->htc_handle, unplugged); -ath9k_hif_usb_dev_deinit (hif_dev); -ath9k_destroy_wmi (hif_dev->htc_handle->drv_priv);ath9k_htc_hw_free (hif_dev->htc_handle); }
drivers/net/wireless/ath/ath9k/htc_drv_init.c +2 -0
@@ -988,6 +988,8 @@ void ath9k_htc_disconnect_device(struct htc_target *htc_handle, bool hotunplug)ath9k_deinit_device (htc_handle->drv_priv);ath9k_stop_wmi (htc_handle->drv_priv); +ath9k_hif_usb_dealloc_urbs ((struct hif_device_usb *)htc_handle->hif_dev); +ath9k_destroy_wmi (htc_handle->drv_priv);ieee80211_free_hw (htc_handle->drv_priv->hw); } }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 546/885 wifi: ath11k: fix monitor mode bringup crash
In reply to Greg Kroah-HartmanFrom: Nagarajan Maran <[email protected]>
[ Upstream commit 950b43f8bd8a4d476d2da6d2a083a89bcd3c90d7 ]
When the interface is brought up in monitor mode, it leads to NULL pointer dereference crash. This crash happens when the packet type is extracted for a SKB. This extraction which is present in the received msdu delivery path,is not needed for the monitor ring packets since they are all RAW packets. Hence appending the flags with "RX_FLAG_ONLY_MONITOR" to skip that extraction.
Observed calltrace:
Unable to handle kernel NULL pointer dereference at virtual address
0000000000000064
Mem abort info:
ESR = 0x0000000096000004
EC = 0x25: DABT (current EL), IL = 32 bits
SET = 0, FnV = 0
EA = 0, S1PTW = 0
FSC = 0x04: level 0 translation fault
Data abort info:
ISV = 0, ISS = 0x00000004
CM = 0, WnR = 0
user pgtable: 4k pages, 48-bit VAs, pgdp=0000000048517000 [0000000000000064] pgd=0000000000000000, p4d=0000000000000000
Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP Modules linked in: ath11k_pci ath11k qmi_helpers CPU: 2 PID: 1781 Comm: napi/-271 Not tainted 6.1.0-rc5-wt-ath-656295-gef907406320c-dirty #6 Hardware name: Qualcomm Technologies, Inc. IPQ8074/AP-HK10-C2 (DT) pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : ath11k_hw_qcn9074_rx_desc_get_decap_type+0x34/0x60 [ath11k] lr : ath11k_hw_qcn9074_rx_desc_get_decap_type+0x5c/0x60 [ath11k]
sp : ffff80000ef5bb10
x29: ffff80000ef5bb10 x28: 0000000000000000 x27: ffff000007baafa0
x26: ffff000014a91ed0 x25: 0000000000000000 x24: 0000000000000000
x23: ffff800002b77378 x22: ffff000014a91ec0 x21: ffff000006c8d600
x20: 0000000000000000 x19: ffff800002b77740 x18: 0000000000000006
x17: 736564203634343a x16: 656e694c20657079 x15: 0000000000000143
x14: 00000000ffffffea x13: ffff80000ef5b8b8 x12: ffff80000ef5b8c8
x11: ffff80000a591d30 x10: ffff80000a579d40 x9 : c0000000ffffefff x8 : 0000000000000003 x7 : 0000000000017fe8 x6 : ffff80000a579ce8 x5 : 0000000000000000 x4 : 0000000000000000 x3 : 0000000000000000 x2 : 3a35ec12ed7f8900 x1 : 0000000000000000 x0 : 0000000000000052
Call trace: ath11k_hw_qcn9074_rx_desc_get_decap_type+0x34/0x60 [ath11k] ath11k_dp_rx_deliver_msdu.isra.42+0xa4/0x3d0 [ath11k] ath11k_dp_rx_mon_deliver.isra.43+0x2f8/0x458 [ath11k] ath11k_dp_rx_process_mon_rings+0x310/0x4c0 [ath11k] ath11k_dp_service_srng+0x234/0x338 [ath11k] ath11k_pcic_ext_grp_napi_poll+0x30/0xb8 [ath11k] __napi_poll+0x5c/0x190 napi_threaded_poll+0xf0/0x118 kthread+0xf4/0x110 ret_from_fork+0x10/0x20
Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1
--- drivers/net/wireless/ath/ath11k/dp_rx.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/ath/ath11k/dp_rx.c +1 -0
@@ -5023,6 +5023,7 @@ static int ath11k_dp_rx_mon_deliver(struct ath11k *ar, u32 mac_id, }else { rxs->flag |=RX_FLAG_ALLOW_SAME_PN ; } + rxs->flag |=RX_FLAG_ONLY_MONITOR ;ath11k_update_radiotap (ar, ppduinfo, mon_skb, rxs);ath11k_dp_rx_deliver_msdu (ar, napi, mon_skb, rxs);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 547/885 wifi: brcmfmac: Fix potential stack-out-of-bounds in brcmf_c_preinit_dcmds()
In reply to Greg Kroah-HartmanFrom: Jisoo Jang <[email protected]>
[ Upstream commit 0a06cadcc2a0044e4a117cc0e61436fc3a0dad69 ]
This patch fixes a stack-out-of-bounds read in brcmfmac that occurs when 'buf' that is not null-terminated is passed as an argument of strsep() in brcmf_c_preinit_dcmds(). This buffer is filled with a firmware version string by memcpy() in brcmf_fil_iovar_data_get().
The patch ensures buf is null-terminated.
Found by a modified version of syzkaller.
[ 47.569679][ T1897] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43236b for chip BCM43236/3 [ 47.582839][ T1897] brcmfmac: brcmf_c_process_clm_blob: no clm_blob available (err=-2), device may have limited channels available [ 47.601565][ T1897] ================================================================== [ 47.602574][ T1897] BUG: KASAN: stack-out-of-bounds in strsep+0x1b2/0x1f0 [ 47.603447][ T1897] Read of size 1 at addr ffffc90001f6f000 by task kworker/0:2/1897 [ 47.604336][ T1897] [ 47.604621][ T1897] CPU: 0 PID: 1897 Comm: kworker/0:2 Tainted: G O 5.14.0+ #131 [ 47.605617][ T1897] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014 [ 47.606907][ T1897] Workqueue: usb_hub_wq hub_event [ 47.607453][ T1897] Call Trace: [ 47.607801][ T1897] dump_stack_lvl+0x8e/0xd1 [ 47.608295][ T1897] print_address_description.constprop.0.cold+0xf/0x334 [ 47.609009][ T1897] ? strsep+0x1b2/0x1f0 [ 47.609434][ T1897] ? strsep+0x1b2/0x1f0 [ 47.609863][ T1897] kasan_report.cold+0x83/0xdf [ 47.610366][ T1897] ? strsep+0x1b2/0x1f0 [ 47.610882][ T1897] strsep+0x1b2/0x1f0 [ 47.611300][ T1897] ? brcmf_fil_iovar_data_get+0x3a/0xf0 [ 47.611883][ T1897] brcmf_c_preinit_dcmds+0x995/0xc40 [ 47.612434][ T1897] ? brcmf_c_set_joinpref_default+0x100/0x100 [ 47.613078][ T1897] ? rcu_read_lock_sched_held+0xa1/0xd0 [ 47.613662][ T1897] ? rcu_read_lock_bh_held+0xb0/0xb0 [ 47.614208][ T1897] ? lock_acquire+0x19d/0x4e0 [ 47.614704][ T1897] ? find_held_lock+0x2d/0x110 [ 47.615236][ T1897] ? brcmf_usb_deq+0x1a7/0x260 [ 47.615741][ T1897] ? brcmf_usb_rx_fill_all+0x5a/0xf0 [ 47.616288][ T1897] brcmf_attach+0x246/0xd40 [ 47.616758][ T1897] ? wiphy_new_nm+0x1703/0x1dd0 [ 47.617280][ T1897] ? kmemdup+0x43/0x50 [ 47.617720][ T1897] brcmf_usb_probe+0x12de/0x1690 [ 47.618244][ T1897] ? brcmf_usbdev_qinit.constprop.0+0x470/0x470 [ 47.618901][ T1897] usb_probe_interface+0x2aa/0x760 [ 47.619429][ T1897] ? usb_probe_device+0x250/0x250 [ 47.619950][ T1897] really_probe+0x205/0xb70 [ 47.620435][ T1897] ? driver_allows_async_probing+0x130/0x130 [ 47.621048][ T1897] __driver_probe_device+0x311/0x4b0 [ 47.621595][ T1897] ? driver_allows_async_probing+0x130/0x130 [ 47.622209][ T1897] driver_probe_device+0x4e/0x150 [ 47.622739][ T1897] __device_attach_driver+0x1cc/0x2a0 [ 47.623287][ T1897] bus_for_each_drv+0x156/0x1d0 [ 47.623796][ T1897] ? bus_rescan_devices+0x30/0x30 [ 47.624309][ T1897] ? lockdep_hardirqs_on_prepare+0x273/0x3e0 [ 47.624907][ T1897] ? trace_hardirqs_on+0x46/0x160 [ 47.625437][ T1897] __device_attach+0x23f/0x3a0 [ 47.625924][ T1897] ? device_bind_driver+0xd0/0xd0 [ 47.626433][ T1897] ? kobject_uevent_env+0x287/0x14b0 [ 47.627057][ T1897] bus_probe_device+0x1da/0x290 [ 47.627557][ T1897] device_add+0xb7b/0x1eb0 [ 47.628027][ T1897] ? wait_for_completion+0x290/0x290 [ 47.628593][ T1897] ? __fw_devlink_link_to_suppliers+0x5a0/0x5a0 [ 47.629249][ T1897] usb_set_configuration+0xf59/0x16f0 [ 47.629829][ T1897] usb_generic_driver_probe+0x82/0xa0 [ 47.630385][ T1897] usb_probe_device+0xbb/0x250 [ 47.630927][ T1897] ? usb_suspend+0x590/0x590 [ 47.631397][ T1897] really_probe+0x205/0xb70 [ 47.631855][ T1897] ? driver_allows_async_probing+0x130/0x130 [ 47.632469][ T1897] __driver_probe_device+0x311/0x4b0 [ 47.633002][ T1897] ? usb_generic_driver_match+0x75/0x90 [ 47.633573][ T1897] ? driver_allows_async_probing+0x130/0x130 [ 47.634170][ T1897] driver_probe_device+0x4e/0x150 [ 47.634703][ T1897] __device_attach_driver+0x1cc/0x2a0 [ 47.635248][ T1897] bus_for_each_drv+0x156/0x1d0 [ 47.635748][ T1897] ? bus_rescan_devices+0x30/0x30 [ 47.636271][ T1897] ? lockdep_hardirqs_on_prepare+0x273/0x3e0 [ 47.636881][ T1897] ? trace_hardirqs_on+0x46/0x160 [ 47.637396][ T1897] __device_attach+0x23f/0x3a0 [ 47.637904][ T1897] ? device_bind_driver+0xd0/0xd0 [ 47.638426][ T1897] ? kobject_uevent_env+0x287/0x14b0 [ 47.638985][ T1897] bus_probe_device+0x1da/0x290 [ 47.639512][ T1897] device_add+0xb7b/0x1eb0 [ 47.639977][ T1897] ? __fw_devlink_link_to_suppliers+0x5a0/0x5a0 [ 47.640612][ T1897] ? kfree+0x14a/0x6b0 [ 47.641055][ T1897] ? __usb_get_extra_descriptor+0x116/0x160 [ 47.641679][ T1897] usb_new_device.cold+0x49c/0x1029 [ 47.642245][ T1897] ? hub_disconnect+0x450/0x450 [ 47.642756][ T1897] ? rwlock_bug.part.0+0x90/0x90 [ 47.643273][ T1897] ? _raw_spin_unlock_irq+0x24/0x30 [ 47.643822][ T1897] ? lockdep_hardirqs_on_prepare+0x273/0x3e0 [ 47.644445][ T1897] hub_event+0x1c98/0x3950 [ 47.644939][ T1897] ? hub_port_debounce+0x2e0/0x2e0 [ 47.645467][ T1897] ? check_irq_usage+0x861/0xf20 [ 47.645975][ T1897] ? drain_workqueue+0x280/0x360 [ 47.646506][ T1897] ? lock_release+0x640/0x640 [ 47.646994][ T1897] ? rcu_read_lock_sched_held+0xa1/0xd0 [ 47.647572][ T1897] ? rcu_read_lock_bh_held+0xb0/0xb0 [ 47.648111][ T1897] ? lockdep_hardirqs_on_prepare+0x273/0x3e0 [ 47.648735][ T1897] process_one_work+0x92b/0x1460 [ 47.649262][ T1897] ? pwq_dec_nr_in_flight+0x330/0x330 [ 47.649816][ T1897] ? rwlock_bug.part.0+0x90/0x90 [ 47.650336][ T1897] worker_thread+0x95/0xe00 [ 47.650830][ T1897] ? __kthread_parkme+0x115/0x1e0 [ 47.651361][ T1897] ? process_one_work+0x1460/0x1460 [ 47.651904][ T1897] kthread+0x3a1/0x480 [ 47.652329][ T1897] ? set_kthread_struct+0x120/0x120 [ 47.652878][ T1897] ret_from_fork+0x1f/0x30 [ 47.653370][ T1897] [ 47.653608][ T1897] [ 47.653848][ T1897] addr ffffc90001f6f000 is located in stack of task kworker/0:2/1897 at offset 512 in frame: [ 47.654891][ T1897] brcmf_c_preinit_dcmds+0x0/0xc40 [ 47.655442][ T1897] [ 47.655690][ T1897] this frame has 4 objects: [ 47.656151][ T1897] [48, 56) 'ptr' [ 47.656159][ T1897] [80, 148) 'revinfo' [ 47.656534][ T1897] [192, 210) 'eventmask' [ 47.656953][ T1897] [256, 512) 'buf' [ 47.657410][ T1897] [ 47.658035][ T1897] Memory state around the buggy address: [ 47.658743][ T1897] ffffc90001f6ef00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 47.659577][ T1897] ffffc90001f6ef80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 47.660394][ T1897] >ffffc90001f6f000: f3 f3 f3 f3 f3 f3 f3 f3 00 00 00 00 00 00 00 00 [ 47.661199][ T1897] ^ [ 47.661625][ T1897] ffffc90001f6f080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 47.662455][ T1897] ffffc90001f6f100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 [ 47.663318][ T1897] ================================================================== [ 47.664147][ T1897] Disabling lock debugging due to kernel taint
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c +1 -0
@@ -298,6 +298,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp) err); goto done; } + buf[sizeof (buf) -1 ] ='\0' ; ptr = (char *)buf;strsep (&ptr,"\n" );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 548/885 rcu: Make RCU_LOCKDEP_WARN() avoid early lockdep checks
In reply to Greg Kroah-HartmanFrom: Paul E. McKenney <[email protected]>
[ Upstream commit 0cae5ded535c3a80aed94f119bbd4ee3ae284a65 ]
Currently, RCU_LOCKDEP_WARN() checks the condition before checking to see if lockdep is still enabled. This is necessary to avoid the false-positive splats fixed by commit 3066820034b5dd ("rcu: Reject RCU_LOCKDEP_WARN() false positives"). However, the current state can result in false-positive splats during early boot before lockdep is fully initialized. This commit therefore checks debug_lockdep_rcu_enabled() both before and after checking the condition, thus avoiding both sets of false-positive error reports.
--- include/linux/rcupdate.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
include/linux/rcupdate.h +8 -1
@@ -350,11 +350,18 @@ static inline int rcu_read_lock_any_held(void)* RCU_LOCKDEP_WARN - emit lockdep splat if specified condition is met * @c: condition to check * @s: informative message +* +* This checks debug_lockdep_rcu_enabled() before checking (c) to +* prevent early boot splats due to lockdep not yet being initialized, +* and rechecks it after checking (c) to prevent false-positive splats +* due to races with lockdep being disabled. See commit 3066820034b5dd +* ("rcu: Reject RCU_LOCKDEP_WARN() false positives") for more detail. */ #define RCU_LOCKDEP_WARN (c, s) \ do { \ static bool __section(".data.unlikely") __warned; \ - if ((c) && debug_lockdep_rcu_enabled() && !__warned) { \ + if (debug_lockdep_rcu_enabled() && (c) && \ + debug_lockdep_rcu_enabled() && !__warned) { \ __warned = true; \ lockdep_rcu_suspicious(__FILE__, __LINE__, s); \ } \
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 549/885 rcu: Suppress smp_processor_id() complaint in synchronize_rcu_expedited_wait()
In reply to Greg Kroah-HartmanFrom: Paul E. McKenney <[email protected]>
[ Upstream commit 2d7f00b2f01301d6e41fd4a28030dab0442265be ]
The normal grace period's RCU CPU stall warnings are invoked from the scheduling-clock interrupt handler, and can thus invoke smp_processor_id() with impunity, which allows them to directly invoke dump_cpu_task(). In contrast, the expedited grace period's RCU CPU stall warnings are invoked from process context, which causes the dump_cpu_task() function's calls to smp_processor_id() to complain bitterly in debug kernels.
This commit therefore causes synchronize_rcu_expedited_wait() to disable preemption around its call to dump_cpu_task().
--- kernel/rcu/tree_exp.h | 2 ++ 1 file changed, 2 insertions(+)
kernel/rcu/tree_exp.h +2 -0
@@ -667,7 +667,9 @@ static void synchronize_rcu_expedited_wait(void) mask =leaf_node_cpu_bit (rnp, cpu);if (!(READ_ONCE (rnp->expmask) & mask))continue ; +preempt_disable ();// For smp_processor_id() in dump_cpu_task(). dump_cpu_task (cpu); +preempt_enable (); } } jiffies_stall =3 *rcu_exp_jiffies_till_stall_check () +3 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 550/885 srcu: Delegate work to the boot cpu if using SRCU_SIZE_SMALL
In reply to Greg Kroah-HartmanFrom: Pingfan Liu <[email protected]>
[ Upstream commit 7f24626d6dd844bfc6d1f492d214d29c86d02550 ]
Commit 994f706872e6 ("srcu: Make Tree SRCU able to operate without snp_node array") assumes that cpu 0 is always online. However, there really are situations when some other CPU is the boot CPU, for example, when booting a kdump kernel with the maxcpus=1 boot parameter.
On PowerPC, the kdump kernel can hang as follows:
...
[ 1.740036] systemd[1]: Hostname set to <xyz.com> [ 243.686240] INFO: task systemd:1 blocked for more than 122 seconds. [ 243.686264] Not tainted 6.1.0-rc1 #1 [ 243.686272] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. [ 243.686281] task:systemd state:D stack:0 pid:1 ppid:0 flags:0x00042000 [ 243.686296] Call Trace: [ 243.686301] [c000000016657640] [c000000016657670] 0xc000000016657670 (unreliable) [ 243.686317] [c000000016657830] [c00000001001dec0] __switch_to+0x130/0x220 [ 243.686333] [c000000016657890] [c000000010f607b8] __schedule+0x1f8/0x580 [ 243.686347] [c000000016657940] [c000000010f60bb4] schedule+0x74/0x140 [ 243.686361] [c0000000166579b0] [c000000010f699b8] schedule_timeout+0x168/0x1c0 [ 243.686374] [c000000016657a80] [c000000010f61de8] __wait_for_common+0x148/0x360 [ 243.686387] [c000000016657b20] [c000000010176bb0] __flush_work.isra.0+0x1c0/0x3d0 [ 243.686401] [c000000016657bb0] [c0000000105f2768] fsnotify_wait_marks_destroyed+0x28/0x40 [ 243.686415] [c000000016657bd0] [c0000000105f21b8] fsnotify_destroy_group+0x68/0x160 [ 243.686428] [c000000016657c40] [c0000000105f6500] inotify_release+0x30/0xa0 [ 243.686440] [c000000016657cb0] [c0000000105751a8] __fput+0xc8/0x350 [ 243.686452] [c000000016657d00] [c00000001017d524] task_work_run+0xe4/0x170 [ 243.686464] [c000000016657d50] [c000000010020e94] do_notify_resume+0x134/0x140 [ 243.686478] [c000000016657d80] [c00000001002eb18] interrupt_exit_user_prepare_main+0x198/0x270 [ 243.686493] [c000000016657de0] [c00000001002ec60] syscall_exit_prepare+0x70/0x180 [ 243.686505] [c000000016657e10] [c00000001000bf7c] system_call_vectored_common+0xfc/0x280 [ 243.686520] --- interrupt: 3000 at 0x7fffa47d5ba4 [ 243.686528] NIP: 00007fffa47d5ba4 LR: 0000000000000000 CTR: 0000000000000000 [ 243.686538] REGS: c000000016657e80 TRAP: 3000 Not tainted (6.1.0-rc1) [ 243.686548] MSR: 800000000000d033 <SF,EE,PR,ME,IR,DR,RI,LE> CR: 42044440 XER: 00000000 [ 243.686572] IRQMASK: 0 [ 243.686572] GPR00: 0000000000000006 00007ffffa606710 00007fffa48e7200 0000000000000000 [ 243.686572] GPR04: 0000000000000002 000000000000000a 0000000000000000 0000000000000001 [ 243.686572] GPR08: 000001000c172dd0 0000000000000000 0000000000000000 0000000000000000 [ 243.686572] GPR12: 0000000000000000 00007fffa4ff4bc0 0000000000000000 0000000000000000 [ 243.686572] GPR16: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 [ 243.686572] GPR20: 0000000132dfdc50 000000000000000e 0000000000189375 0000000000000000 [ 243.686572] GPR24: 00007ffffa606ae0 0000000000000005 000001000c185490 000001000c172570 [ 243.686572] GPR28: 000001000c172990 000001000c184850 000001000c172e00 00007fffa4fedd98 [ 243.686683] NIP [00007fffa47d5ba4] 0x7fffa47d5ba4 [ 243.686691] LR [0000000000000000] 0x0 [ 243.686698] --- interrupt: 3000 [ 243.686708] INFO: task kworker/u16:1:24 blocked for more than 122 seconds. [ 243.686717] Not tainted 6.1.0-rc1 #1 [ 243.686724] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. [ 243.686733] task:kworker/u16:1 state:D stack:0 pid:24 ppid:2 flags:0x00000800 [ 243.686747] Workqueue: events_unbound fsnotify_mark_destroy_workfn [ 243.686758] Call Trace: [ 243.686762] [c0000000166736e0] [c00000004fd91000] 0xc00000004fd91000 (unreliable) [ 243.686775] [c0000000166738d0] [c00000001001dec0] __switch_to+0x130/0x220 [ 243.686788] [c000000016673930] [c000000010f607b8] __schedule+0x1f8/0x580 [ 243.686801] [c0000000166739e0] [c000000010f60bb4] schedule+0x74/0x140 [ 243.686814] [c000000016673a50] [c000000010f699b8] schedule_timeout+0x168/0x1c0 [ 243.686827] [c000000016673b20] [c000000010f61de8] __wait_for_common+0x148/0x360 [ 243.686840] [c000000016673bc0] [c000000010210840] __synchronize_srcu.part.0+0xa0/0xe0 [ 243.686855] [c000000016673c30] [c0000000105f2c64] fsnotify_mark_destroy_workfn+0xc4/0x1a0 [ 243.686868] [c000000016673ca0] [c000000010174ea8] process_one_work+0x2a8/0x570 [ 243.686882] [c000000016673d40] [c000000010175208] worker_thread+0x98/0x5e0 [ 243.686895] [c000000016673dc0] [c0000000101828d4] kthread+0x124/0x130 [ 243.686908] [c000000016673e10] [c00000001000cd40] ret_from_kernel_thread+0x5c/0x64 [ 366.566274] INFO: task systemd:1 blocked for more than 245 seconds. [ 366.566298] Not tainted 6.1.0-rc1 #1 [ 366.566305] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. [ 366.566314] task:systemd state:D stack:0 pid:1 ppid:0 flags:0x00042000 [ 366.566329] Call Trace:
...
The above splat occurs because PowerPC really does use maxcpus=1 instead of nr_cpus=1 in the kernel command line. Consequently, the (quite possibly non-zero) kdump CPU is the only online CPU in the kdump kernel. SRCU unconditionally queues a sdp->work on cpu 0, for which no worker thread has been created, so sdp->work will be never executed and __synchronize_srcu() will never be completed.
This commit therefore replaces CPU ID 0 with get_boot_cpu_id() in key places in Tree SRCU. Since the CPU indicated by get_boot_cpu_id() is guaranteed to be online, this avoids the above splat.
--- kernel/rcu/srcutree.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
kernel/rcu/srcutree.c +5 -4
@@ -663,7 +663,7 @@ static void srcu_gp_start(struct srcu_struct *ssp)int state;if (smp_load_acquire (&ssp->srcu_size_state) <SRCU_SIZE_WAIT_BARRIER ) - sdp =per_cpu_ptr (ssp->sda,0 ); + sdp =per_cpu_ptr (ssp->sda,get_boot_cpu_id ());else sdp =this_cpu_ptr (ssp->sda);lockdep_assert_held (&ACCESS_PRIVATE (ssp, lock));
@@ -774,7 +774,8 @@ static void srcu_gp_end(struct srcu_struct *ssp)/* Initiate callback invocation as needed. */ ss_state =smp_load_acquire (&ssp->srcu_size_state);if (ss_state <SRCU_SIZE_WAIT_BARRIER ) { -srcu_schedule_cbs_sdp (per_cpu_ptr (ssp->sda,0 ), cbdelay); +srcu_schedule_cbs_sdp (per_cpu_ptr (ssp->sda,get_boot_cpu_id ()), + cbdelay); }else { idx =rcu_seq_ctr (gpseq) %ARRAY_SIZE (snp->srcu_have_cbs);srcu_for_each_node_breadth_first (ssp, snp) {
@@ -1093,7 +1094,7 @@ static unsigned long srcu_gp_start_if_needed(struct srcu_struct *ssp, idx =srcu_read_lock (ssp); ss_state =smp_load_acquire (&ssp->srcu_size_state);if (ss_state <SRCU_SIZE_WAIT_CALL ) - sdp =per_cpu_ptr (ssp->sda,0 ); + sdp =per_cpu_ptr (ssp->sda,get_boot_cpu_id ());else sdp =raw_cpu_ptr (ssp->sda);spin_lock_irqsave_sdp_contention (sdp, &flags);
@@ -1429,7 +1430,7 @@ void srcu_barrier(struct srcu_struct *ssp) idx =srcu_read_lock (ssp);if (smp_load_acquire (&ssp->srcu_size_state) <SRCU_SIZE_WAIT_BARRIER ) -srcu_barrier_one_cpu (ssp,per_cpu_ptr (ssp->sda,0 )); +srcu_barrier_one_cpu (ssp,per_cpu_ptr (ssp->sda,get_boot_cpu_id ()));else for_each_possible_cpu (cpu)srcu_barrier_one_cpu (ssp,per_cpu_ptr (ssp->sda, cpu));
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 551/885 rcu-tasks: Make rude RCU-Tasks work well with CPU hotplug
In reply to Greg Kroah-HartmanFrom: Zqiang <[email protected]>
[ Upstream commit ea5c8987fef20a8cca07e428aa28bc64649c5104 ]
The synchronize_rcu_tasks_rude() function invokes rcu_tasks_rude_wait_gp() to wait one rude RCU-tasks grace period. The rcu_tasks_rude_wait_gp() function in turn checks if there is only a single online CPU. If so, it will immediately return, because a call to synchronize_rcu_tasks_rude() is by definition a grace period on a single-CPU system. (We could have blocked!)
Unfortunately, this check uses num_online_cpus() without synchronization, which can result in too-short grace periods. To see this, consider the following scenario:
CPU0 CPU1 (going offline)
migration/1 task:
cpu_stopper_thread
-> take_cpu_down
-> _cpu_disable
(dec __num_online_cpus)
->cpuhp_invoke_callback
preempt_disable
access old_data0
task1
del old_data0 .....
synchronize_rcu_tasks_rude()
task1 schedule out
....
task2 schedule in
rcu_tasks_rude_wait_gp()
->__num_online_cpus == 1
->return ....
task1 schedule in
->free old_data0
preempt_enable
When CPU1 decrements __num_online_cpus, its value becomes 1. However, CPU1 has not finished going offline, and will take one last trip through the scheduler and the idle loop before it actually stops executing instructions. Because synchronize_rcu_tasks_rude() is mostly used for tracing, and because both the scheduler and the idle loop can be traced, this means that CPU0's prematurely ended grace period might disrupt the tracing on CPU1. Given that this disruption might include CPU1 executing instructions in memory that was just now freed (and maybe reallocated), this is a matter of some concern.
This commit therefore removes that problematic single-CPU check from the rcu_tasks_rude_wait_gp() function. This dispenses with the single-CPU optimization, but there is no evidence indicating that this optimization is important. In addition, synchronize_rcu_tasks_generic() contains a similar optimization (albeit only for early boot), which also splats. (As in exactly why are you invoking synchronize_rcu_tasks_rude() so early in boot, anyway???)
It is OK for the synchronize_rcu_tasks_rude() function's check to be unsynchronized because the only times that this check can evaluate to true is when there is only a single CPU running with preemption disabled.
While in the area, this commit also fixes a minor bug in which a call to synchronize_rcu_tasks_rude() would instead be attributed to synchronize_rcu_tasks().
[ paulmck: Add "synchronize_" prefix and "()" suffix. ]
--- kernel/rcu/tasks.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
kernel/rcu/tasks.h +3 -5
@@ -560,8 +560,9 @@ static int __noreturn rcu_tasks_kthread(void *arg)static void synchronize_rcu_tasks_generic (struct rcu_tasks *rtp) {/* Complain if the scheduler has not started. */ -WARN_ONCE (rcu_scheduler_active ==RCU_SCHEDULER_INACTIVE , -"synchronize_rcu_tasks called too soon" ); +if (WARN_ONCE (rcu_scheduler_active ==RCU_SCHEDULER_INACTIVE , +"synchronize_%s() called too soon" , rtp->name)) +return ;// If the grace-period kthread is running, use it. if (READ_ONCE (rtp->kthread_ptr)) {
@@ -1064,9 +1065,6 @@ static void rcu_tasks_be_rude(struct work_struct *work)// Wait for one rude RCU-tasks grace period. static void rcu_tasks_rude_wait_gp (struct rcu_tasks *rtp) { -if (num_online_cpus () <=1 ) -return ;// Fastpath for only one CPU. - rtp->n_ipis +=cpumask_weight (cpu_online_mask);schedule_on_each_cpu (rcu_tasks_be_rude); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 552/885 rcu-tasks: Handle queue-shrink/callback-enqueue race condition
In reply to Greg Kroah-HartmanFrom: Zqiang <[email protected]>
[ Upstream commit a4fcfbee8f6274f9b3f9a71dd5b03e6772ce33f3 ]
The rcu_tasks_need_gpcb() determines whether or not: (1) There are callbacks needing another grace period, (2) There are callbacks ready to be invoked, and (3) It would be a good time to shrink back down to a single-CPU callback list. This third case is interesting because some other CPU might be adding new callbacks, which might suddenly make this a very bad time to be shrinking.
This is currently handled by requiring call_rcu_tasks_generic() to enqueue callbacks under the protection of rcu_read_lock() and requiring rcu_tasks_need_gpcb() to wait for an RCU grace period to elapse before finalizing the transition. This works well in practice.
Unfortunately, the current code assumes that a grace period whose end is detected by the poll_state_synchronize_rcu() in the second "if" condition actually ended before the earlier code counted the callbacks queued on CPUs other than CPU 0 (local variable "ncbsnz"). Given the current code, it is possible that a long-delayed call_rcu_tasks_generic() invocation will queue a callback on a non-zero CPU after these CPUs have had their callbacks counted and zero has been stored to ncbsnz. Such a callback would trigger the WARN_ON_ONCE() in the second "if" statement.
To see this, consider the following sequence of events:
o CPU 0 invokes rcu_tasks_one_gp(), and counts fewer than
rcu_task_collapse_lim callbacks. It sees at least one callback queued on some other CPU, thus setting ncbsnz to a non-zero value.
o CPU 1 invokes call_rcu_tasks_generic() and loads 42 from
->percpu_enqueue_lim. It therefore decides to enqueue its callback onto CPU 1's callback list, but is delayed.
o CPU 0 sees the rcu_task_cb_adjust is non-zero and that the number
of callbacks does not exceed rcu_task_collapse_lim. It therefore checks percpu_enqueue_lim, and sees that its value is greater than the value one. CPU 0 therefore starts the shift back to a single callback list. It sets ->percpu_enqueue_lim to 1, but CPU 1 has already read the old value of 42. It also gets a grace-period state value from get_state_synchronize_rcu().
o CPU 0 sees that ncbsnz is non-zero in its second "if" statement,
so it declines to finalize the shrink operation.
o CPU 0 again invokes rcu_tasks_one_gp(), and counts fewer than
rcu_task_collapse_lim callbacks. It also sees that there are no callback queued on any other CPU, and thus sets ncbsnz to zero.
o CPU 1 resumes execution and enqueues its callback onto its own
list. This invalidates the value of ncbsnz.
o CPU 0 sees the rcu_task_cb_adjust is non-zero and that the number
of callbacks does not exceed rcu_task_collapse_lim. It therefore checks percpu_enqueue_lim, but sees that its value is already
unity. It therefore does not get a new grace-period state value.
o CPU 0 sees that rcu_task_cb_adjust is non-zero, ncbsnz is zero,
and that poll_state_synchronize_rcu() says that the grace period has completed. it therefore finalizes the shrink operation, setting ->percpu_dequeue_lim to the value one.
o CPU 0 does a debug check, scanning the other CPUs' callback lists.
It sees that CPU 1's list has a callback, so it (rightly) triggers the WARN_ON_ONCE(). After all, the new value of ->percpu_dequeue_lim says to not bother looking at CPU 1's callback list, which means that this callback will never be invoked. This can result in hangs and maybe even OOMs.
Based on long experience with rcutorture, this is an extremely low-probability race condition, but it really can happen, especially in preemptible kernels or within guest OSes.
This commit therefore checks for completion of the grace period before counting callbacks. With this change, in the above failure scenario CPU 0 would know not to prematurely end the shrink operation because the grace period would not have completed before the count operation started.
[ paulmck: Adjust grace-period end rather than adding RCU reader. ] [ paulmck: Avoid spurious WARN_ON_ONCE() with ->percpu_dequeue_lim check. ]
--- kernel/rcu/tasks.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
kernel/rcu/tasks.h +8 -5
@@ -384,6 +384,7 @@ static int rcu_tasks_need_gpcb(struct rcu_tasks *rtp) {int cpu;unsigned long flags; +bool gpdone =poll_state_synchronize_rcu (rtp->percpu_dequeue_gpseq);long n;long ncbs =0 ;long ncbsnz =0 ;
@@ -425,21 +426,23 @@ static int rcu_tasks_need_gpcb(struct rcu_tasks *rtp)WRITE_ONCE (rtp->percpu_enqueue_shift,order_base_2 (nr_cpu_ids));smp_store_release (&rtp->percpu_enqueue_lim,1 ); rtp->percpu_dequeue_gpseq =get_state_synchronize_rcu (); + gpdone = false;pr_info ("Starting switch %s to CPU-0 callback queuing.\n" , rtp->name); }raw_spin_unlock_irqrestore (&rtp->cbs_gbl_lock, flags); } -if (rcu_task_cb_adjust && !ncbsnz && -poll_state_synchronize_rcu (rtp->percpu_dequeue_gpseq)) { +if (rcu_task_cb_adjust && !ncbsnz && gpdone) {raw_spin_lock_irqsave (&rtp->cbs_gbl_lock, flags);if (rtp->percpu_enqueue_lim < rtp->percpu_dequeue_lim) {WRITE_ONCE (rtp->percpu_dequeue_lim,1 );pr_info ("Completing switch %s to CPU-0 callback queuing.\n" , rtp->name); } -for (cpu = rtp->percpu_dequeue_lim; cpu < nr_cpu_ids; cpu++) { -struct rcu_tasks_percpu *rtpcp =per_cpu_ptr (rtp->rtpcpu, cpu); +if (rtp->percpu_dequeue_lim ==1 ) { +for (cpu = rtp->percpu_dequeue_lim; cpu < nr_cpu_ids; cpu++) { +struct rcu_tasks_percpu *rtpcp =per_cpu_ptr (rtp->rtpcpu, cpu); -WARN_ON_ONCE (rcu_segcblist_n_cbs (&rtpcp->cblist)); +WARN_ON_ONCE (rcu_segcblist_n_cbs (&rtpcp->cblist)); + } }raw_spin_unlock_irqrestore (&rtp->cbs_gbl_lock, flags); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 553/885 wifi: ath11k: debugfs: fix to work with multiple PCI devices
In reply to Greg Kroah-HartmanFrom: Kalle Valo <[email protected]>
[ Upstream commit 323d91d4684d238f6bc3693fed93caf795378fe0 ]
ath11k fails to load if there are multiple ath11k PCI devices with same name:
ath11k_pci 0000:01:00.0: Hardware name qcn9074 hw1.0
debugfs: Directory 'ath11k' with parent '/' already present! ath11k_pci 0000:01:00.0: failed to create ath11k debugfs ath11k_pci 0000:01:00.0: failed to create soc core: -17 ath11k_pci 0000:01:00.0: failed to init core: -17
ath11k_pci: probe of 0000:01:00.0 failed with error -17
Fix this by creating a directory for each ath11k device using schema <bus>-<devname>, for example "pci-0000:06:00.0". This directory created under the top-level ath11k directory, for example /sys/kernel/debug/ath11k.
The reference to the toplevel ath11k directory is not stored anymore within ath11k, instead it's retrieved using debugfs_lookup(). If the directory does not exist it will be created. After the last directory from the ath11k directory is removed, for example when doing rmmod ath11k, the empty ath11k directory is left in place, it's a minor cosmetic issue anyway.
Here's an example hierarchy with one WCN6855:
ath11k
`-- pci-0000:06:00.0
|-- mac0
| |-- dfs_block_radar_events
| |-- dfs_simulate_radar
| |-- ext_rx_stats
| |-- ext_tx_stats
| |-- fw_dbglog_config
| |-- fw_stats
| | |-- beacon_stats
| | |-- pdev_stats
| | `-- vdev_stats
| |-- htt_stats
| |-- htt_stats_reset
| |-- htt_stats_type
| `-- pktlog_filter
|-- simulate_fw_crash
`-- soc_dp_statsI didn't have a test setup where I could connect multiple ath11k devices to the same the host, so I have only tested this with one device.
Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3.6510.9
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.5.0.1-01208-QCAHKSWPL_SILICONZ-1
Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.5.0.1-01208-QCAHKSWPL_SILICONZ-1
--- drivers/net/wireless/ath/ath11k/core.h | 1 - drivers/net/wireless/ath/ath11k/debugfs.c | 48 +++++++++++++++++++---- 2 files changed, 40 insertions(+), 9 deletions(-)
drivers/net/wireless/ath/ath11k/core.h +0 -1
@@ -912,7 +912,6 @@ struct ath11k_base {enum ath11k_dfs_region dfs_region;#ifdef CONFIG_ATH11K_DEBUGFS struct dentry *debugfs_soc; -struct dentry *debugfs_ath11k;#endif struct ath11k_soc_dp_stats soc_stats;
drivers/net/wireless/ath/ath11k/debugfs.c +40 -8
65 lines not on this page · raw message
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 554/885 thermal: intel: Fix unsigned comparison with less than zero
In reply to Greg Kroah-HartmanFrom: Yang Li <[email protected]>
[ Upstream commit e7fcfe67f9f410736b758969477b17ea285e8e6c ]
The return value from the call to intel_tcc_get_tjmax() is int, which can be a negative error code. However, the return value is being assigned to an u32 variable 'tj_max', so making 'tj_max' an int.
Eliminate the following warning:
./drivers/thermal/intel/intel_soc_dts_iosf.c:394:5-11: WARNING: Unsigned expression compared with zero: tj_max < 0
--- drivers/thermal/intel/intel_soc_dts_iosf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/intel/intel_soc_dts_iosf.c +1 -1
@@ -405,7 +405,7 @@ struct intel_soc_dts_sensors *intel_soc_dts_iosf_init( {struct intel_soc_dts_sensors *sensors;bool notification; -u32 tj_max; +int tj_max;int ret;int i;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 555/885 timers: Prevent union confusion from unexpected restart_syscall()
In reply to Greg Kroah-HartmanFrom: Jann Horn <[email protected]>
[ Upstream commit 9f76d59173d9d146e96c66886b671c1915a5c5e5 ]
The nanosleep syscalls use the restart_block mechanism, with a quirk:
The type and rmtp/compat_rmtp fields are set up unconditionally on syscall entry, while the rest of the restart_block is only set up in the unlikely case that the syscall is actually interrupted by a signal (or pseudo-signal) that doesn't have a signal handler.
If the restart_block was set up by a previous syscall (futex(..., FUTEX_WAIT, ...) or poll()) and hasn't been invalidated somehow since then, this will clobber some of the union fields used by futex_wait_restart() and do_restart_poll().
If userspace afterwards wrongly calls the restart_syscall syscall, futex_wait_restart()/do_restart_poll() will read struct fields that have been clobbered.
This doesn't actually lead to anything particularly interesting because none of the union fields contain trusted kernel data, and futex(..., FUTEX_WAIT, ...) and poll() aren't syscalls where it makes much sense to apply seccomp filters to their arguments.
So the current consequences are just of the "if userspace does bad stuff, it can damage itself, and that's not a problem" flavor.
But still, it seems like a hazard for future developers, so invalidate the restart_block when partly setting it up in the nanosleep syscalls.
--- kernel/time/hrtimer.c | 2 ++ kernel/time/posix-stubs.c | 2 ++ kernel/time/posix-timers.c | 2 ++ 3 files changed, 6 insertions(+)
kernel/time/hrtimer.c +2 -0
@@ -2126,6 +2126,7 @@ SYSCALL_DEFINE2(nanosleep, struct __kernel_timespec __user *, rqtp,if (!timespec64_valid (&tu))return -EINVAL ; + current->restart_block.fn = do_no_restart_syscall; current->restart_block.nanosleep.type = rmtp ?TT_NATIVE :TT_NONE ; current->restart_block.nanosleep.rmtp = rmtp; return hrtimer_nanosleep(timespec64_to_ktime(tu), HRTIMER_MODE_REL,
@@ -2147,6 +2148,7 @@ SYSCALL_DEFINE2(nanosleep_time32, struct old_timespec32 __user *, rqtp,if (!timespec64_valid (&tu))return -EINVAL ; + current->restart_block.fn = do_no_restart_syscall; current->restart_block.nanosleep.type = rmtp ?TT_COMPAT :TT_NONE ; current->restart_block.nanosleep.compat_rmtp = rmtp; return hrtimer_nanosleep(timespec64_to_ktime(tu), HRTIMER_MODE_REL,
kernel/time/posix-stubs.c +2 -0
@@ -147,6 +147,7 @@ SYSCALL_DEFINE4(clock_nanosleep, const clockid_t, which_clock, int, flags,return -EINVAL ;if (flags &TIMER_ABSTIME ) rmtp =NULL ; + current->restart_block.fn = do_no_restart_syscall; current->restart_block.nanosleep.type = rmtp ?TT_NATIVE :TT_NONE ; current->restart_block.nanosleep.rmtp = rmtp; texp =timespec64_to_ktime (t);
@@ -240,6 +241,7 @@ SYSCALL_DEFINE4(clock_nanosleep_time32, clockid_t, which_clock, int, flags,return -EINVAL ;if (flags &TIMER_ABSTIME ) rmtp =NULL ; + current->restart_block.fn = do_no_restart_syscall; current->restart_block.nanosleep.type = rmtp ?TT_COMPAT :TT_NONE ; current->restart_block.nanosleep.compat_rmtp = rmtp; texp =timespec64_to_ktime (t);
kernel/time/posix-timers.c +2 -0
@@ -1270,6 +1270,7 @@ SYSCALL_DEFINE4(clock_nanosleep, const clockid_t, which_clock, int, flags,return -EINVAL ;if (flags &TIMER_ABSTIME ) rmtp =NULL ; + current->restart_block.fn = do_no_restart_syscall; current->restart_block.nanosleep.type = rmtp ?TT_NATIVE :TT_NONE ; current->restart_block.nanosleep.rmtp = rmtp;
@@ -1297,6 +1298,7 @@ SYSCALL_DEFINE4(clock_nanosleep_time32, clockid_t, which_clock, int, flags,return -EINVAL ;if (flags &TIMER_ABSTIME ) rmtp =NULL ; + current->restart_block.fn = do_no_restart_syscall; current->restart_block.nanosleep.type = rmtp ?TT_COMPAT :TT_NONE ; current->restart_block.nanosleep.compat_rmtp = rmtp;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 556/885 x86/bugs: Reset speculation control settings on init
In reply to Greg Kroah-HartmanFrom: Breno Leitao <[email protected]>
[ Upstream commit 0125acda7d76b943ca55811df40ed6ec0ecf670f ]
Currently, x86_spec_ctrl_base is read at boot time and speculative bits are set if Kconfig items are enabled. For example, IBRS is enabled if CONFIG_CPU_IBRS_ENTRY is configured, etc. These MSR bits are not cleared if the mitigations are disabled.
This is a problem when kexec-ing a kernel that has the mitigation disabled from a kernel that has the mitigation enabled. In this case, the MSR bits are not cleared during the new kernel boot. As a result, this might have some performance degradation that is hard to pinpoint.
This problem does not happen if the machine is (hard) rebooted because the bit will be cleared by default.
[ bp: Massage. ]
--- arch/x86/include/asm/msr-index.h | 4 ++++ arch/x86/kernel/cpu/bugs.c | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-)
arch/x86/include/asm/msr-index.h +4 -0
@@ -54,6 +54,10 @@#define SPEC_CTRL_RRSBA_DIS_S_SHIFT 6/* Disable RRSBA behavior */ #define SPEC_CTRL_RRSBA_DIS_S BIT(SPEC_CTRL_RRSBA_DIS_S_SHIFT) +/* A mask for bits which the kernel toggles when controlling mitigations */ +#define SPEC_CTRL_MITIGATIONS_MASK (SPEC_CTRL_IBRS | SPEC_CTRL_STIBP | SPEC_CTRL_SSBD \ + | SPEC_CTRL_RRSBA_DIS_S) +#define MSR_IA32_PRED_CMD 0x00000049/* Prediction Command */ #define PRED_CMD_IBPB BIT(0)/* Indirect Branch Prediction Barrier */
arch/x86/kernel/cpu/bugs.c +9 -1
@@ -144,9 +144,17 @@ void __init check_bugs(void)* have unknown values. AMD64_LS_CFG MSR is cached in the early AMD * init code as it is not enumerated and depends on the family. */ -if (boot_cpu_has (X86_FEATURE_MSR_SPEC_CTRL )) +if (cpu_feature_enabled (X86_FEATURE_MSR_SPEC_CTRL )) {rdmsrl (MSR_IA32_SPEC_CTRL , x86_spec_ctrl_base); +/* +* Previously running kernel (kexec), may have some controls +* turned ON. Clear them and let the mitigations setup below +* rediscover them based on configuration. +*/ + x86_spec_ctrl_base &= ~SPEC_CTRL_MITIGATIONS_MASK ; + } +/* Select the proper CPU mitigations before patching alternatives: */ spectre_v1_select_mitigation ();spectre_v2_select_mitigation ();
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 557/885 bpftool: Always disable stack protection for BPF objects
In reply to Greg Kroah-HartmanFrom: Holger Hoffstätte <[email protected]>
[ Upstream commit 878625e1c7a10dfbb1fdaaaae2c4d2a58fbce627 ]
When the clang toolchain has stack protection enabled in order to be consistent with gcc - which just happens to be the case on Gentoo - the bpftool build fails:
[...]
clang \
-I. \
-I/tmp/portage/dev-util/bpftool-6.0.12/work/linux-6.0/tools/include/uapi/ \
-I/tmp/portage/dev-util/bpftool-6.0.12/work/linux-6.0/tools/bpf/bpftool/bootstrap/libbpf/include \
-g -O2 -Wall -target bpf -c skeleton/pid_iter.bpf.c -o pid_iter.bpf.o
clang \
-I. \
-I/tmp/portage/dev-util/bpftool-6.0.12/work/linux-6.0/tools/include/uapi/ \
-I/tmp/portage/dev-util/bpftool-6.0.12/work/linux-6.0/tools/bpf/bpftool/bootstrap/libbpf/include \
-g -O2 -Wall -target bpf -c skeleton/profiler.bpf.c -o profiler.bpf.o
skeleton/profiler.bpf.c:40:14: error: A call to built-in function '__stack_chk_fail' is not supported.
int BPF_PROG(fentry_XXX)
^
skeleton/profiler.bpf.c:94:14: error: A call to built-in function '__stack_chk_fail' is not supported.
int BPF_PROG(fexit_XXX)
^ 2 errors generated.
[...]
Since stack-protector makes no sense for the BPF bits just unconditionally disable it.
--- tools/bpf/bpftool/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/bpf/bpftool/Makefile +2 -1
@@ -187,7 +187,8 @@ $(OUTPUT)%.bpf.o: skeleton/%.bpf.c $(OUTPUT)vmlinux.h $(LIBBPF_BOOTSTRAP) -I$(or $(OUTPUT),.) \ -I$(srctree)/tools/include/uapi/ \ -I$(LIBBPF_BOOTSTRAP_INCLUDE) \ - -g -O2 -Wall -target bpf -c $< -o $@ + -g -O2 -Wall -fno-stack-protector \ + -target bpf -c $< -o $@ $(Q)$(LLVM_STRIP) -g $@ $(OUTPUT)%.skel.h: $(OUTPUT)%.bpf.o $(BPFTOOL_BOOTSTRAP)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 558/885 wifi: brcmfmac: ensure CLM version is null-terminated to prevent stack-out-of-bounds
In reply to Greg Kroah-HartmanFrom: Jisoo Jang <[email protected]>
[ Upstream commit 660145d708be52f946a82e5b633c020f58f996de ]
Fix a stack-out-of-bounds read in brcmfmac that occurs when 'buf' that is not null-terminated is passed as an argument of strreplace() in brcmf_c_preinit_dcmds(). This buffer is filled with a CLM version string by memcpy() in brcmf_fil_iovar_data_get(). Ensure buf is null-terminated.
Found by a modified version of syzkaller.
[ 33.004414][ T1896] brcmfmac: brcmf_c_process_clm_blob: no clm_blob available (err=-2), device may have limited channels available [ 33.013486][ T1896] brcmfmac: brcmf_c_preinit_dcmds: Firmware: BCM43236/3 wl0: Nov 30 2011 17:33:42 version 5.90.188.22 [ 33.021554][ T1896] ================================================================== [ 33.022379][ T1896] BUG: KASAN: stack-out-of-bounds in strreplace+0xf2/0x110 [ 33.023122][ T1896] Read of size 1 at addr ffffc90001d6efc8 by task kworker/0:2/1896 [ 33.023852][ T1896] [ 33.024096][ T1896] CPU: 0 PID: 1896 Comm: kworker/0:2 Tainted: G O 5.14.0+ #132 [ 33.024927][ T1896] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014 [ 33.026065][ T1896] Workqueue: usb_hub_wq hub_event [ 33.026581][ T1896] Call Trace: [ 33.026896][ T1896] dump_stack_lvl+0x57/0x7d [ 33.027372][ T1896] print_address_description.constprop.0.cold+0xf/0x334 [ 33.028037][ T1896] ? strreplace+0xf2/0x110 [ 33.028403][ T1896] ? strreplace+0xf2/0x110 [ 33.028807][ T1896] kasan_report.cold+0x83/0xdf [ 33.029283][ T1896] ? strreplace+0xf2/0x110 [ 33.029666][ T1896] strreplace+0xf2/0x110 [ 33.029966][ T1896] brcmf_c_preinit_dcmds+0xab1/0xc40 [ 33.030351][ T1896] ? brcmf_c_set_joinpref_default+0x100/0x100 [ 33.030787][ T1896] ? rcu_read_lock_sched_held+0xa1/0xd0 [ 33.031223][ T1896] ? rcu_read_lock_bh_held+0xb0/0xb0 [ 33.031661][ T1896] ? lock_acquire+0x19d/0x4e0 [ 33.032091][ T1896] ? find_held_lock+0x2d/0x110 [ 33.032605][ T1896] ? brcmf_usb_deq+0x1a7/0x260 [ 33.033087][ T1896] ? brcmf_usb_rx_fill_all+0x5a/0xf0 [ 33.033582][ T1896] brcmf_attach+0x246/0xd40 [ 33.034022][ T1896] ? wiphy_new_nm+0x1476/0x1d50 [ 33.034383][ T1896] ? kmemdup+0x30/0x40 [ 33.034722][ T1896] brcmf_usb_probe+0x12de/0x1690 [ 33.035223][ T1896] ? brcmf_usbdev_qinit.constprop.0+0x470/0x470 [ 33.035833][ T1896] usb_probe_interface+0x25f/0x710 [ 33.036315][ T1896] really_probe+0x1be/0xa90 [ 33.036656][ T1896] __driver_probe_device+0x2ab/0x460 [ 33.037026][ T1896] ? usb_match_id.part.0+0x88/0xc0 [ 33.037383][ T1896] driver_probe_device+0x49/0x120 [ 33.037790][ T1896] __device_attach_driver+0x18a/0x250 [ 33.038300][ T1896] ? driver_allows_async_probing+0x120/0x120 [ 33.038986][ T1896] bus_for_each_drv+0x123/0x1a0 [ 33.039906][ T1896] ? bus_rescan_devices+0x20/0x20 [ 33.041412][ T1896] ? lockdep_hardirqs_on_prepare+0x273/0x3e0 [ 33.041861][ T1896] ? trace_hardirqs_on+0x1c/0x120 [ 33.042330][ T1896] __device_attach+0x207/0x330 [ 33.042664][ T1896] ? device_bind_driver+0xb0/0xb0 [ 33.043026][ T1896] ? kobject_uevent_env+0x230/0x12c0 [ 33.043515][ T1896] bus_probe_device+0x1a2/0x260 [ 33.043914][ T1896] device_add+0xa61/0x1ce0 [ 33.044227][ T1896] ? __mutex_unlock_slowpath+0xe7/0x660 [ 33.044891][ T1896] ? __fw_devlink_link_to_suppliers+0x550/0x550 [ 33.045531][ T1896] usb_set_configuration+0x984/0x1770 [ 33.046051][ T1896] ? kernfs_create_link+0x175/0x230 [ 33.046548][ T1896] usb_generic_driver_probe+0x69/0x90 [ 33.046931][ T1896] usb_probe_device+0x9c/0x220 [ 33.047434][ T1896] really_probe+0x1be/0xa90 [ 33.047760][ T1896] __driver_probe_device+0x2ab/0x460 [ 33.048134][ T1896] driver_probe_device+0x49/0x120 [ 33.048516][ T1896] __device_attach_driver+0x18a/0x250 [ 33.048910][ T1896] ? driver_allows_async_probing+0x120/0x120 [ 33.049437][ T1896] bus_for_each_drv+0x123/0x1a0 [ 33.049814][ T1896] ? bus_rescan_devices+0x20/0x20 [ 33.050164][ T1896] ? lockdep_hardirqs_on_prepare+0x273/0x3e0 [ 33.050579][ T1896] ? trace_hardirqs_on+0x1c/0x120 [ 33.050936][ T1896] __device_attach+0x207/0x330 [ 33.051399][ T1896] ? device_bind_driver+0xb0/0xb0 [ 33.051888][ T1896] ? kobject_uevent_env+0x230/0x12c0 [ 33.052314][ T1896] bus_probe_device+0x1a2/0x260 [ 33.052688][ T1896] device_add+0xa61/0x1ce0 [ 33.053121][ T1896] ? __fw_devlink_link_to_suppliers+0x550/0x550 [ 33.053568][ T1896] usb_new_device.cold+0x463/0xf66 [ 33.053953][ T1896] ? hub_disconnect+0x400/0x400 [ 33.054313][ T1896] ? rwlock_bug.part.0+0x90/0x90 [ 33.054661][ T1896] ? lockdep_hardirqs_on_prepare+0x273/0x3e0 [ 33.055094][ T1896] hub_event+0x10d5/0x3330 [ 33.055530][ T1896] ? hub_port_debounce+0x280/0x280 [ 33.055934][ T1896] ? __lock_acquire+0x1671/0x5790 [ 33.056387][ T1896] ? wq_calc_node_cpumask+0x170/0x2a0 [ 33.056924][ T1896] ? lock_release+0x640/0x640 [ 33.057383][ T1896] ? rcu_read_lock_sched_held+0xa1/0xd0 [ 33.057916][ T1896] ? rcu_read_lock_bh_held+0xb0/0xb0 [ 33.058402][ T1896] ? lockdep_hardirqs_on_prepare+0x273/0x3e0 [ 33.059019][ T1896] process_one_work+0x873/0x13e0 [ 33.059488][ T1896] ? lock_release+0x640/0x640 [ 33.059932][ T1896] ? pwq_dec_nr_in_flight+0x320/0x320 [ 33.060446][ T1896] ? rwlock_bug.part.0+0x90/0x90 [ 33.060898][ T1896] worker_thread+0x8b/0xd10 [ 33.061348][ T1896] ? __kthread_parkme+0xd9/0x1d0 [ 33.061810][ T1896] ? process_one_work+0x13e0/0x13e0 [ 33.062288][ T1896] kthread+0x379/0x450 [ 33.062660][ T1896] ? _raw_spin_unlock_irq+0x24/0x30 [ 33.063148][ T1896] ? set_kthread_struct+0x100/0x100 [ 33.063606][ T1896] ret_from_fork+0x1f/0x30 [ 33.064070][ T1896] [ 33.064313][ T1896] [ 33.064545][ T1896] addr ffffc90001d6efc8 is located in stack of task kworker/0:2/1896 at offset 512 in frame: [ 33.065478][ T1896] brcmf_c_preinit_dcmds+0x0/0xc40 [ 33.065973][ T1896] [ 33.066191][ T1896] this frame has 4 objects: [ 33.066614][ T1896] [48, 56) 'ptr' [ 33.066618][ T1896] [80, 148) 'revinfo' [ 33.066957][ T1896] [192, 210) 'eventmask' [ 33.067338][ T1896] [256, 512) 'buf' [ 33.067742][ T1896] [ 33.068304][ T1896] Memory state around the buggy address: [ 33.068838][ T1896] ffffc90001d6ee80: f2 00 00 02 f2 f2 f2 f2 f2 00 00 00 00 00 00 00 [ 33.069545][ T1896] ffffc90001d6ef00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 33.070626][ T1896] >ffffc90001d6ef80: 00 00 00 00 00 00 00 00 00 f3 f3 f3 f3 f3 f3 f3 [ 33.072052][ T1896] ^ [ 33.073043][ T1896] ffffc90001d6f000: f3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 33.074230][ T1896] ffffc90001d6f080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 33.074914][ T1896] ================================================================== [ 33.075713][ T1896] Disabling lock debugging due to kernel taint
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c +4 -2
@@ -319,15 +319,17 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)if (err) {brcmf_dbg (TRACE ,"retrieving clmver failed, %d\n" , err); }else { + buf[sizeof (buf) -1 ] ='\0' ; clmver = (char *)buf; -/* store CLM version for adding it to revinfo debugfs file */ -memcpy (ifp->drvr->clmver, clmver,sizeof (ifp->drvr->clmver));/* Replace all newline/linefeed characters with space * character */ strreplace (clmver,'\n' ,' ' ); +/* store CLM version for adding it to revinfo debugfs file */ +memcpy (ifp->drvr->clmver, clmver,sizeof (ifp->drvr->clmver)); +brcmf_dbg (INFO ,"CLM version = %s\n" , clmver); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 559/885 wifi: mt7601u: fix an integer underflow
In reply to Greg Kroah-HartmanFrom: Jisoo Jang <[email protected]>
[ Upstream commit 803f3176c5df3b5582c27ea690f204abb60b19b9 ]
Fix an integer underflow that leads to a null pointer dereference in 'mt7601u_rx_skb_from_seg()'. The variable 'dma_len' in the URB packet could be manipulated, which could trigger an integer underflow of 'seg_len' in 'mt7601u_rx_process_seg()'. This underflow subsequently causes the 'bad_frame' checks in 'mt7601u_rx_skb_from_seg()' to be bypassed, eventually leading to a dereference of the pointer 'p', which is a null pointer.
Ensure that 'dma_len' is greater than 'min_seg_len'.
Found by a modified version of syzkaller.
KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f] CPU: 0 PID: 12 Comm: ksoftirqd/0 Tainted: G W O 5.14.0+ #139 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014 RIP: 0010:skb_add_rx_frag+0x143/0x370 Code: e2 07 83 c2 03 38 ca 7c 08 84 c9 0f 85 86 01 00 00 4c 8d 7d 08 44 89 68 08 48 b8 00 00 00 00 00 fc ff df 4c 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 cd 01 00 00 48 8b 45 08 a8 01 0f 85 3d 01 00 00 RSP: 0018:ffffc900000cfc90 EFLAGS: 00010202 RAX: dffffc0000000000 RBX: ffff888115520dc0 RCX: 0000000000000000 RDX: 0000000000000001 RSI: ffff8881118430c0 RDI: ffff8881118430f8 RBP: 0000000000000000 R08: 0000000000000e09 R09: 0000000000000010 R10: ffff888111843017 R11: ffffed1022308602 R12: 0000000000000000 R13: 0000000000000e09 R14: 0000000000000010 R15: 0000000000000008 FS: 0000000000000000(0000) GS:ffff88811a800000(0000)
knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000000004035af40 CR3: 00000001157f2000 CR4: 0000000000750ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
PKRU: 55555554
Call Trace: mt7601u_rx_tasklet+0xc73/0x1270 ? mt7601u_submit_rx_buf.isra.0+0x510/0x510 ? tasklet_action_common.isra.0+0x79/0x2f0 tasklet_action_common.isra.0+0x206/0x2f0 __do_softirq+0x1b5/0x880 ? tasklet_unlock+0x30/0x30 run_ksoftirqd+0x26/0x50 smpboot_thread_fn+0x34f/0x7d0 ? smpboot_register_percpu_thread+0x370/0x370 kthread+0x3a1/0x480 ? set_kthread_struct+0x120/0x120 ret_from_fork+0x1f/0x30 Modules linked in: 88XXau(O) 88x2bu(O) ---[ end trace 57f34f93b4da0f9b ]--- RIP: 0010:skb_add_rx_frag+0x143/0x370 Code: e2 07 83 c2 03 38 ca 7c 08 84 c9 0f 85 86 01 00 00 4c 8d 7d 08 44 89 68 08 48 b8 00 00 00 00 00 fc ff df 4c 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 cd 01 00 00 48 8b 45 08 a8 01 0f 85 3d 01 00 00 RSP: 0018:ffffc900000cfc90 EFLAGS: 00010202 RAX: dffffc0000000000 RBX: ffff888115520dc0 RCX: 0000000000000000 RDX: 0000000000000001 RSI: ffff8881118430c0 RDI: ffff8881118430f8 RBP: 0000000000000000 R08: 0000000000000e09 R09: 0000000000000010 R10: ffff888111843017 R11: ffffed1022308602 R12: 0000000000000000 R13: 0000000000000e09 R14: 0000000000000010 R15: 0000000000000008 FS: 0000000000000000(0000) GS:ffff88811a800000(0000)
knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000000004035af40 CR3: 00000001157f2000 CR4: 0000000000750ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
PKRU: 55555554
--- drivers/net/wireless/mediatek/mt7601u/dma.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt7601u/dma.c +2 -1
@@ -123,7 +123,8 @@ static u16 mt7601u_rx_next_seg_len(u8 *data, u32 data_len)if (data_len < min_seg_len ||WARN_ON_ONCE (!dma_len) ||WARN_ON_ONCE (dma_len +MT_DMA_HDRS > data_len) || -WARN_ON_ONCE (dma_len &0x3 )) +WARN_ON_ONCE (dma_len &0x3 ) || +WARN_ON_ONCE (dma_len < min_seg_len))return 0 ;return MT_DMA_HDRS + dma_len;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 560/885 inet: fix fast path in __inet_hash_connect()
In reply to Greg Kroah-HartmanFrom: Pietro Borrello <[email protected]>
[ Upstream commit 21cbd90a6fab7123905386985e3e4a80236b8714 ]
__inet_hash_connect() has a fast path taken if sk_head(&tb->owners) is equal to the sk parameter.sk_head() returns the hlist_entry() with respect to the sk_node field. However entries in the tb->owners list are inserted with respect to the sk_bind_node field with sk_add_bind_node().
Thus the check would never pass and the fast path never execute.
This fast path has never been executed or tested as this bug seems to be present since commit 1da177e4c3f4 ("Linux-2.6.12-rc2"), thus remove it to reduce code complexity.
--- net/ipv4/inet_hashtables.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
net/ipv4/inet_hashtables.c +1 -11
@@ -1008,17 +1008,7 @@ int __inet_hash_connect(struct inet_timewait_death_row *death_row,u32 index;if (port) { - head = &hinfo->bhash[inet_bhashfn (net, port, - hinfo->bhash_size)]; - tb =inet_csk (sk)->icsk_bind_hash; -spin_lock_bh (&head->lock); -if (sk_head (&tb->owners) == sk && !sk->sk_bind_node.next) { -inet_ehash_nolisten (sk,NULL ,NULL ); -spin_unlock_bh (&head->lock); -return 0 ; - } -spin_unlock (&head->lock); -/* No definite answer... Walk to established hash table */ +local_bh_disable (); ret =check_established (death_row, sk, port,NULL );local_bh_enable ();return ret;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 561/885 ice: restrict PTP HW clock freq adjustments to 100, 000, 000 PPB
In reply to Greg Kroah-HartmanFrom: Siddaraju DH <[email protected]>
[ Upstream commit 8aa4318c3a122b8670bc09af142de3872ca63b88 ]
The PHY provides only 39b timestamp. With current timing implementation, we discard lower 7b, leaving 32b timestamp. The driver reconstructs the full 64b timestamp by correlating the 32b timestamp with cached_time for performance. The reconstruction algorithm does both forward & backward interpolation.
The 32b timeval has overflow duration of 2^32 counts ~= 4.23 second. Due to interpolation in both direction, its now ~= 2.125 second IIRC, going with at least half a duration, the cached_time is updated with periodic thread of 1 second (worst-case) periodicity.
But the 1 second periodicity is based on System-timer. With PPB adjustments, if the 1588 timers increments at say double the rate, (2s in-place of 1s), the Nyquist rate/half duration sampling/update of cached_time with 1 second periodic thread will lead to incorrect interpolations.
Hence we should restrict the PPB adjustments to at least half duration of cached_time update which translates to 500,000,000 PPB.
Since the periodicity of the cached-time system thread can vary, it is good to have some buffer time and considering practicality of PPB adjustments, limiting the max_adj to 100,000,000.
--- drivers/net/ethernet/intel/ice/ice_ptp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_ptp.c +1 -1
@@ -2293,7 +2293,7 @@ static void ice_ptp_set_caps(struct ice_pf *pf)snprintf (info->name,sizeof (info->name) -1 ,"%s-%s-clk" ,dev_driver_string (dev),dev_name (dev)); info->owner =THIS_MODULE ; - info->max_adj =999999999 ; + info->max_adj =100000000 ; info->adjtime = ice_ptp_adjtime; info->adjfine = ice_ptp_adjfine; info->gettimex64 = ice_ptp_gettimex64;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 562/885 ice: add missing checks for PF vsi type
In reply to Greg Kroah-HartmanFrom: Jesse Brandeburg <[email protected]>
[ Upstream commit 6a8d013e904ad9a66706fcc926ec9993bed7d190 ]
There were a few places we had missed checking the VSI type to make sure it was definitely a PF VSI, before calling setup functions intended only for the PF VSI.
This doesn't fix any explicit bugs but cleans up the code in a few places and removes one explicit != vsi->type check that can be superseded by this code (it's a super set)
--- drivers/net/ethernet/intel/ice/ice_main.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +8 -9
@@ -6159,15 +6159,12 @@ int ice_vsi_cfg(struct ice_vsi *vsi) {int err; -if (vsi->netdev) { +if (vsi->netdev && vsi->type ==ICE_VSI_PF ) {ice_set_rx_mode (vsi->netdev); -if (vsi->type !=ICE_VSI_LB ) { - err =ice_vsi_vlan_setup (vsi); - -if (err) -return err; - } + err =ice_vsi_vlan_setup (vsi); +if (err) +return err; }ice_vsi_cfg_dcb_rings (vsi);
@@ -6348,7 +6345,7 @@ static int ice_up_complete(struct ice_vsi *vsi)if (vsi->port_info && (vsi->port_info->phy.link_info.link_info &ICE_AQ_LINK_UP ) && - vsi->netdev) { + vsi->netdev && vsi->type ==ICE_VSI_PF ) {ice_print_link_msg (vsi, true);netif_tx_start_all_queues (vsi->netdev);netif_carrier_on (vsi->netdev);
@@ -6360,7 +6357,9 @@ static int ice_up_complete(struct ice_vsi *vsi)* set the baseline so counters are ready when interface is up */ ice_update_eth_stats (vsi); -ice_service_task_schedule (pf); + +if (vsi->type ==ICE_VSI_PF ) +ice_service_task_schedule (pf);return 0 ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 563/885 ACPI: Dont build ACPICA with -Os
In reply to Greg Kroah-HartmanFrom: Mark Rutland <[email protected]>
[ Upstream commit 8f9e0a52810dd83406c768972d022c37e7a18f1f ]
The ACPICA code has been built with '-Os' since the beginning of git history, though there's no explanatory comment as to why.
This is unfortunate as GCC drops the alignment specificed by '-falign-functions=N' when '-Os' is used, as reported in GCC bug 88345:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88345
This prevents CONFIG_FUNCTION_ALIGNMENT and CONFIG_DEBUG_FORCE_FUNCTION_ALIGN_64B from having their expected effect on the ACPICA code. This is doubly unfortunate as in subsequent patches arm64 will depend upon CONFIG_FUNCTION_ALIGNMENT for its ftrace implementation.
Drop the '-Os' flag when building the ACPICA code. With this removed, the code builds cleanly and works correctly in testing so far.
I've tested this by selecting CONFIG_DEBUG_FORCE_FUNCTION_ALIGN_64B=y, building and booting a kernel using ACPI, and looking for misaligned text symbols:
* arm64:
Before, v6.2-rc3:
# uname -rm
6.2.0-rc3 aarch64
# grep ' [Tt] ' /proc/kallsyms | grep -iv '[048c]0 [Tt] ' | wc -l
5009 Before, v6.2-rc3 + fixed __cold:
# uname -rm
6.2.0-rc3-00001-g2a2bedf8bfa9 aarch64
# grep ' [Tt] ' /proc/kallsyms | grep -iv '[048c]0 [Tt] ' | wc -l
919After:
# uname -rm
6.2.0-rc3-00002-g267bddc38572 aarch64
# grep ' [Tt] ' /proc/kallsyms | grep -iv '[048c]0 [Tt] ' | wc -l
323
# grep ' [Tt] ' /proc/kallsyms | grep -iv '[048c]0 [Tt] ' | grep acpi | wc -l
0* x86_64:
Before, v6.2-rc3:
# uname -rm
6.2.0-rc3 x86_64
# grep ' [Tt] ' /proc/kallsyms | grep -iv '[048c]0 [Tt] ' | wc -l
11537 Before, v6.2-rc3 + fixed __cold:
# uname -rm
6.2.0-rc3-00001-g2a2bedf8bfa9 x86_64
# grep ' [Tt] ' /proc/kallsyms | grep -iv '[048c]0 [Tt] ' | wc -l
2805After:
# uname -rm
6.2.0-rc3-00002-g267bddc38572 x86_64
# grep ' [Tt] ' /proc/kallsyms | grep -iv '[048c]0 [Tt] ' | wc -l
1357
# grep ' [Tt] ' /proc/kallsyms | grep -iv '[048c]0 [Tt] ' | grep acpi | wc -l
0With the patch applied, the remaining unaligned text labels are a combination of static call trampolines and labels in assembly, which can be dealt with in subsequent patches.
--- drivers/acpi/acpica/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/acpica/Makefile +1 -1
@@ -3,7 +3,7 @@ # Makefile for ACPICA Core interpreter # -ccflags-y := -Os -D_LINUX -DBUILDING_ACPICA +ccflags-y := -D_LINUX -DBUILDING_ACPICA ccflags-$(CONFIG_ACPI_DEBUG) += -DACPI_DEBUG_OUTPUT # use acpi.o to put all files here into acpi.o modparam namespace
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 564/885 bpf, docs: Fix modulo zero, division by zero, overflow, and underflow
In reply to Greg Kroah-HartmanFrom: Dave Thaler <[email protected]>
[ Upstream commit 0eb9d19e2201068260e439a5c96dc85f9f3722a2 ]
Fix modulo zero, division by zero, overflow, and underflow. Also clarify how a negative immediate value is used in unsigned division.
--- Documentation/bpf/instruction-set.rst | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
Documentation/bpf/instruction-set.rst +14 -2
@@ -99,19 +99,26 @@ code value description BPF_ADD 0x00 dst += src BPF_SUB 0x10 dst -= src BPF_MUL 0x20 dst \*= src -BPF_DIV 0x30 dst /= src +BPF_DIV 0x30 dst = (src != 0) ? (dst / src) : 0 BPF_OR 0x40 dst \|= src BPF_AND 0x50 dst &= src BPF_LSH 0x60 dst <<= src BPF_RSH 0x70 dst >>= src BPF_NEG 0x80 dst = ~src -BPF_MOD 0x90 dst %= src +BPF_MOD 0x90 dst = (src != 0) ? (dst % src) : dst BPF_XOR 0xa0 dst ^= src BPF_MOV 0xb0 dst = src BPF_ARSH 0xc0 sign extending shift right BPF_END 0xd0 byte swap operations (see `Byte swap instructions`_ below) ======== ===== ========================================================== +Underflow and overflow are allowed during arithmetic operations, meaning +the 64-bit or 32-bit value will wrap. If eBPF program execution would +result in division by zero, the destination register is instead set to zero. +If execution would result in modulo by zero, for ``BPF_ALU64`` the value of +the destination register is unchanged whereas for ``BPF_ALU`` the upper +32 bits of the destination register are zeroed. + ``BPF_ADD | BPF_X | BPF_ALU`` means:: dst_reg = (u32) dst_reg + (u32) src_reg;
@@ -128,6 +135,11 @@ BPF_END 0xd0 byte swap operations (see `Byte swap instructions`_ below) src_reg = src_reg ^ imm32 +Also note that the division and modulo operations are unsigned. Thus, for +``BPF_ALU``, 'imm' is first interpreted as an unsigned 32-bit value, whereas +for ``BPF_ALU64``, 'imm' is first sign extended to 64 bits and the result +interpreted as an unsigned 64-bit value. There are no instructions for +signed division or modulo. Byte swap instructions ~~~~~~~~~~~~~~~~~~~~~~
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 565/885 thermal: intel: intel_pch: Add support for Wellsburg PCH
In reply to Greg Kroah-HartmanFrom: Tim Zimmermann <[email protected]>
[ Upstream commit 40dc1929089fc844ea06d9f8bdb6211ed4517c2e ]
Add the PCI ID for the Wellsburg C610 series chipset PCH.
The driver can read the temperature from the Wellsburg PCH with only the PCI ID added and no other modifications.
--- drivers/thermal/intel/intel_pch_thermal.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/thermal/intel/intel_pch_thermal.c +8 -0
@@ -29,6 +29,7 @@#define PCH_THERMAL_DID_CNL_LP 0x02F9/* CNL-LP PCH */ #define PCH_THERMAL_DID_CML_H 0X06F9/* CML-H PCH */ #define PCH_THERMAL_DID_LWB 0xA1B1/* Lewisburg PCH */ +#define PCH_THERMAL_DID_WBG 0x8D24/* Wellsburg PCH */ /* Wildcat Point-LP PCH Thermal registers */ #define WPT_TEMP 0x0000/* Temperature */
@@ -350,6 +351,7 @@ enum board_ids { board_cnl, board_cml, board_lwb, + board_wbg, }; static const struct board_info {
@@ -380,6 +382,10 @@ static const struct board_info { .name = "pch_lewisburg", .ops = &pch_dev_ops_wpt, }, + [board_wbg] = { + .name = "pch_wellsburg", + .ops = &pch_dev_ops_wpt, + }, }; static int intel_pch_thermal_probe(struct pci_dev *pdev,
@@ -495,6 +501,8 @@ static const struct pci_device_id intel_pch_thermal_id[] = { .driver_data = board_cml, }, { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCH_THERMAL_DID_LWB), .driver_data = board_lwb, }, + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCH_THERMAL_DID_WBG), + .driver_data = board_wbg, }, { 0, }, };MODULE_DEVICE_TABLE (pci, intel_pch_thermal_id);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 566/885 clocksource: Suspend the watchdog temporarily when high read latency detected
In reply to Greg Kroah-HartmanFrom: Feng Tang <[email protected]>
[ Upstream commit b7082cdfc464bf9231300605d03eebf943dda307 ]
Bugs have been reported on 8 sockets x86 machines in which the TSC was wrongly disabled when the system is under heavy workload.
[ 818.380354] clocksource: timekeeping watchdog on CPU336: hpet wd-wd read-back delay of 1203520ns [ 818.436160] clocksource: wd-tsc-wd read-back delay of 181880ns, clock-skew test skipped! [ 819.402962] clocksource: timekeeping watchdog on CPU338: hpet wd-wd read-back delay of 324000ns [ 819.448036] clocksource: wd-tsc-wd read-back delay of 337240ns, clock-skew test skipped! [ 819.880863] clocksource: timekeeping watchdog on CPU339: hpet read-back delay of 150280ns, attempt 3, marking unstable [ 819.936243] tsc: Marking TSC unstable due to clocksource watchdog [ 820.068173] TSC found unstable after boot, most likely due to broken BIOS. Use 'tsc=unstable'. [ 820.092382] sched_clock: Marking unstable (818769414384, 1195404998) [ 820.643627] clocksource: Checking clocksource tsc synchronization from CPU 267 to CPUs 0,4,25,70,126,430,557,564. [ 821.067990] clocksource: Switched to clocksource hpet
This can be reproduced by running memory intensive 'stream' tests, or some of the stress-ng subcases such as 'ioport'.
The reason for these issues is the when system is under heavy load, the read latency of the clocksources can be very high. Even lightweight TSC reads can show high latencies, and latencies are much worse for external clocksources such as HPET or the APIC PM timer. These latencies can result in false-positive clocksource-unstable determinations.
These issues were initially reported by a customer running on a production system, and this problem was reproduced on several generations of Xeon servers, especially when running the stress-ng test. These Xeon servers were not production systems, but they did have the latest steppings and firmware.
Given that the clocksource watchdog is a continual diagnostic check with frequency of twice a second, there is no need to rush it when the system is under heavy load. Therefore, when high clocksource read latencies are detected, suspend the watchdog timer for 5 minutes.
--- kernel/time/clocksource.c | 45 ++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 13 deletions(-)
kernel/time/clocksource.c +32 -13
@@ -384,6 +384,15 @@ void clocksource_verify_percpu(struct clocksource *cs) }EXPORT_SYMBOL_GPL (clocksource_verify_percpu); +static inline void clocksource_reset_watchdog (void ) +{ +struct clocksource *cs; + +list_for_each_entry (cs, &watchdog_list, wd_list) + cs->flags &= ~CLOCK_SOURCE_WATCHDOG ; +} + +static void clocksource_watchdog (struct timer_list *unused) {u64 csnow, wdnow, cslast, wdlast, delta;
@@ -391,6 +400,7 @@ static void clocksource_watchdog(struct timer_list *unused)int64_t wd_nsec, cs_nsec;struct clocksource *cs;enum wd_read_status read_ret; +unsigned long extra_wait =0 ;u32 md;spin_lock (&watchdog_lock);
@@ -410,13 +420,30 @@ static void clocksource_watchdog(struct timer_list *unused) read_ret =cs_watchdog_read (cs, &csnow, &wdnow); -if (read_ret !=WD_READ_SUCCESS ) { -if (read_ret ==WD_READ_UNSTABLE ) -/* Clock readout unreliable, so give it up. */ -__clocksource_unstable (cs); +if (read_ret ==WD_READ_UNSTABLE ) { +/* Clock readout unreliable, so give it up. */ +__clocksource_unstable (cs);continue ; } +/* +* When WD_READ_SKIP is returned, it means the system is likely +* under very heavy load, where the latency of reading +* watchdog/clocksource is very big, and affect the accuracy of +* watchdog check. So give system some space and suspend the +* watchdog check for 5 minutes. +*/ +if (read_ret ==WD_READ_SKIP ) { +/* +* As the watchdog timer will be suspended, and +* cs->last could keep unchanged for 5 minutes, reset +* the counters. +*/ +clocksource_reset_watchdog (); + extra_wait =HZ *300 ; +break ; + } +/* Clocksource initialized ? */ if (!(cs->flags &CLOCK_SOURCE_WATCHDOG ) ||atomic_read (&watchdog_reset_pending)) {
@@ -512,7 +539,7 @@ static void clocksource_watchdog(struct timer_list *unused)* pair clocksource_stop_watchdog() clocksource_start_watchdog(). */ if (!timer_pending (&watchdog_timer)) { - watchdog_timer.expires +=WATCHDOG_INTERVAL ; + watchdog_timer.expires +=WATCHDOG_INTERVAL + extra_wait;add_timer_on (&watchdog_timer, next_cpu); } out:
@@ -537,14 +564,6 @@ static inline void clocksource_stop_watchdog(void) watchdog_running =0 ; } -static inline void clocksource_reset_watchdog (void ) -{ -struct clocksource *cs; - -list_for_each_entry (cs, &watchdog_list, wd_list) - cs->flags &= ~CLOCK_SOURCE_WATCHDOG ; -} -static void clocksource_resume_watchdog (void ) {atomic_inc (&watchdog_reset_pending);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 567/885 crypto: hisilicon: Wipe entire pool on error
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
[ Upstream commit aa85923a954e7704bc9d3847dabeb8540aa98d13 ]
To work around a Clang __builtin_object_size bug that shows up under CONFIG_FORTIFY_SOURCE and UBSAN_BOUNDS, move the per-loop-iteration mem_block wipe into a single wipe of the entire pool structure after the loop.
--- drivers/crypto/hisilicon/sgl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/crypto/hisilicon/sgl.c +1 -2
@@ -124,9 +124,8 @@ struct hisi_acc_sgl_pool *hisi_acc_create_sgl_pool(struct device *dev,for (j =0 ; j < i; j++) {dma_free_coherent (dev, block_size, block[j].sgl, block[j].sgl_dma); -memset (block + j,0 ,sizeof (*block)); } -kfree (pool); +kfree_sensitive (pool);return ERR_PTR (-ENOMEM ); }EXPORT_SYMBOL_GPL (hisi_acc_create_sgl_pool);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 568/885 net: bcmgenet: Add a check for oversized packets
In reply to Greg Kroah-HartmanFrom: Florian Fainelli <[email protected]>
[ Upstream commit 5c0862c2c962052ed5055220a00ac1cefb92fbcd ]
Occasionnaly we may get oversized packets from the hardware which exceed the nomimal 2KiB buffer size we allocate SKBs with. Add an early check which drops the packet to avoid invoking skb_over_panic() and move on to processing the next packet.
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +8 -0
@@ -2311,6 +2311,14 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_rx_ring *ring, __func__, p_index, ring->c_index, ring->read_ptr, dma_length_status); +if (unlikely (len >RX_BUF_LENGTH )) { +netif_err (priv, rx_status, dev,"oversized packet\n" ); + dev->stats.rx_length_errors++; + dev->stats.rx_errors++; +dev_kfree_skb_any (skb); + goto next; + } +if (unlikely (!(dma_flag &DMA_EOP ) || !(dma_flag &DMA_SOP ))) {netif_err (priv, rx_status, dev,"dropping fragmented packet!\n" );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 569/885 m68k: Check syscall_trace_enter() return code
In reply to Greg Kroah-HartmanFrom: Michael Schmitz <[email protected]>
[ Upstream commit 2ca8a1de4437f21562e57f9ac123914747a8e7a1 ]
Check return code of syscall_trace_enter(), and skip syscall if -1. Return code will be left at what had been set by ptrace or seccomp (in regs->d0).
No regression seen in testing with strace on ARAnyM.
--- arch/m68k/68000/entry.S | 2 ++ arch/m68k/coldfire/entry.S | 2 ++ arch/m68k/kernel/entry.S | 3 +++ 3 files changed, 7 insertions(+)
arch/m68k/68000/entry.S +2 -0
@@ -45,6 +45,8 @@ do_trace: jbsr syscall_trace_enter RESTORE_SWITCH_STACK addql #4,%sp + addql #1,%d0 + jeq ret_from_exception movel %sp@(PT_OFF_ORIG_D0),%d1 movel #-ENOSYS,%d0 cmpl #NR_syscalls,%d1
arch/m68k/coldfire/entry.S +2 -0
@@ -90,6 +90,8 @@ ENTRY(system_call) jbsr syscall_trace_enter RESTORE_SWITCH_STACK addql #4,%sp + addql #1,%d0 + jeq ret_from_exception movel %d3,%a0 jbsr %a0@ movel %d0,%sp@(PT_OFF_D0) /* save the return value */
arch/m68k/kernel/entry.S +3 -0
@@ -184,9 +184,12 @@ do_trace_entry: jbsr syscall_trace_enter RESTORE_SWITCH_STACK addql #4,%sp + addql #1,%d0 | optimization for cmpil #-1,%d0 + jeq ret_from_syscall movel %sp@(PT_OFF_ORIG_D0),%d0 cmpl #NR_syscalls,%d0 jcs syscall + jra ret_from_syscall badsys: movel #-ENOSYS,%sp@(PT_OFF_D0) jra ret_from_syscall
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 570/885 s390/mm,ptdump: avoid Kasan vs Memcpy Real markers swapping
In reply to Greg Kroah-HartmanFrom: Vasily Gorbik <[email protected]>
[ Upstream commit 05178996e1a77e2a4664536e6d101a086a905034 ]
---[ Real Memory Copy Area Start ]---
0x001bfffffffff000-0x001c000000000000 4K PTE I
---[ Kasan Shadow Start ]---
---[ Real Memory Copy Area End ]---
0x001c000000000000-0x001c000200000000 8G PMD RW NX
...
---[ Kasan Shadow End ]---
ptdump does a stable sort of markers. Move kasan markers after memcpy real to avoid swapping.
--- arch/s390/mm/dump_pagetables.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
arch/s390/mm/dump_pagetables.c +8 -8
@@ -33,10 +33,6 @@ enum address_markers_idx {#endif IDENTITY_AFTER_NR ,IDENTITY_AFTER_END_NR , -#ifdef CONFIG_KASAN -KASAN_SHADOW_START_NR , -KASAN_SHADOW_END_NR , -#endifVMEMMAP_NR ,VMEMMAP_END_NR , VMALLOC_NR,
@@ -47,6 +43,10 @@ enum address_markers_idx {ABS_LOWCORE_END_NR ,MEMCPY_REAL_NR ,MEMCPY_REAL_END_NR , +#ifdef CONFIG_KASAN +KASAN_SHADOW_START_NR , + KASAN_SHADOW_END_NR, +#endif }; static struct addr_marker address_markers[] = {
@@ -62,10 +62,6 @@ static struct addr_marker address_markers[] = { #endif [IDENTITY_AFTER_NR] = {(unsigned long)_end, "Identity Mapping Start"}, [IDENTITY_AFTER_END_NR] = {0, "Identity Mapping End"}, -#ifdef CONFIG_KASAN - [KASAN_SHADOW_START_NR] = {KASAN_SHADOW_START, "Kasan Shadow Start"}, - [KASAN_SHADOW_END_NR] = {KASAN_SHADOW_END, "Kasan Shadow End"}, -#endif [VMEMMAP_NR] = {0, "vmemmap Area Start"}, [VMEMMAP_END_NR] = {0, "vmemmap Area End"}, [VMALLOC_NR] = {0, "vmalloc Area Start"},
@@ -76,6 +72,10 @@ static struct addr_marker address_markers[] = { [ABS_LOWCORE_END_NR] = {0, "Lowcore Area End"}, [MEMCPY_REAL_NR] = {0, "Real Memory Copy Area Start"}, [MEMCPY_REAL_END_NR ] = {0 ,"Real Memory Copy Area End" }, +#ifdef CONFIG_KASAN + [KASAN_SHADOW_START_NR] = {KASAN_SHADOW_START, "Kasan Shadow Start"}, + [KASAN_SHADOW_END_NR] = {KASAN_SHADOW_END, "Kasan Shadow End"}, +#endif { -1, NULL } };
Signature · 1 line
2.39.2