tools: iio: replace seekdir() in iio_generic_buffer
Subsystems (12)
Sasha Levin
maintainerPATCH 1/28 tools: iio: replace seekdir() in iio_generic_buffer
From: Petre Rodan <[email protected]>
[ Upstream commit 4e6500bfa053dc133021f9c144261b77b0ba7dc8 ]
Replace seekdir() with rewinddir() in order to fix a localized glibc bug.
One of the glibc patches that stable Gentoo is using causes an improper directory stream positioning bug on 32bit arm. That in turn ends up as a floating point exception in iio_generic_buffer.
The attached patch provides a fix by using an equivalent function which should not cause trouble for other distros and is easier to reason about in general as it obviously always goes back to to the start.
https://sourceware.org/bugzilla/show_bug.cgi?id=31212
--- tools/iio/iio_utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/iio/iio_utils.c +1 -1
@@ -376,7 +376,7 @@ int build_channel_array(const char *device_dir, int buffer_idx, goto error_close_dir; } -seekdir (dp,0 ); +rewinddir (dp);while (ent =readdir (dp), ent) {if (strcmp (ent->d_name +strlen (ent->d_name) -strlen ("_en" ),"_en" ) ==0 ) {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 2/28 usb: storage: sddr55: fix sloppy typing in sddr55_{read|write}_data()
From: Karina Yankevich <[email protected]>
[ Upstream commit d6429a3555fb29f380c5841a12f5ac3f7444af03 ]
In sddr55_{read|write}_data(), the address variables are needlessly typed as *unsigned long* -- which is 32-bit type on the 32-bit arches and 64-bit type on the 64-bit arches; those variables' value should fit into just 3 command bytes and consists of 10-bit block # (or at least the max block # seems to be 1023) and 4-/5-bit page # within a block, so 32-bit *unsigned* *int* type should be more than enough...
Found by Linux Verification Center (linuxtesting.org) with the Svace static analysis tool.
[Sergey: rewrote the patch subject/description]
--- drivers/usb/storage/sddr55.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/storage/sddr55.c +2 -2
@@ -196,7 +196,7 @@ static int sddr55_read_data(struct us_data *us,unsigned char *buffer;unsigned int pba; -unsigned long address; +unsigned int address;unsigned short pages;unsigned int len, offset;
@@ -316,7 +316,7 @@ static int sddr55_write_data(struct us_data *us,unsigned int pba;unsigned int new_pba; -unsigned long address; +unsigned int address;unsigned short pages;int i;
Signature · 1 line
2.43.0
Re: [PATCH AUTOSEL 6.8 02/28] usb: storage: sddr55: fix sloppy typing in sddr55_{read|write}_data()
Quoted 14 lines · Sasha Levin
From: Karina Yankevich <[email protected]>
[ Upstream commit
d6429a3555fb29f380c5841a12f5ac3f7444af03]In sddr55_{read|write}_data(), the address variables are needlessly typed as *unsigned long* -- which is 32-bit type on the 32-bit arches and 64-bit type on the 64-bit arches; those variables' value should fit into just 3 command bytes and consists of 10-bit block # (or at least the max block # seems to be 1023) and 4-/5-bit page # within a block, so 32-bit *unsigned* *int* type should be more than enough...
Found by Linux Verification Center (linuxtesting.org) with the Svace static analysis tool.
Quoted 8 lines
[Sergey: rewrote the patch subject/description]
Signed-off-by Karina Yankevich <[email protected]>Signed-off-by Sergey Shtylyov <[email protected]>Reviewed-by Alan Stern <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Sasha Levin <[email protected]>
[...]
I doubt this is worth pulling into the stable kernels, it
does not fix any serious issue...
MBR, Sergey
Sasha Levin
maintainerRe: [PATCH AUTOSEL 6.8 02/28] usb: storage: sddr55: fix sloppy typing in sddr55_{read|write}_data()
Quoted 25 lines · Sergey Shtylyov
Quoted 14 lines · Sasha Levin
From: Karina Yankevich <[email protected]>
[ Upstream commit
d6429a3555fb29f380c5841a12f5ac3f7444af03]In sddr55_{read|write}_data(), the address variables are needlessly typed as *unsigned long* -- which is 32-bit type on the 32-bit arches and 64-bit type on the 64-bit arches; those variables' value should fit into just 3 command bytes and consists of 10-bit block # (or at least the max block # seems to be 1023) and 4-/5-bit page # within a block, so 32-bit *unsigned* *int* type should be more than enough...
Found by Linux Verification Center (linuxtesting.org) with the Svace static analysis tool.
Quoted 8 lines
[Sergey: rewrote the patch subject/description]
Signed-off-by Karina Yankevich <[email protected]>Signed-off-by Sergey Shtylyov <[email protected]>Reviewed-by Alan Stern <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Sasha Levin <[email protected]>
Quoted 4 lines
[...]
I doubt this is worth pulling into the stable kernels, it
does not fix any serious issue...
Dropped, thanks!
Signature · 2 lines
Thanks, Sasha
Sasha Levin
maintainerPATCH 3/28 serial: qcom-geni: Don't cancel/abort if we can't get the port lock
In reply to Sasha LevinFrom: Douglas Anderson <[email protected]>
[ Upstream commit 9e957a155005b16af057e86c6bcc1197cd70a6af ]
As of commit d7402513c935 ("arm64: smp: IPI_CPU_STOP and IPI_CPU_CRASH_STOP should try for NMI"), if we've got pseudo-NMI enabled then we'll use it to stop CPUs at panic time. This is nice, but it does mean that there's a pretty good chance that we'll end up stopping a CPU while it holds the port lock for the console UART. Specifically, I see a CPU get stopped while holding the port lock nearly 100% of the time on my sc7180-trogdor based Chromebook by enabling the "buddy" hardlockup detector and then doing:
sysctl -w kernel.hardlockup_all_cpu_backtrace=1 sysctl -w kernel.hardlockup_panic=1
echo HARDLOCKUP > /sys/kernel/debug/provoke-crash/DIRECT
UART drivers are _supposed_ to handle this case OK and this is why UART drivers check "oops_in_progress" and only do a "trylock" in that case. However, before we enabled pseudo-NMI to stop CPUs it wasn't a very well-tested situation.
Now that we're testing the situation a lot, it can be seen that the Qualcomm GENI UART driver is pretty broken. Specifically, when I run my test case and look at the console output I just see a bunch of garbled output like:
[ 201.069084] NMI backtrace[ 201.069084] NM[ 201.069087] CPU: 6 PID: 10296 Comm: dnsproxyd Not tainted 6.7.0-06265-gb13e8c0ede12 #1 01112b9f14923cbd0b[ 201.069090] Hardware name: Google Lazor ([ 201.069092] pstate: 80400009 (Nzcv daif +PAN -UAO -TCO -DI[ 201.069095] pc : smp_call_function_man[ 201.069099]
That's obviously not so great. This happens because each call to the console driver exits after the data has been written to the FIFO but before it's actually been flushed out of the serial port. When we have multiple calls into the console one after the other then (if we can't get the lock) each call tells the UART to throw away any data in the FIFO that hadn't been transferred yet.
I've posted up a patch to change the arm64 core to avoid this situation most of the time [1] much like x86 seems to do, but even if that patch lands the GENI driver should still be fixed.
Quoted 1 line
From testing, it appears that we can just delete the cancel/abort in
the case where we weren't able to get the UART lock and the output looks good. It makes sense that we'd be able to do this since that means we'll just call into __qcom_geni_serial_console_write() and __qcom_geni_serial_console_write() looks much like qcom_geni_serial_poll_put_char() but with a loop. However, it seems safest to poll the FIFO and make sure it's empty before our transfer. This should reliably make sure that we're not interrupting/clobbering any existing transfers.
As part of this change, we'll also avoid re-setting up a TX at the end of the console write function if we weren't able to get the lock, since accessing "port->tx_remaining" without the lock is not safe. This is only needed to re-start userspace initiated transfers.
[1] https://lore.kernel.org/r/20231207170251.1.Id4817adef610302554b8aa42b090d57270dc119c@changeid
--- drivers/tty/serial/qcom_geni_serial.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-)
drivers/tty/serial/qcom_geni_serial.c +13 -14
@@ -488,18 +488,16 @@ static void qcom_geni_serial_console_write(struct console *co, const char *s, geni_status =readl (uport->membase +SE_GENI_STATUS ); -/* Cancel the current write to log the fault */ if (!locked) { -geni_se_cancel_m_cmd (&port->se); -if (!qcom_geni_serial_poll_bit (uport,SE_GENI_M_IRQ_STATUS , -M_CMD_CANCEL_EN , true)) { -geni_se_abort_m_cmd (&port->se); -qcom_geni_serial_poll_bit (uport,SE_GENI_M_IRQ_STATUS , -M_CMD_ABORT_EN , true); -writel (M_CMD_ABORT_EN , uport->membase + -SE_GENI_M_IRQ_CLEAR ); - } -writel (M_CMD_CANCEL_EN , uport->membase +SE_GENI_M_IRQ_CLEAR ); +/* +* We can only get here if an oops is in progress then we were +* unable to get the lock. This means we can't safely access +* our state variables like tx_remaining. About the best we +* can do is wait for the FIFO to be empty before we start our +* transfer, so we'll do that. +*/ +qcom_geni_serial_poll_bit (uport,SE_GENI_M_IRQ_STATUS , +M_TX_FIFO_NOT_EMPTY_EN , false); }else if ((geni_status &M_GENI_CMD_ACTIVE ) && !port->tx_remaining) {/* * It seems we can't interrupt existing transfers if all data
@@ -516,11 +514,12 @@ static void qcom_geni_serial_console_write(struct console *co, const char *s,__qcom_geni_serial_console_write (uport, s, count); -if (port->tx_remaining) -qcom_geni_serial_setup_tx (uport, port->tx_remaining); -if (locked) +if (locked) { +if (port->tx_remaining) +qcom_geni_serial_setup_tx (uport, port->tx_remaining);uart_port_unlock_irqrestore (uport, flags); + } }static void handle_rx_console (struct uart_port *uport,u32 bytes,bool drop)
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 4/28 bus: mhi: host: Add MHI_PM_SYS_ERR_FAIL state
In reply to Sasha LevinFrom: Jeffrey Hugo <[email protected]>
[ Upstream commit bce3f770684cc1d91ff9edab431b71ac991faf29 ]
When processing a SYSERR, if the device does not respond to the MHI_RESET from the host, the host will be stuck in a difficult to recover state. The host will remain in MHI_PM_SYS_ERR_PROCESS and not clean up the host channels. Clients will not be notified of the SYSERR via the destruction of their channel devices, which means clients may think that the device is still up. Subsequent SYSERR events such as a device fatal error will not be processed as the state machine cannot transition from PROCESS back to DETECT. The only way to recover from this is to unload the mhi module (wipe the state machine state) or for the mhi controller to initiate SHUTDOWN.
This issue was discovered by stress testing soc_reset events on AIC100 via the sysfs node.
soc_reset is processed entirely in hardware. When the register write hits the endpoint hardware, it causes the soc to reset without firmware involvement. In stress testing, there is a rare race where soc_reset N will cause the soc to reset and PBL to signal SYSERR (fatal error). If soc_reset N+1 is triggered before PBL can process the MHI_RESET from the host, then the soc will reset again, and re-run PBL from the beginning. This will cause PBL to lose all state. PBL will be waiting for the host to respond to the new syserr, but host will be stuck expecting the previous MHI_RESET to be processed.
Additionally, the AMSS EE firmware (QSM) was hacked to synthetically reproduce the issue by simulating a FW hang after the QSM issued a SYSERR. In this case, soc_reset would not recover the device.
For this failure case, to recover the device, we need a state similar to PROCESS, but can transition to DETECT. There is not a viable existing state to use. POR has the needed transitions, but assumes the device is in a good state and could allow the host to attempt to use the device. Allowing PROCESS to transition to DETECT invites the possibility of parallel SYSERR processing which could get the host and device out of sync.
Thus, invent a new state - MHI_PM_SYS_ERR_FAIL
This essentially a holding state. It allows us to clean up the host elements that are based on the old state of the device (channels), but does not allow us to directly advance back to an operational state. It does allow the detection and processing of another SYSERR which may recover the device, or allows the controller to do a clean shutdown.
--- drivers/bus/mhi/host/init.c | 1 + drivers/bus/mhi/host/internal.h | 9 ++++++--- drivers/bus/mhi/host/pm.c | 20 +++++++++++++++++--- 3 files changed, 24 insertions(+), 6 deletions(-)
drivers/bus/mhi/host/init.c +1 -0
@@ -62,6 +62,7 @@ static const char * const mhi_pm_state_str[] = { [MHI_PM_STATE_FW_DL_ERR] = "Firmware Download Error", [MHI_PM_STATE_SYS_ERR_DETECT] = "SYS ERROR Detect", [MHI_PM_STATE_SYS_ERR_PROCESS] = "SYS ERROR Process", + [MHI_PM_STATE_SYS_ERR_FAIL] = "SYS ERROR Failure", [MHI_PM_STATE_SHUTDOWN_PROCESS] = "SHUTDOWN Process", [MHI_PM_STATE_LD_ERR_FATAL_DETECT] = "Linkdown or Error Fatal Detect", };
drivers/bus/mhi/host/internal.h +6 -3
@@ -88,6 +88,7 @@ enum mhi_pm_state {MHI_PM_STATE_FW_DL_ERR ,MHI_PM_STATE_SYS_ERR_DETECT ,MHI_PM_STATE_SYS_ERR_PROCESS , +MHI_PM_STATE_SYS_ERR_FAIL ,MHI_PM_STATE_SHUTDOWN_PROCESS ,MHI_PM_STATE_LD_ERR_FATAL_DETECT ,MHI_PM_STATE_MAX
@@ -104,14 +105,16 @@ enum mhi_pm_state {#define MHI_PM_FW_DL_ERR BIT(7)#define MHI_PM_SYS_ERR_DETECT BIT(8)#define MHI_PM_SYS_ERR_PROCESS BIT(9) -#define MHI_PM_SHUTDOWN_PROCESS BIT(10) +#define MHI_PM_SYS_ERR_FAIL BIT(10) +#define MHI_PM_SHUTDOWN_PROCESS BIT(11)/* link not accessible */ -#define MHI_PM_LD_ERR_FATAL_DETECT BIT(11) +#define MHI_PM_LD_ERR_FATAL_DETECT BIT(12)#define MHI_REG_ACCESS_VALID (pm_state) ((pm_state & (MHI_PM_POR | MHI_PM_M0 | \ MHI_PM_M2 | MHI_PM_M3_ENTER | MHI_PM_M3_EXIT | \ MHI_PM_SYS_ERR_DETECT | MHI_PM_SYS_ERR_PROCESS | \ - MHI_PM_SHUTDOWN_PROCESS | MHI_PM_FW_DL_ERR))) + MHI_PM_SYS_ERR_FAIL | MHI_PM_SHUTDOWN_PROCESS | \ + MHI_PM_FW_DL_ERR)))#define MHI_PM_IN_ERROR_STATE (pm_state) (pm_state >= MHI_PM_FW_DL_ERR)#define MHI_PM_IN_FATAL_STATE (pm_state) (pm_state == MHI_PM_LD_ERR_FATAL_DETECT)#define MHI_DB_ACCESS_VALID (mhi_cntrl) (mhi_cntrl->pm_state & mhi_cntrl->db_access)
drivers/bus/mhi/host/pm.c +17 -3
@@ -36,7 +36,10 @@* M0 <--> M0 * M0 -> FW_DL_ERR * M0 -> M3_ENTER -> M3 -> M3_EXIT --> M0 -* L1: SYS_ERR_DETECT -> SYS_ERR_PROCESS --> POR +* L1: SYS_ERR_DETECT -> SYS_ERR_PROCESS +* SYS_ERR_PROCESS -> SYS_ERR_FAIL +* SYS_ERR_FAIL -> SYS_ERR_DETECT +* SYS_ERR_PROCESS --> POR * L2: SHUTDOWN_PROCESS -> LD_ERR_FATAL_DETECT * SHUTDOWN_PROCESS -> DISABLE * L3: LD_ERR_FATAL_DETECT <--> LD_ERR_FATAL_DETECT
@@ -93,7 +96,12 @@ static const struct mhi_pm_transitions dev_state_transitions[] = { }, {MHI_PM_SYS_ERR_PROCESS , -MHI_PM_POR |MHI_PM_SHUTDOWN_PROCESS | +MHI_PM_POR |MHI_PM_SYS_ERR_FAIL |MHI_PM_SHUTDOWN_PROCESS | +MHI_PM_LD_ERR_FATAL_DETECT + }, + { +MHI_PM_SYS_ERR_FAIL , +MHI_PM_SYS_ERR_DETECT |MHI_PM_SHUTDOWN_PROCESS |MHI_PM_LD_ERR_FATAL_DETECT },/* L2 States */
@@ -629,7 +637,13 @@ static void mhi_pm_sys_error_transition(struct mhi_controller *mhi_cntrl) !in_reset, timeout);if (!ret || in_reset) {dev_err (dev,"Device failed to exit MHI Reset state\n" ); - goto exit_sys_error_transition; +write_lock_irq (&mhi_cntrl->pm_lock); + cur_state =mhi_tryset_pm_state (mhi_cntrl, +MHI_PM_SYS_ERR_FAIL ); +write_unlock_irq (&mhi_cntrl->pm_lock); +/* Shutdown may have occurred, otherwise cleanup now */ +if (cur_state !=MHI_PM_SYS_ERR_FAIL ) + goto exit_sys_error_transition; }/*
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 5/28 kernfs: RCU protect kernfs_nodes and avoid kernfs_idr_lock in kernfs_find_and_get_node_by_id()
In reply to Sasha LevinFrom: Tejun Heo <[email protected]>
[ Upstream commit 4207b556e62f0a8915afc5da4c5d5ad915a253a5 ]
The BPF helper bpf_cgroup_from_id() calls kernfs_find_and_get_node_by_id() which acquires kernfs_idr_lock, which is an non-raw non-IRQ-safe lock. This can lead to deadlocks as bpf_cgroup_from_id() can be called from any BPF programs including e.g. the ones that attach to functions which are holding the scheduler rq lock.
Consider the following BPF program:
SEC("fentry/__set_cpus_allowed_ptr_locked")
int BPF_PROG(__set_cpus_allowed_ptr_locked, struct task_struct *p,
struct affinity_context *affn_ctx, struct rq *rq, struct rq_flags *rf)
{
struct cgroup *cgrp = bpf_cgroup_from_id(p->cgroups->dfl_cgrp->kn->id);
if (cgrp) {
bpf_printk("%d[%s] in %s", p->pid, p->comm, cgrp->kn->name);
bpf_cgroup_release(cgrp);
}
return 0;}
__set_cpus_allowed_ptr_locked() is called with rq lock held and the above BPF program calls bpf_cgroup_from_id() within leading to the following lockdep warning:
=====================================================
WARNING: HARDIRQ-safe -> HARDIRQ-unsafe lock order detected 6.7.0-rc3-work-00053-g07124366a1d7-dirty #147 Not tainted
-----------------------------------------------------
repro/1620 [HC0[0]:SC0[0]:HE0:SE1] is trying to acquire:
ffffffff833b3688 (kernfs_idr_lock){+.+.}-{2:2}, at: kernfs_find_and_get_node_by_id+0x1e/0x70
and this task is already holding:
ffff888237ced698 (&rq->__lock){-.-.}-{2:2}, at: task_rq_lock+0x4e/0xf0 which would create a new lock dependency:
(&rq->__lock){-.-.}-{2:2} -> (kernfs_idr_lock){+.+.}-{2:2}
...
Possible interrupt unsafe locking scenario:
CPU0 CPU1
---- ----
lock(kernfs_idr_lock);
local_irq_disable();
lock(&rq->__lock);
lock(kernfs_idr_lock);
<Interrupt>
lock(&rq->__lock);
*** DEADLOCK ***
...
Call Trace:
dump_stack_lvl+0x55/0x70
dump_stack+0x10/0x20
__lock_acquire+0x781/0x2a40
lock_acquire+0xbf/0x1f0
_raw_spin_lock+0x2f/0x40
kernfs_find_and_get_node_by_id+0x1e/0x70
cgroup_get_from_id+0x21/0x240
bpf_cgroup_from_id+0xe/0x20
bpf_prog_98652316e9337a5a___set_cpus_allowed_ptr_locked+0x96/0x11a
bpf_trampoline_6442545632+0x4f/0x1000
__set_cpus_allowed_ptr_locked+0x5/0x5a0
sched_setaffinity+0x1b3/0x290
__x64_sys_sched_setaffinity+0x4f/0x60
do_syscall_64+0x40/0xe0
entry_SYSCALL_64_after_hwframe+0x46/0x4eLet's fix it by protecting kernfs_node and kernfs_root with RCU and making kernfs_find_and_get_node_by_id() acquire rcu_read_lock() instead of kernfs_idr_lock.
This adds an rcu_head to kernfs_node making it larger by 16 bytes on 64bit. Combined with the preceding rearrange patch, the net increase is 8 bytes.
--- fs/kernfs/dir.c | 31 ++++++++++++++++++++----------- fs/kernfs/kernfs-internal.h | 2 ++ include/linux/kernfs.h | 2 ++ 3 files changed, 24 insertions(+), 11 deletions(-)
fs/kernfs/dir.c +20 -11
@@ -529,6 +529,20 @@ void kernfs_get(struct kernfs_node *kn) }EXPORT_SYMBOL_GPL (kernfs_get); +static void kernfs_free_rcu (struct rcu_head *rcu) +{ + struct kernfs_node *kn = container_of(rcu, struct kernfs_node, rcu); + +kfree_const (kn->name); + +if (kn->iattr) { +simple_xattrs_free (&kn->iattr->xattrs,NULL ); +kmem_cache_free (kernfs_iattrs_cache, kn->iattr); + } + +kmem_cache_free (kernfs_node_cache, kn); +} +/** * kernfs_put - put a reference count on a kernfs_node * @kn: the target kernfs_node
@@ -557,16 +571,11 @@ void kernfs_put(struct kernfs_node *kn)if (kernfs_type (kn) ==KERNFS_LINK )kernfs_put (kn->symlink.target_kn); -kfree_const (kn->name); - -if (kn->iattr) { -simple_xattrs_free (&kn->iattr->xattrs,NULL ); -kmem_cache_free (kernfs_iattrs_cache, kn->iattr); - }spin_lock (&kernfs_idr_lock);idr_remove (&root->ino_idr, (u32 )kernfs_ino (kn));spin_unlock (&kernfs_idr_lock); -kmem_cache_free (kernfs_node_cache, kn); + +call_rcu (&kn->rcu, kernfs_free_rcu); kn = parent;if (kn) {
@@ -575,7 +584,7 @@ void kernfs_put(struct kernfs_node *kn) }else {/* just released the root kn, free @root too */ idr_destroy (&root->ino_idr); -kfree (root); +kfree_rcu (root, rcu); } }EXPORT_SYMBOL_GPL (kernfs_put);
@@ -715,7 +724,7 @@ struct kernfs_node *kernfs_find_and_get_node_by_id(struct kernfs_root *root,ino_t ino =kernfs_id_ino (id);u32 gen =kernfs_id_gen (id); -spin_lock (&kernfs_idr_lock); +rcu_read_lock (); kn =idr_find (&root->ino_idr, (u32 )ino);if (!kn)
@@ -739,10 +748,10 @@ struct kernfs_node *kernfs_find_and_get_node_by_id(struct kernfs_root *root,if (unlikely (!__kernfs_active (kn) || !atomic_inc_not_zero (&kn->count))) goto err_unlock; -spin_unlock (&kernfs_idr_lock); +rcu_read_unlock ();return kn; err_unlock: -spin_unlock (&kernfs_idr_lock); +rcu_read_unlock ();return NULL ; }
fs/kernfs/kernfs-internal.h +2 -0
@@ -49,6 +49,8 @@ struct kernfs_root {struct rw_semaphore kernfs_rwsem;struct rw_semaphore kernfs_iattr_rwsem;struct rw_semaphore kernfs_supers_rwsem; + +struct rcu_head rcu; };/* +1 to avoid triggering overflow warning when negating it */
include/linux/kernfs.h +2 -0
@@ -223,6 +223,8 @@ struct kernfs_node {unsigned short flags;umode_t mode;struct kernfs_iattrs *iattr; + +struct rcu_head rcu; };/*
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 6/28 usb: typec: ucsi: Add qcm6490-pmic-glink as needing PDOS quirk
In reply to Sasha LevinFrom: Luca Weiss <[email protected]>
[ Upstream commit 88bae831f3810e02c9c951233c7ee662aa13dc2c ]
The QCM6490 Linux Android firmware needs this workaround as well. Add it to the list.
--- drivers/usb/typec/ucsi/ucsi_glink.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/typec/ucsi/ucsi_glink.c +1 -0
@@ -298,6 +298,7 @@ static void pmic_glink_ucsi_destroy(void *data) }static const struct of_device_id pmic_glink_ucsi_of_quirks[] = { + { .compatible ="qcom,qcm6490-pmic-glink" , .data = (void *)UCSI_NO_PARTNER_PDOS , }, { .compatible ="qcom,sc8180x-pmic-glink" , .data = (void *)UCSI_NO_PARTNER_PDOS , }, { .compatible ="qcom,sc8280xp-pmic-glink" , .data = (void *)UCSI_NO_PARTNER_PDOS , }, { .compatible ="qcom,sm8350-pmic-glink" , .data = (void *)UCSI_NO_PARTNER_PDOS , },
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 7/28 thunderbolt: Calculate DisplayPort tunnel bandwidth after DPRX capabilities read
In reply to Sasha LevinFrom: Gil Fine <[email protected]>
[ Upstream commit ccd845021147dc8257a05ed8f5a7f9c61a9101e3 ]
According to USB4 Connection Manager guide, after DisplayPort tunnel was setup, the DPRX capabilities read is performed by the DPTX. According to VESA spec, this shall be completed within 5 seconds after the DisplayPort tunnel was setup. Hence, if the bit: DPRX Capabilities Read Done, was not set to '1' by this time, we timeout and fail calculating DisplayPort tunnel consumed bandwidth.
--- drivers/thunderbolt/tunnel.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
drivers/thunderbolt/tunnel.c +6 -10
@@ -1196,17 +1196,13 @@ static int tb_dp_consumed_bandwidth(struct tb_tunnel *tunnel, int *consumed_up,/* * Then see if the DPRX negotiation is ready and if yes * return that bandwidth (it may be smaller than the -* reduced one). Otherwise return the remote (possibly -* reduced) caps. +* reduced one). According to VESA spec, the DPRX +* negotiation shall compete in 5 seconds after tunnel +* established. We give it 100ms extra just in case. */ - ret =tb_dp_wait_dprx (tunnel,150 ); -if (ret) { -if (ret == -ETIMEDOUT ) - ret =tb_dp_read_cap (tunnel,DP_REMOTE_CAP , - &rate, &lanes); -if (ret) -return ret; - } + ret =tb_dp_wait_dprx (tunnel,5100 ); +if (ret) +return ret; ret =tb_dp_read_cap (tunnel,DP_COMMON_CAP , &rate, &lanes);if (ret)return ret;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 8/28 usb: gadget: uvc: refactor the check for a valid buffer in the pump worker
In reply to Sasha LevinFrom: Michael Grzeschik <[email protected]>
[ Upstream commit 5e7ea65daf13a95a6cc63d1377e4c500e4e1340f ]
By toggling the condition check for a valid buffer, the else path can be completely avoided.
--- drivers/usb/gadget/function/uvc_video.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/usb/gadget/function/uvc_video.c +3 -4
@@ -594,10 +594,7 @@ static void uvcg_video_pump(struct work_struct *work)*/ spin_lock_irqsave (&queue->irqlock, flags); buf =uvcg_queue_head (queue); - -if (buf !=NULL ) { - video->encode (req, video, buf); - }else { +if (!buf) {/* * Either the queue has been disconnected or no video buffer * available for bulk transfer. Either way, stop processing
@@ -607,6 +604,8 @@ static void uvcg_video_pump(struct work_struct *work)break ; } + video->encode (req, video, buf); +spin_unlock_irqrestore (&queue->irqlock, flags);spin_lock_irqsave (&video->req_lock, flags);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 9/28 usb: gadget: uvc: mark incomplete frames with UVC_STREAM_ERR
In reply to Sasha LevinFrom: Michael Grzeschik <[email protected]>
[ Upstream commit 2a3b7af120477d0571b815ccb8600cafd5ebf02f ]
If an frame was transmitted incomplete to the host, we set the UVC_STREAM_ERR bit in the header for the last request that is going to be queued. This way the host will know that it should drop the frame instead of trying to display the corrupted content.
--- drivers/usb/gadget/function/uvc_video.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/gadget/function/uvc_video.c +3 -0
@@ -35,6 +35,9 @@ uvc_video_encode_header(struct uvc_video *video, struct uvc_buffer *buf, data[1 ] =UVC_STREAM_EOH | video->fid; +if (video->queue.flags &UVC_QUEUE_DROP_INCOMPLETE ) + data[1 ] |=UVC_STREAM_ERR ; +if (video->queue.buf_used ==0 && ts.tv_sec) {/* dwClockFrequency is 48 MHz */ u32 pts = ((u64 )ts.tv_sec *USEC_PER_SEC + ts.tv_nsec /NSEC_PER_USEC ) *48 ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 10/28 usb: typec: ucsi: Limit read size on v1.2
In reply to Sasha LevinFrom: Abhishek Pandit-Subedi <[email protected]>
[ Upstream commit b3db266fb031fba88c423d4bb8983a73a3db6527 ]
Between UCSI 1.2 and UCSI 2.0, the size of the MESSAGE_IN region was increased from 16 to 256. In order to avoid overflowing reads for older systems, add a mechanism to use the read UCSI version to truncate read sizes on UCSI v1.2.
--- drivers/usb/typec/ucsi/ucsi.c | 26 ++++++++++++++++++++++++-- drivers/usb/typec/ucsi/ucsi.h | 11 +++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-)
drivers/usb/typec/ucsi/ucsi.c +24 -2
@@ -36,6 +36,19 @@*/ #define UCSI_SWAP_TIMEOUT_MS 5000 +static int ucsi_read_message_in (struct ucsi *ucsi,void *buf, +size_t buf_size) +{ +/* +* Below UCSI 2.0, MESSAGE_IN was limited to 16 bytes. Truncate the +* reads here. +*/ +if (ucsi->version <=UCSI_VERSION_1_2 ) + buf_size =clamp (buf_size,0 ,16 ); + +return ucsi->ops->read (ucsi,UCSI_MESSAGE_IN , buf, buf_size); +} +static int ucsi_acknowledge_command (struct ucsi *ucsi) {u64 ctrl;
@@ -72,7 +85,7 @@ static int ucsi_read_error(struct ucsi *ucsi)if (ret <0 )return ret; - ret = ucsi->ops->read (ucsi,UCSI_MESSAGE_IN , &error,sizeof (error)); + ret =ucsi_read_message_in (ucsi, &error,sizeof (error));if (ret)return ret;
@@ -170,7 +183,7 @@ int ucsi_send_command(struct ucsi *ucsi, u64 command, length = ret;if (data) { - ret = ucsi->ops->read (ucsi,UCSI_MESSAGE_IN , data, size); + ret =ucsi_read_message_in (ucsi, data, size);if (ret) goto out; }
@@ -1558,6 +1571,15 @@ int ucsi_register(struct ucsi *ucsi)if (!ucsi->version)return -ENODEV ; +/* +* Version format is JJ.M.N (JJ = Major version, M = Minor version, +* N = sub-minor version). +*/ +dev_dbg (ucsi->dev,"Registered UCSI interface with version %x.%x.%x" , +UCSI_BCD_GET_MAJOR (ucsi->version), +UCSI_BCD_GET_MINOR (ucsi->version), +UCSI_BCD_GET_SUBMINOR (ucsi->version)); +queue_delayed_work (system_long_wq, &ucsi->work,0 );ucsi_debugfs_register (ucsi);
drivers/usb/typec/ucsi/ucsi.h +11 -0
@@ -23,6 +23,17 @@ struct dentry;#define UCSI_CONTROL 8#define UCSI_MESSAGE_IN 16#define UCSI_MESSAGE_OUT 32 +#define UCSIv2_MESSAGE_OUT 272 + +/* UCSI versions */ +#define UCSI_VERSION_1_2 0x0120 +#define UCSI_VERSION_2_0 0x0200 +#define UCSI_VERSION_2_1 0x0210 +#define UCSI_VERSION_3_0 0x0300 + +#define UCSI_BCD_GET_MAJOR (_v_) (((_v_) >> 8) & 0xFF) +#define UCSI_BCD_GET_MINOR (_v_) (((_v_) >> 4) & 0x0F) +#define UCSI_BCD_GET_SUBMINOR (_v_) ((_v_) & 0x0F)/* Command Status and Connector Change Indication (CCI) bits */ #define UCSI_CCI_CONNECTOR (_c_) (((_c_) & GENMASK(7, 1)) >> 1)
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 11/28 serial: 8250_of: Drop quirk fot NPCM from 8250_port
In reply to Sasha LevinFrom: Andy Shevchenko <[email protected]>
[ Upstream commit cd0eb354d441488feed6685adbeb1acd45db1b8d ]
We are not supposed to spread quirks in 8250_port module especially when we have a separate driver for the hardware in question.
Move quirk from generic module to the driver that uses it.
--- drivers/tty/serial/8250/8250_of.c | 44 +++++++++++++++++++++++++++-- drivers/tty/serial/8250/8250_port.c | 24 ---------------- 2 files changed, 42 insertions(+), 26 deletions(-)
drivers/tty/serial/8250/8250_of.c +42 -2
@@ -4,7 +4,10 @@* * Copyright (C) 2006 Arnd Bergmann <[email protected]>, IBM Corp. */ + +#include <linux/bits.h> #include <linux/console.h> +#include <linux/math.h> #include <linux/module.h> #include <linux/slab.h> #include <linux/serial_core.h>
@@ -25,6 +28,36 @@ struct of_serial_info {int line; }; +/* Nuvoton NPCM timeout register */ +#define UART_NPCM_TOR 7 +#define UART_NPCM_TOIE BIT(7)/* Timeout Interrupt Enable */ + +static int npcm_startup (struct uart_port *port) +{ +/* +* Nuvoton calls the scratch register 'UART_TOR' (timeout +* register). Enable it, and set TIOC (timeout interrupt +* comparator) to be 0x20 for correct operation. +*/ +serial_port_out (port,UART_NPCM_TOR ,UART_NPCM_TOIE |0x20 ); + +return serial8250_do_startup (port); +} + +/* Nuvoton NPCM UARTs have a custom divisor calculation */ +static unsigned int npcm_get_divisor (struct uart_port *port,unsigned int baud, +unsigned int *frac) +{ +return DIV_ROUND_CLOSEST (port->uartclk,16 * baud +2 ) -2 ; +} + +static int npcm_setup (struct uart_port *port) +{ + port->get_divisor = npcm_get_divisor; + port->startup = npcm_startup; +return 0 ; +} +/* * Fill a struct uart_port for a given device node */
@@ -164,10 +197,17 @@ static int of_platform_serial_setup(struct platform_device *ofdev,switch (type) {case PORT_RT2880 : ret =rt288x_setup (port); -if (ret) - goto err_pmruntime; +break ; +case PORT_NPCM : + ret =npcm_setup (port); +break ; +default : +/* Nothing to do */ + ret =0 ;break ; } +if (ret) + goto err_pmruntime; if (IS_REACHABLE(CONFIG_SERIAL_8250_FSL) && (of_device_is_compatible(np, "fsl,ns16550") ||
drivers/tty/serial/8250/8250_port.c +0 -24
@@ -38,10 +38,6 @@#include "8250.h" -/* Nuvoton NPCM timeout register */ -#define UART_NPCM_TOR 7 -#define UART_NPCM_TOIE BIT(7)/* Timeout Interrupt Enable */ -/* * Debugging. */
@@ -2235,15 +2231,6 @@ int serial8250_do_startup(struct uart_port *port) UART_DA830_PWREMU_MGMT_FREE); } -if (port->type ==PORT_NPCM ) { -/* -* Nuvoton calls the scratch register 'UART_TOR' (timeout -* register). Enable it, and set TIOC (timeout interrupt -* comparator) to be 0x20 for correct operation. -*/ -serial_port_out (port,UART_NPCM_TOR ,UART_NPCM_TOIE |0x20 ); - } -#ifdef CONFIG_SERIAL_8250_RSA /* * If this is an RSA port, see if we can kick it up to the
@@ -2545,15 +2532,6 @@ static void serial8250_shutdown(struct uart_port *port)serial8250_do_shutdown (port); } -/* Nuvoton NPCM UARTs have a custom divisor calculation */ -static unsigned int npcm_get_divisor (struct uart_8250_port *up, -unsigned int baud) -{ -struct uart_port *port = &up->port; - -return DIV_ROUND_CLOSEST (port->uartclk,16 * baud +2 ) -2 ; -} -static unsigned int serial8250_do_get_divisor (struct uart_port *port,unsigned int baud,unsigned int *frac)
@@ -2598,8 +2576,6 @@ static unsigned int serial8250_do_get_divisor(struct uart_port *port, quot =0x8001 ; else if (magic_multiplier && baud >= port->uartclk / 12) quot =0x8002 ; - else if (up->port.type == PORT_NPCM) - quot =npcm_get_divisor (up, baud); else quot =uart_get_divisor (port, baud);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 12/28 thunderbolt: Keep the domain powered when USB4 port is in redrive mode
In reply to Sasha LevinFrom: Mika Westerberg <[email protected]>
[ Upstream commit a75e0684efe567ae5f6a8e91a8360c4c1773cf3a ]
If a DiplayPort cable is directly connected to the host routers USB4 port, there is no tunnel involved but the port is in "redrive" mode meaning that it is re-driving the DisplayPort signals from its DisplayPort source. In this case we need to keep the domain powered on otherwise once the domain enters D3cold the connected monitor blanks too.
Since this happens only on Intel Barlow Ridge add a quirk that takes runtime PM reference if we detect that the USB4 port entered redrive mode (and release it once it exits the mode).
--- drivers/thunderbolt/quirks.c | 14 +++++++++++ drivers/thunderbolt/tb.c | 49 +++++++++++++++++++++++++++++++++++- drivers/thunderbolt/tb.h | 4 +++ 3 files changed, 66 insertions(+), 1 deletion(-)
drivers/thunderbolt/quirks.c +14 -0
@@ -43,6 +43,12 @@ static void quirk_usb3_maximum_bandwidth(struct tb_switch *sw) } } +static void quirk_block_rpm_in_redrive (struct tb_switch *sw) +{ + sw->quirks |=QUIRK_KEEP_POWER_IN_DP_REDRIVE ; +tb_sw_dbg (sw,"preventing runtime PM in DP redrive mode\n" ); +} +struct tb_quirk {u16 hw_vendor_id;u16 hw_device_id;
@@ -86,6 +92,14 @@ static const struct tb_quirk tb_quirks[] = { quirk_usb3_maximum_bandwidth }, {0x8087 ,PCI_DEVICE_ID_INTEL_BARLOW_RIDGE_HUB_40G_BRIDGE ,0x0000 ,0x0000 , quirk_usb3_maximum_bandwidth }, +/* +* Block Runtime PM in DP redrive mode for Intel Barlow Ridge host +* controllers. +*/ + { 0x8087, PCI_DEVICE_ID_INTEL_BARLOW_RIDGE_HOST_80G_NHI, 0x0000, 0x0000, + quirk_block_rpm_in_redrive }, + { 0x8087, PCI_DEVICE_ID_INTEL_BARLOW_RIDGE_HOST_40G_NHI, 0x0000, 0x0000, + quirk_block_rpm_in_redrive },/* * CLx is not supported on AMD USB4 Yellow Carp and Pink Sardine platforms. */
drivers/thunderbolt/tb.c +48 -1
67 lines not on this page · raw message
drivers/thunderbolt/tb.h +4 -0
@@ -23,6 +23,8 @@#define QUIRK_FORCE_POWER_LINK_CONTROLLER BIT(0)/* Disable CLx if not supported */ #define QUIRK_NO_CLX BIT(1) +/* Need to keep power on while USB4 port is in redrive mode */ +#define QUIRK_KEEP_POWER_IN_DP_REDRIVE BIT(2)/** * struct tb_nvm - Structure holding NVM information
@@ -258,6 +260,7 @@ struct tb_bandwidth_group {* @group_list: The adapter is linked to the group's list of ports through this * @max_bw: Maximum possible bandwidth through this adapter if set to * non-zero. +* @redrive: For DP IN, if true the adapter is in redrive mode. * * In USB4 terminology this structure represents an adapter (protocol or * lane adapter).
@@ -286,6 +289,7 @@ struct tb_port {struct tb_bandwidth_group *group;struct list_head group_list;unsigned int max_bw; +bool redrive; };/**
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 13/28 usb: typec: tcpci: add generic tcpci fallback compatible
In reply to Sasha LevinFrom: Marco Felsch <[email protected]>
[ Upstream commit 8774ea7a553e2aec323170d49365b59af0a2b7e0 ]
The driver already support the tcpci binding for the i2c_device_id so add the support for the of_device_id too.
--- drivers/usb/typec/tcpm/tcpci.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/typec/tcpm/tcpci.c +1 -0
@@ -889,6 +889,7 @@ MODULE_DEVICE_TABLE(i2c, tcpci_id);#ifdef CONFIG_OF static const struct of_device_id tcpci_of_match[] = { { .compatible ="nxp,ptn5110" , }, + { .compatible ="tcpci" , }, {}, };MODULE_DEVICE_TABLE (of, tcpci_of_match);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 14/28 usb: sl811-hcd: only defined function checkdone if QUIRK2 is defined
In reply to Sasha LevinFrom: Colin Ian King <[email protected]>
[ Upstream commit 12f371e2b6cb4b79c788f1f073992e115f4ca918 ]
Function checkdone is only required if QUIRK2 is defined, so add appropriate #if / #endif around the function.
Cleans up clang scan build warning:drivers/usb/host/sl811-hcd.c:588:18: warning: unused function 'checkdone' [-Wunused-function]
--- drivers/usb/host/sl811-hcd.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/host/sl811-hcd.c +2 -0
@@ -585,6 +585,7 @@ done(struct sl811 *sl811, struct sl811h_ep *ep, u8 bank)finish_request (sl811, ep, urb, urbstat); } +#ifdef QUIRK2 static inline u8 checkdone (struct sl811 *sl811) {u8 ctl;
@@ -616,6 +617,7 @@ static inline u8 checkdone(struct sl811 *sl811)#endif return irqstat; } +#endif static irqreturn_t sl811h_irq (struct usb_hcd *hcd) {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 15/28 ASoC: amd: yc: Fix non-functional mic on ASUS M7600RE
In reply to Sasha LevinFrom: M Cooley <[email protected]>
[ Upstream commit db185362fca554b201e2c62beb15a02bb39a064b ]
The ASUS M7600RE (Vivobook Pro 16X OLED) needs a quirks-table entry for the internal microphone to function properly.
--- sound/soc/amd/yc/acp6x-mach.c | 7 +++++++ 1 file changed, 7 insertions(+)
sound/soc/amd/yc/acp6x-mach.c +7 -0
@@ -318,6 +318,13 @@ static const struct dmi_system_id yc_acp_quirk_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "E1504FA"), } }, + { + .driver_data = &acp6x_card, + .matches = { +DMI_MATCH (DMI_BOARD_VENDOR ,"ASUSTeK COMPUTER INC." ), + DMI_MATCH(DMI_PRODUCT_NAME, "M7600RE"), + } + }, { .driver_data = &acp6x_card, .matches = {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 16/28 thermal/of: Assume polling-delay(-passive) 0 when absent
In reply to Sasha LevinFrom: Konrad Dybcio <[email protected]>
[ Upstream commit 488164006a281986d95abbc4b26e340c19c4c85b ]
Currently, thermal zones associated with providers that have interrupts for signaling hot/critical trips are required to set a polling-delay of 0 to indicate no polling. This feels a bit backwards.
Change the code such that "no polling delay" also means "no polling".
--- drivers/thermal/thermal_of.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/thermal/thermal_of.c +8 -4
@@ -225,14 +225,18 @@ static int thermal_of_monitor_init(struct device_node *np, int *delay, int *pdelint ret; ret =of_property_read_u32 (np,"polling-delay-passive" , pdelay); -if (ret <0 ) { -pr_err ("%pOFn: missing polling-delay-passive property\n" , np); +if (ret == -EINVAL ) { + *pdelay =0 ; + }else if (ret <0 ) { +pr_err ("%pOFn: Couldn't get polling-delay-passive: %d\n" , np, ret);return ret; } ret =of_property_read_u32 (np,"polling-delay" , delay); -if (ret <0 ) { -pr_err ("%pOFn: missing polling-delay property\n" , np); +if (ret == -EINVAL ) { + *delay =0 ; + }else if (ret <0 ) { +pr_err ("%pOFn: Couldn't get polling-delay: %d\n" , np, ret);return ret; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 17/28 ASoC: soc-core.c: Skip dummy codec when adding platforms
In reply to Sasha LevinFrom: Chancel Liu <[email protected]>
[ Upstream commit 23fb6bc2696119391ec3a92ccaffe50e567c515e ]
When pcm_runtime is adding platform components it will scan all registered components. In case of DPCM FE/BE some DAI links will configure dummy platform. However both dummy codec and dummy platform are using "snd-soc-dummy" as component->name. Dummy codec should be skipped when adding platforms otherwise there'll be overflow and UBSAN complains.
--- sound/soc/soc-core.c | 3 +++ 1 file changed, 3 insertions(+)
sound/soc/soc-core.c +3 -0
@@ -1218,6 +1218,9 @@ static int snd_soc_add_pcm_runtime(struct snd_soc_card *card,if (!snd_soc_is_matching_component (platform, component))continue ; +if (snd_soc_component_is_dummy (component) && component->num_dai) +continue ; +snd_soc_rtd_add_component (rtd, component); } }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 18/28 x86/xen: attempt to inflate the memory balloon on PVH
In reply to Sasha LevinFrom: Roger Pau Monne <[email protected]>
[ Upstream commit 38620fc4e8934f1801c7811ef39a041914ac4c1d ]
When running as PVH or HVM Linux will use holes in the memory map as scratch space to map grants, foreign domain pages and possibly miscellaneous other stuff. However the usage of such memory map holes for Xen purposes can be problematic. The request of holesby Xen happen quite early in the kernel boot process (grant table setup already uses scratch map space), and it's possible that by then not all devices have reclaimed their MMIO space. It's not unlikely for chunks of Xen scratch map space to end up using PCI bridge MMIO window memory, which (as expected) causes quite a lot of issues in the system.
At least for PVH dom0 we have the possibility of using regions marked as UNUSABLE in the e820 memory map. Either if the region is UNUSABLE in the native memory map, or it has been converted into UNUSABLE in order to hide RAM regions from dom0, the second stage translation page-tables can populate those areas without issues.
PV already has this kind of logic, where the balloon driver is inflated at boot. Re-use the current logic in order to also inflate it when running as PVH. onvert UNUSABLE regions up to the ratio specified in EXTRA_MEM_RATIO to RAM, while reserving them using xen_add_extra_mem() (which is also moved so it's no longer tied to CONFIG_PV).
[jgross: fixed build for CONFIG_PVH without CONFIG_XEN_PVH]
--- arch/x86/include/asm/xen/hypervisor.h | 5 ++ arch/x86/platform/pvh/enlighten.c | 3 ++ arch/x86/xen/enlighten.c | 32 +++++++++++++ arch/x86/xen/enlighten_pvh.c | 68 +++++++++++++++++++++++++++ arch/x86/xen/setup.c | 44 ----------------- arch/x86/xen/xen-ops.h | 14 ++++++ drivers/xen/balloon.c | 2 - 7 files changed, 122 insertions(+), 46 deletions(-)
arch/x86/include/asm/xen/hypervisor.h +5 -0
@@ -62,6 +62,11 @@ void xen_arch_unregister_cpu(int num);#ifdef CONFIG_PVH void __init xen_pvh_init (struct boot_params *boot_params);void __init mem_map_via_hcall (struct boot_params *boot_params_p); +#ifdef CONFIG_XEN_PVH +void __init xen_reserve_extra_memory (struct boot_params *bootp); +#else +static inline void xen_reserve_extra_memory (struct boot_params *bootp) { } +#endif #endif /* Lazy mode for batching updates / context switch */
arch/x86/platform/pvh/enlighten.c +3 -0
@@ -74,6 +74,9 @@ static void __init init_pvh_bootparams(bool xen_guest) }else xen_raw_printk ("Warning: Can fit ISA range into e820\n" ); +if (xen_guest) +xen_reserve_extra_memory (&pvh_bootparams); + pvh_bootparams.hdr.cmd_line_ptr = pvh_start_info.cmdline_paddr;
arch/x86/xen/enlighten.c +32 -0
@@ -6,6 +6,7 @@#include <linux/console.h> #include <linux/cpu.h> #include <linux/kexec.h> +#include <linux/memblock.h> #include <linux/slab.h> #include <linux/panic_notifier.h>
@@ -350,3 +351,34 @@ void xen_arch_unregister_cpu(int num) }EXPORT_SYMBOL (xen_arch_unregister_cpu);#endif + +/* Amount of extra memory space we add to the e820 ranges */ +struct xen_memory_region xen_extra_mem[XEN_EXTRA_MEM_MAX_REGIONS ]__initdata ; + +void __init xen_add_extra_mem (unsigned long start_pfn,unsigned long n_pfns) +{ +unsigned int i; + +/* +* No need to check for zero size, should happen rarely and will only +* write a new entry regarded to be unused due to zero size. +*/ +for (i =0 ; i <XEN_EXTRA_MEM_MAX_REGIONS ; i++) { +/* Add new region. */ +if (xen_extra_mem[i].n_pfns ==0 ) { + xen_extra_mem[i].start_pfn = start_pfn; + xen_extra_mem[i].n_pfns = n_pfns; +break ; + } +/* Append to existing region. */ +if (xen_extra_mem[i].start_pfn + xen_extra_mem[i].n_pfns == + start_pfn) { + xen_extra_mem[i].n_pfns += n_pfns; +break ; + } + } +if (i ==XEN_EXTRA_MEM_MAX_REGIONS ) +printk (KERN_WARNING "Warning: not enough extra memory regions\n" ); + +memblock_reserve (PFN_PHYS (start_pfn),PFN_PHYS (n_pfns)); +}
arch/x86/xen/enlighten_pvh.c +68 -0
77 lines not on this page · raw message
arch/x86/xen/setup.c +0 -44
62 lines not on this page · raw message
arch/x86/xen/xen-ops.h +14 -0
@@ -163,4 +163,18 @@ void xen_hvm_post_suspend(int suspend_cancelled);static inline void xen_hvm_post_suspend (int suspend_cancelled) {}#endif +/* +* The maximum amount of extra memory compared to the base size. The +* main scaling factor is the size of struct page. At extreme ratios +* of base:extra, all the base memory can be filled with page +* structures for the extra memory, leaving no space for anything +* else. +* +* 10x seems like a reasonable balance between scaling flexibility and +* leaving a practically usable system. +*/ +#define EXTRA_MEM_RATIO (10) + +void xen_add_extra_mem (unsigned long start_pfn,unsigned long n_pfns); +#endif /* XEN_OPS_H */
drivers/xen/balloon.c +0 -2
@@ -672,7 +672,6 @@ EXPORT_SYMBOL(xen_free_ballooned_pages);static void __init balloon_add_regions (void ) { -#if defined(CONFIG_XEN_PV )unsigned long start_pfn, pages;unsigned long pfn, extra_pfn_end;unsigned int i;
@@ -696,7 +695,6 @@ static void __init balloon_add_regions(void) balloon_stats.total_pages += extra_pfn_end - start_pfn; } -#endif }static int __init balloon_init (void )
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 19/28 ASoC: amd: yc: Revert "Fix non-functional mic on Lenovo 21J2"
In reply to Sasha LevinFrom: Jiawei Wang <[email protected]>
[ Upstream commit 861b3415e4dee06cc00cd1754808a7827b9105bf ]
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
@@ -199,13 +199,6 @@ static const struct dmi_system_id yc_acp_quirk_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "21HY"), } }, - { - .driver_data = &acp6x_card, - .matches = { -DMI_MATCH (DMI_BOARD_VENDOR ,"LENOVO" ), - DMI_MATCH(DMI_PRODUCT_NAME, "21J2"), - } - }, { .driver_data = &acp6x_card, .matches = {
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 20/28 ASoC: amd: yc: Revert "add new YC platform variant (0x63) support"
In reply to Sasha LevinFrom: Jiawei Wang <[email protected]>
[ Upstream commit 37bee1855d0e3b6dbeb8de71895f6f68cad137be ]
This reverts commit 316a784839b21b122e1761cdca54677bb19a47fa, that enabled Yellow Carp (YC) driver for PCI revision id 0x63.
Mukunda Vijendar [1] points out that revision 0x63 is Pink Sardine platform, not Yellow Carp. The YC driver should not be enabled for this platform. This patch prevents the YC driver from being incorrectly enabled.
--- sound/soc/amd/yc/pci-acp6x.c | 1 - 1 file changed, 1 deletion(-)
sound/soc/amd/yc/pci-acp6x.c +0 -1
@@ -162,7 +162,6 @@ static int snd_acp6x_probe(struct pci_dev *pci,/* Yellow Carp device check */ switch (pci->revision) {case 0x60 : -case 0x63 :case 0x6f :break ;default :
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 21/28 fbdev: viafb: fix typo in hw_bitblt_1 and hw_bitblt_2
In reply to Sasha LevinFrom: Aleksandr Burakov <[email protected]>
[ Upstream commit bc87bb342f106a0402186bcb588fcbe945dced4b ]
There are some actions with value 'tmp' but 'dst_addr' is checked instead. It is obvious that a copy-paste error was made here and the value of variable 'tmp' should be checked here.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/video/fbdev/via/accel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/video/fbdev/via/accel.c +2 -2
@@ -115,7 +115,7 @@ static int hw_bitblt_1(void __iomem *engine, u8 op, u32 width, u32 height,if (op !=VIA_BITBLT_FILL ) { tmp = src_mem ?0 : src_addr; -if (dst_addr &0xE0000007 ) { +if (tmp &0xE0000007 ) {printk (KERN_WARNING "hw_bitblt_1: Unsupported source " "address %X\n" , tmp);return -EINVAL ;
@@ -260,7 +260,7 @@ static int hw_bitblt_2(void __iomem *engine, u8 op, u32 width, u32 height,writel (tmp, engine +0x18 ); tmp = src_mem ?0 : src_addr; -if (dst_addr &0xE0000007 ) { +if (tmp &0xE0000007 ) {printk (KERN_WARNING "hw_bitblt_2: Unsupported source " "address %X\n" , tmp);return -EINVAL ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 22/28 io_uring: clear opcode specific data for an early failure
In reply to Sasha LevinFrom: Jens Axboe <[email protected]>
[ Upstream commit e21e1c45e1fe2e31732f40256b49c04e76a17cee ]
If failure happens before the opcode prep handler is called, ensure that we clear the opcode specific area of the request, which holds data specific to that request type. This prevents errors where opcode handlers either don't get to clear per-request private data since prep isn't even called.
--- io_uring/io_uring.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-)
io_uring/io_uring.c +16 -9
@@ -2159,6 +2159,13 @@ static void io_init_req_drain(struct io_kiocb *req) } } +static __cold int io_init_fail_req (struct io_kiocb *req,int err) +{ +/* ensure per-opcode data is cleared if we fail before prep */ +memset (&req->cmd.data,0 ,sizeof (req->cmd.data)); +return err; +} + static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req, const struct io_uring_sqe *sqe) __must_hold(&ctx->uring_lock)
@@ -2179,29 +2186,29 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req,if (unlikely (opcode >=IORING_OP_LAST )) { req->opcode =0 ; -return -EINVAL ; +return io_init_fail_req (req, -EINVAL ); } def = &io_issue_defs[opcode];if (unlikely (sqe_flags & ~SQE_COMMON_FLAGS )) {/* enforce forwards compatibility on users */ if (sqe_flags & ~SQE_VALID_FLAGS ) -return -EINVAL ; +return io_init_fail_req (req, -EINVAL );if (sqe_flags &IOSQE_BUFFER_SELECT ) {if (!def->buffer_select) -return -EOPNOTSUPP ; +return io_init_fail_req (req, -EOPNOTSUPP ); req->buf_index =READ_ONCE (sqe->buf_group); }if (sqe_flags &IOSQE_CQE_SKIP_SUCCESS ) ctx->drain_disabled = true;if (sqe_flags &IOSQE_IO_DRAIN ) {if (ctx->drain_disabled) -return -EOPNOTSUPP ; +return io_init_fail_req (req, -EOPNOTSUPP );io_init_req_drain (req); } }if (unlikely (ctx->restricted || ctx->drain_active || ctx->drain_next)) {if (ctx->restricted && !io_check_restriction (ctx, req, sqe_flags)) -return -EACCES ; +return io_init_fail_req (req, -EACCES );/* knock it to the slow queue path, will be drained there */ if (ctx->drain_active) req->flags |=REQ_F_FORCE_ASYNC ;
@@ -2214,9 +2221,9 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req, }if (!def->ioprio && sqe->ioprio) -return -EINVAL ; +return io_init_fail_req (req, -EINVAL );if (!def->iopoll && (ctx->flags &IORING_SETUP_IOPOLL )) -return -EINVAL ; +return io_init_fail_req (req, -EINVAL );if (def->needs_file) {struct io_submit_state *state = &ctx->submit_state;
@@ -2240,12 +2247,12 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req, req->creds =xa_load (&ctx->personalities, personality);if (!req->creds) -return -EINVAL ; +return io_init_fail_req (req, -EINVAL );get_cred (req->creds); ret =security_uring_override_creds (req->creds);if (ret) {put_cred (req->creds); -return ret; +return io_init_fail_req (req, ret); } req->flags |=REQ_F_CREDS ; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 23/28 modpost: fix null pointer dereference
In reply to Sasha LevinFrom: Max Kellermann <[email protected]>
[ Upstream commit 23dfd914d2bfc4c9938b0084dffd7105de231d98 ]
If the find_fromsym() call fails and returns NULL, the warn() call will dereference this NULL pointer and cause the program to crash.
This happened when I tried to build with "test_user_copy" module. With this fix, it prints lots of warnings like this:
WARNING: modpost: lib/test_user_copy: section mismatch in reference: (unknown)+0x4 (section: .text.fixup) -> (unknown) (section: .init.text)
[email protected]:
The issue is reproduced with ARCH=arm allnoconfig + CONFIG_MODULES=y + CONFIG_RUNTIME_TESTING_MENU=y + CONFIG_TEST_USER_COPY=m
--- scripts/mod/modpost.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/mod/modpost.c +3 -1
@@ -1050,7 +1050,9 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf, sec_mismatch_count++;warn ("%s: section mismatch in reference: %s+0x%x (section: %s) -> %s (section: %s)\n" , - modname, fromsym, (unsigned int )(faddr - from->st_value), fromsec, tosym, tosec); + modname, fromsym, + (unsigned int )(faddr - (from ? from->st_value :0 )), + fromsec, tosym, tosec);if (mismatch->mismatch ==EXTABLE_TO_NON_TEXT ) {if (match (tosec, mismatch->bad_tosec))
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 24/28 drivers/nvme: Add quirks for device 126f:2262
In reply to Sasha LevinFrom: "Jiawei Fu (iBug)" <[email protected]>
[ Upstream commit e89086c43f0500bc7c4ce225495b73b8ce234c1f ]
This commit adds NVME_QUIRK_NO_DEEPEST_PS and NVME_QUIRK_BOGUS_NID for device [126f:2262], which appears to be a generic VID:PID pair used for many SSDs based on the Silicon Motion SM2262/SM2262EN controller.
Two of my SSDs with this VID:PID pair exhibit the same behavior:
* They frequently have trouble exiting the deepest power state (5), resulting in the entire disk unresponsive.
Verified by setting nvme_core.default_ps_max_latency_us=10000 and observing them behaving normally.
* They produce all-zero nguid and eui64 with nvme id-ns command.
The offending products are:
* HP SSD EX950 1TB
* HIKVISION C2000Pro 2TB
--- drivers/nvme/host/pci.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/nvme/host/pci.c +3 -0
@@ -3363,6 +3363,9 @@ static const struct pci_device_id nvme_id_table[] = { NVME_QUIRK_BOGUS_NID, }, { PCI_VDEVICE(REDHAT, 0x0010), /* Qemu emulated controller */ .driver_data = NVME_QUIRK_BOGUS_NID, }, + { PCI_DEVICE(0x126f, 0x2262), /* Silicon Motion generic */ + .driver_data = NVME_QUIRK_NO_DEEPEST_PS | + NVME_QUIRK_BOGUS_NID, }, { PCI_DEVICE(0x126f, 0x2263), /* Silicon Motion unidentified */ .driver_data = NVME_QUIRK_NO_NS_DESC_LIST | NVME_QUIRK_BOGUS_NID, },
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 25/28 fbmon: prevent division by zero in fb_videomode_from_videomode()
In reply to Sasha LevinFrom: Roman Smirnov <[email protected]>
[ Upstream commit c2d953276b8b27459baed1277a4fdd5dd9bd4126 ]
The expression htotal * vtotal can have a zero value on overflow. It is necessary to prevent division by zero like in fb_var_to_videomode().
Found by Linux Verification Center (linuxtesting.org) with Svace.
--- drivers/video/fbdev/core/fbmon.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/video/fbdev/core/fbmon.c +4 -3
@@ -1311,7 +1311,7 @@ int fb_get_mode(int flags, u32 val, struct fb_var_screeninfo *var, struct fb_infint fb_videomode_from_videomode (const struct videomode *vm,struct fb_videomode *fbmode) { -unsigned int htotal, vtotal; +unsigned int htotal, vtotal, total; fbmode->xres = vm->hactive; fbmode->left_margin = vm->hback_porch;
@@ -1344,8 +1344,9 @@ int fb_videomode_from_videomode(const struct videomode *vm, vtotal = vm->vactive + vm->vfront_porch + vm->vback_porch + vm->vsync_len;/* prevent division by zero */ -if (htotal && vtotal) { - fbmode->refresh = vm->pixelclock / (htotal * vtotal); + total = htotal * vtotal; +if (total) { + fbmode->refresh = vm->pixelclock / total;/* a mode must have htotal and vtotal != 0 or it is invalid */ }else { fbmode->refresh =0 ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 26/28 ALSA: hda/realtek: Add quirks for some Clevo laptops
In reply to Sasha LevinFrom: Tim Crawford <[email protected]>
[ Upstream commit 33affa7fb46c0c07f6c49d4ddac9dd436715064c ]
Add audio quirks to fix speaker output and headset detection on some new Clevo models:
- L240TU (ALC245)
- PE60SNE-G (ALC1220)
- V350SNEQ (ALC245)
Message-ID: <[email protected]>
--- sound/pci/hda/patch_realtek.c | 3 +++ 1 file changed, 3 insertions(+)
sound/pci/hda/patch_realtek.c +3 -0
@@ -2646,6 +2646,7 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = {SND_PCI_QUIRK (0x1558 ,0x65f1 ,"Clevo PC50HS" ,ALC1220_FIXUP_CLEVO_PB51ED_PINS ),SND_PCI_QUIRK (0x1558 ,0x65f5 ,"Clevo PD50PN[NRT]" ,ALC1220_FIXUP_CLEVO_PB51ED_PINS ),SND_PCI_QUIRK (0x1558 ,0x66a2 ,"Clevo PE60RNE" ,ALC1220_FIXUP_CLEVO_PB51ED_PINS ), +SND_PCI_QUIRK (0x1558 ,0x66a6 ,"Clevo PE60SN[CDE]-[GS]" ,ALC1220_FIXUP_CLEVO_PB51ED_PINS ),SND_PCI_QUIRK (0x1558 ,0x67d1 ,"Clevo PB71[ER][CDF]" ,ALC1220_FIXUP_CLEVO_PB51ED_PINS ),SND_PCI_QUIRK (0x1558 ,0x67e1 ,"Clevo PB71[DE][CDF]" ,ALC1220_FIXUP_CLEVO_PB51ED_PINS ), SND_PCI_QUIRK(0x1558, 0x67e5, "Clevo PC70D[PRS](?:-D|-G)?", ALC1220_FIXUP_CLEVO_PB51ED_PINS),
@@ -10145,12 +10146,14 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x1462 ,0xb120 ,"MSI Cubi MS-B120" ,ALC283_FIXUP_HEADSET_MIC ),SND_PCI_QUIRK (0x1462 ,0xb171 ,"Cubi N 8GL (MS-B171)" ,ALC283_FIXUP_HEADSET_MIC ),SND_PCI_QUIRK (0x152d ,0x1082 ,"Quanta NL3" ,ALC269_FIXUP_LIFEBOOK ), +SND_PCI_QUIRK (0x1558 ,0x0353 ,"Clevo V35[05]SN[CDE]Q" ,ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x1558 ,0x1323 ,"Clevo N130ZU" ,ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x1558 ,0x1325 ,"Clevo N15[01][CW]U" ,ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x1558 ,0x1401 ,"Clevo L140[CZ]U" ,ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x1558 ,0x1403 ,"Clevo N140CU" ,ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x1558 ,0x1404 ,"Clevo N150CU" ,ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x1558 ,0x14a1 ,"Clevo L141MU" ,ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE ), +SND_PCI_QUIRK (0x1558 ,0x2624 ,"Clevo L240TU" ,ALC256_FIXUP_SYSTEM76_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x1558 ,0x4018 ,"Clevo NV40M[BE]" ,ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE ),SND_PCI_QUIRK (0x1558 ,0x4019 ,"Clevo NV40MZ" ,ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE ), SND_PCI_QUIRK(0x1558, 0x4020, "Clevo NV40MB", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE),
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 27/28 drm/amdgpu: fix use-after-free bug
In reply to Sasha LevinFrom: Vitaly Prosyak <[email protected]>
[ Upstream commit 22207fd5c80177b860279653d017474b2812af5e ]
The bug can be triggered by sending a single amdgpu_gem_userptr_ioctl to the AMDGPU DRM driver on any ASICs with an invalid address and size. The bug was reported by Joonkyo Jung <[email protected]>. For example the following code:
static void Syzkaller1(int fd)
{
struct drm_amdgpu_gem_userptr arg;
int ret;
arg.addr = 0xffffffffffff0000;
arg.size = 0x80000000; /*2 Gb*/
arg.flags = 0x7;
ret = drmIoctl(fd, 0xc1186451/*amdgpu_gem_userptr_ioctl*/, &arg);
}Due to the address and size are not valid there is a failure in amdgpu_hmm_register->mmu_interval_notifier_insert->__mmu_interval_notifier_insert-> check_shl_overflow, but we even the amdgpu_hmm_register failure we still call amdgpu_hmm_unregister into amdgpu_gem_object_free which causes access to a bad address. The following stack is below when the issue is reproduced when Kazan is enabled:
[ +0.000014] Hardware name: ASUS System Product Name/ROG STRIX B550-F GAMING (WI-FI), BIOS 1401 12/03/2020 [ +0.000009] RIP: 0010:mmu_interval_notifier_remove+0x327/0x340 [ +0.000017] Code: ff ff 49 89 44 24 08 48 b8 00 01 00 00 00 00 ad de 4c 89 f7 49 89 47 40 48 83 c0 22 49 89 47 48 e8 ce d1 2d 01 e9 32 ff ff ff <0f> 0b e9 16 ff ff ff 4c 89 ef e8 fa 14 b3 ff e9 36 ff ff ff e8 80 [ +0.000014] RSP: 0018:ffffc90002657988 EFLAGS: 00010246 [ +0.000013] RAX: 0000000000000000 RBX: 1ffff920004caf35 RCX: ffffffff8160565b [ +0.000011] RDX: dffffc0000000000 RSI: 0000000000000004 RDI: ffff8881a9f78260 [ +0.000010] RBP: ffffc90002657a70 R08: 0000000000000001 R09: fffff520004caf25 [ +0.000010] R10: 0000000000000003 R11: ffffffff8161d1d6 R12: ffff88810e988c00 [ +0.000010] R13: ffff888126fb5a00 R14: ffff88810e988c0c R15: ffff8881a9f78260 [ +0.000011] FS: 00007ff9ec848540(0000) GS:ffff8883cc880000(0000) knlGS:0000000000000000 [ +0.000012] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ +0.000010] CR2: 000055b3f7e14328 CR3: 00000001b5770000 CR4: 0000000000350ef0 [ +0.000010] Call Trace: [ +0.000006] <TASK> [ +0.000007] ? show_regs+0x6a/0x80 [ +0.000018] ? __warn+0xa5/0x1b0 [ +0.000019] ? mmu_interval_notifier_remove+0x327/0x340 [ +0.000018] ? report_bug+0x24a/0x290 [ +0.000022] ? handle_bug+0x46/0x90 [ +0.000015] ? exc_invalid_op+0x19/0x50 [ +0.000016] ? asm_exc_invalid_op+0x1b/0x20 [ +0.000017] ? kasan_save_stack+0x26/0x50 [ +0.000017] ? mmu_interval_notifier_remove+0x23b/0x340 [ +0.000019] ? mmu_interval_notifier_remove+0x327/0x340 [ +0.000019] ? mmu_interval_notifier_remove+0x23b/0x340 [ +0.000020] ? __pfx_mmu_interval_notifier_remove+0x10/0x10 [ +0.000017] ? kasan_save_alloc_info+0x1e/0x30 [ +0.000018] ? srso_return_thunk+0x5/0x5f [ +0.000014] ? __kasan_kmalloc+0xb1/0xc0 [ +0.000018] ? srso_return_thunk+0x5/0x5f [ +0.000013] ? __kasan_check_read+0x11/0x20 [ +0.000020] amdgpu_hmm_unregister+0x34/0x50 [amdgpu] [ +0.004695] amdgpu_gem_object_free+0x66/0xa0 [amdgpu] [ +0.004534] ? __pfx_amdgpu_gem_object_free+0x10/0x10 [amdgpu] [ +0.004291] ? do_syscall_64+0x5f/0xe0 [ +0.000023] ? srso_return_thunk+0x5/0x5f [ +0.000017] drm_gem_object_free+0x3b/0x50 [drm] [ +0.000489] amdgpu_gem_userptr_ioctl+0x306/0x500 [amdgpu] [ +0.004295] ? __pfx_amdgpu_gem_userptr_ioctl+0x10/0x10 [amdgpu] [ +0.004270] ? srso_return_thunk+0x5/0x5f [ +0.000014] ? __this_cpu_preempt_check+0x13/0x20 [ +0.000015] ? srso_return_thunk+0x5/0x5f [ +0.000013] ? sysvec_apic_timer_interrupt+0x57/0xc0 [ +0.000020] ? srso_return_thunk+0x5/0x5f [ +0.000014] ? asm_sysvec_apic_timer_interrupt+0x1b/0x20 [ +0.000022] ? drm_ioctl_kernel+0x17b/0x1f0 [drm] [ +0.000496] ? __pfx_amdgpu_gem_userptr_ioctl+0x10/0x10 [amdgpu] [ +0.004272] ? drm_ioctl_kernel+0x190/0x1f0 [drm] [ +0.000492] drm_ioctl_kernel+0x140/0x1f0 [drm] [ +0.000497] ? __pfx_amdgpu_gem_userptr_ioctl+0x10/0x10 [amdgpu] [ +0.004297] ? __pfx_drm_ioctl_kernel+0x10/0x10 [drm] [ +0.000489] ? srso_return_thunk+0x5/0x5f [ +0.000011] ? __kasan_check_write+0x14/0x20 [ +0.000016] drm_ioctl+0x3da/0x730 [drm] [ +0.000475] ? __pfx_amdgpu_gem_userptr_ioctl+0x10/0x10 [amdgpu] [ +0.004293] ? __pfx_drm_ioctl+0x10/0x10 [drm] [ +0.000506] ? __pfx_rpm_resume+0x10/0x10 [ +0.000016] ? srso_return_thunk+0x5/0x5f [ +0.000011] ? __kasan_check_write+0x14/0x20 [ +0.000010] ? srso_return_thunk+0x5/0x5f [ +0.000011] ? _raw_spin_lock_irqsave+0x99/0x100 [ +0.000015] ? __pfx__raw_spin_lock_irqsave+0x10/0x10 [ +0.000014] ? srso_return_thunk+0x5/0x5f [ +0.000013] ? srso_return_thunk+0x5/0x5f [ +0.000011] ? srso_return_thunk+0x5/0x5f [ +0.000011] ? preempt_count_sub+0x18/0xc0 [ +0.000013] ? srso_return_thunk+0x5/0x5f [ +0.000010] ? _raw_spin_unlock_irqrestore+0x27/0x50 [ +0.000019] amdgpu_drm_ioctl+0x7e/0xe0 [amdgpu] [ +0.004272] __x64_sys_ioctl+0xcd/0x110 [ +0.000020] do_syscall_64+0x5f/0xe0 [ +0.000021] entry_SYSCALL_64_after_hwframe+0x6e/0x76 [ +0.000015] RIP: 0033:0x7ff9ed31a94f [ +0.000012] Code: 00 48 89 44 24 18 31 c0 48 8d 44 24 60 c7 04 24 10 00 00 00 48 89 44 24 08 48 8d 44 24 20 48 89 44 24 10 b8 10 00 00 00 0f 05 <41> 89 c0 3d 00 f0 ff ff 77 1f 48 8b 44 24 18 64 48 2b 04 25 28 00 [ +0.000013] RSP: 002b:00007fff25f66790 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 [ +0.000016] RAX: ffffffffffffffda RBX: 000055b3f7e133e0 RCX: 00007ff9ed31a94f [ +0.000012] RDX: 000055b3f7e133e0 RSI: 00000000c1186451 RDI: 0000000000000003 [ +0.000010] RBP: 00000000c1186451 R08: 0000000000000000 R09: 0000000000000000 [ +0.000009] R10: 0000000000000008 R11: 0000000000000246 R12: 00007fff25f66ca8 [ +0.000009] R13: 0000000000000003 R14: 000055b3f7021ba8 R15: 00007ff9ed7af040 [ +0.000024] </TASK> [ +0.000007] ---[ end trace 0000000000000000 ]---
v2: Consolidate any error handling into amdgpu_hmm_register
which applied to kfd_bo also. (Christian)
v3: Improve syntax and comment (Christian)
--- drivers/gpu/drm/amd/amdgpu/amdgpu_hmm.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_hmm.c +16 -4
@@ -129,13 +129,25 @@ static const struct mmu_interval_notifier_ops amdgpu_hmm_hsa_ops = {*/ int amdgpu_hmm_register (struct amdgpu_bo *bo,unsigned long addr) { +int r; +if (bo->kfd_bo) -return mmu_interval_notifier_insert (&bo->notifier, current->mm, + r =mmu_interval_notifier_insert (&bo->notifier, current->mm, addr,amdgpu_bo_size (bo), &amdgpu_hmm_hsa_ops); -return mmu_interval_notifier_insert (&bo->notifier, current->mm, addr, -amdgpu_bo_size (bo), - &amdgpu_hmm_gfx_ops); +else + r =mmu_interval_notifier_insert (&bo->notifier, current->mm, addr, +amdgpu_bo_size (bo), + &amdgpu_hmm_gfx_ops); +if (r) +/* +* Make sure amdgpu_hmm_unregister() doesn't call +* mmu_interval_notifier_remove() when the notifier isn't properly +* initialized. +*/ + bo->notifier.mm =NULL ; + +return r; }/**
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 28/28 drm/amdgpu: Init zone device and drm client after mode-1 reset on reload
In reply to Sasha LevinFrom: Ahmad Rehman <[email protected]>
[ Upstream commit f679fd6057fbf5ab34aaee28d58b7f81af0cbf48 ]
In passthrough environment, when amdgpu is reloaded after unload, mode-1 is triggered after initializing the necessary IPs, That init does not include KFD, and KFD init waits until the reset is completed. KFD init is called in the reset handler, but in this case, the zone device and drm client is not initialized, causing app to create kernel panic.
v2: Removing the init KFD condition from amdgpu_amdkfd_drm_client_create. As the previous version has the potential of creating DRM client twice.
v3: v2 patch results in SDMA engine hung as DRM open causes VM clear to SDMA before SDMA init. Adding the condition to in drm client creation, on top of v1, to guard against drm client creation call multiple times.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +1 -1
@@ -146,7 +146,7 @@ int amdgpu_amdkfd_drm_client_create(struct amdgpu_device *adev) {int ret; -if (!adev->kfd.init_complete) +if (!adev->kfd.init_complete || adev->kfd.client.dev)return 0 ; ret = drm_client_init(&adev->ddev, &adev->kfd.client, "kfd",
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4 -1
@@ -2451,8 +2451,11 @@ static void amdgpu_drv_delayed_reset_work_handler(struct work_struct *work) }for (i =0 ; i < mgpu_info.num_dgpu; i++) { adev = mgpu_info.gpu_ins[i].adev; -if (!adev->kfd.init_complete) +if (!adev->kfd.init_complete) { +kgd2kfd_init_zone_device (adev);amdgpu_amdkfd_device_init (adev); +amdgpu_amdkfd_drm_client_create (adev); + }amdgpu_ttm_set_buffer_funcs_status (adev, true); } }
Signature · 1 line
2.43.0