6.7.12-rc1 review
Subsystems (7)
Greg Kroah-Hartman
maintainerPATCH 261/432 USB: usb-storage: Prevent divide-by-0 error in isd200_ata_command
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit 014bcf41d946b36a8f0b8e9b5d9529efbb822f49 upstream.
The isd200 sub-driver in usb-storage uses the HEADS and SECTORS values in the ATA ID information to calculate cylinder and head values when creating a CDB for READ or WRITE commands. The calculation involves division and modulus operations, which will cause a crash if either of these values is 0. While this never happens with a genuine device, it could happen with a flawed or subversive emulation, as reported by the syzbot fuzzer.
Protect against this possibility by refusing to bind to the device if either the ATA_ID_HEADS or ATA_ID_SECTORS value in the device's ID information is 0. This requires isd200_Initialization() to return a negative error code when initialization fails; currently it always returns 0 (even when there is an error).
--- drivers/usb/storage/isd200.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)
drivers/usb/storage/isd200.c +18 -5
@@ -1105,7 +1105,7 @@ static void isd200_dump_driveid(struct ustatic int isd200_get_inquiry_data (struct us_data *us ) {struct isd200_info *info = (struct isd200_info *)us->extra; -int retStatus =ISD200_GOOD ; +int retStatus;u16 *id = info->id;usb_stor_dbg (us,"Entering isd200_get_inquiry_data\n" );
@@ -1137,6 +1137,13 @@ static int isd200_get_inquiry_data( struisd200_fix_driveid (id);isd200_dump_driveid (us, id); +/* Prevent division by 0 in isd200_scsi_to_ata() */ +if (id[ATA_ID_HEADS ] ==0 || id[ATA_ID_SECTORS ] ==0 ) { +usb_stor_dbg (us," Invalid ATA Identify data\n" ); + retStatus =ISD200_ERROR ; + goto Done; + } +memset (&info->InquiryData,0 ,sizeof (info->InquiryData));/* Standard IDE interface only supports disks */
@@ -1202,6 +1209,7 @@ static int isd200_get_inquiry_data( stru } } + Done:usb_stor_dbg (us,"Leaving isd200_get_inquiry_data %08X\n" , retStatus);return (retStatus);
@@ -1481,22 +1489,27 @@ static int isd200_init_info(struct us_dastatic int isd200_Initialization (struct us_data *us) { +int rc =0 ; +usb_stor_dbg (us,"ISD200 Initialization...\n" );/* Initialize ISD200 info struct */ -if (isd200_init_info (us) ==ISD200_ERROR ) { +if (isd200_init_info (us) <0 ) {usb_stor_dbg (us,"ERROR Initializing ISD200 Info struct\n" ); + rc = -ENOMEM ; }else {/* Get device specific data */ -if (isd200_get_inquiry_data (us) !=ISD200_GOOD ) +if (isd200_get_inquiry_data (us) !=ISD200_GOOD ) {usb_stor_dbg (us,"ISD200 Initialization Failure\n" ); -else + rc = -EINVAL ; + }else {usb_stor_dbg (us,"ISD200 Initialization complete\n" ); + } } -return 0 ; +return rc; }
Greg Kroah-Hartman
maintainerPATCH 262/432 usb: typec: altmodes/displayport: create sysfs nodes as drivers default device attribute group
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: RD Babiera <[email protected]>
commit 165376f6b23e9a779850e750fb2eb06622e5a531 upstream.
The DisplayPort driver's sysfs nodes may be present to the userspace before typec_altmode_set_drvdata() completes in dp_altmode_probe. This means that a sysfs read can trigger a NULL pointer error by deferencing dp->hpd in hpd_show or dp->lock in pin_assignment_show, as dev_get_drvdata() returns NULL in those cases.
Remove manual sysfs node creation in favor of adding attribute group as default for devices bound to the driver. The ATTRIBUTE_GROUPS() macro is not used here otherwise the path to the sysfs nodes is no longer compliant with the ABI.
--- drivers/usb/typec/altmodes/displayport.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/usb/typec/altmodes/displayport.c +9 -9
@@ -559,16 +559,21 @@ static ssize_t hpd_show(struct device *d }static DEVICE_ATTR_RO (hpd); -static struct attribute *dp_altmode_attrs[] = { +static struct attribute *displayport_attrs[] = { &dev_attr_configuration.attr, &dev_attr_pin_assignment.attr, &dev_attr_hpd.attr,NULL }; -static const struct attribute_group dp_altmode_group = { +static const struct attribute_group displayport_group = { .name ="displayport" , - .attrs = dp_altmode_attrs, + .attrs = displayport_attrs, +}; + +static const struct attribute_group *displayport_groups[] = { + &displayport_group, +NULL , };int dp_altmode_probe (struct typec_altmode *alt)
@@ -576,7 +581,6 @@ int dp_altmode_probe(struct typec_altmodconst struct typec_altmode *port =typec_altmode_get_partner (alt);struct fwnode_handle *fwnode;struct dp_altmode *dp; -int ret;/* FIXME: Port can only be DFP_U. */
@@ -587,10 +591,6 @@ int dp_altmode_probe(struct typec_altmod DP_CAP_PIN_ASSIGN_DFP_D(alt->vdo)))return -ENODEV ; - ret =sysfs_create_group (&alt->dev.kobj, &dp_altmode_group); -if (ret) -return ret; - dp =devm_kzalloc (&alt->dev,sizeof (*dp),GFP_KERNEL );if (!dp)return -ENOMEM ;
@@ -624,7 +624,6 @@ void dp_altmode_remove(struct typec_altm {struct dp_altmode *dp =typec_altmode_get_drvdata (alt); -sysfs_remove_group (&alt->dev.kobj, &dp_altmode_group);cancel_work_sync (&dp->work);if (dp->connector_fwnode) {
@@ -649,6 +648,7 @@ static struct typec_altmode_driver dp_al .driver = { .name = "typec_displayport", .owner = THIS_MODULE, + .dev_groups = displayport_groups, }, };module_typec_altmode_driver (dp_altmode_driver);
Greg Kroah-Hartman
maintainerPATCH 263/432 usb: gadget: ncm: Fix handling of zero block length packets
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krishna Kurapati <[email protected]>
commit f90ce1e04cbcc76639d6cba0fdbd820cd80b3c70 upstream.
While connecting to a Linux host with CDC_NCM_NTB_DEF_SIZE_TX set to 65536, it has been observed that we receive short packets, which come at interval of 5-10 seconds sometimes and have block length zero but still contain 1-2 valid datagrams present.
According to the NCM spec:
"If wBlockLength = 0x0000, the block is terminated by a short packet. In this case, the USB transfer must still be shorter than dwNtbInMaxSize or dwNtbOutMaxSize. If exactly dwNtbInMaxSize or dwNtbOutMaxSize bytes are sent, and the size is a multiple of wMaxPacketSize for the given pipe, then no ZLP shall be sent.
wBlockLength= 0x0000 must be used with extreme care, because of the possibility that the host and device may get out of sync, and because of test issues.
wBlockLength = 0x0000 allows the sender to reduce latency by starting to send a very large NTB, and then shortening it when the sender discovers that there’s not sufficient data to justify sending a large NTB"
However, there is a potential issue with the current implementation, as it checks for the occurrence of multiple NTBs in a single giveback by verifying if the leftover bytes to be processed is zero or not. If the block length reads zero, we would process the same NTB infintely because the leftover bytes is never zero and it leads to a crash. Fix this by bailing out if block length reads zero.
--- drivers/usb/gadget/function/f_ncm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/function/f_ncm.c +1 -1
@@ -1333,7 +1333,7 @@ parse_ntb:if (to_process ==1 && (*(unsigned char *)(ntb_ptr + block_len) ==0x00 )) { to_process--; - }else if (to_process >0 ) { + }else if ((to_process >0 ) && (block_len !=0 )) { ntb_ptr = (unsigned char *)(ntb_ptr + block_len); goto parse_ntb; }
Greg Kroah-Hartman
maintainerPATCH 264/432 usb: port: Dont try to peer unused USB ports based on location
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mathias Nyman <[email protected]>
commit 69c63350e573367f9c8594162288cffa8a26d0d1 upstream.
Unused USB ports may have bogus location data in ACPI PLD tables. This causes port peering failures as these unused USB2 and USB3 ports location may match.
Due to these failures the driver prints a
"usb: port power management may be unreliable" warning, and unnecessarily blocks port power off during runtime suspend.
This was debugged on a couple DELL systems where the unused ports all returned zeroes in their location data.
Similar bugreports exist for other systems.
Don't try to peer or match ports that have connect type set to USB_PORT_NOT_USED.
--- drivers/usb/core/port.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/usb/core/port.c +3 -2
@@ -573,7 +573,7 @@ static int match_location(struct usb_devstruct usb_hub *peer_hub =usb_hub_to_struct_hub (peer_hdev);struct usb_device *hdev =to_usb_device (port_dev->dev.parent->parent); -if (!peer_hub) +if (!peer_hub || port_dev->connect_type ==USB_PORT_NOT_USED )return 0 ; hcd =bus_to_hcd (hdev->bus);
@@ -584,7 +584,8 @@ static int match_location(struct usb_devfor (port1 =1 ; port1 <= peer_hdev->maxchild; port1++) { peer = peer_hub->ports[port1 -1 ]; -if (peer && peer->location == port_dev->location) { +if (peer && peer->connect_type !=USB_PORT_NOT_USED && + peer->location == port_dev->location) {link_peers_report (port_dev, peer);return 1 ;/* done */ }
Greg Kroah-Hartman
maintainerPATCH 265/432 xhci: Fix failure to detect ring expansion need.
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mathias Nyman <[email protected]>
commit b234c70fefa7532d34ebee104de64cc16f1b21e4 upstream.
Ring expansion checker may incorrectly assume a completely full ring is empty, missing the need for expansion.
This is due to a special empty ring case where the dequeue ends up ahead of the enqueue pointer. This is seen when enqueued TRBs fill up exactly a segment, with enqueue then pointing to the end link TRB. Once those TRBs are handled the dequeue pointer will follow the link TRB and end up pointing to the first entry on the next segment, past the enqueue.
This same enqueue - dequeue condition can be true if a ring is full, with enqueue ending on that last link TRB before the dequeue pointer on the next segment.
This can be seen when queuing several ~510 small URBs via usbfs in one go before a single one is handled (i.e. dequeue not moved from first entry in segment).
Expand the ring already when enqueue reaches the link TRB before the dequeue segment, instead of expanding it when enqueue moves into the dequeue segment.
--- drivers/usb/host/xhci-ring.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/usb/host/xhci-ring.c +7 -1
@@ -326,7 +326,13 @@ static unsigned int xhci_ring_expansion_/* how many trbs will be queued past the enqueue segment? */ trbs_past_seg = enq_used + num_trbs - (TRBS_PER_SEGMENT -1 ); -if (trbs_past_seg <=0 ) +/* +* Consider expanding the ring already if num_trbs fills the current +* segment (i.e. trbs_past_seg == 0), not only when num_trbs goes into +* the next segment. Avoids confusing full ring with special empty ring +* case below +*/ +if (trbs_past_seg <0 )return 0 ;/* Empty ring special case, enqueue stuck on link trb while dequeue advanced */
Greg Kroah-Hartman
maintainerPATCH 266/432 tty: serial: fsl_lpuart: avoid idle preamble pending if CTS is enabled
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sherry Sun <[email protected]>
commit 74cb7e0355fae9641f825afa389d3fba3b617714 upstream.
If the remote uart device is not connected or not enabled after booting up, the CTS line is high by default. At this time, if we enable the flow control when opening the device(for example, using “stty -F /dev/ttyLP4 crtscts” command), there will be a pending idle preamble(first writing 0 and then writing 1 to UARTCTRL_TE will queue an idle preamble) that cannot be sent out, resulting in the uart port fail to close(waiting for TX empty), so the user space stty will have to wait for a long time or forever.
This is an LPUART IP bug(idle preamble has higher priority than CTS), here add a workaround patch to enable TX CTS after enabling UARTCTRL_TE, so that the idle preamble does not get stuck due to CTS is deasserted.
--- drivers/tty/serial/fsl_lpuart.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/tty/serial/fsl_lpuart.c +5 -2
@@ -2345,9 +2345,12 @@ lpuart32_set_termios(struct uart_port *plpuart32_write (&sport->port, bd,UARTBAUD );lpuart32_serial_setbrg (sport, baud); -lpuart32_write (&sport->port, modem,UARTMODIR ); -lpuart32_write (&sport->port, ctrl,UARTCTRL ); +/* disable CTS before enabling UARTCTRL_TE to avoid pending idle preamble */ +lpuart32_write (&sport->port, modem & ~UARTMODIR_TXCTSE ,UARTMODIR );/* restore control register */ +lpuart32_write (&sport->port, ctrl,UARTCTRL ); +/* re-enable the CTS if needed */ +lpuart32_write (&sport->port, modem,UARTMODIR );if ((ctrl & (UARTCTRL_PE |UARTCTRL_M )) ==UARTCTRL_PE ) sport->is_cs7 = true;
Greg Kroah-Hartman
maintainerPATCH 267/432 serial: 8250_dw: Do not reclock if already at correct rate
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Collingbourne <[email protected]>
commit e5d6bd25f93d6ae158bb4cd04956cb497a85b8ef upstream.
When userspace opens the console, we call set_termios() passing a termios with the console's configured baud rate. Currently this causes dw8250_set_termios() to disable and then re-enable the UART clock at the same frequency as it was originally. This can cause corruption of any concurrent console output. Fix it by skipping the reclocking if we are already at the correct rate.
--- drivers/tty/serial/8250/8250_dw.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/tty/serial/8250/8250_dw.c +3 -3
@@ -357,9 +357,9 @@ static void dw8250_set_termios(struct ualong rate;int ret; -clk_disable_unprepare (d->clk); rate =clk_round_rate (d->clk, newrate); -if (rate >0 ) { +if (rate >0 && p->uartclk != rate) { +clk_disable_unprepare (d->clk);/* * Note that any clock-notifer worker will block in * serial8250_update_uartclk() until we are done.
@@ -367,8 +367,8 @@ static void dw8250_set_termios(struct ua ret =clk_set_rate (d->clk, newrate);if (!ret) p->uartclk = rate; +clk_prepare_enable (d->clk); } -clk_prepare_enable (d->clk);dw8250_do_set_termios (p, termios, old); }
Re: [PATCH 6.7 267/432] serial: 8250_dw: Do not reclock if already at correct rate
Quoted 2 lines · Greg Kroah-Hartman
6.7-stable review patch. If anyone has any objections, please let me know.
Hi Greg,
This patch is being reverted for now, so it shouldn't go into any stable branches (I see that you sent similar messages for 6.6 and 6.1).
Peter
Greg Kroah-Hartman
maintainerRe: [PATCH 6.7 267/432] serial: 8250_dw: Do not reclock if already at correct rate
Quoted 10 lines · Peter Collingbourne
Quoted 2 lines · Greg Kroah-Hartman
6.7-stable review patch. If anyone has any objections, please let me know.
Hi Greg,
This patch is being reverted for now, so it shouldn't go into any stable branches (I see that you sent similar messages for 6.6 and 6.1).
Thanks for reminding me, now dropped from all stable queues.
greg k-h
Greg Kroah-Hartman
maintainerPATCH 268/432 misc: lis3lv02d_i2c: Fix regulators getting en-/dis-abled twice on suspend/resume
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit ac3e0384073b2408d6cb0d972fee9fcc3776053d upstream.
When not configured for wakeup lis3lv02d_i2c_suspend() will call lis3lv02d_poweroff() even if the device has already been turned off by the runtime-suspend handler and if configured for wakeup and the device is runtime-suspended at this point then it is not turned back on to serve as a wakeup source.
Before commit b1b9f7a49440 ("misc: lis3lv02d_i2c: Add missing setting of the reg_ctrl callback"), lis3lv02d_poweroff() failed to disable the regulators which as a side effect made calling poweroff() twice ok.
Now that poweroff() correctly disables the regulators, doing this twice triggers a WARN() in the regulator core:
unbalanced disables for regulator-dummy
WARNING: CPU: 1 PID: 92 at drivers/regulator/core.c:2999 _regulator_disable
...
Fix lis3lv02d_i2c_suspend() to not call poweroff() a second time if already runtime-suspended and add a poweron() call when necessary to make wakeup work.
lis3lv02d_i2c_resume() has similar issues, with an added weirness that it always powers on the device if it is runtime suspended, after which the first runtime-resume will call poweron() again, causing the enabled count for the regulator to increase by 1 every suspend/resume. These unbalanced regulator_enable() calls cause the regulator to never be turned off and trigger the following WARN() on driver unbind:
WARNING: CPU: 1 PID: 1724 at drivers/regulator/core.c:2396 _regulator_put
Fix this by making lis3lv02d_i2c_resume() mirror the new suspend().
--- drivers/misc/lis3lv02d/lis3lv02d_i2c.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
drivers/misc/lis3lv02d/lis3lv02d_i2c.c +13 -8
@@ -198,8 +198,14 @@ static int lis3lv02d_i2c_suspend(structstruct i2c_client *client =to_i2c_client (dev);struct lis3lv02d *lis3 =i2c_get_clientdata (client); -if (!lis3->pdata || !lis3->pdata->wakeup_flags) +/* Turn on for wakeup if turned off by runtime suspend */ +if (lis3->pdata && lis3->pdata->wakeup_flags) { +if (pm_runtime_suspended (dev)) +lis3lv02d_poweron (lis3); +/* For non wakeup turn off if not already turned off by runtime suspend */ + }else if (!pm_runtime_suspended (dev))lis3lv02d_poweroff (lis3); +return 0 ; }
@@ -208,13 +214,12 @@ static int lis3lv02d_i2c_resume(struct dstruct i2c_client *client =to_i2c_client (dev);struct lis3lv02d *lis3 =i2c_get_clientdata (client); -/* -* pm_runtime documentation says that devices should always -* be powered on at resume. Pm_runtime turns them off after system -* wide resume is complete. -*/ -if (!lis3->pdata || !lis3->pdata->wakeup_flags || -pm_runtime_suspended (dev)) +/* Turn back off if turned on for wakeup and runtime suspended*/ +if (lis3->pdata && lis3->pdata->wakeup_flags) { +if (pm_runtime_suspended (dev)) +lis3lv02d_poweroff (lis3); +/* For non wakeup turn back on if not runtime suspended */ + }else if (!pm_runtime_suspended (dev))lis3lv02d_poweron (lis3);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 269/432 misc: fastrpc: Pass proper arguments to scm call
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ekansh Gupta <[email protected]>
commit a283d7f179ff83976af27bcc71f7474cb4d7c348 upstream.
For CMA memory allocation, ownership is assigned to DSP to make it accessible by the PD running on the DSP. With current implementation HLOS VM is stored in the channel structure during rpmsg_probe and this VM is passed to qcom_scm call as the source VM.
The qcom_scm call will overwrite the passed source VM with the next VM which would cause a problem in case the scm call is again needed. Adding a local copy of source VM whereever scm call is made to avoid this problem.
--- drivers/misc/fastrpc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/misc/fastrpc.c +6 -4
@@ -263,7 +263,6 @@ struct fastrpc_channel_ctx {int domain_id;int sesscount;int vmcount; -u64 perms;struct qcom_scm_vmperm vmperms[FASTRPC_MAX_VMIDS ];struct rpmsg_device *rpdev;struct fastrpc_session_ctx session[FASTRPC_MAX_SESSIONS ];
@@ -1279,9 +1278,11 @@ static int fastrpc_init_create_static_pr/* Map if we have any heap VMIDs associated with this ADSP Static Process. */ if (fl->cctx->vmcount) { +u64 src_perms =BIT (QCOM_SCM_VMID_HLOS ); + err =qcom_scm_assign_mem (fl->cctx->remote_heap->phys, (u64 )fl->cctx->remote_heap->size, - &fl->cctx->perms, + &src_perms, fl->cctx->vmperms, fl->cctx->vmcount);if (err) { dev_err(fl->sctx->dev, "Failed to assign memory with phys 0x%llx size 0x%llx err %d",
@@ -1915,8 +1916,10 @@ static int fastrpc_req_mmap(struct fastr/* Add memory to static PD pool, protection thru hypervisor */ if (req.flags ==ADSP_MMAP_REMOTE_HEAP_ADDR && fl->cctx->vmcount) { +u64 src_perms =BIT (QCOM_SCM_VMID_HLOS ); + err =qcom_scm_assign_mem (buf->phys, (u64 )buf->size, - &fl->cctx->perms, fl->cctx->vmperms, fl->cctx->vmcount); + &src_perms, fl->cctx->vmperms, fl->cctx->vmcount);if (err) {dev_err (fl->sctx->dev,"Failed to assign memory phys 0x%llx size 0x%llx err %d" , buf->phys, buf->size, err);
@@ -2290,7 +2293,6 @@ static int fastrpc_rpmsg_probe(struct rpif (vmcount) { data->vmcount = vmcount; - data->perms =BIT (QCOM_SCM_VMID_HLOS );for (i =0 ; i < data->vmcount; i++) { data->vmperms[i].vmid = vmids[i]; data->vmperms[i].perm =QCOM_SCM_PERM_RWX ;
Greg Kroah-Hartman
maintainerPATCH 270/432 serial: port: Dont suspend if the port is still busy
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yicong Yang <[email protected]>
commit 43066e32227ecde674e8ae1fcdd4a1ede67680c2 upstream.
We accidently met the issue that the bash prompt is not shown after the previous command done and until the next input if there's only one CPU (In our issue other CPUs are isolated by isolcpus=). Further analysis shows it's because the port entering runtime suspend even if there's still pending chars in the buffer and the pending chars will only be processed in next device resuming. We are using amba-pl011 and the problematic flow is like below:
Bash kworkertty_write()
file_tty_write()
n_tty_write()
uart_write()
__uart_start()
pm_runtime_get() // wakeup waker
queue_work()
pm_runtime_work() rpm_resume() status = RPM_RESUMING serial_port_runtime_resume() port->ops->start_tx() pl011_tx_chars() uart_write_wakeup() […]
__uart_start()
pm_runtime_get() < 0 // because runtime status = RPM_RESUMING // later data are not commit to the port driver status = RPM_ACTIVE rpm_idle() -> rpm_suspend()
This patch tries to fix this by checking the port busy before entering runtime suspending. A runtime_suspend callback is added for the port driver. When entering runtime suspend the callback is invoked, if there's still pending chars in the buffer then flush the buffer.
--- drivers/tty/serial/serial_port.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)
drivers/tty/serial/serial_port.c +24 -1
@@ -46,8 +46,31 @@ out:return 0 ; } +static int serial_port_runtime_suspend (struct device *dev) +{ +struct serial_port_device *port_dev =to_serial_base_port_device (dev); +struct uart_port *port = port_dev->port; +unsigned long flags; +bool busy; + +if (port->flags &UPF_DEAD ) +return 0 ; + +uart_port_lock_irqsave (port, &flags); + busy =__serial_port_busy (port); +if (busy) + port->ops->start_tx (port); +uart_port_unlock_irqrestore (port, flags); + +if (busy) +pm_runtime_mark_last_busy (dev); + +return busy ? -EBUSY :0 ; +} + static DEFINE_RUNTIME_DEV_PM_OPS(serial_port_pm, - NULL, serial_port_runtime_resume, NULL); + serial_port_runtime_suspend, + serial_port_runtime_resume, NULL);static int serial_port_probe (struct device *dev) {
Greg Kroah-Hartman
maintainerPATCH 271/432 mei: me: add arrow lake point S DID
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Usyskin <[email protected]>
commit 7a9b9012043e126f6d6f4683e67409312d1b707b upstream.
Add Arrow Lake S device id.
--- drivers/misc/mei/hw-me-regs.h | 1 + drivers/misc/mei/pci-me.c | 1 + 2 files changed, 2 insertions(+)
drivers/misc/mei/hw-me-regs.h +1 -0
@@ -112,6 +112,7 @@#define MEI_DEV_ID_RPL_S 0x7A68/* Raptor Lake Point S */ #define MEI_DEV_ID_MTL_M 0x7E70/* Meteor Lake Point M */ +#define MEI_DEV_ID_ARL_S 0x7F68/* Arrow Lake Point S */ /* * MEI HW Section
drivers/misc/mei/pci-me.c +1 -0
@@ -119,6 +119,7 @@ static const struct pci_device_id mei_me {MEI_PCI_DEVICE(MEI_DEV_ID_RPL_S, MEI_ME_PCH15_CFG)}, {MEI_PCI_DEVICE(MEI_DEV_ID_MTL_M, MEI_ME_PCH15_CFG)}, + {MEI_PCI_DEVICE(MEI_DEV_ID_ARL_S, MEI_ME_PCH15_CFG)},/* required last entry */ {0, }
Greg Kroah-Hartman
maintainerPATCH 272/432 mei: me: add arrow lake point H DID
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Usyskin <[email protected]>
commit 8436f25802ec028ac7254990893f3e01926d9b79 upstream.
Add Arrow Lake H device id.
--- drivers/misc/mei/hw-me-regs.h | 1 + drivers/misc/mei/pci-me.c | 1 + 2 files changed, 2 insertions(+)
drivers/misc/mei/hw-me-regs.h +1 -0
@@ -113,6 +113,7 @@#define MEI_DEV_ID_MTL_M 0x7E70/* Meteor Lake Point M */ #define MEI_DEV_ID_ARL_S 0x7F68/* Arrow Lake Point S */ +#define MEI_DEV_ID_ARL_H 0x7770/* Arrow Lake Point H */ /* * MEI HW Section
drivers/misc/mei/pci-me.c +1 -0
@@ -120,6 +120,7 @@ static const struct pci_device_id mei_me {MEI_PCI_DEVICE(MEI_DEV_ID_MTL_M, MEI_ME_PCH15_CFG)}, {MEI_PCI_DEVICE(MEI_DEV_ID_ARL_S, MEI_ME_PCH15_CFG)}, + {MEI_PCI_DEVICE(MEI_DEV_ID_ARL_H, MEI_ME_PCH15_CFG)},/* required last entry */ {0, }
Greg Kroah-Hartman
maintainerPATCH 273/432 vt: fix unicode buffer corruption when deleting characters
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolas Pitre <[email protected]>
commit 1581dafaf0d34bc9c428a794a22110d7046d186d upstream.
This is the same issue that was fixed for the VGA text buffer in commit 39cdb68c64d8 ("vt: fix memory overlapping when deleting chars in the buffer"). The cure is also the same i.e. replace memcpy() with memmove() due to the overlaping buffers.
--- drivers/tty/vt/vt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/vt/vt.c +1 -1
@@ -381,7 +381,7 @@ static void vc_uniscr_delete(struct vc_du32 *ln = vc->vc_uni_lines[vc->state.y];unsigned int x = vc->state.x, cols = vc->vc_cols; -memcpy (&ln[x], &ln[x + nr], (cols - x - nr) *sizeof (*ln)); +memmove (&ln[x], &ln[x + nr], (cols - x - nr) *sizeof (*ln));memset32 (&ln[cols - nr],' ' , nr); } }
Greg Kroah-Hartman
maintainerPATCH 274/432 Revert "tty: serial: simplify qcom_geni_serial_send_chunk_fifo()"
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Douglas Anderson <[email protected]>
commit 3d9319c27ceb35fa3d2c8b15508967f3fc7e5b78 upstream.
This reverts commit 5c7e105cd156fc9adf5294a83623d7a40c15f9b9.
As identified by KASAN, the simplification done by the cleanup patch was not legal.
Quoted 1 line
From tracing through the code, it can be seen that we're transmitting
from a 4096-byte circular buffer. We copy anywhere from 1-4 bytes from it each time. The simplification runs into trouble when we get near the end of the circular buffer. For instance, we might start out with xmit->tail = 4094 and we want to transfer 4 bytes. With the code before simplification this was no problem. We'd read buf[4094], buf[4095], buf[0], and buf[1]. With the new code we'll do a memcpy(&buf[4094], 4) which reads 2 bytes past the end of the buffer and then skips transmitting what's at buf[0] and buf[1].
KASAN isn't 100% consistent at reporting this for me, but to be extra confident in the analysis, I added traces of the tail and tx_bytes and then wrote a test program:
while true; do
echo -n "abcdefghijklmnopqrstuvwxyz0" > /dev/ttyMSM0 sleep .1
done
I watched the traces over SSH and saw:
qcom_geni_serial_send_chunk_fifo: 4093 4
qcom_geni_serial_send_chunk_fifo: 1 3
Which indicated that one byte should be missing. Sure enough the output that should have been:
abcdefghijklmnopqrstuvwxyz0
In one case was actually missing a byte:
abcdefghijklmnopqrstuvwyz0
Running "ls -al" on large directories also made the missing bytes obvious since columns didn't line up.
While the original code may not be the most elegant, we only talking about copying up to 4 bytes here. Let's just go back to the code that worked.
--- drivers/tty/serial/qcom_geni_serial.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/tty/serial/qcom_geni_serial.c +6 -4
@@ -851,19 +851,21 @@ static void qcom_geni_serial_stop_tx(str }static void qcom_geni_serial_send_chunk_fifo (struct uart_port *uport, -unsigned int remaining) +unsigned int chunk) {struct qcom_geni_serial_port *port =to_dev_port (uport);struct circ_buf *xmit = &uport->state->xmit; -unsigned int tx_bytes; +unsigned int tx_bytes, c, remaining = chunk;u8 buf[BYTES_PER_FIFO_WORD ];while (remaining) {memset (buf,0 ,sizeof (buf)); tx_bytes =min (remaining,BYTES_PER_FIFO_WORD ); -memcpy (buf, &xmit->buf[xmit->tail], tx_bytes); -uart_xmit_advance (uport, tx_bytes); +for (c =0 ; c < tx_bytes ; c++) { + buf[c] = xmit->buf[xmit->tail]; +uart_xmit_advance (uport,1 ); + }iowrite32_rep (uport->membase + SE_GENI_TX_FIFOn, buf,1 );
Greg Kroah-Hartman
maintainerPATCH 275/432 fs/aio: Check IOCB_AIO_RW before the struct aio_kiocb conversion
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <[email protected]>
commit 961ebd120565cb60cebe21cb634fbc456022db4a upstream.
The first kiocb_set_cancel_fn() argument may point at a struct kiocb that is not embedded inside struct aio_kiocb. With the current code, depending on the compiler, the req->ki_ctx read happens either before the IOCB_AIO_RW test or after that test. Move the req->ki_ctx read such that it is guaranteed that the IOCB_AIO_RW test happens first.
--- fs/aio.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
fs/aio.c +6 -2
@@ -590,8 +590,8 @@ static int aio_setup_ring(struct kioctxvoid kiocb_set_cancel_fn (struct kiocb *iocb,kiocb_cancel_fn *cancel) { - struct aio_kiocb *req = container_of(iocb, struct aio_kiocb, rw); -struct kioctx *ctx = req->ki_ctx; +struct aio_kiocb *req; +struct kioctx *ctx;unsigned long flags;/*
@@ -601,9 +601,13 @@ void kiocb_set_cancel_fn(struct kiocb *iif (!(iocb->ki_flags &IOCB_AIO_RW ))return ; + req = container_of(iocb, struct aio_kiocb, rw); +if (WARN_ON_ONCE (!list_empty (&req->ki_list)))return ; + ctx = req->ki_ctx; +spin_lock_irqsave (&ctx->ctx_lock, flags);list_add_tail (&req->ki_list, &ctx->active_reqs); req->ki_cancel = cancel;
Greg Kroah-Hartman
maintainerPATCH 276/432 ALSA: hda/realtek - Add Headset Mic supported Acer NB platform
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kailang Yang <[email protected]>
commit 34ab5bbc6e82214d7f7393eba26d164b303ebb4e upstream.
It will be enable headset Mic for Acer NB platform.
--- sound/pci/hda/patch_realtek.c | 2 ++ 1 file changed, 2 insertions(+)
sound/pci/hda/patch_realtek.c +2 -0
@@ -11046,6 +11046,8 @@ static const struct snd_hda_pin_quirk al* at most one tbl is allowed to define for the same vendor and same codec */ static const struct snd_hda_pin_quirk alc269_fallback_pin_fixup_tbl[] = { +SND_HDA_PIN_QUIRK (0x10ec0256 ,0x1025 ,"Acer" ,ALC2XX_FIXUP_HEADSET_MIC , + {0x19, 0x40000000}),SND_HDA_PIN_QUIRK (0x10ec0289 ,0x1028 ,"Dell" ,ALC269_FIXUP_DELL4_MIC_NO_PRESENCE , {0x19, 0x40000000}, {0x1b, 0x40000000}),
Greg Kroah-Hartman
maintainerPATCH 277/432 ALSA: hda/realtek: fix mute/micmute LEDs for HP EliteBook
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Chi <[email protected]>
commit a17bd44c0146b00fcaa692915789c16bd1fb2a81 upstream.
The HP EliteBook using ALC236 codec which using 0x02 to control mute LED and 0x01 to control micmute LED. Therefore, add a quirk to make it works.
--- sound/pci/hda/patch_realtek.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/pci/hda/patch_realtek.c +4 -0
@@ -10045,6 +10045,10 @@ static const struct snd_pci_quirk alc269SND_PCI_QUIRK (0x103c ,0x8c70 ,"HP EliteBook 835 G11" ,ALC287_FIXUP_CS35L41_I2C_2_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8c71 ,"HP EliteBook 845 G11" ,ALC287_FIXUP_CS35L41_I2C_2_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8c72 ,"HP EliteBook 865 G11" ,ALC287_FIXUP_CS35L41_I2C_2_HP_GPIO_LED ), +SND_PCI_QUIRK (0x103c ,0x8c8a ,"HP EliteBook 630" ,ALC236_FIXUP_HP_GPIO_LED ), +SND_PCI_QUIRK (0x103c ,0x8c8c ,"HP EliteBook 660" ,ALC236_FIXUP_HP_GPIO_LED ), +SND_PCI_QUIRK (0x103c ,0x8c90 ,"HP EliteBook 640" ,ALC236_FIXUP_HP_GPIO_LED ), +SND_PCI_QUIRK (0x103c ,0x8c91 ,"HP EliteBook 660" ,ALC236_FIXUP_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8c96 ,"HP" ,ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF ),SND_PCI_QUIRK (0x103c ,0x8c97 ,"HP ZBook" ,ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF ), SND_PCI_QUIRK(0x103c, 0x8ca1, "HP ZBook Power", ALC236_FIXUP_HP_GPIO_LED),
Greg Kroah-Hartman
maintainerPATCH 278/432 tee: optee: Fix kernel panic caused by incorrect error handling
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sumit Garg <[email protected]>
commit 95915ba4b987cf2b222b0f251280228a1ff977ac upstream.
The error path while failing to register devices on the TEE bus has a bug leading to kernel panic as follows:
[ 15.398930] Unable to handle kernel paging request at virtual address ffff07ed00626d7c [ 15.406913] Mem abort info: [ 15.409722] ESR = 0x0000000096000005 [ 15.413490] EC = 0x25: DABT (current EL), IL = 32 bits [ 15.418814] SET = 0, FnV = 0 [ 15.421878] EA = 0, S1PTW = 0 [ 15.425031] FSC = 0x05: level 1 translation fault [ 15.429922] Data abort info: [ 15.432813] ISV = 0, ISS = 0x00000005, ISS2 = 0x00000000 [ 15.438310] CM = 0, WnR = 0, TnD = 0, TagAccess = 0 [ 15.443372] GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0 [ 15.448697] swapper pgtable: 4k pages, 48-bit VAs, pgdp=00000000d9e3e000 [ 15.455413] [ffff07ed00626d7c] pgd=1800000bffdf9003, p4d=1800000bffdf9003, pud=0000000000000000 [ 15.464146] Internal error: Oops: 0000000096000005 [#1] PREEMPT SMP
Commit 7269cba53d90 ("tee: optee: Fix supplicant based device enumeration") lead to the introduction of this bug. So fix it appropriately.
--- drivers/tee/optee/device.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/tee/optee/device.c +2 -1
@@ -90,13 +90,14 @@ static int optee_register_device(const uif (rc) {pr_err ("device registration failed, err: %d\n" , rc);put_device (&optee_device->dev); +return rc; }if (func ==PTA_CMD_GET_DEVICES_SUPP )device_create_file (&optee_device->dev, &dev_attr_need_supplicant); -return rc; +return 0 ; }static int __optee_enumerate_devices (u32 func)
Greg Kroah-Hartman
maintainerPATCH 279/432 ARM: imx_v6_v7_defconfig: Restore CONFIG_BACKLIGHT_CLASS_DEVICE
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fabio Estevam <[email protected]>
commit 2b0a5a8a397c0ae8f8cd25e7d3857c749239ceb8 upstream.
Since commit bfac19e239a7 ("fbdev: mx3fb: Remove the driver") backlight is no longer functional.
The fbdev mx3fb driver used to automatically select CONFIG_BACKLIGHT_CLASS_DEVICE.
Now that the mx3fb driver has been removed, enable the CONFIG_BACKLIGHT_CLASS_DEVICE option so that backlight can still work by default.
Tested on a imx6dl-sabresd board.
--- arch/arm/configs/imx_v6_v7_defconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm/configs/imx_v6_v7_defconfig +1 -0
@@ -297,6 +297,7 @@ CONFIG_FB_MODE_HELPERS=y CONFIG_LCD_CLASS_DEVICE=y CONFIG_LCD_L4F00242T03=y CONFIG_LCD_PLATFORM=y +CONFIG_BACKLIGHT_CLASS_DEVICE=y CONFIG_BACKLIGHT_PWM=y CONFIG_BACKLIGHT_GPIO=y CONFIG_FRAMEBUFFER_CONSOLE=y
Greg Kroah-Hartman
maintainerPATCH 280/432 mm, vmscan: prevent infinite loop for costly GFP_NOIO | __GFP_RETRY_MAYFAIL allocations
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vlastimil Babka <[email protected]>
commit 803de9000f334b771afacb6ff3e78622916668b0 upstream.
Sven reports an infinite loop in __alloc_pages_slowpath() for costly order __GFP_RETRY_MAYFAIL allocations that are also GFP_NOIO. Such combination can happen in a suspend/resume context where a GFP_KERNEL allocation can have __GFP_IO masked out via gfp_allowed_mask.
Quoting Sven:
1. try to do a "costly" allocation (order > PAGE_ALLOC_COSTLY_ORDER) with __GFP_RETRY_MAYFAIL set.
2. page alloc's __alloc_pages_slowpath tries to get a page from the freelist. This fails because there is nothing free of that costly order.
3. page alloc tries to reclaim by calling __alloc_pages_direct_reclaim, which bails out because a zone is ready to be compacted; it pretends to have made a single page of progress.
4. page alloc tries to compact, but this always bails out early because __GFP_IO is not set (it's not passed by the snd allocator, and even if it were, we are suspending so the __GFP_IO flag would be cleared anyway).
5. page alloc believes reclaim progress was made (because of the pretense in item 3) and so it checks whether it should retry compaction. The compaction retry logic thinks it should try again, because:
a) reclaim is needed because of the early bail-out in item 4
b) a zonelist is suitable for compaction
6. goto 2. indefinite stall.
(end quote)
The immediate root cause is confusing the COMPACT_SKIPPED returned from __alloc_pages_direct_compact() (step 4) due to lack of __GFP_IO to be indicating a lack of order-0 pages, and in step 5 evaluating that in should_compact_retry() as a reason to retry, before incrementing and limiting the number of retries. There are however other places that wrongly assume that compaction can happen while we lack __GFP_IO.
To fix this, introduce gfp_compaction_allowed() to abstract the __GFP_IO evaluation and switch the open-coded test in try_to_compact_pages() to use it.
Also use the new helper in:
- compaction_ready(), which will make reclaim not bail out in step 3, so there's at least one attempt to actually reclaim, even if chances are small for a costly order
- in_reclaim_compaction() which will make should_continue_reclaim() return false and we don't over-reclaim unnecessarily
- in __alloc_pages_slowpath() to set a local variable can_compact, which is then used to avoid retrying reclaim/compaction for costly allocations (step 5) if we can't compact and also to skip the early compaction attempt that we do in some cases
--- include/linux/gfp.h | 9 +++++++++ mm/compaction.c | 7 +------ mm/page_alloc.c | 10 ++++++---- mm/vmscan.c | 5 ++++- 4 files changed, 20 insertions(+), 11 deletions(-)
include/linux/gfp.h +9 -0
@@ -353,6 +353,15 @@ static inline bool gfp_has_io_fs(gfp_t greturn (gfp & (__GFP_IO | __GFP_FS)) == (__GFP_IO | __GFP_FS); } +/* +* Check if the gfp flags allow compaction - GFP_NOIO is a really +* tricky context because the migration might require IO. +*/ +static inline bool gfp_compaction_allowed (gfp_t gfp_mask) +{ +return IS_ENABLED (CONFIG_COMPACTION ) && (gfp_mask & __GFP_IO); +} +extern gfp_t vma_thp_gfp_mask (struct vm_area_struct *vma);#ifdef CONFIG_CONTIG_ALLOC
mm/compaction.c +1 -6
@@ -2701,16 +2701,11 @@ enum compact_result try_to_compact_pages unsigned int alloc_flags, const struct alloc_context *ac, enum compact_priority prio, struct page **capture) { - int may_perform_io = (__force int)(gfp_mask & __GFP_IO); struct zoneref *z;struct zone *zone;enum compact_result rc =COMPACT_SKIPPED ; -/* -* Check if the GFP flags allow compaction - GFP_NOIO is really -* tricky context because the migration might require IO -*/ -if (!may_perform_io) +if (!gfp_compaction_allowed (gfp_mask))return COMPACT_SKIPPED ;trace_mm_compaction_try_to_compact_pages (order, gfp_mask, prio);
mm/page_alloc.c +6 -4
@@ -4042,6 +4042,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, u struct alloc_context *ac) {bool can_direct_reclaim = gfp_mask & __GFP_DIRECT_RECLAIM; +bool can_compact =gfp_compaction_allowed (gfp_mask);const bool costly_order = order >PAGE_ALLOC_COSTLY_ORDER ;struct page *page =NULL ;unsigned int alloc_flags;
@@ -4112,7 +4113,7 @@ restart:* Don't try this for allocations that are allowed to ignore * watermarks, as the ALLOC_NO_WATERMARKS attempt didn't yet happen. */ -if (can_direct_reclaim && +if (can_direct_reclaim && can_compact && (costly_order || (order >0 && ac->migratetype !=MIGRATE_MOVABLE )) && !gfp_pfmemalloc_allowed (gfp_mask)) {
@@ -4210,9 +4211,10 @@ retry:/* * Do not retry costly high order allocations unless they are -* __GFP_RETRY_MAYFAIL +* __GFP_RETRY_MAYFAIL and we can compact */ -if (costly_order && !(gfp_mask & __GFP_RETRY_MAYFAIL)) +if (costly_order && (!can_compact || + !(gfp_mask & __GFP_RETRY_MAYFAIL))) goto nopage; if (should_reclaim_retry(gfp_mask, order, ac, alloc_flags,
@@ -4225,7 +4227,7 @@ retry:* implementation of the compaction depends on the sufficient amount * of free memory (see __compaction_suitable) */ -if (did_some_progress >0 && +if (did_some_progress >0 && can_compact &&should_compact_retry (ac, order, alloc_flags, compact_result, &compact_priority, &compaction_retries))
mm/vmscan.c +4 -1
@@ -5733,7 +5733,7 @@ static void shrink_lruvec(struct lruvec/* Use reclaim/compaction for costly allocs or under memory pressure */ static bool in_reclaim_compaction (struct scan_control *sc) { -if (IS_ENABLED (CONFIG_COMPACTION ) && sc->order && +if (gfp_compaction_allowed (sc->gfp_mask) && sc->order && (sc->order >PAGE_ALLOC_COSTLY_ORDER || sc->priority <DEF_PRIORITY -2 ))return true;
@@ -5978,6 +5978,9 @@ static inline bool compaction_ready(stru {unsigned long watermark; +if (!gfp_compaction_allowed (sc->gfp_mask)) +return false; +/* Allocation can already succeed, nothing to do */ if (zone_watermark_ok (zone, sc->order,min_wmark_pages (zone), sc->reclaim_idx,0 ))
Greg Kroah-Hartman
maintainerPATCH 281/432 arm64: dts: qcom: sc8280xp-x13s: limit pcie4 link speed
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 7a1c6a8bf47b0b290c79b9cc3ba6ee68be5522e8 upstream.
Limit the WiFi PCIe link speed to Gen2 speed (500 MB/s), which is the speed that the boot firmware has brought up the link at (and that Windows uses).
This is specifically needed to avoid a large amount of link errors when restarting the link during boot (but which are currently not reported).
This also appears to fix intermittent failures to download the ath11k firmware during boot which can be seen when there is a longer delay between restarting the link and loading the WiFi driver (e.g. when using full disk encryption).
--- arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts +2 -0
@@ -721,6 +721,8 @@ }; &pcie4 { + max-link-speed = <2>; + perst-gpios = <&tlmm 141 GPIO_ACTIVE_LOW>; wake-gpios = <&tlmm 139 GPIO_ACTIVE_LOW>;
Greg Kroah-Hartman
maintainerPATCH 282/432 iio: accel: adxl367: fix DEVID read after reset
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cosmin Tanislav <[email protected]>
commit 1b926914bbe4e30cb32f268893ef7d82a85275b8 upstream.
regmap_read_poll_timeout() will not sleep before reading, causing the first read to return -ENXIO on I2C, since the chip does not respond to it while it is being reset.
The datasheet specifies that a soft reset operation has a latency of 7.5ms.
Add a 15ms sleep between reset and reading the DEVID register, and switch to a simple regmap_read() call.
--- drivers/iio/accel/adxl367.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/iio/accel/adxl367.c +6 -2
@@ -1429,9 +1429,11 @@ static int adxl367_verify_devid(struct aunsigned int val;int ret; - ret =regmap_read_poll_timeout (st->regmap,ADXL367_REG_DEVID , val, - val ==ADXL367_DEVID_AD ,1000 ,10000 ); + ret =regmap_read (st->regmap,ADXL367_REG_DEVID , &val);if (ret) +return dev_err_probe (st->dev, ret,"Failed to read dev id\n" ); + +if (val !=ADXL367_DEVID_AD )return dev_err_probe (st->dev, -ENODEV ,"Invalid dev id 0x%02X, expected 0x%02X\n" , val,ADXL367_DEVID_AD );
@@ -1510,6 +1512,8 @@ int adxl367_probe(struct device *dev, coif (ret)return ret; +fsleep (15000 ); + ret =adxl367_verify_devid (st);if (ret)return ret;
Greg Kroah-Hartman
maintainerPATCH 283/432 iio: accel: adxl367: fix I2C FIFO data register
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cosmin Tanislav <[email protected]>
commit 11dadb631007324c7a8bcb2650eda88ed2b9eed0 upstream.
As specified in the datasheet, the I2C FIFO data register is 0x18, not 0x42. 0x42 was used by mistake when adapting the ADXL372 driver.
Fix this mistake.
--- drivers/iio/accel/adxl367_i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/accel/adxl367_i2c.c +1 -1
@@ -11,7 +11,7 @@#include "adxl367.h" -#define ADXL367_I2C_FIFO_DATA 0x42 +#define ADXL367_I2C_FIFO_DATA 0x18struct adxl367_i2c_state {struct regmap *regmap;
Greg Kroah-Hartman
maintainerPATCH 284/432 i2c: i801: Fix using mux_pdev before its set
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiner Kallweit <[email protected]>
commit 09f02902eb9cd41d4b88f4a5b93696297b57a3b0 upstream.
i801_probe_optional_slaves() is called before i801_add_mux(). This results in mux_pdev being checked before it's set by i801_add_mux(). Fix this by changing the order of the calls. I consider this safe as I see no dependencies.
--- drivers/i2c/busses/i2c-i801.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-i801.c +1 -1
@@ -1740,9 +1740,9 @@ static int i801_probe(struct pci_dev *dei801_enable_host_notify (&priv->adapter); -i801_probe_optional_slaves (priv);/* We ignore errors - multiplexing is optional */ i801_add_mux (priv); +i801_probe_optional_slaves (priv);pci_set_drvdata (dev, priv);
Greg Kroah-Hartman
maintainerPATCH 285/432 i2c: i801: Avoid potential double call to gpiod_remove_lookup_table
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiner Kallweit <[email protected]>
commit ceb013b2d9a2946035de5e1827624edc85ae9484 upstream.
If registering the platform device fails, the lookup table is removed in the error path. On module removal we would try to remove the lookup table again. Fix this by setting priv->lookup only if registering the platform device was successful. In addition free the memory allocated for the lookup table in the error path.
--- drivers/i2c/busses/i2c-i801.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-i801.c +3 -1
@@ -1414,7 +1414,6 @@ static void i801_add_mux(struct i801_pri lookup->table[i] =GPIO_LOOKUP (mux_config->gpio_chip, mux_config->gpios[i],"mux" ,0 );gpiod_add_lookup_table (lookup); - priv->lookup = lookup;/* * Register the mux device, we use PLATFORM_DEVID_NONE here
@@ -1428,7 +1427,10 @@ static void i801_add_mux(struct i801_pri sizeof(struct i2c_mux_gpio_platform_data));if (IS_ERR (priv->mux_pdev)) {gpiod_remove_lookup_table (lookup); +devm_kfree (dev, lookup);dev_err (dev,"Failed to register i2c-mux-gpio device\n" ); + }else { + priv->lookup = lookup; } }
Greg Kroah-Hartman
maintainerPATCH 286/432 iio: imu: inv_mpu6050: fix frequency setting when chip is off
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jean-Baptiste Maneyrol <[email protected]>
commit daec424cc57b33a28f8621eb7ac85f8bd327bd6b upstream.
Track correctly FIFO state and apply ODR change before starting the chip. Without the fix, you cannot change ODR more than 1 time when data buffering is off. This restriction on a single pending ODR change should only apply when the FIFO is on.
--- drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c +5 -0
@@ -111,6 +111,7 @@ int inv_mpu6050_prepare_fifo(struct inv_if (enable) {/* reset timestamping */ inv_sensors_timestamp_reset (&st->timestamp); +inv_sensors_timestamp_apply_odr (&st->timestamp,0 ,0 ,0 );/* reset FIFO */ d = st->chip_config.user_ctrl |INV_MPU6050_BIT_FIFO_RST ; ret =regmap_write (st->map, st->reg->user_ctrl, d);
@@ -184,6 +185,10 @@ static int inv_mpu6050_set_enable(structif (result) goto error_power_off; }else { + st->chip_config.gyro_fifo_enable =0 ; + st->chip_config.accl_fifo_enable =0 ; + st->chip_config.temp_fifo_enable =0 ; + st->chip_config.magn_fifo_enable =0 ; result =inv_mpu6050_prepare_fifo (st, false);if (result) goto error_power_off;
Greg Kroah-Hartman
maintainerPATCH 287/432 iio: imu: inv_mpu6050: fix FIFO parsing when empty
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jean-Baptiste Maneyrol <[email protected]>
commit 60caa8b33bd682a9ed99d1fc3f91d74e1acc9922 upstream.
Now that we are reading the full FIFO in the interrupt handler, it is possible to have an emply FIFO since we are still receiving 1 interrupt per data. Handle correctly this case instead of having an error causing a reset of the FIFO.
--- drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c +2 -0
@@ -109,6 +109,8 @@ irqreturn_t inv_mpu6050_read_fifo(int ir/* compute and process only all complete datum */ nb = fifo_count / bytes_per_datum; fifo_count = nb * bytes_per_datum; +if (nb ==0 ) + goto end_session;/* Each FIFO data contains all sensors, so same number for FIFO and sensor data */ fifo_period =NSEC_PER_SEC /INV_MPU6050_DIVIDER_TO_FIFO_RATE (st->chip_config.divider);inv_sensors_timestamp_interrupt (&st->timestamp, fifo_period, nb, nb, pf->timestamp);
Greg Kroah-Hartman
maintainerPATCH 288/432 drm/i915: Dont explode when the dig port we dont have an AUX CH
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ville Syrjälä <[email protected]>
commit 0b385be4c3ccd5636441923d7cad5eda6b4651cb upstream.
The icl+ power well code currently assumes that every AUX power well maps to an encoder which is using said power well. That is by no menas guaranteed as we:
- only register encoders for ports declared in the VBT
- combo PHY HDMI-only encoder no longer get an AUX CH since commit 9856308c94ca ("drm/i915: Only populate aux_ch if really needed")
However we have places such as intel_power_domains_sanitize_state() that blindly traverse all the possible power wells. So these bits of code may very well encounbter an aux power well with no associated encoder.
In this particular case the BIOS seems to have left one AUX power well enabled even though we're dealing with a HDMI only encoder on a combo PHY. We then proceed to turn off said power well and explode when we can't find a matching encoder. As a short term fix we should be able to just skip the PHY related parts of the power well programming since we know this situation can only happen with combo PHYs.
Another option might be to go back to always picking an AUX CH for all encoders. However I'm a bit wary about that since we might in theory end up conflicting with the VBT AUX CH assignment. Also that wouldn't help with encoders not declared in the VBT, should we ever need to poke the corresponding power wells.
Longer term we need to figure out what the actual relationship is between the PHY vs. AUX CH vs. AUX power well. Currently this is entirely unclear.
--- drivers/gpu/drm/i915/display/intel_display_power_well.c | 17 +++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/display/intel_display_power_well.c +14 -3
@@ -246,7 +246,14 @@ static enum phy icl_aux_pw_to_phy(structenum aux_ch aux_ch =icl_aux_pw_to_ch (power_well);struct intel_digital_port *dig_port =aux_ch_to_digital_port (i915, aux_ch); -return intel_port_to_phy (i915, dig_port->base.port); +/* +* FIXME should we care about the (VBT defined) dig_port->aux_ch +* relationship or should this be purely defined by the hardware layout? +* Currently if the port doesn't appear in the VBT, or if it's declared +* as HDMI-only and routed to a combo PHY, the encoder either won't be +* present at all or it will not have an aux_ch assigned. +*/ +return dig_port ?intel_port_to_phy (i915, dig_port->base.port) :PHY_NONE ; } static void hsw_wait_for_power_well_enable(struct drm_i915_private *dev_priv,
@@ -414,7 +421,8 @@ icl_combo_phy_aux_power_well_enable(struintel_de_rmw (dev_priv, regs->driver,0 ,HSW_PWR_WELL_CTL_REQ (pw_idx)); -if (DISPLAY_VER (dev_priv) <12 ) +/* FIXME this is a mess */ +if (phy !=PHY_NONE )intel_de_rmw (dev_priv,ICL_PORT_CL_DW12 (phy),0 ,ICL_LANE_ENABLE_AUX );
@@ -437,7 +445,10 @@ icl_combo_phy_aux_power_well_disable(strdrm_WARN_ON (&dev_priv->drm, !IS_ICELAKE (dev_priv)); -intel_de_rmw (dev_priv,ICL_PORT_CL_DW12 (phy),ICL_LANE_ENABLE_AUX ,0 ); +/* FIXME this is a mess */ +if (phy !=PHY_NONE ) +intel_de_rmw (dev_priv,ICL_PORT_CL_DW12 (phy), +ICL_LANE_ENABLE_AUX ,0 );intel_de_rmw (dev_priv, regs->driver,HSW_PWR_WELL_CTL_REQ (pw_idx),0 );
Greg Kroah-Hartman
maintainerPATCH 289/432 drm/amd/display: handle range offsets in VRR ranges
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
commit 937844d661354bf142dc1c621396fdab10ecbacc upstream.
Need to check the offset bits for values greater than 255.
v2: also update amdgpu_dm_connector values.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +14 -5
@@ -10876,14 +10876,23 @@ void amdgpu_dm_update_freesync_caps(struif (range->flags !=1 )continue ; - amdgpu_dm_connector->min_vfreq = range->min_vfreq; - amdgpu_dm_connector->max_vfreq = range->max_vfreq; - amdgpu_dm_connector->pixel_clock_mhz = - range->pixel_clock_mhz *10 ; - connector->display_info.monitor_range.min_vfreq = range->min_vfreq; connector->display_info.monitor_range.max_vfreq = range->max_vfreq; +if (edid->revision >=4 ) { +if (data->pad2 &DRM_EDID_RANGE_OFFSET_MIN_VFREQ ) + connector->display_info.monitor_range.min_vfreq +=255 ; +if (data->pad2 &DRM_EDID_RANGE_OFFSET_MAX_VFREQ ) + connector->display_info.monitor_range.max_vfreq +=255 ; + } + + amdgpu_dm_connector->min_vfreq = + connector->display_info.monitor_range.min_vfreq; + amdgpu_dm_connector->max_vfreq = + connector->display_info.monitor_range.max_vfreq; + amdgpu_dm_connector->pixel_clock_mhz = + range->pixel_clock_mhz *10 ; +break ; }
Greg Kroah-Hartman
maintainerPATCH 290/432 drm/amd/swsmu: modify the gfx activity scaling
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Ma <[email protected]>
commit 6601c15c8a0680edb0d23a13151adb8023959149 upstream.
Add an if condition for gfx activity because the scaling has been changed after smu fw version 5d4600. And remove a warning log.
--- drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0.c | 2 -- drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_0_ppt.c | 5 ++++- 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0.c +0 -2
@@ -229,8 +229,6 @@ int smu_v14_0_check_fw_version(struct sm smu->smc_driver_if_version =SMU14_DRIVER_IF_VERSION_SMU_V14_0_2 ;break ;case IP_VERSION (14 ,0 ,0 ): -if ((smu->smc_fw_version <0x5d3a00 )) -dev_warn (smu->adev->dev,"The PMFW version(%x) is behind in this BIOS!\n" , smu->smc_fw_version); smu->smc_driver_if_version =SMU14_DRIVER_IF_VERSION_SMU_V14_0_0 ;break ;default :
drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_0_ppt.c +4 -1
@@ -261,7 +261,10 @@ static int smu_v14_0_0_get_smu_metrics_d *value = metrics->MpipuclkFrequency;break ;case METRICS_AVERAGE_GFXACTIVITY : - *value = metrics->GfxActivity /100 ; +if ((smu->smc_fw_version >0x5d4600 )) + *value = metrics->GfxActivity; +else + *value = metrics->GfxActivity /100 ;break ;case METRICS_AVERAGE_VCNACTIVITY : *value = metrics->VcnActivity /100 ;
Greg Kroah-Hartman
maintainerPATCH 291/432 x86/efistub: Call mixed mode boot services on the firmwares stack
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit cefcd4fe2e3aaf792c14c9e56dab89e3d7a65d02 upstream.
Normally, the EFI stub calls into the EFI boot services using the stack that was live when the stub was entered. According to the UEFI spec, this stack needs to be at least 128k in size - this might seem large but all asynchronous processing and event handling in EFI runs from the same stack and so quite a lot of space may be used in practice.
In mixed mode, the situation is a bit different: the bootloader calls the 32-bit EFI stub entry point, which calls the decompressor's 32-bit entry point, where the boot stack is set up, using a fixed allocation of 16k. This stack is still in use when the EFI stub is started in 64-bit mode, and so all calls back into the EFI firmware will be using the decompressor's limited boot stack.
Due to the placement of the boot stack right after the boot heap, any stack overruns have gone unnoticed. However, commit
5c4feadb0011983b ("x86/decompressor: Move global symbol references to C code")
moved the definition of the boot heap into C code, and now the boot stack is placed right at the base of BSS, where any overruns will corrupt the end of the .data section.
While it would be possible to work around this by increasing the size of the boot stack, doing so would affect all x86 systems, and mixed mode systems are a tiny (and shrinking) fraction of the x86 installed base.
So instead, record the firmware stack pointer value when entering from the 32-bit firmware, and switch to this stack every time a EFI boot service call is made.
--- arch/x86/boot/compressed/efi_mixed.S | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/x86/boot/compressed/efi_mixed.S +9 -0
@@ -49,6 +49,11 @@ SYM_FUNC_START(startup_64_mixed_mode) lea efi32_boot_args(%rip), %rdx mov 0(%rdx), %edi mov 4(%rdx), %esi + + /* Switch to the firmware's stack */ + movl efi32_boot_sp(%rip), %esp + andl $~7, %esp + #ifdef CONFIG_EFI_HANDOVER_PROTOCOL mov 8(%rdx), %edx // saved bootparams pointer test %edx, %edx
@@ -254,6 +259,9 @@ SYM_FUNC_START_LOCAL(efi32_entry) /* Store firmware IDT descriptor */ sidtl (efi32_boot_idt - 1b)(%ebx) + /* Store firmware stack pointer */ + movl %esp, (efi32_boot_sp - 1b)(%ebx) + /* Store boot arguments */ leal (efi32_boot_args - 1b)(%ebx), %ebx movl %ecx, 0(%ebx)
@@ -318,5 +326,6 @@ SYM_DATA_END(efi32_boot_idt) SYM_DATA_LOCAL(efi32_boot_cs, .word 0) SYM_DATA_LOCAL(efi32_boot_ds, .word 0) +SYM_DATA_LOCAL(efi32_boot_sp, .long 0) SYM_DATA_LOCAL(efi32_boot_args, .long 0, 0, 0) SYM_DATA(efi_is64, .byte 1)
Greg Kroah-Hartman
maintainerPATCH 292/432 ASoC: amd: yc: Revert "Fix non-functional mic on Lenovo 21J2"
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiawei Wang <[email protected]>
commit 861b3415e4dee06cc00cd1754808a7827b9105bf upstream.
This reverts commit ed00a6945dc32462c2d3744a3518d2316da66fcc, which added a quirk entry to enable the Yellow Carp (YC) driver for the Lenovo 21J2 laptop.
Although the microphone functioned with the YC driver, it resulted in incorrect driver usage. The Lenovo 21J2 is not a Yellow Carp platform, but a Pink Sardine platform, which already has an upstreamed driver.
The microphone on the Lenovo 21J2 operates correctly with the CONFIG_SND_SOC_AMD_PS flag enabled and does not require the quirk entry. So this patch removes the quirk entry.
Thanks to Mukunda Vijendar [1] for pointing this out.
--- sound/soc/amd/yc/acp6x-mach.c | 7 ------- 1 file changed, 7 deletions(-)
sound/soc/amd/yc/acp6x-mach.c +0 -7
@@ -203,13 +203,6 @@ static const struct dmi_system_id yc_acp .driver_data = &acp6x_card, .matches = {DMI_MATCH (DMI_BOARD_VENDOR ,"LENOVO" ), - DMI_MATCH(DMI_PRODUCT_NAME, "21J2"), - } - }, - { - .driver_data = &acp6x_card, - .matches = { -DMI_MATCH (DMI_BOARD_VENDOR ,"LENOVO" ), DMI_MATCH(DMI_PRODUCT_NAME, "21J0"), } },
Greg Kroah-Hartman
maintainerPATCH 293/432 Fix memory leak in posix_clock_open()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Torvalds <[email protected]>
commit 5b4cdd9c5676559b8a7c944ac5269b914b8c0bb8 upstream.
If the clk ops.open() function returns an error, we don't release the pccontext we allocated for this clock.
Re-organize the code slightly to make it all more obvious.
--- kernel/time/posix-clock.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
kernel/time/posix-clock.c +9 -7
@@ -129,15 +129,17 @@ static int posix_clock_open(struct inode goto out; } pccontext->clk = clk; - fp->private_data = pccontext; -if (clk->ops.open) +if (clk->ops.open) { err = clk->ops.open (pccontext, fp->f_mode); -else - err =0 ; - -if (!err) { -get_device (clk->dev); +if (err) { +kfree (pccontext); + goto out; + } } + + fp->private_data = pccontext; +get_device (clk->dev); + err =0 ; out:up_read (&clk->rwsem);return err;
Greg Kroah-Hartman
maintainerPATCH 294/432 wifi: rtw88: 8821cu: Fix connection failure
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bitterblue Smith <[email protected]>
commit 605d7c0b05eecb985273b1647070497142c470d3 upstream.
Clear bit 8 of REG_SYS_STATUS1 after MAC power on.
Without this, some RTL8821CU and RTL8811CU cannot connect to any network:
Feb 19 13:33:11 ideapad2 kernel: wlp3s0f3u2: send auth to 90:55:de:__:__:__ (try 1/3) Feb 19 13:33:13 ideapad2 kernel: wlp3s0f3u2: send auth to 90:55:de:__:__:__ (try 2/3) Feb 19 13:33:14 ideapad2 kernel: wlp3s0f3u2: send auth to 90:55:de:__:__:__ (try 3/3) Feb 19 13:33:15 ideapad2 kernel: wlp3s0f3u2: authentication with 90:55:de:__:__:__ timed out
The RTL8822CU and RTL8822BU out-of-tree drivers do this as well, so do it for all three types of chips.
Tested with RTL8811CU (Tenda U9 V2.0).
--- drivers/net/wireless/realtek/rtw88/mac.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/wireless/realtek/rtw88/mac.c +7 -0
@@ -309,6 +309,13 @@ static int rtw_mac_power_switch(struct r pwr_seq = pwr_on ? chip->pwr_on_seq : chip->pwr_off_seq; ret =rtw_pwr_seq_parser (rtwdev, pwr_seq); +if (pwr_on &&rtw_hci_type (rtwdev) ==RTW_HCI_TYPE_USB ) { +if (chip->id ==RTW_CHIP_TYPE_8822C || + chip->id ==RTW_CHIP_TYPE_8822B || + chip->id ==RTW_CHIP_TYPE_8821C ) +rtw_write8_clr (rtwdev,REG_SYS_STATUS1 +1 ,BIT (0 )); + } +if (rtw_hci_type (rtwdev) ==RTW_HCI_TYPE_SDIO )rtw_write32 (rtwdev,REG_SDIO_HIMR , imr);
Greg Kroah-Hartman
maintainerPATCH 295/432 btrfs: fix deadlock with fiemap and extent locking
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
commit b0ad381fa7690244802aed119b478b4bdafc31dd upstream.
While working on the patchset to remove extent locking I got a lockdep splat with fiemap and pagefaulting with my new extent lock replacement lock.
This deadlock exists with our normal code, we just don't have lockdep annotations with the extent locking so we've never noticed it.
Since we're copying the fiemap extent to user space on every iteration we have the chance of pagefaulting. Because we hold the extent lock for the entire range we could mkwrite into a range in the file that we have mmap'ed. This would deadlock with the following stack trace
[<0>] lock_extent+0x28d/0x2f0 [<0>] btrfs_page_mkwrite+0x273/0x8a0 [<0>] do_page_mkwrite+0x50/0xb0 [<0>] do_fault+0xc1/0x7b0 [<0>] __handle_mm_fault+0x2fa/0x460 [<0>] handle_mm_fault+0xa4/0x330 [<0>] do_user_addr_fault+0x1f4/0x800 [<0>] exc_page_fault+0x7c/0x1e0 [<0>] asm_exc_page_fault+0x26/0x30 [<0>] rep_movs_alternative+0x33/0x70 [<0>] _copy_to_user+0x49/0x70 [<0>] fiemap_fill_next_extent+0xc8/0x120 [<0>] emit_fiemap_extent+0x4d/0xa0 [<0>] extent_fiemap+0x7f8/0xad0 [<0>] btrfs_fiemap+0x49/0x80 [<0>] __x64_sys_ioctl+0x3e1/0xb50 [<0>] do_syscall_64+0x94/0x1a0 [<0>] entry_SYSCALL_64_after_hwframe+0x6e/0x76
I wrote an fstest to reproduce this deadlock without my replacement lock and verified that the deadlock exists with our existing locking.
To fix this simply don't take the extent lock for the entire duration of the fiemap. This is safe in general because we keep track of where we are when we're searching the tree, so if an ordered extent updates in the middle of our fiemap call we'll still emit the correct extents because we know what offset we were on before.
The only place we maintain the lock is searching delalloc. Since the delalloc stuff can change during writeback we want to lock the extent range so we have a consistent view of delalloc at the time we're checking to see if we need to set the delalloc flag.
With this patch applied we no longer deadlock with my testcase.
--- fs/btrfs/extent_io.c | 62 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 17 deletions(-)
fs/btrfs/extent_io.c +45 -17
@@ -2734,16 +2734,34 @@ static int fiemap_process_hole(struct bt* it beyond i_size. */ while (cur_offset < end && cur_offset < i_size) { +struct extent_state *cached_state =NULL ;u64 delalloc_start;u64 delalloc_end;u64 prealloc_start; +u64 lockstart; +u64 lockend;u64 prealloc_len =0 ;bool delalloc; + lockstart =round_down (cur_offset, inode->root->fs_info->sectorsize); + lockend =round_up (end, inode->root->fs_info->sectorsize); + +/* +* We are only locking for the delalloc range because that's the +* only thing that can change here. With fiemap we have a lock +* on the inode, so no buffered or direct writes can happen. +* +* However mmaps and normal page writeback will cause this to +* change arbitrarily. We have to lock the extent lock here to +* make sure that nobody messes with the tree while we're doing +* btrfs_find_delalloc_in_range. +*/ +lock_extent (&inode->io_tree, lockstart, lockend, &cached_state); delalloc =btrfs_find_delalloc_in_range (inode, cur_offset, end, delalloc_cached_state, &delalloc_start, &delalloc_end); +unlock_extent (&inode->io_tree, lockstart, lockend, &cached_state);if (!delalloc)break ;
@@ -2911,15 +2929,15 @@ int extent_fiemap(struct btrfs_inode *in u64 start, u64 len) {const u64 ino =btrfs_ino (inode); -struct extent_state *cached_state =NULL ;struct extent_state *delalloc_cached_state =NULL ;struct btrfs_path *path;struct fiemap_cache cache = {0 };struct btrfs_backref_share_check_ctx *backref_ctx;u64 last_extent_end;u64 prev_extent_end; -u64 lockstart; -u64 lockend; +u64 range_start; +u64 range_end; +const u64 sectorsize = inode->root->fs_info->sectorsize;bool stopped = false;int ret;
@@ -2930,12 +2948,11 @@ int extent_fiemap(struct btrfs_inode *in goto out; } - lockstart =round_down (start, inode->root->fs_info->sectorsize); - lockend =round_up (start + len, inode->root->fs_info->sectorsize); - prev_extent_end = lockstart; + range_start =round_down (start, sectorsize); + range_end =round_up (start + len, sectorsize); + prev_extent_end = range_start;btrfs_inode_lock (inode,BTRFS_ILOCK_SHARED ); -lock_extent (&inode->io_tree, lockstart, lockend, &cached_state); ret =fiemap_find_last_extent_offset (inode, path, &last_extent_end);if (ret <0 )
@@ -2943,7 +2960,7 @@ int extent_fiemap(struct btrfs_inode *inbtrfs_release_path (path); path->reada =READA_FORWARD ; - ret =fiemap_search_slot (inode, path, lockstart); + ret =fiemap_search_slot (inode, path, range_start);if (ret <0 ) { goto out_unlock; }else if (ret >0 ) {
@@ -2955,7 +2972,7 @@ int extent_fiemap(struct btrfs_inode *in goto check_eof_delalloc; } -while (prev_extent_end < lockend) { +while (prev_extent_end < range_end) {struct extent_buffer *leaf = path->nodes[0 ];struct btrfs_file_extent_item *ei;struct btrfs_key key;
@@ -2978,19 +2995,19 @@ int extent_fiemap(struct btrfs_inode *in* The first iteration can leave us at an extent item that ends * before our range's start. Move to the next item. */ -if (extent_end <= lockstart) +if (extent_end <= range_start) goto next_item; backref_ctx->curr_leaf_bytenr = leaf->start;/* We have in implicit hole (NO_HOLES feature enabled). */ if (prev_extent_end < key.offset) { -const u64 range_end =min (key.offset, lockend) -1 ; +const u64 hole_end =min (key.offset, range_end) -1 ; ret =fiemap_process_hole (inode, fieinfo, &cache, &delalloc_cached_state, backref_ctx,0 ,0 ,0 , - prev_extent_end, range_end); + prev_extent_end, hole_end);if (ret <0 ) { goto out_unlock; }else if (ret >0 ) {
@@ -3000,7 +3017,7 @@ int extent_fiemap(struct btrfs_inode *in }/* We've reached the end of the fiemap range, stop. */ -if (key.offset >= lockend) { +if (key.offset >= range_end) { stopped = true;break ; }
@@ -3094,29 +3111,41 @@ check_eof_delalloc:btrfs_free_path (path); path =NULL ; -if (!stopped && prev_extent_end < lockend) { +if (!stopped && prev_extent_end < range_end) { ret =fiemap_process_hole (inode, fieinfo, &cache, &delalloc_cached_state, backref_ctx, -0 ,0 ,0 , prev_extent_end, lockend -1 ); +0 ,0 ,0 , prev_extent_end, range_end -1 );if (ret <0 ) goto out_unlock; - prev_extent_end = lockend; + prev_extent_end = range_end; }if (cache.cached && cache.offset + cache.len >= last_extent_end) {const u64 i_size =i_size_read (&inode->vfs_inode);if (prev_extent_end < i_size) { +struct extent_state *cached_state =NULL ;u64 delalloc_start;u64 delalloc_end; +u64 lockstart; +u64 lockend;bool delalloc; + lockstart =round_down (prev_extent_end, sectorsize); + lockend =round_up (i_size, sectorsize); + +/* +* See the comment in fiemap_process_hole as to why +* we're doing the locking here. +*/ +lock_extent (&inode->io_tree, lockstart, lockend, &cached_state); delalloc =btrfs_find_delalloc_in_range (inode, prev_extent_end, i_size -1 , &delalloc_cached_state, &delalloc_start, &delalloc_end); +unlock_extent (&inode->io_tree, lockstart, lockend, &cached_state);if (!delalloc) cache.flags |=FIEMAP_EXTENT_LAST ; }else {
@@ -3127,7 +3156,6 @@ check_eof_delalloc: ret =emit_last_fiemap_cache (fieinfo, &cache); out_unlock: -unlock_extent (&inode->io_tree, lockstart, lockend, &cached_state);btrfs_inode_unlock (inode,BTRFS_ILOCK_SHARED ); out:free_extent_state (delalloc_cached_state);
Greg Kroah-Hartman
maintainerPATCH 296/432 x86/Kconfig: Remove CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Borislav Petkov (AMD) <[email protected]>
commit 29956748339aa8757a7e2f927a8679dd08f24bb6 upstream.
It was meant well at the time but nothing's using it so get rid of it.
--- Documentation/admin-guide/kernel-parameters.txt | 4 +--- Documentation/arch/x86/amd-memory-encryption.rst | 16 ++++++++-------- arch/x86/Kconfig | 13 ------------- arch/x86/mm/mem_encrypt_identity.c | 11 +---------- 4 files changed, 10 insertions(+), 34 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +1 -3
@@ -3327,9 +3327,7 @@ mem_encrypt= [X86-64] AMD Secure Memory Encryption (SME) control Valid arguments: on, off - Default (depends on kernel configuration option): - on (CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT=y) - off (CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT=n) + Default: off mem_encrypt=on: Activate SME mem_encrypt=off: Do not activate SME
Documentation/arch/x86/amd-memory-encryption.rst +8 -8
@@ -87,14 +87,14 @@ The state of SME in the Linux kernel can kernel is non-zero). SME can also be enabled and activated in the BIOS. If SME is enabled and -activated in the BIOS, then all memory accesses will be encrypted and it will -not be necessary to activate the Linux memory encryption support. If the BIOS -merely enables SME (sets bit 23 of the MSR_AMD64_SYSCFG), then Linux can activate -memory encryption by default (CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT=y) or -by supplying mem_encrypt=on on the kernel command line. However, if BIOS does -not enable SME, then Linux will not be able to activate memory encryption, even -if configured to do so by default or the mem_encrypt=on command line parameter -is specified. +activated in the BIOS, then all memory accesses will be encrypted and it +will not be necessary to activate the Linux memory encryption support. + +If the BIOS merely enables SME (sets bit 23 of the MSR_AMD64_SYSCFG), +then memory encryption can be enabled by supplying mem_encrypt=on on the +kernel command line. However, if BIOS does not enable SME, then Linux +will not be able to activate memory encryption, even if configured to do +so by default or the mem_encrypt=on command line parameter is specified. Secure Nested Paging (SNP) ==========================
arch/x86/Kconfig +0 -13
@@ -1539,19 +1539,6 @@ config AMD_MEM_ENCRYPT This requires an AMD processor that supports Secure Memory Encryption (SME). -config AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT - bool "Activate AMD Secure Memory Encryption (SME) by default" - depends on AMD_MEM_ENCRYPT - help - Say yes to have system memory encrypted by default if running on - an AMD processor that supports Secure Memory Encryption (SME). - - If set to Y, then the encryption of system memory can be - deactivated with the mem_encrypt=off command line option. - - If set to N, then the encryption of system memory can be - activated with the mem_encrypt=on command line option. - # Common NUMA Features config NUMA bool "NUMA Memory Allocation and Scheduler Support"
arch/x86/mm/mem_encrypt_identity.c +1 -10
@@ -97,7 +97,6 @@ static char sme_workarea[2 * PMD_SIZE] _static char sme_cmdline_arg[]__initdata ="mem_encrypt" ;static char sme_cmdline_on[]__initdata ="on" ; -static char sme_cmdline_off[]__initdata ="off" ;static void __init sme_clear_pgd (struct sme_populate_pgd_data *ppd) {
@@ -504,7 +503,7 @@ void __init sme_encrypt_kernel(struct bovoid __init sme_enable (struct boot_params *bp) { -const char *cmdline_ptr, *cmdline_arg, *cmdline_on, *cmdline_off; +const char *cmdline_ptr, *cmdline_arg, *cmdline_on;unsigned int eax, ebx, ecx, edx;unsigned long feature_mask;unsigned long me_mask;
@@ -587,12 +586,6 @@ void __init sme_enable(struct boot_param asm ("lea sme_cmdline_on(%%rip), %0" :"=r" (cmdline_on) :"p" (sme_cmdline_on)); - asm ("lea sme_cmdline_off(%%rip), %0" - :"=r" (cmdline_off) - :"p" (sme_cmdline_off)); - -if (IS_ENABLED (CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT )) - sme_me_mask = me_mask; cmdline_ptr = (const char *)((u64 )bp->hdr.cmd_line_ptr | ((u64 )bp->ext_cmd_line_ptr <<32 ));
@@ -602,8 +595,6 @@ void __init sme_enable(struct boot_paramif (!strncmp (buffer, cmdline_on,sizeof (buffer))) sme_me_mask = me_mask; -else if (!strncmp (buffer, cmdline_off,sizeof (buffer))) - sme_me_mask =0 ; out:if (sme_me_mask) {
Greg Kroah-Hartman
maintainerPATCH 297/432 x86/sev: Fix position dependent variable references in startup code
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit 1c811d403afd73f04bde82b83b24c754011bd0e8 upstream.
The early startup code executes from a 1:1 mapping of memory, which differs from the mapping that the code was linked and/or relocated to run at. The latter mapping is not active yet at this point, and so symbol references that rely on it will fault.
Given that the core kernel is built without -fPIC, symbol references are typically emitted as absolute, and so any such references occuring in the early startup code will therefore crash the kernel.
While an attempt was made to work around this for the early SEV/SME startup code, by forcing RIP-relative addressing for certain global SEV/SME variables via inline assembly (see snp_cpuid_get_table() for example), RIP-relative addressing must be pervasively enforced for SEV/SME global variables when accessed prior to page table fixups.
__startup_64() already handles this issue for select non-SEV/SME global variables using fixup_pointer(), which adjusts the pointer relative to a physaddr argument. To avoid having to pass around this physaddr argument across all functions needing to apply pointer fixups, introduce a macro RIP_RELATIVE_REF() which generates a RIP-relative reference to a given global variable. It is used where necessary to force RIP-relative accesses to global variables.
For backporting purposes, this patch makes no attempt at cleaning up other occurrences of this pattern, involving either inline asm or fixup_pointer(). Those will be addressed later.
[ bp: Call it "rip_rel_ref" everywhere like other code shortens
"rIP-relative reference" and make the asm wrapper __always_inline. ]
--- arch/x86/coco/core.c | 7 +------ arch/x86/include/asm/asm.h | 14 ++++++++++++++ arch/x86/include/asm/coco.h | 8 +++++++- arch/x86/include/asm/mem_encrypt.h | 15 +++++++++------ arch/x86/kernel/sev-shared.c | 12 ++++++------ arch/x86/kernel/sev.c | 4 ++-- arch/x86/mm/mem_encrypt_identity.c | 27 ++++++++++++--------------- 7 files changed, 51 insertions(+), 36 deletions(-)
arch/x86/coco/core.c +1 -6
@@ -14,7 +14,7 @@#include <asm/processor.h> enum cc_vendor cc_vendor__ro_after_init =CC_VENDOR_NONE ; -static u64 cc_mask__ro_after_init ; +u64 cc_mask__ro_after_init ; static bool noinstr intel_cc_platform_has(enum cc_attr attr) {
@@ -148,8 +148,3 @@ u64 cc_mkdec(u64 val) } }EXPORT_SYMBOL_GPL (cc_mkdec); - -__init void cc_set_mask (u64 mask) -{ - cc_mask = mask; -}
arch/x86/include/asm/asm.h +14 -0
@@ -113,6 +113,20 @@#endif +#ifndef __ASSEMBLY__ +#ifndef __pic__ +static __always_inline __pure void *rip_rel_ptr(void *p) +{ + asm("leaq %c1(%%rip), %0" :"=r" (p) :"i" (p)); + +return p; +} +#define RIP_REL_REF (var) (*(typeof(&(var)))rip_rel_ptr(&(var))) +#else +#define RIP_REL_REF (var) (var) +#endif +#endif +/* * Macros to generate condition code outputs from inline assembly, * The output operand must be type "bool".
arch/x86/include/asm/coco.h +7 -1
@@ -2,6 +2,7 @@#ifndef _ASM_X86_COCO_H#define _ASM_X86_COCO_H +#include <asm/asm.h> #include <asm/types.h> enum cc_vendor {
@@ -11,9 +12,14 @@ enum cc_vendor { };extern enum cc_vendor cc_vendor; +extern u64 cc_mask;#ifdef CONFIG_ARCH_HAS_CC_PLATFORM -void cc_set_mask (u64 mask); +static inline void cc_set_mask (u64 mask) +{ +RIP_REL_REF (cc_mask) = mask; +} +u64 cc_mkenc (u64 val);u64 cc_mkdec (u64 val);#else
arch/x86/include/asm/mem_encrypt.h +9 -6
@@ -15,7 +15,8 @@#include <linux/init.h> #include <linux/cc_platform.h> -#include <asm/bootparam.h> +#include <asm/asm.h> +struct boot_params ;#ifdef CONFIG_X86_MEM_ENCRYPT void __init mem_encrypt_init (void );
@@ -58,6 +59,11 @@ void __init mem_encrypt_free_decrypted_mvoid __init sev_es_init_vc_handling (void ); +static inline u64 sme_get_me_mask (void ) +{ +return RIP_REL_REF (sme_me_mask); +} +#define __bss_decrypted __section(".bss..decrypted")#else /* !CONFIG_AMD_MEM_ENCRYPT */
@@ -89,6 +95,8 @@ early_set_mem_enc_dec_hypercall(unsignedstatic inline void mem_encrypt_free_decrypted_mem (void ) { } +static inline u64 sme_get_me_mask (void ) {return 0 ; } +#define __bss_decrypted#endif /* CONFIG_AMD_MEM_ENCRYPT */
@@ -106,11 +114,6 @@ void add_encrypt_protection_map(void);extern char __start_bss_decrypted[], __end_bss_decrypted[], __start_bss_decrypted_unused[]; -static inline u64 sme_get_me_mask (void ) -{ -return sme_me_mask; -} -#endif /* __ASSEMBLY__ */ #endif /* __X86_MEM_ENCRYPT_H__ */
arch/x86/kernel/sev-shared.c +6 -6
@@ -556,9 +556,9 @@ static int snp_cpuid(struct ghcb *ghcb, leaf->eax = leaf->ebx = leaf->ecx = leaf->edx =0 ;/* Skip post-processing for out-of-range zero leafs. */ -if (!(leaf->fn <= cpuid_std_range_max || - (leaf->fn >=0x40000000 && leaf->fn <= cpuid_hyp_range_max) || - (leaf->fn >=0x80000000 && leaf->fn <= cpuid_ext_range_max))) +if (!(leaf->fn <=RIP_REL_REF (cpuid_std_range_max) || + (leaf->fn >=0x40000000 && leaf->fn <=RIP_REL_REF (cpuid_hyp_range_max)) || + (leaf->fn >=0x80000000 && leaf->fn <=RIP_REL_REF (cpuid_ext_range_max))))return 0 ; }
@@ -1063,11 +1063,11 @@ static void __init setup_cpuid_table(conconst struct snp_cpuid_fn *fn = &cpuid_table->fn[i];if (fn->eax_in ==0x0 ) - cpuid_std_range_max = fn->eax; +RIP_REL_REF (cpuid_std_range_max) = fn->eax;else if (fn->eax_in ==0x40000000 ) - cpuid_hyp_range_max = fn->eax; +RIP_REL_REF (cpuid_hyp_range_max) = fn->eax;else if (fn->eax_in ==0x80000000 ) - cpuid_ext_range_max = fn->eax; +RIP_REL_REF (cpuid_ext_range_max) = fn->eax; } }
arch/x86/kernel/sev.c +2 -2
@@ -748,7 +748,7 @@ void __init early_snp_set_memory_private* This eliminates worries about jump tables or checking boot_cpu_data * in the cc_platform_has() function. */ -if (!(sev_status &MSR_AMD64_SEV_SNP_ENABLED )) +if (!(RIP_REL_REF (sev_status) &MSR_AMD64_SEV_SNP_ENABLED ))return ;/*
@@ -767,7 +767,7 @@ void __init early_snp_set_memory_shared(* This eliminates worries about jump tables or checking boot_cpu_data * in the cc_platform_has() function. */ -if (!(sev_status &MSR_AMD64_SEV_SNP_ENABLED )) +if (!(RIP_REL_REF (sev_status) &MSR_AMD64_SEV_SNP_ENABLED ))return ;/* Ask hypervisor to mark the memory pages shared in the RMP table. */
arch/x86/mm/mem_encrypt_identity.c +12 -15
@@ -304,7 +304,8 @@ void __init sme_encrypt_kernel(struct bo* instrumentation or checking boot_cpu_data in the cc_platform_has() * function. */ -if (!sme_get_me_mask () || sev_status &MSR_AMD64_SEV_ENABLED ) +if (!sme_get_me_mask () || +RIP_REL_REF (sev_status) &MSR_AMD64_SEV_ENABLED )return ;/*
@@ -541,11 +542,11 @@ void __init sme_enable(struct boot_param me_mask =1UL << (ebx &0x3f );/* Check the SEV MSR whether SEV or SME is enabled */ - sev_status =__rdmsr (MSR_AMD64_SEV ); - feature_mask = (sev_status &MSR_AMD64_SEV_ENABLED ) ?AMD_SEV_BIT :AMD_SME_BIT ; +RIP_REL_REF (sev_status) = msr =__rdmsr (MSR_AMD64_SEV ); + feature_mask = (msr &MSR_AMD64_SEV_ENABLED ) ?AMD_SEV_BIT :AMD_SME_BIT ;/* The SEV-SNP CC blob should never be present unless SEV-SNP is enabled. */ -if (snp && !(sev_status &MSR_AMD64_SEV_SNP_ENABLED )) +if (snp && !(msr &MSR_AMD64_SEV_SNP_ENABLED ))snp_abort ();/* Check if memory encryption is enabled */
@@ -571,7 +572,6 @@ void __init sme_enable(struct boot_paramreturn ; }else {/* SEV state cannot be controlled by a command line option */ - sme_me_mask = me_mask; goto out; }
@@ -590,16 +590,13 @@ void __init sme_enable(struct boot_param cmdline_ptr = (const char *)((u64 )bp->hdr.cmd_line_ptr | ((u64 )bp->ext_cmd_line_ptr <<32 )); -if (cmdline_find_option (cmdline_ptr, cmdline_arg, buffer,sizeof (buffer)) <0 ) - goto out; - -if (!strncmp (buffer, cmdline_on,sizeof (buffer))) - sme_me_mask = me_mask; +if (cmdline_find_option (cmdline_ptr, cmdline_arg, buffer,sizeof (buffer)) <0 || +strncmp (buffer, cmdline_on,sizeof (buffer))) +return ; out: -if (sme_me_mask) { - physical_mask &= ~sme_me_mask; - cc_vendor =CC_VENDOR_AMD ; -cc_set_mask (sme_me_mask); - } +RIP_REL_REF (sme_me_mask) = me_mask; + physical_mask &= ~me_mask; + cc_vendor =CC_VENDOR_AMD ; +cc_set_mask (me_mask); }
Greg Kroah-Hartman
maintainerPATCH 298/432 clocksource/drivers/arm_global_timer: Fix maximum prescaler value
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Blumenstingl <[email protected]>
[ Upstream commit b34b9547cee41575a4fddf390f615570759dc999 ]
The prescaler in the "Global Timer Control Register bit assignments" is documented to use bits [15:8], which means that the maximum prescaler register value is 0xff.
--- drivers/clocksource/arm_global_timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/arm_global_timer.c +1 -1
@@ -32,7 +32,7 @@#define GT_CONTROL_IRQ_ENABLE BIT(2)/* banked */ #define GT_CONTROL_AUTO_INC BIT(3)/* banked */ #define GT_CONTROL_PRESCALER_SHIFT 8 -#define GT_CONTROL_PRESCALER_MAX 0xF +#define GT_CONTROL_PRESCALER_MAX 0xFF#define GT_CONTROL_PRESCALER_MASK (GT_CONTROL_PRESCALER_MAX << \ GT_CONTROL_PRESCALER_SHIFT)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 299/432 ARM: 9352/1: iwmmxt: Remove support for PJ4/PJ4B cores
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
[ Upstream commit b9920fdd5a751df129808e7fa512e9928223ee05 ]
PJ4 is a v7 core that incorporates a iWMMXt coprocessor. However, GCC does not support this combination (its iWMMXt configuration always implies v5te), and so there is no v6/v7 user space that actually makes use of this, beyond generic support for things like setjmp() that preserve/restore the iWMMXt register file using generic LDC/STC instructions emitted in assembler. As [0] appears to imply, this logic is triggered for the init process at boot, and so most user threads will have a iWMMXt register context associated with it, even though it is never used.
At this point, it is highly unlikely that such GCC support will ever materialize (and Clang does not implement support for iWMMXt to begin with).
This means that advertising iWMMXt support on these cores results in context switch overhead without any associated benefit, and so it is better to simply ignore the iWMMXt unit on these systems. So rip out the support. Doing so also fixes the issue reported in [0] related to UNDEF handling of co-processor #0/#1 instructions issued from user space running in Thumb2 mode.
The PJ4 cores are used in four platforms: Armada 370/xp, Dove (Cubox, d2plug), MMP2 (xo-1.75) and Berlin (Google TV). Out of these, only the first is still widely used, but that one actually doesn't have iWMMXt but instead has only VFPV3-D16, and so it is not impacted by this change.
--- arch/arm/Kconfig | 4 +- arch/arm/kernel/Makefile | 2 - arch/arm/kernel/iwmmxt.S | 51 ++++---------- arch/arm/kernel/pj4-cp0.c | 135 -------------------------------------- 4 files changed, 15 insertions(+), 177 deletions(-) delete mode 100644 arch/arm/kernel/pj4-cp0.c
arch/arm/Kconfig +2 -2
@@ -591,8 +591,8 @@ source "arch/arm/mm/Kconfig" config IWMMXT bool "Enable iWMMXt support" - depends on CPU_XSCALE || CPU_XSC3 || CPU_MOHAWK || CPU_PJ4 || CPU_PJ4B - default y if PXA27x || PXA3xx || ARCH_MMP || CPU_PJ4 || CPU_PJ4B + depends on CPU_XSCALE || CPU_XSC3 || CPU_MOHAWK + default y if PXA27x || PXA3xx || ARCH_MMP help Enable support for iWMMXt context switching at run time if running on a CPU that supports it.
arch/arm/kernel/Makefile +0 -2
@@ -75,8 +75,6 @@ obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o obj-$(CONFIG_CPU_XSCALE) += xscale-cp0.o obj-$(CONFIG_CPU_XSC3) += xscale-cp0.o obj-$(CONFIG_CPU_MOHAWK) += xscale-cp0.o -obj-$(CONFIG_CPU_PJ4) += pj4-cp0.o -obj-$(CONFIG_CPU_PJ4B) += pj4-cp0.o obj-$(CONFIG_IWMMXT) += iwmmxt.o obj-$(CONFIG_PERF_EVENTS) += perf_regs.o perf_callchain.o obj-$(CONFIG_HW_PERF_EVENTS) += perf_event_xscale.o perf_event_v6.o \
arch/arm/kernel/iwmmxt.S +13 -38
91 lines not on this page · raw message
arch/arm/kernel/pj4-cp0.c deleted +0 -135
135 lines not on this page · raw message
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 300/432 ARM: 9359/1: flush: check if the folio is reserved for no-mapping addresses
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yongqiang Liu <[email protected]>
[ Upstream commit 0c66c6f4e21cb22220cbd8821c5c73fc157d20dc ]
Since commit a4d5613c4dc6 ("arm: extend pfn_valid to take into account freed memory map alignment") changes the semantics of pfn_valid() to check presence of the memory map for a PFN. A valid page for an address which is reserved but not mapped by the kernel[1], the system crashed during some uio test with the following memory layout:
node 0: [mem 0x00000000c0a00000-0x00000000cc8fffff]
node 0: [mem 0x00000000d0000000-0x00000000da1fffff]
the uio layout is:0xc0900000, 0x100000
the crash backtrace like:
Unable to handle kernel paging request at virtual address bff00000 [...] CPU: 1 PID: 465 Comm: startapp.bin Tainted: G O 5.10.0 #1 Hardware name: Generic DT based system PC is at b15_flush_kern_dcache_area+0x24/0x3c LR is at __sync_icache_dcache+0x6c/0x98 [...] (b15_flush_kern_dcache_area) from (__sync_icache_dcache+0x6c/0x98) (__sync_icache_dcache) from (set_pte_at+0x28/0x54) (set_pte_at) from (remap_pfn_range+0x1a0/0x274) (remap_pfn_range) from (uio_mmap+0x184/0x1b8 [uio]) (uio_mmap [uio]) from (__mmap_region+0x264/0x5f4) (__mmap_region) from (__do_mmap_mm+0x3ec/0x440) (__do_mmap_mm) from (do_mmap+0x50/0x58) (do_mmap) from (vm_mmap_pgoff+0xfc/0x188) (vm_mmap_pgoff) from (ksys_mmap_pgoff+0xac/0xc4) (ksys_mmap_pgoff) from (ret_fast_syscall+0x0/0x5c) Code: e0801001 e2423001 e1c00003 f57ff04f (ee070f3e) ---[ end trace 09cf0734c3805d52 ]--- Kernel panic - not syncing: Fatal exception
So check if PG_reserved was set to solve this issue.
[1]: https://lore.kernel.org/lkml/[email protected]/
--- arch/arm/mm/flush.c | 3 +++ 1 file changed, 3 insertions(+)
arch/arm/mm/flush.c +3 -0
@@ -296,6 +296,9 @@ void __sync_icache_dcache(pte_t pteval)return ; folio =page_folio (pfn_to_page (pfn)); +if (folio_test_reserved (folio)) +return ; +if (cache_is_vipt_aliasing ()) mapping =folio_flush_mapping (folio);else
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 301/432 entry: Respect changes to system call number by trace_sys_enter()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: André Rösti <[email protected]>
[ Upstream commit fb13b11d53875e28e7fbf0c26b288e4ea676aa9f ]
When a probe is registered at the trace_sys_enter() tracepoint, and that probe changes the system call number, the old system call still gets executed. This worked correctly until commit b6ec41346103 ("core/entry:
Report syscall correctly for trace and audit"), which removed the re-evaluation of the syscall number after the trace point.
Restore the original semantics by re-evaluating the system call number after trace_sys_enter().
The performance impact of this re-evaluation is minimal because it only takes place when a trace point is active, and compared to the actual trace point overhead the read from a cache hot variable is negligible.
--- kernel/entry/common.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
kernel/entry/common.c +7 -1
@@ -77,8 +77,14 @@ static long syscall_trace_enter(struct pt_regs *regs, long syscall,/* Either of the above might have changed the syscall number */ syscall =syscall_get_nr (current, regs); -if (unlikely (work &SYSCALL_WORK_SYSCALL_TRACEPOINT )) +if (unlikely (work &SYSCALL_WORK_SYSCALL_TRACEPOINT )) {trace_sys_enter (regs, syscall); +/* +* Probes or BPF hooks in the tracepoint may have changed the +* system call number as well. +*/ + syscall =syscall_get_nr (current, regs); + }syscall_enter_audit (regs, syscall);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 302/432 swiotlb: Fix double-allocation of slots due to broken alignment handling
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Will Deacon <[email protected]>
[ Upstream commit 04867a7a33324c9c562ee7949dbcaab7aaad1fb4 ]
Commit bbb73a103fbb ("swiotlb: fix a braino in the alignment check fix"), which was a fix for commit 0eee5ae10256 ("swiotlb: fix slot alignment checks"), causes a functional regression with vsock in a virtual machine using bouncing via a restricted DMA SWIOTLB pool.
When virtio allocates the virtqueues for the vsock device using dma_alloc_coherent(), the SWIOTLB search can return page-unaligned allocations if 'area->index' was left unaligned by a previous allocation from the buffer:
# Final address in brackets is the SWIOTLB address returned to the caller
| virtio-pci 0000:00:07.0: orig_addr 0x0 alloc_size 0x2000, iotlb_align_mask 0x800 stride 0x2: got slot 1645-1649/7168 (0x98326800) | virtio-pci 0000:00:07.0: orig_addr 0x0 alloc_size 0x2000, iotlb_align_mask 0x800 stride 0x2: got slot 1649-1653/7168 (0x98328800) | virtio-pci 0000:00:07.0: orig_addr 0x0 alloc_size 0x2000, iotlb_align_mask 0x800 stride 0x2: got slot 1653-1657/7168 (0x9832a800)
This ends badly (typically buffer corruption and/or a hang) because swiotlb_alloc() is expecting a page-aligned allocation and so blindly returns a pointer to the 'struct page' corresponding to the allocation, therefore double-allocating the first half (2KiB slot) of the 4KiB page.
Fix the problem by treating the allocation alignment separately to any additional alignment requirements from the device, using the maximum of the two as the stride to search the buffer slots and taking care to ensure a minimum of page-alignment for buffers larger than a page.
This also resolves swiotlb allocation failures occuring due to the inclusion of ~PAGE_MASK in 'iotlb_align_mask' for large allocations and resulting in alignment requirements exceeding swiotlb_max_mapping_size().
--- kernel/dma/swiotlb.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-)
kernel/dma/swiotlb.c +14 -12
@@ -982,7 +982,7 @@ static int swiotlb_area_find_slots(struct device *dev, struct io_tlb_pool *pool,phys_to_dma_unencrypted (dev, pool->start) & boundary_mask;unsigned long max_slots =get_max_slots (boundary_mask);unsigned int iotlb_align_mask = -dma_get_min_align_mask (dev) | alloc_align_mask; +dma_get_min_align_mask (dev) & ~(IO_TLB_SIZE -1 );unsigned int nslots =nr_slots (alloc_size), stride;unsigned int offset =swiotlb_align_offset (dev, orig_addr);unsigned int index, slots_checked, count =0 , i;
@@ -994,18 +994,17 @@ static int swiotlb_area_find_slots(struct device *dev, struct io_tlb_pool *pool,BUG_ON (area_index >= pool->nareas);/* -* For allocations of PAGE_SIZE or larger only look for page aligned -* allocations. +* For mappings with an alignment requirement don't bother looping to +* unaligned slots once we found an aligned one. */ -if (alloc_size >=PAGE_SIZE ) - iotlb_align_mask |= ~PAGE_MASK ; - iotlb_align_mask &= ~(IO_TLB_SIZE -1 ); + stride =get_max_slots (max (alloc_align_mask, iotlb_align_mask));/* -* For mappings with an alignment requirement don't bother looping to -* unaligned slots once we found an aligned one. +* For allocations of PAGE_SIZE or larger only look for page aligned +* allocations. */ - stride = (iotlb_align_mask >>IO_TLB_SHIFT ) +1 ; +if (alloc_size >=PAGE_SIZE ) + stride =umax (stride,PAGE_SHIFT -IO_TLB_SHIFT +1 );spin_lock_irqsave (&area->lock, flags);if (unlikely (nslots > pool->area_nslabs - area->used))
@@ -1015,11 +1014,14 @@ static int swiotlb_area_find_slots(struct device *dev, struct io_tlb_pool *pool, index = area->index;for (slots_checked =0 ; slots_checked < pool->area_nslabs; ) { +phys_addr_t tlb_addr; + slot_index = slot_base + index; + tlb_addr =slot_addr (tbl_dma_addr, slot_index); -if (orig_addr && - (slot_addr (tbl_dma_addr, slot_index) & - iotlb_align_mask) != (orig_addr & iotlb_align_mask)) { +if ((tlb_addr & alloc_align_mask) || + (orig_addr && (tlb_addr & iotlb_align_mask) != + (orig_addr & iotlb_align_mask))) { index =wrap_area_index (pool, index +1 ); slots_checked++;continue ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 303/432 swiotlb: Honour dma_alloc_coherent() alignment in swiotlb_alloc()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Will Deacon <[email protected]>
[ Upstream commit cbf53074a528191df82b4dba1e3d21191102255e ]
core-api/dma-api-howto.rst states the following properties of dma_alloc_coherent():
| The CPU virtual address and the DMA address are both guaranteed to | be aligned to the smallest PAGE_SIZE order which is greater than or | equal to the requested size.
However, swiotlb_alloc() passes zero for the 'alloc_align_mask' parameter of swiotlb_find_slots() and so this property is not upheld. Instead, allocations larger than a page are aligned to PAGE_SIZE,
Calculate the mask corresponding to the page order suitable for holding the allocation and pass that to swiotlb_find_slots().
--- kernel/dma/swiotlb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/dma/swiotlb.c +3 -1
@@ -1610,12 +1610,14 @@ struct page *swiotlb_alloc(struct device *dev, size_t size)struct io_tlb_mem *mem = dev->dma_io_tlb_mem;struct io_tlb_pool *pool;phys_addr_t tlb_addr; +unsigned int align;int index;if (!mem)return NULL ; - index =swiotlb_find_slots (dev,0 , size,0 , &pool); + align = (1 << (get_order (size) +PAGE_SHIFT )) -1 ; + index =swiotlb_find_slots (dev,0 , size, align, &pool);if (index ==-1 )return NULL ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 304/432 swiotlb: Fix alignment checks when both allocation and DMA masks are present
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Will Deacon <[email protected]>
[ Upstream commit 51b30ecb73b481d5fac6ccf2ecb4a309c9ee3310 ]
Nicolin reports that swiotlb buffer allocations fail for an NVME device behind an IOMMU using 64KiB pages. This is because we end up with a minimum allocation alignment of 64KiB (for the IOMMU to map the buffer safely) but a minimum DMA alignment mask corresponding to a 4KiB NVME page (i.e. preserving the 4KiB page offset from the original allocation). If the original address is not 4KiB-aligned, the allocation will fail because swiotlb_search_pool_area() erroneously compares these unmasked bits with the 64KiB-aligned candidate allocation.
Tweak swiotlb_search_pool_area() so that the DMA alignment mask is reduced based on the required alignment of the allocation.
--- kernel/dma/swiotlb.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
kernel/dma/swiotlb.c +9 -2
@@ -981,8 +981,7 @@ static int swiotlb_area_find_slots(struct device *dev, struct io_tlb_pool *pool,dma_addr_t tbl_dma_addr =phys_to_dma_unencrypted (dev, pool->start) & boundary_mask;unsigned long max_slots =get_max_slots (boundary_mask); -unsigned int iotlb_align_mask = -dma_get_min_align_mask (dev) & ~(IO_TLB_SIZE -1 ); +unsigned int iotlb_align_mask =dma_get_min_align_mask (dev);unsigned int nslots =nr_slots (alloc_size), stride;unsigned int offset =swiotlb_align_offset (dev, orig_addr);unsigned int index, slots_checked, count =0 , i;
@@ -993,6 +992,14 @@ static int swiotlb_area_find_slots(struct device *dev, struct io_tlb_pool *pool,BUG_ON (!nslots);BUG_ON (area_index >= pool->nareas); +/* +* Ensure that the allocation is at least slot-aligned and update +* 'iotlb_align_mask' to ignore bits that will be preserved when +* offsetting into the allocation. +*/ + alloc_align_mask |= (IO_TLB_SIZE -1 ); + iotlb_align_mask &= ~alloc_align_mask; +/* * For mappings with an alignment requirement don't bother looping to * unaligned slots once we found an aligned one.
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 305/432 iommu/dma: Force swiotlb_max_mapping_size on an untrusted device
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolin Chen <[email protected]>
[ Upstream commit afc5aa46ed560f01ceda897c053c6a40c77ce5c4 ]
The swiotlb does not support a mapping size > swiotlb_max_mapping_size().
On the other hand, with a 64KB PAGE_SIZE configuration, it's observed that
an NVME device can map a size between 300KB~512KB, which certainly failed
the swiotlb mappings, though the default pool of swiotlb has many slots:
systemd[1]: Started Journal Service.
=> nvme 0000:00:01.0: swiotlb buffer is full (sz: 327680 bytes), total 32768 (slots), used 32 (slots)
note: journal-offline[392] exited with irqs disabled
note: journal-offline[392] exited with preempt_count 1
Call trace: [ 3.099918] swiotlb_tbl_map_single+0x214/0x240 [ 3.099921] iommu_dma_map_page+0x218/0x328 [ 3.099928] dma_map_page_attrs+0x2e8/0x3a0 [ 3.101985] nvme_prep_rq.part.0+0x408/0x878 [nvme] [ 3.102308] nvme_queue_rqs+0xc0/0x300 [nvme] [ 3.102313] blk_mq_flush_plug_list.part.0+0x57c/0x600 [ 3.102321] blk_add_rq_to_plug+0x180/0x2a0 [ 3.102323] blk_mq_submit_bio+0x4c8/0x6b8 [ 3.103463] __submit_bio+0x44/0x220 [ 3.103468] submit_bio_noacct_nocheck+0x2b8/0x360 [ 3.103470] submit_bio_noacct+0x180/0x6c8 [ 3.103471] submit_bio+0x34/0x130 [ 3.103473] ext4_bio_write_folio+0x5a4/0x8c8 [ 3.104766] mpage_submit_folio+0xa0/0x100 [ 3.104769] mpage_map_and_submit_buffers+0x1a4/0x400 [ 3.104771] ext4_do_writepages+0x6a0/0xd78 [ 3.105615] ext4_writepages+0x80/0x118 [ 3.105616] do_writepages+0x90/0x1e8 [ 3.105619] filemap_fdatawrite_wbc+0x94/0xe0 [ 3.105622] __filemap_fdatawrite_range+0x68/0xb8 [ 3.106656] file_write_and_wait_range+0x84/0x120 [ 3.106658] ext4_sync_file+0x7c/0x4c0 [ 3.106660] vfs_fsync_range+0x3c/0xa8 [ 3.106663] do_fsync+0x44/0xc0
Since untrusted devices might go down the swiotlb pathway with dma-iommu, these devices should not map a size larger than swiotlb_max_mapping_size.
To fix this bug, add iommu_dma_max_mapping_size() for untrusted devices to take into account swiotlb_max_mapping_size() v.s. iova_rcache_range() from the iommu_dma_opt_mapping_size().
--- drivers/iommu/dma-iommu.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/iommu/dma-iommu.c +9 -0
@@ -1706,6 +1706,14 @@ static size_t iommu_dma_opt_mapping_size(void)return iova_rcache_range (); } +static size_t iommu_dma_max_mapping_size (struct device *dev) +{ +if (dev_is_untrusted (dev)) +return swiotlb_max_mapping_size (dev); + +return SIZE_MAX ; +} +static const struct dma_map_ops iommu_dma_ops = { .flags =DMA_F_PCI_P2PDMA_SUPPORTED , .alloc = iommu_dma_alloc,
@@ -1728,6 +1736,7 @@ static const struct dma_map_ops iommu_dma_ops = { .unmap_resource = iommu_dma_unmap_resource, .get_merge_boundary = iommu_dma_get_merge_boundary, .opt_mapping_size = iommu_dma_opt_mapping_size, + .max_mapping_size = iommu_dma_max_mapping_size, };/*
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 306/432 printk: Update @console_may_schedule in console_trylock_spinning()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Ogness <[email protected]>
[ Upstream commit 8076972468584d4a21dab9aa50e388b3ea9ad8c7 ]
console_trylock_spinning() may takeover the console lock from a schedulable context. Update @console_may_schedule to make sure it reflects a trylock acquire.
--- kernel/printk/printk.c | 6 ++++++ 1 file changed, 6 insertions(+)
kernel/printk/printk.c +6 -0
@@ -2026,6 +2026,12 @@ static int console_trylock_spinning(void)*/ mutex_acquire (&console_lock_dep_map,0 ,1 , _THIS_IP_); +/* +* Update @console_may_schedule for trylock because the previous +* owner may have been schedulable. +*/ + console_may_schedule =0 ; +return 1 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 307/432 irqchip/renesas-rzg2l: Implement restriction when writing ISCR register
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claudiu Beznea <[email protected]>
[ Upstream commit ef88eefb1a81a8701eabb7d5ced761a66a465a49 ]
The RZ/G2L manual (chapter "IRQ Status Control Register (ISCR)") describes the operation to clear interrupts through the ISCR register as follows:
[Write operation]
When "Falling-edge detection", "Rising-edge detection" or "Falling/Rising-edge detection" is set in IITSR:
- In case ISTAT is 1
0: IRQn interrupt detection status is cleared. 1: Invalid to write.
- In case ISTAT is 0
Invalid to write.
When "Low-level detection" is set in IITSR.:
Invalid to write.
Take the interrupt type into account when clearing interrupts through the ISCR register to avoid writing the ISCR when the interrupt type is level.
Stable-dep-of: 9eec61df55c5 ("irqchip/renesas-rzg2l: Flush posted write in irq_eoi()")
--- drivers/irqchip/irq-renesas-rzg2l.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/irqchip/irq-renesas-rzg2l.c +10 -4
@@ -72,11 +72,17 @@ static void rzg2l_irq_eoi(struct irq_data *d)unsigned int hw_irq =irqd_to_hwirq (d) -IRQC_IRQ_START ;struct rzg2l_irqc_priv *priv =irq_data_to_priv (d);u32 bit =BIT (hw_irq); -u32 reg; +u32 iitsr, iscr; - reg =readl_relaxed (priv->base +ISCR ); -if (reg & bit) -writel_relaxed (reg & ~bit, priv->base +ISCR ); + iscr =readl_relaxed (priv->base +ISCR ); + iitsr =readl_relaxed (priv->base +IITSR ); + +/* +* ISCR can only be cleared if the type is falling-edge, rising-edge or +* falling/rising-edge. +*/ +if ((iscr & bit) && (iitsr &IITSR_IITSEL_MASK (hw_irq))) +writel_relaxed (iscr & ~bit, priv->base +ISCR ); }static void rzg2l_tint_eoi (struct irq_data *d)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 308/432 irqchip/renesas-rzg2l: Flush posted write in irq_eoi()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Biju Das <[email protected]>
[ Upstream commit 9eec61df55c51415409c7cc47e9a1c8de94a0522 ]
The irq_eoi() callback of the RZ/G2L interrupt chip clears the relevant interrupt cause bit in the TSCR register by writing to it.
This write is not sufficient because the write is posted and therefore not guaranteed to immediately clear the bit. Due to that delay the CPU can raise the just handled interrupt again.
Prevent this by reading the register back which causes the posted write to be flushed to the hardware before the read completes.
--- drivers/irqchip/irq-renesas-rzg2l.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/irqchip/irq-renesas-rzg2l.c +14 -2
@@ -81,8 +81,14 @@ static void rzg2l_irq_eoi(struct irq_data *d)* ISCR can only be cleared if the type is falling-edge, rising-edge or * falling/rising-edge. */ -if ((iscr & bit) && (iitsr &IITSR_IITSEL_MASK (hw_irq))) +if ((iscr & bit) && (iitsr &IITSR_IITSEL_MASK (hw_irq))) {writel_relaxed (iscr & ~bit, priv->base +ISCR ); +/* +* Enforce that the posted write is flushed to prevent that the +* just handled interrupt is raised again. +*/ +readl_relaxed (priv->base +ISCR ); + } }static void rzg2l_tint_eoi (struct irq_data *d)
@@ -93,8 +99,14 @@ static void rzg2l_tint_eoi(struct irq_data *d)u32 reg; reg =readl_relaxed (priv->base +TSCR ); -if (reg & bit) +if (reg & bit) {writel_relaxed (reg & ~bit, priv->base +TSCR ); +/* +* Enforce that the posted write is flushed to prevent that the +* just handled interrupt is raised again. +*/ +readl_relaxed (priv->base +TSCR ); + } }static void rzg2l_irqc_eoi (struct irq_data *d)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 309/432 irqchip/renesas-rzg2l: Add macro to retrieve TITSR register offset based on registers index
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claudiu Beznea <[email protected]>
[ Upstream commit 2eca4731cc66563b3919d8753dbd74d18c39f662 ]
There are 2 TITSR registers available on the IA55 interrupt controller.
Add a macro that retrieves the TITSR register offset based on it's index. This macro is useful in when adding suspend/resume support so both TITSR registers can be accessed in a for loop.
Stable-dep-of: 853a6030303f ("irqchip/renesas-rzg2l: Prevent spurious interrupts when setting trigger type")
--- drivers/irqchip/irq-renesas-rzg2l.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/irqchip/irq-renesas-rzg2l.c +6 -8
@@ -28,8 +28,7 @@#define ISCR 0x10#define IITSR 0x14#define TSCR 0x20 -#define TITSR0 0x24 -#define TITSR1 0x28 +#define TITSR (n) (0x24 + (n) * 4)#define TITSR0_MAX_INT 16#define TITSEL_WIDTH 0x2#define TSSR (n) (0x30 + ((n) * 4))
@@ -206,8 +205,7 @@ static int rzg2l_tint_set_edge(struct irq_data *d, unsigned int type)struct rzg2l_irqc_priv *priv =irq_data_to_priv (d);unsigned int hwirq =irqd_to_hwirq (d);u32 titseln = hwirq -IRQC_TINT_START ; -u32 offset; -u8 sense; +u8 index, sense;u32 reg;switch (type &IRQ_TYPE_SENSE_MASK ) {
@@ -223,17 +221,17 @@ static int rzg2l_tint_set_edge(struct irq_data *d, unsigned int type)return -EINVAL ; } - offset =TITSR0 ; + index =0 ;if (titseln >=TITSR0_MAX_INT ) { titseln -=TITSR0_MAX_INT ; - offset =TITSR1 ; + index =1 ; }raw_spin_lock (&priv->lock); - reg =readl_relaxed (priv->base + offset); + reg =readl_relaxed (priv->base +TITSR (index)); reg &= ~(IRQ_MASK << (titseln *TITSEL_WIDTH )); reg |= sense << (titseln *TITSEL_WIDTH ); -writel_relaxed (reg, priv->base + offset); +writel_relaxed (reg, priv->base +TITSR (index));raw_spin_unlock (&priv->lock);return 0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 310/432 irqchip/renesas-rzg2l: Rename rzg2l_tint_eoi()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Biju Das <[email protected]>
[ Upstream commit 7cb6362c63df233172eaecddaf9ce2ce2f769112 ]
Rename rzg2l_tint_eoi()->rzg2l_clear_tint_int() and simplify the code by removing redundant priv and hw_irq local variables.
Stable-dep-of: 853a6030303f ("irqchip/renesas-rzg2l: Prevent spurious interrupts when setting trigger type")
--- drivers/irqchip/irq-renesas-rzg2l.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/irqchip/irq-renesas-rzg2l.c +3 -5
@@ -90,11 +90,9 @@ static void rzg2l_irq_eoi(struct irq_data *d) } } -static void rzg2l_tint_eoi (struct irq_data *d) +static void rzg2l_clear_tint_int (struct rzg2l_irqc_priv *priv,unsigned int hwirq) { -unsigned int hw_irq =irqd_to_hwirq (d) -IRQC_TINT_START ; -struct rzg2l_irqc_priv *priv =irq_data_to_priv (d); -u32 bit =BIT (hw_irq); +u32 bit =BIT (hwirq -IRQC_TINT_START );u32 reg; reg =readl_relaxed (priv->base +TSCR );
@@ -117,7 +115,7 @@ static void rzg2l_irqc_eoi(struct irq_data *d)if (hw_irq >=IRQC_IRQ_START && hw_irq <=IRQC_IRQ_COUNT )rzg2l_irq_eoi (d);else if (hw_irq >=IRQC_TINT_START && hw_irq <IRQC_NUM_IRQ ) -rzg2l_tint_eoi (d); +rzg2l_clear_tint_int (priv, hw_irq);raw_spin_unlock (&priv->lock);irq_chip_eoi_parent (d); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 311/432 irqchip/renesas-rzg2l: Rename rzg2l_irq_eoi()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Biju Das <[email protected]>
[ Upstream commit b4b5cd61a6fdd92ede0dc39f0850a182affd1323 ]
Rename rzg2l_irq_eoi()->rzg2l_clear_irq_int() and simplify the code by removing redundant priv local variable.
Stable-dep-of: 853a6030303f ("irqchip/renesas-rzg2l: Prevent spurious interrupts when setting trigger type")
--- drivers/irqchip/irq-renesas-rzg2l.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/irqchip/irq-renesas-rzg2l.c +3 -4
@@ -66,10 +66,9 @@ static struct rzg2l_irqc_priv *irq_data_to_priv(struct irq_data *data)return data->domain->host_data; } -static void rzg2l_irq_eoi (struct irq_data *d) +static void rzg2l_clear_irq_int (struct rzg2l_irqc_priv *priv,unsigned int hwirq) { -unsigned int hw_irq =irqd_to_hwirq (d) -IRQC_IRQ_START ; -struct rzg2l_irqc_priv *priv =irq_data_to_priv (d); +unsigned int hw_irq = hwirq -IRQC_IRQ_START ;u32 bit =BIT (hw_irq);u32 iitsr, iscr;
@@ -113,7 +112,7 @@ static void rzg2l_irqc_eoi(struct irq_data *d)raw_spin_lock (&priv->lock);if (hw_irq >=IRQC_IRQ_START && hw_irq <=IRQC_IRQ_COUNT ) -rzg2l_irq_eoi (d); +rzg2l_clear_irq_int (priv, hw_irq);else if (hw_irq >=IRQC_TINT_START && hw_irq <IRQC_NUM_IRQ )rzg2l_clear_tint_int (priv, hw_irq);raw_spin_unlock (&priv->lock);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 312/432 irqchip/renesas-rzg2l: Prevent spurious interrupts when setting trigger type
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Biju Das <[email protected]>
[ Upstream commit 853a6030303f8a8fa54929b68e5665d9b21aa405 ]
RZ/G2L interrupt chips require that the interrupt is masked before changing the NMI, IRQ, TINT interrupt settings. Aside of that, after setting an edge trigger type it is required to clear the interrupt status register in order to avoid spurious interrupts.
The current implementation fails to do either of that and therefore is prone to generate spurious interrupts when setting the trigger type.
Address this by:
- Ensuring that the interrupt is masked at the chip level across the update for the TINT chip
- Clearing the interrupt status register after updating the trigger mode for edge type interrupts
[ tglx: Massaged changelog and reverted the spin_lock_irqsave() change as
the set_type() callback is always called with interrupts disabled. ]
--- drivers/irqchip/irq-renesas-rzg2l.c | 36 +++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-)
drivers/irqchip/irq-renesas-rzg2l.c +32 -4
@@ -162,8 +162,10 @@ static void rzg2l_irqc_irq_enable(struct irq_data *d)static int rzg2l_irq_set_type (struct irq_data *d,unsigned int type) { -unsigned int hw_irq =irqd_to_hwirq (d) -IRQC_IRQ_START ;struct rzg2l_irqc_priv *priv =irq_data_to_priv (d); +unsigned int hwirq =irqd_to_hwirq (d); +u32 iitseln = hwirq -IRQC_IRQ_START ; +bool clear_irq_int = false;u16 sense, tmp;switch (type &IRQ_TYPE_SENSE_MASK ) {
@@ -173,14 +175,17 @@ static int rzg2l_irq_set_type(struct irq_data *d, unsigned int type)case IRQ_TYPE_EDGE_FALLING : sense =IITSR_IITSEL_EDGE_FALLING ; + clear_irq_int = true;break ;case IRQ_TYPE_EDGE_RISING : sense =IITSR_IITSEL_EDGE_RISING ; + clear_irq_int = true;break ;case IRQ_TYPE_EDGE_BOTH : sense =IITSR_IITSEL_EDGE_BOTH ; + clear_irq_int = true;break ;default :
@@ -189,21 +194,40 @@ static int rzg2l_irq_set_type(struct irq_data *d, unsigned int type)raw_spin_lock (&priv->lock); tmp =readl_relaxed (priv->base +IITSR ); - tmp &= ~IITSR_IITSEL_MASK (hw_irq); - tmp |=IITSR_IITSEL (hw_irq, sense); + tmp &= ~IITSR_IITSEL_MASK (iitseln); + tmp |=IITSR_IITSEL (iitseln, sense); +if (clear_irq_int) +rzg2l_clear_irq_int (priv, hwirq);writel_relaxed (tmp, priv->base +IITSR );raw_spin_unlock (&priv->lock);return 0 ; } +static u32 rzg2l_disable_tint_and_set_tint_source (struct irq_data *d,struct rzg2l_irqc_priv *priv, +u32 reg,u32 tssr_offset,u8 tssr_index) +{ +u32 tint = (u32 )(uintptr_t )irq_data_get_irq_chip_data (d); +u32 tien = reg & (TIEN <<TSSEL_SHIFT (tssr_offset)); + +/* Clear the relevant byte in reg */ + reg &= ~(TSSEL_MASK <<TSSEL_SHIFT (tssr_offset)); +/* Set TINT and leave TIEN clear */ + reg |= tint <<TSSEL_SHIFT (tssr_offset); +writel_relaxed (reg, priv->base +TSSR (tssr_index)); + +return reg | tien; +} +static int rzg2l_tint_set_edge (struct irq_data *d,unsigned int type) {struct rzg2l_irqc_priv *priv =irq_data_to_priv (d);unsigned int hwirq =irqd_to_hwirq (d);u32 titseln = hwirq -IRQC_TINT_START ; +u32 tssr_offset =TSSR_OFFSET (titseln); +u8 tssr_index =TSSR_INDEX (titseln);u8 index, sense; -u32 reg; +u32 reg, tssr;switch (type &IRQ_TYPE_SENSE_MASK ) {case IRQ_TYPE_EDGE_RISING :
@@ -225,10 +249,14 @@ static int rzg2l_tint_set_edge(struct irq_data *d, unsigned int type) }raw_spin_lock (&priv->lock); + tssr =readl_relaxed (priv->base +TSSR (tssr_index)); + tssr =rzg2l_disable_tint_and_set_tint_source (d, priv, tssr, tssr_offset, tssr_index); reg =readl_relaxed (priv->base +TITSR (index)); reg &= ~(IRQ_MASK << (titseln *TITSEL_WIDTH )); reg |= sense << (titseln *TITSEL_WIDTH );writel_relaxed (reg, priv->base +TITSR (index)); +rzg2l_clear_tint_int (priv, hwirq); +writel_relaxed (tssr, priv->base +TSSR (tssr_index));raw_spin_unlock (&priv->lock);return 0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 313/432 kprobes/x86: Use copy_from_kernel_nofault() to read from unsafe address
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masami Hiramatsu (Google) <[email protected]>
[ Upstream commit 4e51653d5d871f40f1bd5cf95cc7f2d8b33d063b ]
Read from an unsafe address with copy_from_kernel_nofault() in arch_adjust_kprobe_addr() because this function is used before checking the address is in text or not. Syzcaller bot found a bug and reported the case if user specifies inaccessible data area, arch_adjust_kprobe_addr() will cause a kernel panic.
[ mingo: Clarified the comment. ]
--- arch/x86/kernel/kprobes/core.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
arch/x86/kernel/kprobes/core.c +10 -1
@@ -335,7 +335,16 @@ static int can_probe(unsigned long paddr)kprobe_opcode_t *arch_adjust_kprobe_addr (unsigned long addr,unsigned long offset,bool *on_func_entry) { -if (is_endbr (*(u32 *)addr)) { +u32 insn; + +/* +* Since 'addr' is not guaranteed to be safe to access, use +* copy_from_kernel_nofault() to read the instruction: +*/ +if (copy_from_kernel_nofault (&insn, (void *)addr,sizeof (u32))) +return NULL ; + +if (is_endbr (insn)) { *on_func_entry = !offset || offset ==4 ;if (*on_func_entry) offset =4 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 314/432 efi/libstub: fix efi_random_alloc() to allocate memory at alloc_min or higher address
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: KONDO KAZUMA(近藤 和真) <[email protected]>
[ Upstream commit 3cb4a4827596abc82e55b80364f509d0fefc3051 ]
Following warning is sometimes observed while booting my servers:
[ 3.594838] DMA: preallocated 4096 KiB GFP_KERNEL pool for atomic allocations [ 3.602918] swapper/0: page allocation failure: order:10, mode:0xcc1(GFP_KERNEL|GFP_DMA), nodemask=(null),cpuset=/,mems_allowed=0-1 ... [ 3.851862] DMA: preallocated 1024 KiB GFP_KERNEL|GFP_DMA pool for atomic allocation
If 'nokaslr' boot option is set, the warning always happens.
On x86, ZONE_DMA is small zone at the first 16MB of physical address space. When this problem happens, most of that space seems to be used by decompressed kernel. Thereby, there is not enough space at DMA_ZONE to meet the request of DMA pool allocation.
The commit 2f77465b05b1 ("x86/efistub: Avoid placing the kernel below LOAD_PHYSICAL_ADDR") tried to fix this problem by introducing lower bound of allocation.
But the fix is not complete.
efi_random_alloc() allocates pages by following steps.
1. Count total available slots ('total_slots')
2. Select a slot ('target_slot') to allocate randomly
3. Calculate a starting address ('target') to be included target_slot
4. Allocate pages, which starting address is 'target'
In step 1, 'alloc_min' is used to offset the starting address of memory chunk. But in step 3 'alloc_min' is not considered at all. As the result, 'target' can be miscalculated and become lower than 'alloc_min'.
When KASLR is disabled, 'target_slot' is always 0 and the problem happens everytime if the EFI memory map of the system meets the condition.
Fix this problem by calculating 'target' considering 'alloc_min'.
--- drivers/firmware/efi/libstub/randomalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/efi/libstub/randomalloc.c +1 -1
@@ -120,7 +120,7 @@ efi_status_t efi_random_alloc(unsigned long size,continue ; } - target =round_up (md->phys_addr, align) + target_slot * align; + target =round_up (max (md->phys_addr, alloc_min), align) + target_slot * align; pages = size /EFI_PAGE_SIZE ; status = efi_bs_call(allocate_pages, EFI_ALLOCATE_ADDRESS,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 315/432 x86/mpparse: Register APIC address only once
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
[ Upstream commit f2208aa12c27bfada3c15c550c03ca81d42dcac2 ]
The APIC address is registered twice. First during the early detection and afterwards when actually scanning the table for APIC IDs. The APIC and topology core warn about the second attempt.
Restrict it to the early detection call.
--- arch/x86/kernel/mpparse.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
arch/x86/kernel/mpparse.c +5 -5
@@ -196,12 +196,12 @@ static int __init smp_read_mpc(struct mpc_table *mpc, unsigned early)if (!smp_check_mpc (mpc, oem, str))return 0 ; -/* Initialize the lapic mapping */ -if (!acpi_lapic) -register_lapic_address (mpc->lapic); - -if (early) +if (early) { +/* Initialize the lapic mapping */ +if (!acpi_lapic) +register_lapic_address (mpc->lapic);return 1 ; + }/* Now process the configuration blocks. */ while (count < mpc->length) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 316/432 x86/fpu: Keep xfd_state in sync with MSR_IA32_XFD
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adamos Ttofari <[email protected]>
[ Upstream commit 10e4b5166df9ff7a2d5316138ca668b42d004422 ]
Commit 672365477ae8 ("x86/fpu: Update XFD state where required") and commit 8bf26758ca96 ("x86/fpu: Add XFD state to fpstate") introduced a per CPU variable xfd_state to keep the MSR_IA32_XFD value cached, in order to avoid unnecessary writes to the MSR.
On CPU hotplug MSR_IA32_XFD is reset to the init_fpstate.xfd, which wipes out any stale state. But the per CPU cached xfd value is not reset, which brings them out of sync.
As a consequence a subsequent xfd_update_state() might fail to update the MSR which in turn can result in XRSTOR raising a #NM in kernel space, which crashes the kernel.
To fix this, introduce xfd_set_state() to write xfd_state together with MSR_IA32_XFD, and use it in all places that set MSR_IA32_XFD.
--- arch/x86/kernel/fpu/xstate.c | 5 +++-- arch/x86/kernel/fpu/xstate.h | 14 ++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-)
arch/x86/kernel/fpu/xstate.c +3 -2
@@ -178,10 +178,11 @@ void fpu__init_cpu_xstate(void)* Must happen after CR4 setup and before xsetbv() to allow KVM * lazy passthrough. Write independent of the dynamic state static * key as that does not work on the boot CPU. This also ensures -* that any stale state is wiped out from XFD. +* that any stale state is wiped out from XFD. Reset the per CPU +* xfd cache too. */ if (cpu_feature_enabled (X86_FEATURE_XFD )) -wrmsrl (MSR_IA32_XFD , init_fpstate.xfd); +xfd_set_state (init_fpstate.xfd);/* * XCR_XFEATURE_ENABLED_MASK (aka. XCR0) sets user features
arch/x86/kernel/fpu/xstate.h +10 -4
@@ -148,20 +148,26 @@ static inline void xfd_validate_state(struct fpstate *fpstate, u64 mask, bool rs#endif #ifdef CONFIG_X86_64 +static inline void xfd_set_state (u64 xfd) +{ +wrmsrl (MSR_IA32_XFD , xfd); +__this_cpu_write (xfd_state, xfd); +} +static inline void xfd_update_state (struct fpstate *fpstate) {if (fpu_state_size_dynamic ()) {u64 xfd = fpstate->xfd; -if (__this_cpu_read (xfd_state) != xfd) { -wrmsrl (MSR_IA32_XFD , xfd); -__this_cpu_write (xfd_state, xfd); - } +if (__this_cpu_read (xfd_state) != xfd) +xfd_set_state (xfd); } }extern int __xfd_enable_feature (u64 which,struct fpu_guest *guest_fpu);#else +static inline void xfd_set_state (u64 xfd) { } +static inline void xfd_update_state (struct fpstate *fpstate) { }static inline int __xfd_enable_feature (u64 which,struct fpu_guest *guest_fpu) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 317/432 efi: fix panic in kdump kernel
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oleksandr Tymoshenko <[email protected]>
[ Upstream commit 62b71cd73d41ddac6b1760402bbe8c4932e23531 ]
Check if get_next_variable() is actually valid pointer before calling it. In kdump kernel this method is set to NULL that causes panic during the kexec-ed kernel boot.
Tested with QEMU and OVMF firmware.
--- drivers/firmware/efi/efi.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/firmware/efi/efi.c +2 -0
@@ -199,6 +199,8 @@ static bool generic_ops_supported(void) name_size =sizeof (name); +if (!efi.get_next_variable) +return false; status = efi.get_next_variable (&name_size, &name, &guid);if (status ==EFI_UNSUPPORTED )return false;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 318/432 pwm: img: fix pwm clock lookup
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zoltan HERPAI <[email protected]>
[ Upstream commit 9eb05877dbee03064d3d3483cd6702f610d5a358 ]
22e8e19 has introduced a regression in the imgchip->pwm_clk lookup, whereas the clock name has also been renamed to "imgchip". This causes the driver failing to load:
[ 0.546905] img-pwm 18101300.pwm: failed to get imgchip clock [ 0.553418] img-pwm: probe of 18101300.pwm failed with error -2
Fix this lookup by reverting the clock name back to "pwm".
--- drivers/pwm/pwm-img.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pwm/pwm-img.c +2 -2
@@ -288,9 +288,9 @@ static int img_pwm_probe(struct platform_device *pdev)return PTR_ERR (imgchip->sys_clk); } - imgchip->pwm_clk =devm_clk_get (&pdev->dev,"imgchip" ); + imgchip->pwm_clk =devm_clk_get (&pdev->dev,"pwm" );if (IS_ERR (imgchip->pwm_clk)) { -dev_err (&pdev->dev,"failed to get imgchip clock\n" ); +dev_err (&pdev->dev,"failed to get pwm clock\n" );return PTR_ERR (imgchip->pwm_clk); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 319/432 selftests/mm: gup_test: conform test to TAP format output
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Muhammad Usama Anjum <[email protected]>
[ Upstream commit cb6e7cae18868422a23d62670110c61fd1b15029 ]
Conform the layout, informational and status messages to TAP. No functional change is intended other than the layout of output messages.
Stable-dep-of: 8b65ef5ad486 ("selftests/mm: Fix build with _FORTIFY_SOURCE")
--- tools/testing/selftests/mm/gup_test.c | 65 ++++++++++++++------------- 1 file changed, 33 insertions(+), 32 deletions(-)
tools/testing/selftests/mm/gup_test.c +33 -32
@@ -50,39 +50,41 @@ static char *cmd_to_str(unsigned long cmd)void *gup_thread (void *data) {struct gup_test gup = *(struct gup_test *)data; -int i; +int i, status;/* Only report timing information on the *_BENCHMARK commands: */ if ((cmd ==PIN_FAST_BENCHMARK ) || (cmd ==GUP_FAST_BENCHMARK ) || (cmd ==PIN_LONGTERM_BENCHMARK )) {for (i =0 ; i < repeats; i++) { gup.size = size; -if (ioctl (gup_fd, cmd, &gup)) -perror ("ioctl" ),exit (1 ); + status =ioctl (gup_fd, cmd, &gup); +if (status) +break ;pthread_mutex_lock (&print_mutex); -printf ("%s: Time: get:%lld put:%lld us" , -cmd_to_str (cmd), gup.get_delta_usec, - gup.put_delta_usec); +ksft_print_msg ("%s: Time: get:%lld put:%lld us" , +cmd_to_str (cmd), gup.get_delta_usec, + gup.put_delta_usec);if (gup.size != size) -printf (", truncated (size: %lld)" , gup.size); -printf ("\n" ); +ksft_print_msg (", truncated (size: %lld)" , gup.size); +ksft_print_msg ("\n" );pthread_mutex_unlock (&print_mutex); } }else { gup.size = size; -if (ioctl (gup_fd, cmd, &gup)) { -perror ("ioctl" ); -exit (1 ); - } + status =ioctl (gup_fd, cmd, &gup); +if (status) + goto return_;pthread_mutex_lock (&print_mutex); -printf ("%s: done\n" ,cmd_to_str (cmd)); +ksft_print_msg ("%s: done\n" ,cmd_to_str (cmd));if (gup.size != size) -printf ("Truncated (size: %lld)\n" , gup.size); +ksft_print_msg ("Truncated (size: %lld)\n" , gup.size);pthread_mutex_unlock (&print_mutex); } +return_: +ksft_test_result (!status,"ioctl status %d\n" , status);return NULL ; }
@@ -170,7 +172,7 @@ int main(int argc, char **argv) touch =1 ;break ;default : -return -1 ; +ksft_exit_fail_msg ("Wrong argument\n" ); } }
@@ -198,11 +200,12 @@ int main(int argc, char **argv) } } +ksft_print_header (); +ksft_set_plan (nthreads); + filed =open (file,O_RDWR |O_CREAT ); -if (filed <0 ) { -perror ("open" ); -exit (filed); - } +if (filed <0 ) +ksft_exit_fail_msg ("Unable to open %s: %s\n" , file,strerror (errno)); gup.nr_pages_per_call = nr_pages;if (write)
@@ -213,27 +216,24 @@ int main(int argc, char **argv)switch (errno) {case EACCES :if (getuid ()) -printf ("Please run this test as root\n" ); +ksft_print_msg ("Please run this test as root\n" );break ;case ENOENT : -if (opendir ("/sys/kernel/debug" ) ==NULL ) { -printf ("mount debugfs at /sys/kernel/debug\n" ); -break ; - } -printf ("check if CONFIG_GUP_TEST is enabled in kernel config\n" ); +if (opendir ("/sys/kernel/debug" ) ==NULL ) +ksft_print_msg ("mount debugfs at /sys/kernel/debug\n" ); +ksft_print_msg ("check if CONFIG_GUP_TEST is enabled in kernel config\n" );break ;default : -perror ("failed to open " GUP_TEST_FILE ); +ksft_print_msg ("failed to open %s: %s\n" ,GUP_TEST_FILE ,strerror (errno));break ; } -exit (KSFT_SKIP ); +ksft_test_result_skip ("Please run this test as root\n" ); +return ksft_exit_pass (); } p =mmap (NULL , size,PROT_READ |PROT_WRITE , flags, filed,0 ); -if (p ==MAP_FAILED ) { -perror ("mmap" ); -exit (1 ); - } +if (p ==MAP_FAILED ) +ksft_exit_fail_msg ("mmap: %s\n" ,strerror (errno)); gup.addr = (unsigned long )p;if (thp ==1 )
@@ -264,7 +264,8 @@ int main(int argc, char **argv) ret =pthread_join (tid[i],NULL );assert (ret ==0 ); } +free (tid); -return 0 ; +return ksft_exit_pass (); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 320/432 selftests/mm: Fix build with _FORTIFY_SOURCE
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vitaly Chikunov <[email protected]>
[ Upstream commit 8b65ef5ad4862904e476a8f3d4e4418c950ddb90 ]
Add missing flags argument to open(2) call with O_CREAT.
Some tests fail to compile if _FORTIFY_SOURCE is defined (to any valid value) (together with -O), resulting in similar error messages such as:
In file included from /usr/include/fcntl.h:342,
from gup_test.c:1:
In function 'open',
inlined from 'main' at gup_test.c:206:10:
/usr/include/bits/fcntl2.h:50:11: error: call to '__open_missing_mode' declared with attribute error: open with O_CREAT or O_TMPFILE in second argument needs 3 arguments
50 | __open_missing_mode ();
| ^~~~~~~~~~~~~~~~~~~~~~_FORTIFY_SOURCE is enabled by default in some distributions, so the tests are not built by default and are skipped.
open(2) man-page warns about missing flags argument: "if it is not supplied, some arbitrary bytes from the stack will be applied as the file mode."
--- tools/testing/selftests/mm/gup_test.c | 2 +- tools/testing/selftests/mm/soft-dirty.c | 2 +- tools/testing/selftests/mm/split_huge_page_test.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/mm/gup_test.c +1 -1
@@ -203,7 +203,7 @@ int main(int argc, char **argv)ksft_print_header ();ksft_set_plan (nthreads); - filed =open (file,O_RDWR |O_CREAT ); + filed =open (file,O_RDWR |O_CREAT ,0664 );if (filed <0 )ksft_exit_fail_msg ("Unable to open %s: %s\n" , file,strerror (errno));
tools/testing/selftests/mm/soft-dirty.c +1 -1
@@ -137,7 +137,7 @@ static void test_mprotect(int pagemap_fd, int pagesize, bool anon)if (!map)ksft_exit_fail_msg ("anon mmap failed\n" ); }else { - test_fd =open (fname,O_RDWR |O_CREAT ); + test_fd =open (fname,O_RDWR |O_CREAT ,0664 );if (test_fd <0 ) {ksft_test_result_skip ("Test %s open() file failed\n" , __func__);return ;
tools/testing/selftests/mm/split_huge_page_test.c +1 -1
@@ -253,7 +253,7 @@ void split_file_backed_thp(void) goto cleanup; } - fd =open (testfile,O_CREAT |O_WRONLY ); + fd =open (testfile,O_CREAT |O_WRONLY ,0664 );if (fd ==-1 ) {perror ("Cannot open testing file\n" ); goto cleanup;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 321/432 btrfs: do not skip re-registration for the mounted device
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anand Jain <[email protected]>
commit d565fffa68560ac540bf3d62cc79719da50d5e7a upstream.
There are reports that since version 6.7 update-grub fails to find the device of the root on systems without initrd and on a single device.
This looks like the device name changed in the output of /proc/self/mountinfo:
6.5-rc5 working
18 1 0:16 / / rw,noatime - btrfs /dev/sda8 ...
6.7 not working:
17 1 0:15 / / rw,noatime - btrfs /dev/root ...
and "update-grub" shows this error:
/usr/sbin/grub-probe: error: cannot find a device for / (is /dev mounted?)
This looks like it's related to the device name, but grub-probe recognizes the "/dev/root" path and tries to find the underlying device. However there's a special case for some filesystems, for btrfs in particular.
The generic root device detection heuristic is not done and it all relies on reading the device infos by a btrfs specific ioctl. This ioctl returns the device name as it was saved at the time of device scan (in this case it's /dev/root).
The change in 6.7 for temp_fsid to allow several single device filesystem to exist with the same fsid (and transparently generate a new UUID at mount time) was to skip caching/registering such devices.
This also skipped mounted device. One step of scanning is to check if the device name hasn't changed, and if yes then update the cached value.
This broke the grub-probe as it always read the device /dev/root and couldn't find it in the system. A temporary workaround is to create a symlink but this does not survive reboot.
The right fix is to allow updating the device path of a mounted filesystem even if this is a single device one.
In the fix, check if the device's major:minor number matches with the cached device. If they do, then we can allow the scan to happen so that device_list_add() can take care of updating the device path. The file descriptor remains unchanged.
This does not affect the temp_fsid feature, the UUID of the mounted filesystem remains the same and the matching is based on device major:minor which is unique per mounted filesystem.
This covers the path when the device (that exists for all mounted devices) name changes, updating /dev/root to /dev/sdx. Any other single device with filesystem and is not mounted is still skipped.
Note that if a system is booted and initial mount is done on the /dev/root device, this will be the cached name of the device. Only after the command "btrfs device scan" it will change as it triggers the rename.
The fix was verified by users whose systems were affected.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=218353
--- fs/btrfs/volumes.c | 57 +++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 47 insertions(+), 10 deletions(-)
fs/btrfs/volumes.c +47 -10
@@ -1290,6 +1290,47 @@ int btrfs_forget_devices(dev_t devt)return ret; } +static bool btrfs_skip_registration (struct btrfs_super_block *disk_super, +const char *path,dev_t devt, +bool mount_arg_dev) +{ +struct btrfs_fs_devices *fs_devices; + +/* +* Do not skip device registration for mounted devices with matching +* maj:min but different paths. Booting without initrd relies on +* /dev/root initially, later replaced with the actual root device. +* A successful scan ensures grub2-probe selects the correct device. +*/ +list_for_each_entry (fs_devices, &fs_uuids, fs_list) { +struct btrfs_device *device; + +mutex_lock (&fs_devices->device_list_mutex); + +if (!fs_devices->opened) { +mutex_unlock (&fs_devices->device_list_mutex); +continue ; + } + +list_for_each_entry (device, &fs_devices->devices, dev_list) { +if (device->bdev && (device->bdev->bd_dev == devt) && +strcmp (device->name->str, path) !=0 ) { +mutex_unlock (&fs_devices->device_list_mutex); + +/* Do not skip registration. */ +return false; + } + } +mutex_unlock (&fs_devices->device_list_mutex); + } + +if (!mount_arg_dev &&btrfs_super_num_devices (disk_super) ==1 && + !(btrfs_super_flags (disk_super) &BTRFS_SUPER_FLAG_SEEDING )) +return true; + +return false; +} +/* * Look for a btrfs signature on a device. This may be called out of the mount path * and we are not allowed to call set_blocksize during the scan. The superblock
@@ -1346,18 +1387,14 @@ struct btrfs_device *btrfs_scan_one_devi goto error_bdev_put; } -if (!mount_arg_dev &&btrfs_super_num_devices (disk_super) ==1 && - !(btrfs_super_flags (disk_super) &BTRFS_SUPER_FLAG_SEEDING )) { -dev_t devt; +if (btrfs_skip_registration (disk_super, path, bdev_handle->bdev->bd_dev, + mount_arg_dev)) { +pr_debug ("BTRFS: skip registering single non-seed device %s (%d:%d)\n" , + path,MAJOR (bdev_handle->bdev->bd_dev), +MINOR (bdev_handle->bdev->bd_dev)); - ret =lookup_bdev (path, &devt); -if (ret) -btrfs_warn (NULL ,"lookup bdev failed for path %s: %d" , - path, ret); -else -btrfs_free_stale_devices (devt,NULL ); +btrfs_free_stale_devices (bdev_handle->bdev->bd_dev,NULL ); -pr_debug ("BTRFS: skip registering single non-seed device %s\n" , path); device =NULL ; goto free_disk_super; }
Greg Kroah-Hartman
maintainerPATCH 322/432 mfd: intel-lpss: Switch to generalized quirk table
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aleksandrs Vinarskis <[email protected]>
commit ac9538f6007e1c80f1b8a62db7ecc391b4d78ae5 upstream.
Introduce generic quirk table, and port existing walkaround for select Microsoft devices to it. This is a preparation for QUIRK_CLOCK_DIVIDER_UNITY.
--- drivers/mfd/intel-lpss-pci.c | 23 +++++++++++++++-------- drivers/mfd/intel-lpss.c | 2 +- drivers/mfd/intel-lpss.h | 9 ++++++++- 3 files changed, 24 insertions(+), 10 deletions(-)
drivers/mfd/intel-lpss-pci.c +15 -8
@@ -18,18 +18,24 @@#include "intel-lpss.h" -/* Some DSDTs have an unused GEXP ACPI device conflicting with I2C4 resources */ -static const struct pci_device_id ignore_resource_conflicts_ids[] = { -/* Microsoft Surface Go (version 1) I2C4 */ - {PCI_DEVICE_SUB (PCI_VENDOR_ID_INTEL ,0x9d64 ,0x152d ,0x1182 ), }, -/* Microsoft Surface Go 2 I2C4 */ - {PCI_DEVICE_SUB (PCI_VENDOR_ID_INTEL ,0x9d64 ,0x152d ,0x1237 ), }, +static const struct pci_device_id quirk_ids[] = { + { +/* Microsoft Surface Go (version 1) I2C4 */ +PCI_DEVICE_SUB (PCI_VENDOR_ID_INTEL ,0x9d64 ,0x152d ,0x1182 ), + .driver_data =QUIRK_IGNORE_RESOURCE_CONFLICTS , + }, + { +/* Microsoft Surface Go 2 I2C4 */ +PCI_DEVICE_SUB (PCI_VENDOR_ID_INTEL ,0x9d64 ,0x152d ,0x1237 ), + .driver_data =QUIRK_IGNORE_RESOURCE_CONFLICTS , + }, { } };static int intel_lpss_pci_probe (struct pci_dev *pdev,const struct pci_device_id *id) { +const struct pci_device_id *quirk_pci_info;struct intel_lpss_platform_info *info;int ret;
@@ -45,8 +51,9 @@ static int intel_lpss_pci_probe(struct p info->mem = &pdev->resource[0 ]; info->irq = pdev->irq; -if (pci_match_id (ignore_resource_conflicts_ids, pdev)) - info->ignore_resource_conflicts = true; + quirk_pci_info =pci_match_id (quirk_ids, pdev); +if (quirk_pci_info) + info->quirks = quirk_pci_info->driver_data; pdev->d3cold_delay =0 ;
drivers/mfd/intel-lpss.c +1 -1
@@ -401,7 +401,7 @@ int intel_lpss_probe(struct device *dev,return ret; lpss->cell->swnode = info->swnode; - lpss->cell->ignore_resource_conflicts = info->ignore_resource_conflicts; + lpss->cell->ignore_resource_conflicts = info->quirks &QUIRK_IGNORE_RESOURCE_CONFLICTS ;intel_lpss_init_dev (lpss);
drivers/mfd/intel-lpss.h +8 -1
@@ -11,16 +11,23 @@ #ifndef __MFD_INTEL_LPSS_H #define __MFD_INTEL_LPSS_H +#include <linux/bits.h> #include <linux/pm.h> +/* + * Some DSDTs have an unused GEXP ACPI device conflicting with I2C4 resources. + * Set to ignore resource conflicts with ACPI declared SystemMemory regions. + */ +#define QUIRK_IGNORE_RESOURCE_CONFLICTS BIT(0) + struct device; struct resource; struct software_node; struct intel_lpss_platform_info { struct resource *mem; - bool ignore_resource_conflicts; int irq; + unsigned int quirks; unsigned long clk_rate; const char *clk_con_id; const struct software_node *swnode;
Greg Kroah-Hartman
maintainerPATCH 323/432 mfd: intel-lpss: Introduce QUIRK_CLOCK_DIVIDER_UNITY for XPS 9530
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aleksandrs Vinarskis <[email protected]>
commit 1d8c51ed2ddcc4161e6496cf14fcd83921c50ec8 upstream.
Some devices (eg. Dell XPS 9530, 2023) due to a firmware bug have a misconfigured clock divider, which should've been 1:1. This introduces quirk which conditionally re-configures the clock divider to 1:1.
--- drivers/mfd/intel-lpss-pci.c | 5 +++++ drivers/mfd/intel-lpss.c | 7 +++++++ drivers/mfd/intel-lpss.h | 5 +++++ 3 files changed, 17 insertions(+)
drivers/mfd/intel-lpss-pci.c +5 -0
@@ -29,6 +29,11 @@ static const struct pci_device_id quirk_ PCI_DEVICE_SUB(PCI_VENDOR_ID_INTEL, 0x9d64, 0x152d, 0x1237), .driver_data = QUIRK_IGNORE_RESOURCE_CONFLICTS, }, + { +/* Dell XPS 9530 (2023) */ + PCI_DEVICE_SUB(PCI_VENDOR_ID_INTEL, 0x51fb, 0x1028, 0x0beb), + .driver_data = QUIRK_CLOCK_DIVIDER_UNITY, + }, { } };
drivers/mfd/intel-lpss.c +7 -0
@@ -292,6 +292,7 @@ static int intel_lpss_register_clock_div {char name[32 ];struct clk *tmp = *clk; +int ret;snprintf (name,sizeof (name),"%s-enable" , devname); tmp = clk_register_gate(NULL, name, __clk_get_name(tmp), 0,
@@ -308,6 +309,12 @@ static int intel_lpss_register_clock_divreturn PTR_ERR (tmp); *clk = tmp; +if (lpss->info->quirks &QUIRK_CLOCK_DIVIDER_UNITY ) { + ret =clk_set_rate (tmp, lpss->info->clk_rate); +if (ret) +return ret; + } +snprintf (name,sizeof (name),"%s-update" , devname); tmp =clk_register_gate (NULL , name,__clk_get_name (tmp),CLK_SET_RATE_PARENT , lpss->priv,31 ,0 ,NULL );
drivers/mfd/intel-lpss.h +5 -0
@@ -19,6 +19,11 @@* Set to ignore resource conflicts with ACPI declared SystemMemory regions. */ #define QUIRK_IGNORE_RESOURCE_CONFLICTS BIT(0) +/* +* Some devices have misconfigured clock divider due to a firmware bug. +* Set this to force the clock divider to 1:1 ratio. +*/ +#define QUIRK_CLOCK_DIVIDER_UNITY BIT(1)struct device ;struct resource ;
Greg Kroah-Hartman
maintainerPATCH 324/432 perf top: Use evsels cpus to replace user_requested_cpus
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kan Liang <[email protected]>
commit 5fa695e7da4975e8d21ce49f3718d6cf00ecb75e upstream.
perf top errors out on a hybrid machine
$perf top
Error:
The cycles:P event is not supported.
The perf top expects that the "cycles" is collected on all CPUs in the system. But for hybrid there is no single "cycles" event which can cover all CPUs. Perf has to split it into two cycles events, e.g., cpu_core/cycles/ and cpu_atom/cycles/. Each event has its own CPU mask. If a event is opened on the unsupported CPU. The open fails. That's the reason of the above error out.
Perf should only open the cycles event on the corresponding CPU. The commit ef91871c960e ("perf evlist: Propagate user CPU maps intersecting core PMU maps") intersect the requested CPU map with the CPU map of the PMU. Use the evsel's cpus to replace user_requested_cpus.
The evlist's threads are also propagated to the evsel's threads in __perf_evlist__propagate_maps(). For a system-wide event, perf appends a dummy event and assign it to the evsel's threads. For a per-thread event, the evlist's thread_map is assigned to the evsel's threads. The same as the other tools, e.g., perf record, using the evsel's threads when opening an event.
--- tools/perf/builtin-top.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/builtin-top.c +2 -2
@@ -1027,8 +1027,8 @@ static int perf_top__start_counters(struevlist__for_each_entry (evlist, counter) { try_again: -if (evsel__open (counter, top->evlist->core.user_requested_cpus, - top->evlist->core.threads) <0 ) { +if (evsel__open (counter, counter->core.cpus, + counter->core.threads) <0 ) {/* * Specially handle overwrite fall back.
Greg Kroah-Hartman
maintainerPATCH 325/432 drm/i915: Stop printing pipe name as hex
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ville Syrjälä <[email protected]>
commit 58046e6cf811464b8a6f269dc6a40a8cb91a8a68 upstream.
Print the pipe name in ascii rather than hex.
--- drivers/gpu/drm/i915/display/intel_dpll_mgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/display/intel_dpll_mgr.c +1 -1
@@ -4534,7 +4534,7 @@ void intel_shared_dpll_state_verify(stru"pll active mismatch (didn't expect pipe %c in active mask (0x%x))\n" , pipe_name(crtc->pipe), pll->active_mask);I915_STATE_WARN (i915, pll->state.pipe_mask & pipe_mask, -"pll enabled crtcs mismatch (found %x in enabled mask (0x%x))\n" , +"pll enabled crtcs mismatch (found pipe %c in enabled mask (0x%x))\n" ,pipe_name (crtc->pipe), pll->state.pipe_mask); } }
Greg Kroah-Hartman
maintainerPATCH 326/432 drm/i915: Use named initializers for DPLL info
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ville Syrjälä <[email protected]>
commit f215038f4133ea9d1b525e9bb812527fe002db2b upstream.
Use named initializers when populating the DPLL info. This is just more convenient and less error prone as we no longer have to keep the initializers in a specific order.
--- drivers/gpu/drm/i915/display/intel_dpll_mgr.c | 130 +++++++++++++------------- 1 file changed, 67 insertions(+), 63 deletions(-)
drivers/gpu/drm/i915/display/intel_dpll_mgr.c +67 -63
@@ -631,9 +631,9 @@ static const struct intel_shared_dpll_fu };static const struct dpll_info pch_plls[] = { - {"PCH DPLL A" , &ibx_pch_dpll_funcs,DPLL_ID_PCH_PLL_A ,0 }, - {"PCH DPLL B" , &ibx_pch_dpll_funcs,DPLL_ID_PCH_PLL_B ,0 }, - { }, + { .name ="PCH DPLL A" , .funcs = &ibx_pch_dpll_funcs, .id =DPLL_ID_PCH_PLL_A , }, + { .name ="PCH DPLL B" , .funcs = &ibx_pch_dpll_funcs, .id =DPLL_ID_PCH_PLL_B , }, + {} };static const struct intel_dpll_mgr pch_pll_mgr = {
@@ -1239,13 +1239,16 @@ static const struct intel_shared_dpll_fu };static const struct dpll_info hsw_plls[] = { - {"WRPLL 1" , &hsw_ddi_wrpll_funcs,DPLL_ID_WRPLL1 ,0 }, - {"WRPLL 2" , &hsw_ddi_wrpll_funcs,DPLL_ID_WRPLL2 ,0 }, - {"SPLL" , &hsw_ddi_spll_funcs,DPLL_ID_SPLL ,0 }, - {"LCPLL 810" , &hsw_ddi_lcpll_funcs,DPLL_ID_LCPLL_810 ,INTEL_DPLL_ALWAYS_ON }, - {"LCPLL 1350" , &hsw_ddi_lcpll_funcs,DPLL_ID_LCPLL_1350 ,INTEL_DPLL_ALWAYS_ON }, - {"LCPLL 2700" , &hsw_ddi_lcpll_funcs,DPLL_ID_LCPLL_2700 ,INTEL_DPLL_ALWAYS_ON }, - { }, + { .name ="WRPLL 1" , .funcs = &hsw_ddi_wrpll_funcs, .id =DPLL_ID_WRPLL1 , }, + { .name ="WRPLL 2" , .funcs = &hsw_ddi_wrpll_funcs, .id =DPLL_ID_WRPLL2 , }, + { .name ="SPLL" , .funcs = &hsw_ddi_spll_funcs, .id =DPLL_ID_SPLL , }, + { .name ="LCPLL 810" , .funcs = &hsw_ddi_lcpll_funcs, .id =DPLL_ID_LCPLL_810 , + .flags =INTEL_DPLL_ALWAYS_ON , }, + { .name ="LCPLL 1350" , .funcs = &hsw_ddi_lcpll_funcs, .id =DPLL_ID_LCPLL_1350 , + .flags =INTEL_DPLL_ALWAYS_ON , }, + { .name ="LCPLL 2700" , .funcs = &hsw_ddi_lcpll_funcs, .id =DPLL_ID_LCPLL_2700 , + .flags =INTEL_DPLL_ALWAYS_ON , }, + {} };static const struct intel_dpll_mgr hsw_pll_mgr = {
@@ -1921,11 +1924,12 @@ static const struct intel_shared_dpll_fu };static const struct dpll_info skl_plls[] = { - {"DPLL 0" , &skl_ddi_dpll0_funcs,DPLL_ID_SKL_DPLL0 ,INTEL_DPLL_ALWAYS_ON }, - {"DPLL 1" , &skl_ddi_pll_funcs,DPLL_ID_SKL_DPLL1 ,0 }, - {"DPLL 2" , &skl_ddi_pll_funcs,DPLL_ID_SKL_DPLL2 ,0 }, - {"DPLL 3" , &skl_ddi_pll_funcs,DPLL_ID_SKL_DPLL3 ,0 }, - { }, + { .name ="DPLL 0" , .funcs = &skl_ddi_dpll0_funcs, .id =DPLL_ID_SKL_DPLL0 , + .flags =INTEL_DPLL_ALWAYS_ON , }, + { .name ="DPLL 1" , .funcs = &skl_ddi_pll_funcs, .id =DPLL_ID_SKL_DPLL1 , }, + { .name ="DPLL 2" , .funcs = &skl_ddi_pll_funcs, .id =DPLL_ID_SKL_DPLL2 , }, + { .name ="DPLL 3" , .funcs = &skl_ddi_pll_funcs, .id =DPLL_ID_SKL_DPLL3 , }, + {} };static const struct intel_dpll_mgr skl_pll_mgr = {
@@ -2376,10 +2380,10 @@ static const struct intel_shared_dpll_fu };static const struct dpll_info bxt_plls[] = { - {"PORT PLL A" , &bxt_ddi_pll_funcs,DPLL_ID_SKL_DPLL0 ,0 }, - {"PORT PLL B" , &bxt_ddi_pll_funcs,DPLL_ID_SKL_DPLL1 ,0 }, - {"PORT PLL C" , &bxt_ddi_pll_funcs,DPLL_ID_SKL_DPLL2 ,0 }, - { }, + { .name ="PORT PLL A" , .funcs = &bxt_ddi_pll_funcs, .id =DPLL_ID_SKL_DPLL0 , }, + { .name ="PORT PLL B" , .funcs = &bxt_ddi_pll_funcs, .id =DPLL_ID_SKL_DPLL1 , }, + { .name ="PORT PLL C" , .funcs = &bxt_ddi_pll_funcs, .id =DPLL_ID_SKL_DPLL2 , }, + {} };static const struct intel_dpll_mgr bxt_pll_mgr = {
@@ -4014,14 +4018,14 @@ static const struct intel_shared_dpll_fu };static const struct dpll_info icl_plls[] = { - {"DPLL 0" , &combo_pll_funcs,DPLL_ID_ICL_DPLL0 ,0 }, - {"DPLL 1" , &combo_pll_funcs,DPLL_ID_ICL_DPLL1 ,0 }, - {"TBT PLL" , &tbt_pll_funcs,DPLL_ID_ICL_TBTPLL ,0 }, - {"MG PLL 1" , &mg_pll_funcs,DPLL_ID_ICL_MGPLL1 ,0 }, - {"MG PLL 2" , &mg_pll_funcs,DPLL_ID_ICL_MGPLL2 ,0 }, - {"MG PLL 3" , &mg_pll_funcs,DPLL_ID_ICL_MGPLL3 ,0 }, - {"MG PLL 4" , &mg_pll_funcs,DPLL_ID_ICL_MGPLL4 ,0 }, - { }, + { .name ="DPLL 0" , .funcs = &combo_pll_funcs, .id =DPLL_ID_ICL_DPLL0 , }, + { .name ="DPLL 1" , .funcs = &combo_pll_funcs, .id =DPLL_ID_ICL_DPLL1 , }, + { .name ="TBT PLL" , .funcs = &tbt_pll_funcs, .id =DPLL_ID_ICL_TBTPLL , }, + { .name ="MG PLL 1" , .funcs = &mg_pll_funcs, .id =DPLL_ID_ICL_MGPLL1 , }, + { .name ="MG PLL 2" , .funcs = &mg_pll_funcs, .id =DPLL_ID_ICL_MGPLL2 , }, + { .name ="MG PLL 3" , .funcs = &mg_pll_funcs, .id =DPLL_ID_ICL_MGPLL3 , }, + { .name ="MG PLL 4" , .funcs = &mg_pll_funcs, .id =DPLL_ID_ICL_MGPLL4 , }, + {} };static const struct intel_dpll_mgr icl_pll_mgr = {
@@ -4035,10 +4039,10 @@ static const struct intel_dpll_mgr icl_p };static const struct dpll_info ehl_plls[] = { - {"DPLL 0" , &combo_pll_funcs,DPLL_ID_ICL_DPLL0 ,0 }, - {"DPLL 1" , &combo_pll_funcs,DPLL_ID_ICL_DPLL1 ,0 }, - {"DPLL 4" , &combo_pll_funcs,DPLL_ID_EHL_DPLL4 ,0 }, - { }, + { .name ="DPLL 0" , .funcs = &combo_pll_funcs, .id =DPLL_ID_ICL_DPLL0 , }, + { .name ="DPLL 1" , .funcs = &combo_pll_funcs, .id =DPLL_ID_ICL_DPLL1 , }, + { .name ="DPLL 4" , .funcs = &combo_pll_funcs, .id =DPLL_ID_EHL_DPLL4 , }, + {} };static const struct intel_dpll_mgr ehl_pll_mgr = {
@@ -4058,16 +4062,16 @@ static const struct intel_shared_dpll_fu };static const struct dpll_info tgl_plls[] = { - {"DPLL 0" , &combo_pll_funcs,DPLL_ID_ICL_DPLL0 ,0 }, - {"DPLL 1" , &combo_pll_funcs,DPLL_ID_ICL_DPLL1 ,0 }, - {"TBT PLL" , &tbt_pll_funcs,DPLL_ID_ICL_TBTPLL ,0 }, - {"TC PLL 1" , &dkl_pll_funcs,DPLL_ID_ICL_MGPLL1 ,0 }, - {"TC PLL 2" , &dkl_pll_funcs,DPLL_ID_ICL_MGPLL2 ,0 }, - {"TC PLL 3" , &dkl_pll_funcs,DPLL_ID_ICL_MGPLL3 ,0 }, - {"TC PLL 4" , &dkl_pll_funcs,DPLL_ID_ICL_MGPLL4 ,0 }, - {"TC PLL 5" , &dkl_pll_funcs,DPLL_ID_TGL_MGPLL5 ,0 }, - {"TC PLL 6" , &dkl_pll_funcs,DPLL_ID_TGL_MGPLL6 ,0 }, - { }, + { .name ="DPLL 0" , .funcs = &combo_pll_funcs, .id =DPLL_ID_ICL_DPLL0 , }, + { .name ="DPLL 1" , .funcs = &combo_pll_funcs, .id =DPLL_ID_ICL_DPLL1 , }, + { .name ="TBT PLL" , .funcs = &tbt_pll_funcs, .id =DPLL_ID_ICL_TBTPLL , }, + { .name ="TC PLL 1" , .funcs = &dkl_pll_funcs, .id =DPLL_ID_ICL_MGPLL1 , }, + { .name ="TC PLL 2" , .funcs = &dkl_pll_funcs, .id =DPLL_ID_ICL_MGPLL2 , }, + { .name ="TC PLL 3" , .funcs = &dkl_pll_funcs, .id =DPLL_ID_ICL_MGPLL3 , }, + { .name ="TC PLL 4" , .funcs = &dkl_pll_funcs, .id =DPLL_ID_ICL_MGPLL4 , }, + { .name ="TC PLL 5" , .funcs = &dkl_pll_funcs, .id =DPLL_ID_TGL_MGPLL5 , }, + { .name ="TC PLL 6" , .funcs = &dkl_pll_funcs, .id =DPLL_ID_TGL_MGPLL6 , }, + {} };static const struct intel_dpll_mgr tgl_pll_mgr = {
@@ -4081,10 +4085,10 @@ static const struct intel_dpll_mgr tgl_p };static const struct dpll_info rkl_plls[] = { - {"DPLL 0" , &combo_pll_funcs,DPLL_ID_ICL_DPLL0 ,0 }, - {"DPLL 1" , &combo_pll_funcs,DPLL_ID_ICL_DPLL1 ,0 }, - {"DPLL 4" , &combo_pll_funcs,DPLL_ID_EHL_DPLL4 ,0 }, - { }, + { .name ="DPLL 0" , .funcs = &combo_pll_funcs, .id =DPLL_ID_ICL_DPLL0 , }, + { .name ="DPLL 1" , .funcs = &combo_pll_funcs, .id =DPLL_ID_ICL_DPLL1 , }, + { .name ="DPLL 4" , .funcs = &combo_pll_funcs, .id =DPLL_ID_EHL_DPLL4 , }, + {} };static const struct intel_dpll_mgr rkl_pll_mgr = {
@@ -4097,11 +4101,11 @@ static const struct intel_dpll_mgr rkl_p };static const struct dpll_info dg1_plls[] = { - {"DPLL 0" , &combo_pll_funcs,DPLL_ID_DG1_DPLL0 ,0 }, - {"DPLL 1" , &combo_pll_funcs,DPLL_ID_DG1_DPLL1 ,0 }, - {"DPLL 2" , &combo_pll_funcs,DPLL_ID_DG1_DPLL2 ,0 }, - {"DPLL 3" , &combo_pll_funcs,DPLL_ID_DG1_DPLL3 ,0 }, - { }, + { .name ="DPLL 0" , .funcs = &combo_pll_funcs, .id =DPLL_ID_DG1_DPLL0 , }, + { .name ="DPLL 1" , .funcs = &combo_pll_funcs, .id =DPLL_ID_DG1_DPLL1 , }, + { .name ="DPLL 2" , .funcs = &combo_pll_funcs, .id =DPLL_ID_DG1_DPLL2 , }, + { .name ="DPLL 3" , .funcs = &combo_pll_funcs, .id =DPLL_ID_DG1_DPLL3 , }, + {} };static const struct intel_dpll_mgr dg1_pll_mgr = {
@@ -4114,11 +4118,11 @@ static const struct intel_dpll_mgr dg1_p };static const struct dpll_info adls_plls[] = { - {"DPLL 0" , &combo_pll_funcs,DPLL_ID_ICL_DPLL0 ,0 }, - {"DPLL 1" , &combo_pll_funcs,DPLL_ID_ICL_DPLL1 ,0 }, - {"DPLL 2" , &combo_pll_funcs,DPLL_ID_DG1_DPLL2 ,0 }, - {"DPLL 3" , &combo_pll_funcs,DPLL_ID_DG1_DPLL3 ,0 }, - { }, + { .name ="DPLL 0" , .funcs = &combo_pll_funcs, .id =DPLL_ID_ICL_DPLL0 , }, + { .name ="DPLL 1" , .funcs = &combo_pll_funcs, .id =DPLL_ID_ICL_DPLL1 , }, + { .name ="DPLL 2" , .funcs = &combo_pll_funcs, .id =DPLL_ID_DG1_DPLL2 , }, + { .name ="DPLL 3" , .funcs = &combo_pll_funcs, .id =DPLL_ID_DG1_DPLL3 , }, + {} };static const struct intel_dpll_mgr adls_pll_mgr = {
@@ -4131,14 +4135,14 @@ static const struct intel_dpll_mgr adls_ };static const struct dpll_info adlp_plls[] = { - {"DPLL 0" , &combo_pll_funcs,DPLL_ID_ICL_DPLL0 ,0 }, - {"DPLL 1" , &combo_pll_funcs,DPLL_ID_ICL_DPLL1 ,0 }, - {"TBT PLL" , &tbt_pll_funcs,DPLL_ID_ICL_TBTPLL ,0 }, - {"TC PLL 1" , &dkl_pll_funcs,DPLL_ID_ICL_MGPLL1 ,0 }, - {"TC PLL 2" , &dkl_pll_funcs,DPLL_ID_ICL_MGPLL2 ,0 }, - {"TC PLL 3" , &dkl_pll_funcs,DPLL_ID_ICL_MGPLL3 ,0 }, - {"TC PLL 4" , &dkl_pll_funcs,DPLL_ID_ICL_MGPLL4 ,0 }, - { }, + { .name ="DPLL 0" , .funcs = &combo_pll_funcs, .id =DPLL_ID_ICL_DPLL0 , }, + { .name ="DPLL 1" , .funcs = &combo_pll_funcs, .id =DPLL_ID_ICL_DPLL1 , }, + { .name ="TBT PLL" , .funcs = &tbt_pll_funcs, .id =DPLL_ID_ICL_TBTPLL , }, + { .name ="TC PLL 1" , .funcs = &dkl_pll_funcs, .id =DPLL_ID_ICL_MGPLL1 , }, + { .name ="TC PLL 2" , .funcs = &dkl_pll_funcs, .id =DPLL_ID_ICL_MGPLL2 , }, + { .name ="TC PLL 3" , .funcs = &dkl_pll_funcs, .id =DPLL_ID_ICL_MGPLL3 , }, + { .name ="TC PLL 4" , .funcs = &dkl_pll_funcs, .id =DPLL_ID_ICL_MGPLL4 , }, + {} };static const struct intel_dpll_mgr adlp_pll_mgr = {
Greg Kroah-Hartman
maintainerPATCH 327/432 drm/i915: Replace a memset() with zero initialization
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ville Syrjälä <[email protected]>
commit 92b47c3b8b242a1f1b73d5c1181d5b678ac1382b upstream.
Declaring a struct and immediately zeroing it with memset() seems a bit silly to me. Just zero initialize the struct when declaring it.
--- drivers/gpu/drm/i915/display/intel_dpll_mgr.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/i915/display/intel_dpll_mgr.c +1 -3
@@ -4466,12 +4466,10 @@ verify_single_dpll_state(struct drm_i915struct intel_crtc *crtc, const struct intel_crtc_state *new_crtc_state) { - struct intel_dpll_hw_state dpll_hw_state; + struct intel_dpll_hw_state dpll_hw_state = {};u8 pipe_mask;bool active; -memset (&dpll_hw_state,0 ,sizeof (dpll_hw_state)); -drm_dbg_kms (&i915->drm,"%s\n" , pll->info->name); active =intel_dpll_get_hw_state (i915, pll, &dpll_hw_state);
Greg Kroah-Hartman
maintainerPATCH 328/432 drm/i915: Try to preserve the current shared_dpll for fastset on type-c ports
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ville Syrjälä <[email protected]>
commit ba407525f8247ee4c270369f3371b9994c27bfda upstream.
Currently icl_compute_tc_phy_dplls() assumes that the active PLL will be the TC PLL (as opposed to the TBT PLL). The actual PLL will be selected during the modeset enable sequence, but we need to put *something* into the crtc_state->shared_dpll already during compute_config().
The downside of assuming one PLL or the other is that we'll fail to fastset if the assumption doesn't match what was in use previously. So let's instead keep the same PLL that was in use previously (assuming there was one). This should allow fastset to work again when using TBT PLL, at least in the steady state.
Now, assuming we want keep the same PLL may not be entirely correct either. But we should be covered by the type-c link reset handling which will force a full modeset by flagging connectors_changed=true which means the resulting modeset can't be converted into a fastset even if the full crtc state looks identical.
--- drivers/gpu/drm/i915/display/intel_dpll_mgr.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/display/intel_dpll_mgr.c +7 -1
@@ -3288,6 +3288,8 @@ static int icl_compute_tc_phy_dplls(strustruct drm_i915_private *i915 =to_i915 (state->base.dev);struct intel_crtc_state *crtc_state =intel_atomic_get_new_crtc_state (state, crtc); +const struct intel_crtc_state *old_crtc_state = +intel_atomic_get_old_crtc_state (state, crtc);struct icl_port_dpll *port_dpll = &crtc_state->icl_port_dplls[ICL_PORT_DPLL_DEFAULT ];struct skl_wrpll_params pll_params = {};
@@ -3306,7 +3308,11 @@ static int icl_compute_tc_phy_dplls(strureturn ret;/* this is mainly for the fastset check */ -icl_set_active_port_dpll (crtc_state,ICL_PORT_DPLL_MG_PHY ); +if (old_crtc_state->shared_dpll && + old_crtc_state->shared_dpll->info->id ==DPLL_ID_ICL_TBTPLL ) +icl_set_active_port_dpll (crtc_state,ICL_PORT_DPLL_DEFAULT ); +else +icl_set_active_port_dpll (crtc_state,ICL_PORT_DPLL_MG_PHY ); crtc_state->port_clock =icl_ddi_mg_pll_get_freq (i915,NULL , &port_dpll->hw_state);
Greg Kroah-Hartman
maintainerPATCH 329/432 drm/i915: Include the PLL name in the debug messages
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ville Syrjälä <[email protected]>
commit d283ee5662c6bf2f3771a36b926f6988e6dddfc6 upstream.
Make the log easier to parse by including the name of the PLL in the debug prints regarding said PLL.
--- drivers/gpu/drm/i915/display/intel_dpll_mgr.c | 39 +++++++++++++------------- 1 file changed, 20 insertions(+), 19 deletions(-)
drivers/gpu/drm/i915/display/intel_dpll_mgr.c +20 -19
@@ -4476,25 +4476,25 @@ verify_single_dpll_state(struct drm_i915u8 pipe_mask;bool active; -drm_dbg_kms (&i915->drm,"%s\n" , pll->info->name); - active =intel_dpll_get_hw_state (i915, pll, &dpll_hw_state);if (!(pll->info->flags &INTEL_DPLL_ALWAYS_ON )) {I915_STATE_WARN (i915, !pll->on && pll->active_mask, -"pll in active use but not on in sw tracking\n" ); +"%s: pll in active use but not on in sw tracking\n" , + pll->info->name);I915_STATE_WARN (i915, pll->on && !pll->active_mask, -"pll is on but not used by any active pipe\n" ); +"%s: pll is on but not used by any active pipe\n" , + pll->info->name);I915_STATE_WARN (i915, pll->on != active, -"pll on state mismatch (expected %i, found %i)\n" , - pll->on, active); +"%s: pll on state mismatch (expected %i, found %i)\n" , + pll->info->name, pll->on, active); }if (!crtc) {I915_STATE_WARN (i915, pll->active_mask & ~pll->state.pipe_mask, -"more active pll users than references: 0x%x vs 0x%x\n" , - pll->active_mask, pll->state.pipe_mask); +"%s: more active pll users than references: 0x%x vs 0x%x\n" , + pll->info->name, pll->active_mask, pll->state.pipe_mask);return ; }
@@ -4503,21 +4503,22 @@ verify_single_dpll_state(struct drm_i915if (new_crtc_state->hw.active)I915_STATE_WARN (i915, !(pll->active_mask & pipe_mask), -"pll active mismatch (expected pipe %c in active mask 0x%x)\n" , -pipe_name (crtc->pipe), pll->active_mask); +"%s: pll active mismatch (expected pipe %c in active mask 0x%x)\n" , + pll->info->name,pipe_name (crtc->pipe), pll->active_mask);else I915_STATE_WARN (i915, pll->active_mask & pipe_mask, -"pll active mismatch (didn't expect pipe %c in active mask 0x%x)\n" , -pipe_name (crtc->pipe), pll->active_mask); +"%s: pll active mismatch (didn't expect pipe %c in active mask 0x%x)\n" , + pll->info->name,pipe_name (crtc->pipe), pll->active_mask);I915_STATE_WARN (i915, !(pll->state.pipe_mask & pipe_mask), -"pll enabled crtcs mismatch (expected 0x%x in 0x%x)\n" , - pipe_mask, pll->state.pipe_mask); +"%s: pll enabled crtcs mismatch (expected 0x%x in 0x%x)\n" , + pll->info->name, pipe_mask, pll->state.pipe_mask);I915_STATE_WARN (i915, pll->on &&memcmp (&pll->state.hw_state, &dpll_hw_state,sizeof (dpll_hw_state)), -"pll hw state mismatch\n" ); +"%s: pll hw state mismatch\n" , + pll->info->name); } void intel_shared_dpll_state_verify(struct intel_atomic_state *state,
@@ -4539,11 +4540,11 @@ void intel_shared_dpll_state_verify(strustruct intel_shared_dpll *pll = old_crtc_state->shared_dpll;I915_STATE_WARN (i915, pll->active_mask & pipe_mask, -"pll active mismatch (didn't expect pipe %c in active mask (0x%x))\n" , -pipe_name (crtc->pipe), pll->active_mask); +"%s: pll active mismatch (didn't expect pipe %c in active mask (0x%x))\n" , + pll->info->name,pipe_name (crtc->pipe), pll->active_mask);I915_STATE_WARN (i915, pll->state.pipe_mask & pipe_mask, -"pll enabled crtcs mismatch (found pipe %c in enabled mask (0x%x))\n" , -pipe_name (crtc->pipe), pll->state.pipe_mask); +"%s: pll enabled crtcs mismatch (found pipe %c in enabled mask (0x%x))\n" , + pll->info->name,pipe_name (crtc->pipe), pll->state.pipe_mask); } }
Greg Kroah-Hartman
maintainerPATCH 330/432 drm/i915: Suppress old PLL pipe_mask checks for MG/TC/TBT PLLs
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ville Syrjälä <[email protected]>
commit 33c7760226c79ee8de6c0646640963a8a7ee794a upstream.
TC ports have both the MG/TC and TBT PLLs selected simultanously (so that we can switch from MG/TC to TBT as a fallback). This doesn't play well with the state checker that assumes that the old PLL shouldn't have the pipe in its pipe_mask anymore. Suppress that check for these PLLs to avoid spurious WARNs when you disconnect a TC port and a non-disabling modeset happens before actually disabling the port.
v2: Only suppress when one of the PLLs is the TBT PLL and the
other one is not
--- drivers/gpu/drm/i915/display/intel_dpll_mgr.c | 23 +++++++++++++++++++---- drivers/gpu/drm/i915/display/intel_dpll_mgr.h | 4 ++++ 2 files changed, 23 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/display/intel_dpll_mgr.c +19 -4
@@ -4026,7 +4026,8 @@ static const struct intel_shared_dpll_fustatic const struct dpll_info icl_plls[] = { { .name ="DPLL 0" , .funcs = &combo_pll_funcs, .id =DPLL_ID_ICL_DPLL0 , }, { .name ="DPLL 1" , .funcs = &combo_pll_funcs, .id =DPLL_ID_ICL_DPLL1 , }, - { .name ="TBT PLL" , .funcs = &tbt_pll_funcs, .id =DPLL_ID_ICL_TBTPLL , }, + { .name ="TBT PLL" , .funcs = &tbt_pll_funcs, .id =DPLL_ID_ICL_TBTPLL , + .flags =INTEL_DPLL_IS_ALT_PORT_DPLL , }, { .name ="MG PLL 1" , .funcs = &mg_pll_funcs, .id =DPLL_ID_ICL_MGPLL1 , }, { .name ="MG PLL 2" , .funcs = &mg_pll_funcs, .id =DPLL_ID_ICL_MGPLL2 , }, { .name ="MG PLL 3" , .funcs = &mg_pll_funcs, .id =DPLL_ID_ICL_MGPLL3 , },
@@ -4070,7 +4071,8 @@ static const struct intel_shared_dpll_fustatic const struct dpll_info tgl_plls[] = { { .name ="DPLL 0" , .funcs = &combo_pll_funcs, .id =DPLL_ID_ICL_DPLL0 , }, { .name ="DPLL 1" , .funcs = &combo_pll_funcs, .id =DPLL_ID_ICL_DPLL1 , }, - { .name ="TBT PLL" , .funcs = &tbt_pll_funcs, .id =DPLL_ID_ICL_TBTPLL , }, + { .name ="TBT PLL" , .funcs = &tbt_pll_funcs, .id =DPLL_ID_ICL_TBTPLL , + .flags =INTEL_DPLL_IS_ALT_PORT_DPLL , }, { .name ="TC PLL 1" , .funcs = &dkl_pll_funcs, .id =DPLL_ID_ICL_MGPLL1 , }, { .name ="TC PLL 2" , .funcs = &dkl_pll_funcs, .id =DPLL_ID_ICL_MGPLL2 , }, { .name ="TC PLL 3" , .funcs = &dkl_pll_funcs, .id =DPLL_ID_ICL_MGPLL3 , },
@@ -4143,7 +4145,8 @@ static const struct intel_dpll_mgr adls_static const struct dpll_info adlp_plls[] = { { .name ="DPLL 0" , .funcs = &combo_pll_funcs, .id =DPLL_ID_ICL_DPLL0 , }, { .name ="DPLL 1" , .funcs = &combo_pll_funcs, .id =DPLL_ID_ICL_DPLL1 , }, - { .name ="TBT PLL" , .funcs = &tbt_pll_funcs, .id =DPLL_ID_ICL_TBTPLL , }, + { .name ="TBT PLL" , .funcs = &tbt_pll_funcs, .id =DPLL_ID_ICL_TBTPLL , + .flags =INTEL_DPLL_IS_ALT_PORT_DPLL , }, { .name ="TC PLL 1" , .funcs = &dkl_pll_funcs, .id =DPLL_ID_ICL_MGPLL1 , }, { .name ="TC PLL 2" , .funcs = &dkl_pll_funcs, .id =DPLL_ID_ICL_MGPLL2 , }, { .name ="TC PLL 3" , .funcs = &dkl_pll_funcs, .id =DPLL_ID_ICL_MGPLL3 , },
@@ -4521,6 +4524,14 @@ verify_single_dpll_state(struct drm_i915 pll->info->name); } +static bool has_alt_port_dpll (const struct intel_shared_dpll *old_pll, +const struct intel_shared_dpll *new_pll) +{ +return old_pll && new_pll && old_pll != new_pll && + (old_pll->info->flags &INTEL_DPLL_IS_ALT_PORT_DPLL || + new_pll->info->flags &INTEL_DPLL_IS_ALT_PORT_DPLL ); +} +void intel_shared_dpll_state_verify (struct intel_atomic_state *state,struct intel_crtc *crtc) {
@@ -4542,7 +4553,11 @@ void intel_shared_dpll_state_verify(struI915_STATE_WARN (i915, pll->active_mask & pipe_mask,"%s: pll active mismatch (didn't expect pipe %c in active mask (0x%x))\n" , pll->info->name,pipe_name (crtc->pipe), pll->active_mask); -I915_STATE_WARN (i915, pll->state.pipe_mask & pipe_mask, + +/* TC ports have both MG/TC and TBT PLL referenced simultaneously */ +I915_STATE_WARN (i915, !has_alt_port_dpll (old_crtc_state->shared_dpll, + new_crtc_state->shared_dpll) && + pll->state.pipe_mask & pipe_mask,"%s: pll enabled crtcs mismatch (found pipe %c in enabled mask (0x%x))\n" , pll->info->name,pipe_name (crtc->pipe), pll->state.pipe_mask); }
drivers/gpu/drm/i915/display/intel_dpll_mgr.h +4 -0
@@ -271,12 +271,16 @@ struct dpll_info {enum intel_dpll_id id;#define INTEL_DPLL_ALWAYS_ON (1 << 0) +#define INTEL_DPLL_IS_ALT_PORT_DPLL (1 << 1)/** * @flags: * * INTEL_DPLL_ALWAYS_ON * Inform the state checker that the DPLL is kept enabled even if * not in use by any CRTC. +* INTEL_DPLL_IS_ALT_PORT_DPLL +* Inform the state checker that the DPLL can be used as a fallback +* (for TC->TBT fallback). */ u32 flags; };
Greg Kroah-Hartman
maintainerPATCH 331/432 drm/amd/display: Prevent crash when disable stream
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Park <[email protected]>
commit 72d72e8fddbcd6c98e1b02d32cf6f2b04e10bd1c upstream.
[Why]
Disabling stream encoder invokes a function that no longer exists.
[How]
Check if the function declaration is NULL in disable stream encoder.
--- drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c +2 -1
@@ -1184,7 +1184,8 @@ void dce110_disable_stream(struct pipe_cif (dccg) { dccg->funcs->disable_symclk32_se (dccg, dp_hpo_inst); dccg->funcs->set_dpstreamclk (dccg,REFCLK , tg->inst, dp_hpo_inst); - dccg->funcs->set_dtbclk_dto (dccg, &dto_params); +if (dccg && dccg->funcs->set_dtbclk_dto) + dccg->funcs->set_dtbclk_dto (dccg, &dto_params); } }else if (dccg && dccg->funcs->disable_symclk_se) { dccg->funcs->disable_symclk_se(dccg, stream_enc->stream_enc_inst,
Greg Kroah-Hartman
maintainerPATCH 332/432 ALSA: hda/tas2781: remove digital gain kcontrol
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gergo Koteles <[email protected]>
commit ae065d0ce9e36ca4efdfb9b96ce3395bd1c19372 upstream.
The "Speaker Digital Gain" kcontrol controls the TAS2781_DVC_LVL (0x1A) register. Unfortunately the tas2563 does not have DVC_LVL, but has INT_MASK0 in 0x1A, which has been misused so far.
Since commit c1947ce61ff4 ("ALSA: hda/realtek: tas2781: enable subwoofer volume control") the volume of the tas2781 amplifiers can be controlled by the master volume, so this digital gain kcontrol is not needed.
Remove it.
Message-ID: <741fc21db994efd58f83e7aef38931204961e5b2.1711469583.git.soyer@irl.hu>
--- sound/pci/hda/tas2781_hda_i2c.c | 37 +------------------------------------ 1 file changed, 1 insertion(+), 36 deletions(-)
sound/pci/hda/tas2781_hda_i2c.c +1 -36
@@ -71,7 +71,7 @@ struct tas2781_hda {struct snd_kcontrol *dsp_prog_ctl;struct snd_kcontrol *dsp_conf_ctl;struct snd_kcontrol *prof_ctl; -struct snd_kcontrol *snd_ctls[3 ]; +struct snd_kcontrol *snd_ctls[2 ]; };static int tas2781_get_i2c_res (struct acpi_resource *ares,void *data)
@@ -288,27 +288,6 @@ static int tasdevice_config_put(struct sreturn ret; } -/* -* tas2781_digital_getvol - get the volum control -* @kcontrol: control pointer -* @ucontrol: User data -* Customer Kcontrol for tas2781 is primarily for regmap booking, paging -* depends on internal regmap mechanism. -* tas2781 contains book and page two-level register map, especially -* book switching will set the register BXXP00R7F, after switching to the -* correct book, then leverage the mechanism for paging to access the -* register. -*/ -static int tas2781_digital_getvol (struct snd_kcontrol *kcontrol, -struct snd_ctl_elem_value *ucontrol) -{ -struct tasdevice_priv *tas_priv =snd_kcontrol_chip (kcontrol); -struct soc_mixer_control *mc = - (struct soc_mixer_control *)kcontrol->private_value; - -return tasdevice_digital_getvol (tas_priv, ucontrol, mc); -} -static int tas2781_amp_getvol (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) {
@@ -319,17 +298,6 @@ static int tas2781_amp_getvol(struct sndreturn tasdevice_amp_getvol (tas_priv, ucontrol, mc); } -static int tas2781_digital_putvol (struct snd_kcontrol *kcontrol, -struct snd_ctl_elem_value *ucontrol) -{ -struct tasdevice_priv *tas_priv =snd_kcontrol_chip (kcontrol); -struct soc_mixer_control *mc = - (struct soc_mixer_control *)kcontrol->private_value; - -/* The check of the given value is in tasdevice_digital_putvol. */ -return tasdevice_digital_putvol (tas_priv, ucontrol, mc); -} -static int tas2781_amp_putvol (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) {
@@ -375,9 +343,6 @@ static const struct snd_kcontrol_new tasACARD_SINGLE_RANGE_EXT_TLV ("Speaker Analog Gain" ,TAS2781_AMP_LEVEL ,1 ,0 ,20 ,0 , tas2781_amp_getvol, tas2781_amp_putvol, amp_vol_tlv), -ACARD_SINGLE_RANGE_EXT_TLV ("Speaker Digital Gain" ,TAS2781_DVC_LVL , -0 ,0 ,200 ,1 , tas2781_digital_getvol, - tas2781_digital_putvol, dvc_tlv),ACARD_SINGLE_BOOL_EXT ("Speaker Force Firmware Load" ,0 , tas2781_force_fwload_get, tas2781_force_fwload_put), };
Greg Kroah-Hartman
maintainerPATCH 333/432 ALSA: hda/tas2781: add locks to kcontrols
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gergo Koteles <[email protected]>
commit 15bc3066d2378eef1b45254be9df23b0dd7f1667 upstream.
The rcabin.profile_cfg_id, cur_prog, cur_conf, force_fwload_status variables are acccessible from multiple threads and therefore require locking.
Message-ID: <e35b867f6fe5fa1f869dd658a0a1f2118b737f57.1711469583.git.soyer@irl.hu>
--- sound/pci/hda/tas2781_hda_i2c.c | 50 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-)
sound/pci/hda/tas2781_hda_i2c.c +48 -2
@@ -179,8 +179,12 @@ static int tasdevice_get_profile_id(stru {struct tasdevice_priv *tas_priv =snd_kcontrol_chip (kcontrol); +mutex_lock (&tas_priv->codec_lock); + ucontrol->value.integer.value[0 ] = tas_priv->rcabin.profile_cfg_id; +mutex_unlock (&tas_priv->codec_lock); +return 0 ; }
@@ -194,11 +198,15 @@ static int tasdevice_set_profile_id(stru val =clamp (nr_profile,0 , max); +mutex_lock (&tas_priv->codec_lock); +if (tas_priv->rcabin.profile_cfg_id != val) { tas_priv->rcabin.profile_cfg_id = val; ret =1 ; } +mutex_unlock (&tas_priv->codec_lock); +return ret; }
@@ -235,8 +243,12 @@ static int tasdevice_program_get(struct {struct tasdevice_priv *tas_priv =snd_kcontrol_chip (kcontrol); +mutex_lock (&tas_priv->codec_lock); + ucontrol->value.integer.value[0 ] = tas_priv->cur_prog; +mutex_unlock (&tas_priv->codec_lock); +return 0 ; }
@@ -251,11 +263,15 @@ static int tasdevice_program_put(struct val =clamp (nr_program,0 , max); +mutex_lock (&tas_priv->codec_lock); +if (tas_priv->cur_prog != val) { tas_priv->cur_prog = val; ret =1 ; } +mutex_unlock (&tas_priv->codec_lock); +return ret; }
@@ -264,8 +280,12 @@ static int tasdevice_config_get(struct s {struct tasdevice_priv *tas_priv =snd_kcontrol_chip (kcontrol); +mutex_lock (&tas_priv->codec_lock); + ucontrol->value.integer.value[0 ] = tas_priv->cur_conf; +mutex_unlock (&tas_priv->codec_lock); +return 0 ; }
@@ -280,11 +300,15 @@ static int tasdevice_config_put(struct s val =clamp (nr_config,0 , max); +mutex_lock (&tas_priv->codec_lock); +if (tas_priv->cur_conf != val) { tas_priv->cur_conf = val; ret =1 ; } +mutex_unlock (&tas_priv->codec_lock); +return ret; }
@@ -294,8 +318,15 @@ static int tas2781_amp_getvol(struct sndstruct tasdevice_priv *tas_priv =snd_kcontrol_chip (kcontrol);struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; +int ret; -return tasdevice_amp_getvol (tas_priv, ucontrol, mc); +mutex_lock (&tas_priv->codec_lock); + + ret =tasdevice_amp_getvol (tas_priv, ucontrol, mc); + +mutex_unlock (&tas_priv->codec_lock); + +return ret; } static int tas2781_amp_putvol(struct snd_kcontrol *kcontrol,
@@ -304,9 +335,16 @@ static int tas2781_amp_putvol(struct sndstruct tasdevice_priv *tas_priv =snd_kcontrol_chip (kcontrol);struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; +int ret; + +mutex_lock (&tas_priv->codec_lock);/* The check of the given value is in tasdevice_amp_putvol. */ -return tasdevice_amp_putvol (tas_priv, ucontrol, mc); + ret =tasdevice_amp_putvol (tas_priv, ucontrol, mc); + +mutex_unlock (&tas_priv->codec_lock); + +return ret; } static int tas2781_force_fwload_get(struct snd_kcontrol *kcontrol,
@@ -314,10 +352,14 @@ static int tas2781_force_fwload_get(stru {struct tasdevice_priv *tas_priv =snd_kcontrol_chip (kcontrol); +mutex_lock (&tas_priv->codec_lock); + ucontrol->value.integer.value[0 ] = (int )tas_priv->force_fwload_status;dev_dbg (tas_priv->dev,"%s : Force FWload %s\n" , __func__, tas_priv->force_fwload_status ?"ON" :"OFF" ); +mutex_unlock (&tas_priv->codec_lock); +return 0 ; }
@@ -327,6 +369,8 @@ static int tas2781_force_fwload_put(strustruct tasdevice_priv *tas_priv =snd_kcontrol_chip (kcontrol);bool change, val = (bool )ucontrol->value.integer.value[0 ]; +mutex_lock (&tas_priv->codec_lock); +if (tas_priv->force_fwload_status == val) change = false;else {
@@ -336,6 +380,8 @@ static int tas2781_force_fwload_put(strudev_dbg (tas_priv->dev,"%s : Force FWload %s\n" , __func__, tas_priv->force_fwload_status ?"ON" :"OFF" ); +mutex_unlock (&tas_priv->codec_lock); +return change; }
Greg Kroah-Hartman
maintainerPATCH 334/432 init: open /initrd.image with O_LARGEFILE
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Sperbeck <[email protected]>
commit 4624b346cf67400ef46a31771011fb798dd2f999 upstream.
If initrd data is larger than 2Gb, we'll eventually fail to write to the /initrd.image file when we hit that limit, unless O_LARGEFILE is set.
--- init/initramfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
init/initramfs.c +1 -1
@@ -673,7 +673,7 @@ static void __init populate_initrd_imageprintk (KERN_INFO "rootfs image is not initramfs (%s); looks like an initrd\n" , err); - file =filp_open ("/initrd.image" ,O_WRONLY |O_CREAT ,0700 ); + file =filp_open ("/initrd.image" ,O_WRONLY |O_CREAT |O_LARGEFILE ,0700 );if (IS_ERR (file))return ;
Greg Kroah-Hartman
maintainerPATCH 335/432 x86/efistub: Add missing boot_params for mixed mode compat entry
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit d21f5a59ea773826cc489acb287811d690b703cc upstream.
The pure EFI stub entry point does not take a struct boot_params from the boot loader, but creates it from scratch, and populates only the fields that still have meaning in this context (command line, initrd base and size, etc)
The original mixed mode implementation used the EFI handover protocol instead, where the boot loader (i.e., GRUB) populates a boot_params struct and passes it to a special Linux specific EFI entry point that takes the boot_params pointer as its third argument.
When the new mixed mode implementation was introduced, using a special 32-bit PE entrypoint in the 64-bit kernel, it adopted the pure approach, and relied on the EFI stub to create the struct boot_params. This is preferred because it makes the bootloader side much easier to implement, as it does not need any x86-specific knowledge on how struct boot_params and struct setup_header are put together. This mixed mode implementation was adopted by systemd-boot version 252 and later.
When commit
e2ab9eab324c ("x86/boot/compressed: Move 32-bit entrypoint code into .text section")
refactored this code and moved it out of head_64.S, the fact that ESI was populated with the address of the base of the image was overlooked, and to simplify the code flow, ESI is now zeroed and stored to memory unconditionally in shared code, so that the NULL-ness of that variable can still be used later to determine which mixed mode boot protocol is in use.
With ESI pointing to the base of the image, it can serve as a struct boot_params pointer for startup_32(), which only accesses the init_data and kernel_alignment fields (and the scratch field as a temporary stack). Zeroing ESI means that those accesses produce garbage now, even though things appear to work if the first page of memory happens to be zeroed, and the region right before LOAD_PHYSICAL_ADDR (== 16 MiB) happens to be free.
The solution is to pass a special, temporary struct boot_params to startup_32() via ESI, one that is sufficient for getting it to create the page tables correctly and is discarded right after. This involves setting a minimal alignment of 4k, only to get the statically allocated page tables line up correctly, and setting init_size to the executable image size (_end - startup_32). This ensures that the page tables are covered by the static footprint of the PE image.
Given that EFI boot no longer calls the decompressor and no longer pads the image to permit the decompressor to execute in place, the same temporary struct boot_params should be used in the EFI handover protocol based mixed mode implementation as well, to prevent the page tables from being placed outside of allocated memory.
--- arch/x86/boot/compressed/efi_mixed.S | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
arch/x86/boot/compressed/efi_mixed.S +15 -5
@@ -15,10 +15,12 @@ */ #include <linux/linkage.h> +#include <asm/asm-offsets.h> #include <asm/msr.h> #include <asm/page_types.h> #include <asm/processor-flags.h> #include <asm/segment.h> +#include <asm/setup.h> .code64 .text
@@ -149,6 +151,7 @@ SYM_FUNC_END(__efi64_thunk) SYM_FUNC_START(efi32_stub_entry) call 1f 1: popl %ecx + leal (efi32_boot_args - 1b)(%ecx), %ebx /* Clear BSS */ xorl %eax, %eax
@@ -163,6 +166,7 @@ SYM_FUNC_START(efi32_stub_entry) popl %ecx popl %edx popl %esi + movl %esi, 8(%ebx) jmp efi32_entry SYM_FUNC_END(efi32_stub_entry) #endif
@@ -239,8 +243,6 @@ SYM_FUNC_END(efi_enter32) * * Arguments: %ecx image handle * %edx EFI system table pointer - * %esi struct bootparams pointer (or NULL when not using - * the EFI handover protocol) * * Since this is the point of no return for ordinary execution, no registers * are considered live except for the function parameters. [Note that the EFI
@@ -266,9 +268,18 @@ SYM_FUNC_START_LOCAL(efi32_entry) leal (efi32_boot_args - 1b)(%ebx), %ebx movl %ecx, 0(%ebx) movl %edx, 4(%ebx) - movl %esi, 8(%ebx) movb $0x0, 12(%ebx) // efi_is64 + /* + * Allocate some memory for a temporary struct boot_params, which only + * needs the minimal pieces that startup_32() relies on. + */ + subl $PARAM_SIZE, %esp + movl %esp, %esi + movl $PAGE_SIZE, BP_kernel_alignment(%esi) + movl $_end - 1b, BP_init_size(%esi) + subl $startup_32 - 1b, BP_init_size(%esi) + /* Disable paging */ movl %cr0, %eax btrl $X86_CR0_PG_BIT, %eax
@@ -294,8 +305,7 @@ SYM_FUNC_START(efi32_pe_entry) movl 8(%ebp), %ecx // image_handle movl 12(%ebp), %edx // sys_table - xorl %esi, %esi - jmp efi32_entry // pass %ecx, %edx, %esi + jmp efi32_entry // pass %ecx, %edx // no other registers remain live 2: popl %edi // restore callee-save registers
Greg Kroah-Hartman
maintainerPATCH 336/432 efi/libstub: Cast away type warning in use of max()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit 61d130f261a3c15ae2c4b6f3ac3517d5d5b78855 upstream.
Avoid a type mismatch warning in max() by switching to max_t() and providing the type explicitly.
--- drivers/firmware/efi/libstub/randomalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/efi/libstub/randomalloc.c +1 -1
@@ -120,7 +120,7 @@ efi_status_t efi_random_alloc(unsigned lcontinue ; } - target =round_up (max (md->phys_addr, alloc_min), align) + target_slot * align; + target =round_up (max_t (u64, md->phys_addr, alloc_min), align) + target_slot * align; pages = size /EFI_PAGE_SIZE ; status = efi_bs_call(allocate_pages, EFI_ALLOCATE_ADDRESS,
Greg Kroah-Hartman
maintainerPATCH 337/432 x86/efistub: Reinstate soft limit for initrd loading
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit decd347c2a75d32984beb8807d470b763a53b542 upstream.
Commit
8117961d98fb2 ("x86/efi: Disregard setup header of loaded image")
dropped the memcopy of the image's setup header into the boot_params struct provided to the core kernel, on the basis that EFI boot does not need it and should rely only on a single protocol to interface with the boot chain. It is also a prerequisite for being able to increase the section alignment to 4k, which is needed to enable memory protections when running in the boot services.
So only the setup_header fields that matter to the core kernel are populated explicitly, and everything else is ignored. One thing was overlooked, though: the initrd_addr_max field in the setup_header is not used by the core kernel, but it is used by the EFI stub itself when it loads the initrd, where its default value of INT_MAX is used as the soft limit for memory allocation.
This means that, in the old situation, the initrd was virtually always loaded in the lower 2G of memory, but now, due to initrd_addr_max being 0x0, the initrd may end up anywhere in memory. This should not be an issue principle, as most systems can deal with this fine. However, it does appear to tickle some problems in older UEFI implementations, where the memory ends up being corrupted, resulting in errors when unpacking the initramfs.
So set the initrd_addr_max field to INT_MAX like it was before.
--- drivers/firmware/efi/libstub/x86-stub.c | 1 + 1 file changed, 1 insertion(+)
drivers/firmware/efi/libstub/x86-stub.c +1 -0
@@ -487,6 +487,7 @@ efi_status_t __efiapi efi_pe_entry(efi_h hdr->vid_mode =0xffff ; hdr->type_of_loader =0x21 ; + hdr->initrd_addr_max =INT_MAX ;/* Convert unicode cmdline to ascii */ cmdline_ptr =efi_convert_cmdline (image, &options_size);
Greg Kroah-Hartman
maintainerPATCH 338/432 prctl: generalize PR_SET_MDWE support check to be per-arch
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zev Weiss <[email protected]>
commit d5aad4c2ca057e760a92a9a7d65bd38d72963f27 upstream.
Patch series "ARM: prctl: Reject PR_SET_MDWE where not supported".
I noticed after a recent kernel update that my ARM926 system started segfaulting on any execve() after calling prctl(PR_SET_MDWE). After some investigation it appears that ARMv5 is incapable of providing the appropriate protections for MDWE, since any readable memory is also implicitly executable.
The prctl_set_mdwe() function already had some special-case logic added disabling it on PARISC (commit 793838138c15, "prctl: Disable prctl(PR_SET_MDWE) on parisc"); this patch series (1) generalizes that check to use an arch_*() function, and (2) adds a corresponding override for ARM to disable MDWE on pre-ARMv6 CPUs.
With the series applied, prctl(PR_SET_MDWE) is rejected on ARMv5 and subsequent execve() calls (as well as mmap(PROT_READ|PROT_WRITE)) can succeed instead of unconditionally failing; on ARMv6 the prctl works as it did previously.
[0] https://lore.kernel.org/all/2023112456-linked-nape-bf19@gregkh/
This patch (of 2):
There exist systems other than PARISC where MDWE may not be feasible to support; rather than cluttering up the generic code with additional arch-specific logic let's add a generic function for checking MDWE support and allow each arch to override it as needed.
--- arch/parisc/include/asm/mman.h | 14 ++++++++++++++ include/linux/mman.h | 8 ++++++++ kernel/sys.c | 7 +++++-- 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 arch/parisc/include/asm/mman.h
arch/parisc/include/asm/mman.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __ASM_MMAN_H__ +#define __ASM_MMAN_H__ + +#include <uapi/asm/mman.h> + +/* PARISC cannot allow mdwe as it needs writable stacks */ +static inline bool arch_memory_deny_write_exec_supported (void ) +{ +return false; +} +#define arch_memory_deny_write_exec_supported arch_memory_deny_write_exec_supported + +#endif /* __ASM_MMAN_H__ */
include/linux/mman.h +8 -0
@@ -162,6 +162,14 @@ calc_vm_flag_bits(unsigned long flags)unsigned long vm_commit_limit (void ); +#ifndef arch_memory_deny_write_exec_supported +static inline bool arch_memory_deny_write_exec_supported (void ) +{ +return true; +} +#define arch_memory_deny_write_exec_supported arch_memory_deny_write_exec_supported +#endif +/* * Denies creating a writable executable mapping or gaining executable permissions. *
kernel/sys.c +5 -2
@@ -2408,8 +2408,11 @@ static inline int prctl_set_mdwe(unsigneif (bits &PR_MDWE_NO_INHERIT && !(bits &PR_MDWE_REFUSE_EXEC_GAIN ))return -EINVAL ; -/* PARISC cannot allow mdwe as it needs writable stacks */ -if (IS_ENABLED (CONFIG_PARISC )) +/* +* EOPNOTSUPP might be more appropriate here in principle, but +* existing userspace depends on EINVAL specifically. +*/ +if (!arch_memory_deny_write_exec_supported ())return -EINVAL ; current_bits =get_current_mdwe ();
Greg Kroah-Hartman
maintainerPATCH 339/432 ARM: prctl: reject PR_SET_MDWE on pre-ARMv6
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zev Weiss <[email protected]>
commit 166ce846dc5974a266f6c2a2896dbef5425a6f21 upstream.
On v5 and lower CPUs we can't provide MDWE protection, so ensure we fail any attempt to enable it via prctl(PR_SET_MDWE).
Previously such an attempt would misleadingly succeed, leading to any subsequent mmap(PROT_READ|PROT_WRITE) or execve() failing unconditionally (the latter somewhat violently via force_fatal_sig(SIGSEGV) due to READ_IMPLIES_EXEC).
--- arch/arm/include/asm/mman.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 arch/arm/include/asm/mman.h
arch/arm/include/asm/mman.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __ASM_MMAN_H__ +#define __ASM_MMAN_H__ + +#include <asm/system_info.h> +#include <uapi/asm/mman.h> + +static inline bool arch_memory_deny_write_exec_supported (void ) +{ +return cpu_architecture () >= CPU_ARCH_ARMv6; +} +#define arch_memory_deny_write_exec_supported arch_memory_deny_write_exec_supported + +#endif /* __ASM_MMAN_H__ */
Greg Kroah-Hartman
maintainerPATCH 340/432 tmpfs: fix race on handling dquot rbtree
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Carlos Maiolino <[email protected]>
commit 0a69b6b3a026543bc215ccc866d0aea5579e6ce2 upstream.
A syzkaller reproducer found a race while attempting to remove dquot information from the rb tree.
Fetching the rb_tree root node must also be protected by the dqopt->dqio_sem, otherwise, giving the right timing, shmem_release_dquot() will trigger a warning because it couldn't find a node in the tree, when the real reason was the root node changing before the search starts:
Thread 1 Thread 2
- shmem_release_dquot() - shmem_{acquire,release}_dquot()
- fetch ROOT - Fetch ROOT
- acquire dqio_sem
- wait dqio_sem
- do something, triger a tree rebalance
- release dqio_sem
- acquire dqio_sem
- start searching for the node, but
from the wrong location, missing
the node, and triggering a warning.
--- mm/shmem_quota.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
mm/shmem_quota.c +7 -3
@@ -116,7 +116,7 @@ static int shmem_free_file_info(struct sstatic int shmem_get_next_id (struct super_block *sb,struct kqid *qid) {struct mem_dqinfo *info =sb_dqinfo (sb, qid->type); -struct rb_node *node = ((struct rb_root *)info->dqi_priv)->rb_node; +struct rb_node *node;qid_t id =from_kqid (&init_user_ns, *qid);struct quota_info *dqopt =sb_dqopt (sb);struct quota_id *entry =NULL ;
@@ -126,6 +126,7 @@ static int shmem_get_next_id(struct supereturn -ESRCH ;down_read (&dqopt->dqio_sem); + node = ((struct rb_root *)info->dqi_priv)->rb_node;while (node) { entry = rb_entry(node, struct quota_id, node);
@@ -165,7 +166,7 @@ out_unlock:static int shmem_acquire_dquot (struct dquot *dquot) {struct mem_dqinfo *info =sb_dqinfo (dquot->dq_sb, dquot->dq_id.type); -struct rb_node **n = &((struct rb_root *)info->dqi_priv)->rb_node; +struct rb_node **n;struct shmem_sb_info *sbinfo = dquot->dq_sb->s_fs_info;struct rb_node *parent =NULL , *new_node =NULL ;struct quota_id *new_entry, *entry;
@@ -176,6 +177,8 @@ static int shmem_acquire_dquot(struct dqmutex_lock (&dquot->dq_lock);down_write (&dqopt->dqio_sem); + n = &((struct rb_root *)info->dqi_priv)->rb_node; +while (*n) { parent = *n; entry = rb_entry(parent, struct quota_id, node);
@@ -264,7 +267,7 @@ static bool shmem_is_empty_dquot(structstatic int shmem_release_dquot (struct dquot *dquot) {struct mem_dqinfo *info =sb_dqinfo (dquot->dq_sb, dquot->dq_id.type); -struct rb_node *node = ((struct rb_root *)info->dqi_priv)->rb_node; +struct rb_node *node;qid_t id =from_kqid (&init_user_ns, dquot->dq_id);struct quota_info *dqopt =sb_dqopt (dquot->dq_sb);struct quota_id *entry =NULL ;
@@ -275,6 +278,7 @@ static int shmem_release_dquot(struct dq goto out_dqlock;down_write (&dqopt->dqio_sem); + node = ((struct rb_root *)info->dqi_priv)->rb_node;while (node) { entry = rb_entry(node, struct quota_id, node);
Greg Kroah-Hartman
maintainerPATCH 341/432 btrfs: validate device maj:min during open
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anand Jain <[email protected]>
commit 9f7eb8405dcbc79c5434821e9e3e92abe187ee8e upstream.
Boris managed to create a device capable of changing its maj:min without altering its device path.
Only multi-devices can be scanned. A device that gets scanned and remains in the btrfs kernel cache might end up with an incorrect maj:min.
Despite the temp-fsid feature patch did not introduce this bug, it could lead to issues if the above multi-device is converted to a single device with a stale maj:min. Subsequently, attempting to mount the same device with the correct maj:min might mistake it for another device with the same fsid, potentially resulting in wrongly auto-enabling the temp-fsid feature.
To address this, this patch validates the device's maj:min at the time of device open and updates it if it has changed since the last scan.
--- fs/btrfs/volumes.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
fs/btrfs/volumes.c +10 -0
@@ -683,6 +683,16 @@ static int btrfs_open_one_device(struct device->bdev = bdev_handle->bdev;clear_bit (BTRFS_DEV_STATE_IN_FS_METADATA , &device->dev_state); +if (device->devt != device->bdev->bd_dev) { +btrfs_warn (NULL , +"device %s maj:min changed from %d:%d to %d:%d" , + device->name->str,MAJOR (device->devt), +MINOR (device->devt),MAJOR (device->bdev->bd_dev), +MINOR (device->bdev->bd_dev)); + + device->devt = device->bdev->bd_dev; + } + fs_devices->open_devices++;if (test_bit (BTRFS_DEV_STATE_WRITEABLE , &device->dev_state) && device->devid !=BTRFS_DEV_REPLACE_DEVID ) {
Greg Kroah-Hartman
maintainerPATCH 342/432 btrfs: fix race in read_extent_buffer_pages()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tavian Barnes <[email protected]>
commit ef1e68236b9153c27cb7cf29ead0c532870d4215 upstream.
There are reports from tree-checker that detects corrupted nodes, without any obvious pattern so possibly an overwrite in memory. After some debugging it turns out there's a race when reading an extent buffer the uptodate status can be missed.
To prevent concurrent reads for the same extent buffer, read_extent_buffer_pages() performs these checks:
/* (1) */
if (test_bit(EXTENT_BUFFER_UPTODATE, &eb->bflags))
return 0;
/* (2) */
if (test_and_set_bit(EXTENT_BUFFER_READING, &eb->bflags))
goto done;At this point, it seems safe to start the actual read operation. Once that completes, end_bbio_meta_read() does
/* (3) */
set_extent_buffer_uptodate(eb);
/* (4) */
clear_bit(EXTENT_BUFFER_READING, &eb->bflags);Normally, this is enough to ensure only one read happens, and all other callers wait for it to finish before returning. Unfortunately, there is a racey interleaving:
Thread A | Thread B | Thread C
---------+----------+---------
(1) | |
| (1) |
(2) | |
(3) | |
(4) | |
| (2) |
| | (1)When this happens, thread B kicks of an unnecessary read. Worse, thread C will see UPTODATE set and return immediately, while the read from thread B is still in progress. This race could result in tree-checker errors like this as the extent buffer is concurrently modified:
BTRFS critical (device dm-0): corrupted node, root=256
block=8550954455682405139 owner mismatch, have 11858205567642294356
expect [256, 18446744073709551360]Fix it by testing UPTODATE again after setting the READING bit, and if it's been set, skip the unnecessary read.
--- fs/btrfs/extent_io.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
fs/btrfs/extent_io.c +13 -0
@@ -4052,6 +4052,19 @@ int read_extent_buffer_pages(struct exteif (test_and_set_bit (EXTENT_BUFFER_READING , &eb->bflags)) goto done; +/* +* Between the initial test_bit(EXTENT_BUFFER_UPTODATE) and the above +* test_and_set_bit(EXTENT_BUFFER_READING), someone else could have +* started and finished reading the same eb. In this case, UPTODATE +* will now be set, and we shouldn't read it in again. +*/ +if (unlikely (test_bit (EXTENT_BUFFER_UPTODATE , &eb->bflags))) { +clear_bit (EXTENT_BUFFER_READING , &eb->bflags); +smp_mb__after_atomic (); +wake_up_bit (&eb->bflags,EXTENT_BUFFER_READING ); +return 0 ; + } +clear_bit (EXTENT_BUFFER_READ_ERR , &eb->bflags); eb->read_mirror =0 ;check_buffer_tree_ref (eb);
Greg Kroah-Hartman
maintainerPATCH 343/432 btrfs: zoned: dont skip block groups with 100% zone unusable
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Thumshirn <[email protected]>
commit a8b70c7f8600bc77d03c0b032c0662259b9e615e upstream.
Commit f4a9f219411f ("btrfs: do not delete unused block group if it may be used soon") changed the behaviour of deleting unused block-groups on zoned filesystems. Starting with this commit, we're using btrfs_space_info_used() to calculate the number of used bytes in a space_info. But btrfs_space_info_used() also accounts btrfs_space_info::bytes_zone_unusable as used bytes.
So if a block group is 100% zone_unusable it is skipped from the deletion step.
In order not to skip fully zone_unusable block-groups, also check if the block-group has bytes left that can be used on a zoned filesystem.
--- fs/btrfs/block-group.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/block-group.c +2 -1
@@ -1562,7 +1562,8 @@ void btrfs_delete_unused_bgs(struct btrf* needing to allocate extents from the block group. */ used =btrfs_space_info_used (space_info, true); -if (space_info->total_bytes - block_group->length < used) { +if (space_info->total_bytes - block_group->length < used && + block_group->zone_unusable < block_group->length) {/* * Add a reference for the list, compensate for the ref * drop under the "next" label for the
Greg Kroah-Hartman
maintainerPATCH 344/432 btrfs: zoned: use zone aware sb location for scrub
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Thumshirn <[email protected]>
commit 74098a989b9c3370f768140b7783a7aaec2759b3 upstream.
At the moment scrub_supers() doesn't grab the super block's location via the zoned device aware btrfs_sb_log_location() but via btrfs_sb_offset().
This leads to checksum errors on 'scrub' as we're not accessing the correct location of the super block.
So use btrfs_sb_log_location() for getting the super blocks location on scrub.
--- fs/btrfs/scrub.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
fs/btrfs/scrub.c +11 -1
@@ -2809,7 +2809,17 @@ static noinline_for_stack int scrub_supe gen =btrfs_get_last_trans_committed (fs_info);for (i =0 ; i <BTRFS_SUPER_MIRROR_MAX ; i++) { - bytenr =btrfs_sb_offset (i); + ret =btrfs_sb_log_location (scrub_dev, i,0 , &bytenr); +if (ret == -ENOENT ) +break ; + +if (ret) { +spin_lock (&sctx->stat_lock); + sctx->stat.super_errors++; +spin_unlock (&sctx->stat_lock); +continue ; + } +if (bytenr +BTRFS_SUPER_INFO_SIZE > scrub_dev->commit_total_bytes)break ;
Greg Kroah-Hartman
maintainerPATCH 345/432 wifi: mac80211: check/clear fast rx for non-4addr sta VLAN changes
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Fietkau <[email protected]>
commit 4f2bdb3c5e3189297e156b3ff84b140423d64685 upstream.
When moving a station out of a VLAN and deleting the VLAN afterwards, the fast_rx entry still holds a pointer to the VLAN's netdev, which can cause use-after-free bugs. Fix this by immediately calling ieee80211_check_fast_rx after the VLAN change.
--- net/mac80211/cfg.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
net/mac80211/cfg.c +2 -3
@@ -2164,15 +2164,14 @@ static int ieee80211_change_station(stru }if (sta->sdata->vif.type ==NL80211_IFTYPE_AP_VLAN && - sta->sdata->u.vlan.sta) { -ieee80211_clear_fast_rx (sta); + sta->sdata->u.vlan.sta)RCU_INIT_POINTER (sta->sdata->u.vlan.sta,NULL ); - }if (test_sta_flag (sta,WLAN_STA_AUTHORIZED ))ieee80211_vif_dec_num_mcast (sta->sdata); sta->sdata = vlansdata; +ieee80211_check_fast_rx (sta);ieee80211_check_fast_xmit (sta);if (test_sta_flag (sta,WLAN_STA_AUTHORIZED )) {
Greg Kroah-Hartman
maintainerPATCH 346/432 wifi: cfg80211: add a flag to disable wireless extensions
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
commit be23b2d7c3b7c8bf57b1cf0bf890bd65df9d0186 upstream.
Wireless extensions are already disabled if MLO is enabled, given that we cannot support MLO there with all the hard- coded assumptions about BSSID etc.
However, the WiFi7 ecosystem is still stabilizing, and some devices may need MLO disabled while that happens. In that case, we might end up with a device that supports wext (but not MLO) in one kernel, and then breaks wext in the future (by enabling MLO), which is not desirable.
Add a flag to let such drivers/devices disable wext even if MLO isn't yet enabled.
--- include/net/cfg80211.h | 2 ++ net/wireless/wext-core.c | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-)
include/net/cfg80211.h +2 -0
@@ -4914,6 +4914,7 @@ struct cfg80211_ops {* NL80211_REGDOM_SET_BY_DRIVER. * @WIPHY_FLAG_CHANNEL_CHANGE_ON_BEACON: reg_call_notifier() is called if driver * set this flag to update channels on beacon hints. +* @WIPHY_FLAG_DISABLE_WEXT: disable wireless extensions for this device */ enum wiphy_flags {WIPHY_FLAG_SUPPORTS_EXT_KEK_KCK =BIT (0 ),
@@ -4925,6 +4926,7 @@ enum wiphy_flags {WIPHY_FLAG_4ADDR_STATION =BIT (6 ),WIPHY_FLAG_CONTROL_PORT_PROTOCOL =BIT (7 ),WIPHY_FLAG_IBSS_RSN =BIT (8 ), +WIPHY_FLAG_DISABLE_WEXT =BIT (9 ),WIPHY_FLAG_MESH_AUTH =BIT (10 ), WIPHY_FLAG_SUPPORTS_EXT_KCK_32 = BIT(11),/* use hole at 12 */
net/wireless/wext-core.c +5 -2
@@ -4,6 +4,7 @@* Authors : Jean Tourrilhes - HPL - <[email protected]> * Copyright (c) 1997-2007 Jean Tourrilhes, All Rights Reserved. * Copyright 2009 Johannes Berg <[email protected]> +* Copyright (C) 2024 Intel Corporation * * (As all part of the Linux kernel, this file is GPL) */
@@ -662,7 +663,8 @@ struct iw_statistics *get_wireless_stats dev->ieee80211_ptr->wiphy->wext && dev->ieee80211_ptr->wiphy->wext->get_wireless_stats) {wireless_warn_cfg80211_wext (); -if (dev->ieee80211_ptr->wiphy->flags &WIPHY_FLAG_SUPPORTS_MLO ) +if (dev->ieee80211_ptr->wiphy->flags & (WIPHY_FLAG_SUPPORTS_MLO | +WIPHY_FLAG_DISABLE_WEXT ))return NULL ;return dev->ieee80211_ptr->wiphy->wext->get_wireless_stats (dev); }
@@ -704,7 +706,8 @@ static iw_handler get_handler(struct net#ifdef CONFIG_CFG80211_WEXT if (dev->ieee80211_ptr && dev->ieee80211_ptr->wiphy) {wireless_warn_cfg80211_wext (); -if (dev->ieee80211_ptr->wiphy->flags &WIPHY_FLAG_SUPPORTS_MLO ) +if (dev->ieee80211_ptr->wiphy->flags & (WIPHY_FLAG_SUPPORTS_MLO | +WIPHY_FLAG_DISABLE_WEXT ))return NULL ; handlers = dev->ieee80211_ptr->wiphy->wext; }
Greg Kroah-Hartman
maintainerPATCH 347/432 wifi: iwlwifi: mvm: disable MLO for the time being
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
commit 5f404005055304830bbbee0d66af2964fc48f29e upstream.
MLO ended up not really fully stable yet, we want to make sure it works well with the ecosystem before enabling it. Thus, remove the flag, but set WIPHY_FLAG_DISABLE_WEXT so we don't get wireless extensions back until we enable MLO for this hardware.
--- drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c +1 -1
@@ -344,7 +344,7 @@ int iwl_mvm_mac_setup_register(struct iwif (mvm->mld_api_is_used && mvm->nvm_data->sku_cap_11be_enable && !iwlwifi_mod_params.disable_11ax && !iwlwifi_mod_params.disable_11be) - hw->wiphy->flags |=WIPHY_FLAG_SUPPORTS_MLO ; + hw->wiphy->flags |=WIPHY_FLAG_DISABLE_WEXT ;/* With MLD FW API, it tracks timing by itself, * no need for any timing from the host
Greg Kroah-Hartman
maintainerPATCH 348/432 wifi: iwlwifi: fw: dont always use FW dump trig
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
commit 045a5b645dd59929b0e05375f493cde3a0318271 upstream.
Since the dump_data (struct iwl_fwrt_dump_data) is a union, it's not safe to unconditionally access and use the 'trig' member, it might be 'desc' instead. Access it only if it's known to be 'trig' rather than 'desc', i.e. if ini-debug is present.
--- drivers/net/wireless/intel/iwlwifi/fw/dbg.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/net/wireless/intel/iwlwifi/fw/dbg.c +9 -8
@@ -3075,8 +3075,6 @@ static void iwl_fw_dbg_collect_sync(strustruct iwl_fw_dbg_params params = {0 };struct iwl_fwrt_dump_data *dump_data = &fwrt->dump.wks[wk_idx].dump_data; -u32 policy; -u32 time_point;if (!test_bit (wk_idx, &fwrt->dump.active_wks))return ;
@@ -3107,13 +3105,16 @@ static void iwl_fw_dbg_collect_sync(struiwl_fw_dbg_stop_restart_recording (fwrt, ¶ms, false); - policy =le32_to_cpu (dump_data->trig->apply_policy); - time_point =le32_to_cpu (dump_data->trig->time_point); - -if (policy &IWL_FW_INI_APPLY_POLICY_DUMP_COMPLETE_CMD ) { -IWL_DEBUG_FW_INFO (fwrt,"WRT: sending dump complete\n" ); -iwl_send_dbg_dump_complete_cmd (fwrt, time_point,0 ); +if (iwl_trans_dbg_ini_valid (fwrt->trans)) { +u32 policy =le32_to_cpu (dump_data->trig->apply_policy); +u32 time_point =le32_to_cpu (dump_data->trig->time_point); + +if (policy &IWL_FW_INI_APPLY_POLICY_DUMP_COMPLETE_CMD ) { +IWL_DEBUG_FW_INFO (fwrt,"WRT: sending dump complete\n" ); +iwl_send_dbg_dump_complete_cmd (fwrt, time_point,0 ); + } } +if (fwrt->trans->dbg.last_tp_resetfw ==IWL_FW_INI_RESET_FW_MODE_STOP_FW_ONLY )iwl_force_nmi (fwrt->trans);
Greg Kroah-Hartman
maintainerPATCH 349/432 wifi: iwlwifi: mvm: handle debugfs names more carefully
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
commit 19d82bdedaf2db0bfb3762dda714ea803065eed5 upstream.
With debugfs=off, we can get here with the dbgfs_dir being an ERR_PTR(). Instead of checking for all this, which is often flagged as a mistake, simply handle the names here more carefully by printing them, then we don't need extra checks.
Also, while checking, I noticed theoretically 'buf' is too small, so fix that size as well.
--- drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c +7 -4
@@ -735,7 +735,9 @@ void iwl_mvm_vif_dbgfs_add_link(struct i {struct dentry *dbgfs_dir = vif->debugfs_dir;struct iwl_mvm_vif *mvmvif =iwl_mvm_vif_from_mac80211 (vif); -char buf[100 ]; +char buf[3 *3 +11 + (NL80211_WIPHY_NAME_MAXLEN +1 ) + + (7 +IFNAMSIZ +1 ) +6 +1 ]; +char name[7 +IFNAMSIZ +1 ];/* this will happen in monitor mode */ if (!dbgfs_dir)
@@ -748,10 +750,11 @@ void iwl_mvm_vif_dbgfs_add_link(struct i* find * netdev:wlan0 -> ../../../ieee80211/phy0/netdev:wlan0/iwlmvm/ */ -snprintf (buf,100 ,"../../../%pd3/iwlmvm" , dbgfs_dir); +snprintf (name,sizeof (name),"%pd" , dbgfs_dir); +snprintf (buf,sizeof (buf),"../../../%pd3/iwlmvm" , dbgfs_dir); - mvmvif->dbgfs_slink =debugfs_create_symlink (dbgfs_dir->d_name.name, - mvm->debugfs_dir, buf); + mvmvif->dbgfs_slink = +debugfs_create_symlink (name, mvm->debugfs_dir, buf); }void iwl_mvm_vif_dbgfs_rm_link (struct iwl_mvm *mvm,struct ieee80211_vif *vif)
Greg Kroah-Hartman
maintainerPATCH 350/432 Revert "drm/amd/display: Fix sending VSC (+ colorimetry) packets for DP/eDP displays without PSR"
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Harry Wentland <[email protected]>
commit 78aca9ee5e012e130dbfbd7191bc2302b0cf3b37 upstream.
This causes flicker on a bunch of eDP panels. The info_packet code also caused regressions on other OSes that we haven't' seen on Linux yet, but that is likely due to the fact that we haven't had a chance to test those environments on Linux.
We'll need to revisit this.
This reverts commit 202260f64519e591b5cd99626e441b6559f571a3.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 8 ++---- drivers/gpu/drm/amd/display/modules/info_packet/info_packet.c | 13 +++------- 2 files changed, 8 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +3 -5
@@ -6163,9 +6163,8 @@ create_stream_for_sink(struct drm_connecif (stream->signal ==SIGNAL_TYPE_HDMI_TYPE_A )mod_build_hf_vsif_infopacket (stream, &stream->vsp_infopacket); -else if (stream->signal ==SIGNAL_TYPE_DISPLAY_PORT || - stream->signal ==SIGNAL_TYPE_DISPLAY_PORT_MST || - stream->signal ==SIGNAL_TYPE_EDP ) { + +if (stream->link->psr_settings.psr_feature_enabled || stream->link->replay_settings.replay_feature_enabled) {// // should decide stream support vsc sdp colorimetry capability // before building vsc info packet
@@ -6181,9 +6180,8 @@ create_stream_for_sink(struct drm_connecif (stream->out_transfer_func->tf ==TRANSFER_FUNCTION_GAMMA22 ) tf =TRANSFER_FUNC_GAMMA_22 ;mod_build_vsc_infopacket (stream, &stream->vsc_infopacket, stream->output_color_space, tf); + aconnector->psr_skip_count =AMDGPU_DM_PSR_ENTRY_DELAY ; -if (stream->link->psr_settings.psr_feature_enabled) - aconnector->psr_skip_count =AMDGPU_DM_PSR_ENTRY_DELAY ; } finish:dc_sink_release (sink);
drivers/gpu/drm/amd/display/modules/info_packet/info_packet.c +5 -8
@@ -147,15 +147,12 @@ void mod_build_vsc_infopacket(const stru }/* VSC packet set to 4 for PSR-SU, or 2 for PSR1 */ -if (stream->link->psr_settings.psr_feature_enabled) { -if (stream->link->psr_settings.psr_version ==DC_PSR_VERSION_SU_1 ) - vsc_packet_revision = vsc_packet_rev4; -else if (stream->link->psr_settings.psr_version ==DC_PSR_VERSION_1 ) - vsc_packet_revision = vsc_packet_rev2; - } - -if (stream->link->replay_settings.config.replay_supported) +if (stream->link->psr_settings.psr_version ==DC_PSR_VERSION_SU_1 ) + vsc_packet_revision = vsc_packet_rev4; +else if (stream->link->replay_settings.config.replay_supported) vsc_packet_revision = vsc_packet_rev4; +else if (stream->link->psr_settings.psr_version ==DC_PSR_VERSION_1 ) + vsc_packet_revision = vsc_packet_rev2;/* Update to revision 5 for extended colorimetry support */ if (stream->use_vsc_sdp_for_colorimetry)
Greg Kroah-Hartman
maintainerPATCH 351/432 gpio: cdev: sanitize the label before requesting the interrupt
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bartosz Golaszewski <[email protected]>
commit b34490879baa847d16fc529c8ea6e6d34f004b38 upstream.
When an interrupt is requested, a procfs directory is created under "/proc/irq/<irqnum>/<label>" where <label> is the string passed to one of the request_irq() variants.
What follows is that the string must not contain the "/" character or the procfs mkdir operation will fail. We don't have such constraints for GPIO consumer labels which are used verbatim as interrupt labels for GPIO irqs. We must therefore sanitize the consumer string before requesting the interrupt.
Let's replace all "/" with ":".
--- drivers/gpio/gpiolib-cdev.c | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-)
drivers/gpio/gpiolib-cdev.c +32 -6
@@ -1010,10 +1010,20 @@ static u32 gpio_v2_line_config_debounce_return 0 ; } +static inline char *make_irq_label (const char *orig) +{ +return kstrdup_and_replace (orig,'/' ,':' ,GFP_KERNEL ); +} + +static inline void free_irq_label (const char *label) +{ +kfree (label); +} +static void edge_detector_stop (struct line *line) {if (line->irq) { -free_irq (line->irq, line); +free_irq_label (free_irq (line->irq, line)); line->irq =0 ; }
@@ -1038,6 +1048,7 @@ static int edge_detector_setup(struct liunsigned long irqflags =0 ;u64 eflags;int irq, ret; +char *label; eflags = edflags &GPIO_V2_LINE_EDGE_FLAGS ;if (eflags && !kfifo_initialized (&line->req->events)) {
@@ -1074,11 +1085,17 @@ static int edge_detector_setup(struct li IRQF_TRIGGER_RISING :IRQF_TRIGGER_FALLING ; irqflags |=IRQF_ONESHOT ; + label =make_irq_label (line->req->label); +if (!label) +return -ENOMEM ; +/* Request a thread to read the events */ ret =request_threaded_irq (irq, edge_irq_handler, edge_irq_thread, - irqflags, line->req->label, line); -if (ret) + irqflags, label, line); +if (ret) { +free_irq_label (label);return ret; + } line->irq = irq;return 0 ;
@@ -1943,7 +1960,7 @@ static void lineevent_free(struct lineevblocking_notifier_chain_unregister (&le->gdev->device_notifier, &le->device_unregistered_nb);if (le->irq) -free_irq (le->irq, le); +free_irq_label (free_irq (le->irq, le));if (le->desc)gpiod_free (le->desc);kfree (le->label);
@@ -2091,6 +2108,7 @@ static int lineevent_create(struct gpio_int fd;int ret;int irq, irqflags =0 ; +char *label;if (copy_from_user (&eventreq, ip,sizeof (eventreq)))return -EFAULT ;
@@ -2175,15 +2193,23 @@ static int lineevent_create(struct gpio_if (ret) goto out_free_le; + label =make_irq_label (le->label); +if (!label) { + ret = -ENOMEM ; + goto out_free_le; + } +/* Request a thread to read the events */ ret =request_threaded_irq (irq, lineevent_irq_handler, lineevent_irq_thread, irqflags, - le->label, + label, le); -if (ret) +if (ret) { +free_irq_label (label); goto out_free_le; + } le->irq = irq;
Greg Kroah-Hartman
maintainerPATCH 352/432 exec: Fix NOMMU linux_binprm::exec in transfer_args_to_stack()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Max Filippov <[email protected]>
commit 2aea94ac14d1e0a8ae9e34febebe208213ba72f7 upstream.
In NOMMU kernel the value of linux_binprm::p is the offset inside the temporary program arguments array maintained in separate pages in the linux_binprm::page. linux_binprm::exec being a copy of linux_binprm::p thus must be adjusted when that array is copied to the user stack. Without that adjustment the value passed by the NOMMU kernel to the ELF program in the AT_EXECFN entry of the aux array doesn't make any sense and it may break programs that try to access memory pointed to by that entry.
Adjust linux_binprm::exec before the successful return from the transfer_args_to_stack().
--- fs/exec.c | 1 + 1 file changed, 1 insertion(+)
fs/exec.c +1 -0
@@ -894,6 +894,7 @@ int transfer_args_to_stack(struct linux_ goto out; } + bprm->exec += *sp_location -MAX_ARG_PAGES *PAGE_SIZE ; *sp_location = sp; out:
Greg Kroah-Hartman
maintainerPATCH 353/432 hexagon: vmlinux.lds.S: handle attributes section
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
commit 549aa9678a0b3981d4821bf244579d9937650562 upstream.
After the linked LLVM change, the build fails with CONFIG_LD_ORPHAN_WARN_LEVEL="error", which happens with allmodconfig:
ld.lld: error: vmlinux.a(init/main.o):(.hexagon.attributes) is being placed in '.hexagon.attributes'
Handle the attributes section in a similar manner as arm and riscv by adding it after the primary ELF_DETAILS grouping in vmlinux.lds.S, which fixes the error.
--- arch/hexagon/kernel/vmlinux.lds.S | 1 + 1 file changed, 1 insertion(+)
arch/hexagon/kernel/vmlinux.lds.S +1 -0
@@ -63,6 +63,7 @@ SECTIONS STABS_DEBUG DWARF_DEBUG ELF_DETAILS + .hexagon.attributes 0 : { *(.hexagon.attributes) } DISCARDS }
Greg Kroah-Hartman
maintainerPATCH 354/432 mm: cachestat: fix two shmem bugs
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Weiner <[email protected]>
commit d5d39c707a4cf0bcc84680178677b97aa2cb2627 upstream.
When cachestat on shmem races with swapping and invalidation, there are two possible bugs:
1) A swapin error can have resulted in a poisoned swap entry in the shmem inode's xarray. Calling get_shadow_from_swap_cache() on it will result in an out-of-bounds access to swapper_spaces[].
Validate the entry with non_swap_entry() before going further.
2) When we find a valid swap entry in the shmem's inode, the shadow entry in the swapcache might not exist yet: swap IO is still in progress and we're before __remove_mapping; swapin, invalidation, or swapoff have removed the shadow from swapcache after we saw the shmem swap entry.
This will send a NULL to workingset_test_recent(). The latter purely operates on pointer bits, so it won't crash - node 0, memcg ID 0, eviction timestamp 0, etc. are all valid inputs - but it's a bogus test. In theory that could result in a false "recently evicted" count.
Such a false positive wouldn't be the end of the world. But for code clarity and (future) robustness, be explicit about this case.
Bail on get_shadow_from_swap_cache() returning NULL.
--- mm/filemap.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
mm/filemap.c +16 -0
@@ -4150,7 +4150,23 @@ static void filemap_cachestat(struct add/* shmem file - in swap cache */ swp_entry_t swp =radix_to_swp_entry (folio); +/* swapin error results in poisoned entry */ +if (non_swap_entry (swp)) + goto resched; + +/* +* Getting a swap entry from the shmem +* inode means we beat +* shmem_unuse(). rcu_read_lock() +* ensures swapoff waits for us before +* freeing the swapper space. However, +* we can race with swapping and +* invalidation, so there might not be +* a shadow in the swapcache (yet). +*/ shadow =get_shadow_from_swap_cache (swp); +if (!shadow) + goto resched; }#endif if (workingset_test_recent (shadow, true, &workingset))
Greg Kroah-Hartman
maintainerPATCH 355/432 selftests/mm: sigbus-wp test requires UFFD_FEATURE_WP_HUGETLBFS_SHMEM
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Edward Liaw <[email protected]>
commit 105840ebd76d8dbc1a7d734748ae320076f3201e upstream.
The sigbus-wp test requires the UFFD_FEATURE_WP_HUGETLBFS_SHMEM flag for shmem and hugetlb targets. Otherwise it is not backwards compatible with kernels <5.19 and fails with EINVAL.
--- tools/testing/selftests/mm/uffd-unit-tests.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/mm/uffd-unit-tests.c +2 -1
@@ -1219,7 +1219,8 @@ uffd_test_case_t uffd_tests[] = { .uffd_fn = uffd_sigbus_wp_test, .mem_targets = MEM_ALL, .uffd_feature_required = UFFD_FEATURE_SIGBUS | - UFFD_FEATURE_EVENT_FORK | UFFD_FEATURE_PAGEFAULT_FLAG_WP, + UFFD_FEATURE_EVENT_FORK | UFFD_FEATURE_PAGEFAULT_FLAG_WP | + UFFD_FEATURE_WP_HUGETLBFS_SHMEM, }, { .name = "events",
Greg Kroah-Hartman
maintainerPATCH 356/432 selftests/mm: fix ARM related issue with fork after pthread_create
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Edward Liaw <[email protected]>
commit 8c864371b2a15a23ce35aa7e2bd241baaad6fbe8 upstream.
Following issue was observed while running the uffd-unit-tests selftest on ARM devices. On x86_64 no issues were detected:
pthread_create followed by fork caused deadlock in certain cases wherein fork required some work to be completed by the created thread. Used synchronization to ensure that created thread's start function has started before invoking fork.
--- tools/testing/selftests/mm/uffd-common.c | 3 +++ tools/testing/selftests/mm/uffd-common.h | 2 ++ tools/testing/selftests/mm/uffd-unit-tests.c | 10 ++++++++++ 3 files changed, 15 insertions(+)
tools/testing/selftests/mm/uffd-common.c +3 -0
@@ -17,6 +17,7 @@ bool map_shared;bool test_uffdio_wp = true;unsigned long long *count_verify;uffd_test_ops_t *uffd_test_ops; +atomic_bool ready_for_fork;static int uffd_mem_fd_create (off_t mem_size,bool hugetlb) {
@@ -507,6 +508,8 @@ void *uffd_poll_thread(void *arg) pollfd[1 ].fd = pipefd[cpu*2 ]; pollfd[1 ].events =POLLIN ; + ready_for_fork = true; +for (;;) { ret =poll (pollfd,2 ,-1 );if (ret <=0 ) {
tools/testing/selftests/mm/uffd-common.h +2 -0
@@ -32,6 +32,7 @@#include <inttypes.h> #include <stdint.h> #include <sys/random.h> +#include <stdatomic.h> #include "../kselftest.h" #include "vm_util.h"
@@ -97,6 +98,7 @@ extern bool map_shared;extern bool test_uffdio_wp;extern unsigned long long *count_verify;extern volatile bool test_uffdio_copy_eexist; +extern atomic_bool ready_for_fork;extern uffd_test_ops_t anon_uffd_test_ops;extern uffd_test_ops_t shmem_uffd_test_ops;
tools/testing/selftests/mm/uffd-unit-tests.c +10 -0
@@ -770,6 +770,8 @@ static void uffd_sigbus_test_common(boolchar c;struct uffd_args args = {0 }; + ready_for_fork = false; +fcntl (uffd,F_SETFL , uffd_flags |O_NONBLOCK ); if (uffd_register(uffd, area_dst, nr_pages * page_size,
@@ -785,6 +787,9 @@ static void uffd_sigbus_test_common(boolif (pthread_create (&uffd_mon,NULL , uffd_poll_thread, &args))err ("uffd_poll_thread create" ); +while (!ready_for_fork) + ;/* Wait for the poll_thread to start executing before forking */ + pid =fork ();if (pid <0 )err ("fork" );
@@ -824,6 +829,8 @@ static void uffd_events_test_common(boolchar c;struct uffd_args args = {0 }; + ready_for_fork = false; +fcntl (uffd,F_SETFL , uffd_flags |O_NONBLOCK );if (uffd_register (uffd, area_dst, nr_pages * page_size, true, wp, false))
@@ -833,6 +840,9 @@ static void uffd_events_test_common(boolif (pthread_create (&uffd_mon,NULL , uffd_poll_thread, &args))err ("uffd_poll_thread create" ); +while (!ready_for_fork) + ;/* Wait for the poll_thread to start executing before forking */ + pid =fork ();if (pid <0 )err ("fork" );
Greg Kroah-Hartman
maintainerPATCH 357/432 mmc: sdhci-omap: re-tuning is needed after a pm transition to support emmc HS200 mode
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Romain Naour <[email protected]>
commit f9e2a5b00a35f2c064dc679808bc8db5cc779ed6 upstream.
"PM runtime functions" was been added in sdhci-omap driver in commit f433e8aac6b9 ("mmc: sdhci-omap: Implement PM runtime functions") along with "card power off and enable aggressive PM" in commit 3edf588e7fe0 ("mmc: sdhci-omap: Allow SDIO card power off and enable aggressive PM").
Since then, the sdhci-omap driver doesn't work using mmc-hs200 mode due to the tuning values being lost during a pm transition.
As for the sdhci_am654 driver, request a new tuning sequence before suspend (sdhci_omap_runtime_suspend()), otherwise the device will trigger cache flush error:
mmc1: cache flush error -110 (ETIMEDOUT)
mmc1: error -110 doing aggressive suspend
followed by I/O errors produced by fdisk -l /dev/mmcblk1boot1:
I/O error, dev mmcblk1boot0, sector 64384 op 0x0:(READ) flags 0x80700 phys_seg 1 prio class 2
I/O error, dev mmcblk1boot1, sector 64384 op 0x0:(READ) flags 0x80700 phys_seg 1 prio class 2
I/O error, dev mmcblk1boot1, sector 64384 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 2
Buffer I/O error on dev mmcblk1boot1, logical block 8048, async page read I/O error, dev mmcblk1boot0, sector 64384 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 2
Buffer I/O error on dev mmcblk1boot0, logical block 8048, async page read
Don't re-tune if auto retuning is supported in HW (when SDHCI_TUNING_MODE_3 is available).
--- drivers/mmc/host/sdhci-omap.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mmc/host/sdhci-omap.c +3 -0
@@ -1439,6 +1439,9 @@ static int __maybe_unused sdhci_omap_runstruct sdhci_pltfm_host *pltfm_host =sdhci_priv (host);struct sdhci_omap_host *omap_host =sdhci_pltfm_priv (pltfm_host); +if (host->tuning_mode !=SDHCI_TUNING_MODE_3 ) +mmc_retune_needed (host->mmc); +if (omap_host->con != -EINVAL )sdhci_runtime_suspend_host (host);
Greg Kroah-Hartman
maintainerPATCH 358/432 mmc: core: Initialize mmc_blk_ioc_data
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikko Rapeli <[email protected]>
commit 0cdfe5b0bf295c0dee97436a8ed13336933a0211 upstream.
Commit 4d0c8d0aef63 ("mmc: core: Use mrq.sbc in close-ended ffu") adds flags uint to struct mmc_blk_ioc_data, but it does not get initialized for RPMB ioctls which now fails.
Let's fix this by always initializing the struct and flags to zero.
--- drivers/mmc/core/block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/core/block.c +1 -1
@@ -413,7 +413,7 @@ static struct mmc_blk_ioc_data *mmc_blk_struct mmc_blk_ioc_data *idata;int err; - idata =kmalloc (sizeof (*idata),GFP_KERNEL ); + idata =kzalloc (sizeof (*idata),GFP_KERNEL );if (!idata) { err = -ENOMEM ; goto out;
Greg Kroah-Hartman
maintainerPATCH 359/432 mmc: core: Avoid negative index with array access
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikko Rapeli <[email protected]>
commit cf55a7acd1ed38afe43bba1c8a0935b51d1dc014 upstream.
Commit 4d0c8d0aef63 ("mmc: core: Use mrq.sbc in close-ended ffu") assigns prev_idata = idatas[i - 1], but doesn't check that the iterator i is greater than zero. Let's fix this by adding a check.
--- drivers/mmc/core/block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/core/block.c +1 -1
@@ -488,7 +488,7 @@ static int __mmc_blk_ioctl_cmd(struct mmif (idata->flags &MMC_BLK_IOC_DROP )return 0 ; -if (idata->flags &MMC_BLK_IOC_SBC ) +if (idata->flags &MMC_BLK_IOC_SBC && i >0 ) prev_idata = idatas[i -1 ];/*
Greg Kroah-Hartman
maintainerPATCH 360/432 sdhci-of-dwcmshc: disable PM runtime in dwcmshc_remove()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liming Sun <[email protected]>
commit 03749309909935070253accab314288d332a204d upstream.
This commit disables PM runtime in dwcmshc_remove() to avoid the error message below when reloading the sdhci-of-dwcmshc.ko
sdhci-dwcmshc MLNXBF30:00: Unbalanced pm_runtime_enable!
--- drivers/mmc/host/sdhci-of-dwcmshc.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-)
drivers/mmc/host/sdhci-of-dwcmshc.c +17 -11
@@ -584,6 +584,17 @@ free_pltfm:return err; } +static void dwcmshc_disable_card_clk (struct sdhci_host *host) +{ +u16 ctrl; + + ctrl =sdhci_readw (host,SDHCI_CLOCK_CONTROL ); +if (ctrl &SDHCI_CLOCK_CARD_EN ) { + ctrl &= ~SDHCI_CLOCK_CARD_EN ; +sdhci_writew (host, ctrl,SDHCI_CLOCK_CONTROL ); + } +} +static void dwcmshc_remove (struct platform_device *pdev) {struct sdhci_host *host =platform_get_drvdata (pdev);
@@ -591,8 +602,14 @@ static void dwcmshc_remove(struct platfostruct dwcmshc_priv *priv =sdhci_pltfm_priv (pltfm_host);struct rk35xx_priv *rk_priv = priv->priv; +pm_runtime_get_sync (&pdev->dev); +pm_runtime_disable (&pdev->dev); +pm_runtime_put_noidle (&pdev->dev); +sdhci_remove_host (host,0 ); +dwcmshc_disable_card_clk (host); +clk_disable_unprepare (pltfm_host->clk);clk_disable_unprepare (priv->bus_clk);if (rk_priv)
@@ -683,17 +700,6 @@ static void dwcmshc_enable_card_clk(strusdhci_writew (host, ctrl,SDHCI_CLOCK_CONTROL ); } } - -static void dwcmshc_disable_card_clk (struct sdhci_host *host) -{ -u16 ctrl; - - ctrl =sdhci_readw (host,SDHCI_CLOCK_CONTROL ); -if (ctrl &SDHCI_CLOCK_CARD_EN ) { - ctrl &= ~SDHCI_CLOCK_CARD_EN ; -sdhci_writew (host, ctrl,SDHCI_CLOCK_CONTROL ); - } -}static int dwcmshc_runtime_suspend (struct device *dev) {
Greg Kroah-Hartman
maintainerPATCH 361/432 block: Do not force full zone append completion in req_bio_endio()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
commit 55251fbdf0146c252ceff146a1bb145546f3e034 upstream.
This reverts commit 748dc0b65ec2b4b7b3dbd7befcc4a54fdcac7988.
Partial zone append completions cannot be supported as there is no guarantees that the fragmented data will be written sequentially in the same manner as with a full command. Commit 748dc0b65ec2 ("block: fix partial zone append completion handling in req_bio_endio()") changed req_bio_endio() to always advance a partially failed BIO by its full length, but this can lead to incorrect accounting. So revert this change and let low level device drivers handle this case by always failing completely zone append operations. With this revert, users will still see an IO error for a partially completed zone append BIO.
--- block/blk-mq.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
block/blk-mq.c +2 -7
@@ -772,16 +772,11 @@ static void req_bio_endio(struct request/* * Partial zone append completions cannot be supported as the * BIO fragments may end up not being written sequentially. -* For such case, force the completed nbytes to be equal to -* the BIO size so that bio_advance() sets the BIO remaining -* size to 0 and we end up calling bio_endio() before returning. */ -if (bio->bi_iter.bi_size != nbytes) { +if (bio->bi_iter.bi_size != nbytes) bio->bi_status =BLK_STS_IOERR ; - nbytes = bio->bi_iter.bi_size; - }else { +else bio->bi_iter.bi_sector = rq->__sector; - } }bio_advance (bio, nbytes);
Greg Kroah-Hartman
maintainerPATCH 362/432 thermal: devfreq_cooling: Fix perf state when calculate dfc res_util
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ye Zhang <[email protected]>
commit a26de34b3c77ae3a969654d94be49e433c947e3b upstream.
The issue occurs when the devfreq cooling device uses the EM power model and the get_real_power() callback is provided by the driver.
The EM power table is sorted ascending,can't index the table by cooling device state,so convert cooling state to performance state by dfc->max_state - dfc->capped_state.
--- drivers/thermal/devfreq_cooling.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/devfreq_cooling.c +1 -1
@@ -201,7 +201,7 @@ static int devfreq_cooling_get_requested res = dfc->power_ops->get_real_power (df, power, freq, voltage);if (!res) { - state = dfc->capped_state; + state = dfc->max_state - dfc->capped_state;/* Convert EM power into milli-Watts first */ dfc->res_util = dfc->em_pd->table[state].power;
Greg Kroah-Hartman
maintainerPATCH 363/432 nouveau/dmem: handle kcalloc() allocation failure
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Duoming Zhou <[email protected]>
commit 16e87fe23d4af6df920406494ced5c0f4354567b upstream.
The kcalloc() in nouveau_dmem_evict_chunk() will return null if the physical memory has run out. As a result, if we dereference src_pfns, dst_pfns or dma_addrs, the null pointer dereference bugs will happen.
Moreover, the GPU is going away. If the kcalloc() fails, we could not evict all pages mapping a chunk. So this patch adds a __GFP_NOFAIL flag in kcalloc().
Finally, as there is no need to have physically contiguous memory, this patch switches kcalloc() to kvcalloc() in order to avoid failing allocations.
--- drivers/gpu/drm/nouveau/nouveau_dmem.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/nouveau/nouveau_dmem.c +6 -6
@@ -378,9 +378,9 @@ nouveau_dmem_evict_chunk(struct nouveau_dma_addr_t *dma_addrs;struct nouveau_fence *fence; - src_pfns =kcalloc (npages,sizeof (*src_pfns),GFP_KERNEL ); - dst_pfns =kcalloc (npages,sizeof (*dst_pfns),GFP_KERNEL ); - dma_addrs =kcalloc (npages,sizeof (*dma_addrs),GFP_KERNEL ); + src_pfns =kvcalloc (npages,sizeof (*src_pfns),GFP_KERNEL | __GFP_NOFAIL); + dst_pfns =kvcalloc (npages,sizeof (*dst_pfns),GFP_KERNEL | __GFP_NOFAIL); + dma_addrs =kvcalloc (npages,sizeof (*dma_addrs),GFP_KERNEL | __GFP_NOFAIL);migrate_device_range (src_pfns, chunk->pagemap.range.start >>PAGE_SHIFT , npages);
@@ -406,11 +406,11 @@ nouveau_dmem_evict_chunk(struct nouveau_migrate_device_pages (src_pfns, dst_pfns, npages);nouveau_dmem_fence_done (&fence);migrate_device_finalize (src_pfns, dst_pfns, npages); -kfree (src_pfns); -kfree (dst_pfns); +kvfree (src_pfns); +kvfree (dst_pfns);for (i =0 ; i < npages; i++)dma_unmap_page (chunk->drm->dev->dev, dma_addrs[i],PAGE_SIZE ,DMA_BIDIRECTIONAL ); -kfree (dma_addrs); +kvfree (dma_addrs); }void
Greg Kroah-Hartman
maintainerPATCH 364/432 net: ll_temac: platform_get_resource replaced by wrong function
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claus Hansen Ries <[email protected]>
commit 3a38a829c8bc27d78552c28e582eb1d885d07d11 upstream.
The function platform_get_resource was replaced with devm_platform_ioremap_resource_byname and is called using 0 as name.
This eventually ends up in platform_get_resource_byname in the call stack, where it causes a null pointer in strcmp.
if (type == resource_type(r) && !strcmp(r->name, name))
It should have been replaced with devm_platform_ioremap_resource.
--- drivers/net/ethernet/xilinx/ll_temac_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/xilinx/ll_temac_main.c +1 -1
@@ -1443,7 +1443,7 @@ static int temac_probe(struct platform_d }/* map device registers */ - lp->regs =devm_platform_ioremap_resource_byname (pdev,0 ); + lp->regs =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (lp->regs)) {dev_err (&pdev->dev,"could not map TEMAC registers\n" );return -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 365/432 drm/vmwgfx: Create debugfs ttm_resource_manager entry only if needed
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jocelyn Falempe <[email protected]>
commit 4be9075fec0a639384ed19975634b662bfab938f upstream.
The driver creates /sys/kernel/debug/dri/0/mob_ttm even when the corresponding ttm_resource_manager is not allocated. This leads to a crash when trying to read from this file.
Add a check to create mob_ttm, system_mob_ttm, and gmr_ttm debug file only when the corresponding ttm_resource_manager is allocated.
crash> bt
PID: 3133409 TASK: ffff8fe4834a5000 CPU: 3 COMMAND: "grep"
#0 [ffffb954506b3b20] machine_kexec at ffffffffb2a6bec3 #1 [ffffb954506b3b78] __crash_kexec at ffffffffb2bb598a #2 [ffffb954506b3c38] crash_kexec at ffffffffb2bb68c1 #3 [ffffb954506b3c50] oops_end at ffffffffb2a2a9b1
#4 [ffffb954506b3c70] no_context at ffffffffb2a7e913 #5 [ffffb954506b3cc8] __bad_area_nosemaphore at ffffffffb2a7ec8c #6 [ffffb954506b3d10] do_page_fault at ffffffffb2a7f887 #7 [ffffb954506b3d40] page_fault at ffffffffb360116e
[exception RIP: ttm_resource_manager_debug+0x11]
RIP: ffffffffc04afd11 RSP: ffffb954506b3df0 RFLAGS: 00010246
RAX: ffff8fe41a6d1200 RBX: 0000000000000000 RCX: 0000000000000940
RDX: 0000000000000000 RSI: ffffffffc04b4338 RDI: 0000000000000000
RBP: ffffb954506b3e08 R8: ffff8fee3ffad000 R9: 0000000000000000
R10: ffff8fe41a76a000 R11: 0000000000000001 R12: 00000000ffffffff
R13: 0000000000000001 R14: ffff8fe5bb6f3900 R15: ffff8fe41a6d1200
ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018
#8 [ffffb954506b3e00] ttm_resource_manager_show at ffffffffc04afde7 [ttm]
#9 [ffffb954506b3e30] seq_read at ffffffffb2d8f9f3
RIP: 00007f4c4eda8985 RSP: 00007ffdbba9e9f8 RFLAGS: 00000246
RAX: ffffffffffffffda RBX: 000000000037e000 RCX: 00007f4c4eda8985
RDX: 000000000037e000 RSI: 00007f4c41573000 RDI: 0000000000000003
RBP: 000000000037e000 R8: 0000000000000000 R9: 000000000037fe30
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f4c41573000
R13: 0000000000000003 R14: 00007f4c41572010 R15: 0000000000000003
ORIG_RAX: 0000000000000000 CS: 0033 SS: 002b--- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +9 -6
@@ -1444,12 +1444,15 @@ static void vmw_debugfs_resource_manager root, "system_ttm");ttm_resource_manager_create_debugfs (ttm_manager_type (&vmw->bdev,TTM_PL_VRAM ), root,"vram_ttm" ); -ttm_resource_manager_create_debugfs (ttm_manager_type (&vmw->bdev,VMW_PL_GMR ), - root,"gmr_ttm" ); -ttm_resource_manager_create_debugfs (ttm_manager_type (&vmw->bdev,VMW_PL_MOB ), - root,"mob_ttm" ); -ttm_resource_manager_create_debugfs (ttm_manager_type (&vmw->bdev,VMW_PL_SYSTEM ), - root,"system_mob_ttm" ); +if (vmw->has_gmr) +ttm_resource_manager_create_debugfs (ttm_manager_type (&vmw->bdev,VMW_PL_GMR ), + root,"gmr_ttm" ); +if (vmw->has_mob) { +ttm_resource_manager_create_debugfs (ttm_manager_type (&vmw->bdev,VMW_PL_MOB ), + root,"mob_ttm" ); +ttm_resource_manager_create_debugfs (ttm_manager_type (&vmw->bdev,VMW_PL_SYSTEM ), + root,"system_mob_ttm" ); + } } static int vmwgfx_pm_notifier(struct notifier_block *nb, unsigned long val,
Greg Kroah-Hartman
maintainerPATCH 366/432 drm/amdkfd: fix TLB flush after unmap for GFX9.4.2
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Huang <[email protected]>
commit 1210e2f1033dc56b666c9f6dfb761a2d3f9f5d6c upstream.
TLB flush after unmap accidentially was removed on gfx9.4.2. It is to add it back.
--- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +1 -1
@@ -1466,7 +1466,7 @@ void kfd_flush_tlb(struct kfd_process_destatic inline bool kfd_flush_tlb_after_unmap (struct kfd_dev *dev) { -return KFD_GC_VERSION (dev) >IP_VERSION (9 ,4 ,2 ) || +return KFD_GC_VERSION (dev) >=IP_VERSION (9 ,4 ,2 ) || (KFD_GC_VERSION (dev) ==IP_VERSION (9 ,4 ,1 ) && dev->sdma_fw_version >=18 ) ||KFD_GC_VERSION (dev) ==IP_VERSION (9 ,4 ,0 ); }
Greg Kroah-Hartman
maintainerPATCH 367/432 drm/amdgpu: fix deadlock while reading mqd from debugfs
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Weiner <[email protected]>
commit 8678b1060ae2b75feb60b87e5b75e17374e3c1c5 upstream.
An errant disk backup on my desktop got into debugfs and triggered the following deadlock scenario in the amdgpu debugfs files. The machine also hard-resets immediately after those lines are printed (although I wasn't able to reproduce that part when reading by hand):
[ 1318.016074][ T1082] ======================================================
[ 1318.016607][ T1082] WARNING: possible circular locking dependency detected
[ 1318.017107][ T1082] 6.8.0-rc7-00015-ge0c8221b72c0 #17 Not tainted
[ 1318.017598][ T1082] ------------------------------------------------------
[ 1318.018096][ T1082] tar/1082 is trying to acquire lock:
[ 1318.018585][ T1082] ffff98c44175d6a0 (&mm->mmap_lock){++++}-{3:3}, at: __might_fault+0x40/0x80
[ 1318.019084][ T1082]
[ 1318.019084][ T1082] but task is already holding lock:
[ 1318.020052][ T1082] ffff98c4c13f55f8 (reservation_ww_class_mutex){+.+.}-{3:3}, at: amdgpu_debugfs_mqd_read+0x6a/0x250 [amdgpu]
[ 1318.020607][ T1082]
[ 1318.020607][ T1082] which lock already depends on the new lock.
[ 1318.020607][ T1082]
[ 1318.022081][ T1082]
[ 1318.022081][ T1082] the existing dependency chain (in reverse order) is:
[ 1318.023083][ T1082]
[ 1318.023083][ T1082] -> #2 (reservation_ww_class_mutex){+.+.}-{3:3}:
[ 1318.024114][ T1082] __ww_mutex_lock.constprop.0+0xe0/0x12f0
[ 1318.024639][ T1082] ww_mutex_lock+0x32/0x90
[ 1318.025161][ T1082] dma_resv_lockdep+0x18a/0x330
[ 1318.025683][ T1082] do_one_initcall+0x6a/0x350
[ 1318.026210][ T1082] kernel_init_freeable+0x1a3/0x310
[ 1318.026728][ T1082] kernel_init+0x15/0x1a0
[ 1318.027242][ T1082] ret_from_fork+0x2c/0x40
[ 1318.027759][ T1082] ret_from_fork_asm+0x11/0x20
[ 1318.028281][ T1082]
[ 1318.028281][ T1082] -> #1 (reservation_ww_class_acquire){+.+.}-{0:0}:
[ 1318.029297][ T1082] dma_resv_lockdep+0x16c/0x330
[ 1318.029790][ T1082] do_one_initcall+0x6a/0x350
[ 1318.030263][ T1082] kernel_init_freeable+0x1a3/0x310
[ 1318.030722][ T1082] kernel_init+0x15/0x1a0
[ 1318.031168][ T1082] ret_from_fork+0x2c/0x40
[ 1318.031598][ T1082] ret_from_fork_asm+0x11/0x20
[ 1318.032011][ T1082]
[ 1318.032011][ T1082] -> #0 (&mm->mmap_lock){++++}-{3:3}:
[ 1318.032778][ T1082] __lock_acquire+0x14bf/0x2680
[ 1318.033141][ T1082] lock_acquire+0xcd/0x2c0
[ 1318.033487][ T1082] __might_fault+0x58/0x80
[ 1318.033814][ T1082] amdgpu_debugfs_mqd_read+0x103/0x250 [amdgpu]
[ 1318.034181][ T1082] full_proxy_read+0x55/0x80
[ 1318.034487][ T1082] vfs_read+0xa7/0x360
[ 1318.034788][ T1082] ksys_read+0x70/0xf0
[ 1318.035085][ T1082] do_syscall_64+0x94/0x180
[ 1318.035375][ T1082] entry_SYSCALL_64_after_hwframe+0x46/0x4e
[ 1318.035664][ T1082]
[ 1318.035664][ T1082] other info that might help us debug this:
[ 1318.035664][ T1082]
[ 1318.036487][ T1082] Chain exists of:
[ 1318.036487][ T1082] &mm->mmap_lock --> reservation_ww_class_acquire --> reservation_ww_class_mutex
[ 1318.036487][ T1082]
[ 1318.037310][ T1082] Possible unsafe locking scenario:
[ 1318.037310][ T1082]
[ 1318.037838][ T1082] CPU0 CPU1
[ 1318.038101][ T1082] ---- ----
[ 1318.038350][ T1082] lock(reservation_ww_class_mutex);
[ 1318.038590][ T1082] lock(reservation_ww_class_acquire);
[ 1318.038839][ T1082] lock(reservation_ww_class_mutex);
[ 1318.039083][ T1082] rlock(&mm->mmap_lock);
[ 1318.039328][ T1082]
[ 1318.039328][ T1082] *** DEADLOCK ***
[ 1318.039328][ T1082]
[ 1318.040029][ T1082] 1 lock held by tar/1082:
[ 1318.040259][ T1082] #0: ffff98c4c13f55f8 (reservation_ww_class_mutex){+.+.}-{3:3}, at: amdgpu_debugfs_mqd_read+0x6a/0x250 [amdgpu]
[ 1318.040560][ T1082]
[ 1318.040560][ T1082] stack backtrace:
[ 1318.041053][ T1082] CPU: 22 PID: 1082 Comm: tar Not tainted 6.8.0-rc7-00015-ge0c8221b72c0 #17 3316c85d50e282c5643b075d1f01a4f6365e39c2
[ 1318.041329][ T1082] Hardware name: Gigabyte Technology Co., Ltd. B650 AORUS PRO AX/B650 AORUS PRO AX, BIOS F20 12/14/2023
[ 1318.041614][ T1082] Call Trace:
[ 1318.041895][ T1082] <TASK>
[ 1318.042175][ T1082] dump_stack_lvl+0x4a/0x80
[ 1318.042460][ T1082] check_noncircular+0x145/0x160
[ 1318.042743][ T1082] __lock_acquire+0x14bf/0x2680
[ 1318.043022][ T1082] lock_acquire+0xcd/0x2c0
[ 1318.043301][ T1082] ? __might_fault+0x40/0x80
[ 1318.043580][ T1082] ? __might_fault+0x40/0x80
[ 1318.043856][ T1082] __might_fault+0x58/0x80
[ 1318.044131][ T1082] ? __might_fault+0x40/0x80
[ 1318.044408][ T1082] amdgpu_debugfs_mqd_read+0x103/0x250 [amdgpu 8fe2afaa910cbd7654c8cab23563a94d6caebaab]
[ 1318.044749][ T1082] full_proxy_read+0x55/0x80
[ 1318.045042][ T1082] vfs_read+0xa7/0x360
[ 1318.045333][ T1082] ksys_read+0x70/0xf0
[ 1318.045623][ T1082] do_syscall_64+0x94/0x180
[ 1318.045913][ T1082] ? do_syscall_64+0xa0/0x180
[ 1318.046201][ T1082] ? lockdep_hardirqs_on+0x7d/0x100
[ 1318.046487][ T1082] ? do_syscall_64+0xa0/0x180
[ 1318.046773][ T1082] ? do_syscall_64+0xa0/0x180
[ 1318.047057][ T1082] ? do_syscall_64+0xa0/0x180
[ 1318.047337][ T1082] ? do_syscall_64+0xa0/0x180
[ 1318.047611][ T1082] entry_SYSCALL_64_after_hwframe+0x46/0x4e
[ 1318.047887][ T1082] RIP: 0033:0x7f480b70a39d
[ 1318.048162][ T1082] Code: 91 ba 0d 00 f7 d8 64 89 02 b8 ff ff ff ff eb b2 e8 18 a3 01 00 0f 1f 84 00 00 00 00 00 80 3d a9 3c 0e 00 00 74 17 31 c0 0f 05 <48> 3d 00 f0 ff ff 77 5b c3 66 2e 0f 1f 84 00 00 00 00 00 53 48 83
[ 1318.048769][ T1082] RSP: 002b:00007ffde77f5c68 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
[ 1318.049083][ T1082] RAX: ffffffffffffffda RBX: 0000000000000800 RCX: 00007f480b70a39d
[ 1318.049392][ T1082] RDX: 0000000000000800 RSI: 000055c9f2120c00 RDI: 0000000000000008
[ 1318.049703][ T1082] RBP: 0000000000000800 R08: 000055c9f2120a94 R09: 0000000000000007
[ 1318.050011][ T1082] R10: 0000000000000000 R11: 0000000000000246 R12: 000055c9f2120c00
[ 1318.050324][ T1082] R13: 0000000000000008 R14: 0000000000000008 R15: 0000000000000800
[ 1318.050638][ T1082] </TASK>amdgpu_debugfs_mqd_read() holds a reservation when it calls put_user(), which may fault and acquire the mmap_sem. This violates the established locking order.
Bounce the mqd data through a kernel buffer to get put_user() out of the illegal section.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 46 +++++++++++++++++++------------ 1 file changed, 29 insertions(+), 17 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +29 -17
@@ -524,46 +524,58 @@ static ssize_t amdgpu_debugfs_mqd_read(s {struct amdgpu_ring *ring =file_inode (f)->i_private;volatile u32 *mqd; -int r; +u32 *kbuf; +int r, i;uint32_t value, result;if (*pos &3 || size &3 )return -EINVAL ; - result =0 ; + kbuf =kmalloc (ring->mqd_size,GFP_KERNEL ); +if (!kbuf) +return -ENOMEM ; r =amdgpu_bo_reserve (ring->mqd_obj, false);if (unlikely (r !=0 )) -return r; + goto err_free; r =amdgpu_bo_kmap (ring->mqd_obj, (void **)&mqd); -if (r) { -amdgpu_bo_unreserve (ring->mqd_obj); -return r; - } +if (r) + goto err_unreserve; + +/* +* Copy to local buffer to avoid put_user(), which might fault +* and acquire mmap_sem, under reservation_ww_class_mutex. +*/ +for (i =0 ; i < ring->mqd_size/sizeof (u32); i++) + kbuf[i] = mqd[i]; + +amdgpu_bo_kunmap (ring->mqd_obj); +amdgpu_bo_unreserve (ring->mqd_obj); + result =0 ;while (size) {if (*pos >= ring->mqd_size) - goto done; +break ; - value = mqd[*pos/4 ]; + value = kbuf[*pos/4 ]; r =put_user (value, (uint32_t *)buf);if (r) - goto done; + goto err_free; buf +=4 ; result +=4 ; size -=4 ; *pos +=4 ; } -done: -amdgpu_bo_kunmap (ring->mqd_obj); - mqd =NULL ; -amdgpu_bo_unreserve (ring->mqd_obj); -if (r) -return r; - +kfree (kbuf);return result; + +err_unreserve: +amdgpu_bo_unreserve (ring->mqd_obj); +err_free: +kfree (kbuf); +return r; }static const struct file_operations amdgpu_debugfs_mqd_fops = {
Greg Kroah-Hartman
maintainerPATCH 368/432 drm/amd/display: Remove MPC rate control logic from DCN30 and above
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: George Shen <[email protected]>
commit edfa93d87fc46913868481fe8ed3fb62c891ffb5 upstream.
[Why]
MPC flow rate control is not needed for DCN30 and above. Current logic that uses it can result in underflow for certain edge cases (such as DSC N422 + ODM combine + 422 left edge pixel).
[How]
Remove MPC flow rate control logic and programming for DCN30 and above.
--- drivers/gpu/drm/amd/display/dc/dcn30/dcn30_mpc.c | 54 ++++++++------ drivers/gpu/drm/amd/display/dc/dcn30/dcn30_mpc.h | 14 +-- drivers/gpu/drm/amd/display/dc/dcn32/dcn32_mpc.c | 5 - drivers/gpu/drm/amd/display/dc/hwss/dcn314/dcn314_hwseq.c | 41 ---------- drivers/gpu/drm/amd/display/dc/hwss/dcn32/dcn32_hwseq.c | 41 ---------- drivers/gpu/drm/amd/display/dc/hwss/dcn35/dcn35_hwseq.c | 41 ---------- 6 files changed, 41 insertions(+), 155 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_mpc.c +32 -22
@@ -44,6 +44,36 @@#define NUM_ELEMENTS (a) (sizeof(a) / sizeof((a)[0])) +void mpc3_mpc_init (struct mpc *mpc) +{ +struct dcn30_mpc *mpc30 =TO_DCN30_MPC (mpc); +int opp_id; + +mpc1_mpc_init (mpc); + +for (opp_id =0 ; opp_id <MAX_OPP ; opp_id++) { +if (REG (MUX [opp_id])) +/* disable mpc out rate and flow control */ +REG_UPDATE_2 (MUX [opp_id],MPC_OUT_RATE_CONTROL_DISABLE , +1 ,MPC_OUT_FLOW_CONTROL_COUNT ,0 ); + } +} + +void mpc3_mpc_init_single_inst (struct mpc *mpc,unsigned int mpcc_id) +{ +struct dcn30_mpc *mpc30 =TO_DCN30_MPC (mpc); + +mpc1_mpc_init_single_inst (mpc, mpcc_id); + +/* assuming mpc out mux is connected to opp with the same index at this +* point in time (e.g. transitioning from vbios to driver) +*/ +if (mpcc_id <MAX_OPP &® (MUX [mpcc_id])) +/* disable mpc out rate and flow control */ +REG_UPDATE_2 (MUX [mpcc_id],MPC_OUT_RATE_CONTROL_DISABLE , +1 ,MPC_OUT_FLOW_CONTROL_COUNT ,0 ); +} +bool mpc3_is_dwb_idle (struct mpc *mpc,int dwb_id)
@@ -80,25 +110,6 @@ void mpc3_disable_dwb_mux( MPC_DWB0_MUX, 0xf); } -void mpc3_set_out_rate_control ( -struct mpc *mpc, -int opp_id, -bool enable, -bool rate_2x_mode, -struct mpc_dwb_flow_control *flow_control) -{ -struct dcn30_mpc *mpc30 =TO_DCN30_MPC (mpc); - -REG_UPDATE_2 (MUX [opp_id], -MPC_OUT_RATE_CONTROL_DISABLE , !enable, -MPC_OUT_RATE_CONTROL , rate_2x_mode); - -if (flow_control) -REG_UPDATE_2 (MUX [opp_id], -MPC_OUT_FLOW_CONTROL_MODE , flow_control->flow_ctrl_mode, -MPC_OUT_FLOW_CONTROL_COUNT , flow_control->flow_ctrl_cnt1); -} -enum dc_lut_mode mpc3_get_ogam_current (struct mpc *mpc,int mpcc_id) {/*Contrary to DCN2 and DCN1 wherein a single status register field holds this info;
@@ -1386,8 +1397,8 @@ static const struct mpc_funcs dcn30_mpc_ .read_mpcc_state = mpc1_read_mpcc_state, .insert_plane = mpc1_insert_plane, .remove_mpcc = mpc1_remove_mpcc, - .mpc_init = mpc1_mpc_init, - .mpc_init_single_inst = mpc1_mpc_init_single_inst, + .mpc_init = mpc3_mpc_init, + .mpc_init_single_inst = mpc3_mpc_init_single_inst, .update_blending = mpc2_update_blending, .cursor_lock = mpc1_cursor_lock, .get_mpcc_for_dpp = mpc1_get_mpcc_for_dpp,
@@ -1404,7 +1415,6 @@ static const struct mpc_funcs dcn30_mpc_ .set_dwb_mux = mpc3_set_dwb_mux, .disable_dwb_mux = mpc3_disable_dwb_mux, .is_dwb_idle = mpc3_is_dwb_idle, - .set_out_rate_control = mpc3_set_out_rate_control, .set_gamut_remap = mpc3_set_gamut_remap, .program_shaper = mpc3_program_shaper, .acquire_rmu = mpcc3_acquire_rmu,
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_mpc.h +7 -7
@@ -1007,6 +1007,13 @@ void dcn30_mpc_construct(struct dcn30_mpint num_mpcc, int num_rmu); +void mpc3_mpc_init ( +struct mpc *mpc); + +void mpc3_mpc_init_single_inst ( +struct mpc *mpc, +unsigned int mpcc_id); + bool mpc3_program_shaper( struct mpc *mpc, const struct pwl_params *params,
@@ -1074,13 +1081,6 @@ bool mpc3_is_dwb_idle(struct mpc *mpc, int dwb_id); -void mpc3_set_out_rate_control ( -struct mpc *mpc, -int opp_id, -bool enable, -bool rate_2x_mode, -struct mpc_dwb_flow_control *flow_control); -void mpc3_power_on_ogam_lut (struct mpc *mpc,int mpcc_id,bool power_on);
drivers/gpu/drm/amd/display/dc/dcn32/dcn32_mpc.c +2 -3
@@ -47,7 +47,7 @@ void mpc32_mpc_init(struct mpc *mpc)struct dcn30_mpc *mpc30 =TO_DCN30_MPC (mpc);int mpcc_id; -mpc1_mpc_init (mpc); +mpc3_mpc_init (mpc);if (mpc->ctx->dc->debug.enable_mem_low_power.bits.mpc) {if (mpc30->mpc_mask->MPCC_MCM_SHAPER_MEM_LOW_PWR_MODE && mpc30->mpc_mask->MPCC_MCM_3DLUT_MEM_LOW_PWR_MODE) {
@@ -990,7 +990,7 @@ static const struct mpc_funcs dcn32_mpc_ .insert_plane = mpc1_insert_plane, .remove_mpcc = mpc1_remove_mpcc, .mpc_init = mpc32_mpc_init, - .mpc_init_single_inst = mpc1_mpc_init_single_inst, + .mpc_init_single_inst = mpc3_mpc_init_single_inst, .update_blending = mpc2_update_blending, .cursor_lock = mpc1_cursor_lock, .get_mpcc_for_dpp = mpc1_get_mpcc_for_dpp,
@@ -1007,7 +1007,6 @@ static const struct mpc_funcs dcn32_mpc_ .set_dwb_mux = mpc3_set_dwb_mux, .disable_dwb_mux = mpc3_disable_dwb_mux, .is_dwb_idle = mpc3_is_dwb_idle, - .set_out_rate_control = mpc3_set_out_rate_control, .set_gamut_remap = mpc3_set_gamut_remap, .program_shaper = mpc32_program_shaper, .program_3dlut = mpc32_program_3dlut,
drivers/gpu/drm/amd/display/dc/hwss/dcn314/dcn314_hwseq.c +0 -41
59 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/hwss/dcn32/dcn32_hwseq.c +0 -41
59 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/hwss/dcn35/dcn35_hwseq.c +0 -41
59 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 369/432 drm/amd/display: Set DCN351 BB and IP the same as DCN35
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xi Liu <[email protected]>
commit 0ccc2b30f4feadc0b1a282dbcc06e396382e5d74 upstream.
[WHY & HOW]
DCN351 and DCN35 should use the same bounding box and IP settings.
--- drivers/gpu/drm/amd/display/dc/dml2/dml2_translation_helper.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/gpu/drm/amd/display/dc/dml2/dml2_translation_helper.c +1 -5
@@ -228,17 +228,13 @@ void dml2_init_socbb_params(struct dml2_break ;case dml_project_dcn35: +case dml_project_dcn351: out->num_chans =4 ; out->round_trip_ping_latency_dcfclk_cycles =106 ; out->smn_latency_us =2 ; out->dispclk_dppclk_vco_speed_mhz =3600 ;break ; -case dml_project_dcn351: - out->num_chans =16 ; - out->round_trip_ping_latency_dcfclk_cycles =1100 ; - out->smn_latency_us =2 ; -break ; }/* ---Overrides if available--- */ if (dml2->config.bbox_overrides.dram_num_chan)
Greg Kroah-Hartman
maintainerPATCH 370/432 drm/i915/hwmon: Fix locking inversion in sysfs getter
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Janusz Krzysztofik <[email protected]>
commit b212b79768ccde74429f872c37618c543fa11333 upstream.
In i915 hwmon sysfs getter path we now take a hwmon_lock, then acquire an rpm wakeref. That results in lock inversion:
<4> [197.079335] ======================================================
<4> [197.085473] WARNING: possible circular locking dependency detected
<4> [197.091611] 6.8.0-rc7-Patchwork_129026v7-gc4dc92fb1152+ #1 Not tainted
<4> [197.098096] ------------------------------------------------------
<4> [197.104231] prometheus-node/839 is trying to acquire lock:
<4> [197.109680] ffffffff82764d80 (fs_reclaim){+.+.}-{0:0}, at: __kmalloc+0x9a/0x350 <4> [197.116939]
but task is already holding lock:
<4> [197.122730] ffff88811b772a40 (&hwmon->hwmon_lock){+.+.}-{3:3}, at: hwm_energy+0x4b/0x100 [i915] <4> [197.131543]
which lock already depends on the new lock.
...
<4> [197.507922] Chain exists of:
fs_reclaim --> >->reset.mutex --> &hwmon->hwmon_lock
<4> [197.518528] Possible unsafe locking scenario:
<4> [197.524411] CPU0 CPU1 <4> [197.528916] ---- ----
<4> [197.533418] lock(&hwmon->hwmon_lock);
<4> [197.537237] lock(>->reset.mutex);
<4> [197.543376] lock(&hwmon->hwmon_lock);
<4> [197.549682] lock(fs_reclaim);
...
<4> [197.632548] Call Trace:
<4> [197.634990] <TASK> <4> [197.637088] dump_stack_lvl+0x64/0xb0 <4> [197.640738] check_noncircular+0x15e/0x180 <4> [197.652968] check_prev_add+0xe9/0xce0 <4> [197.656705] __lock_acquire+0x179f/0x2300 <4> [197.660694] lock_acquire+0xd8/0x2d0 <4> [197.673009] fs_reclaim_acquire+0xa1/0xd0 <4> [197.680478] __kmalloc+0x9a/0x350 <4> [197.689063] acpi_ns_internalize_name.part.0+0x4a/0xb0 <4> [197.694170] acpi_ns_get_node_unlocked+0x60/0xf0 <4> [197.720608] acpi_ns_get_node+0x3b/0x60 <4> [197.724428] acpi_get_handle+0x57/0xb0 <4> [197.728164] acpi_has_method+0x20/0x50 <4> [197.731896] acpi_pci_set_power_state+0x43/0x120 <4> [197.736485] pci_power_up+0x24/0x1c0 <4> [197.740047] pci_pm_default_resume_early+0x9/0x30 <4> [197.744725] pci_pm_runtime_resume+0x2d/0x90 <4> [197.753911] __rpm_callback+0x3c/0x110 <4> [197.762586] rpm_callback+0x58/0x70 <4> [197.766064] rpm_resume+0x51e/0x730 <4> [197.769542] rpm_resume+0x267/0x730 <4> [197.773020] rpm_resume+0x267/0x730 <4> [197.776498] rpm_resume+0x267/0x730 <4> [197.779974] __pm_runtime_resume+0x49/0x90 <4> [197.784055] __intel_runtime_pm_get+0x19/0xa0 [i915] <4> [197.789070] hwm_energy+0x55/0x100 [i915] <4> [197.793183] hwm_read+0x9a/0x310 [i915] <4> [197.797124] hwmon_attr_show+0x36/0x120 <4> [197.800946] dev_attr_show+0x15/0x60 <4> [197.804509] sysfs_kf_seq_show+0xb5/0x100
Acquire the wakeref before the lock and hold it as long as the lock is also held. Follow that pattern across the whole source file where similar lock inversion can happen.
v2: Keep hardware read under the lock so the whole operation of updating
energy from hardware is still atomic (Guenter),
- instead, acquire the rpm wakeref before the lock and hold it as long as the lock is held,
- use the same aproach for other similar places across the i915_hwmon.c source file (Rodrigo).
--- drivers/gpu/drm/i915/i915_hwmon.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-)
drivers/gpu/drm/i915/i915_hwmon.c +19 -18
@@ -72,12 +72,13 @@ hwm_locked_with_pm_intel_uncore_rmw(strustruct intel_uncore *uncore = ddat->uncore;intel_wakeref_t wakeref; -mutex_lock (&hwmon->hwmon_lock); + with_intel_runtime_pm(uncore->rpm, wakeref) { +mutex_lock (&hwmon->hwmon_lock); - with_intel_runtime_pm(uncore->rpm, wakeref)intel_uncore_rmw (uncore, reg, clear, set); -mutex_unlock (&hwmon->hwmon_lock); +mutex_unlock (&hwmon->hwmon_lock); + } }/*
@@ -136,20 +137,21 @@ hwm_energy(struct hwm_drvdata *ddat, lonelse rgaddr = hwmon->rg.energy_status_all; -mutex_lock (&hwmon->hwmon_lock); + with_intel_runtime_pm(uncore->rpm, wakeref) { +mutex_lock (&hwmon->hwmon_lock); -with_intel_runtime_pm (uncore->rpm, wakeref) reg_val =intel_uncore_read (uncore, rgaddr); -if (reg_val >= ei->reg_val_prev) - ei->accum_energy += reg_val - ei->reg_val_prev; -else - ei->accum_energy +=UINT_MAX - ei->reg_val_prev + reg_val; - ei->reg_val_prev = reg_val; +if (reg_val >= ei->reg_val_prev) + ei->accum_energy += reg_val - ei->reg_val_prev; +else + ei->accum_energy +=UINT_MAX - ei->reg_val_prev + reg_val; + ei->reg_val_prev = reg_val; - *energy =mul_u64_u32_shr (ei->accum_energy,SF_ENERGY , - hwmon->scl_shift_energy); -mutex_unlock (&hwmon->hwmon_lock); + *energy =mul_u64_u32_shr (ei->accum_energy,SF_ENERGY , + hwmon->scl_shift_energy); +mutex_unlock (&hwmon->hwmon_lock); + } } static ssize_t
@@ -404,6 +406,7 @@ hwm_power_max_write(struct hwm_drvdata */* Block waiting for GuC reset to complete when needed */ for (;;) { + wakeref =intel_runtime_pm_get (ddat->uncore->rpm);mutex_lock (&hwmon->hwmon_lock);prepare_to_wait (&ddat->waitq, &wait,TASK_INTERRUPTIBLE );
@@ -417,14 +420,13 @@ hwm_power_max_write(struct hwm_drvdata * }mutex_unlock (&hwmon->hwmon_lock); +intel_runtime_pm_put (ddat->uncore->rpm, wakeref);schedule (); }finish_wait (&ddat->waitq, &wait);if (ret) - goto unlock; - - wakeref =intel_runtime_pm_get (ddat->uncore->rpm); + goto exit;/* Disable PL1 limit and verify, because the limit cannot be disabled on all platforms */ if (val ==PL1_DISABLE ) {
@@ -444,9 +446,8 @@ hwm_power_max_write(struct hwm_drvdata *intel_uncore_rmw (ddat->uncore, hwmon->rg.pkg_rapl_limit,PKG_PWR_LIM_1_EN |PKG_PWR_LIM_1 , nval); exit: -intel_runtime_pm_put (ddat->uncore->rpm, wakeref); -unlock:mutex_unlock (&hwmon->hwmon_lock); +intel_runtime_pm_put (ddat->uncore->rpm, wakeref);return ret; }
Greg Kroah-Hartman
maintainerPATCH 371/432 drm/i915/bios: Tolerate devdata==NULL in intel_bios_encoder_supports_dp_dual_mode()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ville Syrjälä <[email protected]>
commit 32e39bab59934bfd3f37097d4dd85ac5eb0fd549 upstream.
If we have no VBT, or the VBT didn't declare the encoder in question, we won't have the 'devdata' for the encoder. Instead of oopsing just bail early.
We won't be able to tell whether the port is DP++ or not, but so be it.
--- drivers/gpu/drm/i915/display/intel_bios.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/i915/display/intel_bios.c +3 -0
@@ -3321,6 +3321,9 @@ bool intel_bios_encoder_supports_dp_dual {const struct child_device_config *child = &devdata->child; +if (!devdata) +return false; +if (!intel_bios_encoder_supports_dp (devdata) || !intel_bios_encoder_supports_hdmi (devdata))return false;
Greg Kroah-Hartman
maintainerPATCH 372/432 drm/i915/vrr: Generate VRR "safe window" for DSB
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ville Syrjälä <[email protected]>
commit f7d3b9277ff7eb8e84e6f8554d1c2dd78278a572 upstream.
Looks like TRANS_CHICKEN bit 31 means something totally different depending on the platform:
TGL: generate VRR "safe window" for DSB
ADL/DG2: make TRANS_SET_CONTEXT_LATENCY effective with VRR
So far we've only set this on ADL/DG2, but when using DSB+VRR we also need to set it on TGL.
And a quick test on MTL says it doesn't need this bit for either of those purposes, even though it's still documented as valid in bspec.
--- drivers/gpu/drm/i915/display/intel_vrr.c | 7 ++++--- drivers/gpu/drm/i915/i915_reg.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/display/intel_vrr.c +4 -3
@@ -187,10 +187,11 @@ void intel_vrr_set_transcoder_timings(coenum transcoder cpu_transcoder = crtc_state->cpu_transcoder;/* -* TRANS_SET_CONTEXT_LATENCY with VRR enabled -* requires this chicken bit on ADL/DG2. +* This bit seems to have two meanings depending on the platform: +* TGL: generate VRR "safe window" for DSB vblank waits +* ADL/DG2: make TRANS_SET_CONTEXT_LATENCY effective with VRR */ -if (DISPLAY_VER (dev_priv) ==13 ) +if (IS_DISPLAY_VER (dev_priv,12 ,13 ))intel_de_rmw (dev_priv,CHICKEN_TRANS (cpu_transcoder),0 ,PIPE_VBLANK_WITH_DELAY );
drivers/gpu/drm/i915/i915_reg.h +1 -1
@@ -4599,7 +4599,7 @@#define MTL_CHICKEN_TRANS (trans) _MMIO_TRANS((trans), \ _MTL_CHICKEN_TRANS_A, \ _MTL_CHICKEN_TRANS_B) -#define PIPE_VBLANK_WITH_DELAY REG_BIT(31)/* ADL/DG2 */ +#define PIPE_VBLANK_WITH_DELAY REG_BIT(31)/* tgl+ */ #define SKL_UNMASK_VBL_TO_PIPE_IN_SRD REG_BIT(30)/* skl+ */ #define HSW_FRAME_START_DELAY_MASK REG_GENMASK(28, 27)#define HSW_FRAME_START_DELAY (x) REG_FIELD_PREP(HSW_FRAME_START_DELAY_MASK, x)
Greg Kroah-Hartman
maintainerPATCH 373/432 drm/i915/dsi: Go back to the previous INIT_OTP/DISPLAY_ON order, mostly
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ville Syrjälä <[email protected]>
commit 18846627ef1210dcd55d65342b055ea97a46ffff upstream.
Reinstate commit 88b065943cb5 ("drm/i915/dsi: Do display on sequence later on icl+"), for the most part. Turns out some machines (eg. Chuwi Minibook X) really do need that updated order. It is also the order the Windows driver uses.
However we can't just undo the revert since that would again break Lenovo 82TQ. After staring at the VBT sequences for both machines I've concluded that the Lenovo 82TQ sequences look somewhat broken:
- INIT_OTP is not present at all
- what should be in INIT_OTP is found in DISPLAY_ON
- what should be in DISPLAY_ON is found in BACKLIGHT_ON (along with the actual backlight stuff)
The Chuwi Minibook X on the other hand has a full complement of sequences in its VBT.
So let's try to deal with the broken sequences in the Lenovo 82TQ VBT by simply swapping the (non-existent) INIT_OTP sequence with the DISPLAY_ON sequence. Thus we execute DISPLAY_ON when intending to execute INIT_OTP, and execute nothing at all when intending to execute DISPLAY_ON. That should be 100% equivalent to the revert, for such broken VBTs.
References: https://gitlab.freedesktop.org/drm/intel/-/issues/10071
--- drivers/gpu/drm/i915/display/icl_dsi.c | 3 +- drivers/gpu/drm/i915/display/intel_bios.c | 43 +++++++++++++++++++++++++----- 2 files changed, 39 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/display/icl_dsi.c +2 -1
@@ -1155,7 +1155,6 @@ static void gen11_dsi_powerup_panel(stru }intel_dsi_vbt_exec_sequence (intel_dsi,MIPI_SEQ_INIT_OTP ); -intel_dsi_vbt_exec_sequence (intel_dsi,MIPI_SEQ_DISPLAY_ON );/* ensure all panel commands dispatched before enabling transcoder */ wait_for_cmds_dispatched_to_panel (encoder);
@@ -1256,6 +1255,8 @@ static void gen11_dsi_enable(struct inte/* step6d: enable dsi transcoder */ gen11_dsi_enable_transcoder (encoder); +intel_dsi_vbt_exec_sequence (intel_dsi,MIPI_SEQ_DISPLAY_ON ); +/* step7: enable backlight */ intel_backlight_enable (crtc_state, conn_state);intel_dsi_vbt_exec_sequence (intel_dsi,MIPI_SEQ_BACKLIGHT_ON );
drivers/gpu/drm/i915/display/intel_bios.c +37 -6
59 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 374/432 drm/i915/dsb: Fix DSB vblank waits when using VRR
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ville Syrjälä <[email protected]>
commit f12751168f1a49ebb84b8056cf038973c53b284f upstream.
Looks like the undelayed vblank gets signalled exactly when the active period ends. That is a problem for DSB+VRR when we are already in vblank and expect DSB to start executing as soon as we send the push. Instead of starting, the DSB just keeps on waiting for the undelayed vblank which won't signal until the end of the next frame's active period, which is far too late.
The end result is that DSB won't have even started
executing by the time the flips/etc. have completed.
We then wait for an extra 1ms, after which we terminate
the DSB and report a timeout:
[drm] *ERROR* [CRTC:80:pipe A] DSB 0 timed out waiting for idle (current head=0xfedf4000, head=0x0, tail=0x1080)
To fix this let's configure DSB to use the so called VRR "safe window" instead of the undelayed vblank to trigger the DSB vblank logic, when VRR is enabled.
--- drivers/gpu/drm/i915/display/intel_dsb.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/gpu/drm/i915/display/intel_dsb.c +14 -0
@@ -339,6 +339,17 @@ static int intel_dsb_dewake_scanline(conreturn max (0 , vblank_start -intel_usecs_to_scanlines (adjusted_mode, latency)); } +static u32 dsb_chicken (struct intel_crtc *crtc) +{ +if (crtc->mode_flags &I915_MODE_FLAG_VRR ) +return DSB_CTRL_WAIT_SAFE_WINDOW | +DSB_CTRL_NO_WAIT_VBLANK | +DSB_INST_WAIT_SAFE_WINDOW | +DSB_INST_NO_WAIT_VBLANK ; +else +return 0 ; +} +static void _intel_dsb_commit (struct intel_dsb *dsb,u32 ctrl,int dewake_scanline) {
@@ -360,6 +371,9 @@ static void _intel_dsb_commit(struct intintel_de_write_fw (dev_priv,DSB_CTRL (pipe, dsb->id), ctrl |DSB_ENABLE ); +intel_de_write_fw (dev_priv,DSB_CHICKEN (pipe, dsb->id), +dsb_chicken (crtc)); +intel_de_write_fw (dev_priv,DSB_HEAD (pipe, dsb->id),i915_ggtt_offset (dsb->vma));
Greg Kroah-Hartman
maintainerPATCH 375/432 drm/i915: Do not match JSL in ehl_combo_pll_div_frac_wa_needed()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jonathon Hall <[email protected]>
commit e41d769f1a7a1dc533c35ef7b366be3dbf432a1c upstream.
Since commit 0c65dc062611 ("drm/i915/jsl: s/JSL/JASPERLAKE for platform/subplatform defines"), boot freezes on a Jasper Lake tablet (Librem 11), usually with graphical corruption on the eDP display, but sometimes just a black screen. This commit was included in 6.6 and later.
That commit was intended to refactor EHL and JSL macros, but the change to ehl_combo_pll_div_frac_wa_needed() started matching JSL incorrectly when it was only intended to match EHL.
It replaced:
return ((IS_PLATFORM(i915, INTEL_ELKHARTLAKE) && IS_JSL_EHL_DISPLAY_STEP(i915, STEP_B0, STEP_FOREVER)) || with: return (((IS_ELKHARTLAKE(i915) || IS_JASPERLAKE(i915)) && IS_DISPLAY_STEP(i915, STEP_B0, STEP_FOREVER)) ||
Remove IS_JASPERLAKE() to fix the regression.
--- drivers/gpu/drm/i915/display/intel_dpll_mgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/display/intel_dpll_mgr.c +1 -1
@@ -2489,7 +2489,7 @@ static void icl_wrpll_params_populate(ststatic bool ehl_combo_pll_div_frac_wa_needed (struct drm_i915_private *i915) { -return (((IS_ELKHARTLAKE (i915) ||IS_JASPERLAKE (i915)) && +return ((IS_ELKHARTLAKE (i915) &&IS_DISPLAY_STEP (i915,STEP_B0 ,STEP_FOREVER )) ||IS_TIGERLAKE (i915) ||IS_ALDERLAKE_S (i915) ||IS_ALDERLAKE_P (i915)) && i915->display.dpll.ref_clks.nssc ==38400 ;
Greg Kroah-Hartman
maintainerPATCH 376/432 drm/i915/gt: Reset queue_priority_hint on parking
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Wilson <[email protected]>
commit 4a3859ea5240365d21f6053ee219bb240d520895 upstream.
Originally, with strict in order execution, we could complete execution only when the queue was empty. Preempt-to-busy allows replacement of an active request that may complete before the preemption is processed by HW. If that happens, the request is retired from the queue, but the queue_priority_hint remains set, preventing direct submission until after the next CS interrupt is processed.
This preempt-to-busy race can be triggered by the heartbeat, which will also act as the power-management barrier and upon completion allow us to idle the HW. We may process the completion of the heartbeat, and begin parking the engine before the CS event that restores the queue_priority_hint, causing us to fail the assertion that it is MIN.
<3>[ 166.210729] __engine_park:283 GEM_BUG_ON(engine->sched_engine->queue_priority_hint != (-((int)(~0U >> 1)) - 1))
<0>[ 166.210781] Dumping ftrace buffer:
<0>[ 166.210795] ---------------------------------
...
<0>[ 167.302811] drm_fdin-1097 2..s1. 165741070us : trace_ports: 0000:00:02.0 rcs0: promote { ccid:20 1217:2 prio 0 }
<0>[ 167.302861] drm_fdin-1097 2d.s2. 165741072us : execlists_submission_tasklet: 0000:00:02.0 rcs0: preempting last=1217:2, prio=0, hint=2147483646
<0>[ 167.302928] drm_fdin-1097 2d.s2. 165741072us : __i915_request_unsubmit: 0000:00:02.0 rcs0: fence 1217:2, current 0
<0>[ 167.302992] drm_fdin-1097 2d.s2. 165741073us : __i915_request_submit: 0000:00:02.0 rcs0: fence 3:4660, current 4659
<0>[ 167.303044] drm_fdin-1097 2d.s1. 165741076us : execlists_submission_tasklet: 0000:00:02.0 rcs0: context:3 schedule-in, ccid:40
<0>[ 167.303095] drm_fdin-1097 2d.s1. 165741077us : trace_ports: 0000:00:02.0 rcs0: submit { ccid:40 3:4660* prio 2147483646 }
<0>[ 167.303159] kworker/-89 11..... 165741139us : i915_request_retire.part.0: 0000:00:02.0 rcs0: fence c90:2, current 2
<0>[ 167.303208] kworker/-89 11..... 165741148us : __intel_context_do_unpin: 0000:00:02.0 rcs0: context:c90 unpin
<0>[ 167.303272] kworker/-89 11..... 165741159us : i915_request_retire.part.0: 0000:00:02.0 rcs0: fence 1217:2, current 2
<0>[ 167.303321] kworker/-89 11..... 165741166us : __intel_context_do_unpin: 0000:00:02.0 rcs0: context:1217 unpin
<0>[ 167.303384] kworker/-89 11..... 165741170us : i915_request_retire.part.0: 0000:00:02.0 rcs0: fence 3:4660, current 4660
<0>[ 167.303434] kworker/-89 11d..1. 165741172us : __intel_context_retire: 0000:00:02.0 rcs0: context:1216 retire runtime: { total:56028ns, avg:56028ns }
<0>[ 167.303484] kworker/-89 11..... 165741198us : __engine_park: 0000:00:02.0 rcs0: parked
<0>[ 167.303534] <idle>-0 5d.H3. 165741207us : execlists_irq_handler: 0000:00:02.0 rcs0: semaphore yield: 00000040
<0>[ 167.303583] kworker/-89 11..... 165741397us : __intel_context_retire: 0000:00:02.0 rcs0: context:1217 retire runtime: { total:325575ns, avg:0ns }
<0>[ 167.303756] kworker/-89 11..... 165741777us : __intel_context_retire: 0000:00:02.0 rcs0: context:c90 retire runtime: { total:0ns, avg:0ns }
<0>[ 167.303806] kworker/-89 11..... 165742017us : __engine_park: __engine_park:283 GEM_BUG_ON(engine->sched_engine->queue_priority_hint != (-((int)(~0U >> 1)) - 1))
<0>[ 167.303811] ---------------------------------
<4>[ 167.304722] ------------[ cut here ]------------
<2>[ 167.304725] kernel BUG at drivers/gpu/drm/i915/gt/intel_engine_pm.c:283!
<4>[ 167.304731] invalid opcode: 0000 [#1] PREEMPT SMP NOPTI
<4>[ 167.304734] CPU: 11 PID: 89 Comm: kworker/11:1 Tainted: G W 6.8.0-rc2-CI_DRM_14193-gc655e0fd2804+ #1
<4>[ 167.304736] Hardware name: Intel Corporation Rocket Lake Client Platform/RocketLake S UDIMM 6L RVP, BIOS RKLSFWI1.R00.3173.A03.2204210138 04/21/2022
<4>[ 167.304738] Workqueue: i915-unordered retire_work_handler [i915]
<4>[ 167.304839] RIP: 0010:__engine_park+0x3fd/0x680 [i915]
<4>[ 167.304937] Code: 00 48 c7 c2 b0 e5 86 a0 48 8d 3d 00 00 00 00 e8 79 48 d4 e0 bf 01 00 00 00 e8 ef 0a d4 e0 31 f6 bf 09 00 00 00 e8 03 49 c0 e0 <0f> 0b 0f 0b be 01 00 00 00 e8 f5 61 fd ff 31 c0 e9 34 fd ff ff 48
<4>[ 167.304940] RSP: 0018:ffffc9000059fce0 EFLAGS: 00010246
<4>[ 167.304942] RAX: 0000000000000200 RBX: 0000000000000000 RCX: 0000000000000006
<4>[ 167.304944] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000009
<4>[ 167.304946] RBP: ffff8881330ca1b0 R08: 0000000000000001 R09: 0000000000000001
<4>[ 167.304947] R10: 0000000000000001 R11: 0000000000000001 R12: ffff8881330ca000
<4>[ 167.304948] R13: ffff888110f02aa0 R14: ffff88812d1d0205 R15: ffff88811277d4f0
<4>[ 167.304950] FS: 0000000000000000(0000) GS:ffff88844f780000(0000) knlGS:0000000000000000
<4>[ 167.304952] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
<4>[ 167.304953] CR2: 00007fc362200c40 CR3: 000000013306e003 CR4: 0000000000770ef0
<4>[ 167.304955] PKRU: 55555554
<4>[ 167.304957] Call Trace:
<4>[ 167.304958] <TASK>
<4>[ 167.305573] ____intel_wakeref_put_last+0x1d/0x80 [i915]
<4>[ 167.305685] i915_request_retire.part.0+0x34f/0x600 [i915]
<4>[ 167.305800] retire_requests+0x51/0x80 [i915]
<4>[ 167.305892] intel_gt_retire_requests_timeout+0x27f/0x700 [i915]
<4>[ 167.305985] process_scheduled_works+0x2db/0x530
<4>[ 167.305990] worker_thread+0x18c/0x350
<4>[ 167.305993] kthread+0xfe/0x130
<4>[ 167.305997] ret_from_fork+0x2c/0x50
<4>[ 167.306001] ret_from_fork_asm+0x1b/0x30
<4>[ 167.306004] </TASK>It is necessary for the queue_priority_hint to be lower than the next request submission upon waking up, as we rely on the hint to decide when to kick the tasklet to submit that first request.
--- drivers/gpu/drm/i915/gt/intel_engine_pm.c | 3 --- drivers/gpu/drm/i915/gt/intel_execlists_submission.c | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/gt/intel_engine_pm.c +0 -3
@@ -278,9 +278,6 @@ static int __engine_park(struct intel_waintel_engine_park_heartbeat (engine);intel_breadcrumbs_park (engine->breadcrumbs); -/* Must be reset upon idling, or we may miss the busy wakeup. */ -GEM_BUG_ON (engine->sched_engine->queue_priority_hint !=INT_MIN ); -if (engine->park) engine->park (engine);
drivers/gpu/drm/i915/gt/intel_execlists_submission.c +3 -0
@@ -3272,6 +3272,9 @@ static void execlists_park(struct intel_ {cancel_timer (&engine->execlists.timer);cancel_timer (&engine->execlists.preempt); + +/* Reset upon idling, or we may delay the busy wakeup. */ +WRITE_ONCE (engine->sched_engine->queue_priority_hint,INT_MIN ); }static void add_to_engine (struct i915_request *rq)
Greg Kroah-Hartman
maintainerPATCH 377/432 drm/amd/display: Fix bounds check for dcn35 DcfClocks
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Roman Li <[email protected]>
commit 2f10d4a51bbcd938f1f02f16c304ad1d54717b96 upstream.
[Why]
NumFclkLevelsEnabled is used for DcfClocks bounds check instead of designated NumDcfClkLevelsEnabled. That can cause array index out-of-bounds access.
[How]
Use designated variable for dcn35 DcfClocks bounds check.
--- drivers/gpu/drm/amd/display/dc/clk_mgr/dcn35/dcn35_clk_mgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn35/dcn35_clk_mgr.c +1 -1
@@ -705,7 +705,7 @@ static void dcn35_clk_mgr_helper_populat clock_table->NumFclkLevelsEnabled; max_fclk =find_max_clk_value (clock_table->FclkClocks_Freq, num_fclk); - num_dcfclk = (clock_table->NumFclkLevelsEnabled >NUM_DCFCLK_DPM_LEVELS ) ?NUM_DCFCLK_DPM_LEVELS : + num_dcfclk = (clock_table->NumDcfClkLevelsEnabled >NUM_DCFCLK_DPM_LEVELS ) ?NUM_DCFCLK_DPM_LEVELS : clock_table->NumDcfClkLevelsEnabled;for (i =0 ; i < num_dcfclk; i++) {int j;
Greg Kroah-Hartman
maintainerPATCH 378/432 Bluetooth: hci_sync: Fix not checking error on hci_cmd_sync_cancel_sync
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
commit 1c3366abdbe884be62e5a7502b4db758aa3974c6 upstream.
hci_cmd_sync_cancel_sync shall check the error passed to it since it will be propagated using req_result which is __u32 it needs to be properly set to a positive value if it was passed as negative othertise IS_ERR will not trigger as -(errno) would be converted to a positive value.
--- net/bluetooth/hci_core.c | 6 +++--- net/bluetooth/hci_sync.c | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-)
net/bluetooth/hci_core.c +3 -3
@@ -2842,7 +2842,7 @@ static void hci_cancel_cmd_sync(struct hcancel_delayed_work_sync (&hdev->ncmd_timer);atomic_set (&hdev->cmd_cnt,1 ); -hci_cmd_sync_cancel_sync (hdev, -err); +hci_cmd_sync_cancel_sync (hdev, err); }/* Suspend HCI device */
@@ -2862,7 +2862,7 @@ int hci_suspend_dev(struct hci_dev *hdevreturn 0 ;/* Cancel potentially blocking sync operation before suspend */ -hci_cancel_cmd_sync (hdev, -EHOSTDOWN ); +hci_cancel_cmd_sync (hdev,EHOSTDOWN );hci_req_sync_lock (hdev); ret =hci_suspend_sync (hdev);
@@ -4178,7 +4178,7 @@ static void hci_send_cmd_sync(struct hci err =hci_send_frame (hdev, skb);if (err <0 ) { -hci_cmd_sync_cancel_sync (hdev, err); +hci_cmd_sync_cancel_sync (hdev, -err);return ; }
net/bluetooth/hci_sync.c +4 -1
@@ -679,7 +679,10 @@ void hci_cmd_sync_cancel_sync(struct hcibt_dev_dbg (hdev,"err 0x%2.2x" , err);if (hdev->req_status ==HCI_REQ_PEND ) { - hdev->req_result = err; +/* req_result is __u32 so error must be positive to be properly +* propagated. +*/ + hdev->req_result = err <0 ? -err : err; hdev->req_status =HCI_REQ_CANCELED ;wake_up_interruptible (&hdev->req_wait_q);
Greg Kroah-Hartman
maintainerPATCH 379/432 mtd: spinand: Add support for 5-byte IDs
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ezra Buehler <[email protected]>
commit 34a956739d295de6010cdaafeed698ccbba87ea4 upstream.
E.g. ESMT chips will return an identification code with a length of 5 bytes. In order to prevent ambiguity, flash chips would actually need to return IDs that are up to 17 or more bytes long due to JEDEC's continuation scheme. I understand that if a manufacturer ID is located in bank N of JEDEC's database (there are currently 16 banks), N - 1 continuation codes (7Fh) need to be added to the identification code (comprising of manufacturer ID and device ID). However, most flash chip manufacturers don't seem to implement this (correctly).
--- include/linux/mtd/spinand.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/mtd/spinand.h +1 -1
@@ -169,7 +169,7 @@struct spinand_op ;struct spinand_device ; -#define SPINAND_MAX_ID_LEN 4 +#define SPINAND_MAX_ID_LEN 5/* * For erase, write and read operation, we got the following timings : * tBERS (erase) 1ms to 4ms
Greg Kroah-Hartman
maintainerPATCH 380/432 Revert "usb: phy: generic: Get the vbus supply"
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Stein <[email protected]>
commit fdada0db0b2ae2addef4ccafe50937874dbeeebe upstream.
This reverts commit 75fd6485cccef269ac9eb3b71cf56753341195ef. This patch was applied twice by accident, causing probe failures. Revert the accident.
--- drivers/usb/phy/phy-generic.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/usb/phy/phy-generic.c +0 -7
@@ -268,13 +268,6 @@ int usb_phy_gen_create_phy(struct devicereturn dev_err_probe (dev,PTR_ERR (nop->vbus_draw),"could not get vbus regulator\n" ); - nop->vbus_draw =devm_regulator_get_exclusive (dev,"vbus" ); -if (PTR_ERR (nop->vbus_draw) == -ENODEV ) - nop->vbus_draw =NULL ; -if (IS_ERR (nop->vbus_draw)) -return dev_err_probe (dev,PTR_ERR (nop->vbus_draw), -"could not get vbus regulator\n" ); - nop->dev = dev; nop->phy.dev = nop->dev; nop->phy.label ="nop-xceiv" ;
Greg Kroah-Hartman
maintainerPATCH 381/432 usb: cdc-wdm: close race between read and workqueue
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
commit 339f83612f3a569b194680768b22bf113c26a29d upstream.
wdm_read() cannot race with itself. However, in service_outstanding_interrupt() it can race with the workqueue, which can be triggered by error handling.
Hence we need to make sure that the WDM_RESPONDING flag is not just only set but tested.
--- drivers/usb/class/cdc-wdm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/usb/class/cdc-wdm.c +5 -1
@@ -485,6 +485,7 @@ out_free_mem:static int service_outstanding_interrupt (struct wdm_device *desc) {int rv =0 ; +int used;/* submit read urb only if the device is waiting for it */ if (!desc->resp_count || !--desc->resp_count)
@@ -499,7 +500,10 @@ static int service_outstanding_interrupt goto out; } -set_bit (WDM_RESPONDING , &desc->flags); + used =test_and_set_bit (WDM_RESPONDING , &desc->flags); +if (used) + goto out; +spin_unlock_irq (&desc->iuspin); rv =usb_submit_urb (desc->response,GFP_KERNEL );spin_lock_irq (&desc->iuspin);
Greg Kroah-Hartman
maintainerPATCH 382/432 usb: misc: ljca: Fix double free in error handling path
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yongzhi Liu <[email protected]>
commit 7c9631969287a5366bc8e39cd5abff154b35fb80 upstream.
When auxiliary_device_add() returns error and then calls auxiliary_device_uninit(), callback function ljca_auxdev_release calls kfree(auxdev->dev.platform_data) to free the parameter data of the function ljca_new_client_device. The callers of ljca_new_client_device shouldn't call kfree() again
in the error handling path to free the platform data.
Fix this by cleaning up the redundant kfree() in all callers and adding kfree() the passed in platform_data on errors which happen before auxiliary_device_init() succeeds .
--- drivers/usb/misc/usb-ljca.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)
drivers/usb/misc/usb-ljca.c +9 -13
@@ -518,8 +518,10 @@ static int ljca_new_client_device(struct ljca_adapter *adap, u8 type, u8 id,int ret; client =kzalloc (sizeof *client,GFP_KERNEL ); -if (!client) +if (!client) { +kfree (data);return -ENOMEM ; + } client->type = type; client->id = id;
@@ -535,8 +537,10 @@ static int ljca_new_client_device(struct ljca_adapter *adap, u8 type, u8 id, auxdev->dev.release = ljca_auxdev_release; ret =auxiliary_device_init (auxdev); -if (ret) +if (ret) { +kfree (data); goto err_free; + }ljca_auxdev_acpi_bind (adap, auxdev, adr, id);
@@ -590,12 +594,8 @@ static int ljca_enumerate_gpio(struct ljca_adapter *adap) valid_pin[i] =get_unaligned_le32 (&desc->bank_desc[i].valid_pins);bitmap_from_arr32 (gpio_info->valid_pin_map, valid_pin, gpio_num); - ret =ljca_new_client_device (adap,LJCA_CLIENT_GPIO ,0 ,"ljca-gpio" , +return ljca_new_client_device (adap,LJCA_CLIENT_GPIO ,0 ,"ljca-gpio" , gpio_info,LJCA_GPIO_ACPI_ADR ); -if (ret) -kfree (gpio_info); - -return ret; }static int ljca_enumerate_i2c (struct ljca_adapter *adap)
@@ -629,10 +629,8 @@ static int ljca_enumerate_i2c(struct ljca_adapter *adap) ret =ljca_new_client_device (adap,LJCA_CLIENT_I2C , i,"ljca-i2c" , i2c_info,LJCA_I2C1_ACPI_ADR + i); -if (ret) { -kfree (i2c_info); +if (ret)return ret; - } }return 0 ;
@@ -669,10 +667,8 @@ static int ljca_enumerate_spi(struct ljca_adapter *adap) ret =ljca_new_client_device (adap,LJCA_CLIENT_SPI , i,"ljca-spi" , spi_info,LJCA_SPI1_ACPI_ADR + i); -if (ret) { -kfree (spi_info); +if (ret)return ret; - } }return 0 ;
Signature · 1 line
2.44.0
Greg Kroah-Hartman
maintainerPATCH 383/432 USB: UAS: return ENODEV when submit urbs fail with device not attached
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weitao Wang <[email protected]>
commit cd5432c712351a3d5f82512908f5febfca946ca6 upstream.
In the scenario of entering hibernation with udisk in the system, if the udisk was gone or resume fail in the thaw phase of hibernation. Its state will be set to NOTATTACHED. At this point, usb_hub_wq was already freezed and can't not handle disconnect event. Next, in the poweroff phase of hibernation, SYNCHRONIZE_CACHE SCSI command will be sent to this udisk when poweroff this scsi device, which will cause uas_submit_urbs to be called to submit URB for sense/data/cmd pipe. However, these URBs will submit fail as device was set to NOTATTACHED state. Then, uas_submit_urbs will return a value SCSI_MLQUEUE_DEVICE_BUSY to the caller. That will lead the SCSI layer go into an ugly loop and system fail to go into hibernation.
On the other hand, when we specially check for -ENODEV in function uas_queuecommand_lck, returning DID_ERROR to SCSI layer will cause device poweroff fail and system shutdown instead of entering hibernation.
To fix this issue, let uas_submit_urbs to return original generic error when submitting URB failed. At the same time, we need to translate -ENODEV to DID_NOT_CONNECT for the SCSI layer.
--- drivers/usb/storage/uas.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-)
drivers/usb/storage/uas.c +13 -15
@@ -533,7 +533,7 @@ static struct urb *uas_alloc_cmd_urb(str* daft to me. */ -static struct urb *uas_submit_sense_urb (struct scsi_cmnd *cmnd,gfp_t gfp) +static int uas_submit_sense_urb (struct scsi_cmnd *cmnd,gfp_t gfp) {struct uas_dev_info *devinfo = cmnd->device->hostdata;struct urb *urb;
@@ -541,30 +541,28 @@ static struct urb *uas_submit_sense_urb( urb =uas_alloc_sense_urb (devinfo, gfp, cmnd);if (!urb) -return NULL ; +return -ENOMEM ;usb_anchor_urb (urb, &devinfo->sense_urbs); err =usb_submit_urb (urb, gfp);if (err) {usb_unanchor_urb (urb);uas_log_cmd_state (cmnd,"sense submit err" , err);usb_free_urb (urb); -return NULL ; } -return urb; +return err; }static int uas_submit_urbs (struct scsi_cmnd *cmnd,struct uas_dev_info *devinfo) {struct uas_cmd_info *cmdinfo =scsi_cmd_priv (cmnd); -struct urb *urb;int err;lockdep_assert_held (&devinfo->lock);if (cmdinfo->state &SUBMIT_STATUS_URB ) { - urb =uas_submit_sense_urb (cmnd,GFP_ATOMIC ); -if (!urb) -return SCSI_MLQUEUE_DEVICE_BUSY ; + err =uas_submit_sense_urb (cmnd,GFP_ATOMIC ); +if (err) +return err; cmdinfo->state &= ~SUBMIT_STATUS_URB ; }
@@ -572,7 +570,7 @@ static int uas_submit_urbs(struct scsi_c cmdinfo->data_in_urb =uas_alloc_data_urb (devinfo,GFP_ATOMIC , cmnd,DMA_FROM_DEVICE );if (!cmdinfo->data_in_urb) -return SCSI_MLQUEUE_DEVICE_BUSY ; +return -ENOMEM ; cmdinfo->state &= ~ALLOC_DATA_IN_URB ; }
@@ -582,7 +580,7 @@ static int uas_submit_urbs(struct scsi_cif (err) {usb_unanchor_urb (cmdinfo->data_in_urb);uas_log_cmd_state (cmnd,"data in submit err" , err); -return SCSI_MLQUEUE_DEVICE_BUSY ; +return err; } cmdinfo->state &= ~SUBMIT_DATA_IN_URB ; cmdinfo->state |=DATA_IN_URB_INFLIGHT ;
@@ -592,7 +590,7 @@ static int uas_submit_urbs(struct scsi_c cmdinfo->data_out_urb =uas_alloc_data_urb (devinfo,GFP_ATOMIC , cmnd,DMA_TO_DEVICE );if (!cmdinfo->data_out_urb) -return SCSI_MLQUEUE_DEVICE_BUSY ; +return -ENOMEM ; cmdinfo->state &= ~ALLOC_DATA_OUT_URB ; }
@@ -602,7 +600,7 @@ static int uas_submit_urbs(struct scsi_cif (err) {usb_unanchor_urb (cmdinfo->data_out_urb);uas_log_cmd_state (cmnd,"data out submit err" , err); -return SCSI_MLQUEUE_DEVICE_BUSY ; +return err; } cmdinfo->state &= ~SUBMIT_DATA_OUT_URB ; cmdinfo->state |=DATA_OUT_URB_INFLIGHT ;
@@ -611,7 +609,7 @@ static int uas_submit_urbs(struct scsi_cif (cmdinfo->state &ALLOC_CMD_URB ) { cmdinfo->cmd_urb =uas_alloc_cmd_urb (devinfo,GFP_ATOMIC , cmnd);if (!cmdinfo->cmd_urb) -return SCSI_MLQUEUE_DEVICE_BUSY ; +return -ENOMEM ; cmdinfo->state &= ~ALLOC_CMD_URB ; }
@@ -621,7 +619,7 @@ static int uas_submit_urbs(struct scsi_cif (err) {usb_unanchor_urb (cmdinfo->cmd_urb);uas_log_cmd_state (cmnd,"cmd submit err" , err); -return SCSI_MLQUEUE_DEVICE_BUSY ; +return err; } cmdinfo->cmd_urb =NULL ; cmdinfo->state &= ~SUBMIT_CMD_URB ;
@@ -698,7 +696,7 @@ static int uas_queuecommand_lck(struct s* of queueing, no matter how fatal the error */ if (err == -ENODEV ) { -set_host_byte (cmnd,DID_ERROR ); +set_host_byte (cmnd,DID_NO_CONNECT );scsi_done (cmnd); goto zombie; }
Greg Kroah-Hartman
maintainerPATCH 384/432 drm/amd/display: set odm_combine_policy based on context in dcn32 resource
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wenjing Liu <[email protected]>
[ Upstream commit 0a5fd7811a17af708cefdaab93af86838353002d ]
[why]
When populating dml pipes, odm combine policy should be assigned based on the pipe topology of the context passed in. DML pipes could be repopulated multiple times during single validate bandwidth attempt. We need to make sure that whenever we repopulate the dml pipes it is always aligned with the updated context. There is a case where DML pipes get repopulated during FPO optimization after ODM combine policy is changed. Since in the current code we reinitlaize ODM combine policy, even though the current context has ODM combine enabled, we overwrite it despite the pipes are already split. This causes DML to think that MPC combine is used so we mistakenly enable MPC combine because we apply pipe split with ODM combine policy reset. This issue doesn't impact non windowed MPO with ODM case because the legacy policy has restricted use cases. We don't encounter the case where both ODM and FPO optimizations are enabled together. So we decide to leave it as is because it is about to be replaced anyway.
--- .../drm/amd/display/dc/dcn32/dcn32_resource.c | 16 ++++++++++++++- .../drm/amd/display/dc/dml/dcn32/dcn32_fpu.c | 15 ++++++++++---- drivers/gpu/drm/amd/display/dc/inc/resource.h | 20 ++++++++----------- 3 files changed, 34 insertions(+), 17 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource.c +15 -1
@@ -1925,7 +1925,21 @@ int dcn32_populate_dml_pipes_from_context(dcn32_zero_pipe_dcc_fraction (pipes, pipe_cnt);DC_FP_END (); pipes[pipe_cnt].pipe.dest.vfront_porch = timing->v_front_porch; - pipes[pipe_cnt].pipe.dest.odm_combine_policy = dm_odm_combine_policy_dal; +if (dc->config.enable_windowed_mpo_odm && + dc->debug.enable_single_display_2to1_odm_policy) { +switch (resource_get_odm_slice_count (pipe)) { +case 2 : + pipes[pipe_cnt].pipe.dest.odm_combine_policy = dm_odm_combine_policy_2to1; +break ; +case 4 : + pipes[pipe_cnt].pipe.dest.odm_combine_policy = dm_odm_combine_policy_4to1; +break ; +default : + pipes[pipe_cnt].pipe.dest.odm_combine_policy = dm_odm_combine_policy_dal; + } + }else { + pipes[pipe_cnt].pipe.dest.odm_combine_policy = dm_odm_combine_policy_dal; + } pipes[pipe_cnt].pipe.src.gpuvm_min_page_size_kbytes =256 ;// according to spreadsheet pipes[pipe_cnt].pipe.src.unbounded_req_mode = false; pipes[pipe_cnt].pipe.scale_ratio_depth.lb_depth = dm_lb_19;
drivers/gpu/drm/amd/display/dc/dml/dcn32/dcn32_fpu.c +11 -4
@@ -1265,7 +1265,7 @@ static bool update_pipes_with_split_flags(struct dc *dc, struct dc_state *contexreturn updated; } -static bool should_allow_odm_power_optimization (struct dc *dc, +static bool should_apply_odm_power_optimization (struct dc *dc,struct dc_state *context,struct vba_vars_st *v,int *split,bool *merge) {
@@ -1369,9 +1369,12 @@ static void try_odm_power_optimization_and_revalidate( {int i;unsigned int new_vlevel; +unsigned int cur_policy[MAX_PIPES ]; -for (i =0 ; i < pipe_cnt; i++) +for (i =0 ; i < pipe_cnt; i++) { + cur_policy[i] = pipes[i].pipe.dest.odm_combine_policy; pipes[i].pipe.dest.odm_combine_policy = dm_odm_combine_policy_2to1; + } new_vlevel =dml_get_voltage_level (&context->bw_ctx.dml, pipes, pipe_cnt);
@@ -1380,6 +1383,9 @@ static void try_odm_power_optimization_and_revalidate(memset (merge,0 ,MAX_PIPES *sizeof (bool )); *vlevel =dcn20_validate_apply_pipe_split_flags (dc, context, new_vlevel, split, merge); context->bw_ctx.dml.vba.VoltageLevel = *vlevel; + }else { +for (i =0 ; i < pipe_cnt; i++) + pipes[i].pipe.dest.odm_combine_policy = cur_policy[i]; } }
@@ -1550,7 +1556,7 @@ static void dcn32_full_validate_bw_helper(struct dc *dc, } } -if (should_allow_odm_power_optimization (dc, context, vba, split, merge)) +if (should_apply_odm_power_optimization (dc, context, vba, split, merge))try_odm_power_optimization_and_revalidate ( dc, context, pipes, split, merge, vlevel, *pipe_cnt);
@@ -2178,7 +2184,8 @@ bool dcn32_internal_validate_bw(struct dc *dc,int i; pipe_cnt = dc->res_pool->funcs->populate_dml_pipes (dc, context, pipes, fast_validate); -dcn32_update_dml_pipes_odm_policy_based_on_context (dc, context, pipes); +if (!dc->config.enable_windowed_mpo_odm) +dcn32_update_dml_pipes_odm_policy_based_on_context (dc, context, pipes);/* repopulate_pipes = 1 means the pipes were either split or merged. In this case * we have to re-calculate the DET allocation and run through DML once more to
drivers/gpu/drm/amd/display/dc/inc/resource.h +8 -12
@@ -427,22 +427,18 @@ struct pipe_ctx *resource_get_primary_dpp_pipe(const struct pipe_ctx *dpp_pipe);int resource_get_mpc_slice_index (const struct pipe_ctx *dpp_pipe);/* -* Get number of MPC "cuts" of the plane associated with the pipe. MPC slice -* count is equal to MPC splits + 1. For example if a plane is cut 3 times, it -* will have 4 pieces of slice. -* return - 0 if pipe is not used for a plane with MPCC combine. otherwise -* the number of MPC "cuts" for the plane. +* Get the number of MPC slices associated with the pipe. +* The function returns 0 if the pipe is not associated with an MPC combine +* pipe topology. */ -int resource_get_mpc_slice_count (const struct pipe_ctx *opp_head); +int resource_get_mpc_slice_count (const struct pipe_ctx *pipe);/* -* Get number of ODM "cuts" of the timing associated with the pipe. ODM slice -* count is equal to ODM splits + 1. For example if a timing is cut 3 times, it -* will have 4 pieces of slice. -* return - 0 if pipe is not used for ODM combine. otherwise -* the number of ODM "cuts" for the timing. +* Get the number of ODM slices associated with the pipe. +* The function returns 0 if the pipe is not associated with an ODM combine +* pipe topology. */ -int resource_get_odm_slice_count (const struct pipe_ctx *otg_master); +int resource_get_odm_slice_count (const struct pipe_ctx *pipe);/* Get the ODM slice index counting from 0 from left most slice */ int resource_get_odm_slice_index (const struct pipe_ctx *opp_head);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 385/432 drm/amdgpu: make damage clips support configurable
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hamza Mahfooz <[email protected]>
[ Upstream commit fc184dbe9fd99ad2dfb197b6fe18768bae1774b1 ]
We have observed that there are quite a number of PSR-SU panels on the market that are unable to keep up with what user space throws at them, resulting in hangs and random black screens. So, make damage clips support configurable and disable it by default for PSR-SU displays.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 13 +++++++++++++ drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 7 +++++++ 3 files changed, 21 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -198,6 +198,7 @@ extern uint amdgpu_dc_debug_mask;extern uint amdgpu_dc_visual_confirm;extern uint amdgpu_dm_abm_level;extern int amdgpu_backlight; +extern int amdgpu_damage_clips;extern struct amdgpu_mgpu_info mgpu_info;extern int amdgpu_ras_enable;extern uint amdgpu_ras_mask;
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +13 -0
@@ -209,6 +209,7 @@ int amdgpu_umsch_mm;int amdgpu_seamless =-1 ;/* auto */ uint amdgpu_debug_mask;int amdgpu_agp =-1 ;/* auto */ +int amdgpu_damage_clips =-1 ;/* auto */ static void amdgpu_drv_delayed_reset_work_handler (struct work_struct *work);
@@ -857,6 +858,18 @@ int amdgpu_backlight = -1;MODULE_PARM_DESC (backlight,"Backlight control (0 = pwm, 1 = aux, -1 auto (default))" );module_param_named (backlight, amdgpu_backlight, bint,0444 ); +/** +* DOC: damageclips (int) +* Enable or disable damage clips support. If damage clips support is disabled, +* we will force full frame updates, irrespective of what user space sends to +* us. +* +* Defaults to -1 (where it is enabled unless a PSR-SU display is detected). +*/ +MODULE_PARM_DESC (damageclips, +"Damage clips support (0 = disable, 1 = enable, -1 auto (default))" ); +module_param_named (damageclips, amdgpu_damage_clips, int,0444 ); +/** * DOC: tmz (int) * Trusted Memory Zone (TMZ) is a method to protect data being written
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +7 -0
@@ -5147,6 +5147,7 @@ static void fill_dc_dirty_rects(struct drm_plane *plane,struct drm_plane_state *new_plane_state, struct drm_crtc_state *crtc_state, struct dc_flip_addrs *flip_addrs, + bool is_psr_su, bool *dirty_regions_changed) { struct dm_crtc_state *dm_crtc_state = to_dm_crtc_state(crtc_state);
@@ -5171,6 +5172,10 @@ static void fill_dc_dirty_rects(struct drm_plane *plane, num_clips =drm_plane_get_damage_clips_count (new_plane_state); clips =drm_plane_get_damage_clips (new_plane_state); +if (num_clips && (!amdgpu_damage_clips || (amdgpu_damage_clips <0 && + is_psr_su))) + goto ffu; +if (!dm_crtc_state->mpo_requested) {if (!num_clips || num_clips >DC_MAX_DIRTY_RECTS ) goto ffu;
@@ -8216,6 +8221,8 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,fill_dc_dirty_rects (plane, old_plane_state, new_plane_state, new_crtc_state, &bundle->flip_addrs[planes_count], + acrtc_state->stream->link->psr_settings.psr_version == +DC_PSR_VERSION_SU_1 , &dirty_rects_changed);/*
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 386/432 drm/amdgpu/display: Address kdoc for is_psr_su in fill_dc_dirty_rects
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivasan Shanmugam <[email protected]>
[ Upstream commit 3651306ae4c7f3f54caa9feb826a93cc69ccebbf ]
The is_psr_su parameter is a boolean flag indicating whether the Panel Self Refresh Selective Update (PSR SU) feature is enabled which is a power-saving feature that allows only the updated regions of the screen to be refreshed, reducing the amount of data that needs to be sent to the display.
Fixes the below with gcc W=1:drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:5257: warning: Function parameter or member 'is_psr_su' not described in 'fill_dc_dirty_rects'
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +4 -0
@@ -5129,6 +5129,10 @@ static inline void fill_dc_dirty_rect(struct drm_plane *plane,* @new_plane_state: New state of @plane * @crtc_state: New state of CRTC connected to the @plane * @flip_addrs: DC flip tracking struct, which also tracts dirty rects +* @is_psr_su: Flag indicating whether Panel Self Refresh Selective Update (PSR SU) is enabled. +* If PSR SU is enabled and damage clips are available, only the regions of the screen +* that have changed will be updated. If PSR SU is not enabled, +* or if damage clips are not available, the entire screen will be updated. * @dirty_regions_changed: dirty regions changed * * For PSR SU, DC informs the DMUB uController of dirty rectangle regions
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 387/432 vfio/pds: Make sure migration file isnt accessed after reset
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brett Creeley <[email protected]>
[ Upstream commit 457f7308254756b6e4b8fc3876cb770dcf0e7cc7 ]
It's possible the migration file is accessed after reset when it has been cleaned up, especially when it's initiated by the device. This is because the driver doesn't rip out the filep when cleaning up it only frees the related page structures and sets its local struct pds_vfio_lm_file pointer to NULL. This can cause a NULL pointer dereference, which is shown in the example below during a restore after a device initiated reset:
BUG: kernel NULL pointer dereference, address: 000000000000000c PF: supervisor read access in kernel mode PF: error_code(0x0000) - not-present page PGD 0 P4D 0 Oops: 0000 [#1] PREEMPT SMP NOPTI RIP: 0010:pds_vfio_get_file_page+0x5d/0xf0 [pds_vfio_pci] [...] Call Trace: <TASK> pds_vfio_restore_write+0xf6/0x160 [pds_vfio_pci] vfs_write+0xc9/0x3f0 ? __fget_light+0xc9/0x110 ksys_write+0xb5/0xf0 __x64_sys_write+0x1a/0x20 do_syscall_64+0x38/0x90 entry_SYSCALL_64_after_hwframe+0x63/0xcd
[...]
Add a disabled flag to the driver's struct pds_vfio_lm_file that gets set during cleanup. Then make sure to check the flag when the migration file is accessed via its file_operations. By default this flag will be false as the memory for struct pds_vfio_lm_file is kzalloc'd, which means the struct pds_vfio_lm_file is enabled and accessible. Also, since the file_operations and driver's migration file cleanup happen under the protection of the same pds_vfio_lm_file.lock, using this flag is thread safe.
--- drivers/vfio/pci/pds/lm.c | 13 +++++++++++++ drivers/vfio/pci/pds/lm.h | 1 + 2 files changed, 14 insertions(+)
drivers/vfio/pci/pds/lm.c +13 -0
@@ -92,8 +92,10 @@ static void pds_vfio_put_lm_file(struct pds_vfio_lm_file *lm_file) {mutex_lock (&lm_file->lock); + lm_file->disabled = true; lm_file->size =0 ; lm_file->alloc_size =0 ; + lm_file->filep->f_pos =0 ;/* Free scatter list of file pages */ sg_free_table (&lm_file->sg_table);
@@ -183,6 +185,12 @@ static ssize_t pds_vfio_save_read(struct file *filp, char __user *buf, pos = &filp->f_pos;mutex_lock (&lm_file->lock); + +if (lm_file->disabled) { + done = -ENODEV ; + goto out_unlock; + } +if (*pos > lm_file->size) { done = -EINVAL ; goto out_unlock;
@@ -283,6 +291,11 @@ static ssize_t pds_vfio_restore_write(struct file *filp, const char __user *buf,mutex_lock (&lm_file->lock); +if (lm_file->disabled) { + done = -ENODEV ; + goto out_unlock; + } +while (len) {size_t page_offset;struct page *page;
drivers/vfio/pci/pds/lm.h +1 -0
@@ -27,6 +27,7 @@ struct pds_vfio_lm_file {struct scatterlist *last_offset_sg;/* Iterator */ unsigned int sg_last_entry;unsigned long last_offset; +bool disabled; };struct pds_vfio_pci_device ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 388/432 ALSA: sh: aica: reorder cleanup operations to avoid UAF bugs
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Duoming Zhou <[email protected]>
commit 051e0840ffa8ab25554d6b14b62c9ab9e4901457 upstream.
The dreamcastcard->timer could schedule the spu_dma_work and the spu_dma_work could also arm the dreamcastcard->timer.
When the snd_pcm_substream is closing, the aica_channel will be deallocated. But it could still be dereferenced in the worker thread. The reason is that del_timer() will return directly regardless of whether the timer handler is running or not and the worker could be rescheduled in the timer handler. As a result, the UAF bug will happen. The racy situation is shown below:
(Thread 1) | (Thread 2)
snd_aicapcm_pcm_close() |
... | run_spu_dma() //worker
| mod_timer()
flush_work() |
del_timer() | aica_period_elapsed() //timer
kfree(dreamcastcard->channel) | schedule_work()
| run_spu_dma() //worker
... | dreamcastcard->channel-> //USEIn order to mitigate this bug and other possible corner cases, call mod_timer() conditionally in run_spu_dma(), then implement PCM sync_stop op to cancel both the timer and worker. The sync_stop op will be called from PCM core appropriately when needed.
Message-ID: <[email protected]>
--- sound/sh/aica.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
sound/sh/aica.c +14 -3
@@ -278,7 +278,8 @@ static void run_spu_dma(struct work_stru dreamcastcard->clicks++;if (unlikely (dreamcastcard->clicks >=AICA_PERIOD_NUMBER )) dreamcastcard->clicks %=AICA_PERIOD_NUMBER ; -mod_timer (&dreamcastcard->timer, jiffies +1 ); +if (snd_pcm_running (dreamcastcard->substream)) +mod_timer (&dreamcastcard->timer, jiffies +1 ); } }
@@ -290,6 +291,8 @@ static void aica_period_elapsed(struct t/*timer function - so cannot sleep */ int play_period;struct snd_pcm_runtime *runtime; +if (!snd_pcm_running (substream)) +return ; runtime = substream->runtime; dreamcastcard = substream->pcm->private_data;/* Have we played out an additional period? */
@@ -350,12 +353,19 @@ static int snd_aicapcm_pcm_open(struct sreturn 0 ; } +static int snd_aicapcm_pcm_sync_stop (struct snd_pcm_substream *substream) +{ +struct snd_card_aica *dreamcastcard = substream->pcm->private_data; + +del_timer_sync (&dreamcastcard->timer); +cancel_work_sync (&dreamcastcard->spu_dma_work); +return 0 ; +} +static int snd_aicapcm_pcm_close (struct snd_pcm_substream *substream) {struct snd_card_aica *dreamcastcard = substream->pcm->private_data; -flush_work (&(dreamcastcard->spu_dma_work)); -del_timer (&dreamcastcard->timer); dreamcastcard->substream =NULL ;kfree (dreamcastcard->channel);spu_disable ();
@@ -401,6 +411,7 @@ static const struct snd_pcm_ops snd_aica .prepare = snd_aicapcm_pcm_prepare, .trigger = snd_aicapcm_pcm_trigger, .pointer = snd_aicapcm_pcm_pointer, + .sync_stop = snd_aicapcm_pcm_sync_stop, };/* TO DO: set up to handle more than one pcm instance */
Greg Kroah-Hartman
maintainerPATCH 389/432 scsi: ufs: qcom: Provide default cycles_in_1us value
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
commit 81e2c1a0f8d3f62f4c9e80b20270aa3481c40524 upstream.
The MSM8996 DT doesn't provide frequency limits for the core_clk_unipro clock, which results in miscalculation of the cycles_in_1us value. Provide the backwards-compatible default to support existing MSM8996 DT files.
--- drivers/ufs/host/ufs-qcom.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/ufs/host/ufs-qcom.c +4 -2
@@ -1397,8 +1397,10 @@ static int ufs_qcom_set_core_clk_ctrl(stlist_for_each_entry (clki, head, list) {if (!IS_ERR_OR_NULL (clki->clk) && - !strcmp (clki->name,"core_clk_unipro" )) { -if (is_scale_up) + !strcmp (clki->name,"core_clk_unipro" )) { +if (!clki->max_freq) + cycles_in_1us =150 ;/* default for backwards compatibility */ +else if (is_scale_up) cycles_in_1us =ceil (clki->max_freq, (1000 *1000 ));else cycles_in_1us =ceil (clk_get_rate (clki->clk), (1000 *1000 ));
Greg Kroah-Hartman
maintainerPATCH 390/432 scsi: sd: Fix TCG OPAL unlock on system resume
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
commit 0c76106cb97548810214def8ee22700bbbb90543 upstream.
Commit 3cc2ffe5c16d ("scsi: sd: Differentiate system and runtime start/stop management") introduced the manage_system_start_stop scsi_device flag to allow libata to indicate to the SCSI disk driver that nothing should be done when resuming a disk on system resume. This change turned the execution of sd_resume() into a no-op for ATA devices on system resume. While this solved deadlock issues during device resume, this change also wrongly removed the execution of opal_unlock_from_suspend(). As a result, devices with TCG OPAL locking enabled remain locked and inaccessible after a system resume from sleep.
To fix this issue, introduce the SCSI driver resume method and implement it with the sd_resume() function calling opal_unlock_from_suspend(). The former sd_resume() function is renamed to sd_resume_common() and modified to call the new sd_resume() function. For non-ATA devices, this result in no functional changes.
In order for libata to explicitly execute sd_resume() when a device is resumed during system restart, the function scsi_resume_device() is introduced. libata calls this function from the revalidation work executed on devie resume, a state that is indicated with the new device flag ATA_DFLAG_RESUMING. Doing so, locked TCG OPAL enabled devices are unlocked on resume, allowing normal operation.
--- drivers/ata/libata-eh.c | 5 ++++- drivers/ata/libata-scsi.c | 9 +++++++++ drivers/scsi/scsi_scan.c | 34 ++++++++++++++++++++++++++++++++++ drivers/scsi/sd.c | 23 +++++++++++++++++++---- include/linux/libata.h | 1 + include/scsi/scsi_driver.h | 1 + include/scsi/scsi_host.h | 1 + 7 files changed, 69 insertions(+), 5 deletions(-)
drivers/ata/libata-eh.c +4 -1
@@ -712,8 +712,10 @@ void ata_scsi_port_error_handler(struct ehc->saved_ncq_enabled |=1 << devno;/* If we are resuming, wake up the device */ -if (ap->pflags &ATA_PFLAG_RESUMING ) +if (ap->pflags &ATA_PFLAG_RESUMING ) { + dev->flags |=ATA_DFLAG_RESUMING ; ehc->i.dev_action[devno] |=ATA_EH_SET_ACTIVE ; + } } }
@@ -3169,6 +3171,7 @@ static int ata_eh_revalidate_and_attach(return 0 ; err: + dev->flags &= ~ATA_DFLAG_RESUMING ; *r_failed_dev = dev;return rc; }
drivers/ata/libata-scsi.c +9 -0
@@ -4730,6 +4730,7 @@ void ata_scsi_dev_rescan(struct work_strstruct ata_link *link;struct ata_device *dev;unsigned long flags; +bool do_resume;int ret =0 ;mutex_lock (&ap->scsi_scan_mutex);
@@ -4751,7 +4752,15 @@ void ata_scsi_dev_rescan(struct work_strif (scsi_device_get (sdev))continue ; + do_resume = dev->flags &ATA_DFLAG_RESUMING ; +spin_unlock_irqrestore (ap->lock, flags); +if (do_resume) { + ret =scsi_resume_device (sdev); +if (ret == -EWOULDBLOCK ) + goto unlock; + dev->flags &= ~ATA_DFLAG_RESUMING ; + } ret =scsi_rescan_device (sdev);scsi_device_put (sdev);spin_lock_irqsave (ap->lock, flags);
drivers/scsi/scsi_scan.c +34 -0
@@ -1619,6 +1619,40 @@ int scsi_add_device(struct Scsi_Host *ho }EXPORT_SYMBOL (scsi_add_device); +int scsi_resume_device (struct scsi_device *sdev) +{ +struct device *dev = &sdev->sdev_gendev; +int ret =0 ; + +device_lock (dev); + +/* +* Bail out if the device or its queue are not running. Otherwise, +* the rescan may block waiting for commands to be executed, with us +* holding the device lock. This can result in a potential deadlock +* in the power management core code when system resume is on-going. +*/ +if (sdev->sdev_state !=SDEV_RUNNING || +blk_queue_pm_only (sdev->request_queue)) { + ret = -EWOULDBLOCK ; + goto unlock; + } + +if (dev->driver &&try_module_get (dev->driver->owner)) { +struct scsi_driver *drv =to_scsi_driver (dev->driver); + +if (drv->resume) + ret = drv->resume (dev); +module_put (dev->driver->owner); + } + +unlock: +device_unlock (dev); + +return ret; +} +EXPORT_SYMBOL (scsi_resume_device); +int scsi_rescan_device (struct scsi_device *sdev) {struct device *dev = &sdev->sdev_gendev;
drivers/scsi/sd.c +19 -4
@@ -3948,7 +3948,21 @@ static int sd_suspend_runtime(struct devreturn sd_suspend_common (dev, true); } -static int sd_resume (struct device *dev,bool runtime) +static int sd_resume (struct device *dev) +{ +struct scsi_disk *sdkp =dev_get_drvdata (dev); + +sd_printk (KERN_NOTICE , sdkp,"Starting disk\n" ); + +if (opal_unlock_from_suspend (sdkp->opal_dev)) { +sd_printk (KERN_NOTICE , sdkp,"OPAL unlock failed\n" ); +return -EIO ; + } + +return 0 ; +} + +static int sd_resume_common (struct device *dev,bool runtime) {struct scsi_disk *sdkp =dev_get_drvdata (dev);int ret;
@@ -3964,7 +3978,7 @@ static int sd_resume(struct device *dev,sd_printk (KERN_NOTICE , sdkp,"Starting disk\n" ); ret =sd_start_stop_device (sdkp,1 );if (!ret) { -opal_unlock_from_suspend (sdkp->opal_dev); +sd_resume (dev); sdkp->suspended = false; }
@@ -3983,7 +3997,7 @@ static int sd_resume_system(struct devicreturn 0 ; } -return sd_resume (dev, false); +return sd_resume_common (dev, false); }static int sd_resume_runtime (struct device *dev)
@@ -4010,7 +4024,7 @@ static int sd_resume_runtime(struct devi "Failed to clear sense data\n"); } -return sd_resume (dev, true); +return sd_resume_common (dev, true); }static const struct dev_pm_ops sd_pm_ops = {
@@ -4033,6 +4047,7 @@ static struct scsi_driver sd_template = .pm = &sd_pm_ops, }, .rescan = sd_rescan, + .resume = sd_resume, .init_command = sd_init_command, .uninit_command = sd_uninit_command, .done = sd_done,
include/linux/libata.h +1 -0
@@ -107,6 +107,7 @@ enum {ATA_DFLAG_NCQ_PRIO_ENABLED = (1 <<20 ),/* Priority cmds sent to dev */ ATA_DFLAG_CDL_ENABLED = (1 <<21 ),/* cmd duration limits is enabled */ +ATA_DFLAG_RESUMING = (1 <<22 ),/* Device is resuming */ ATA_DFLAG_DETACH = (1 <<24 ),ATA_DFLAG_DETACHED = (1 <<25 ), ATA_DFLAG_DA = (1 << 26), /* device supports Device Attention */
include/scsi/scsi_driver.h +1 -0
@@ -12,6 +12,7 @@ struct request;struct scsi_driver {struct device_driver gendrv; +int (*resume)(struct device *);void (*rescan)(struct device *);blk_status_t (*init_command)(struct scsi_cmnd *);void (*uninit_command)(struct scsi_cmnd *);
include/scsi/scsi_host.h +1 -0
@@ -767,6 +767,7 @@ scsi_template_proc_dir(const struct scsi#define scsi_template_proc_dir (sht) NULL#endif extern void scsi_scan_host (struct Scsi_Host *); +extern int scsi_resume_device (struct scsi_device *sdev);extern int scsi_rescan_device (struct scsi_device *sdev);extern void scsi_remove_host (struct Scsi_Host *);extern struct Scsi_Host *scsi_host_get (struct Scsi_Host *);
Greg Kroah-Hartman
maintainerPATCH 391/432 scsi: sg: Avoid sg device teardown race
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Wetzel <[email protected]>
commit 27f58c04a8f438078583041468ec60597841284d upstream.
sg_remove_sfp_usercontext() must not use sg_device_destroy() after calling scsi_device_put().
sg_device_destroy() is accessing the parent scsi_device request_queue which will already be set to NULL when the preceding call to scsi_device_put() removed the last reference to the parent scsi_device.
The resulting NULL pointer exception will then crash the kernel.
--- drivers/scsi/sg.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/scsi/sg.c +3 -1
@@ -2207,6 +2207,7 @@ sg_remove_sfp_usercontext(struct work_st { struct sg_fd *sfp = container_of(work, struct sg_fd, ew.work);struct sg_device *sdp = sfp->parentdp; +struct scsi_device *device = sdp->device;Sg_request *srp;unsigned long iflags;
@@ -2232,8 +2233,9 @@ sg_remove_sfp_usercontext(struct work_st "sg_remove_sfp: sfp=0x%p\n", sfp));kfree (sfp); -scsi_device_put (sdp->device); +WARN_ON_ONCE (kref_read (&sdp->d_ref) !=1 );kref_put (&sdp->d_ref, sg_device_destroy); +scsi_device_put (device);module_put (THIS_MODULE ); }
Greg Kroah-Hartman
maintainerPATCH 392/432 scsi: core: Fix unremoved procfs host directory regression
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guilherme G. Piccoli <[email protected]>
commit f23a4d6e07570826fe95023ca1aa96a011fa9f84 upstream.
Commit fc663711b944 ("scsi: core: Remove the /proc/scsi/${proc_name} directory earlier") fixed a bug related to modules loading/unloading, by adding a call to scsi_proc_hostdir_rm() on scsi_remove_host(). But that led to a potential duplicate call to the hostdir_rm() routine, since it's also called from scsi_host_dev_release(). That triggered a regression report, which was then fixed by commit be03df3d4bfe ("scsi: core: Fix a procfs host directory removal regression"). The fix just dropped the hostdir_rm() call from dev_release().
But it happens that this proc directory is created on scsi_host_alloc(), and that function "pairs" with scsi_host_dev_release(), while scsi_remove_host() pairs with scsi_add_host(). In other words, it seems the reason for removing the proc directory on dev_release() was meant to cover cases in which a SCSI host structure was allocated, but the call to scsi_add_host() didn't happen. And that pattern happens to exist in some error paths, for example.
Syzkaller causes that by using USB raw gadget device, error'ing on usb-storage driver, at usb_stor_probe2(). By checking that path, we can see that the BadDevice label leads to a scsi_host_put() after a SCSI host allocation, but there's no call to scsi_add_host() in such path. That leads to messages like this in dmesg (and a leak of the SCSI host proc structure):
usb-storage 4-1:87.51: USB Mass Storage device detected proc_dir_entry 'scsi/usb-storage' already registered
WARNING: CPU: 1 PID: 3519 at fs/proc/generic.c:377 proc_register+0x347/0x4e0 fs/proc/generic.c:376
The proper fix seems to still call scsi_proc_hostdir_rm() on dev_release(), but guard that with the state check for SHOST_CREATED; there is even a comment in scsi_host_dev_release() detailing that: such conditional is meant for cases where the SCSI host was allocated but there was no calls to {add,remove}_host(), like the usb-storage case.
This is what we propose here and with that, the error path of usb-storage does not trigger the warning anymore.
--- drivers/scsi/hosts.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/scsi/hosts.c +4 -3
@@ -353,12 +353,13 @@ static void scsi_host_dev_release(structif (shost->shost_state ==SHOST_CREATED ) {/* -* Free the shost_dev device name here if scsi_host_alloc() -* and scsi_host_put() have been called but neither +* Free the shost_dev device name and remove the proc host dir +* here if scsi_host_{alloc,put}() have been called but neither * scsi_host_add() nor scsi_remove_host() has been called. * This avoids that the memory allocated for the shost_dev -* name is leaked. +* name as well as the proc dir structure are leaked. */ +scsi_proc_hostdir_rm (shost->hostt);kfree (dev_name (&shost->shost_dev)); }
Greg Kroah-Hartman
maintainerPATCH 393/432 staging: vc04_services: changen strncpy() to strscpy_pad()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit ef25725b7f8aaffd7756974d3246ec44fae0a5cf upstream.
gcc-14 warns about this strncpy() that results in a non-terminated string for an overflow:
In file included from include/linux/string.h:369,
from drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c:20:
In function 'strncpy',
inlined from 'create_component' at drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c:940:2:include/linux/fortify-string.h:108:33: error: '__builtin_strncpy' specified bound 128 equals destination size [-Werror=stringop-truncation]
Change it to strscpy_pad(), which produces a properly terminated and zero-padded string.
--- drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +2 -2
@@ -937,8 +937,8 @@ static int create_component(struct vchiq/* build component create message */ m.h.type =MMAL_MSG_TYPE_COMPONENT_CREATE ; m.u.component_create.client_component = component->client_component; -strncpy (m.u.component_create.name, name, -sizeof (m.u.component_create.name)); +strscpy_pad (m.u.component_create.name, name, +sizeof (m.u.component_create.name)); ret = send_synchronous_mmal_msg(instance, &m, sizeof(m.u.component_create),
Greg Kroah-Hartman
maintainerPATCH 394/432 staging: vc04_services: fix information leak in create_component()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit f37e76abd614b68987abc8e5c22d986013349771 upstream.
The m.u.component_create.pid field is for debugging and in the mainline kernel it's not used anything. However, it still needs to be set to something to prevent disclosing uninitialized stack data. Set it to zero.
--- drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 1 + 1 file changed, 1 insertion(+)
drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +1 -0
@@ -939,6 +939,7 @@ static int create_component(struct vchiq m.u.component_create.client_component = component->client_component;strscpy_pad (m.u.component_create.name, name,sizeof (m.u.component_create.name)); + m.u.component_create.pid =0 ; ret = send_synchronous_mmal_msg(instance, &m, sizeof(m.u.component_create),
Greg Kroah-Hartman
maintainerPATCH 395/432 usb: dwc3: Properly set system wakeup
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thinh Nguyen <[email protected]>
commit f9aa41130ac69d13a53ce2a153ca79c70d43f39c upstream.
If the device is configured for system wakeup, then make sure that the xHCI driver knows about it and make sure to permit wakeup only at the appropriate time.
For host mode, if the controller goes through the dwc3 code path, then a child xHCI platform device is created. Make sure the platform device also inherits the wakeup setting for xHCI to enable remote wakeup.
For device mode, make sure to disable system wakeup if no gadget driver is bound. We may experience unwanted system wakeup due to the wakeup signal from the controller PMU detecting connection/disconnection when in low power (D3). E.g. In the case of Steam Deck, the PCI PME prevents the system staying in suspend.
--- drivers/usb/dwc3/core.c | 2 ++ drivers/usb/dwc3/core.h | 2 ++ drivers/usb/dwc3/gadget.c | 10 ++++++++++ drivers/usb/dwc3/host.c | 11 +++++++++++ 4 files changed, 25 insertions(+)
drivers/usb/dwc3/core.c +2 -0
@@ -1507,6 +1507,8 @@ static void dwc3_get_properties(struct delse dwc->sysdev = dwc->dev; + dwc->sys_wakeup =device_may_wakeup (dwc->sysdev); + ret =device_property_read_string (dev,"usb-psy-name" , &usb_psy_name);if (ret >=0 ) { dwc->usb_psy =power_supply_get_by_name (usb_psy_name);
drivers/usb/dwc3/core.h +2 -0
@@ -1127,6 +1127,7 @@ struct dwc3_scratchpad_array {* 3 - Reserved * @dis_metastability_quirk: set to disable metastability quirk. * @dis_split_quirk: set to disable split boundary. +* @sys_wakeup: set if the device may do system wakeup. * @wakeup_configured: set if the device is configured for remote wakeup. * @suspended: set to track suspend event due to U3/L2. * @imod_interval: set the interrupt moderation interval in 250ns
@@ -1350,6 +1351,7 @@ struct dwc3 { unsigned dis_split_quirk:1; unsigned async_callbacks:1; + unsigned sys_wakeup:1; unsigned wakeup_configured:1; unsigned suspended:1;
drivers/usb/dwc3/gadget.c +10 -0
@@ -2968,6 +2968,9 @@ static int dwc3_gadget_start(struct usb_ dwc->gadget_driver = driver;spin_unlock_irqrestore (&dwc->lock, flags); +if (dwc->sys_wakeup) +device_wakeup_enable (dwc->sysdev); +return 0 ; }
@@ -2983,6 +2986,9 @@ static int dwc3_gadget_stop(struct usb_gstruct dwc3 *dwc =gadget_to_dwc (g);unsigned long flags; +if (dwc->sys_wakeup) +device_wakeup_disable (dwc->sysdev); +spin_lock_irqsave (&dwc->lock, flags); dwc->gadget_driver =NULL ; dwc->max_cfg_eps =0 ;
@@ -4664,6 +4670,10 @@ int dwc3_gadget_init(struct dwc3 *dwc)else dwc3_gadget_set_speed (dwc->gadget, dwc->maximum_speed); +/* No system wakeup if no gadget driver bound */ +if (dwc->sys_wakeup) +device_wakeup_disable (dwc->sysdev); +return 0 ; err5:
drivers/usb/dwc3/host.c +11 -0
@@ -123,6 +123,14 @@ int dwc3_host_init(struct dwc3 *dwc) goto err; } +if (dwc->sys_wakeup) { +/* Restore wakeup setting if switched from device */ +device_wakeup_enable (dwc->sysdev); + +/* Pass on wakeup setting to the new xhci platform device */ +device_init_wakeup (&xhci->dev, true); + } +return 0 ; err:platform_device_put (xhci);
@@ -131,6 +139,9 @@ err:void dwc3_host_exit (struct dwc3 *dwc) { +if (dwc->sys_wakeup) +device_init_wakeup (&dwc->xhci->dev, false); +platform_device_unregister (dwc->xhci); dwc->xhci =NULL ; }
Greg Kroah-Hartman
maintainerPATCH 396/432 USB: core: Fix deadlock in usb_deauthorize_interface()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit 80ba43e9f799cbdd83842fc27db667289b3150f5 upstream.
Among the attribute file callback routines in drivers/usb/core/sysfs.c, the interface_authorized_store() function is the only one which acquires a device lock on an ancestor device: It calls usb_deauthorize_interface(), which locks the interface's parent USB device.
The will lead to deadlock if another process already owns that lock and tries to remove the interface, whether through a configuration change or because the device has been disconnected. As part of the removal procedure, device_del() waits for all ongoing sysfs attribute callbacks to complete. But usb_deauthorize_interface() can't complete until the device lock has been released, and the lock won't be released until the removal has finished.
The mechanism provided by sysfs to prevent this kind of deadlock is to use the sysfs_break_active_protection() function, which tells sysfs not to wait for the attribute callback.
Reported-and-tested by: Yue Sun <[email protected]> Reported by: xingwei lee <[email protected]>
--- drivers/usb/core/sysfs.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/usb/core/sysfs.c +13 -3
@@ -1168,14 +1168,24 @@ static ssize_t interface_authorized_stor {struct usb_interface *intf =to_usb_interface (dev);bool val; +struct kernfs_node *kn;if (kstrtobool (buf, &val) !=0 )return -EINVAL ; -if (val) +if (val) {usb_authorize_interface (intf); -else -usb_deauthorize_interface (intf); + }else { +/* +* Prevent deadlock if another process is concurrently +* trying to unregister intf. +*/ + kn =sysfs_break_active_protection (&dev->kobj, &attr->attr); +if (kn) { +usb_deauthorize_interface (intf); +sysfs_unbreak_active_protection (kn); + } + }return count; }
Greg Kroah-Hartman
maintainerPATCH 397/432 USB: core: Add hub_get() and hub_put() routines
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit ee113b860aa169e9a4d2c167c95d0f1961c6e1b8 upstream.
Create hub_get() and hub_put() routines to encapsulate the kref_get() and kref_put() calls in hub.c. The new routines will be used by the next patch in this series.
--- drivers/usb/core/hub.c | 23 ++++++++++++++++------- drivers/usb/core/hub.h | 2 ++ 2 files changed, 18 insertions(+), 7 deletions(-)
drivers/usb/core/hub.c +16 -7
@@ -123,7 +123,6 @@ EXPORT_SYMBOL_GPL(ehci_cf_port_reset_rws#define HUB_DEBOUNCE_STEP 25#define HUB_DEBOUNCE_STABLE 100 -static void hub_release (struct kref *kref);static int usb_reset_and_verify_device (struct usb_device *udev);static int hub_port_disable (struct usb_hub *hub,int port1,int set_state); static bool hub_port_warm_reset_required(struct usb_hub *hub, int port1,
@@ -685,14 +684,14 @@ static void kick_hub_wq(struct usb_hub **/ intf =to_usb_interface (hub->intfdev);usb_autopm_get_interface_no_resume (intf); -kref_get (&hub->kref); +hub_get (hub);if (queue_work (hub_wq, &hub->events))return ;/* the work has already been scheduled */ usb_autopm_put_interface_async (intf); -kref_put (&hub->kref, hub_release); +hub_put (hub); }void usb_kick_hub_wq (struct usb_device *hdev)
@@ -1060,7 +1059,7 @@ static void hub_activate(struct usb_hub goto init2; goto init3; } -kref_get (&hub->kref); +hub_get (hub);/* The superspeed hub except for root hub has to use Hub Depth * value as an offset into the route string to locate the bits
@@ -1308,7 +1307,7 @@ static void hub_activate(struct usb_hubdevice_unlock (&hdev->dev); } -kref_put (&hub->kref, hub_release); +hub_put (hub); }/* Implement the continuations for the delays above */
@@ -1724,6 +1723,16 @@ static void hub_release(struct kref *krekfree (hub); } +void hub_get (struct usb_hub *hub) +{ +kref_get (&hub->kref); +} + +void hub_put (struct usb_hub *hub) +{ +kref_put (&hub->kref, hub_release); +} +static unsigned highspeed_hubs;static void hub_disconnect (struct usb_interface *intf)
@@ -1772,7 +1781,7 @@ static void hub_disconnect(struct usb_inonboard_hub_destroy_pdevs (&hub->onboard_hub_devs); -kref_put (&hub->kref, hub_release); +hub_put (hub); }static bool hub_descriptor_is_sane (struct usb_host_interface *desc)
@@ -5894,7 +5903,7 @@ out_hdev_lock:/* Balance the stuff in kick_hub_wq() and allow autosuspend */ usb_autopm_put_interface (intf); -kref_put (&hub->kref, hub_release); +hub_put (hub);kcov_remote_stop (); }
drivers/usb/core/hub.h +2 -0
@@ -129,6 +129,8 @@ extern void usb_hub_remove_port_device(sextern int usb_hub_set_port_power (struct usb_device *hdev,struct usb_hub *hub,int port1,bool set);extern struct usb_hub *usb_hub_to_struct_hub (struct usb_device *hdev); +extern void hub_get (struct usb_hub *hub); +extern void hub_put (struct usb_hub *hub);extern int hub_port_debounce (struct usb_hub *hub,int port1,bool must_be_connected); extern int usb_clear_port_feature(struct usb_device *hdev,
Greg Kroah-Hartman
maintainerPATCH 398/432 USB: core: Fix deadlock in port "disable" sysfs attribute
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit f4d1960764d8a70318b02f15203a1be2b2554ca1 upstream.
The show and store callback routines for the "disable" sysfs attribute file in port.c acquire the device lock for the port's parent hub device. This can cause problems if another process has locked the hub to remove it or change its configuration:
Removing the hub or changing its configuration requires the hub interface to be removed, which requires the port device to be removed, and device_del() waits until all outstanding sysfs attribute callbacks for the ports have returned. The lock can't be released until then.
But the disable_show() or disable_store() routine can't return until after it has acquired the lock.
The resulting deadlock can be avoided by calling sysfs_break_active_protection(). This will cause the sysfs core not to wait for the attribute's callback routine to return, allowing the removal to proceed. The disadvantage is that after making this call, there is no guarantee that the hub structure won't be deallocated at any moment. To prevent this, we have to acquire a reference to it first by calling hub_get().
--- drivers/usb/core/port.c | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-)
drivers/usb/core/port.c +34 -4
@@ -55,11 +55,22 @@ static ssize_t disable_show(struct devicu16 portstatus, unused;bool disabled;int rc; +struct kernfs_node *kn; +hub_get (hub); rc =usb_autopm_get_interface (intf);if (rc <0 ) -return rc; + goto out_hub_get; +/* +* Prevent deadlock if another process is concurrently +* trying to unregister hdev. +*/ + kn =sysfs_break_active_protection (&dev->kobj, &attr->attr); +if (!kn) { + rc = -ENODEV ; + goto out_autopm; + }usb_lock_device (hdev);if (hub->disconnected) { rc = -ENODEV ;
@@ -69,9 +80,13 @@ static ssize_t disable_show(struct devicusb_hub_port_status (hub, port1, &portstatus, &unused); disabled = !usb_port_is_power_on (hub, portstatus); -out_hdev_lock: + out_hdev_lock:usb_unlock_device (hdev); +sysfs_unbreak_active_protection (kn); + out_autopm:usb_autopm_put_interface (intf); + out_hub_get: +hub_put (hub);if (rc)return rc;
@@ -89,15 +104,26 @@ static ssize_t disable_store(struct deviint port1 = port_dev->portnum;bool disabled;int rc; +struct kernfs_node *kn; rc =kstrtobool (buf, &disabled);if (rc)return rc; +hub_get (hub); rc =usb_autopm_get_interface (intf);if (rc <0 ) -return rc; + goto out_hub_get; +/* +* Prevent deadlock if another process is concurrently +* trying to unregister hdev. +*/ + kn =sysfs_break_active_protection (&dev->kobj, &attr->attr); +if (!kn) { + rc = -ENODEV ; + goto out_autopm; + }usb_lock_device (hdev);if (hub->disconnected) { rc = -ENODEV ;
@@ -118,9 +144,13 @@ static ssize_t disable_store(struct deviif (!rc) rc = count; -out_hdev_lock: + out_hdev_lock:usb_unlock_device (hdev); +sysfs_unbreak_active_protection (kn); + out_autopm:usb_autopm_put_interface (intf); + out_hub_get: +hub_put (hub);return rc; }