5.15.99-rc1 review
Subsystems (10)
Greg Kroah-Hartman
maintainerPATCH 160/567 l2tp: Avoid possible recursive deadlock in l2tp_tunnel_register()
In reply to Greg Kroah-HartmanFrom: Shigeru Yoshida <[email protected]>
[ Upstream commit 9ca5e7ecab064f1f47da07f7c1ddf40e4bc0e5ac ]
When a file descriptor of pppol2tp socket is passed as file descriptor of UDP socket, a recursive deadlock occurs in l2tp_tunnel_register(). This situation is reproduced by the following program:
int main(void)
{
int sock;
struct sockaddr_pppol2tp addr;
sock = socket(AF_PPPOX, SOCK_DGRAM, PX_PROTO_OL2TP);
if (sock < 0) {
perror("socket");
return 1;
}
addr.sa_family = AF_PPPOX;
addr.sa_protocol = PX_PROTO_OL2TP;
addr.pppol2tp.pid = 0;
addr.pppol2tp.fd = sock;
addr.pppol2tp.addr.sin_family = PF_INET;
addr.pppol2tp.addr.sin_port = htons(0);
addr.pppol2tp.addr.sin_addr.s_addr = inet_addr("192.168.0.1");
addr.pppol2tp.s_tunnel = 1;
addr.pppol2tp.s_session = 0;
addr.pppol2tp.d_tunnel = 0;
addr.pppol2tp.d_session = 0;
if (connect(sock, (const struct sockaddr *)&addr, sizeof(addr)) < 0) {
perror("connect");
return 1;
}
return 0;
}This program causes the following lockdep warning:
============================================
WARNING: possible recursive locking detected 6.2.0-rc5-00205-gc96618275234 #56 Not tainted
--------------------------------------------
repro/8607 is trying to acquire lock:
ffff8880213c8130 (sk_lock-AF_PPPOX){+.+.}-{0:0}, at: l2tp_tunnel_register+0x2b7/0x11c0
but task is already holding lock:
ffff8880213c8130 (sk_lock-AF_PPPOX){+.+.}-{0:0}, at: pppol2tp_connect+0xa82/0x1a30
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
---- lock(sk_lock-AF_PPPOX);
lock(sk_lock-AF_PPPOX);
*** DEADLOCK ***
May be due to missing lock nesting notation
1 lock held by repro/8607:
#0: ffff8880213c8130 (sk_lock-AF_PPPOX){+.+.}-{0:0}, at: pppol2tp_connect+0xa82/0x1a30
stack backtrace: CPU: 0 PID: 8607 Comm: repro Not tainted 6.2.0-rc5-00205-gc96618275234 #56 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.1-2.fc37 04/01/2014 Call Trace: <TASK> dump_stack_lvl+0x100/0x178 __lock_acquire.cold+0x119/0x3b9 ? lockdep_hardirqs_on_prepare+0x410/0x410 lock_acquire+0x1e0/0x610 ? l2tp_tunnel_register+0x2b7/0x11c0 ? lock_downgrade+0x710/0x710 ? __fget_files+0x283/0x3e0 lock_sock_nested+0x3a/0xf0 ? l2tp_tunnel_register+0x2b7/0x11c0 l2tp_tunnel_register+0x2b7/0x11c0 ? sprintf+0xc4/0x100 ? l2tp_tunnel_del_work+0x6b0/0x6b0 ? debug_object_deactivate+0x320/0x320 ? lockdep_init_map_type+0x16d/0x7a0 ? lockdep_init_map_type+0x16d/0x7a0 ? l2tp_tunnel_create+0x2bf/0x4b0 ? l2tp_tunnel_create+0x3c6/0x4b0 pppol2tp_connect+0x14e1/0x1a30 ? pppol2tp_put_sk+0xd0/0xd0 ? aa_sk_perm+0x2b7/0xa80 ? aa_af_perm+0x260/0x260 ? bpf_lsm_socket_connect+0x9/0x10 ? pppol2tp_put_sk+0xd0/0xd0 __sys_connect_file+0x14f/0x190 __sys_connect+0x133/0x160 ? __sys_connect_file+0x190/0x190 ? lockdep_hardirqs_on+0x7d/0x100 ? ktime_get_coarse_real_ts64+0x1b7/0x200 ? ktime_get_coarse_real_ts64+0x147/0x200 ? __audit_syscall_entry+0x396/0x500 __x64_sys_connect+0x72/0xb0 do_syscall_64+0x38/0xb0 entry_SYSCALL_64_after_hwframe+0x63/0xcd
This patch fixes the issue by getting/creating the tunnel before locking the pppol2tp socket.
--- net/l2tp/l2tp_ppp.c | 125 ++++++++++++++++++++++++-------------------- 1 file changed, 67 insertions(+), 58 deletions(-)
net/l2tp/l2tp_ppp.c +67 -58
@@ -651,54 +651,22 @@ static int pppol2tp_tunnel_mtu(const struct l2tp_tunnel *tunnel)return mtu -PPPOL2TP_HEADER_OVERHEAD ; } -/* connect() handler. Attach a PPPoX socket to a tunnel UDP socket -*/ -static int pppol2tp_connect (struct socket *sock,struct sockaddr *uservaddr, -int sockaddr_len,int flags) +static struct l2tp_tunnel *pppol2tp_tunnel_get (struct net *net, +const struct l2tp_connect_info *info, +bool *new_tunnel) { -struct sock *sk = sock->sk; -struct pppox_sock *po =pppox_sk (sk); -struct l2tp_session *session =NULL ; -struct l2tp_connect_info info;struct l2tp_tunnel *tunnel; -struct pppol2tp_session *ps; -struct l2tp_session_cfg cfg = {0 , }; -bool drop_refcnt = false; -bool drop_tunnel = false; -bool new_session = false; -bool new_tunnel = false;int error; - error =pppol2tp_sockaddr_get_info (uservaddr, sockaddr_len, &info); -if (error <0 ) -return error; + *new_tunnel = false; -lock_sock (sk); - -/* Check for already bound sockets */ - error = -EBUSY ; -if (sk->sk_state &PPPOX_CONNECTED ) - goto end; - -/* We don't supporting rebinding anyway */ - error = -EALREADY ; -if (sk->sk_user_data) - goto end;/* socket is already attached */ - -/* Don't bind if tunnel_id is 0 */ - error = -EINVAL ; -if (!info.tunnel_id) - goto end; - - tunnel =l2tp_tunnel_get (sock_net (sk), info.tunnel_id); -if (tunnel) - drop_tunnel = true; + tunnel =l2tp_tunnel_get (net, info->tunnel_id);/* Special case: create tunnel context if session_id and * peer_session_id is 0. Otherwise look up tunnel using supplied * tunnel id. */ -if (!info.session_id && !info.peer_session_id) { +if (!info->session_id && !info->peer_session_id) {if (!tunnel) {struct l2tp_tunnel_cfg tcfg = { .encap = L2TP_ENCAPTYPE_UDP,
@@ -707,40 +675,82 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr,/* Prevent l2tp_tunnel_register() from trying to set up * a kernel socket. */ -if (info.fd <0 ) { - error = -EBADF ; - goto end; - } +if (info->fd <0 ) +return ERR_PTR (-EBADF ); - error =l2tp_tunnel_create (info.fd, - info.version, - info.tunnel_id, - info.peer_tunnel_id, &tcfg, + error =l2tp_tunnel_create (info->fd, + info->version, + info->tunnel_id, + info->peer_tunnel_id, &tcfg, &tunnel);if (error <0 ) - goto end; +return ERR_PTR (error);l2tp_tunnel_inc_refcount (tunnel); - error =l2tp_tunnel_register (tunnel,sock_net (sk), - &tcfg); + error =l2tp_tunnel_register (tunnel, net, &tcfg);if (error <0 ) {kfree (tunnel); - goto end; +return ERR_PTR (error); } - drop_tunnel = true; - new_tunnel = true; + + *new_tunnel = true; } }else {/* Error if we can't find the tunnel */ - error = -ENOENT ;if (!tunnel) - goto end; +return ERR_PTR (-ENOENT );/* Error if socket is not prepped */ -if (!tunnel->sock) - goto end; +if (!tunnel->sock) { +l2tp_tunnel_dec_refcount (tunnel); +return ERR_PTR (-ENOENT ); + } } +return tunnel; +} + +/* connect() handler. Attach a PPPoX socket to a tunnel UDP socket +*/ +static int pppol2tp_connect (struct socket *sock,struct sockaddr *uservaddr, +int sockaddr_len,int flags) +{ +struct sock *sk = sock->sk; +struct pppox_sock *po =pppox_sk (sk); +struct l2tp_session *session =NULL ; +struct l2tp_connect_info info; +struct l2tp_tunnel *tunnel; +struct pppol2tp_session *ps; +struct l2tp_session_cfg cfg = {0 , }; +bool drop_refcnt = false; +bool new_session = false; +bool new_tunnel = false; +int error; + + error =pppol2tp_sockaddr_get_info (uservaddr, sockaddr_len, &info); +if (error <0 ) +return error; + +/* Don't bind if tunnel_id is 0 */ +if (!info.tunnel_id) +return -EINVAL ; + + tunnel =pppol2tp_tunnel_get (sock_net (sk), &info, &new_tunnel); +if (IS_ERR (tunnel)) +return PTR_ERR (tunnel); + +lock_sock (sk); + +/* Check for already bound sockets */ + error = -EBUSY ; +if (sk->sk_state &PPPOX_CONNECTED ) + goto end; + +/* We don't supporting rebinding anyway */ + error = -EALREADY ; +if (sk->sk_user_data) + goto end;/* socket is already attached */ +if (tunnel->peer_tunnel_id ==0 ) tunnel->peer_tunnel_id = info.peer_tunnel_id;
@@ -841,8 +851,7 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr, }if (drop_refcnt)l2tp_session_dec_refcount (session); -if (drop_tunnel) -l2tp_tunnel_dec_refcount (tunnel); +l2tp_tunnel_dec_refcount (tunnel);release_sock (sk);return error;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 161/567 net: bcmgenet: fix MoCA LED control
In reply to Greg Kroah-HartmanFrom: Doug Berger <[email protected]>
[ Upstream commit a7515af9fb8f0890fe540b108def4a86b9e8330a ]
When the bcmgenet_mii_config() code was refactored it was missed that the LED control for the MoCA interface got overwritten by the port_ctrl value. Its previous programming is restored here.
--- drivers/net/ethernet/broadcom/genet/bcmmii.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmmii.c +2 -9
@@ -165,15 +165,6 @@ void bcmgenet_phy_power_set(struct net_device *dev, bool enable)static void bcmgenet_moca_phy_setup (struct bcmgenet_priv *priv) { -u32 reg; - -if (!GENET_IS_V5 (priv)) { -/* Speed settings are set in bcmgenet_mii_setup() */ - reg =bcmgenet_sys_readl (priv,SYS_PORT_CTRL ); - reg |=LED_ACT_SOURCE_MAC ; -bcmgenet_sys_writel (priv, reg,SYS_PORT_CTRL ); - } -if (priv->hw_params->flags &GENET_HAS_MOCA_LINK_DET )fixed_phy_set_link_update (priv->dev->phydev, bcmgenet_fixed_phy_link_update);
@@ -206,6 +197,8 @@ int bcmgenet_mii_config(struct net_device *dev, bool init)if (!phy_name) { phy_name ="MoCA" ; +if (!GENET_IS_V5 (priv)) + port_ctrl |=LED_ACT_SOURCE_MAC ;bcmgenet_moca_phy_setup (priv); }break ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 162/567 selftest: fib_tests: Always cleanup before exit
In reply to Greg Kroah-HartmanFrom: Roxana Nicolescu <[email protected]>
[ Upstream commit b60417a9f2b890a8094477b2204d4f73c535725e ]
Usage of set -e before executing a command causes immediate exit on failure, without cleanup up the resources allocated at setup. This can affect the next tests that use the same resources, leading to a chain of failures.
A simple fix is to always call cleanup function when the script exists. This approach is already used by other existing tests.
--- tools/testing/selftests/net/fib_tests.sh | 2 ++ 1 file changed, 2 insertions(+)
tools/testing/selftests/net/fib_tests.sh +2 -0
@@ -1921,6 +1921,8 @@ EOF ################################################################################ # main +trap cleanup EXIT + while getopts :t:pPhv o do case $o in
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 163/567 sefltests: netdevsim: wait for devlink instance after netns removal
In reply to Greg Kroah-HartmanFrom: Jiri Pirko <[email protected]>
[ Upstream commit f922c7b1c1c45740d329bf248936fdb78c0cff6e ]
When devlink instance is put into network namespace and that network namespace gets deleted, devlink instance is moved back into init_ns. This is done as a part of cleanup_net() routine. Since cleanup_net() is called asynchronously from workqueue, there is no guarantee that the devlink instance move is done after "ip netns del" returns.
So fix this race by making sure that the devlink instance is present before any other operation.
--- .../selftests/drivers/net/netdevsim/devlink.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
tools/testing/selftests/drivers/net/netdevsim/devlink.sh +18 -0
@@ -17,6 +17,18 @@ SYSFS_NET_DIR=/sys/bus/netdevsim/devices/$DEV_NAME/net/ DEBUGFS_DIR=/sys/kernel/debug/netdevsim/$DEV_NAME/ DL_HANDLE=netdevsim/$DEV_NAME +wait_for_devlink() +{ + "$@" | grep -q $DL_HANDLE +} + +devlink_wait() +{ + local timeout=$1 + + busywait "$timeout" wait_for_devlink devlink dev +} + fw_flash_test() { RET=0
@@ -256,6 +268,9 @@ netns_reload_test() ip netns del testns2 ip netns del testns1 + # Wait until netns async cleanup is done. + devlink_wait 2000 + log_test "netns reload test" }
@@ -348,6 +363,9 @@ resource_test() ip netns del testns2 ip netns del testns1 + # Wait until netns async cleanup is done. + devlink_wait 2000 + log_test "resource test" }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 164/567 drm: Fix potential null-ptr-deref due to drmm_mode_config_init()
In reply to Greg Kroah-HartmanFrom: Shang XiaoJing <[email protected]>
[ Upstream commit 834c23e4f798dcdc8af251b3c428ceef94741991 ]
drmm_mode_config_init() will call drm_mode_create_standard_properties() and won't check the ret value. When drm_mode_create_standard_properties() failed due to alloc, property will be a NULL pointer and may causes the null-ptr-deref. Fix the null-ptr-deref by adding the ret value check.
Found null-ptr-deref while testing insert module bochs:
general protection fault, probably for non-canonical address
0xdffffc000000000c: 0000 [#1] SMP KASAN PTI
KASAN: null-ptr-deref in range [0x0000000000000060-0x0000000000000067]
CPU: 3 PID: 249 Comm: modprobe Not tainted 6.1.0-rc1+ #364
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
rel-1.15.0-0-g2dd4b9b3f840-prebuilt.qemu.org 04/01/2014
RIP: 0010:drm_object_attach_property+0x73/0x3c0 [drm]
Call Trace:
<TASK>
__drm_connector_init+0xb6c/0x1100 [drm]
bochs_pci_probe.cold.11+0x4cb/0x7fe [bochs]
pci_device_probe+0x17d/0x340
really_probe+0x1db/0x5d0
__driver_probe_device+0x1e7/0x250
driver_probe_device+0x4a/0x120
__driver_attach+0xcd/0x2c0
bus_for_each_dev+0x11a/0x1b0
bus_add_driver+0x3d7/0x500
driver_register+0x18e/0x320
do_one_initcall+0xc4/0x3e0
do_init_module+0x1b4/0x630
load_module+0x5dca/0x7230
__do_sys_finit_module+0x100/0x170
do_syscall_64+0x3f/0x90
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7ff65af9f839--- drivers/gpu/drm/drm_mode_config.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_mode_config.c +7 -1
@@ -398,6 +398,8 @@ static void drm_mode_config_init_release(struct drm_device *dev, void *ptr)*/ int drmm_mode_config_init (struct drm_device *dev) { +int ret; +mutex_init (&dev->mode_config.mutex);drm_modeset_lock_init (&dev->mode_config.connection_mutex);mutex_init (&dev->mode_config.idr_mutex);
@@ -419,7 +421,11 @@ int drmm_mode_config_init(struct drm_device *dev)init_llist_head (&dev->mode_config.connector_free_list);INIT_WORK (&dev->mode_config.connector_free_work, drm_connector_free_work_fn); -drm_mode_create_standard_properties (dev); + ret =drm_mode_create_standard_properties (dev); +if (ret) { +drm_mode_config_cleanup (dev); +return ret; + }/* Just to be sure */ dev->mode_config.num_fb =0 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 165/567 drm/fourcc: Add missing big-endian XRGB1555 and RGB565 formats
In reply to Greg Kroah-HartmanFrom: Geert Uytterhoeven <[email protected]>
[ Upstream commit 6fb6c979ca628583d4d0c59a0f8ff977e581ecc0 ]
As of commit eae06120f1974e1a ("drm: refuse ADDFB2 ioctl for broken bigendian drivers"), drivers must set the quirk_addfb_prefer_host_byte_order quirk to make the drm_mode_addfb() compat code work correctly on big-endian machines.
While that works fine for big-endian XRGB8888 and ARGB8888, which are mapped to the existing little-endian BGRX8888 and BGRA8888 formats, it does not work for big-endian XRGB1555 and RGB565, as the latter are not listed in the format database.
Fix this by adding the missing formats. Limit this to big-endian platforms, as there is currently no need to support these formats on little-endian platforms.
--- drivers/gpu/drm/drm_fourcc.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/drm_fourcc.c +4 -0
@@ -153,6 +153,10 @@ const struct drm_format_info *__drm_format_info(u32 format) { .format = DRM_FORMAT_BGRA5551, .depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1, .has_alpha = true }, { .format = DRM_FORMAT_RGB565, .depth = 16, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 }, { .format = DRM_FORMAT_BGR565, .depth = 16, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 }, +#ifdef __BIG_ENDIAN + { .format = DRM_FORMAT_XRGB1555 | DRM_FORMAT_BIG_ENDIAN, .depth = 15, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 }, + { .format = DRM_FORMAT_RGB565 | DRM_FORMAT_BIG_ENDIAN, .depth = 16, .num_planes = 1, .cpp = { 2, 0, 0 }, .hsub = 1, .vsub = 1 }, +#endif { .format = DRM_FORMAT_RGB888, .depth = 24, .num_planes = 1, .cpp = { 3, 0, 0 }, .hsub = 1, .vsub = 1 }, { .format = DRM_FORMAT_BGR888, .depth = 24, .num_planes = 1, .cpp = { 3, 0, 0 }, .hsub = 1, .vsub = 1 }, { .format = DRM_FORMAT_XRGB8888, .depth = 24, .num_planes = 1, .cpp = { 4, 0, 0 }, .hsub = 1, .vsub = 1 },
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 166/567 drm/bridge: ti-sn65dsi83: Fix delay after reset deassert to match spec
In reply to Greg Kroah-HartmanFrom: Frieder Schrempf <[email protected]>
[ Upstream commit 4b03d5e0d3e86ee492d54254927d020dc0fe8acf ]
The datasheet specifies a delay of 10 milliseconds, but the current driver only waits for 1 ms. Fix this to make sure the initialization sequence meets the spec.
--- drivers/gpu/drm/bridge/ti-sn65dsi83.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/bridge/ti-sn65dsi83.c +2 -0
@@ -381,6 +381,8 @@ static void sn65dsi83_atomic_enable(struct drm_bridge *bridge,u16 val;int ret; +usleep_range (10000 ,11000 ); +/* Get the LVDS format from the bridge state. */ bridge_state =drm_atomic_get_new_bridge_state (state, bridge);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 167/567 drm: mxsfb: DRM_MXSFB should depend on ARCH_MXS || ARCH_MXC
In reply to Greg Kroah-HartmanFrom: Geert Uytterhoeven <[email protected]>
[ Upstream commit 7783cc67862f9166c901bfa0f80b717aa8d354dd ]
Freescale/NXP i.MX LCDIF and eLCDIF LCD controllers are only present on Freescale/NXP i.MX SoCs. Hence add a dependency on ARCH_MXS || ARCH_MXC, to prevent asking the user about this driver when configuring a kernel without Freescale/NXP i.MX support.
--- drivers/gpu/drm/mxsfb/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/mxsfb/Kconfig +1 -0
@@ -8,6 +8,7 @@ config DRM_MXSFB tristate "i.MX (e)LCDIF LCD controller" depends on DRM && OF depends on COMMON_CLK + depends on ARCH_MXS || ARCH_MXC || COMPILE_TEST select DRM_MXS select DRM_KMS_HELPER select DRM_KMS_CMA_HELPER
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 168/567 drm/bridge: megachips: Fix error handling in i2c_register_driver()
In reply to Greg Kroah-HartmanFrom: Yuan Can <[email protected]>
[ Upstream commit 4ecff954c370b82bce45bdca2846c5c5563e8a8a ]
A problem about insmod megachips-stdpxxxx-ge-b850v3-fw.ko failed is triggered with the following log given:
[ 4497.981497] Error: Driver 'stdp4028-ge-b850v3-fw' is already registered, aborting...
insmod: ERROR: could not insert module megachips-stdpxxxx-ge-b850v3-fw.ko: Device or resource busy
The reason is that stdpxxxx_ge_b850v3_init() returns i2c_add_driver() directly without checking its return value, if i2c_add_driver() failed, it returns without calling i2c_del_driver() on the previous i2c driver, resulting the megachips-stdpxxxx-ge-b850v3-fw can never be installed later.
A simple call graph is shown as below:
stdpxxxx_ge_b850v3_init()
i2c_add_driver(&stdp4028_ge_b850v3_fw_driver)
i2c_add_driver(&stdp2690_ge_b850v3_fw_driver)
i2c_register_driver()
driver_register()
bus_add_driver()
priv = kzalloc(...) # OOM happened
# return without delete stdp4028_ge_b850v3_fw_driver
Fix by calling i2c_del_driver() on stdp4028_ge_b850v3_fw_driver when i2c_add_driver() returns error.
--- drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c +5 -1
@@ -444,7 +444,11 @@ static int __init stdpxxxx_ge_b850v3_init(void)if (ret)return ret; -return i2c_add_driver (&stdp2690_ge_b850v3_fw_driver); + ret =i2c_add_driver (&stdp2690_ge_b850v3_fw_driver); +if (ret) +i2c_del_driver (&stdp4028_ge_b850v3_fw_driver); + +return ret; }module_init (stdpxxxx_ge_b850v3_init);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 169/567 drm/vkms: Fix memory leak in vkms_init()
In reply to Greg Kroah-HartmanFrom: Yuan Can <[email protected]>
[ Upstream commit 0d0b368b9d104b437e1f4850ae94bdb9a3601e89 ]
A memory leak was reported after the vkms module install failed.
unreferenced object 0xffff88810bc28520 (size 16):
comm "modprobe", pid 9662, jiffies 4298009455 (age 42.590s) hex dump (first 16 bytes):
01 01 00 64 81 88 ff ff 00 00 dc 0a 81 88 ff ff ...d............
backtrace:
[<00000000e7561ff8>] kmalloc_trace+0x27/0x60
[<000000000b1954a0>] 0xffffffffc45200a9
[<00000000abbf1da0>] do_one_initcall+0xd0/0x4f0
[<000000001505ee87>] do_init_module+0x1a4/0x680
[<00000000958079ad>] load_module+0x6249/0x7110
[<00000000117e4696>] __do_sys_finit_module+0x140/0x200
[<00000000f74b12d2>] do_syscall_64+0x35/0x80
[<000000008fc6fcde>] entry_SYSCALL_64_after_hwframe+0x46/0xb0The reason is that the vkms_init() returns without checking the return value of vkms_create(), and if the vkms_create() failed, the config allocated at the beginning of vkms_init() is leaked.
vkms_init()
config = kmalloc(...) # config allocated
...
return vkms_create() # vkms_create failed and config is leaked
Fix this problem by checking return value of vkms_create() and free the config if error happened.
--- drivers/gpu/drm/vkms/vkms_drv.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/vkms/vkms_drv.c +6 -1
@@ -218,6 +218,7 @@ static int vkms_create(struct vkms_config *config)static int __init vkms_init (void ) { +int ret;struct vkms_config *config; config =kmalloc (sizeof (*config),GFP_KERNEL );
@@ -230,7 +231,11 @@ static int __init vkms_init(void) config->writeback = enable_writeback; config->overlay = enable_overlay; -return vkms_create (config); + ret =vkms_create (config); +if (ret) +kfree (config); + +return ret; }static void vkms_destroy (struct vkms_config *config)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 170/567 drm/vkms: Fix null-ptr-deref in vkms_release()
In reply to Greg Kroah-HartmanFrom: Yuan Can <[email protected]>
[ Upstream commit 2fe2a8f40c21161ffe7653cc234e7934db5b7cc5 ]
A null-ptr-deref is triggered when it tries to destroy the workqueue in vkms->output.composer_workq in vkms_release().
KASAN: null-ptr-deref in range [0x0000000000000118-0x000000000000011f] CPU: 5 PID: 17193 Comm: modprobe Not tainted 6.0.0-11331-gd465bff130bf #24 RIP: 0010:destroy_workqueue+0x2f/0x710 ... Call Trace: <TASK> ? vkms_config_debugfs_init+0x50/0x50 [vkms] __devm_drm_dev_alloc+0x15a/0x1c0 [drm] vkms_init+0x245/0x1000 [vkms] do_one_initcall+0xd0/0x4f0 do_init_module+0x1a4/0x680 load_module+0x6249/0x7110 __do_sys_finit_module+0x140/0x200 do_syscall_64+0x35/0x80 entry_SYSCALL_64_after_hwframe+0x46/0xb0
The reason is that an OOM happened which triggers the destroy of the workqueue, however, the workqueue is alloced in the later process, thus a null-ptr-deref happened. A simple call graph is shown as below:
vkms_init()
vkms_create()
devm_drm_dev_alloc()
__devm_drm_dev_alloc()
devm_drm_dev_init()
devm_add_action_or_reset()
devm_add_action() # an error happened
devm_drm_dev_init_release()
drm_dev_put()
kref_put()
drm_dev_release()
vkms_release()
destroy_workqueue() # null-ptr-deref happened
vkms_modeset_init()
vkms_output_init()
vkms_crtc_init() # where the workqueue get allocatedFix this by checking if composer_workq is NULL before passing it to the destroy_workqueue() in vkms_release().
--- drivers/gpu/drm/vkms/vkms_drv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/vkms/vkms_drv.c +2 -1
@@ -57,7 +57,8 @@ static void vkms_release(struct drm_device *dev) {struct vkms_device *vkms =drm_device_to_vkms_device (dev); -destroy_workqueue (vkms->output.composer_workq); +if (vkms->output.composer_workq) +destroy_workqueue (vkms->output.composer_workq); }static void vkms_atomic_commit_tail (struct drm_atomic_state *old_state)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 171/567 drm/vc4: dpi: Add option for inverting pixel clock and output enable
In reply to Greg Kroah-HartmanFrom: Dave Stevenson <[email protected]>
[ Upstream commit 3c2707632146b22e97b0fbf6778bab8add2eaa1d ]
DRM provides flags for inverting pixel clock and output enable signals, but these were not mapped to the relevant registers.
Add those mappings.
Stable-dep-of: 0870d86eac8a ("drm/vc4: dpi: Fix format mapping for RGB565")
--- drivers/gpu/drm/vc4/vc4_dpi.c | 66 ++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 28 deletions(-)
drivers/gpu/drm/vc4/vc4_dpi.c +38 -28
@@ -148,35 +148,45 @@ static void vc4_dpi_encoder_enable(struct drm_encoder *encoder) }drm_connector_list_iter_end (&conn_iter); -if (connector && connector->display_info.num_bus_formats) { -u32 bus_format = connector->display_info.bus_formats[0 ]; - -switch (bus_format) { -case MEDIA_BUS_FMT_RGB888_1X24 : - dpi_c |=VC4_SET_FIELD (DPI_FORMAT_24BIT_888_RGB , -DPI_FORMAT ); -break ; -case MEDIA_BUS_FMT_BGR888_1X24 : - dpi_c |=VC4_SET_FIELD (DPI_FORMAT_24BIT_888_RGB , -DPI_FORMAT ); - dpi_c |=VC4_SET_FIELD (DPI_ORDER_BGR ,DPI_ORDER ); -break ; -case MEDIA_BUS_FMT_RGB666_1X24_CPADHI : - dpi_c |=VC4_SET_FIELD (DPI_FORMAT_18BIT_666_RGB_2 , -DPI_FORMAT ); -break ; -case MEDIA_BUS_FMT_RGB666_1X18 : - dpi_c |=VC4_SET_FIELD (DPI_FORMAT_18BIT_666_RGB_1 , -DPI_FORMAT ); -break ; -case MEDIA_BUS_FMT_RGB565_1X16 : - dpi_c |=VC4_SET_FIELD (DPI_FORMAT_16BIT_565_RGB_3 , -DPI_FORMAT ); -break ; -default : -DRM_ERROR ("Unknown media bus format %d\n" , bus_format); -break ; +if (connector) { +if (connector->display_info.num_bus_formats) { +u32 bus_format = connector->display_info.bus_formats[0 ]; + +switch (bus_format) { +case MEDIA_BUS_FMT_RGB888_1X24 : + dpi_c |=VC4_SET_FIELD (DPI_FORMAT_24BIT_888_RGB , +DPI_FORMAT ); +break ; +case MEDIA_BUS_FMT_BGR888_1X24 : + dpi_c |=VC4_SET_FIELD (DPI_FORMAT_24BIT_888_RGB , +DPI_FORMAT ); + dpi_c |=VC4_SET_FIELD (DPI_ORDER_BGR , +DPI_ORDER ); +break ; +case MEDIA_BUS_FMT_RGB666_1X24_CPADHI : + dpi_c |=VC4_SET_FIELD (DPI_FORMAT_18BIT_666_RGB_2 , +DPI_FORMAT ); +break ; +case MEDIA_BUS_FMT_RGB666_1X18 : + dpi_c |=VC4_SET_FIELD (DPI_FORMAT_18BIT_666_RGB_1 , +DPI_FORMAT ); +break ; +case MEDIA_BUS_FMT_RGB565_1X16 : + dpi_c |=VC4_SET_FIELD (DPI_FORMAT_16BIT_565_RGB_3 , +DPI_FORMAT ); +break ; +default : +DRM_ERROR ("Unknown media bus format %d\n" , + bus_format); +break ; + } } + +if (connector->display_info.bus_flags &DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE ) + dpi_c |=DPI_PIXEL_CLK_INVERT ; + +if (connector->display_info.bus_flags &DRM_BUS_FLAG_DE_LOW ) + dpi_c |=DPI_OUTPUT_ENABLE_INVERT ; }else {/* Default to 24bit if no connector found. */ dpi_c |=VC4_SET_FIELD (DPI_FORMAT_24BIT_888_RGB ,DPI_FORMAT );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 172/567 drm/vc4: dpi: Fix format mapping for RGB565
In reply to Greg Kroah-HartmanFrom: Dave Stevenson <[email protected]>
[ Upstream commit 0870d86eac8a9abd89a0be1b719d5dc5bac936f0 ]
The mapping is incorrect for RGB565_1X16 as it should be DPI_FORMAT_18BIT_666_RGB_1 instead of DPI_FORMAT_18BIT_666_RGB_3.
--- drivers/gpu/drm/vc4/vc4_dpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_dpi.c +1 -1
@@ -172,7 +172,7 @@ static void vc4_dpi_encoder_enable(struct drm_encoder *encoder) DPI_FORMAT);break ;case MEDIA_BUS_FMT_RGB565_1X16 : - dpi_c |=VC4_SET_FIELD (DPI_FORMAT_16BIT_565_RGB_3 , + dpi_c |=VC4_SET_FIELD (DPI_FORMAT_16BIT_565_RGB_1 ,DPI_FORMAT );break ;default :
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 173/567 drm: tidss: Fix pixel format definition
In reply to Greg Kroah-HartmanFrom: Randolph Sapp <[email protected]>
[ Upstream commit 2df0433b18f2735a49d2c3a968b40fa2881137c0 ]
There was a long-standing bug from a typo that created 2 ARGB1555 and ABGR1555 pixel format entries. Weston 10 has a sanity check that alerted me to this issue.
According to the Supported Pixel Data formats table we have the later entries should have been for Alpha-X instead.
--- drivers/gpu/drm/tidss/tidss_dispc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/tidss/tidss_dispc.c +2 -2
@@ -1855,8 +1855,8 @@ static const struct { { DRM_FORMAT_XBGR4444, 0x21, }, { DRM_FORMAT_RGBX4444, 0x22, }, - { DRM_FORMAT_ARGB1555, 0x25, }, - { DRM_FORMAT_ABGR1555, 0x26, }, + { DRM_FORMAT_XRGB1555, 0x25, }, + { DRM_FORMAT_XBGR1555, 0x26, }, { DRM_FORMAT_XRGB8888, 0x27, }, { DRM_FORMAT_XBGR8888, 0x28, },
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 174/567 gpu: ipu-v3: common: Add of_node_put() for reference returned by of_graph_get_port_by_id()
In reply to Greg Kroah-HartmanFrom: Liang He <[email protected]>
[ Upstream commit 9afdf98cfdfa2ba8ec068cf08c5fcdc1ed8daf3f ]
In ipu_add_client_devices(), we need to call of_node_put() for reference returned by of_graph_get_port_by_id() in fail path.
--- drivers/gpu/ipu-v3/ipu-common.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/ipu-v3/ipu-common.c +1 -0
@@ -1165,6 +1165,7 @@ static int ipu_add_client_devices(struct ipu_soc *ipu, unsigned long ipu_base) pdev =platform_device_alloc (reg->name, id++);if (!pdev) { ret = -ENOMEM ; +of_node_put (of_node); goto err_register; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 175/567 hwmon: (ftsteutates) Fix scaling of measurements
In reply to Greg Kroah-HartmanFrom: Armin Wolf <[email protected]>
[ Upstream commit ca8fd8c16a8b77dfcf7f6ce52d2c863220693a78 ]
A user complained that the ftsteutates driver was displaying bogus values since its introduction. This happens because the sensor measurements need to be scaled in order to produce meaningful results:
- the fan speed needs to be multiplied by 60 since its in RPS
- the temperature is in degrees celsius and needs an offset of 64
- the voltage is in 1/256 of 3.3V
The offical datasheet says the voltage needs to be divided by 256, but this is likely an off-by-one-error, since even the BIOS devides by 255 (otherwise 3.3V could not be measured).
The voltage channels additionally need a board-specific multiplier, however this can be done by the driver since its board-specific.
The reason the missing scaling of measurements is the way Fujitsu used this driver when it was still out-of-tree. Back then, all scaling was done in userspace by libsensors, even the generic one.
Tested on a Fujitsu DS3401-B1.
--- Documentation/hwmon/ftsteutates.rst | 4 ++++ drivers/hwmon/ftsteutates.c | 19 +++++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-)
Documentation/hwmon/ftsteutates.rst +4 -0
@@ -22,6 +22,10 @@ enhancements. It can monitor up to 4 voltages, 16 temperatures and 8 fans. It also contains an integrated watchdog which is currently implemented in this driver. +The 4 voltages require a board-specific multiplier, since the BMC can +only measure voltages up to 3.3V and thus relies on voltage dividers. +Consult your motherboard manual for details. + To clear a temperature or fan alarm, execute the following command with the correct path to the alarm file::
drivers/hwmon/ftsteutates.c +13 -6
@@ -12,6 +12,7 @@#include <linux/i2c.h> #include <linux/init.h> #include <linux/jiffies.h> +#include <linux/math.h> #include <linux/module.h> #include <linux/mutex.h> #include <linux/slab.h>
@@ -347,13 +348,15 @@ static ssize_t in_value_show(struct device *dev, {struct fts_data *data =dev_get_drvdata (dev);int index =to_sensor_dev_attr (devattr)->index; -int err; +int value, err; err =fts_update_device (data);if (err <0 )return err; -return sprintf (buf,"%u\n" , data->volt[index]); + value =DIV_ROUND_CLOSEST (data->volt[index] *3300 ,255 ); + +return sprintf (buf,"%d\n" , value); } static ssize_t temp_value_show(struct device *dev,
@@ -361,13 +364,15 @@ static ssize_t temp_value_show(struct device *dev, {struct fts_data *data =dev_get_drvdata (dev);int index =to_sensor_dev_attr (devattr)->index; -int err; +int value, err; err =fts_update_device (data);if (err <0 )return err; -return sprintf (buf,"%u\n" , data->temp_input[index]); + value = (data->temp_input[index] -64 ) *1000 ; + +return sprintf (buf,"%d\n" , value); } static ssize_t temp_fault_show(struct device *dev,
@@ -436,13 +441,15 @@ static ssize_t fan_value_show(struct device *dev, {struct fts_data *data =dev_get_drvdata (dev);int index =to_sensor_dev_attr (devattr)->index; -int err; +int value, err; err =fts_update_device (data);if (err <0 )return err; -return sprintf (buf,"%u\n" , data->fan_input[index]); + value = data->fan_input[index] *60 ; + +return sprintf (buf,"%d\n" , value); } static ssize_t fan_source_show(struct device *dev,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 176/567 drm/msm/hdmi: Add missing check for alloc_ordered_workqueue
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit afe4cb96153a0d8003e4e4ebd91b5c543e10df84 ]
Add check for the return value of alloc_ordered_workqueue as it may return NULL pointer and cause NULL pointer dereference in hdmi_hdcp.c and hdmi_hpd.c.
Patchwork: https://patchwork.freedesktop.org/patch/517211/
--- drivers/gpu/drm/msm/hdmi/hdmi.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/msm/hdmi/hdmi.c +4 -0
@@ -264,6 +264,10 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev)devm_pm_runtime_enable (&pdev->dev); hdmi->workq =alloc_ordered_workqueue ("msm_hdmi" ,0 ); +if (!hdmi->workq) { + ret = -ENOMEM ; + goto fail; + } hdmi->i2c =msm_hdmi_i2c_init (hdmi);if (IS_ERR (hdmi->i2c)) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 177/567 pinctrl: qcom: pinctrl-msm8976: Correct function names for wcss pins
In reply to Greg Kroah-HartmanFrom: Adam Skladowski <[email protected]>
[ Upstream commit a7cc0e2685082a0d79baec02df184dfa83cbfac3 ]
Adjust names of function for wcss pins, also fix third gpio in bt group.
--- drivers/pinctrl/qcom/pinctrl-msm8976.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/pinctrl/qcom/pinctrl-msm8976.c +4 -4
@@ -733,7 +733,7 @@ static const char * const codec_int2_groups[] = { "gpio74", };static const char *const wcss_bt_groups[] = { -"gpio39" ,"gpio47" ,"gpio88" , +"gpio39" ,"gpio47" ,"gpio48" , };static const char *const sdc3_groups[] = {"gpio39" ,"gpio40" ,"gpio41" ,
@@ -958,9 +958,9 @@ static const struct msm_pingroup msm8976_groups[] = {PINGROUP (37 ,NA ,NA ,NA , qdss_tracedata_b,NA ,NA ,NA ,NA ,NA ),PINGROUP (38 ,NA ,NA ,NA ,NA ,NA ,NA ,NA , qdss_tracedata_b,NA ),PINGROUP (39 , wcss_bt, sdc3,NA , qdss_tracedata_a,NA ,NA ,NA ,NA ,NA ), -PINGROUP (40 , wcss_wlan, sdc3,NA , qdss_tracedata_a,NA ,NA ,NA ,NA ,NA ), -PINGROUP (41 , wcss_wlan, sdc3,NA , qdss_tracedata_a,NA ,NA ,NA ,NA ,NA ), -PINGROUP (42 , wcss_wlan, sdc3,NA , qdss_tracedata_a,NA ,NA ,NA ,NA ,NA ), +PINGROUP (40 , wcss_wlan2, sdc3,NA , qdss_tracedata_a,NA ,NA ,NA ,NA ,NA ), +PINGROUP (41 , wcss_wlan1, sdc3,NA , qdss_tracedata_a,NA ,NA ,NA ,NA ,NA ), +PINGROUP (42 , wcss_wlan0, sdc3,NA , qdss_tracedata_a,NA ,NA ,NA ,NA ,NA ),PINGROUP (43 , wcss_wlan, sdc3,NA ,NA , qdss_tracedata_a,NA ,NA ,NA ,NA ),PINGROUP (44 , wcss_wlan, sdc3,NA ,NA ,NA ,NA ,NA ,NA ,NA ), PINGROUP(45, wcss_fm, NA, qdss_tracectl_a, NA, NA, NA, NA, NA, NA),
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 178/567 pinctrl: stm32: Fix refcount leak in stm32_pctrl_get_irq_domain
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit dcef18c8ac40aa85bb339f64c1dd31dd458b06fb ]
of_irq_find_parent() returns a node pointer with refcount incremented, We should use of_node_put() on it when not needed anymore. Add missing of_node_put() to avoid refcount leak.
--- drivers/pinctrl/stm32/pinctrl-stm32.c | 1 + 1 file changed, 1 insertion(+)
drivers/pinctrl/stm32/pinctrl-stm32.c +1 -0
@@ -1334,6 +1334,7 @@ static struct irq_domain *stm32_pctrl_get_irq_domain(struct device_node *np)return ERR_PTR (-ENXIO ); domain =irq_find_host (parent); +of_node_put (parent);if (!domain)/* domain not registered yet */ return ERR_PTR (-EPROBE_DEFER );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 179/567 pinctrl: rockchip: Fix refcount leak in rockchip_pinctrl_parse_groups
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit c818ae563bf99457f02e8170aabd6b174f629f65 ]
of_find_node_by_phandle() returns a node pointer with refcount incremented, We should use of_node_put() on it when not needed anymore.
Add missing of_node_put() to avoid refcount leak.
--- drivers/pinctrl/pinctrl-rockchip.c | 1 + 1 file changed, 1 insertion(+)
drivers/pinctrl/pinctrl-rockchip.c +1 -0
@@ -2499,6 +2499,7 @@ static int rockchip_pinctrl_parse_groups(struct device_node *np, np_config =of_find_node_by_phandle (be32_to_cpup (phandle)); ret =pinconf_generic_parse_dt_config (np_config,NULL , &grp->data[j].configs, &grp->data[j].nconfigs); +of_node_put (np_config);if (ret)return ret; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 180/567 drm/vc4: hvs: Set AXI panic modes
In reply to Greg Kroah-HartmanFrom: Dave Stevenson <[email protected]>
[ Upstream commit df993fced230daa8452892406f3180c93ebf7e7b ]
The HVS can change AXI request mode based on how full the COB FIFOs are.
Until now the vc4 driver has been relying on the firmware to have set these to sensible values.
With HVS channel 2 now being used for live video, change the panic mode for all channels to be explicitly set by the driver, and the same for all channels.
--- drivers/gpu/drm/vc4/vc4_hvs.c | 11 +++++++++++ drivers/gpu/drm/vc4/vc4_regs.h | 6 ++++++ 2 files changed, 17 insertions(+)
drivers/gpu/drm/vc4/vc4_hvs.c +11 -0
@@ -718,6 +718,17 @@ static int vc4_hvs_bind(struct device *dev, struct device *master, void *data)SCALER_DISPCTRL_DSPEISLUR (2 ) | SCALER_DISPCTRL_SCLEIRQ); +/* Set AXI panic mode. +* VC4 panics when < 2 lines in FIFO. +* VC5 panics when less than 1 line in the FIFO. +*/ + dispctrl &= ~(SCALER_DISPCTRL_PANIC0_MASK | +SCALER_DISPCTRL_PANIC1_MASK | +SCALER_DISPCTRL_PANIC2_MASK ); + dispctrl |=VC4_SET_FIELD (2 ,SCALER_DISPCTRL_PANIC0 ); + dispctrl |=VC4_SET_FIELD (2 ,SCALER_DISPCTRL_PANIC1 ); + dispctrl |=VC4_SET_FIELD (2 ,SCALER_DISPCTRL_PANIC2 ); +HVS_WRITE (SCALER_DISPCTRL , dispctrl); ret = devm_request_irq(dev, platform_get_irq(pdev, 0),
drivers/gpu/drm/vc4/vc4_regs.h +6 -0
@@ -220,6 +220,12 @@#define SCALER_DISPCTRL 0x00000000/* Global register for clock gating the HVS */ # define SCALER_DISPCTRL_ENABLE BIT(31) +# define SCALER_DISPCTRL_PANIC0_MASK VC4_MASK(25, 24) +# define SCALER_DISPCTRL_PANIC0_SHIFT 24 +# define SCALER_DISPCTRL_PANIC1_MASK VC4_MASK(27, 26) +# define SCALER_DISPCTRL_PANIC1_SHIFT 26 +# define SCALER_DISPCTRL_PANIC2_MASK VC4_MASK(29, 28) +# define SCALER_DISPCTRL_PANIC2_SHIFT 28# define SCALER_DISPCTRL_DSP3_MUX_MASK VC4_MASK(19, 18)# define SCALER_DISPCTRL_DSP3_MUX_SHIFT 18
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 181/567 drm/vc4: hvs: Fix colour order for xRGB1555 on HVS5
In reply to Greg Kroah-HartmanFrom: Dave Stevenson <[email protected]>
[ Upstream commit 902973dc1a049c0d7bf0c222b8f2b3876f01b4a2 ]
Same as the xRGB8888 formats, HVS5 has managed to swap the colour channels for the xRGB1555 formats as well. Add the relevant config for pixel_order_hvs5.
--- drivers/gpu/drm/vc4/vc4_plane.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/vc4/vc4_plane.c +2 -0
@@ -72,11 +72,13 @@ static const struct hvs_format { .drm = DRM_FORMAT_ARGB1555, .hvs = HVS_PIXEL_FORMAT_RGBA5551, .pixel_order = HVS_PIXEL_ORDER_ABGR, + .pixel_order_hvs5 = HVS_PIXEL_ORDER_ARGB, }, { .drm = DRM_FORMAT_XRGB1555, .hvs = HVS_PIXEL_FORMAT_RGBA5551, .pixel_order = HVS_PIXEL_ORDER_ABGR, + .pixel_order_hvs5 = HVS_PIXEL_ORDER_ARGB, }, { .drm = DRM_FORMAT_RGB888,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 182/567 drm/vc4: hdmi: Correct interlaced timings again
In reply to Greg Kroah-HartmanFrom: Dave Stevenson <[email protected]>
[ Upstream commit 771d6539f27bd55f43d8a95d53a7eeaaffa2681c ]
The back porch timings were correct, only the sync offset was wrong. Correct timing is now reported for 1080i and 576i, but the h offset is incorrect for 480i for non-obvious reasons.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +3 -2
@@ -785,11 +785,12 @@ static void vc5_hdmi_set_timings(struct vc4_hdmi *vc4_hdmi, VC4_SET_FIELD(mode->crtc_vdisplay, VC5_HDMI_VERTA_VAL));u32 vertb = (VC4_SET_FIELD (mode->htotal >> (2 - pixel_rep),VC5_HDMI_VERTB_VSPO ) | -VC4_SET_FIELD (mode->crtc_vtotal - mode->crtc_vsync_end, +VC4_SET_FIELD (mode->crtc_vtotal - mode->crtc_vsync_end + + interlaced,VC4_HDMI_VERTB_VBP ));u32 vertb_even = (VC4_SET_FIELD (0 ,VC5_HDMI_VERTB_VSPO ) |VC4_SET_FIELD (mode->crtc_vtotal - - mode->crtc_vsync_end - interlaced, + mode->crtc_vsync_end,VC4_HDMI_VERTB_VBP ));unsigned char gcp;bool gcp_en;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 183/567 drm/msm: clean event_thread->worker in case of an error
In reply to Greg Kroah-HartmanFrom: Dmitry Baryshkov <[email protected]>
[ Upstream commit c79bb6b92defdcb834ceeeed9c1cf591beb1b71a ]
If worker creation fails, nullify the event_thread->worker, so that msm_drm_uninit() doesn't try accessing invalid memory location. While we are at it, remove duplicate assignment to the ret variable.
Patchwork: https://patchwork.freedesktop.org/patch/490106/
--- drivers/gpu/drm/msm/msm_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/msm_drv.c +1 -1
@@ -609,7 +609,7 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv)if (IS_ERR (priv->event_thread[i].worker)) { ret =PTR_ERR (priv->event_thread[i].worker);DRM_DEV_ERROR (dev,"failed to create crtc_event kthread\n" ); - ret =PTR_ERR (priv->event_thread[i].worker); + priv->event_thread[i].worker =NULL ; goto err_msm_uninit; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 184/567 scsi: qla2xxx: edif: Fix I/O timeout due to over-subscription
In reply to Greg Kroah-HartmanFrom: Quinn Tran <[email protected]>
[ Upstream commit 63ab6cb582fad3757a03f466db671729b97f2df8 ]
The current edif code does not keep track of FW IOCB resources. This led to IOCB queue full on error recovery (I/O timeout). Make use of the existing code that tracks IOCB resources to prevent over-subscription.
Stable-dep-of: 41e5afe51f75 ("scsi: qla2xxx: Fix exchange oversubscription")
--- drivers/scsi/qla2xxx/qla_edif.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/scsi/qla2xxx/qla_edif.c +7 -0
@@ -2898,6 +2898,12 @@ qla28xx_start_scsi_edif(srb_t *sp) tot_dsds = nseg; req_cnt =qla24xx_calc_iocbs (vha, tot_dsds); + + sp->iores.res_type =RESOURCE_INI ; + sp->iores.iocb_cnt = req_cnt; +if (qla_get_iocbs (sp->qpair, &sp->iores)) + goto queuing_error; +if (req->cnt < (req_cnt +2 )) { cnt =IS_SHADOW_REG_CAPABLE (ha) ? *req->out_ptr :rd_reg_dword (req->req_q_out);
@@ -3089,6 +3095,7 @@ qla28xx_start_scsi_edif(srb_t *sp)mempool_free (sp->u.scmd.ct6_ctx, ha->ctx_mempool); sp->u.scmd.ct6_ctx =NULL ; } +qla_put_iocbs (sp->qpair, &sp->iores);spin_unlock_irqrestore (lock, flags);return QLA_FUNCTION_FAILED ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 185/567 scsi: qla2xxx: Fix exchange oversubscription
In reply to Greg Kroah-HartmanFrom: Quinn Tran <[email protected]>
[ Upstream commit 41e5afe51f75f2858f5563145348f6c26d307b8f ]
In large environment, it is possible to experience command timeout and escalation of path recovery. Currently the driver does not track the number of exchanges/commands sent to FW. If there is a delay for commands at the head of the queue, then this will create back pressure for commands at the back of the queue.
Check for exchange availability before command submission.
--- drivers/scsi/qla2xxx/qla_def.h | 6 +++- drivers/scsi/qla2xxx/qla_edif.c | 7 +++-- drivers/scsi/qla2xxx/qla_init.c | 13 ++++++++ drivers/scsi/qla2xxx/qla_inline.h | 52 +++++++++++++++++++++---------- drivers/scsi/qla2xxx/qla_iocb.c | 28 ++++++++++------- drivers/scsi/qla2xxx/qla_isr.c | 3 +- drivers/scsi/qla2xxx/qla_nvme.c | 15 ++++++++- 7 files changed, 88 insertions(+), 36 deletions(-)
drivers/scsi/qla2xxx/qla_def.h +5 -1
@@ -655,7 +655,7 @@ enum {struct iocb_resource {u8 res_type; -u8 pad; +u8 exch_cnt;u16 iocb_cnt; };
@@ -3707,6 +3707,10 @@ struct qla_fw_resources {u16 iocbs_limit;u16 iocbs_qp_limit;u16 iocbs_used; +u16 exch_total; +u16 exch_limit; +u16 exch_used; +u16 pad; };#define QLA_IOCB_PCT_LIMIT 95
drivers/scsi/qla2xxx/qla_edif.c +4 -3
@@ -2899,9 +2899,10 @@ qla28xx_start_scsi_edif(srb_t *sp) tot_dsds = nseg; req_cnt =qla24xx_calc_iocbs (vha, tot_dsds); - sp->iores.res_type =RESOURCE_INI ; + sp->iores.res_type =RESOURCE_IOCB |RESOURCE_EXCH ; + sp->iores.exch_cnt =1 ; sp->iores.iocb_cnt = req_cnt; -if (qla_get_iocbs (sp->qpair, &sp->iores)) +if (qla_get_fw_resources (sp->qpair, &sp->iores)) goto queuing_error;if (req->cnt < (req_cnt +2 )) {
@@ -3095,7 +3096,7 @@ qla28xx_start_scsi_edif(srb_t *sp)mempool_free (sp->u.scmd.ct6_ctx, ha->ctx_mempool); sp->u.scmd.ct6_ctx =NULL ; } -qla_put_iocbs (sp->qpair, &sp->iores); +qla_put_fw_resources (sp->qpair, &sp->iores);spin_unlock_irqrestore (lock, flags);return QLA_FUNCTION_FAILED ;
drivers/scsi/qla2xxx/qla_init.c +13 -0
@@ -128,12 +128,14 @@ static void qla24xx_abort_iocb_timeout(void *data) sp->cmd_sp)) { qpair->req->outstanding_cmds[handle] =NULL ; cmdsp_found =1 ; +qla_put_fw_resources (qpair, &sp->cmd_sp->iores); }/* removing the abort */ if (qpair->req->outstanding_cmds[handle] == sp) { qpair->req->outstanding_cmds[handle] =NULL ; sp_found =1 ; +qla_put_fw_resources (qpair, &sp->iores);break ; } }
@@ -2002,6 +2004,7 @@ qla2x00_tmf_iocb_timeout(void *data)for (h =1 ; h < sp->qpair->req->num_outstanding_cmds; h++) {if (sp->qpair->req->outstanding_cmds[h] == sp) { sp->qpair->req->outstanding_cmds[h] =NULL ; +qla_put_fw_resources (sp->qpair, &sp->iores);break ; } }
@@ -3945,6 +3948,12 @@ void qla_init_iocb_limit(scsi_qla_host_t *vha) ha->base_qpair->fwres.iocbs_limit = limit; ha->base_qpair->fwres.iocbs_qp_limit = limit / num_qps; ha->base_qpair->fwres.iocbs_used =0 ; + + ha->base_qpair->fwres.exch_total = ha->orig_fw_xcb_count; + ha->base_qpair->fwres.exch_limit = (ha->orig_fw_xcb_count * +QLA_IOCB_PCT_LIMIT ) /100 ; + ha->base_qpair->fwres.exch_used =0 ; +for (i =0 ; i < ha->max_qpairs; i++) {if (ha->queue_pair_map[i]) { ha->queue_pair_map[i]->fwres.iocbs_total =
@@ -3953,6 +3962,10 @@ void qla_init_iocb_limit(scsi_qla_host_t *vha) ha->queue_pair_map[i]->fwres.iocbs_qp_limit = limit / num_qps; ha->queue_pair_map[i]->fwres.iocbs_used =0 ; + ha->queue_pair_map[i]->fwres.exch_total = ha->orig_fw_xcb_count; + ha->queue_pair_map[i]->fwres.exch_limit = + (ha->orig_fw_xcb_count *QLA_IOCB_PCT_LIMIT ) /100 ; + ha->queue_pair_map[i]->fwres.exch_used =0 ; } } }
drivers/scsi/qla2xxx/qla_inline.h +35 -17
88 lines not on this page · raw message
drivers/scsi/qla2xxx/qla_iocb.c +16 -12
@@ -1589,9 +1589,10 @@ qla24xx_start_scsi(srb_t *sp) tot_dsds = nseg; req_cnt =qla24xx_calc_iocbs (vha, tot_dsds); - sp->iores.res_type =RESOURCE_INI ; + sp->iores.res_type =RESOURCE_IOCB |RESOURCE_EXCH ; + sp->iores.exch_cnt =1 ; sp->iores.iocb_cnt = req_cnt; -if (qla_get_iocbs (sp->qpair, &sp->iores)) +if (qla_get_fw_resources (sp->qpair, &sp->iores)) goto queuing_error;if (req->cnt < (req_cnt +2 )) {
@@ -1678,7 +1679,7 @@ qla24xx_start_scsi(srb_t *sp)if (tot_dsds)scsi_dma_unmap (cmd); -qla_put_iocbs (sp->qpair, &sp->iores); +qla_put_fw_resources (sp->qpair, &sp->iores);spin_unlock_irqrestore (&ha->hardware_lock, flags);return QLA_FUNCTION_FAILED ;
@@ -1793,9 +1794,10 @@ qla24xx_dif_start_scsi(srb_t *sp) tot_prot_dsds = nseg; tot_dsds += nseg; - sp->iores.res_type =RESOURCE_INI ; + sp->iores.res_type =RESOURCE_IOCB |RESOURCE_EXCH ; + sp->iores.exch_cnt =1 ; sp->iores.iocb_cnt =qla24xx_calc_iocbs (vha, tot_dsds); -if (qla_get_iocbs (sp->qpair, &sp->iores)) +if (qla_get_fw_resources (sp->qpair, &sp->iores)) goto queuing_error;if (req->cnt < (req_cnt +2 )) {
@@ -1883,7 +1885,7 @@ qla24xx_dif_start_scsi(srb_t *sp) }/* Cleanup will be performed by the caller (queuecommand) */ -qla_put_iocbs (sp->qpair, &sp->iores); +qla_put_fw_resources (sp->qpair, &sp->iores);spin_unlock_irqrestore (&ha->hardware_lock, flags);return QLA_FUNCTION_FAILED ;
@@ -1952,9 +1954,10 @@ qla2xxx_start_scsi_mq(srb_t *sp) tot_dsds = nseg; req_cnt =qla24xx_calc_iocbs (vha, tot_dsds); - sp->iores.res_type =RESOURCE_INI ; + sp->iores.res_type =RESOURCE_IOCB |RESOURCE_EXCH ; + sp->iores.exch_cnt =1 ; sp->iores.iocb_cnt = req_cnt; -if (qla_get_iocbs (sp->qpair, &sp->iores)) +if (qla_get_fw_resources (sp->qpair, &sp->iores)) goto queuing_error;if (req->cnt < (req_cnt +2 )) {
@@ -2041,7 +2044,7 @@ qla2xxx_start_scsi_mq(srb_t *sp)if (tot_dsds)scsi_dma_unmap (cmd); -qla_put_iocbs (sp->qpair, &sp->iores); +qla_put_fw_resources (sp->qpair, &sp->iores);spin_unlock_irqrestore (&qpair->qp_lock, flags);return QLA_FUNCTION_FAILED ;
@@ -2171,9 +2174,10 @@ qla2xxx_dif_start_scsi_mq(srb_t *sp) tot_prot_dsds = nseg; tot_dsds += nseg; - sp->iores.res_type =RESOURCE_INI ; + sp->iores.res_type =RESOURCE_IOCB |RESOURCE_EXCH ; + sp->iores.exch_cnt =1 ; sp->iores.iocb_cnt =qla24xx_calc_iocbs (vha, tot_dsds); -if (qla_get_iocbs (sp->qpair, &sp->iores)) +if (qla_get_fw_resources (sp->qpair, &sp->iores)) goto queuing_error;if (req->cnt < (req_cnt +2 )) {
@@ -2260,7 +2264,7 @@ qla2xxx_dif_start_scsi_mq(srb_t *sp) }/* Cleanup will be performed by the caller (queuecommand) */ -qla_put_iocbs (sp->qpair, &sp->iores); +qla_put_fw_resources (sp->qpair, &sp->iores);spin_unlock_irqrestore (&qpair->qp_lock, flags);return QLA_FUNCTION_FAILED ;
drivers/scsi/qla2xxx/qla_isr.c +1 -2
@@ -3184,7 +3184,7 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt) }return ; } -qla_put_iocbs (sp->qpair, &sp->iores); +qla_put_fw_resources (sp->qpair, &sp->iores);if (sp->cmd_type !=TYPE_SRB ) { req->outstanding_cmds[handle] =NULL ;
@@ -3605,7 +3605,6 @@ qla2x00_error_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, sts_entry_t *pkt)default : sp =qla2x00_get_sp_from_handle (vha, func, req, pkt);if (sp) { -qla_put_iocbs (sp->qpair, &sp->iores); sp->done (sp, res);return 0 ; }
drivers/scsi/qla2xxx/qla_nvme.c +14 -1
@@ -438,13 +438,24 @@ static inline int qla2x00_start_nvme_mq(srb_t *sp) goto queuing_error; } req_cnt =qla24xx_calc_iocbs (vha, tot_dsds); + + sp->iores.res_type =RESOURCE_IOCB |RESOURCE_EXCH ; + sp->iores.exch_cnt =1 ; + sp->iores.iocb_cnt = req_cnt; +if (qla_get_fw_resources (sp->qpair, &sp->iores)) { + rval = -EBUSY ; + goto queuing_error; + } +if (req->cnt < (req_cnt +2 )) {if (IS_SHADOW_REG_CAPABLE (ha)) { cnt = *req->out_ptr; }else { cnt =rd_reg_dword_relaxed (req->req_q_out); -if (qla2x00_check_reg16_for_disconnect (vha, cnt)) +if (qla2x00_check_reg16_for_disconnect (vha, cnt)) { + rval = -EBUSY ; goto queuing_error; + } }if (req->ring_index < cnt)
@@ -589,6 +600,8 @@ static inline int qla2x00_start_nvme_mq(srb_t *sp)wrt_reg_dword (req->req_q_in, req->ring_index); queuing_error: +if (rval) +qla_put_fw_resources (sp->qpair, &sp->iores);spin_unlock_irqrestore (&qpair->qp_lock, flags);return rval;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 186/567 scsi: qla2xxx: Fix exchange oversubscription for management commands
In reply to Greg Kroah-HartmanFrom: Quinn Tran <[email protected]>
[ Upstream commit 5f63a163ed2f12c34dd4ae9b2757962ec7bb86e5 ]
Add resource checking for management (non-I/O) commands.
--- drivers/scsi/qla2xxx/qla_dfs.c | 10 ++++- drivers/scsi/qla2xxx/qla_inline.h | 5 ++- drivers/scsi/qla2xxx/qla_iocb.c | 67 +++++++++++++++++++++++++++++++ drivers/scsi/qla2xxx/qla_isr.c | 1 + 4 files changed, 80 insertions(+), 3 deletions(-)
drivers/scsi/qla2xxx/qla_dfs.c +8 -2
@@ -235,7 +235,7 @@ qla_dfs_fw_resource_cnt_show(struct seq_file *s, void *unused)uint16_t mb[MAX_IOCB_MB_REG ];int rc;struct qla_hw_data *ha = vha->hw; -u16 iocbs_used, i; +u16 iocbs_used, i, exch_used; rc =qla24xx_res_count_wait (vha, mb,SIZEOF_IOCB_MB_REG );if (rc !=QLA_SUCCESS ) {
@@ -263,13 +263,19 @@ qla_dfs_fw_resource_cnt_show(struct seq_file *s, void *unused)if (ql2xenforce_iocb_limit) {/* lock is not require. It's an estimate. */ iocbs_used = ha->base_qpair->fwres.iocbs_used; + exch_used = ha->base_qpair->fwres.exch_used;for (i =0 ; i < ha->max_qpairs; i++) { -if (ha->queue_pair_map[i]) +if (ha->queue_pair_map[i]) { iocbs_used += ha->queue_pair_map[i]->fwres.iocbs_used; + exch_used += ha->queue_pair_map[i]->fwres.exch_used; + } }seq_printf (s,"Driver: estimate iocb used [%d] high water limit [%d]\n" , iocbs_used, ha->base_qpair->fwres.iocbs_limit); + +seq_printf (s,"estimate exchange used[%d] high water limit [%d] n" , + exch_used, ha->base_qpair->fwres.exch_limit); }return 0 ;
drivers/scsi/qla2xxx/qla_inline.h +4 -1
@@ -380,7 +380,7 @@ qla2xxx_get_fc4_priority(struct scsi_qla_host *vha)enum {RESOURCE_NONE , -RESOURCE_IOCB =BIT_0 , +RESOURCE_IOCB =BIT_0 ,RESOURCE_EXCH =BIT_1 ,/* exchange */ RESOURCE_FORCE =BIT_2 , };
@@ -396,6 +396,8 @@ qla_get_fw_resources(struct qla_qpair *qp, struct iocb_resource *iores) iores->res_type =RESOURCE_NONE ;return 0 ; } +if (iores->res_type &RESOURCE_FORCE ) + goto force;if ((iores->iocb_cnt + qp->fwres.iocbs_used) >= qp->fwres.iocbs_qp_limit) {/* no need to acquire qpair lock. It's just rough calculation */
@@ -423,6 +425,7 @@ qla_get_fw_resources(struct qla_qpair *qp, struct iocb_resource *iores)return -ENOSPC ; } } +force: qp->fwres.iocbs_used += iores->iocb_cnt; qp->fwres.exch_used += iores->exch_cnt;return 0 ;
drivers/scsi/qla2xxx/qla_iocb.c +67 -0
85 lines not on this page · raw message
drivers/scsi/qla2xxx/qla_isr.c +1 -0
@@ -3099,6 +3099,7 @@ qla25xx_process_bidir_status_iocb(scsi_qla_host_t *vha, void *pkt, } bsg_reply->reply_payload_rcv_len =0 ; +qla_put_fw_resources (sp->qpair, &sp->iores); done:/* Return the vendor specific reply to API */ bsg_reply->reply_data.vendor_reply.vendor_rsp[0 ] = rval;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 187/567 ASoC: fsl_sai: Update to modern clocking terminology
In reply to Greg Kroah-HartmanFrom: Mark Brown <[email protected]>
[ Upstream commit 361284a4eb598eaf28e8458c542f214d3689b134 ]
As part of moving to remove the old style defines for the bus clocks update the fsl_sai driver to use more modern terminology for clocking.
Stable-dep-of: a23924b7dd7b ("ASoC: fsl_sai: initialize is_dsp_mode flag")
--- sound/soc/fsl/fsl_sai.c | 34 +++++++++++++++++----------------- sound/soc/fsl/fsl_sai.h | 2 +- 2 files changed, 18 insertions(+), 18 deletions(-)
sound/soc/fsl/fsl_sai.c +17 -17
@@ -297,23 +297,23 @@ static int fsl_sai_set_dai_fmt_tr(struct snd_soc_dai *cpu_dai,return -EINVAL ; } -/* DAI clock master masks */ -switch (fmt &SND_SOC_DAIFMT_MASTER_MASK ) { -case SND_SOC_DAIFMT_CBS_CFS : +/* DAI clock provider masks */ +switch (fmt &SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK ) { +case SND_SOC_DAIFMT_CBC_CFC : val_cr2 |=FSL_SAI_CR2_BCD_MSTR ; val_cr4 |=FSL_SAI_CR4_FSD_MSTR ; - sai->is_slave_mode = false; + sai->is_consumer_mode = false;break ; -case SND_SOC_DAIFMT_CBM_CFM : - sai->is_slave_mode = true; +case SND_SOC_DAIFMT_CBP_CFP : + sai->is_consumer_mode = true;break ; -case SND_SOC_DAIFMT_CBS_CFM : +case SND_SOC_DAIFMT_CBC_CFP : val_cr2 |=FSL_SAI_CR2_BCD_MSTR ; - sai->is_slave_mode = false; + sai->is_consumer_mode = false;break ; -case SND_SOC_DAIFMT_CBM_CFS : +case SND_SOC_DAIFMT_CBP_CFC : val_cr4 |=FSL_SAI_CR4_FSD_MSTR ; - sai->is_slave_mode = true; + sai->is_consumer_mode = true;break ;default :return -EINVAL ;
@@ -356,8 +356,8 @@ static int fsl_sai_set_bclk(struct snd_soc_dai *dai, bool tx, u32 freq)u32 id;int ret =0 ; -/* Don't apply to slave mode */ -if (sai->is_slave_mode) +/* Don't apply to consumer mode */ +if (sai->is_consumer_mode)return 0 ;/*
@@ -462,7 +462,7 @@ static int fsl_sai_hw_params(struct snd_pcm_substream *substream, pins =DIV_ROUND_UP (channels, slots); -if (!sai->is_slave_mode) { +if (!sai->is_consumer_mode) {if (sai->bclk_ratio) ret = fsl_sai_set_bclk(cpu_dai, tx, sai->bclk_ratio *
@@ -502,12 +502,12 @@ static int fsl_sai_hw_params(struct snd_pcm_substream *substream, val_cr4 |=FSL_SAI_CR4_CHMOD ;/* -* For SAI master mode, when Tx(Rx) sync with Rx(Tx) clock, Rx(Tx) will +* For SAI provider mode, when Tx(Rx) sync with Rx(Tx) clock, Rx(Tx) will * generate bclk and frame clock for Tx(Rx), we should set RCR4(TCR4), * RCR5(TCR5) for playback(capture), or there will be sync error. */ -if (!sai->is_slave_mode &&fsl_sai_dir_is_synced (sai, adir)) { +if (!sai->is_consumer_mode &&fsl_sai_dir_is_synced (sai, adir)) { regmap_update_bits(sai->regmap, FSL_SAI_xCR4(!tx, ofs), FSL_SAI_CR4_SYWD_MASK | FSL_SAI_CR4_FRSZ_MASK | FSL_SAI_CR4_CHMOD_MASK,
@@ -543,7 +543,7 @@ static int fsl_sai_hw_free(struct snd_pcm_substream *substream,regmap_update_bits (sai->regmap,FSL_SAI_xCR3 (tx, ofs),FSL_SAI_CR3_TRCE_MASK ,0 ); -if (!sai->is_slave_mode && +if (!sai->is_consumer_mode && sai->mclk_streams &BIT (substream->stream)) {clk_disable_unprepare (sai->mclk_clk[sai->mclk_id[tx]]); sai->mclk_streams &= ~BIT (substream->stream);
@@ -577,7 +577,7 @@ static void fsl_sai_config_disable(struct fsl_sai *sai, int dir)* This is a hardware bug, and will be fix in the * next sai version. */ -if (!sai->is_slave_mode) { +if (!sai->is_consumer_mode) {/* Software Reset */ regmap_write (sai->regmap,FSL_SAI_xCSR (tx, ofs),FSL_SAI_CSR_SR );/* Clear SR bit to finish the reset */
sound/soc/fsl/fsl_sai.h +1 -1
@@ -259,7 +259,7 @@ struct fsl_sai {struct clk *bus_clk;struct clk *mclk_clk[FSL_SAI_MCLK_MAX ]; -bool is_slave_mode; +bool is_consumer_mode;bool is_lsb_first;bool is_dsp_mode;bool synchronous[2 ];
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 188/567 ASoC: fsl_sai: initialize is_dsp_mode flag
In reply to Greg Kroah-HartmanFrom: Shengjiu Wang <[email protected]>
[ Upstream commit a23924b7dd7b748fff8e305e1daf590fed2af21b ]
Initialize is_dsp_mode flag in the beginning of function fsl_sai_set_dai_fmt_tr().
When the DAIFMT is DAIFMT_DSP_B the first time, is_dsp_mode is true, then the second time DAIFMT is DAIFMT_I2S, is_dsp_mode still true, which is a wrong state. So need to initialize is_dsp_mode flag every time.
--- sound/soc/fsl/fsl_sai.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/fsl/fsl_sai.c +1 -0
@@ -231,6 +231,7 @@ static int fsl_sai_set_dai_fmt_tr(struct snd_soc_dai *cpu_dai,if (!sai->is_lsb_first) val_cr4 |=FSL_SAI_CR4_MF ; + sai->is_dsp_mode = false;/* DAI mode */ switch (fmt &SND_SOC_DAIFMT_FORMAT_MASK ) {case SND_SOC_DAIFMT_I2S :
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 189/567 drm/msm/adreno: Fix null ptr access in adreno_gpu_cleanup()
In reply to Greg Kroah-HartmanFrom: Akhil P Oommen <[email protected]>
[ Upstream commit dbeedbcb268d055d8895aceca427f897e12c2b50 ]
Fix the below kernel panic due to null pointer access:
[ 18.504431] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000048 [ 18.513464] Mem abort info: [ 18.516346] ESR = 0x0000000096000005 [ 18.520204] EC = 0x25: DABT (current EL), IL = 32 bits [ 18.525706] SET = 0, FnV = 0 [ 18.528878] EA = 0, S1PTW = 0 [ 18.532117] FSC = 0x05: level 1 translation fault [ 18.537138] Data abort info: [ 18.540110] ISV = 0, ISS = 0x00000005 [ 18.544060] CM = 0, WnR = 0 [ 18.547109] user pgtable: 4k pages, 39-bit VAs, pgdp=0000000112826000 [ 18.553738] [0000000000000048] pgd=0000000000000000, p4d=0000000000000000, pud=0000000000000000 [ 18.562690] Internal error: Oops: 0000000096000005 [#1] PREEMPT SMP **Snip** [ 18.696758] Call trace: [ 18.699278] adreno_gpu_cleanup+0x30/0x88 [ 18.703396] a6xx_destroy+0xc0/0x130 [ 18.707066] a6xx_gpu_init+0x308/0x424 [ 18.710921] adreno_bind+0x178/0x288 [ 18.714590] component_bind_all+0xe0/0x214 [ 18.718797] msm_drm_bind+0x1d4/0x614 [ 18.722566] try_to_bring_up_aggregate_device+0x16c/0x1b8 [ 18.728105] __component_add+0xa0/0x158 [ 18.732048] component_add+0x20/0x2c [ 18.735719] adreno_probe+0x40/0xc0 [ 18.739300] platform_probe+0xb4/0xd4 [ 18.743068] really_probe+0xfc/0x284 [ 18.746738] __driver_probe_device+0xc0/0xec [ 18.751129] driver_probe_device+0x48/0x110 [ 18.755421] __device_attach_driver+0xa8/0xd0 [ 18.759900] bus_for_each_drv+0x90/0xdc [ 18.763843] __device_attach+0xfc/0x174 [ 18.767786] device_initial_probe+0x20/0x2c [ 18.772090] bus_probe_device+0x40/0xa0 [ 18.776032] deferred_probe_work_func+0x94/0xd0 [ 18.780686] process_one_work+0x190/0x3d0 [ 18.784805] worker_thread+0x280/0x3d4 [ 18.788659] kthread+0x104/0x1c0 [ 18.791981] ret_from_fork+0x10/0x20 [ 18.795654] Code: f9400408 aa0003f3 aa1f03f4 91142015 (f9402516) [ 18.801913] ---[ end trace 0000000000000000 ]--- [ 18.809039] Kernel panic - not syncing: Oops: Fatal exception
Patchwork: https://patchwork.freedesktop.org/patch/515605/
--- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/adreno/adreno_gpu.c +2 -2
@@ -952,13 +952,13 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,void adreno_gpu_cleanup (struct adreno_gpu *adreno_gpu) {struct msm_gpu *gpu = &adreno_gpu->base; -struct msm_drm_private *priv = gpu->dev->dev_private; +struct msm_drm_private *priv = gpu->dev ? gpu->dev->dev_private :NULL ;unsigned int i;for (i =0 ; i <ARRAY_SIZE (adreno_gpu->info->fw); i++)release_firmware (adreno_gpu->fw[i]); -if (pm_runtime_enabled (&priv->gpu_pdev->dev)) +if (priv &&pm_runtime_enabled (&priv->gpu_pdev->dev))pm_runtime_disable (&priv->gpu_pdev->dev);msm_gpu_cleanup (&adreno_gpu->base);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 190/567 ALSA: hda/ca0132: minor fix for allocation size
In reply to Greg Kroah-HartmanFrom: Alexey V. Vissarionov <[email protected]>
[ Upstream commit 3ee0fe7fa39b14d1cea455b7041f2df933bd97d2 ]
Although the "dma_chan" pointer occupies more or equal space compared to "*dma_chan", the allocation size should use the size of variable itself.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- sound/pci/hda/patch_ca0132.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/hda/patch_ca0132.c +1 -1
@@ -2455,7 +2455,7 @@ static int dspio_set_uint_param(struct hda_codec *codec, int mod_id,static int dspio_alloc_dma_chan (struct hda_codec *codec,unsigned int *dma_chan) {int status =0 ; -unsigned int size =sizeof (dma_chan); +unsigned int size =sizeof (*dma_chan);codec_dbg (codec," dspio_alloc_dma_chan() -- begin\n" ); status = dspio_scp(codec, MASTERCONTROL, 0x20,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 191/567 drm/msm/gem: Add check for kmalloc
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit d839f0811a31322c087a859c2b181e2383daa7be ]
Add the check for the return value of kmalloc in order to avoid NULL pointer dereference in copy_from_user.
Patchwork: https://patchwork.freedesktop.org/patch/514678/
--- drivers/gpu/drm/msm/msm_gem_submit.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/msm/msm_gem_submit.c +4 -0
@@ -220,6 +220,10 @@ static int submit_lookup_cmds(struct msm_gem_submit *submit, goto out; } submit->cmd[i].relocs =kmalloc (sz,GFP_KERNEL ); +if (!submit->cmd[i].relocs) { + ret = -ENOMEM ; + goto out; + } ret =copy_from_user (submit->cmd[i].relocs, userptr, sz);if (ret) { ret = -EFAULT ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 192/567 drm/msm/dpu: Disallow unallocated resources to be returned
In reply to Greg Kroah-HartmanFrom: Marijn Suijten <[email protected]>
[ Upstream commit abc40122d9a69f56c04efb5a7485795f5ac799d1 ]
In the event that the topology requests resources that have not been created by the system (because they are typically not represented in dpu_mdss_cfg ^1), the resource(s) in global_state (in this case DSC blocks, until their allocation/assignment is being sanity-checked in "drm/msm/dpu: Reject topologies for which no DSC blocks are available") remain NULL but will still be returned out of dpu_rm_get_assigned_resources, where the caller expects to get an array containing num_blks valid pointers (but instead gets these NULLs).
To prevent this from happening, where null-pointer dereferences typically result in a hard-to-debug platform lockup, num_blks shouldn't increase past NULL blocks and will print an error and break instead. After all, max_blks represents the static size of the maximum number of blocks whereas the actual amount varies per platform.
^1: which can happen after a git rebase ended up moving additions to _dpu_cfg to a different struct which has the same patch context.
Patchwork: https://patchwork.freedesktop.org/patch/517636/
--- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +5 -0
@@ -663,6 +663,11 @@ int dpu_rm_get_assigned_resources(struct dpu_rm *rm, blks_size, enc_id);break ; } +if (!hw_blks[i]) { +DPU_ERROR ("Allocated resource %d unavailable to assign to enc %d\n" , + type, enc_id); +break ; + } blks[num_blks++] = hw_blks[i]; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 193/567 drm/bridge: lt9611: fix sleep mode setup
In reply to Greg Kroah-HartmanFrom: Dmitry Baryshkov <[email protected]>
[ Upstream commit ae2d329f104b75a0a78dcaded29fe6283289cdf9 ]
On atomic_post_disable the bridge goes to the low power state. However the code disables too much of the chip, so the HPD event is not being detected and delivered to the host. Reduce the power saving in order to get the HPD event.
--- drivers/gpu/drm/bridge/lontium-lt9611.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/bridge/lontium-lt9611.c +2 -3
@@ -446,12 +446,11 @@ static void lt9611_sleep_setup(struct lt9611 *lt9611) { 0x8023, 0x01 }, { 0x8157, 0x03 }, /* set addr pin as output */ { 0x8149, 0x0b }, - { 0x8151, 0x30 }, /* disable IRQ */ + { 0x8102, 0x48 }, /* MIPI Rx power down */ { 0x8123, 0x80 }, { 0x8130, 0x00 }, - { 0x8100, 0x01 }, /* bandgap power down */ - { 0x8101, 0x00 }, /* system clk power down */ + { 0x8011, 0x0a }, }; regmap_multi_reg_write(lt9611->regmap,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 194/567 drm/bridge: lt9611: fix HPD reenablement
In reply to Greg Kroah-HartmanFrom: Dmitry Baryshkov <[email protected]>
[ Upstream commit a7790f6bd38f3642b60ae3504a2c749135b89451 ]
The driver will reset the bridge in the atomic_pre_enable(). However this will also drop the HPD interrupt state. Instead of resetting the bridge, properly wake it up. This fixes the HPD interrupt delivery after the disable/enable cycle.
--- drivers/gpu/drm/bridge/lontium-lt9611.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/lontium-lt9611.c +8 -2
@@ -880,12 +880,18 @@ static enum drm_mode_status lt9611_bridge_mode_valid(struct drm_bridge *bridge,static void lt9611_bridge_pre_enable (struct drm_bridge *bridge) {struct lt9611 *lt9611 =bridge_to_lt9611 (bridge); +static const struct reg_sequence reg_cfg[] = { + {0x8102 ,0x12 }, + {0x8123 ,0x40 }, + {0x8130 ,0xea }, + {0x8011 ,0xfa }, + };if (!lt9611->sleep)return ; -lt9611_reset (lt9611); -regmap_write (lt9611->regmap,0x80ee ,0x01 ); +regmap_multi_reg_write (lt9611->regmap, + reg_cfg,ARRAY_SIZE (reg_cfg)); lt9611->sleep = false; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 195/567 drm/bridge: lt9611: fix polarity programming
In reply to Greg Kroah-HartmanFrom: Dmitry Baryshkov <[email protected]>
[ Upstream commit 0b157efa384ea417304b1da284ee2f603c607fc3 ]
Fix programming of hsync and vsync polarities
--- drivers/gpu/drm/bridge/lontium-lt9611.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/gpu/drm/bridge/lontium-lt9611.c +12 -5
@@ -205,7 +205,6 @@ static void lt9611_pcr_setup(struct lt9611 *lt9611, const struct drm_display_mod/* stage 2 */ { 0x834a, 0x40 }, - { 0x831d, 0x10 },/* MK limit */ { 0x832d, 0x38 },
@@ -220,11 +219,19 @@ static void lt9611_pcr_setup(struct lt9611 *lt9611, const struct drm_display_mod { 0x8325, 0x00 }, { 0x832a, 0x01 }, { 0x834a, 0x10 }, - { 0x831d, 0x10 }, - { 0x8326, 0x37 }, }; +u8 pol =0x10 ; -regmap_multi_reg_write (lt9611->regmap, reg_cfg,ARRAY_SIZE (reg_cfg)); +if (mode->flags &DRM_MODE_FLAG_NHSYNC ) + pol |=0x2 ; +if (mode->flags &DRM_MODE_FLAG_NVSYNC ) + pol |=0x1 ; +regmap_write (lt9611->regmap,0x831d , pol); + +if (mode->hdisplay ==3840 ) +regmap_multi_reg_write (lt9611->regmap, reg_cfg2,ARRAY_SIZE (reg_cfg2)); +else +regmap_multi_reg_write (lt9611->regmap, reg_cfg,ARRAY_SIZE (reg_cfg));switch (mode->hdisplay) {case 640 :
@@ -234,7 +241,7 @@ static void lt9611_pcr_setup(struct lt9611 *lt9611, const struct drm_display_modregmap_write (lt9611->regmap,0x8326 ,0x37 );break ;case 3840 : -regmap_multi_reg_write (lt9611->regmap, reg_cfg2,ARRAY_SIZE (reg_cfg2)); +regmap_write (lt9611->regmap,0x8326 ,0x37 );break ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 196/567 drm/bridge: lt9611: fix programming of video modes
In reply to Greg Kroah-HartmanFrom: Dmitry Baryshkov <[email protected]>
[ Upstream commit ad188aa47edaa033a270e1a3efae43836ff47569 ]
Program the upper part of the hfront_porch into the proper register.
--- drivers/gpu/drm/bridge/lontium-lt9611.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/bridge/lontium-lt9611.c +2 -1
@@ -185,7 +185,8 @@ static void lt9611_mipi_video_setup(struct lt9611 *lt9611,regmap_write (lt9611->regmap,0x8319 , (u8)(hfront_porch %256 )); -regmap_write (lt9611->regmap,0x831a , (u8)(hsync_porch /256 )); +regmap_write (lt9611->regmap,0x831a , (u8)(hsync_porch /256 ) | + ((hfront_porch /256 ) <<4 ));regmap_write (lt9611->regmap,0x831b , (u8)(hsync_porch %256 )); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 197/567 drm/bridge: lt9611: fix clock calculation
In reply to Greg Kroah-HartmanFrom: Dmitry Baryshkov <[email protected]>
[ Upstream commit 2576eb26494eb0509dd9ceb0cd27771a7a5e3674 ]
Instead of having several fixed values for the pcr register, calculate it before programming. This allows the bridge to support most of the display modes.
--- drivers/gpu/drm/bridge/lontium-lt9611.c | 32 +++++++++++-------------- 1 file changed, 14 insertions(+), 18 deletions(-)
drivers/gpu/drm/bridge/lontium-lt9611.c +14 -18
@@ -190,8 +190,9 @@ static void lt9611_mipi_video_setup(struct lt9611 *lt9611,regmap_write (lt9611->regmap,0x831b , (u8)(hsync_porch %256 )); } -static void lt9611_pcr_setup (struct lt9611 *lt9611,const struct drm_display_mode *mode) +static void lt9611_pcr_setup (struct lt9611 *lt9611,const struct drm_display_mode *mode,unsigned int postdiv) { +unsigned int pcr_m = mode->clock *5 * postdiv /27000 ;const struct reg_sequence reg_cfg[] = { {0x830b ,0x01 }, {0x830c ,0x10 },
@@ -234,24 +235,14 @@ static void lt9611_pcr_setup(struct lt9611 *lt9611, const struct drm_display_modelse regmap_multi_reg_write (lt9611->regmap, reg_cfg,ARRAY_SIZE (reg_cfg)); -switch (mode->hdisplay) { -case 640 : -regmap_write (lt9611->regmap,0x8326 ,0x14 ); -break ; -case 1920 : -regmap_write (lt9611->regmap,0x8326 ,0x37 ); -break ; -case 3840 : -regmap_write (lt9611->regmap,0x8326 ,0x37 ); -break ; - } +regmap_write (lt9611->regmap,0x8326 , pcr_m);/* pcr rst */ regmap_write (lt9611->regmap,0x8011 ,0x5a );regmap_write (lt9611->regmap,0x8011 ,0xfa ); } -static int lt9611_pll_setup (struct lt9611 *lt9611,const struct drm_display_mode *mode) +static int lt9611_pll_setup (struct lt9611 *lt9611,const struct drm_display_mode *mode,unsigned int *postdiv) {unsigned int pclk = mode->clock; const struct reg_sequence reg_cfg[] = {
@@ -269,12 +260,16 @@ static int lt9611_pll_setup(struct lt9611 *lt9611, const struct drm_display_moderegmap_multi_reg_write (lt9611->regmap, reg_cfg,ARRAY_SIZE (reg_cfg)); -if (pclk >150000 ) +if (pclk >150000 ) {regmap_write (lt9611->regmap,0x812d ,0x88 ); -else if (pclk >70000 ) + *postdiv =1 ; + }else if (pclk >70000 ) {regmap_write (lt9611->regmap,0x812d ,0x99 ); -else + *postdiv =2 ; + }else {regmap_write (lt9611->regmap,0x812d ,0xaa ); + *postdiv =4 ; + }/* * first divide pclk by 2 first
@@ -917,14 +912,15 @@ static void lt9611_bridge_mode_set(struct drm_bridge *bridge, {struct lt9611 *lt9611 =bridge_to_lt9611 (bridge);struct hdmi_avi_infoframe avi_frame; +unsigned int postdiv;int ret;lt9611_bridge_pre_enable (bridge);lt9611_mipi_input_digital (lt9611, mode); -lt9611_pll_setup (lt9611, mode); +lt9611_pll_setup (lt9611, mode, &postdiv);lt9611_mipi_video_setup (lt9611, mode); -lt9611_pcr_setup (lt9611, mode); +lt9611_pcr_setup (lt9611, mode, postdiv); ret = drm_hdmi_avi_infoframe_from_display_mode(&avi_frame, <9611->connector,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 198/567 drm/bridge: lt9611: pass a pointer to the of node
In reply to Greg Kroah-HartmanFrom: Dmitry Baryshkov <[email protected]>
[ Upstream commit b0a7f8736789935f62d6df32d441cdf05a5c05d2 ]
Pass a pointer to the OF node while registering lt9611 MIPI device.
--- drivers/gpu/drm/bridge/lontium-lt9611.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bridge/lontium-lt9611.c +1 -1
@@ -759,7 +759,7 @@ static const struct drm_connector_funcs lt9611_bridge_connector_funcs = {static struct mipi_dsi_device *lt9611_attach_dsi (struct lt9611 *lt9611,struct device_node *dsi_node) { -const struct mipi_dsi_device_info info = {"lt9611" ,0 ,NULL }; +const struct mipi_dsi_device_info info = {"lt9611" ,0 , lt9611->dev->of_node};struct mipi_dsi_device *dsi;struct mipi_dsi_host *host;int ret;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 199/567 drm/mipi-dsi: Fix byte order of 16-bit DCS set/get brightness
In reply to Greg Kroah-HartmanFrom: Daniel Mentz <[email protected]>
[ Upstream commit c9d27c6be518b4ef2966d9564654ef99292ea1b3 ]
The MIPI DCS specification demands that brightness values are sent in big endian byte order. It also states that one parameter (i.e. one byte) shall be sent/received for 8 bit wide values, and two parameters shall be used for values that are between 9 and 16 bits wide.
Add new functions to properly handle 16-bit brightness in big endian, since the two 8- and 16-bit cases are distinct from each other.
[richard: use separate functions instead of switch/case] [richard: split into 16-bit component]
--- drivers/gpu/drm/drm_mipi_dsi.c | 52 ++++++++++++++++++++++++++++++++++ include/drm/drm_mipi_dsi.h | 4 +++ 2 files changed, 56 insertions(+)
drivers/gpu/drm/drm_mipi_dsi.c +52 -0
@@ -1143,6 +1143,58 @@ int mipi_dsi_dcs_get_display_brightness(struct mipi_dsi_device *dsi, }EXPORT_SYMBOL (mipi_dsi_dcs_get_display_brightness); +/** +* mipi_dsi_dcs_set_display_brightness_large() - sets the 16-bit brightness value +* of the display +* @dsi: DSI peripheral device +* @brightness: brightness value +* +* Return: 0 on success or a negative error code on failure. +*/ +int mipi_dsi_dcs_set_display_brightness_large (struct mipi_dsi_device *dsi, +u16 brightness) +{ +u8 payload[2 ] = { brightness >>8 , brightness &0xff }; +ssize_t err; + + err =mipi_dsi_dcs_write (dsi,MIPI_DCS_SET_DISPLAY_BRIGHTNESS , + payload,sizeof (payload)); +if (err <0 ) +return err; + +return 0 ; +} +EXPORT_SYMBOL (mipi_dsi_dcs_set_display_brightness_large); + +/** +* mipi_dsi_dcs_get_display_brightness_large() - gets the current 16-bit +* brightness value of the display +* @dsi: DSI peripheral device +* @brightness: brightness value +* +* Return: 0 on success or a negative error code on failure. +*/ +int mipi_dsi_dcs_get_display_brightness_large (struct mipi_dsi_device *dsi, +u16 *brightness) +{ +u8 brightness_be[2 ]; +ssize_t err; + + err =mipi_dsi_dcs_read (dsi,MIPI_DCS_GET_DISPLAY_BRIGHTNESS , + brightness_be,sizeof (brightness_be)); +if (err <=0 ) { +if (err ==0 ) + err = -ENODATA ; + +return err; + } + + *brightness = (brightness_be[0 ] <<8 ) | brightness_be[1 ]; + +return 0 ; +} +EXPORT_SYMBOL (mipi_dsi_dcs_get_display_brightness_large); +static int mipi_dsi_drv_probe (struct device *dev) {struct mipi_dsi_driver *drv =to_mipi_dsi_driver (dev->driver);
include/drm/drm_mipi_dsi.h +4 -0
@@ -288,6 +288,10 @@ int mipi_dsi_dcs_set_display_brightness(struct mipi_dsi_device *dsi, u16 brightness);int mipi_dsi_dcs_get_display_brightness (struct mipi_dsi_device *dsi,u16 *brightness); +int mipi_dsi_dcs_set_display_brightness_large (struct mipi_dsi_device *dsi, +u16 brightness); +int mipi_dsi_dcs_get_display_brightness_large (struct mipi_dsi_device *dsi, +u16 *brightness);/** * struct mipi_dsi_driver - DSI driver
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 200/567 drm: exynos: dsi: Fix MIPI_DSI*_NO_* mode flags
In reply to Greg Kroah-HartmanFrom: Jagan Teki <[email protected]>
[ Upstream commit 996e1defca34485dd2bd70b173f069aab5f21a65 ]
HFP/HBP/HSA/EOT_PACKET modes in Exynos DSI host specifies 0 = Enable and 1 = Disable.
The logic for checking these mode flags was correct before the MIPI_DSI*_NO_* mode flag conversion.
This patch is trying to fix this MIPI_DSI*_NO_* mode flags handling Exynos DSI host and update the mode_flags in relevant panel drivers.
--- drivers/gpu/drm/exynos/exynos_drm_dsi.c | 8 ++++---- drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c | 4 +++- drivers/gpu/drm/panel/panel-samsung-s6e63j0x03.c | 3 ++- drivers/gpu/drm/panel/panel-samsung-s6e8aa0.c | 2 -- 4 files changed, 9 insertions(+), 8 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_dsi.c +4 -4
@@ -809,15 +809,15 @@ static int exynos_dsi_init_link(struct exynos_dsi *dsi) reg |=DSIM_AUTO_MODE ;if (dsi->mode_flags &MIPI_DSI_MODE_VIDEO_HSE ) reg |=DSIM_HSE_MODE ; -if (!(dsi->mode_flags &MIPI_DSI_MODE_VIDEO_NO_HFP )) +if (dsi->mode_flags &MIPI_DSI_MODE_VIDEO_NO_HFP ) reg |=DSIM_HFP_MODE ; -if (!(dsi->mode_flags &MIPI_DSI_MODE_VIDEO_NO_HBP )) +if (dsi->mode_flags &MIPI_DSI_MODE_VIDEO_NO_HBP ) reg |=DSIM_HBP_MODE ; -if (!(dsi->mode_flags &MIPI_DSI_MODE_VIDEO_NO_HSA )) +if (dsi->mode_flags &MIPI_DSI_MODE_VIDEO_NO_HSA ) reg |=DSIM_HSA_MODE ; } -if (!(dsi->mode_flags &MIPI_DSI_MODE_NO_EOT_PACKET )) +if (dsi->mode_flags &MIPI_DSI_MODE_NO_EOT_PACKET ) reg |=DSIM_EOT_DISABLE ;switch (dsi->format) {
drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c +3 -1
@@ -692,7 +692,9 @@ static int s6e3ha2_probe(struct mipi_dsi_device *dsi) dsi->lanes =4 ; dsi->format =MIPI_DSI_FMT_RGB888 ; - dsi->mode_flags =MIPI_DSI_CLOCK_NON_CONTINUOUS ; + dsi->mode_flags =MIPI_DSI_CLOCK_NON_CONTINUOUS | +MIPI_DSI_MODE_VIDEO_NO_HFP |MIPI_DSI_MODE_VIDEO_NO_HBP | +MIPI_DSI_MODE_VIDEO_NO_HSA |MIPI_DSI_MODE_NO_EOT_PACKET ; ctx->supplies[0 ].supply ="vdd3" ; ctx->supplies[1 ].supply ="vci" ;
drivers/gpu/drm/panel/panel-samsung-s6e63j0x03.c +2 -1
@@ -446,7 +446,8 @@ static int s6e63j0x03_probe(struct mipi_dsi_device *dsi) dsi->lanes =1 ; dsi->format =MIPI_DSI_FMT_RGB888 ; - dsi->mode_flags =MIPI_DSI_MODE_NO_EOT_PACKET ; + dsi->mode_flags =MIPI_DSI_MODE_VIDEO_NO_HFP | +MIPI_DSI_MODE_VIDEO_NO_HBP |MIPI_DSI_MODE_VIDEO_NO_HSA ; ctx->supplies[0 ].supply ="vdd3" ; ctx->supplies[1 ].supply ="vci" ;
drivers/gpu/drm/panel/panel-samsung-s6e8aa0.c +0 -2
@@ -990,8 +990,6 @@ static int s6e8aa0_probe(struct mipi_dsi_device *dsi) dsi->lanes =4 ; dsi->format =MIPI_DSI_FMT_RGB888 ; dsi->mode_flags =MIPI_DSI_MODE_VIDEO |MIPI_DSI_MODE_VIDEO_BURST - |MIPI_DSI_MODE_VIDEO_NO_HFP |MIPI_DSI_MODE_VIDEO_NO_HBP - |MIPI_DSI_MODE_VIDEO_NO_HSA |MIPI_DSI_MODE_NO_EOT_PACKET |MIPI_DSI_MODE_VSYNC_FLUSH |MIPI_DSI_MODE_VIDEO_AUTO_VERT ; ret =s6e8aa0_parse_dt (ctx);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 201/567 drm/msm/dsi: Allow 2 CTRLs on v2.5.0
In reply to Greg Kroah-HartmanFrom: Konrad Dybcio <[email protected]>
[ Upstream commit 1ae654ded7c5a19dc13f57a4fe4434fef879b6f9 ]
v2.5.0 support was originally added for SC7280, but this hw is also present on SM8350, which has one more DSI host. Bump up the dsi count and fill in the register of the secondary host to allow it to probe.
This should not have any adverse effects on SC7280, as the secondary CTRL will only be touched if it's defined, anyway.
Patchwork: https://patchwork.freedesktop.org/patch/519513/
--- drivers/gpu/drm/msm/dsi/dsi_cfg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/dsi/dsi_cfg.c +2 -2
@@ -209,8 +209,8 @@ static const struct msm_dsi_config sc7280_dsi_cfg = { }, .bus_clk_names = dsi_sc7280_bus_clk_names, .num_bus_clks = ARRAY_SIZE(dsi_sc7280_bus_clk_names), - .io_start = { 0xae94000 }, - .num_dsi = 1, + .io_start = { 0xae94000, 0xae96000 }, + .num_dsi = 2, }; static const struct msm_dsi_host_cfg_ops msm_dsi_v2_host_ops = {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 202/567 drm/msm: use strscpy instead of strncpy
In reply to Greg Kroah-HartmanFrom: Dmitry Baryshkov <[email protected]>
[ Upstream commit d7fd8634f48d76aa799ed57beb7d87dab91bde80 ]
Using strncpy can result in non-NULL-terminated destination string. Use strscpy instead. This fixes following warning:
drivers/gpu/drm/msm/msm_fence.c: In function ‘msm_fence_context_alloc’:drivers/gpu/drm/msm/msm_fence.c:25:9: warning: ‘strncpy’ specified bound 32 equals destination size [-Wstringop-truncation]
25 | strncpy(fctx->name, name, sizeof(fctx->name));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Patchwork: https://patchwork.freedesktop.org/patch/518787/
--- drivers/gpu/drm/msm/msm_fence.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/msm_fence.c +1 -1
@@ -21,7 +21,7 @@ msm_fence_context_alloc(struct drm_device *dev, volatile uint32_t *fenceptr,return ERR_PTR (-ENOMEM ); fctx->dev = dev; -strncpy (fctx->name, name,sizeof (fctx->name)); +strscpy (fctx->name, name,sizeof (fctx->name)); fctx->context =dma_fence_context_alloc (1 ); fctx->fenceptr = fenceptr;spin_lock_init (&fctx->spinlock);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 203/567 drm/msm/dpu: Add check for cstate
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit c96988b7d99327bb08bd9efd29a203b22cd88ace ]
As kzalloc may fail and return NULL pointer,
it should be better to check cstate
in order to avoid the NULL pointer dereference
in __drm_atomic_helper_crtc_reset.
Patchwork: https://patchwork.freedesktop.org/patch/514163/
--- drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c +4 -1
@@ -770,7 +770,10 @@ static void dpu_crtc_reset(struct drm_crtc *crtc)if (crtc->state)dpu_crtc_destroy_state (crtc, crtc->state); -__drm_atomic_helper_crtc_reset (crtc, &cstate->base); +if (cstate) +__drm_atomic_helper_crtc_reset (crtc, &cstate->base); +else +__drm_atomic_helper_crtc_reset (crtc,NULL ); }/**
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 204/567 drm/msm/dpu: Add check for pstates
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit 93340e10b9c5fc86730d149636e0aa8b47bb5a34 ]
As kzalloc may fail and return NULL pointer,
it should be better to check pstates
in order to avoid the NULL pointer dereference.
Patchwork: https://patchwork.freedesktop.org/patch/514160/
--- drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c +2 -0
@@ -941,6 +941,8 @@ static int dpu_crtc_atomic_check(struct drm_crtc *crtc,bool needs_dirtyfb =dpu_crtc_needs_dirtyfb (crtc_state); pstates =kzalloc (sizeof (*pstates) *DPU_STAGE_MAX *4 ,GFP_KERNEL ); +if (!pstates) +return -ENOMEM ;if (!crtc_state->enable || !crtc_state->active) { DRM_DEBUG_ATOMIC("crtc%d -> enable %d, active %d, skip atomic_check\n",
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 205/567 drm/msm/mdp5: Add check for kzalloc
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit 13fcfcb2a9a4787fe4e49841d728f6f2e9fa6911 ]
As kzalloc may fail and return NULL pointer,
it should be better to check the return value
in order to avoid the NULL pointer dereference.
Patchwork: https://patchwork.freedesktop.org/patch/514154/
--- drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c +4 -1
@@ -1138,7 +1138,10 @@ static void mdp5_crtc_reset(struct drm_crtc *crtc)if (crtc->state)mdp5_crtc_destroy_state (crtc, crtc->state); -__drm_atomic_helper_crtc_reset (crtc, &mdp5_cstate->base); +if (mdp5_cstate) +__drm_atomic_helper_crtc_reset (crtc, &mdp5_cstate->base); +else +__drm_atomic_helper_crtc_reset (crtc,NULL ); }static const struct drm_crtc_funcs mdp5_crtc_no_lm_cursor_funcs = {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 206/567 pinctrl: bcm2835: Remove of_node_put() in bcm2835_of_gpio_ranges_fallback()
In reply to Greg Kroah-HartmanFrom: Andy Shevchenko <[email protected]>
[ Upstream commit 2d578dd27871372f7159dd3206149ec616700d87 ]
Remove wrong of_node_put() in bcm2835_of_gpio_ranges_fallback(), there is no counterpart of_node_get() for it.
--- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 2 -- 1 file changed, 2 deletions(-)
drivers/pinctrl/bcm/pinctrl-bcm2835.c +0 -2
@@ -356,8 +356,6 @@ static int bcm2835_of_gpio_ranges_fallback(struct gpio_chip *gc, {struct pinctrl_dev *pctldev =of_pinctrl_get (np); -of_node_put (np); -if (!pctldev)return 0 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 207/567 pinctrl: mediatek: fix coding style
In reply to Greg Kroah-HartmanFrom: Zhiyong Tao <[email protected]>
[ Upstream commit 25a74c0f4bf1338af29a32383fb4e1a960ec5063 ]
Fix Camel spelling coding style to avoid checkpatch warning in a following patch.
Stable-dep-of: a298c70a10c6 ("pinctrl: mediatek: Initialize variable pullen and pullup to zero")
--- drivers/pinctrl/mediatek/pinctrl-paris.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/pinctrl/mediatek/pinctrl-paris.c +4 -4
@@ -572,7 +572,7 @@ static int mtk_hw_get_value_wrap(struct mtk_pinctrl *hw, unsigned int gpio, int mtk_hw_get_value_wrap(hw, gpio, PINCTRL_PIN_REG_DRV)ssize_t mtk_pctrl_show_one_pin (struct mtk_pinctrl *hw, -unsigned int gpio,char *buf,unsigned int bufLen) +unsigned int gpio,char *buf,unsigned int buf_len) {int pinmux, pullup, pullen, len =0 , r1 =-1 , r0 =-1 ;const struct mtk_pin_desc *desc;
@@ -608,7 +608,7 @@ ssize_t mtk_pctrl_show_one_pin(struct mtk_pinctrl *hw, }else if (pullen !=MTK_DISABLE && pullen !=MTK_ENABLE ) { pullen =0 ; } - len += scnprintf(buf + len, bufLen - len, + len += scnprintf(buf + len, buf_len - len, "%03d: %1d%1d%1d%1d%02d%1d%1d%1d%1d", gpio, pinmux,
@@ -622,10 +622,10 @@ ssize_t mtk_pctrl_show_one_pin(struct mtk_pinctrl *hw, pullup);if (r1 !=-1 ) { - len +=scnprintf (buf + len, bufLen - len," (%1d %1d)\n" , + len +=scnprintf (buf + len, buf_len - len," (%1d %1d)\n" , r1, r0); }else { - len +=scnprintf (buf + len, bufLen - len,"\n" ); + len +=scnprintf (buf + len, buf_len - len,"\n" ); }return len;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 208/567 pinctrl: mediatek: Initialize variable pullen and pullup to zero
In reply to Greg Kroah-HartmanFrom: Guodong Liu <[email protected]>
[ Upstream commit a298c70a10c604a6b3df5a0aa56597b705ba0f6b ]
Coverity spotted that pullen and pullup is not initialized to zero in mtk_pctrl_show_one_pin. The uninitialized variable pullen is used in assignment statement "rsel = pullen;" in mtk_pctrl_show_one_pin, and Uninitialized variable pullup is used when calling scnprintf. Fix this coverity by initializing pullen and pullup as zero.
--- drivers/pinctrl/mediatek/pinctrl-paris.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/mediatek/pinctrl-paris.c +1 -1
@@ -574,7 +574,7 @@ static int mtk_hw_get_value_wrap(struct mtk_pinctrl *hw, unsigned int gpio, intssize_t mtk_pctrl_show_one_pin (struct mtk_pinctrl *hw,unsigned int gpio,char *buf,unsigned int buf_len) { -int pinmux, pullup, pullen, len =0 , r1 =-1 , r0 =-1 ; +int pinmux, pullup =0 , pullen =0 , len =0 , r1 =-1 , r0 =-1 ;const struct mtk_pin_desc *desc;if (gpio >= hw->soc->npins)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 209/567 pinctrl: mediatek: Initialize variable *buf to zero
In reply to Greg Kroah-HartmanFrom: Guodong Liu <[email protected]>
[ Upstream commit 2e34f82ba214134ecf590fbe0cdbd87401645a8a ]
Coverity spotted that *buf is not initialized to zero in mtk_pctrl_dbg_show. Using uninitialized variable *buf as argument to %s when calling seq_printf. Fix this coverity by initializing *buf as zero.
--- drivers/pinctrl/mediatek/pinctrl-paris.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/mediatek/pinctrl-paris.c +1 -1
@@ -637,7 +637,7 @@ static void mtk_pctrl_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s, unsigned int gpio) {struct mtk_pinctrl *hw =pinctrl_dev_get_drvdata (pctldev); -char buf[PIN_DBG_BUF_SZ ]; +char buf[PIN_DBG_BUF_SZ ] = {0 }; (void )mtk_pctrl_show_one_pin (hw, gpio, buf,PIN_DBG_BUF_SZ );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 210/567 gpu: host1x: Dont skip assigning syncpoints to channels
In reply to Greg Kroah-HartmanFrom: Mikko Perttunen <[email protected]>
[ Upstream commit eb258cc1fd458e584082be987dbc6ec42668c05e ]
The code to write the syncpoint channel assignment register incorrectly skips the write if hypervisor registers are not available.
The register, however, is within the guest aperture so remove the check and assign syncpoints properly even on virtualized systems.
--- drivers/gpu/host1x/hw/syncpt_hw.c | 3 --- 1 file changed, 3 deletions(-)
drivers/gpu/host1x/hw/syncpt_hw.c +0 -3
@@ -106,9 +106,6 @@ static void syncpt_assign_to_channel(struct host1x_syncpt *sp,#if HOST1X_HW >=6 struct host1x *host = sp->host; -if (!host->hv_regs) -return ; -host1x_sync_writel (host,HOST1X_SYNC_SYNCPT_CH_APP_CH (ch ? ch->id :0xff ),HOST1X_SYNC_SYNCPT_CH_APP (sp->id));
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 211/567 drm/tegra: firewall: Check for is_addr_reg existence in IMM check
In reply to Greg Kroah-HartmanFrom: Mikko Perttunen <[email protected]>
[ Upstream commit 1b5c09de25e8c08655c270a70e5e74e93b6bad1f ]
In the IMM opcode check, don't call is_addr_reg if it's not set.
--- drivers/gpu/drm/tegra/firewall.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/tegra/firewall.c +3 -0
@@ -97,6 +97,9 @@ static int fw_check_regs_imm(struct tegra_drm_firewall *fw, u32 offset) {bool is_addr; +if (!fw->client->ops->is_addr_reg) +return 0 ; + is_addr = fw->client->ops->is_addr_reg (fw->client->base.dev, fw->class, offset);if (is_addr)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 212/567 drm/msm/dpu: set pdpu->is_rt_pipe early in dpu_plane_sspp_atomic_update()
In reply to Greg Kroah-HartmanFrom: Dmitry Baryshkov <[email protected]>
[ Upstream commit 1d233b1cb149ec78c20fac58331b27bb460f9558 ]
The function dpu_plane_sspp_atomic_update() updates pdpu->is_rt_pipe flag, but after the commit 854f6f1c653b ("drm/msm/dpu: update the qos remap only if the client type changes") it sets the flag late, after all the qos functions have updated QoS programming. Move the flag update back to the place where it happened before the mentioned commit to let the pipe be programmed according to its current RT/non-RT state.
Patchwork: https://patchwork.freedesktop.org/patch/516239/
--- drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c +6 -9
@@ -1089,7 +1089,7 @@ static void dpu_plane_sspp_atomic_update(struct drm_plane *plane)struct dpu_plane_state *pstate =to_dpu_plane_state (state);struct drm_crtc *crtc = state->crtc;struct drm_framebuffer *fb = state->fb; -bool is_rt_pipe, update_qos_remap; +bool is_rt_pipe;const struct dpu_format *fmt =to_dpu_format (msm_framebuffer_format (fb));
@@ -1100,6 +1100,9 @@ static void dpu_plane_sspp_atomic_update(struct drm_plane *plane) pstate->pending = true; is_rt_pipe = (dpu_crtc_get_client_type (crtc) !=NRT_CLIENT ); + pstate->needs_qos_remap |= (is_rt_pipe != pdpu->is_rt_pipe); + pdpu->is_rt_pipe = is_rt_pipe; +_dpu_plane_set_qos_ctrl (plane, false,DPU_PLANE_QOS_PANIC_CTRL ); DPU_DEBUG_PLANE(pdpu, "FB[%u] " DRM_RECT_FP_FMT "->crtc%u " DRM_RECT_FMT
@@ -1205,14 +1208,8 @@ static void dpu_plane_sspp_atomic_update(struct drm_plane *plane)_dpu_plane_set_ot_limit (plane, crtc); } - update_qos_remap = (is_rt_pipe != pdpu->is_rt_pipe) || - pstate->needs_qos_remap; - -if (update_qos_remap) { -if (is_rt_pipe != pdpu->is_rt_pipe) - pdpu->is_rt_pipe = is_rt_pipe; -else if (pstate->needs_qos_remap) - pstate->needs_qos_remap = false; +if (pstate->needs_qos_remap) { + pstate->needs_qos_remap = false;_dpu_plane_set_qos_remap (plane); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 213/567 drm/mediatek: dsi: Reduce the time of dsi from LP11 to sending cmd
In reply to Greg Kroah-HartmanFrom: Xinlei Lee <[email protected]>
[ Upstream commit 91aeaed2c1147e3b1157dc084d23f190856a6c23 ]
According to Figure 16 Turnaround Procedure on page 36 in [1], you can see the status of LP-00 -> LP10 -> LP11. This state can correspond to the state of DSI from LP00 -> LP11 in mtk_dsi_lane_ready function in mtk_dsi.c.
LP-00 -> LP10 -> LP11 takes about 2*TLPX time (refer to [1] page 51 to see that TLPX is 50ns)
The delay at the end of the mtk_dsi_lane_ready function should be greater than the 2*TLPX specified by the DSI spec, and less than the time specified by the DSI_RX (generally 6ms to 40ms), to avoid problems caused by the RX specification
[1]:mipi_D-PHY_specification_v1-1
--- drivers/gpu/drm/mediatek/mtk_dsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/mediatek/mtk_dsi.c +1 -1
@@ -709,7 +709,7 @@ static void mtk_dsi_lane_ready(struct mtk_dsi *dsi)mtk_dsi_clk_ulp_mode_leave (dsi);mtk_dsi_lane0_ulp_mode_leave (dsi);mtk_dsi_clk_hs_mode (dsi,0 ); -msleep (20 ); +usleep_range (1000 ,3000 );/* The reaction time after pulling up the mipi signal for dsi_rx */ } }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 214/567 drm/mediatek: Use NULL instead of 0 for NULL pointer
In reply to Greg Kroah-HartmanFrom: Miles Chen <[email protected]>
[ Upstream commit 4744cde06f57dd6fbaac468663b1fe2f653eaa16 ]
Use NULL for NULL pointer to fix the following sparse warning:drivers/gpu/drm/mediatek/mtk_drm_gem.c:265:27: sparse: warning: Using plain integer as NULL pointer
--- drivers/gpu/drm/mediatek/mtk_drm_gem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/mediatek/mtk_drm_gem.c +1 -1
@@ -261,6 +261,6 @@ void mtk_drm_gem_prime_vunmap(struct drm_gem_object *obj, struct dma_buf_map *mareturn ;vunmap (vaddr); - mtk_gem->kvaddr =0 ; + mtk_gem->kvaddr =NULL ;kfree (mtk_gem->pages); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 215/567 drm/mediatek: Drop unbalanced obj unref
In reply to Greg Kroah-HartmanFrom: Rob Clark <[email protected]>
[ Upstream commit 4deef811828e87e26a978d5d6433b261d4713849 ]
In the error path, mtk_drm_gem_object_mmap() is dropping an obj reference that it doesn't own.
--- drivers/gpu/drm/mediatek/mtk_drm_gem.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/mediatek/mtk_drm_gem.c +0 -2
@@ -164,8 +164,6 @@ static int mtk_drm_gem_object_mmap(struct drm_gem_object *obj, ret =dma_mmap_attrs (priv->dma_dev, vma, mtk_gem->cookie, mtk_gem->dma_addr, obj->size, mtk_gem->dma_attrs); -if (ret) -drm_gem_vm_close (vma);return ret; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 216/567 drm/mediatek: mtk_drm_crtc: Add checks for devm_kcalloc
In reply to Greg Kroah-HartmanFrom: ruanjinjie <[email protected]>
[ Upstream commit 5bf1e3bd7da625ccf9a22c8cb7d65271e6e47f4c ]
As the devm_kcalloc may return NULL, the return value needs to be checked to avoid NULL poineter dereference.
--- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/mediatek/mtk_drm_crtc.c +2 -0
@@ -889,6 +889,8 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev, mtk_crtc->planes =devm_kcalloc (dev, num_comp_planes,sizeof (struct drm_plane ),GFP_KERNEL ); +if (!mtk_crtc->planes) +return -ENOMEM ;for (i =0 ; i < mtk_crtc->ddp_comp_nr; i++) { ret = mtk_drm_crtc_init_comp_planes(drm_dev, mtk_crtc, i,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 217/567 drm/mediatek: Clean dangling pointer on bind error path
In reply to Greg Kroah-HartmanFrom: Nícolas F. R. A. Prado <[email protected]>
[ Upstream commit 36aa8c61af55675ed967900fbe5deb32d776f051 ]
mtk_drm_bind() can fail, in which case drm_dev_put() is called, destroying the drm_device object. However a pointer to it was still being held in the private object, and that pointer would be passed along to DRM in mtk_drm_sys_prepare() if a suspend were triggered at that point, resulting in a panic. Clean the pointer when destroying the object in the error path to prevent this from happening.
--- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/mediatek/mtk_drm_drv.c +1 -0
@@ -376,6 +376,7 @@ static int mtk_drm_bind(struct device *dev) err_deinit:mtk_drm_kms_deinit (drm); err_free: + private->drm =NULL ;drm_dev_put (drm);return ret; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 218/567 ASoC: soc-compress.c: fixup private_data on snd_soc_new_compress()
In reply to Greg Kroah-HartmanFrom: Kuninori Morimoto <[email protected]>
[ Upstream commit ffe4c0f0bfaa571a676a0e946d4a6a0607f94294 ]
commit d3268a40d4b19f ("ASoC: soc-compress.c: fix NULL dereference") enables DPCM capture, but it should independent from playback. This patch fixup it.
--- sound/soc/soc-compress.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/soc-compress.c +1 -1
@@ -590,7 +590,7 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) rtd->fe_compr =1 ;if (rtd->dai_link->dpcm_playback) be_pcm->streams[SNDRV_PCM_STREAM_PLAYBACK ].substream->private_data = rtd; -else if (rtd->dai_link->dpcm_capture) +if (rtd->dai_link->dpcm_capture) be_pcm->streams[SNDRV_PCM_STREAM_CAPTURE ].substream->private_data = rtd;memcpy (compr->ops, &soc_compr_dyn_ops,sizeof (soc_compr_dyn_ops)); }else {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 219/567 gpio: vf610: connect GPIO label to dev name
In reply to Greg Kroah-HartmanFrom: Haibo Chen <[email protected]>
[ Upstream commit 6f8ecb7f85f441eb7d78ba2a4df45ee8a821934e ]
Current GPIO label is fixed, so can't distinguish different GPIO controllers through labels. Use dev name instead.
--- drivers/gpio/gpio-vf610.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-vf610.c +1 -1
@@ -304,7 +304,7 @@ static int vf610_gpio_probe(struct platform_device *pdev) gc = &port->gc; gc->of_node = np; gc->parent = dev; - gc->label ="vf610-gpio" ; + gc->label =dev_name (dev); gc->ngpio =VF610_GPIO_PER_PORT ; gc->base =of_alias_get_id (np,"gpio" ) *VF610_GPIO_PER_PORT ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 220/567 spi: dw_bt1: fix MUX_MMIO dependencies
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit d4bde04318c0d33705e9a77d4c7df72f262011e0 ]
Selecting a symbol with additional dependencies requires adding the same dependency here:
WARNING: unmet direct dependencies detected for MUX_MMIO
Depends on [n]: MULTIPLEXER [=y] && OF [=n]
Selected by [y]:
- SPI_DW_BT1 [=y] && SPI [=y] && SPI_MASTER [=y] && SPI_DESIGNWARE [=y] && (MIPS_BAIKAL_T1 || COMPILE_TEST [=y])
Drop the 'select' here to avoid the problem. Anyone using the dw-bt1 SPI driver should make sure they include the mux driver as well now.
--- drivers/spi/Kconfig | 1 - 1 file changed, 1 deletion(-)
drivers/spi/Kconfig +0 -1
@@ -272,7 +272,6 @@ config SPI_DW_BT1 tristate "Baikal-T1 SPI driver for DW SPI core" depends on MIPS_BAIKAL_T1 || COMPILE_TEST select MULTIPLEXER - select MUX_MMIO help Baikal-T1 SoC is equipped with three DW APB SSI-based MMIO SPI controllers. Two of them are pretty much normal: with IRQ, DMA,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 221/567 ASoC: mchp-spdifrx: fix controls which rely on rsr register
In reply to Greg Kroah-HartmanFrom: Claudiu Beznea <[email protected]>
[ Upstream commit fa09fa60385abbf99342494b280da8b4aebbc0e9 ]
The SPDIFRX block is clocked by 2 clocks: peripheral and generic clocks. Peripheral clock feeds user interface (registers) and generic clock feeds the receiver.
To enable the receiver the generic clock needs to be enabled and also the ENABLE bit of MCHP_SPDIFRX_MR register need to be set.
The signal control exported by mchp-spdifrx driver reports wrong status when the receiver is disabled. This can happen when requesting the signal and the capture was not previously started. To solve this the receiver needs to be enabled (by enabling generic clock and setting ENABLE bit of MR register) before reading the signal status.
As with this fix there are 2 paths now that need to control the generic clock and ENABLE bit of SPDIFRX_MR register (one path though controls, one path though configuration) a mutex has been introduced. We can't rely on subsystem locking as the controls are protected by
struct snd_card::controls_rwsem semaphore and configuration is protected by a different lock (embedded in snd_pcm_stream_lock_irq()).
The introduction of mutex is also extended to other controls which rely on SPDIFRX_RSR.ULOCK bit as it has been discovered experimentally that having both clocks enabled but not the receiver (through ENABLE bit of SPDIFRX.MR) leads to inconsistent values of SPDIFRX_RSR.ULOCK. Thus on some controls we rely on software state (dev->trigger_enabled protected by mutex) to retrieve proper values.
--- sound/soc/atmel/mchp-spdifrx.c | 192 ++++++++++++++++++++++++--------- 1 file changed, 142 insertions(+), 50 deletions(-)
sound/soc/atmel/mchp-spdifrx.c +142 -50
@@ -233,11 +233,13 @@ struct mchp_spdifrx_dev {struct mchp_spdifrx_mixer_control control;spinlock_t blockend_lock;/* protect access to blockend_refcount */ int blockend_refcount; +struct mutex mlock;struct device *dev;struct regmap *regmap;struct clk *pclk;struct clk *gclk;unsigned int fmt; +unsigned int trigger_enabled; unsigned int gclk_enabled:1; };
@@ -353,47 +355,40 @@ static int mchp_spdifrx_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) {struct mchp_spdifrx_dev *dev =snd_soc_dai_get_drvdata (dai); -u32 mr; -int running; -int ret; - -regmap_read (dev->regmap,SPDIFRX_MR , &mr); - running = !!(mr &SPDIFRX_MR_RXEN_ENABLE ); +int ret =0 ;switch (cmd) {case SNDRV_PCM_TRIGGER_START :case SNDRV_PCM_TRIGGER_RESUME :case SNDRV_PCM_TRIGGER_PAUSE_RELEASE : -if (!running) { - mr &= ~SPDIFRX_MR_RXEN_MASK ; - mr |=SPDIFRX_MR_RXEN_ENABLE ; -/* enable overrun interrupts */ -regmap_write (dev->regmap,SPDIFRX_IER , -SPDIFRX_IR_OVERRUN ); - } +mutex_lock (&dev->mlock); +/* Enable overrun interrupts */ +regmap_write (dev->regmap,SPDIFRX_IER ,SPDIFRX_IR_OVERRUN ); + +/* Enable receiver. */ +regmap_update_bits (dev->regmap,SPDIFRX_MR ,SPDIFRX_MR_RXEN_MASK , +SPDIFRX_MR_RXEN_ENABLE ); + dev->trigger_enabled = true; +mutex_unlock (&dev->mlock);break ;case SNDRV_PCM_TRIGGER_STOP :case SNDRV_PCM_TRIGGER_SUSPEND :case SNDRV_PCM_TRIGGER_PAUSE_PUSH : -if (running) { - mr &= ~SPDIFRX_MR_RXEN_MASK ; - mr |=SPDIFRX_MR_RXEN_DISABLE ; -/* disable overrun interrupts */ -regmap_write (dev->regmap,SPDIFRX_IDR , -SPDIFRX_IR_OVERRUN ); - } +mutex_lock (&dev->mlock); +/* Disable overrun interrupts */ +regmap_write (dev->regmap,SPDIFRX_IDR ,SPDIFRX_IR_OVERRUN ); + +/* Disable receiver. */ +regmap_update_bits (dev->regmap,SPDIFRX_MR ,SPDIFRX_MR_RXEN_MASK , +SPDIFRX_MR_RXEN_DISABLE ); + dev->trigger_enabled = false; +mutex_unlock (&dev->mlock);break ;default : -return -EINVAL ; + ret = -EINVAL ; } - ret =regmap_write (dev->regmap,SPDIFRX_MR , mr); -if (ret) { -dev_err (dev->dev,"unable to enable/disable RX: %d\n" , ret); -return ret; - } - -return 0 ; +return ret; } static int mchp_spdifrx_hw_params(struct snd_pcm_substream *substream,
@@ -413,13 +408,6 @@ static int mchp_spdifrx_hw_params(struct snd_pcm_substream *substream,return -EINVAL ; } -regmap_read (dev->regmap,SPDIFRX_MR , &mr); - -if (mr &SPDIFRX_MR_RXEN_ENABLE ) { -dev_err (dev->dev,"PCM already running\n" ); -return -EBUSY ; - } -if (params_channels (params) !=SPDIFRX_CHANNELS ) {dev_err (dev->dev,"unsupported number of channels: %d\n" ,params_channels (params));
@@ -445,6 +433,13 @@ static int mchp_spdifrx_hw_params(struct snd_pcm_substream *substream,return -EINVAL ; } +mutex_lock (&dev->mlock); +if (dev->trigger_enabled) { +dev_err (dev->dev,"PCM already running\n" ); + ret = -EBUSY ; + goto unlock; + } +if (dev->gclk_enabled) {clk_disable_unprepare (dev->gclk); dev->gclk_enabled =0 ;
@@ -455,19 +450,24 @@ static int mchp_spdifrx_hw_params(struct snd_pcm_substream *substream,dev_err (dev->dev,"unable to set gclk min rate: rate %u * ratio %u + 1\n" ,params_rate (params),SPDIFRX_GCLK_RATIO_MIN ); -return ret; + goto unlock; } ret =clk_prepare_enable (dev->gclk);if (ret) {dev_err (dev->dev,"unable to enable gclk: %d\n" , ret); -return ret; + goto unlock; } dev->gclk_enabled =1 ;dev_dbg (dev->dev,"GCLK range min set to %d\n" ,params_rate (params) *SPDIFRX_GCLK_RATIO_MIN +1 ); -return regmap_write (dev->regmap,SPDIFRX_MR , mr); + ret =regmap_write (dev->regmap,SPDIFRX_MR , mr); + +unlock: +mutex_unlock (&dev->mlock); + +return ret; } static int mchp_spdifrx_hw_free(struct snd_pcm_substream *substream,
@@ -475,10 +475,12 @@ static int mchp_spdifrx_hw_free(struct snd_pcm_substream *substream, {struct mchp_spdifrx_dev *dev =snd_soc_dai_get_drvdata (dai); +mutex_lock (&dev->mlock);if (dev->gclk_enabled) {clk_disable_unprepare (dev->gclk); dev->gclk_enabled =0 ; } +mutex_unlock (&dev->mlock);return 0 ; }
@@ -627,10 +629,24 @@ static int mchp_spdifrx_ulock_get(struct snd_kcontrol *kcontrol,u32 val;bool ulock_old = ctrl->ulock; -regmap_read (dev->regmap,SPDIFRX_RSR , &val); - ctrl->ulock = !(val &SPDIFRX_RSR_ULOCK ); +mutex_lock (&dev->mlock); + +/* +* The RSR.ULOCK has wrong value if both pclk and gclk are enabled +* and the receiver is disabled. Thus we take into account the +* dev->trigger_enabled here to return a real status. +*/ +if (dev->trigger_enabled) { +regmap_read (dev->regmap,SPDIFRX_RSR , &val); + ctrl->ulock = !(val &SPDIFRX_RSR_ULOCK ); + }else { + ctrl->ulock =0 ; + } + uvalue->value.integer.value[0 ] = ctrl->ulock; +mutex_unlock (&dev->mlock); +return ulock_old != ctrl->ulock; }
@@ -643,8 +659,22 @@ static int mchp_spdifrx_badf_get(struct snd_kcontrol *kcontrol,u32 val;bool badf_old = ctrl->badf; -regmap_read (dev->regmap,SPDIFRX_RSR , &val); - ctrl->badf = !!(val &SPDIFRX_RSR_BADF ); +mutex_lock (&dev->mlock); + +/* +* The RSR.ULOCK has wrong value if both pclk and gclk are enabled +* and the receiver is disabled. Thus we take into account the +* dev->trigger_enabled here to return a real status. +*/ +if (dev->trigger_enabled) { +regmap_read (dev->regmap,SPDIFRX_RSR , &val); + ctrl->badf = !!(val &SPDIFRX_RSR_BADF ); + }else { + ctrl->badf =0 ; + } + +mutex_unlock (&dev->mlock); + uvalue->value.integer.value[0 ] = ctrl->badf;return badf_old != ctrl->badf;
@@ -656,11 +686,48 @@ static int mchp_spdifrx_signal_get(struct snd_kcontrol *kcontrol,struct snd_soc_dai *dai =snd_kcontrol_chip (kcontrol);struct mchp_spdifrx_dev *dev =snd_soc_dai_get_drvdata (dai);struct mchp_spdifrx_mixer_control *ctrl = &dev->control; -u32 val; +u32 val = ~0U , loops =10 ; +int ret;bool signal_old = ctrl->signal; -regmap_read (dev->regmap,SPDIFRX_RSR , &val); - ctrl->signal = !(val &SPDIFRX_RSR_NOSIGNAL ); +mutex_lock (&dev->mlock); + +/* +* To get the signal we need to have receiver enabled. This +* could be enabled also from trigger() function thus we need to +* take care of not disabling the receiver when it runs. +*/ +if (!dev->trigger_enabled) { + ret =clk_prepare_enable (dev->gclk); +if (ret) + goto unlock; + +regmap_update_bits (dev->regmap,SPDIFRX_MR ,SPDIFRX_MR_RXEN_MASK , +SPDIFRX_MR_RXEN_ENABLE ); + +/* Wait for RSR.ULOCK bit. */ +while (--loops) { +regmap_read (dev->regmap,SPDIFRX_RSR , &val); +if (!(val &SPDIFRX_RSR_ULOCK )) +break ; +usleep_range (100 ,150 ); + } + +regmap_update_bits (dev->regmap,SPDIFRX_MR ,SPDIFRX_MR_RXEN_MASK , +SPDIFRX_MR_RXEN_DISABLE ); + +clk_disable_unprepare (dev->gclk); + }else { +regmap_read (dev->regmap,SPDIFRX_RSR , &val); + } + +unlock: +mutex_unlock (&dev->mlock); + +if (!(val &SPDIFRX_RSR_ULOCK )) + ctrl->signal = !(val &SPDIFRX_RSR_NOSIGNAL ); +else + ctrl->signal =0 ; uvalue->value.integer.value[0 ] = ctrl->signal;return signal_old != ctrl->signal;
@@ -685,18 +752,32 @@ static int mchp_spdifrx_rate_get(struct snd_kcontrol *kcontrol,u32 val;int rate; -regmap_read (dev->regmap,SPDIFRX_RSR , &val); - -/* if the receiver is not locked, ISF data is invalid */ -if (val &SPDIFRX_RSR_ULOCK || !(val &SPDIFRX_RSR_IFS_MASK )) { +mutex_lock (&dev->mlock); + +/* +* The RSR.ULOCK has wrong value if both pclk and gclk are enabled +* and the receiver is disabled. Thus we take into account the +* dev->trigger_enabled here to return a real status. +*/ +if (dev->trigger_enabled) { +regmap_read (dev->regmap,SPDIFRX_RSR , &val); +/* If the receiver is not locked, ISF data is invalid. */ +if (val &SPDIFRX_RSR_ULOCK || !(val &SPDIFRX_RSR_IFS_MASK )) { + ucontrol->value.integer.value[0 ] =0 ; + goto unlock; + } + }else { +/* Reveicer is not locked, IFS data is invalid. */ ucontrol->value.integer.value[0 ] =0 ; -return 0 ; + goto unlock; } rate =clk_get_rate (dev->gclk); ucontrol->value.integer.value[0 ] = rate / (32 *SPDIFRX_RSR_IFS (val)); +unlock: +mutex_unlock (&dev->mlock);return 0 ; }
@@ -912,7 +993,18 @@ static int mchp_spdifrx_probe(struct platform_device *pdev) "failed to get the PMC generated clock: %d\n", err);return err; } + +/* +* Signal control need a valid rate on gclk. hw_params() configures +* it propertly but requesting signal before any hw_params() has been +* called lead to invalid value returned for signal. Thus, configure +* gclk at a valid rate, here, in initialization, to simplify the +* control path. +*/ +clk_set_min_rate (dev->gclk,48000 *SPDIFRX_GCLK_RATIO_MIN +1 ); +spin_lock_init (&dev->blockend_lock); +mutex_init (&dev->mlock); dev->dev = &pdev->dev; dev->regmap = regmap;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 222/567 ASoC: mchp-spdifrx: fix return value in case completion times out
In reply to Greg Kroah-HartmanFrom: Claudiu Beznea <[email protected]>
[ Upstream commit a4c4161d6eae3ef5f486d1638ef452d9bc1376b0 ]
wait_for_completion_interruptible_timeout() returns 0 in case of timeout. Check this into account when returning from function.
--- sound/soc/atmel/mchp-spdifrx.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
sound/soc/atmel/mchp-spdifrx.c +3 -2
@@ -524,9 +524,10 @@ static int mchp_spdifrx_cs_get(struct mchp_spdifrx_dev *dev, ret =wait_for_completion_interruptible_timeout (&ch_stat->done,msecs_to_jiffies (100 ));/* IP might not be started or valid stream might not be present */ -if (ret <0 ) { +if (ret <=0 ) {dev_dbg (dev->dev,"channel status for channel %d timeout\n" , channel); +return ret ? : -ETIMEDOUT ; } memcpy(uvalue->value.iec958.status, ch_stat->data,
@@ -580,7 +581,7 @@ static int mchp_spdifrx_subcode_ch_get(struct mchp_spdifrx_dev *dev,dev_dbg (dev->dev,"user data for channel %d timeout\n" , channel);mchp_spdifrx_isr_blockend_dis (dev); -return ret; +return ret ? : -ETIMEDOUT ; }spin_lock_irqsave (&user_data->lock, flags);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 223/567 ASoC: mchp-spdifrx: fix controls that works with completion mechanism
In reply to Greg Kroah-HartmanFrom: Claudiu Beznea <[email protected]>
[ Upstream commit d3681df44e856aab523a6eb7ba15b5e41efcbb1c ]
Channel status get and channel subcode get controls relies on data returned by controls when certain IRQs are raised. To achieve that completions are used b/w controls and interrupt service routine. The concurrent accesses to these controls are protected by struct snd_card::controls_rwsem.
Issues identified:
- reinit_completion() may be called while waiting for completion which should be avoided
- in case of multiple threads waiting, the complete() call in interrupt will signal only one waiting thread per interrupt which may lead to timeout for the others
- in case of channel status get as the CSC interrupt is not refcounted ISR may disable interrupt for threads that were just enabled it.
To solve these the access to controls were protected by a mutex. Along with this there is no need for spinlock to protect the software cache reads/updates b/w controls and ISR as the update is happening only when requested from control, and only one reader can reach the control.
--- sound/soc/atmel/mchp-spdifrx.c | 143 ++++++++++++++++++--------------- 1 file changed, 77 insertions(+), 66 deletions(-)
sound/soc/atmel/mchp-spdifrx.c +77 -66
@@ -217,7 +217,6 @@ struct mchp_spdifrx_ch_stat {struct mchp_spdifrx_user_data {unsigned char data[SPDIFRX_UD_BITS /8 ];struct completion done; -spinlock_t lock;/* protect access to user data */ };struct mchp_spdifrx_mixer_control {
@@ -231,8 +230,6 @@ struct mchp_spdifrx_mixer_control {struct mchp_spdifrx_dev {struct snd_dmaengine_dai_dma_data capture;struct mchp_spdifrx_mixer_control control; -spinlock_t blockend_lock;/* protect access to blockend_refcount */ -int blockend_refcount;struct mutex mlock;struct device *dev;struct regmap *regmap;
@@ -277,37 +274,11 @@ static void mchp_spdifrx_channel_user_data_read(struct mchp_spdifrx_dev *dev, } } -/* called from non-atomic context only */ -static void mchp_spdifrx_isr_blockend_en (struct mchp_spdifrx_dev *dev) -{ -unsigned long flags; - -spin_lock_irqsave (&dev->blockend_lock, flags); - dev->blockend_refcount++; -/* don't enable BLOCKEND interrupt if it's already enabled */ -if (dev->blockend_refcount ==1 ) -regmap_write (dev->regmap,SPDIFRX_IER ,SPDIFRX_IR_BLOCKEND ); -spin_unlock_irqrestore (&dev->blockend_lock, flags); -} - -/* called from atomic/non-atomic context */ -static void mchp_spdifrx_isr_blockend_dis (struct mchp_spdifrx_dev *dev) -{ -unsigned long flags; - -spin_lock_irqsave (&dev->blockend_lock, flags); - dev->blockend_refcount--; -/* don't enable BLOCKEND interrupt if it's already enabled */ -if (dev->blockend_refcount ==0 ) -regmap_write (dev->regmap,SPDIFRX_IDR ,SPDIFRX_IR_BLOCKEND ); -spin_unlock_irqrestore (&dev->blockend_lock, flags); -} -static irqreturn_t mchp_spdif_interrupt (int irq,void *dev_id) {struct mchp_spdifrx_dev *dev = dev_id;struct mchp_spdifrx_mixer_control *ctrl = &dev->control; -u32 sr, imr, pending, idr =0 ; +u32 sr, imr, pending;irqreturn_t ret =IRQ_NONE ;int ch;
@@ -322,13 +293,10 @@ static irqreturn_t mchp_spdif_interrupt(int irq, void *dev_id)if (pending &SPDIFRX_IR_BLOCKEND ) {for (ch =0 ; ch <SPDIFRX_CHANNELS ; ch++) { -spin_lock (&ctrl->user_data[ch].lock);mchp_spdifrx_channel_user_data_read (dev, ch); -spin_unlock (&ctrl->user_data[ch].lock); -complete (&ctrl->user_data[ch].done); } -mchp_spdifrx_isr_blockend_dis (dev); +regmap_write (dev->regmap,SPDIFRX_IDR ,SPDIFRX_IR_BLOCKEND ); ret =IRQ_HANDLED ; }
@@ -336,7 +304,7 @@ static irqreturn_t mchp_spdif_interrupt(int irq, void *dev_id)if (pending &SPDIFRX_IR_CSC (ch)) {mchp_spdifrx_channel_status_read (dev, ch);complete (&ctrl->ch_stat[ch].done); - idr |=SPDIFRX_IR_CSC (ch); +regmap_write (dev->regmap,SPDIFRX_IDR ,SPDIFRX_IR_CSC (ch)); ret =IRQ_HANDLED ; } }
@@ -346,8 +314,6 @@ static irqreturn_t mchp_spdif_interrupt(int irq, void *dev_id) ret =IRQ_HANDLED ; } -regmap_write (dev->regmap,SPDIFRX_IDR , idr); -return ret; }
@@ -517,23 +483,51 @@ static int mchp_spdifrx_cs_get(struct mchp_spdifrx_dev *dev, {struct mchp_spdifrx_mixer_control *ctrl = &dev->control;struct mchp_spdifrx_ch_stat *ch_stat = &ctrl->ch_stat[channel]; -int ret; +int ret =0 ; + +mutex_lock (&dev->mlock); -regmap_write (dev->regmap,SPDIFRX_IER ,SPDIFRX_IR_CSC (channel)); -/* check for new data available */ - ret =wait_for_completion_interruptible_timeout (&ch_stat->done, -msecs_to_jiffies (100 )); -/* IP might not be started or valid stream might not be present */ -if (ret <=0 ) { -dev_dbg (dev->dev,"channel status for channel %d timeout\n" , - channel); -return ret ? : -ETIMEDOUT ; +/* +* We may reach this point with both clocks enabled but the receiver +* still disabled. To void waiting for completion and return with +* timeout check the dev->trigger_enabled. +* +* To retrieve data: +* - if the receiver is enabled CSC IRQ will update the data in software +* caches (ch_stat->data) +* - otherwise we just update it here the software caches with latest +* available information and return it; in this case we don't need +* spin locking as the IRQ is disabled and will not be raised from +* anywhere else. +*/ + +if (dev->trigger_enabled) { +reinit_completion (&ch_stat->done); +regmap_write (dev->regmap,SPDIFRX_IER ,SPDIFRX_IR_CSC (channel)); +/* Check for new data available */ + ret =wait_for_completion_interruptible_timeout (&ch_stat->done, +msecs_to_jiffies (100 )); +/* Valid stream might not be present */ +if (ret <=0 ) { +dev_dbg (dev->dev,"channel status for channel %d timeout\n" , + channel); +regmap_write (dev->regmap,SPDIFRX_IDR ,SPDIFRX_IR_CSC (channel)); + ret = ret ? : -ETIMEDOUT ; + goto unlock; + }else { + ret =0 ; + } + }else { +/* Update software cache with latest channel status. */ +mchp_spdifrx_channel_status_read (dev, channel); }memcpy (uvalue->value.iec958.status, ch_stat->data,sizeof (ch_stat->data)); -return 0 ; +unlock: +mutex_unlock (&dev->mlock); +return ret; } static int mchp_spdifrx_cs1_get(struct snd_kcontrol *kcontrol,
@@ -567,29 +561,49 @@ static int mchp_spdifrx_subcode_ch_get(struct mchp_spdifrx_dev *dev,int channel, struct snd_ctl_elem_value *uvalue) { - unsigned long flags; struct mchp_spdifrx_mixer_control *ctrl = &dev->control;struct mchp_spdifrx_user_data *user_data = &ctrl->user_data[channel]; -int ret; +int ret =0 ; + +mutex_lock (&dev->mlock); + +/* +* We may reach this point with both clocks enabled but the receiver +* still disabled. To void waiting for completion to just timeout we +* check here the dev->trigger_enabled flag. +* +* To retrieve data: +* - if the receiver is enabled we need to wait for blockend IRQ to read +* data to and update it for us in software caches +* - otherwise reading the SPDIFRX_CHUD() registers is enough. +*/ -reinit_completion (&user_data->done); -mchp_spdifrx_isr_blockend_en (dev); - ret =wait_for_completion_interruptible_timeout (&user_data->done, -msecs_to_jiffies (100 )); -/* IP might not be started or valid stream might not be present */ -if (ret <=0 ) { -dev_dbg (dev->dev,"user data for channel %d timeout\n" , - channel); -mchp_spdifrx_isr_blockend_dis (dev); -return ret ? : -ETIMEDOUT ; +if (dev->trigger_enabled) { +reinit_completion (&user_data->done); +regmap_write (dev->regmap,SPDIFRX_IER ,SPDIFRX_IR_BLOCKEND ); + ret =wait_for_completion_interruptible_timeout (&user_data->done, +msecs_to_jiffies (100 )); +/* Valid stream might not be present. */ +if (ret <=0 ) { +dev_dbg (dev->dev,"user data for channel %d timeout\n" , + channel); +regmap_write (dev->regmap,SPDIFRX_IDR ,SPDIFRX_IR_BLOCKEND ); + ret = ret ? : -ETIMEDOUT ; + goto unlock; + }else { + ret =0 ; + } + }else { +/* Update software cache with last available data. */ +mchp_spdifrx_channel_user_data_read (dev, channel); } -spin_lock_irqsave (&user_data->lock, flags);memcpy (uvalue->value.iec958.subcode, user_data->data,sizeof (user_data->data)); -spin_unlock_irqrestore (&user_data->lock, flags); -return 0 ; +unlock: +mutex_unlock (&dev->mlock); +return ret; } static int mchp_spdifrx_subcode_ch1_get(struct snd_kcontrol *kcontrol,
@@ -890,11 +904,9 @@ static int mchp_spdifrx_dai_probe(struct snd_soc_dai *dai)SPDIFRX_MR_AUTORST_NOACTION | SPDIFRX_MR_PACK_DISABLED); - dev->blockend_refcount =0 ;for (ch =0 ; ch <SPDIFRX_CHANNELS ; ch++) {init_completion (&ctrl->ch_stat[ch].done);init_completion (&ctrl->user_data[ch].done); -spin_lock_init (&ctrl->user_data[ch].lock); }/* Add controls */
@@ -1004,7 +1016,6 @@ static int mchp_spdifrx_probe(struct platform_device *pdev)*/ clk_set_min_rate (dev->gclk,48000 *SPDIFRX_GCLK_RATIO_MIN +1 ); -spin_lock_init (&dev->blockend_lock);mutex_init (&dev->mlock); dev->dev = &pdev->dev;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 224/567 ASoC: mchp-spdifrx: disable all interrupts in mchp_spdifrx_dai_remove()
In reply to Greg Kroah-HartmanFrom: Claudiu Beznea <[email protected]>
[ Upstream commit aaecdc32b7e35b4f9b457fb3509414aa9a932589 ]
CSC interrupts which might be used in controls are on bits 8 and 9 of SPDIFRX_IDR register. Thus disable all the interrupts that are exported by driver.
--- sound/soc/atmel/mchp-spdifrx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/atmel/mchp-spdifrx.c +1 -1
@@ -921,7 +921,7 @@ static int mchp_spdifrx_dai_remove(struct snd_soc_dai *dai)struct mchp_spdifrx_dev *dev =snd_soc_dai_get_drvdata (dai);/* Disable interrupts */ -regmap_write (dev->regmap,SPDIFRX_IDR ,0xFF ); +regmap_write (dev->regmap,SPDIFRX_IDR ,GENMASK (14 ,0 ));clk_disable_unprepare (dev->pclk);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 225/567 ASoC: rsnd: fixup #endif position
In reply to Greg Kroah-HartmanFrom: Kuninori Morimoto <[email protected]>
[ Upstream commit 49123b51cd896e00b256a27c2ce9e6bfe1bbc22f ]
commit 1f9c82b5ab83ff2 ("ASoC: rsnd: add debugfs support") added CONFIG_DEBUG_FS related definitions on rsnd.h, but it should be added inside of RSND_H. This patch fixup it.
--- sound/soc/sh/rcar/rsnd.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/sh/rcar/rsnd.h +2 -2
@@ -901,8 +901,6 @@ void rsnd_mod_make_sure(struct rsnd_mod *mod, enum rsnd_mod_type type);if (!IS_BUILTIN (RSND_DEBUG_NO_DAI_CALL )) \ dev_dbg(dev, param) -#endif -#ifdef CONFIG_DEBUG_FS int rsnd_debugfs_probe (struct snd_soc_component *component); void rsnd_debugfs_reg_show(struct seq_file *m, phys_addr_t _addr,
@@ -913,3 +911,5 @@ void rsnd_debugfs_mod_reg_show(struct seq_file *m, struct rsnd_mod *mod,#else #define rsnd_debugfs_probe NULL#endif + +#endif /* RSND_H */
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 226/567 ASoC: mchp-spdifrx: Fix uninitialized use of mr in mchp_spdifrx_hw_params()
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
[ Upstream commit 218674a45930c700486d27b765bf2f1b43f8cbf7 ]
Clang warns:
../sound/soc/atmel/mchp-spdifrx.c:455:3: error: variable 'mr' is uninitialized when used here [-Werror,-Wuninitialized]
mr |= SPDIFRX_MR_ENDIAN_BIG;
^~
../sound/soc/atmel/mchp-spdifrx.c:432:8: note: initialize the variable 'mr' to silence this warning
u32 mr;
^
= 01 error generated.
Zero initialize mr so that these bitwise OR and assignment operation works unconditionally.
--- sound/soc/atmel/mchp-spdifrx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/atmel/mchp-spdifrx.c +1 -1
@@ -362,7 +362,7 @@ static int mchp_spdifrx_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) {struct mchp_spdifrx_dev *dev =snd_soc_dai_get_drvdata (dai); -u32 mr; +u32 mr =0 ;int ret; dev_dbg(dev->dev, "%s() rate=%u format=%#x width=%u channels=%u\n",
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 227/567 ASoC: dt-bindings: meson: fix gx-card codec node regex
In reply to Greg Kroah-HartmanFrom: Jerome Brunet <[email protected]>
[ Upstream commit 480b26226873c88e482575ceb0d0a38d76e1be57 ]
'codec' is a valid node name when there is a single codec in the link. Fix the node regular expression to apply this.
--- .../devicetree/bindings/sound/amlogic,gx-sound-card.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/devicetree/bindings/sound/amlogic,gx-sound-card.yaml +1 -1
@@ -61,7 +61,7 @@ patternProperties: description: phandle of the CPU DAI patternProperties: - "^codec-[0-9]+$": + "^codec(-[0-9]+)?$": type: object description: |- Codecs:
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 228/567 hwmon: (ltc2945) Handle error case in ltc2945_value_store
In reply to Greg Kroah-HartmanFrom: Jonathan Cormier <[email protected]>
[ Upstream commit 178b01eccfb0b8149682f61388400bd3d903dddc ]
ltc2945_val_to_reg errors were not being handled which would have resulted in register being set to 0 (clamped) instead of being left alone.
--- drivers/hwmon/ltc2945.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/hwmon/ltc2945.c +2 -0
@@ -248,6 +248,8 @@ static ssize_t ltc2945_value_store(struct device *dev,/* convert to register value, then clamp and write result */ regval =ltc2945_val_to_reg (dev, reg, val); +if (regval <0 ) +return regval;if (is_power_reg (reg)) { regval =clamp_val (regval,0 ,0xffffff ); regbuf[0 ] = regval >>16 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 229/567 drm/amdgpu: fix enum odm_combine_mode mismatch
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 087bad7eb1f6945f8232f132953ecc2bda8bd38d ]
A conversion from 'bool' to 'enum odm_combine_mode' was incomplete, and gcc warns about this with many instances of
display/dc/dml/dcn20/display_mode_vba_20.c:3899:44: warning: implicit conversion from 'enum <anonymous>' to 'enum odm_combine_mode' [-Wenum-conversion]
3899 | locals->ODMCombineEnablePerState[i][k] = false;
Change the ones that we get a warning for, using the same numerical values to leave the behavior unchanged.
--- .../amd/display/dc/dml/dcn20/display_mode_vba_20.c | 8 ++++---- .../amd/display/dc/dml/dcn20/display_mode_vba_20v2.c | 10 +++++----- .../amd/display/dc/dml/dcn21/display_mode_vba_21.c | 12 ++++++------ 3 files changed, 15 insertions(+), 15 deletions(-)
drivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20.c +4 -4
@@ -3897,14 +3897,14 @@ void dml20_ModeSupportAndSystemConfigurationFull(struct display_mode_lib *mode_l mode_lib->vba.PlaneRequiredDISPCLKWithODMCombine = mode_lib->vba.PixelClock[k] /2 * (1 + mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading /100.0 ); - locals->ODMCombineEnablePerState[i][k] = false; + locals->ODMCombineEnablePerState[i][k] = dm_odm_combine_mode_disabled; mode_lib->vba.PlaneRequiredDISPCLK = mode_lib->vba.PlaneRequiredDISPCLKWithoutODMCombine;if (mode_lib->vba.ODMCapability) {if (locals->PlaneRequiredDISPCLKWithoutODMCombine > mode_lib->vba.MaxDispclkRoundedDownToDFSGranularity) { - locals->ODMCombineEnablePerState[i][k] = true; + locals->ODMCombineEnablePerState[i][k] = dm_odm_combine_mode_2to1; mode_lib->vba.PlaneRequiredDISPCLK = mode_lib->vba.PlaneRequiredDISPCLKWithODMCombine; }else if (locals->HActive[k] >DCN20_MAX_420_IMAGE_WIDTH && locals->OutputFormat[k] == dm_420) { - locals->ODMCombineEnablePerState[i][k] = true; + locals->ODMCombineEnablePerState[i][k] = dm_odm_combine_mode_2to1; mode_lib->vba.PlaneRequiredDISPCLK = mode_lib->vba.PlaneRequiredDISPCLKWithODMCombine; } }
@@ -3957,7 +3957,7 @@ void dml20_ModeSupportAndSystemConfigurationFull(struct display_mode_lib *mode_l locals->RequiredDISPCLK[i][j] =0.0 ; locals->DISPCLK_DPPCLK_Support[i][j] = true;for (k =0 ; k <= mode_lib->vba.NumberOfActivePlanes -1 ; k++) { - locals->ODMCombineEnablePerState[i][k] = false; + locals->ODMCombineEnablePerState[i][k] = dm_odm_combine_mode_disabled;if (locals->SwathWidthYSingleDPP[k] <= locals->MaximumSwathWidth[k]) { locals->NoOfDPP[i][j][k] =1 ; locals->RequiredDPPCLK[i][j][k] = locals->MinDPPCLKUsingSingleDPP[k]
drivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20v2.c +5 -5
@@ -4008,17 +4008,17 @@ void dml20v2_ModeSupportAndSystemConfigurationFull(struct display_mode_lib *mode mode_lib->vba.PlaneRequiredDISPCLKWithODMCombine = mode_lib->vba.PixelClock[k] /2 * (1 + mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading /100.0 ); - locals->ODMCombineEnablePerState[i][k] = false; + locals->ODMCombineEnablePerState[i][k] = dm_odm_combine_mode_disabled; mode_lib->vba.PlaneRequiredDISPCLK = mode_lib->vba.PlaneRequiredDISPCLKWithoutODMCombine;if (mode_lib->vba.ODMCapability) {if (locals->PlaneRequiredDISPCLKWithoutODMCombine > MaxMaxDispclkRoundedDown) { - locals->ODMCombineEnablePerState[i][k] = true; + locals->ODMCombineEnablePerState[i][k] = dm_odm_combine_mode_2to1; mode_lib->vba.PlaneRequiredDISPCLK = mode_lib->vba.PlaneRequiredDISPCLKWithODMCombine; }else if (locals->DSCEnabled[k] && (locals->HActive[k] >DCN20_MAX_DSC_IMAGE_WIDTH )) { - locals->ODMCombineEnablePerState[i][k] = true; + locals->ODMCombineEnablePerState[i][k] = dm_odm_combine_mode_2to1; mode_lib->vba.PlaneRequiredDISPCLK = mode_lib->vba.PlaneRequiredDISPCLKWithODMCombine; }else if (locals->HActive[k] >DCN20_MAX_420_IMAGE_WIDTH && locals->OutputFormat[k] == dm_420) { - locals->ODMCombineEnablePerState[i][k] = true; + locals->ODMCombineEnablePerState[i][k] = dm_odm_combine_mode_2to1; mode_lib->vba.PlaneRequiredDISPCLK = mode_lib->vba.PlaneRequiredDISPCLKWithODMCombine; } }
@@ -4071,7 +4071,7 @@ void dml20v2_ModeSupportAndSystemConfigurationFull(struct display_mode_lib *mode locals->RequiredDISPCLK[i][j] =0.0 ; locals->DISPCLK_DPPCLK_Support[i][j] = true;for (k =0 ; k <= mode_lib->vba.NumberOfActivePlanes -1 ; k++) { - locals->ODMCombineEnablePerState[i][k] = false; + locals->ODMCombineEnablePerState[i][k] = dm_odm_combine_mode_disabled;if (locals->SwathWidthYSingleDPP[k] <= locals->MaximumSwathWidth[k]) { locals->NoOfDPP[i][j][k] =1 ; locals->RequiredDPPCLK[i][j][k] = locals->MinDPPCLKUsingSingleDPP[k]
drivers/gpu/drm/amd/display/dc/dml/dcn21/display_mode_vba_21.c +6 -6
@@ -3979,17 +3979,17 @@ void dml21_ModeSupportAndSystemConfigurationFull(struct display_mode_lib *mode_l mode_lib->vba.PlaneRequiredDISPCLKWithODMCombine = mode_lib->vba.PixelClock[k] /2 * (1 + mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading /100.0 ); - locals->ODMCombineEnablePerState[i][k] = false; + locals->ODMCombineEnablePerState[i][k] = dm_odm_combine_mode_disabled; mode_lib->vba.PlaneRequiredDISPCLK = mode_lib->vba.PlaneRequiredDISPCLKWithoutODMCombine;if (mode_lib->vba.ODMCapability) {if (locals->PlaneRequiredDISPCLKWithoutODMCombine > MaxMaxDispclkRoundedDown) { - locals->ODMCombineEnablePerState[i][k] = true; + locals->ODMCombineEnablePerState[i][k] = dm_odm_combine_mode_2to1; mode_lib->vba.PlaneRequiredDISPCLK = mode_lib->vba.PlaneRequiredDISPCLKWithODMCombine; }else if (locals->DSCEnabled[k] && (locals->HActive[k] >DCN21_MAX_DSC_IMAGE_WIDTH )) { - locals->ODMCombineEnablePerState[i][k] = true; + locals->ODMCombineEnablePerState[i][k] = dm_odm_combine_mode_2to1; mode_lib->vba.PlaneRequiredDISPCLK = mode_lib->vba.PlaneRequiredDISPCLKWithODMCombine; }else if (locals->HActive[k] >DCN21_MAX_420_IMAGE_WIDTH && locals->OutputFormat[k] == dm_420) { - locals->ODMCombineEnablePerState[i][k] = true; + locals->ODMCombineEnablePerState[i][k] = dm_odm_combine_mode_2to1; mode_lib->vba.PlaneRequiredDISPCLK = mode_lib->vba.PlaneRequiredDISPCLKWithODMCombine; } }
@@ -4042,7 +4042,7 @@ void dml21_ModeSupportAndSystemConfigurationFull(struct display_mode_lib *mode_l locals->RequiredDISPCLK[i][j] =0.0 ; locals->DISPCLK_DPPCLK_Support[i][j] = true;for (k =0 ; k <= mode_lib->vba.NumberOfActivePlanes -1 ; k++) { - locals->ODMCombineEnablePerState[i][k] = false; + locals->ODMCombineEnablePerState[i][k] = dm_odm_combine_mode_disabled;if (locals->SwathWidthYSingleDPP[k] <= locals->MaximumSwathWidth[k]) { locals->NoOfDPP[i][j][k] =1 ; locals->RequiredDPPCLK[i][j][k] = locals->MinDPPCLKUsingSingleDPP[k]
@@ -5218,7 +5218,7 @@ void dml21_ModeSupportAndSystemConfigurationFull(struct display_mode_lib *mode_l mode_lib->vba.ODMCombineEnabled[k] = locals->ODMCombineEnablePerState[mode_lib->vba.VoltageLevel][k]; }else { - mode_lib->vba.ODMCombineEnabled[k] = false; + mode_lib->vba.ODMCombineEnabled[k] = dm_odm_combine_mode_disabled; } mode_lib->vba.DSCEnabled[k] = locals->RequiresDSC[mode_lib->vba.VoltageLevel][k];
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 230/567 scsi: mpt3sas: Fix a memory leak
In reply to Greg Kroah-HartmanFrom: Tomas Henzl <[email protected]>
[ Upstream commit 54dd96015e8d7a2a07359e2dfebf05b529d1780c ]
Add a forgotten kfree().
--- drivers/scsi/mpt3sas/mpt3sas_base.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/scsi/mpt3sas/mpt3sas_base.c +3 -0
@@ -5682,6 +5682,9 @@ _base_release_memory_pools(struct MPT3SAS_ADAPTER *ioc) }dma_pool_destroy (ioc->pcie_sgl_dma_pool); } +kfree (ioc->pcie_sg_lookup); + ioc->pcie_sg_lookup =NULL ; +if (ioc->config_page) { dexitprintk(ioc, ioc_info(ioc, "config_page(0x%p): free\n",
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 231/567 scsi: aic94xx: Add missing check for dma_map_single()
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit 32fe45274edb5926abc0fac7263d9f889d02d9cf ]
Add check for dma_map_single() and return error if it fails in order to avoid invalid DMA address.
--- drivers/scsi/aic94xx/aic94xx_task.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/scsi/aic94xx/aic94xx_task.c +3 -0
@@ -50,6 +50,9 @@ static int asd_map_scatterlist(struct sas_task *task,dma_addr_t dma =dma_map_single (&asd_ha->pcidev->dev, p, task->total_xfer_len, task->data_dir); +if (dma_mapping_error (&asd_ha->pcidev->dev, dma)) +return -ENOMEM ; + sg_arr[0 ].bus_addr =cpu_to_le64 ((u64 )dma); sg_arr[0 ].size =cpu_to_le32 (task->total_xfer_len); sg_arr[0 ].flags |=ASD_SG_EL_LIST_EOL ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 232/567 HID: multitouch: Add quirks for flipped axes
In reply to Greg Kroah-HartmanFrom: Allen Ballway <[email protected]>
[ Upstream commit a2f416bf062a38bb76cccd526d2d286b8e4db4d9 ]
Certain touchscreen devices, such as the ELAN9034, are oriented incorrectly and report touches on opposite points on the X and Y axes. For example, a 100x200 screen touched at (10,20) would report (90, 180) and vice versa.
This is fixed by adding device quirks to transform the touch points into the correct spaces, from X -> MAX(X) - X, and Y -> MAX(Y) - Y.
Stable-dep-of: 03a86105556e ("HID: retain initial quirks set up when creating HID devices")
--- drivers/hid/hid-multitouch.c | 39 ++++++++++++++++++--- drivers/hid/hid-quirks.c | 6 ++++ drivers/hid/i2c-hid/i2c-hid-dmi-quirks.c | 43 ++++++++++++++++++++++++ drivers/hid/i2c-hid/i2c-hid.h | 3 ++ 4 files changed, 87 insertions(+), 4 deletions(-)
drivers/hid/hid-multitouch.c +35 -4
@@ -71,6 +71,7 @@ MODULE_LICENSE("GPL");#define MT_QUIRK_SEPARATE_APP_REPORT BIT(19)#define MT_QUIRK_FORCE_MULTI_INPUT BIT(20)#define MT_QUIRK_DISABLE_WAKEUP BIT(21) +#define MT_QUIRK_ORIENTATION_INVERT BIT(22)#define MT_INPUTMODE_TOUCHSCREEN 0x02#define MT_INPUTMODE_TOUCHPAD 0x03
@@ -1009,6 +1010,7 @@ static int mt_process_slot(struct mt_device *td, struct input_dev *input, struct mt_usages *slot) {struct input_mt *mt = input->mt; +struct hid_device *hdev = td->hdev;__s32 quirks = app->quirks;bool valid = true;bool confidence_state = true;
@@ -1086,6 +1088,10 @@ static int mt_process_slot(struct mt_device *td, struct input_dev *input,int orientation = wide;int max_azimuth;int azimuth; +int x; +int y; +int cx; +int cy;if (slot->a !=DEFAULT_ZERO ) {/*
@@ -1104,6 +1110,9 @@ static int mt_process_slot(struct mt_device *td, struct input_dev *input,if (azimuth > max_azimuth *2 ) azimuth -= max_azimuth *4 ; orientation = -azimuth; +if (quirks &MT_QUIRK_ORIENTATION_INVERT ) + orientation = -orientation; + }if (quirks &MT_QUIRK_TOUCH_SIZE_SCALING ) {
@@ -1115,10 +1124,23 @@ static int mt_process_slot(struct mt_device *td, struct input_dev *input, minor = minor >>1 ; } -input_event (input,EV_ABS ,ABS_MT_POSITION_X , *slot->x); -input_event (input,EV_ABS ,ABS_MT_POSITION_Y , *slot->y); -input_event (input,EV_ABS ,ABS_MT_TOOL_X , *slot->cx); -input_event (input,EV_ABS ,ABS_MT_TOOL_Y , *slot->cy); + x = hdev->quirks &HID_QUIRK_X_INVERT ? +input_abs_get_max (input,ABS_MT_POSITION_X ) - *slot->x : + *slot->x; + y = hdev->quirks &HID_QUIRK_Y_INVERT ? +input_abs_get_max (input,ABS_MT_POSITION_Y ) - *slot->y : + *slot->y; + cx = hdev->quirks &HID_QUIRK_X_INVERT ? +input_abs_get_max (input,ABS_MT_POSITION_X ) - *slot->cx : + *slot->cx; + cy = hdev->quirks &HID_QUIRK_Y_INVERT ? +input_abs_get_max (input,ABS_MT_POSITION_Y ) - *slot->cy : + *slot->cy; + +input_event (input,EV_ABS ,ABS_MT_POSITION_X , x); +input_event (input,EV_ABS ,ABS_MT_POSITION_Y , y); +input_event (input,EV_ABS ,ABS_MT_TOOL_X , cx); +input_event (input,EV_ABS ,ABS_MT_TOOL_Y , cy);input_event (input,EV_ABS ,ABS_MT_DISTANCE , !*slot->tip_state);input_event (input,EV_ABS ,ABS_MT_ORIENTATION , orientation);input_event (input,EV_ABS ,ABS_MT_PRESSURE , *slot->p);
@@ -1738,6 +1760,15 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)if (id->vendor ==HID_ANY_ID && id->product ==HID_ANY_ID ) td->serial_maybe = true; + +/* Orientation is inverted if the X or Y axes are +* flipped, but normalized if both are inverted. +*/ +if (hdev->quirks & (HID_QUIRK_X_INVERT |HID_QUIRK_Y_INVERT ) && + !((hdev->quirks &HID_QUIRK_X_INVERT ) + && (hdev->quirks &HID_QUIRK_Y_INVERT ))) + td->mtclass.quirks =MT_QUIRK_ORIENTATION_INVERT ; +/* This allows the driver to correctly support devices * that emit events over several HID messages. */
drivers/hid/hid-quirks.c +6 -0
@@ -19,6 +19,7 @@#include <linux/input/elan-i2c-ids.h> #include "hid-ids.h" +#include "i2c-hid/i2c-hid.h" /* * Alphabetically sorted by vendor then product.
@@ -1278,6 +1279,11 @@ unsigned long hid_lookup_quirk(const struct hid_device *hdev) quirks =hid_gets_squirk (hdev);mutex_unlock (&dquirks_lock); +/* Get quirks specific to I2C devices */ +if (IS_ENABLED (CONFIG_I2C_DMI_CORE ) &&IS_ENABLED (CONFIG_DMI ) && + hdev->bus ==BUS_I2C ) + quirks |=i2c_hid_get_dmi_quirks (hdev->vendor, hdev->product); +return quirks; }EXPORT_SYMBOL_GPL (hid_lookup_quirk);
drivers/hid/i2c-hid/i2c-hid-dmi-quirks.c +43 -0
60 lines not on this page · raw message
drivers/hid/i2c-hid/i2c-hid.h +3 -0
@@ -9,6 +9,7 @@struct i2c_hid_desc *i2c_hid_get_dmi_i2c_hid_desc_override (uint8_t *i2c_name);char *i2c_hid_get_dmi_hid_report_desc_override (uint8_t *i2c_name,unsigned int *size); +u32 i2c_hid_get_dmi_quirks (const u16 vendor,const u16 product);#else static inline struct i2c_hid_desc *i2c_hid_get_dmi_i2c_hid_desc_override (uint8_t *i2c_name)
@@ -16,6 +17,8 @@ static inline struct i2c_hid_descstatic inline char *i2c_hid_get_dmi_hid_report_desc_override (uint8_t *i2c_name,unsigned int *size) {return NULL ; } +static inline u32 i2c_hid_get_dmi_quirks (const u16 vendor,const u16 product) +{return 0 ; }#endif /**
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 233/567 HID: retain initial quirks set up when creating HID devices
In reply to Greg Kroah-HartmanFrom: Dmitry Torokhov <[email protected]>
[ Upstream commit 03a86105556e23650e4470c09f91cf7c360d5e28 ]
In certain circumstances, such as when creating I2C-connected HID devices, we want to pass and retain some quirks (axis inversion, etc). The source of such quirks may be device tree, or DMI data, or something else not readily available to the HID core itself and therefore cannot be reconstructed easily. To allow this, introduce "initial_quirks" field in hid_device structure and use it when determining the final set of quirks.
This fixes the problem with i2c-hid setting up device-tree sourced quirks too late and losing them on device rebind, and also allows to sever the tie between hid-code and i2c-hid when applying DMI-based quirks.
--- drivers/hid/hid-quirks.c | 8 +------- drivers/hid/i2c-hid/i2c-hid-core.c | 6 ++++-- drivers/hid/i2c-hid/i2c-hid-dmi-quirks.c | 1 - include/linux/hid.h | 1 + 4 files changed, 6 insertions(+), 10 deletions(-)
drivers/hid/hid-quirks.c +1 -7
@@ -19,7 +19,6 @@#include <linux/input/elan-i2c-ids.h> #include "hid-ids.h" -#include "i2c-hid/i2c-hid.h" /* * Alphabetically sorted by vendor then product.
@@ -1218,7 +1217,7 @@ EXPORT_SYMBOL_GPL(hid_quirks_exit);static unsigned long hid_gets_squirk (const struct hid_device *hdev) {const struct hid_device_id *bl_entry; -unsigned long quirks =0 ; +unsigned long quirks = hdev->initial_quirks;if (hid_match_id (hdev, hid_ignore_list)) quirks |=HID_QUIRK_IGNORE ;
@@ -1279,11 +1278,6 @@ unsigned long hid_lookup_quirk(const struct hid_device *hdev) quirks =hid_gets_squirk (hdev);mutex_unlock (&dquirks_lock); -/* Get quirks specific to I2C devices */ -if (IS_ENABLED (CONFIG_I2C_DMI_CORE ) &&IS_ENABLED (CONFIG_DMI ) && - hdev->bus ==BUS_I2C ) - quirks |=i2c_hid_get_dmi_quirks (hdev->vendor, hdev->product); -return quirks; }EXPORT_SYMBOL_GPL (hid_lookup_quirk);
drivers/hid/i2c-hid/i2c-hid-core.c +4 -2
@@ -1012,6 +1012,10 @@ int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops, hid->vendor =le16_to_cpu (ihid->hdesc.wVendorID); hid->product =le16_to_cpu (ihid->hdesc.wProductID); + hid->initial_quirks = quirks; + hid->initial_quirks |=i2c_hid_get_dmi_quirks (hid->vendor, + hid->product); +snprintf (hid->name,sizeof (hid->name),"%s %04X:%04X" , client->name, (u16 )hid->vendor, (u16 )hid->product);strlcpy (hid->phys,dev_name (&client->dev),sizeof (hid->phys));
@@ -1025,8 +1029,6 @@ int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops, goto err_mem_free; } - hid->quirks |= quirks; -return 0 ; err_mem_free:
drivers/hid/i2c-hid/i2c-hid-dmi-quirks.c +0 -1
@@ -492,4 +492,3 @@ u32 i2c_hid_get_dmi_quirks(const u16 vendor, const u16 product)return quirks; } -EXPORT_SYMBOL_GPL (i2c_hid_get_dmi_quirks);
include/linux/hid.h +1 -0
@@ -599,6 +599,7 @@ struct hid_device { /* device report descriptor */unsigned long status;/* see STAT flags above */ unsigned claimed;/* Claimed by hidinput, hiddev? */ unsigned quirks;/* Various quirks the device can pull on us */ +unsigned initial_quirks;/* Initial set of quirks supplied when creating device */ bool io_started;/* If IO has started */ struct list_head inputs;/* The list of inputs */
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 234/567 ASoC: codecs: Change bulk clock voting to optional voting in digital codecs
In reply to Greg Kroah-HartmanFrom: Srinivasa Rao Mandadapu <[email protected]>
[ Upstream commit 9f589cf0f91485c8591775acad056c80378a2d34 ]
Change bulk clock frequency voting to optional bulk voting in va, rx and tx macros to accommodate both ADSP and ADSP bypass based lpass architectures.
Stable-dep-of: e7621434378c ("ASoC: codecs: lpass: fix incorrect mclk rate")
--- sound/soc/codecs/lpass-rx-macro.c | 2 +- sound/soc/codecs/lpass-tx-macro.c | 2 +- sound/soc/codecs/lpass-va-macro.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
sound/soc/codecs/lpass-rx-macro.c +1 -1
@@ -3535,7 +3535,7 @@ static int rx_macro_probe(struct platform_device *pdev) rx->clks[3 ].id ="npl" ; rx->clks[4 ].id ="fsgen" ; - ret =devm_clk_bulk_get (dev,RX_NUM_CLKS_MAX , rx->clks); + ret =devm_clk_bulk_get_optional (dev,RX_NUM_CLKS_MAX , rx->clks);if (ret) {dev_err (dev,"Error getting RX Clocks (%d)\n" , ret);return ret;
sound/soc/codecs/lpass-tx-macro.c +1 -1
@@ -1801,7 +1801,7 @@ static int tx_macro_probe(struct platform_device *pdev) tx->clks[3 ].id ="npl" ; tx->clks[4 ].id ="fsgen" ; - ret =devm_clk_bulk_get (dev,TX_NUM_CLKS_MAX , tx->clks); + ret =devm_clk_bulk_get_optional (dev,TX_NUM_CLKS_MAX , tx->clks);if (ret) {dev_err (dev,"Error getting RX Clocks (%d)\n" , ret);return ret;
sound/soc/codecs/lpass-va-macro.c +1 -1
@@ -1408,7 +1408,7 @@ static int va_macro_probe(struct platform_device *pdev) va->clks[1 ].id ="dcodec" ; va->clks[2 ].id ="mclk" ; - ret =devm_clk_bulk_get (dev,VA_NUM_CLKS_MAX , va->clks); + ret =devm_clk_bulk_get_optional (dev,VA_NUM_CLKS_MAX , va->clks);if (ret) {dev_err (dev,"Error getting VA Clocks (%d)\n" , ret);return ret;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 235/567 ASoC: codecs: rx-macro: move clk provider to managed variants
In reply to Greg Kroah-HartmanFrom: Srinivas Kandagatla <[email protected]>
[ Upstream commit 70a5e96bad592145ba25365689a2d7d8dedb3bd9 ]
move clk provider registration to managed api variants, this should help with some code tidyup.
Stable-dep-of: e7621434378c ("ASoC: codecs: lpass: fix incorrect mclk rate")
--- sound/soc/codecs/lpass-rx-macro.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
sound/soc/codecs/lpass-rx-macro.c +11 -10
@@ -3479,10 +3479,9 @@ static const struct clk_ops swclk_gate_ops = { }; -static struct clk *rx_macro_register_mclk_output (struct rx_macro *rx) +static int rx_macro_register_mclk_output (struct rx_macro *rx) {struct device *dev = rx->dev; -struct device_node *np = dev->of_node;const char *parent_clk_name =NULL ;const char *clk_name ="lpass-rx-mclk" ;struct clk_hw *hw;
@@ -3498,13 +3497,11 @@ static struct clk *rx_macro_register_mclk_output(struct rx_macro *rx) init.num_parents =1 ; rx->hw.init = &init; hw = &rx->hw; - ret =clk_hw_register (rx->dev, hw); + ret =devm_clk_hw_register (rx->dev, hw);if (ret) -return ERR_PTR (ret); - -of_clk_add_provider (np, of_clk_src_simple_get, hw->clk); +return ret; -return NULL ; +return devm_of_clk_add_hw_provider (dev, of_clk_hw_simple_get, hw); }static const struct snd_soc_component_driver rx_macro_component_drv = {
@@ -3562,22 +3559,26 @@ static int rx_macro_probe(struct platform_device *pdev)if (ret)return ret; -rx_macro_register_mclk_output (rx); + ret =rx_macro_register_mclk_output (rx); +if (ret) + goto err; ret =devm_snd_soc_register_component (dev, &rx_macro_component_drv, rx_macro_dai,ARRAY_SIZE (rx_macro_dai));if (ret) -clk_bulk_disable_unprepare (RX_NUM_CLKS_MAX , rx->clks); + goto err;return ret; +err: +clk_bulk_disable_unprepare (RX_NUM_CLKS_MAX , rx->clks); +return ret; }static int rx_macro_remove (struct platform_device *pdev) {struct rx_macro *rx =dev_get_drvdata (&pdev->dev); -of_clk_del_provider (pdev->dev.of_node);clk_bulk_disable_unprepare (RX_NUM_CLKS_MAX , rx->clks);return 0 ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 236/567 ASoC: codecs: tx-macro: move clk provider to managed variants
In reply to Greg Kroah-HartmanFrom: Srinivas Kandagatla <[email protected]>
[ Upstream commit db8665a3e904f579840417f9414415c4dd54ac84 ]
move clk provider registration to managed api variants, this should help with some code tidyup.
Stable-dep-of: e7621434378c ("ASoC: codecs: lpass: fix incorrect mclk rate")
--- sound/soc/codecs/lpass-tx-macro.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
sound/soc/codecs/lpass-tx-macro.c +7 -10
@@ -1745,10 +1745,9 @@ static const struct clk_ops swclk_gate_ops = { }; -static struct clk *tx_macro_register_mclk_output (struct tx_macro *tx) +static int tx_macro_register_mclk_output (struct tx_macro *tx) {struct device *dev = tx->dev; -struct device_node *np = dev->of_node;const char *parent_clk_name =NULL ;const char *clk_name ="lpass-tx-mclk" ;struct clk_hw *hw;
@@ -1764,13 +1763,11 @@ static struct clk *tx_macro_register_mclk_output(struct tx_macro *tx) init.num_parents =1 ; tx->hw.init = &init; hw = &tx->hw; - ret =clk_hw_register (tx->dev, hw); + ret =devm_clk_hw_register (dev, hw);if (ret) -return ERR_PTR (ret); - -of_clk_add_provider (np, of_clk_src_simple_get, hw->clk); +return ret; -return NULL ; +return devm_of_clk_add_hw_provider (dev, of_clk_hw_simple_get, hw); }static const struct snd_soc_component_driver tx_macro_component_drv = {
@@ -1828,7 +1825,9 @@ static int tx_macro_probe(struct platform_device *pdev)if (ret)return ret; -tx_macro_register_mclk_output (tx); + ret =tx_macro_register_mclk_output (tx); +if (ret) + goto err; ret = devm_snd_soc_register_component(dev, &tx_macro_component_drv, tx_macro_dai,
@@ -1846,8 +1845,6 @@ static int tx_macro_remove(struct platform_device *pdev) {struct tx_macro *tx =dev_get_drvdata (&pdev->dev); -of_clk_del_provider (pdev->dev.of_node); -clk_bulk_disable_unprepare (TX_NUM_CLKS_MAX , tx->clks);return 0 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 237/567 ASoC: codecs: rx-macro: move to individual clks from bulk
In reply to Greg Kroah-HartmanFrom: Srinivas Kandagatla <[email protected]>
[ Upstream commit 43b647d9940454263421f9a1c756680bdf1d443c ]
Using bulk clocks and referencing them individually using array index is not great for readers.
So move them to individual clocks handling and also remove some unnecessary error handling in the code.
Stable-dep-of: e7621434378c ("ASoC: codecs: lpass: fix incorrect mclk rate")
--- sound/soc/codecs/lpass-rx-macro.c | 85 +++++++++++++++++++++++-------- 1 file changed, 64 insertions(+), 21 deletions(-)
sound/soc/codecs/lpass-rx-macro.c +64 -21
@@ -608,7 +608,11 @@ struct rx_macro {int softclip_clk_users;struct regmap *regmap; -struct clk_bulk_data clks[RX_NUM_CLKS_MAX ]; +struct clk *mclk; +struct clk *npl; +struct clk *macro; +struct clk *dcodec; +struct clk *fsgen;struct clk_hw hw; };#define to_rx_macro (_hw) container_of(_hw, struct rx_macro, hw)
@@ -3488,7 +3492,7 @@ static int rx_macro_register_mclk_output(struct rx_macro *rx)struct clk_init_data init;int ret; - parent_clk_name =__clk_get_name (rx->clks[2 ].clk); + parent_clk_name =__clk_get_name (rx->mclk); init.name = clk_name; init.ops = &swclk_gate_ops;
@@ -3526,17 +3530,25 @@ static int rx_macro_probe(struct platform_device *pdev)if (!rx)return -ENOMEM ; - rx->clks[0 ].id ="macro" ; - rx->clks[1 ].id ="dcodec" ; - rx->clks[2 ].id ="mclk" ; - rx->clks[3 ].id ="npl" ; - rx->clks[4 ].id ="fsgen" ; + rx->macro =devm_clk_get_optional (dev,"macro" ); +if (IS_ERR (rx->macro)) +return PTR_ERR (rx->macro); - ret =devm_clk_bulk_get_optional (dev,RX_NUM_CLKS_MAX , rx->clks); -if (ret) { -dev_err (dev,"Error getting RX Clocks (%d)\n" , ret); -return ret; - } + rx->dcodec =devm_clk_get_optional (dev,"dcodec" ); +if (IS_ERR (rx->dcodec)) +return PTR_ERR (rx->dcodec); + + rx->mclk =devm_clk_get (dev,"mclk" ); +if (IS_ERR (rx->mclk)) +return PTR_ERR (rx->mclk); + + rx->npl =devm_clk_get (dev,"npl" ); +if (IS_ERR (rx->npl)) +return PTR_ERR (rx->npl); + + rx->fsgen =devm_clk_get (dev,"fsgen" ); +if (IS_ERR (rx->fsgen)) +return PTR_ERR (rx->fsgen); base =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (base))
@@ -3552,26 +3564,52 @@ static int rx_macro_probe(struct platform_device *pdev) rx->dev = dev;/* set MCLK and NPL rates */ -clk_set_rate (rx->clks[2 ].clk,MCLK_FREQ ); -clk_set_rate (rx->clks[3 ].clk,2 *MCLK_FREQ ); +clk_set_rate (rx->mclk,MCLK_FREQ ); +clk_set_rate (rx->npl,2 *MCLK_FREQ ); - ret =clk_bulk_prepare_enable (RX_NUM_CLKS_MAX , rx->clks); + ret =clk_prepare_enable (rx->macro);if (ret) -return ret; + goto err; + + ret =clk_prepare_enable (rx->dcodec); +if (ret) + goto err_dcodec; + + ret =clk_prepare_enable (rx->mclk); +if (ret) + goto err_mclk; + + ret =clk_prepare_enable (rx->npl); +if (ret) + goto err_npl; + + ret =clk_prepare_enable (rx->fsgen); +if (ret) + goto err_fsgen; ret =rx_macro_register_mclk_output (rx);if (ret) - goto err; + goto err_clkout; ret =devm_snd_soc_register_component (dev, &rx_macro_component_drv, rx_macro_dai,ARRAY_SIZE (rx_macro_dai));if (ret) - goto err; + goto err_clkout; -return ret; +return 0 ; + +err_clkout: +clk_disable_unprepare (rx->fsgen); +err_fsgen: +clk_disable_unprepare (rx->npl); +err_npl: +clk_disable_unprepare (rx->mclk); +err_mclk: +clk_disable_unprepare (rx->dcodec); +err_dcodec: +clk_disable_unprepare (rx->macro); err: -clk_bulk_disable_unprepare (RX_NUM_CLKS_MAX , rx->clks);return ret; }
@@ -3579,7 +3617,12 @@ static int rx_macro_remove(struct platform_device *pdev) {struct rx_macro *rx =dev_get_drvdata (&pdev->dev); -clk_bulk_disable_unprepare (RX_NUM_CLKS_MAX , rx->clks); +clk_disable_unprepare (rx->mclk); +clk_disable_unprepare (rx->npl); +clk_disable_unprepare (rx->fsgen); +clk_disable_unprepare (rx->macro); +clk_disable_unprepare (rx->dcodec); +return 0 ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 238/567 ASoC: codecs: tx-macro: move to individual clks from bulk
In reply to Greg Kroah-HartmanFrom: Srinivas Kandagatla <[email protected]>
[ Upstream commit 512864c4ffa70522b9c44d5b40c15273330ae9c7 ]
Using bulk clocks and referencing them individually using array index is not great for readers.
So move them to individual clocks handling and also remove some unnecessary error handling in the code.
Stable-dep-of: e7621434378c ("ASoC: codecs: lpass: fix incorrect mclk rate")
--- sound/soc/codecs/lpass-tx-macro.c | 87 +++++++++++++++++++++++-------- 1 file changed, 65 insertions(+), 22 deletions(-)
sound/soc/codecs/lpass-tx-macro.c +65 -22
@@ -6,6 +6,7 @@#include <linux/clk.h> #include <linux/io.h> #include <linux/platform_device.h> +#include <linux/pm_runtime.h> #include <linux/regmap.h> #include <sound/soc.h> #include <sound/soc-dapm.h>
@@ -258,7 +259,11 @@ struct tx_macro {unsigned long active_ch_cnt[TX_MACRO_MAX_DAIS ];unsigned long active_decimator[TX_MACRO_MAX_DAIS ];struct regmap *regmap; -struct clk_bulk_data clks[TX_NUM_CLKS_MAX ]; +struct clk *mclk; +struct clk *npl; +struct clk *macro; +struct clk *dcodec; +struct clk *fsgen;struct clk_hw hw;bool dec_active[NUM_DECIMATORS ];bool reset_swr;
@@ -1754,7 +1759,7 @@ static int tx_macro_register_mclk_output(struct tx_macro *tx)struct clk_init_data init;int ret; - parent_clk_name =__clk_get_name (tx->clks[2 ].clk); + parent_clk_name =__clk_get_name (tx->mclk); init.name = clk_name; init.ops = &swclk_gate_ops;
@@ -1792,17 +1797,25 @@ static int tx_macro_probe(struct platform_device *pdev)if (!tx)return -ENOMEM ; - tx->clks[0 ].id ="macro" ; - tx->clks[1 ].id ="dcodec" ; - tx->clks[2 ].id ="mclk" ; - tx->clks[3 ].id ="npl" ; - tx->clks[4 ].id ="fsgen" ; + tx->macro =devm_clk_get_optional (dev,"macro" ); +if (IS_ERR (tx->macro)) +return PTR_ERR (tx->macro); - ret =devm_clk_bulk_get_optional (dev,TX_NUM_CLKS_MAX , tx->clks); -if (ret) { -dev_err (dev,"Error getting RX Clocks (%d)\n" , ret); -return ret; - } + tx->dcodec =devm_clk_get_optional (dev,"dcodec" ); +if (IS_ERR (tx->dcodec)) +return PTR_ERR (tx->dcodec); + + tx->mclk =devm_clk_get (dev,"mclk" ); +if (IS_ERR (tx->mclk)) +return PTR_ERR (tx->mclk); + + tx->npl =devm_clk_get (dev,"npl" ); +if (IS_ERR (tx->npl)) +return PTR_ERR (tx->npl); + + tx->fsgen =devm_clk_get (dev,"fsgen" ); +if (IS_ERR (tx->fsgen)) +return PTR_ERR (tx->fsgen); base =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (base))
@@ -1818,26 +1831,52 @@ static int tx_macro_probe(struct platform_device *pdev) tx->dev = dev;/* set MCLK and NPL rates */ -clk_set_rate (tx->clks[2 ].clk,MCLK_FREQ ); -clk_set_rate (tx->clks[3 ].clk,2 *MCLK_FREQ ); +clk_set_rate (tx->mclk,MCLK_FREQ ); +clk_set_rate (tx->npl,2 *MCLK_FREQ ); - ret =clk_bulk_prepare_enable (TX_NUM_CLKS_MAX , tx->clks); + ret =clk_prepare_enable (tx->macro);if (ret) -return ret; + goto err; + + ret =clk_prepare_enable (tx->dcodec); +if (ret) + goto err_dcodec; + + ret =clk_prepare_enable (tx->mclk); +if (ret) + goto err_mclk; + + ret =clk_prepare_enable (tx->npl); +if (ret) + goto err_npl; + + ret =clk_prepare_enable (tx->fsgen); +if (ret) + goto err_fsgen; ret =tx_macro_register_mclk_output (tx);if (ret) - goto err; + goto err_clkout; ret =devm_snd_soc_register_component (dev, &tx_macro_component_drv, tx_macro_dai,ARRAY_SIZE (tx_macro_dai));if (ret) - goto err; -return ret; -err: -clk_bulk_disable_unprepare (TX_NUM_CLKS_MAX , tx->clks); + goto err_clkout; +return 0 ; + +err_clkout: +clk_disable_unprepare (tx->fsgen); +err_fsgen: +clk_disable_unprepare (tx->npl); +err_npl: +clk_disable_unprepare (tx->mclk); +err_mclk: +clk_disable_unprepare (tx->dcodec); +err_dcodec: +clk_disable_unprepare (tx->macro); +err:return ret; }
@@ -1845,7 +1884,11 @@ static int tx_macro_remove(struct platform_device *pdev) {struct tx_macro *tx =dev_get_drvdata (&pdev->dev); -clk_bulk_disable_unprepare (TX_NUM_CLKS_MAX , tx->clks); +clk_disable_unprepare (tx->macro); +clk_disable_unprepare (tx->dcodec); +clk_disable_unprepare (tx->mclk); +clk_disable_unprepare (tx->npl); +clk_disable_unprepare (tx->fsgen);return 0 ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 239/567 ASoC: codecs: lpass: fix incorrect mclk rate
In reply to Greg Kroah-HartmanFrom: Srinivas Kandagatla <[email protected]>
[ Upstream commit e7621434378c40b62ef858c14ae6415fb6469a8e ]
For some reason we ended up with incorrect mclk rate which should be 1920000 instead of 96000, So far we were getting lucky as the same clk is set to 192000 by wsa and va macro. This issue is discovered when there is no wsa macro active and only rx or tx path is tested.
Fix this by setting correct rate.
--- sound/soc/codecs/lpass-rx-macro.c | 4 ++-- sound/soc/codecs/lpass-tx-macro.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
sound/soc/codecs/lpass-rx-macro.c +2 -2
@@ -363,7 +363,7 @@#define CDC_RX_DSD1_CFG2 (0x0F8C)#define RX_MAX_OFFSET (0x0F8C) -#define MCLK_FREQ 9600000 +#define MCLK_FREQ 19200000#define RX_MACRO_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\ SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |\
@@ -3565,7 +3565,7 @@ static int rx_macro_probe(struct platform_device *pdev)/* set MCLK and NPL rates */ clk_set_rate (rx->mclk,MCLK_FREQ ); -clk_set_rate (rx->npl,2 *MCLK_FREQ ); +clk_set_rate (rx->npl,MCLK_FREQ ); ret =clk_prepare_enable (rx->macro);if (ret)
sound/soc/codecs/lpass-tx-macro.c +2 -2
@@ -200,7 +200,7 @@#define TX_MACRO_AMIC_UNMUTE_DELAY_MS 100#define TX_MACRO_DMIC_HPF_DELAY_MS 300#define TX_MACRO_AMIC_HPF_DELAY_MS 300 -#define MCLK_FREQ 9600000 +#define MCLK_FREQ 19200000enum {TX_MACRO_AIF_INVALID =0 ,
@@ -1832,7 +1832,7 @@ static int tx_macro_probe(struct platform_device *pdev)/* set MCLK and NPL rates */ clk_set_rate (tx->mclk,MCLK_FREQ ); -clk_set_rate (tx->npl,2 *MCLK_FREQ ); +clk_set_rate (tx->npl,MCLK_FREQ ); ret =clk_prepare_enable (tx->macro);if (ret)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 240/567 spi: bcm63xx-hsspi: Endianness fix for ARM based SoC
In reply to Greg Kroah-HartmanFrom: William Zhang <[email protected]>
[ Upstream commit 85a84a61699990db6a025b5073f337f49933a875 ]
HSSPI controller uses big endian for the opcode in the message to the controller ping pong buffer. Use cpu_to_be16 to properly handle the endianness for both big and little endian host.
--- drivers/spi/spi-bcm63xx-hsspi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-bcm63xx-hsspi.c +1 -1
@@ -194,7 +194,7 @@ static int bcm63xx_hsspi_do_txrx(struct spi_device *spi, struct spi_transfer *t) tx += curr_step; } -__raw_writew (opcode | curr_step, bs->fifo); +__raw_writew ((u16 )cpu_to_be16 (opcode | curr_step), bs->fifo);/* enable interrupt */ __raw_writel(HSSPI_PINGx_CMD_DONE(0),
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 241/567 spi: bcm63xx-hsspi: Fix multi-bit mode setting
In reply to Greg Kroah-HartmanFrom: William Zhang <[email protected]>
[ Upstream commit 811ff802aaf878ebbbaeac0307a0164fa21e7d40 ]
Currently the driver always sets the controller to dual data bit mode for both tx and rx data in the profile mode control register even for single data bit transfer. Luckily the opcode is set correctly according to SPI transfer data bit width so it does not actually cause issues.
This change fixes the problem by setting tx and rx data bit mode field correctly according to the actual SPI transfer tx and rx data bit width.
--- drivers/spi/spi-bcm63xx-hsspi.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/spi/spi-bcm63xx-hsspi.c +9 -3
@@ -163,6 +163,7 @@ static int bcm63xx_hsspi_do_txrx(struct spi_device *spi, struct spi_transfer *t)int step_size =HSSPI_BUFFER_LEN ;const u8 *tx = t->tx_buf;u8 *rx = t->rx_buf; +u32 val =0 ;bcm63xx_hsspi_set_clk (bs, spi, t->speed_hz);bcm63xx_hsspi_set_cs (bs, spi->chip_select, true);
@@ -178,11 +179,16 @@ static int bcm63xx_hsspi_do_txrx(struct spi_device *spi, struct spi_transfer *t) step_size -=HSSPI_OPCODE_LEN ;if ((opcode ==HSSPI_OP_READ && t->rx_nbits ==SPI_NBITS_DUAL ) || - (opcode ==HSSPI_OP_WRITE && t->tx_nbits ==SPI_NBITS_DUAL )) + (opcode ==HSSPI_OP_WRITE && t->tx_nbits ==SPI_NBITS_DUAL )) { opcode |=HSSPI_OP_MULTIBIT ; -__raw_writel (1 <<MODE_CTRL_MULTIDATA_WR_SIZE_SHIFT | -1 <<MODE_CTRL_MULTIDATA_RD_SIZE_SHIFT |0xff , +if (t->rx_nbits ==SPI_NBITS_DUAL ) + val |=1 <<MODE_CTRL_MULTIDATA_RD_SIZE_SHIFT ; +if (t->tx_nbits ==SPI_NBITS_DUAL ) + val |=1 <<MODE_CTRL_MULTIDATA_WR_SIZE_SHIFT ; + } + +__raw_writel (val |0xff , bs->regs +HSSPI_PROFILE_MODE_CTRL_REG (chip_select));while (pending >0 ) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 242/567 hwmon: (mlxreg-fan) Return zero speed for broken fan
In reply to Greg Kroah-HartmanFrom: Vadim Pasternak <[email protected]>
[ Upstream commit a1ffd3c46267ee5c807acd780e15df9bb692223f ]
Currently for broken fan driver returns value calculated based on error code (0xFF) in related fan speed register.
Thus, for such fan user gets fan{n}_fault to 1 and fan{n}_input with misleading value.
Add check for fan fault prior return speed value and return zero if fault is detected.
--- drivers/hwmon/mlxreg-fan.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/hwmon/mlxreg-fan.c +6 -0
@@ -151,6 +151,12 @@ mlxreg_fan_read(struct device *dev, enum hwmon_sensor_types type, u32 attr,if (err)return err; +if (MLXREG_FAN_GET_FAULT (regval, tacho->mask)) { +/* FAN is broken - return zero for FAN speed. */ + *val =0 ; +return 0 ; + } + *val =MLXREG_FAN_GET_RPM (regval, fan->divider, fan->samples);break ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 243/567 ASoC: tlv320adcx140: fix ti,gpio-config DT property init
In reply to Greg Kroah-HartmanFrom: Steffen Aschbacher <[email protected]>
[ Upstream commit 771725efe5e2e5396dd9d1220437e5f9d6b9ca9d ]
When the 'ti,gpio-config' property is not defined, the device_property_count_u32() will return an error, rather than zero.
The current check, only handles a return value of zero, which assumes that the property is defined and has nothing defined.
This change extends the check to also check for an error case (most likely to be hit by the case that the 'ti,gpio-config' is not defined).
In case that the 'ti,gpio-config' and the returned 'gpio_count' is not correct, there is a 'if (gpio_count != ADCX140_NUM_GPIO_CFGS)' check, a few lines lower that will return -EINVAL.
This means that someone tried to define 'ti,gpio-config', but with the wrong number of GPIOs.
--- sound/soc/codecs/tlv320adcx140.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/tlv320adcx140.c +1 -1
@@ -870,7 +870,7 @@ static int adcx140_configure_gpio(struct adcx140_priv *adcx140) gpio_count =device_property_count_u32 (adcx140->dev,"ti,gpio-config" ); -if (gpio_count ==0 ) +if (gpio_count <=0 )return 0 ;if (gpio_count !=ADCX140_NUM_GPIO_CFGS )
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 244/567 dm: remove flush_scheduled_work() during local_exit()
In reply to Greg Kroah-HartmanFrom: Mike Snitzer <[email protected]>
[ Upstream commit 0b22ff5360f5c4e11050b89206370fdf7dc0a226 ]
Commit acfe0ad74d2e1 ("dm: allocate a special workqueue for deferred device removal") switched from using system workqueue to a single workqueue local to DM. But it didn't eliminate the call to flush_scheduled_work() that was introduced purely for the benefit of deferred device removal with commit 2c140a246dc ("dm: allow remove to be deferred").
Since DM core uses its own workqueue (and queue_work) there is no need to call flush_scheduled_work() from local_exit(). local_exit()'s destroy_workqueue(deferred_remove_workqueue) handles flushing work started with queue_work().
--- drivers/md/dm.c | 1 - 1 file changed, 1 deletion(-)
drivers/md/dm.c +0 -1
@@ -226,7 +226,6 @@ static int __init local_init(void)static void local_exit (void ) { -flush_scheduled_work ();destroy_workqueue (deferred_remove_workqueue);unregister_blkdev (_major, _name);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 245/567 NFSv4: keep state manager thread active if swap is enabled
In reply to Greg Kroah-HartmanFrom: NeilBrown <[email protected]>
[ Upstream commit 4dc73c679114a2f408567e2e44770ed934190db2 ]
If we are swapping over NFSv4, we may not be able to allocate memory to start the state-manager thread at the time when we need it. So keep it always running when swap is enabled, and just signal it to start.
This requires updating and testing the cl_swapper count on the root rpc_clnt after following all ->cl_parent links.
Stable-dep-of: b46d80bd2d6e ("nfs4trace: fix state manager flag printing")
--- fs/nfs/file.c | 15 ++++++++++++--- fs/nfs/nfs4_fs.h | 1 + fs/nfs/nfs4proc.c | 20 ++++++++++++++++++++ fs/nfs/nfs4state.c | 40 +++++++++++++++++++++++++++++++++------- include/linux/nfs_xdr.h | 2 ++ net/sunrpc/clnt.c | 2 ++ 6 files changed, 70 insertions(+), 10 deletions(-)
fs/nfs/file.c +12 -3
@@ -484,8 +484,9 @@ static int nfs_swap_activate(struct swap_info_struct *sis, struct file *file, {unsigned long blocks;long long isize; -struct rpc_clnt *clnt =NFS_CLIENT (file->f_mapping->host); -struct inode *inode = file->f_mapping->host; +struct inode *inode =file_inode (file); +struct rpc_clnt *clnt =NFS_CLIENT (inode); +struct nfs_client *cl =NFS_SERVER (inode)->nfs_client;spin_lock (&inode->i_lock); blocks = inode->i_blocks;
@@ -498,14 +499,22 @@ static int nfs_swap_activate(struct swap_info_struct *sis, struct file *file, *span = sis->pages; + +if (cl->rpc_ops->enable_swap) + cl->rpc_ops->enable_swap (inode); +return rpc_clnt_swap_activate (clnt); }static void nfs_swap_deactivate (struct file *file) { -struct rpc_clnt *clnt =NFS_CLIENT (file->f_mapping->host); +struct inode *inode =file_inode (file); +struct rpc_clnt *clnt =NFS_CLIENT (inode); +struct nfs_client *cl =NFS_SERVER (inode)->nfs_client;rpc_clnt_swap_deactivate (clnt); +if (cl->rpc_ops->disable_swap) + cl->rpc_ops->disable_swap (file_inode (file)); }const struct address_space_operations nfs_file_aops = {
fs/nfs/nfs4_fs.h +1 -0
@@ -42,6 +42,7 @@ enum nfs4_client_state {NFS4CLNT_LEASE_MOVED ,NFS4CLNT_DELEGATION_EXPIRED ,NFS4CLNT_RUN_MANAGER , +NFS4CLNT_MANAGER_AVAILABLE ,NFS4CLNT_RECALL_RUNNING ,NFS4CLNT_RECALL_ANY_LAYOUT_READ , NFS4CLNT_RECALL_ANY_LAYOUT_RW,
fs/nfs/nfs4proc.c +20 -0
@@ -10530,6 +10530,24 @@ static ssize_t nfs4_listxattr(struct dentry *dentry, char *list, size_t size)return error + error2 + error3; } +static void nfs4_enable_swap (struct inode *inode) +{ +/* The state manager thread must always be running. +* It will notice the client is a swapper, and stay put. +*/ +struct nfs_client *clp =NFS_SERVER (inode)->nfs_client; + +nfs4_schedule_state_manager (clp); +} + +static void nfs4_disable_swap (struct inode *inode) +{ +/* The state manager thread will now exit once it is +* woken. +*/ +wake_up_var (&NFS_SERVER (inode)->nfs_client->cl_state); +} +static const struct inode_operations nfs4_dir_inode_operations = { .create = nfs_create, .lookup = nfs_lookup,
@@ -10607,6 +10625,8 @@ const struct nfs_rpc_ops nfs_v4_clientops = { .create_server = nfs4_create_server, .clone_server = nfs_clone_server, .discover_trunking = nfs4_discover_trunking, + .enable_swap = nfs4_enable_swap, + .disable_swap = nfs4_disable_swap, };static const struct xattr_handler nfs4_xattr_nfs4_acl_handler = {
fs/nfs/nfs4state.c +33 -7
@@ -1209,10 +1209,17 @@ void nfs4_schedule_state_manager(struct nfs_client *clp) {struct task_struct *task;char buf[INET6_ADDRSTRLEN +sizeof ("-manager" ) +1 ]; +struct rpc_clnt *cl = clp->cl_rpcclient; + +while (cl != cl->cl_parent) + cl = cl->cl_parent;set_bit (NFS4CLNT_RUN_MANAGER , &clp->cl_state); -if (test_and_set_bit (NFS4CLNT_MANAGER_RUNNING , &clp->cl_state) !=0 ) +if (test_and_set_bit (NFS4CLNT_MANAGER_AVAILABLE , &clp->cl_state) !=0 ) { +wake_up_var (&clp->cl_state);return ; + } +set_bit (NFS4CLNT_MANAGER_RUNNING , &clp->cl_state);__module_get (THIS_MODULE );refcount_inc (&clp->cl_count);
@@ -1230,6 +1237,7 @@ void nfs4_schedule_state_manager(struct nfs_client *clp)if (!nfs_client_init_is_complete (clp))nfs_mark_client_ready (clp,PTR_ERR (task));nfs4_clear_state_manager_bit (clp); +clear_bit (NFS4CLNT_MANAGER_AVAILABLE , &clp->cl_state);nfs_put_client (clp);module_put (THIS_MODULE ); }
@@ -2689,12 +2697,8 @@ static void nfs4_state_manager(struct nfs_client *clp)clear_bit (NFS4CLNT_RECALL_RUNNING , &clp->cl_state); } -/* Did we race with an attempt to give us more work? */ -if (!test_bit (NFS4CLNT_RUN_MANAGER , &clp->cl_state)) -return ; -if (test_and_set_bit (NFS4CLNT_MANAGER_RUNNING , &clp->cl_state) !=0 ) -return ; - memflags =memalloc_nofs_save (); +return ; + }while (refcount_read (&clp->cl_count) >1 && !signalled ()); goto out_drain;
@@ -2715,9 +2719,31 @@ static void nfs4_state_manager(struct nfs_client *clp)static int nfs4_run_state_manager (void *ptr) {struct nfs_client *clp = ptr; +struct rpc_clnt *cl = clp->cl_rpcclient; + +while (cl != cl->cl_parent) + cl = cl->cl_parent;allow_signal (SIGKILL ); +again: +set_bit (NFS4CLNT_MANAGER_RUNNING , &clp->cl_state);nfs4_state_manager (clp); +if (atomic_read (&cl->cl_swapper)) { +wait_var_event_interruptible (&clp->cl_state, +test_bit (NFS4CLNT_RUN_MANAGER , + &clp->cl_state)); +if (atomic_read (&cl->cl_swapper) && +test_bit (NFS4CLNT_RUN_MANAGER , &clp->cl_state)) + goto again; +/* Either no longer a swapper, or were signalled */ + } +clear_bit (NFS4CLNT_MANAGER_AVAILABLE , &clp->cl_state); + +if (refcount_read (&clp->cl_count) >1 && !signalled () && +test_bit (NFS4CLNT_RUN_MANAGER , &clp->cl_state) && + !test_and_set_bit (NFS4CLNT_MANAGER_AVAILABLE , &clp->cl_state)) + goto again; +nfs_put_client (clp);module_put_and_exit (0 );return 0 ;
include/linux/nfs_xdr.h +2 -0
@@ -1806,6 +1806,8 @@ struct nfs_rpc_ops {struct nfs_server *(*clone_server)(struct nfs_server *,struct nfs_fh *,struct nfs_fattr *,rpc_authflavor_t );int (*discover_trunking)(struct nfs_server *,struct nfs_fh *); +void (*enable_swap)(struct inode *inode); +void (*disable_swap)(struct inode *inode); };/*
net/sunrpc/clnt.c +2 -0
@@ -3117,6 +3117,8 @@ rpc_clnt_swap_activate_callback(struct rpc_clnt *clnt,int rpc_clnt_swap_activate (struct rpc_clnt *clnt) { +while (clnt != clnt->cl_parent) + clnt = clnt->cl_parent;if (atomic_inc_return (&clnt->cl_swapper) ==1 )return rpc_clnt_iterate_for_each_xprt (clnt, rpc_clnt_swap_activate_callback,NULL );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 246/567 nfs4trace: fix state manager flag printing
In reply to Greg Kroah-HartmanFrom: Benjamin Coddington <[email protected]>
[ Upstream commit b46d80bd2d6e7e063c625a20de54248afe8d4889 ]
__print_flags wants a mask, not the enum value. Add two more flags.
--- fs/nfs/nfs4trace.h | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-)
fs/nfs/nfs4trace.h +22 -20
@@ -584,32 +584,34 @@ TRACE_DEFINE_ENUM(NFS4CLNT_MOVED);TRACE_DEFINE_ENUM (NFS4CLNT_LEASE_MOVED );TRACE_DEFINE_ENUM (NFS4CLNT_DELEGATION_EXPIRED );TRACE_DEFINE_ENUM (NFS4CLNT_RUN_MANAGER ); +TRACE_DEFINE_ENUM (NFS4CLNT_MANAGER_AVAILABLE );TRACE_DEFINE_ENUM (NFS4CLNT_RECALL_RUNNING );TRACE_DEFINE_ENUM (NFS4CLNT_RECALL_ANY_LAYOUT_READ );TRACE_DEFINE_ENUM (NFS4CLNT_RECALL_ANY_LAYOUT_RW ); +TRACE_DEFINE_ENUM (NFS4CLNT_DELEGRETURN_DELAYED );#define show_nfs4_clp_state (state) \ __print_flags(state, "|", \ - { NFS4CLNT_MANAGER_RUNNING, "MANAGER_RUNNING" }, \ - { NFS4CLNT_CHECK_LEASE, "CHECK_LEASE" }, \ - { NFS4CLNT_LEASE_EXPIRED, "LEASE_EXPIRED" }, \ - { NFS4CLNT_RECLAIM_REBOOT, "RECLAIM_REBOOT" }, \ - { NFS4CLNT_RECLAIM_NOGRACE, "RECLAIM_NOGRACE" }, \ - { NFS4CLNT_DELEGRETURN, "DELEGRETURN" }, \ - { NFS4CLNT_SESSION_RESET, "SESSION_RESET" }, \ - { NFS4CLNT_LEASE_CONFIRM, "LEASE_CONFIRM" }, \ - { NFS4CLNT_SERVER_SCOPE_MISMATCH, \ - "SERVER_SCOPE_MISMATCH" }, \ - { NFS4CLNT_PURGE_STATE, "PURGE_STATE" }, \ - { NFS4CLNT_BIND_CONN_TO_SESSION, \ - "BIND_CONN_TO_SESSION" }, \ - { NFS4CLNT_MOVED, "MOVED" }, \ - { NFS4CLNT_LEASE_MOVED, "LEASE_MOVED" }, \ - { NFS4CLNT_DELEGATION_EXPIRED, "DELEGATION_EXPIRED" }, \ - { NFS4CLNT_RUN_MANAGER, "RUN_MANAGER" }, \ - { NFS4CLNT_RECALL_RUNNING, "RECALL_RUNNING" }, \ - { NFS4CLNT_RECALL_ANY_LAYOUT_READ, "RECALL_ANY_LAYOUT_READ" }, \ - { NFS4CLNT_RECALL_ANY_LAYOUT_RW, "RECALL_ANY_LAYOUT_RW" }) + { BIT(NFS4CLNT_MANAGER_RUNNING), "MANAGER_RUNNING" }, \ + { BIT(NFS4CLNT_CHECK_LEASE), "CHECK_LEASE" }, \ + { BIT(NFS4CLNT_LEASE_EXPIRED), "LEASE_EXPIRED" }, \ + { BIT(NFS4CLNT_RECLAIM_REBOOT), "RECLAIM_REBOOT" }, \ + { BIT(NFS4CLNT_RECLAIM_NOGRACE), "RECLAIM_NOGRACE" }, \ + { BIT(NFS4CLNT_DELEGRETURN), "DELEGRETURN" }, \ + { BIT(NFS4CLNT_SESSION_RESET), "SESSION_RESET" }, \ + { BIT(NFS4CLNT_LEASE_CONFIRM), "LEASE_CONFIRM" }, \ + { BIT(NFS4CLNT_SERVER_SCOPE_MISMATCH), "SERVER_SCOPE_MISMATCH" }, \ + { BIT(NFS4CLNT_PURGE_STATE), "PURGE_STATE" }, \ + { BIT(NFS4CLNT_BIND_CONN_TO_SESSION), "BIND_CONN_TO_SESSION" }, \ + { BIT(NFS4CLNT_MOVED), "MOVED" }, \ + { BIT(NFS4CLNT_LEASE_MOVED), "LEASE_MOVED" }, \ + { BIT(NFS4CLNT_DELEGATION_EXPIRED), "DELEGATION_EXPIRED" }, \ + { BIT(NFS4CLNT_RUN_MANAGER), "RUN_MANAGER" }, \ + { BIT(NFS4CLNT_MANAGER_AVAILABLE), "MANAGER_AVAILABLE" }, \ + { BIT(NFS4CLNT_RECALL_RUNNING), "RECALL_RUNNING" }, \ + { BIT(NFS4CLNT_RECALL_ANY_LAYOUT_READ), "RECALL_ANY_LAYOUT_READ" }, \ + { BIT(NFS4CLNT_RECALL_ANY_LAYOUT_RW), "RECALL_ANY_LAYOUT_RW" }, \ + { BIT(NFS4CLNT_DELEGRETURN_DELAYED), "DELERETURN_DELAYED" }) TRACE_EVENT(nfs4_state_mgr, TP_PROTO(
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 247/567 NFS: fix disabling of swap
In reply to Greg Kroah-HartmanFrom: NeilBrown <[email protected]>
[ Upstream commit 5bab56fff53ce161ed859d9559a10361d4f79578 ]
When swap is activated to a file on an NFSv4 mount we arrange that the state manager thread is always present as starting a new thread requires memory allocations that might block waiting for swap.
Unfortunately the code for allowing the state manager thread to exit when swap is disabled was not tested properly and does not work. This can be seen by examining /proc/fs/nfsfs/servers after disabling swap and unmounting the filesystem. The servers file will still list one entry. Also a "ps" listing will show the state manager thread is still present.
There are two problems.
1/ rpc_clnt_swap_deactivate() doesn't walk up the ->cl_parent list to
find the primary client on which the state manager runs.
2/ The thread is not woken up properly and it immediately goes back to
sleep without checking whether it is really needed. Using nfs4_schedule_state_manager() ensures a proper wake-up.
--- fs/nfs/nfs4proc.c | 4 +++- net/sunrpc/clnt.c | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-)
fs/nfs/nfs4proc.c +3 -1
@@ -10545,7 +10545,9 @@ static void nfs4_disable_swap(struct inode *inode)/* The state manager thread will now exit once it is * woken. */ -wake_up_var (&NFS_SERVER (inode)->nfs_client->cl_state); +struct nfs_client *clp =NFS_SERVER (inode)->nfs_client; + +nfs4_schedule_state_manager (clp); }static const struct inode_operations nfs4_dir_inode_operations = {
net/sunrpc/clnt.c +2 -0
@@ -3138,6 +3138,8 @@ rpc_clnt_swap_deactivate_callback(struct rpc_clnt *clnt,void rpc_clnt_swap_deactivate (struct rpc_clnt *clnt) { +while (clnt != clnt->cl_parent) + clnt = clnt->cl_parent;if (atomic_dec_if_positive (&clnt->cl_swapper) ==0 )rpc_clnt_iterate_for_each_xprt (clnt, rpc_clnt_swap_deactivate_callback,NULL );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 248/567 spi: synquacer: Fix timeout handling in synquacer_spi_transfer_one()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit e6a0b671880207566e1ece983bf989dde60bc1d7 ]
wait_for_completion_timeout() never returns a <0 value. It returns either on timeout or a positive value (at least 1, or number of jiffies left till timeout)
So, fix the error handling path and return -ETIMEDOUT should a timeout occur.
--- drivers/spi/spi-synquacer.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/spi/spi-synquacer.c +3 -4
@@ -472,10 +472,9 @@ static int synquacer_spi_transfer_one(struct spi_master *master,read_fifo (sspi); } -if (status <0 ) { -dev_err (sspi->dev,"failed to transfer. status: 0x%x\n" , - status); -return status; +if (status ==0 ) { +dev_err (sspi->dev,"failed to transfer. Timeout.\n" ); +return -ETIMEDOUT ; }return 0 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 249/567 ASoC: soc-dapm.h: fixup warning struct snd_pcm_substream not declared
In reply to Greg Kroah-HartmanFrom: Lucas Tanure <[email protected]>
[ Upstream commit fdff966bfde7cf0c85562d2bfb1ff1ba83da5f7b ]
Add struct snd_pcm_substream forward declaration
--- include/sound/soc-dapm.h | 1 + 1 file changed, 1 insertion(+)
include/sound/soc-dapm.h +1 -0
@@ -16,6 +16,7 @@#include <sound/asoc.h> struct device ; +struct snd_pcm_substream ;struct snd_soc_pcm_runtime ;struct soc_enum ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 250/567 HID: bigben: use spinlock to protect concurrent accesses
In reply to Greg Kroah-HartmanFrom: Pietro Borrello <[email protected]>
[ Upstream commit 9fefb6201c4f8dd9f58c581b2a66e5cde2895ea2 ]
bigben driver has a worker that may access data concurrently. Proct the accesses using a spinlock.
--- drivers/hid/hid-bigbenff.c | 52 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-)
drivers/hid/hid-bigbenff.c +50 -2
@@ -174,6 +174,7 @@ static __u8 pid0902_rdesc_fixed[] = {struct bigben_device {struct hid_device *hid;struct hid_report *report; +spinlock_t lock;bool removed;u8 led_state;/* LED1 = 1 .. LED4 = 8 */ u8 right_motor_on;/* right motor off/on 0/1 */
@@ -190,12 +191,27 @@ static void bigben_worker(struct work_struct *work)struct bigben_device *bigben =container_of (work, struct bigben_device, worker);struct hid_field *report_field = bigben->report->field[0 ]; +bool do_work_led = false; +bool do_work_ff = false; +u8 *buf; +u32 len; +unsigned long flags;if (bigben->removed || !report_field)return ; + buf =hid_alloc_report_buf (bigben->report,GFP_KERNEL ); +if (!buf) +return ; + + len =hid_report_len (bigben->report); + +/* LED work */ +spin_lock_irqsave (&bigben->lock, flags); +if (bigben->work_led) { bigben->work_led = false; + do_work_led = true; report_field->value[0 ] =0x01 ;/* 1 = led message */ report_field->value[1 ] =0x08 ;/* reserved value, always 8 */ report_field->value[2 ] = bigben->led_state;
@@ -204,11 +220,22 @@ static void bigben_worker(struct work_struct *work) report_field->value[5 ] =0x00 ;/* padding */ report_field->value[6 ] =0x00 ;/* padding */ report_field->value[7 ] =0x00 ;/* padding */ -hid_hw_request (bigben->hid, bigben->report,HID_REQ_SET_REPORT ); +hid_output_report (bigben->report, buf); + } + +spin_unlock_irqrestore (&bigben->lock, flags); + +if (do_work_led) { +hid_hw_raw_request (bigben->hid, bigben->report->id, buf, len, + bigben->report->type,HID_REQ_SET_REPORT ); } +/* FF work */ +spin_lock_irqsave (&bigben->lock, flags); +if (bigben->work_ff) { bigben->work_ff = false; + do_work_ff = true; report_field->value[0 ] =0x02 ;/* 2 = rumble effect message */ report_field->value[1 ] =0x08 ;/* reserved value, always 8 */ report_field->value[2 ] = bigben->right_motor_on;
@@ -217,8 +244,17 @@ static void bigben_worker(struct work_struct *work) report_field->value[5 ] =0x00 ;/* padding */ report_field->value[6 ] =0x00 ;/* padding */ report_field->value[7 ] =0x00 ;/* padding */ -hid_hw_request (bigben->hid, bigben->report,HID_REQ_SET_REPORT ); +hid_output_report (bigben->report, buf); + } + +spin_unlock_irqrestore (&bigben->lock, flags); + +if (do_work_ff) { +hid_hw_raw_request (bigben->hid, bigben->report->id, buf, len, + bigben->report->type,HID_REQ_SET_REPORT ); } + +kfree (buf); } static int hid_bigben_play_effect(struct input_dev *dev, void *data,
@@ -228,6 +264,7 @@ static int hid_bigben_play_effect(struct input_dev *dev, void *data,struct bigben_device *bigben =hid_get_drvdata (hid);u8 right_motor_on;u8 left_motor_force; +unsigned long flags;if (!bigben) {hid_err (hid,"no device data\n" );
@@ -242,9 +279,12 @@ static int hid_bigben_play_effect(struct input_dev *dev, void *data,if (right_motor_on != bigben->right_motor_on || left_motor_force != bigben->left_motor_force) { +spin_lock_irqsave (&bigben->lock, flags); bigben->right_motor_on = right_motor_on; bigben->left_motor_force = left_motor_force; bigben->work_ff = true; +spin_unlock_irqrestore (&bigben->lock, flags); +schedule_work (&bigben->worker); }
@@ -259,6 +299,7 @@ static void bigben_set_led(struct led_classdev *led,struct bigben_device *bigben =hid_get_drvdata (hid);int n;bool work; +unsigned long flags;if (!bigben) {hid_err (hid,"no device data\n" );
@@ -267,6 +308,7 @@ static void bigben_set_led(struct led_classdev *led,for (n =0 ; n <NUM_LEDS ; n++) {if (led == bigben->leds[n]) { +spin_lock_irqsave (&bigben->lock, flags);if (value ==LED_OFF ) { work = (bigben->led_state &BIT (n)); bigben->led_state &= ~BIT (n);
@@ -274,6 +316,7 @@ static void bigben_set_led(struct led_classdev *led, work = !(bigben->led_state &BIT (n)); bigben->led_state |=BIT (n); } +spin_unlock_irqrestore (&bigben->lock, flags);if (work) { bigben->work_led = true;
@@ -307,8 +350,12 @@ static enum led_brightness bigben_get_led(struct led_classdev *led)static void bigben_remove (struct hid_device *hid) {struct bigben_device *bigben =hid_get_drvdata (hid); +unsigned long flags; +spin_lock_irqsave (&bigben->lock, flags); bigben->removed = true; +spin_unlock_irqrestore (&bigben->lock, flags); +cancel_work_sync (&bigben->worker);hid_hw_stop (hid); }
@@ -362,6 +409,7 @@ static int bigben_probe(struct hid_device *hid,set_bit (FF_RUMBLE , hidinput->input->ffbit);INIT_WORK (&bigben->worker, bigben_worker); +spin_lock_init (&bigben->lock); error =input_ff_create_memless (hidinput->input,NULL , hid_bigben_play_effect);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 251/567 HID: bigben_worker() remove unneeded check on report_field
In reply to Greg Kroah-HartmanFrom: Pietro Borrello <[email protected]>
[ Upstream commit 27d2a2fd844ec7da70d19fabb482304fd1e0595b ]
bigben_worker() checks report_field to be non-NULL. The check has been added in commit918aa1ef104d ("HID: bigbenff: prevent null pointer dereference") to prevent a NULL pointer crash.
However, the true root cause was a missing check for output reports, patched in commitc7bf714f8755 ("HID: check empty report_list in bigben_probe()"), where the type-confused report list_entry was overlapping with a NULL pointer, which was then causing the crash.
--- drivers/hid/hid-bigbenff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/hid-bigbenff.c +1 -1
@@ -197,7 +197,7 @@ static void bigben_worker(struct work_struct *work)u32 len;unsigned long flags; -if (bigben->removed || !report_field) +if (bigben->removed)return ; buf =hid_alloc_report_buf (bigben->report,GFP_KERNEL );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 252/567 HID: bigben: use spinlock to safely schedule workers
In reply to Greg Kroah-HartmanFrom: Pietro Borrello <[email protected]>
[ Upstream commit 76ca8da989c7d97a7f76c75d475fe95a584439d7 ]
Use spinlocks to deal with workers introducing a wrapper bigben_schedule_work(), and several spinlock checks. Otherwise, bigben_set_led() may schedule bigben->worker after the structure has been freed, causing a use-after-free.
--- drivers/hid/hid-bigbenff.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/hid/hid-bigbenff.c +12 -6
@@ -185,6 +185,15 @@ struct bigben_device {struct work_struct worker; }; +static inline void bigben_schedule_work (struct bigben_device *bigben) +{ +unsigned long flags; + +spin_lock_irqsave (&bigben->lock, flags); +if (!bigben->removed) +schedule_work (&bigben->worker); +spin_unlock_irqrestore (&bigben->lock, flags); +}static void bigben_worker (struct work_struct *work) {
@@ -197,9 +206,6 @@ static void bigben_worker(struct work_struct *work)u32 len;unsigned long flags; -if (bigben->removed) -return ; - buf =hid_alloc_report_buf (bigben->report,GFP_KERNEL );if (!buf)return ;
@@ -285,7 +291,7 @@ static int hid_bigben_play_effect(struct input_dev *dev, void *data, bigben->work_ff = true;spin_unlock_irqrestore (&bigben->lock, flags); -schedule_work (&bigben->worker); +bigben_schedule_work (bigben); }return 0 ;
@@ -320,7 +326,7 @@ static void bigben_set_led(struct led_classdev *led,if (work) { bigben->work_led = true; -schedule_work (&bigben->worker); +bigben_schedule_work (bigben); }return ; }
@@ -450,7 +456,7 @@ static int bigben_probe(struct hid_device *hid, bigben->left_motor_force =0 ; bigben->work_led = true; bigben->work_ff = true; -schedule_work (&bigben->worker); +bigben_schedule_work (bigben);hid_info (hid,"LED and force feedback support for BigBen gamepad\n" );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 253/567 hid: bigben_probe(): validate report count
In reply to Greg Kroah-HartmanFrom: Pietro Borrello <[email protected]>
[ Upstream commit b94335f899542a0da5fafc38af8edcaf90195843 ]
bigben_probe() does not validate that the output report has the needed report values in the first field.
A malicious device registering a report with one field and a single value causes an head OOB write in bigben_worker() when accessing report_field->value[1] to report_field->value[7]. Use hid_validate_values() which takes care of all the needed checks.
--- drivers/hid/hid-bigbenff.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/hid/hid-bigbenff.c +2 -5
@@ -371,7 +371,6 @@ static int bigben_probe(struct hid_device *hid, {struct bigben_device *bigben;struct hid_input *hidinput; -struct list_head *report_list;struct led_classdev *led;char *name;size_t name_sz;
@@ -396,14 +395,12 @@ static int bigben_probe(struct hid_device *hid,return error; } - report_list = &hid->report_enum[HID_OUTPUT_REPORT ].report_list; -if (list_empty (report_list)) { + bigben->report =hid_validate_values (hid,HID_OUTPUT_REPORT ,0 ,0 ,8 ); +if (!bigben->report) {hid_err (hid,"no output report found\n" ); error = -ENODEV ; goto error_hw_stop; } - bigben->report =list_entry (report_list->next, - struct hid_report, list);if (list_empty (&hid->inputs)) {hid_err (hid,"no inputs found\n" );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 254/567 drm/shmem-helper: Fix locking for drm_gem_shmem_get_pages_sgt()
In reply to Greg Kroah-HartmanFrom: Asahi Lina <[email protected]>
[ Upstream commit ddddedaa0db99481c5e5abe628ad54f65e8765bc ]
Other functions touching shmem->sgt take the pages lock, so do that here too. drm_gem_shmem_get_pages() & co take the same lock, so move to the _locked() variants to avoid recursive locking.
Discovered while auditing locking to write the Rust abstractions.
--- drivers/gpu/drm/drm_gem_shmem_helper.c | 54 ++++++++++++++++---------- 1 file changed, 34 insertions(+), 20 deletions(-)
drivers/gpu/drm/drm_gem_shmem_helper.c +34 -20
@@ -651,23 +651,7 @@ struct sg_table *drm_gem_shmem_get_sg_table(struct drm_gem_shmem_object *shmem) }EXPORT_SYMBOL_GPL (drm_gem_shmem_get_sg_table); -/** -* drm_gem_shmem_get_pages_sgt - Pin pages, dma map them, and return a -* scatter/gather table for a shmem GEM object. -* @shmem: shmem GEM object -* -* This function returns a scatter/gather table suitable for driver usage. If -* the sg table doesn't exist, the pages are pinned, dma-mapped, and a sg -* table created. -* -* This is the main function for drivers to get at backing storage, and it hides -* and difference between dma-buf imported and natively allocated objects. -* drm_gem_shmem_get_sg_table() should not be directly called by drivers. -* -* Returns: -* A pointer to the scatter/gather table of pinned pages or errno on failure. -*/ -struct sg_table *drm_gem_shmem_get_pages_sgt (struct drm_gem_shmem_object *shmem) +static struct sg_table *drm_gem_shmem_get_pages_sgt_locked (struct drm_gem_shmem_object *shmem) {struct drm_gem_object *obj = &shmem->base;int ret;
@@ -678,7 +662,7 @@ struct sg_table *drm_gem_shmem_get_pages_sgt(struct drm_gem_shmem_object *shmem)WARN_ON (obj->import_attach); - ret =drm_gem_shmem_get_pages (shmem); + ret =drm_gem_shmem_get_pages_locked (shmem);if (ret)return ERR_PTR (ret);
@@ -700,10 +684,40 @@ struct sg_table *drm_gem_shmem_get_pages_sgt(struct drm_gem_shmem_object *shmem)sg_free_table (sgt);kfree (sgt); err_put_pages: -drm_gem_shmem_put_pages (shmem); +drm_gem_shmem_put_pages_locked (shmem);return ERR_PTR (ret); } -EXPORT_SYMBOL_GPL (drm_gem_shmem_get_pages_sgt); + +/** +* drm_gem_shmem_get_pages_sgt - Pin pages, dma map them, and return a +* scatter/gather table for a shmem GEM object. +* @shmem: shmem GEM object +* +* This function returns a scatter/gather table suitable for driver usage. If +* the sg table doesn't exist, the pages are pinned, dma-mapped, and a sg +* table created. +* +* This is the main function for drivers to get at backing storage, and it hides +* and difference between dma-buf imported and natively allocated objects. +* drm_gem_shmem_get_sg_table() should not be directly called by drivers. +* +* Returns: +* A pointer to the scatter/gather table of pinned pages or errno on failure. +*/ +struct sg_table *drm_gem_shmem_get_pages_sgt (struct drm_gem_shmem_object *shmem) +{ +int ret; +struct sg_table *sgt; + + ret =mutex_lock_interruptible (&shmem->pages_lock); +if (ret) +return ERR_PTR (ret); + sgt =drm_gem_shmem_get_pages_sgt_locked (shmem); +mutex_unlock (&shmem->pages_lock); + +return sgt; +} +EXPORT_SYMBOL (drm_gem_shmem_get_pages_sgt);/** * drm_gem_shmem_prime_import_sg_table - Produce a shmem GEM object from
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 255/567 nfsd: fix race to check ls_layouts
In reply to Greg Kroah-HartmanFrom: Benjamin Coddington <[email protected]>
[ Upstream commit fb610c4dbc996415d57d7090957ecddd4fd64fb6 ]
Its possible for __break_lease to find the layout's lease before we've added the layout to the owner's ls_layouts list. In that case, setting ls_recalled = true without actually recalling the layout will cause the server to never send a recall callback.
Move the check for ls_layouts before setting ls_recalled.
--- fs/nfsd/nfs4layouts.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfsd/nfs4layouts.c +2 -2
@@ -322,11 +322,11 @@ nfsd4_recall_file_layout(struct nfs4_layout_stateid *ls)if (ls->ls_recalled) goto out_unlock; - ls->ls_recalled = true; -atomic_inc (&ls->ls_stid.sc_file->fi_lo_recalls);if (list_empty (&ls->ls_layouts)) goto out_unlock; + ls->ls_recalled = true; +atomic_inc (&ls->ls_stid.sc_file->fi_lo_recalls);trace_nfsd_layout_recall (&ls->ls_stid.sc_stateid);refcount_inc (&ls->ls_stid.sc_count);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 256/567 cifs: Fix lost destroy smbd connection when MR allocate failed
In reply to Greg Kroah-HartmanFrom: Zhang Xiaoxu <[email protected]>
[ Upstream commit e9d3401d95d62a9531082cd2453ed42f2740e3fd ]
If the MR allocate failed, the smb direct connection info is NULL, then smbd_destroy() will directly return, then the connection info will be leaked.
Let's set the smb direct connection info to the server before call smbd_destroy().
--- fs/cifs/smbdirect.c | 1 + 1 file changed, 1 insertion(+)
fs/cifs/smbdirect.c +1 -0
@@ -1702,6 +1702,7 @@ static struct smbd_connection *_smbd_get_connection( allocate_mr_failed:/* At this point, need to a full transport shutdown */ + server->smbd_conn = info;smbd_destroy (server);return NULL ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 257/567 cifs: Fix warning and UAF when destroy the MR list
In reply to Greg Kroah-HartmanFrom: Zhang Xiaoxu <[email protected]>
[ Upstream commit 3e161c2791f8e661eed24a2c624087084d910215 ]
If the MR allocate failed, the MR recovery work not initialized and list not cleared. Then will be warning and UAF when release the MR:
WARNING: CPU: 4 PID: 824 at kernel/workqueue.c:3066 __flush_work.isra.0+0xf7/0x110 CPU: 4 PID: 824 Comm: mount.cifs Not tainted 6.1.0-rc5+ #82 RIP: 0010:__flush_work.isra.0+0xf7/0x110 Call Trace: <TASK> __cancel_work_timer+0x2ba/0x2e0 smbd_destroy+0x4e1/0x990 _smbd_get_connection+0x1cbd/0x2110 smbd_get_connection+0x21/0x40 cifs_get_tcp_session+0x8ef/0xda0 mount_get_conns+0x60/0x750 cifs_mount+0x103/0xd00 cifs_smb3_do_mount+0x1dd/0xcb0 smb3_get_tree+0x1d5/0x300 vfs_get_tree+0x41/0xf0 path_mount+0x9b3/0xdd0 __x64_sys_mount+0x190/0x1d0 do_syscall_64+0x35/0x80 entry_SYSCALL_64_after_hwframe+0x46/0xb0 BUG: KASAN: use-after-free in smbd_destroy+0x4fc/0x990 Read of size 8 at addr ffff88810b156a08 by task mount.cifs/824 CPU: 4 PID: 824 Comm: mount.cifs Tainted: G W 6.1.0-rc5+ #82 Call Trace: dump_stack_lvl+0x34/0x44 print_report+0x171/0x472 kasan_report+0xad/0x130 smbd_destroy+0x4fc/0x990 _smbd_get_connection+0x1cbd/0x2110 smbd_get_connection+0x21/0x40 cifs_get_tcp_session+0x8ef/0xda0 mount_get_conns+0x60/0x750 cifs_mount+0x103/0xd00 cifs_smb3_do_mount+0x1dd/0xcb0 smb3_get_tree+0x1d5/0x300 vfs_get_tree+0x41/0xf0 path_mount+0x9b3/0xdd0 __x64_sys_mount+0x190/0x1d0 do_syscall_64+0x35/0x80 entry_SYSCALL_64_after_hwframe+0x46/0xb0 Allocated by task 824: kasan_save_stack+0x1e/0x40 kasan_set_track+0x21/0x30 __kasan_kmalloc+0x7a/0x90 _smbd_get_connection+0x1b6f/0x2110 smbd_get_connection+0x21/0x40 cifs_get_tcp_session+0x8ef/0xda0 mount_get_conns+0x60/0x750 cifs_mount+0x103/0xd00 cifs_smb3_do_mount+0x1dd/0xcb0 smb3_get_tree+0x1d5/0x300 vfs_get_tree+0x41/0xf0 path_mount+0x9b3/0xdd0 __x64_sys_mount+0x190/0x1d0 do_syscall_64+0x35/0x80 entry_SYSCALL_64_after_hwframe+0x46/0xb0 Freed by task 824: kasan_save_stack+0x1e/0x40 kasan_set_track+0x21/0x30 kasan_save_free_info+0x2a/0x40 ____kasan_slab_free+0x143/0x1b0 __kmem_cache_free+0xc8/0x330 _smbd_get_connection+0x1c6a/0x2110 smbd_get_connection+0x21/0x40 cifs_get_tcp_session+0x8ef/0xda0 mount_get_conns+0x60/0x750 cifs_mount+0x103/0xd00 cifs_smb3_do_mount+0x1dd/0xcb0 smb3_get_tree+0x1d5/0x300 vfs_get_tree+0x41/0xf0 path_mount+0x9b3/0xdd0 __x64_sys_mount+0x190/0x1d0 do_syscall_64+0x35/0x80 entry_SYSCALL_64_after_hwframe+0x46/0xb0
Let's initialize the MR recovery work before MR allocate to prevent the warning, remove the MRs from the list to prevent the UAF.
--- fs/cifs/smbdirect.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/cifs/smbdirect.c +2 -1
@@ -2251,6 +2251,7 @@ static int allocate_mr_list(struct smbd_connection *info)atomic_set (&info->mr_ready_count,0 );atomic_set (&info->mr_used_count,0 );init_waitqueue_head (&info->wait_for_mr_cleanup); +INIT_WORK (&info->mr_recovery_work, smbd_mr_recovery_work);/* Allocate more MRs (2x) than hardware responder_resources */ for (i =0 ; i < info->responder_resources *2 ; i++) { smbdirect_mr =kzalloc (sizeof (*smbdirect_mr),GFP_KERNEL );
@@ -2278,13 +2279,13 @@ static int allocate_mr_list(struct smbd_connection *info)list_add_tail (&smbdirect_mr->list, &info->mr_list);atomic_inc (&info->mr_ready_count); } -INIT_WORK (&info->mr_recovery_work, smbd_mr_recovery_work);return 0 ; out:kfree (smbdirect_mr);list_for_each_entry_safe (smbdirect_mr, tmp, &info->mr_list, list) { +list_del (&smbdirect_mr->list);ib_dereg_mr (smbdirect_mr->mr);kfree (smbdirect_mr->sgl);kfree (smbdirect_mr);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 258/567 gfs2: jdata writepage fix
In reply to Greg Kroah-HartmanFrom: Andreas Gruenbacher <[email protected]>
[ Upstream commit cbb60951ce18c9b6e91d2eb97deb41d8ff616622 ]
The ->writepage() and ->writepages() operations are supposed to write entire pages. However, on filesystems with a block size smaller than PAGE_SIZE, __gfs2_jdata_writepage() only adds the first block to the current transaction instead of adding the entire page. Fix that.
--- fs/gfs2/aops.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/gfs2/aops.c +1 -2
@@ -152,7 +152,6 @@ static int __gfs2_jdata_writepage(struct page *page, struct writeback_control *w {struct inode *inode = page->mapping->host;struct gfs2_inode *ip =GFS2_I (inode); -struct gfs2_sbd *sdp =GFS2_SB (inode);if (PageChecked (page)) {ClearPageChecked (page);
@@ -160,7 +159,7 @@ static int __gfs2_jdata_writepage(struct page *page, struct writeback_control *wcreate_empty_buffers (page, inode->i_sb->s_blocksize,BIT (BH_Dirty)|BIT (BH_Uptodate)); } -gfs2_page_add_databufs (ip, page,0 , sdp->sd_vfs->s_blocksize); +gfs2_page_add_databufs (ip, page,0 ,PAGE_SIZE ); }return gfs2_write_jdata_page (page, wbc); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 259/567 perf llvm: Fix inadvertent file creation
In reply to Greg Kroah-HartmanFrom: Ian Rogers <[email protected]>
[ Upstream commit 9f19aab47ced012eddef1e2bc96007efc7713b61 ]
The LLVM template is first echo-ed into command_out and then command_out executed. The echo surrounds the template with double quotes, however, the template itself may contain quotes. This is generally innocuous but in tools/perf/tests/bpf-script-test-prologue.c we see:
...SEC("func=null_lseek file->f_mode offset orig")
...
where the first double quote ends the double quote of the echo, then the > redirects output into a file called f_mode.
To avoid this inadvertent behavior substitute redirects and similar characters to be ASCII control codes, then substitute the output in the echo back again.
--- tools/perf/util/llvm-utils.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)
tools/perf/util/llvm-utils.c +24 -1
@@ -531,14 +531,37 @@ int llvm__compile_bpf(const char *path, void **p_obj_buf,pr_debug ("llvm compiling command template: %s\n" , template); +/* +* Below, substitute control characters for values that can cause the +* echo to misbehave, then substitute the values back. +*/ err = -ENOMEM ; -if (asprintf (&command_echo,"echo -n \"%s\"" , template) <0 ) +if (asprintf (&command_echo,"echo -n \a%s\a" , template) <0 ) goto errout; +#define SWAP_CHAR (a, b) do { if (*p == a) *p = b; } while (0) +for (char *p = command_echo; *p; p++) { +SWAP_CHAR ('<' ,'\001' ); +SWAP_CHAR ('>' ,'\002' ); +SWAP_CHAR ('"' ,'\003' ); +SWAP_CHAR ('\'' ,'\004' ); +SWAP_CHAR ('|' ,'\005' ); +SWAP_CHAR ('&' ,'\006' ); +SWAP_CHAR ('\a' ,'"' ); + } err =read_from_pipe (command_echo, (void **) &command_out,NULL );if (err) goto errout; +for (char *p = command_out; *p; p++) { +SWAP_CHAR ('\001' ,'<' ); +SWAP_CHAR ('\002' ,'>' ); +SWAP_CHAR ('\003' ,'"' ); +SWAP_CHAR ('\004' ,'\'' ); +SWAP_CHAR ('\005' ,'|' ); +SWAP_CHAR ('\006' ,'&' ); + } +#undef SWAP_CHARpr_debug ("llvm compiling command : %s\n" , command_out); err =read_from_pipe (template, &obj_buf, &obj_buf_sz);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 260/567 leds: led-core: Fix refcount leak in of_led_get()
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit da1afe8e6099980fe1e2fd7436dca284af9d3f29 ]
class_find_device_by_of_node() calls class_find_device(), it will take the reference, use the put_device() to drop the reference when not need anymore.
--- drivers/leds/led-class.c | 1 + 1 file changed, 1 insertion(+)
drivers/leds/led-class.c +1 -0
@@ -235,6 +235,7 @@ struct led_classdev *of_led_get(struct device_node *np, int index) led_dev =class_find_device_by_of_node (leds_class, led_node);of_node_put (led_node); +put_device (led_dev);if (!led_dev)return ERR_PTR (-EPROBE_DEFER );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 261/567 perf inject: Use perf_data__read() for auxtrace
In reply to Greg Kroah-HartmanFrom: Namhyung Kim <[email protected]>
[ Upstream commit 1746212daeba95e9ae1639227dc0c3591d41deeb ]
In copy_bytes(), it reads the data from the (input) fd and writes it to the output file. But it does with the read(2) unconditionally which caused a problem of mixing buffered vs unbuffered I/O together.
You can see the problem when using pipes.
$ perf record -e intel_pt// -o- true | perf inject -b > /dev/null [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.000 MB - ] 0x45c0 [0x30]: failed to process type: 71
It should use perf_data__read() to honor the 'use_stdio' setting.
--- tools/perf/builtin-inject.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/perf/builtin-inject.c +3 -3
@@ -142,14 +142,14 @@ static int perf_event__repipe_event_update(struct perf_tool *tool,#ifdef HAVE_AUXTRACE_SUPPORT -static int copy_bytes (struct perf_inject *inject,int fd,off_t size) +static int copy_bytes (struct perf_inject *inject,struct perf_data *data,off_t size) {char buf[4096 ];ssize_t ssz;int ret;while (size >0 ) { - ssz =read (fd, buf,min (size, (off_t )sizeof (buf))); + ssz =perf_data__read (data, buf,min (size, (off_t )sizeof (buf)));if (ssz <0 )return -errno; ret =output_bytes (inject, buf, ssz);
@@ -187,7 +187,7 @@ static s64 perf_event__repipe_auxtrace(struct perf_session *session, ret =output_bytes (inject, event, event->header.size);if (ret <0 )return ret; - ret =copy_bytes (inject,perf_data__fd (session->data), + ret =copy_bytes (inject, session->data, event->auxtrace.size); }else { ret = output_bytes(inject, event,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 262/567 perf intel-pt: Add documentation for Event Trace and TNT disable
In reply to Greg Kroah-HartmanFrom: Adrian Hunter <[email protected]>
[ Upstream commit 24e3599c5a88e0e2995e3f5c9305f80195942dc9 ]
Add documentation for Event Trace and TNT disable to the perf Intel PT man page.
Stable-dep-of: aeb802f872a7 ("perf intel-pt: Do not try to queue auxtrace data on pipe")
--- tools/perf/Documentation/perf-intel-pt.txt | 104 ++++++++++++++++++++- 1 file changed, 102 insertions(+), 2 deletions(-)
tools/perf/Documentation/perf-intel-pt.txt +102 -2
@@ -108,9 +108,10 @@ displayed as follows: perf script --itrace=ibxwpe -F+flags -The flags are "bcrosyiABExgh" which stand for branch, call, return, conditional, +The flags are "bcrosyiABExghDt" which stand for branch, call, return, conditional, system, asynchronous, interrupt, transaction abort, trace begin, trace end, -in transaction, VM-entry, and VM-exit respectively. +in transaction, VM-entry, VM-exit, interrupt disabled, and interrupt disable +toggle respectively. perf script also supports higher level ways to dump instruction traces:
@@ -472,6 +473,30 @@ pwr_evt Enable power events. The power events provide information about which contains "1" if the feature is supported and "0" otherwise. +event Enable Event Trace. The events provide information about asynchronous + events. + + Support for this feature is indicated by: + + /sys/bus/event_source/devices/intel_pt/caps/event_trace + + which contains "1" if the feature is supported and + "0" otherwise. + +notnt Disable TNT packets. Without TNT packets, it is not possible to walk + executable code to reconstruct control flow, however FUP, TIP, TIP.PGE + and TIP.PGD packets still indicate asynchronous control flow, and (if + return compression is disabled - see noretcomp) return statements. + The advantage of eliminating TNT packets is reducing the size of the + trace and corresponding tracing overhead. + + Support for this feature is indicated by: + + /sys/bus/event_source/devices/intel_pt/caps/tnt_disable + + which contains "1" if the feature is supported and + "0" otherwise. + AUX area sampling option ~~~~~~~~~~~~~~~~~~~~~~~~
@@ -865,6 +890,8 @@ The letters are: p synthesize "power" events (incl. PSB events) c synthesize branches events (calls only) r synthesize branches events (returns only) + o synthesize PEBS-via-PT events + I synthesize Event Trace events e synthesize tracing error events d create a debug log g synthesize a call chain (use with i or x)
@@ -1338,6 +1365,79 @@ There were none. :17006 17006 [001] 11500.262869216: ffffffff8220116e error_entry+0xe ([guest.kernel.kallsyms]) pushq %rax +Event Trace +----------- + +Event Trace records information about asynchronous events, for example interrupts, +faults, VM exits and entries. The information is recorded in CFE and EVD packets, +and also the Interrupt Flag is recorded on the MODE.Exec packet. The CFE packet +contains a type field to identify one of the following: + + 1 INTR interrupt, fault, exception, NMI + 2 IRET interrupt return + 3 SMI system management interrupt + 4 RSM resume from system management mode + 5 SIPI startup interprocessor interrupt + 6 INIT INIT signal + 7 VMENTRY VM-Entry + 8 VMEXIT VM-Entry + 9 VMEXIT_INTR VM-Exit due to interrupt + 10 SHUTDOWN Shutdown + +For more details, refer to the Intel 64 and IA-32 Architectures Software +Developer Manuals (version 076 or later). + +The capability to do Event Trace is indicated by the +/sys/bus/event_source/devices/intel_pt/caps/event_trace file. + +Event trace is selected for recording using the "event" config term. e.g. + + perf record -e intel_pt/event/u uname + +Event trace events are output using the --itrace I option. e.g. + + perf script --itrace=Ie + +perf script displays events containing CFE type, vector and event data, +in the form: + + evt: hw int (t) cfe: INTR IP: 1 vector: 3 PFA: 0x8877665544332211 + +The IP flag indicates if the event binds to an IP, which includes any case where +flow control packet generation is enabled, as well as when CFE packet IP bit is +set. + +perf script displays events containing changes to the Interrupt Flag in the form: + + iflag: t IFLAG: 1->0 via branch + +where "via branch" indicates a branch (interrupt or return from interrupt) and +"non branch" indicates an instruction such as CFI, STI or POPF). + +In addition, the current state of the interrupt flag is indicated by the presence +or absence of the "D" (interrupt disabled) perf script flag. If the interrupt +flag is changed, then the "t" flag is also included i.e. + + no flag, interrupts enabled IF=1 + t interrupts become disabled IF=1 -> IF=0 + D interrupts are disabled IF=0 + Dt interrupts become enabled IF=0 -> IF=1 + +The intel-pt-events.py script illustrates how to access Event Trace information +using a Python script. + + +TNT Disable +----------- + +TNT packets are disabled using the "notnt" config term. e.g. + + perf record -e intel_pt/notnt/u uname + +In that case the --itrace q option is forced because walking executable code +to reconstruct the control flow is not possible. + + SEE ALSO --------
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 263/567 perf intel-pt: Add link to the perf wikis Intel PT page
In reply to Greg Kroah-HartmanFrom: Adrian Hunter <[email protected]>
[ Upstream commit 9e5e641045ff09ded4eb52828c4c7e110635422a ]
Add an EXAMPLE section and link to the perf wiki's Intel PT page.
Stable-dep-of: aeb802f872a7 ("perf intel-pt: Do not try to queue auxtrace data on pipe")
--- tools/perf/Documentation/perf-intel-pt.txt | 7 +++++++ 1 file changed, 7 insertions(+)
tools/perf/Documentation/perf-intel-pt.txt +7 -0
@@ -1438,6 +1438,13 @@ In that case the --itrace q option is forced because walking executable code to reconstruct the control flow is not possible. +EXAMPLE +------- + +Examples can be found on perf wiki page "Perf tools support for Intel® Processor Trace": + +https://perf.wiki.kernel.org/index.php/Perf_tools_support_for_Intel%C2%AE_Processor_Trace + SEE ALSO --------
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 264/567 perf intel-pt: Add support for emulated ptwrite
In reply to Greg Kroah-HartmanFrom: Adrian Hunter <[email protected]>
[ Upstream commit d7015e50a9ed180dcc3947635bb2b5711c37f48b ]
ptwrite is an Intel x86 instruction that writes arbitrary values into an Intel PT trace. It is not supported on all hardware, so provide an alternative that makes use of TNT packets to convey the payload data. TNT packets encode Taken/Not-taken conditional branch information, so taking branches based on the payload value will encode the value into the TNT packet. Refer to the changes to the documentation file perf-intel-pt.txt in this patch for an example.
Stable-dep-of: aeb802f872a7 ("perf intel-pt: Do not try to queue auxtrace data on pipe")
--- tools/perf/Documentation/perf-intel-pt.txt | 88 +++++++++++++++++ .../util/intel-pt-decoder/intel-pt-decoder.c | 99 ++++++++++++++++++- .../util/intel-pt-decoder/intel-pt-decoder.h | 1 + .../intel-pt-decoder/intel-pt-insn-decoder.c | 1 + .../intel-pt-decoder/intel-pt-insn-decoder.h | 1 + tools/perf/util/intel-pt.c | 37 ++++++- 6 files changed, 224 insertions(+), 3 deletions(-)
tools/perf/Documentation/perf-intel-pt.txt +88 -0
@@ -457,6 +457,8 @@ ptw Enable PTWRITE packets which are produced when a ptwrite instruction which contains "1" if the feature is supported and "0" otherwise. + As an alternative, refer to "Emulated PTWRITE" further below. + fup_on_ptw Enable a FUP packet to follow the PTWRITE packet. The FUP packet provides the address of the ptwrite instruction. In the absence of fup_on_ptw, the decoder will use the address of the previous branch
@@ -1438,6 +1440,92 @@ In that case the --itrace q option is forced because walking executable code to reconstruct the control flow is not possible. +Emulated PTWRITE +---------------- + +Later perf tools support a method to emulate the ptwrite instruction, which +can be useful if hardware does not support the ptwrite instruction. + +Instead of using the ptwrite instruction, a function is used which produces +a trace that encodes the payload data into TNT packets. Here is an example +of the function: + + #include <stdint.h> + + void perf_emulate_ptwrite(uint64_t x) + __attribute__((externally_visible, noipa, no_instrument_function, naked)); + + #define PERF_EMULATE_PTWRITE_8_BITS \ + "1: shl %rax\n" \ + " jc 1f\n" \ + "1: shl %rax\n" \ + " jc 1f\n" \ + "1: shl %rax\n" \ + " jc 1f\n" \ + "1: shl %rax\n" \ + " jc 1f\n" \ + "1: shl %rax\n" \ + " jc 1f\n" \ + "1: shl %rax\n" \ + " jc 1f\n" \ + "1: shl %rax\n" \ + " jc 1f\n" \ + "1: shl %rax\n" \ + " jc 1f\n" + + /* Undefined instruction */ + #define PERF_EMULATE_PTWRITE_UD2 ".byte 0x0f, 0x0b\n" + + #define PERF_EMULATE_PTWRITE_MAGIC PERF_EMULATE_PTWRITE_UD2 ".ascii \"perf,ptwrite \"\n" + + void perf_emulate_ptwrite(uint64_t x __attribute__ ((__unused__))) + { + /* Assumes SysV ABI : x passed in rdi */ + __asm__ volatile ( + "jmp 1f\n" + PERF_EMULATE_PTWRITE_MAGIC + "1: mov %rdi, %rax\n" + PERF_EMULATE_PTWRITE_8_BITS + PERF_EMULATE_PTWRITE_8_BITS + PERF_EMULATE_PTWRITE_8_BITS + PERF_EMULATE_PTWRITE_8_BITS + PERF_EMULATE_PTWRITE_8_BITS + PERF_EMULATE_PTWRITE_8_BITS + PERF_EMULATE_PTWRITE_8_BITS + PERF_EMULATE_PTWRITE_8_BITS + "1: ret\n" + ); + } + +For example, a test program with the function above: + + #include <stdio.h> + #include <stdint.h> + #include <stdlib.h> + + #include "perf_emulate_ptwrite.h" + + int main(int argc, char *argv[]) + { + uint64_t x = 0; + + if (argc > 1) + x = strtoull(argv[1], NULL, 0); + perf_emulate_ptwrite(x); + return 0; + } + +Can be compiled and traced: + + $ gcc -Wall -Wextra -O3 -g -o eg_ptw eg_ptw.c + $ perf record -e intel_pt//u ./eg_ptw 0x1234567890abcdef + [ perf record: Woken up 1 times to write data ] + [ perf record: Captured and wrote 0.017 MB perf.data ] + $ perf script --itrace=ew + eg_ptw 19875 [007] 8061.235912: ptwrite: IP: 0 payload: 0x1234567890abcdef 55701249a196 perf_emulate_ptwrite+0x16 (/home/user/eg_ptw) + $ + + EXAMPLE -------
tools/perf/util/intel-pt-decoder/intel-pt-decoder.c +97 -2
132 lines not on this page · raw message
tools/perf/util/intel-pt-decoder/intel-pt-decoder.h +1 -0
@@ -55,6 +55,7 @@ enum {INTEL_PT_ERR_LOST ,INTEL_PT_ERR_UNK ,INTEL_PT_ERR_NELOOP , +INTEL_PT_ERR_EPTW , INTEL_PT_ERR_MAX, };
tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c +1 -0
@@ -32,6 +32,7 @@ static void intel_pt_insn_decoder(struct insn *insn,int ext; intel_pt_insn->rel =0 ; + intel_pt_insn->emulated_ptwrite = false;if (insn_is_avx (insn)) { intel_pt_insn->op =INTEL_PT_OP_OTHER ;
tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.h +1 -0
@@ -37,6 +37,7 @@ enum intel_pt_insn_branch {struct intel_pt_insn {enum intel_pt_insn_op op;enum intel_pt_insn_branch branch; +bool emulated_ptwrite;int length;int32_t rel;unsigned char buf[INTEL_PT_INSN_BUF_SZ ];
tools/perf/util/intel-pt.c +36 -1
@@ -506,6 +506,7 @@ struct intel_pt_cache_entry {u64 byte_cnt;enum intel_pt_insn_op op;enum intel_pt_insn_branch branch; +bool emulated_ptwrite;int length;int32_t rel;char insn[INTEL_PT_INSN_BUF_SZ ];
@@ -592,6 +593,7 @@ static int intel_pt_cache_add(struct dso *dso, struct machine *machine, e->byte_cnt = byte_cnt; e->op = intel_pt_insn->op; e->branch = intel_pt_insn->branch; + e->emulated_ptwrite = intel_pt_insn->emulated_ptwrite; e->length = intel_pt_insn->length; e->rel = intel_pt_insn->rel;memcpy (e->insn, intel_pt_insn->buf,INTEL_PT_INSN_BUF_SZ );
@@ -678,6 +680,28 @@ static int intel_pt_get_guest(struct intel_pt_queue *ptq)return 0 ; } +static inline bool intel_pt_jmp_16 (struct intel_pt_insn *intel_pt_insn) +{ +return intel_pt_insn->rel ==16 && intel_pt_insn->branch ==INTEL_PT_BR_UNCONDITIONAL ; +} + +#define PTWRITE_MAGIC "\x0f\x0bperf,ptwrite " +#define PTWRITE_MAGIC_LEN 16 + +static bool intel_pt_emulated_ptwrite (struct dso *dso,struct machine *machine,u64 offset) +{ +unsigned char buf[PTWRITE_MAGIC_LEN ]; +ssize_t len; + + len =dso__data_read_offset (dso, machine, offset, buf,PTWRITE_MAGIC_LEN ); +if (len ==PTWRITE_MAGIC_LEN && !memcmp (buf,PTWRITE_MAGIC ,PTWRITE_MAGIC_LEN )) { +intel_pt_log ("Emulated ptwrite signature found\n" ); +return true; + } +intel_pt_log ("Emulated ptwrite signature not found\n" ); +return false; +} + static int intel_pt_walk_next_insn(struct intel_pt_insn *intel_pt_insn, uint64_t *insn_cnt_ptr, uint64_t *ip, uint64_t to_ip, uint64_t max_insn_cnt,
@@ -740,6 +764,7 @@ static int intel_pt_walk_next_insn(struct intel_pt_insn *intel_pt_insn, *ip += e->byte_cnt; intel_pt_insn->op = e->op; intel_pt_insn->branch = e->branch; + intel_pt_insn->emulated_ptwrite = e->emulated_ptwrite; intel_pt_insn->length = e->length; intel_pt_insn->rel = e->rel; memcpy(intel_pt_insn->buf, e->insn,
@@ -771,8 +796,18 @@ static int intel_pt_walk_next_insn(struct intel_pt_insn *intel_pt_insn, insn_cnt +=1 ; -if (intel_pt_insn->branch !=INTEL_PT_BR_NO_BRANCH ) +if (intel_pt_insn->branch !=INTEL_PT_BR_NO_BRANCH ) { +bool eptw; +u64 offs; + +if (!intel_pt_jmp_16 (intel_pt_insn)) + goto out; +/* Check for emulated ptwrite */ + offs = offset + intel_pt_insn->length; + eptw =intel_pt_emulated_ptwrite (al.map->dso, machine, offs); + intel_pt_insn->emulated_ptwrite = eptw; goto out; + }if (max_insn_cnt && insn_cnt >= max_insn_cnt) goto out_no_cache;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 265/567 perf intel-pt: Do not try to queue auxtrace data on pipe
In reply to Greg Kroah-HartmanFrom: Namhyung Kim <[email protected]>
[ Upstream commit aeb802f872a7c42e4381f36041e77d1745908255 ]
When it processes AUXTRACE_INFO, it calls to auxtrace_queue_data() to collect AUXTRACE data first. That won't work with pipe since it needs lseek() to read the scattered aux data.
$ perf record -o- -e intel_pt// true | perf report -i- --itrace=i100 # To display the perf.data header info, please use --header/--header-only options. # 0x4118 [0xa0]: failed to process type: 70 Error: failed to process sample
For the pipe mode, it can handle the aux data as it gets. But there's no guarantee it can get the aux data in time. So the following warning will be shown at the beginning:
WARNING: Intel PT with pipe mode is not recommended.
The output cannot relied upon. In particular, time stamps and the order of events may be incorrect.
--- tools/perf/Documentation/perf-intel-pt.txt | 30 ++++++++++++++++++++++ tools/perf/util/auxtrace.c | 3 +++ tools/perf/util/intel-pt.c | 6 +++++ 3 files changed, 39 insertions(+)
tools/perf/Documentation/perf-intel-pt.txt +30 -0
@@ -1526,6 +1526,36 @@ Can be compiled and traced: $ +Pipe mode +--------- +Pipe mode is a problem for Intel PT and possibly other auxtrace users. +It's not recommended to use a pipe as data output with Intel PT because +of the following reason. + +Essentially the auxtrace buffers do not behave like the regular perf +event buffers. That is because the head and tail are updated by +software, but in the auxtrace case the data is written by hardware. +So the head and tail do not get updated as data is written. + +In the Intel PT case, the head and tail are updated only when the trace +is disabled by software, for example: + - full-trace, system wide : when buffer passes watermark + - full-trace, not system-wide : when buffer passes watermark or + context switches + - snapshot mode : as above but also when a snapshot is made + - sample mode : as above but also when a sample is made + +That means finished-round ordering doesn't work. An auxtrace buffer +can turn up that has data that extends back in time, possibly to the +very beginning of tracing. + +For a perf.data file, that problem is solved by going through the trace +and queuing up the auxtrace buffers in advance. + +For pipe mode, the order of events and timestamps can presumably +be messed up. + + EXAMPLE -------
tools/perf/util/auxtrace.c +3 -0
@@ -1107,6 +1107,9 @@ int auxtrace_queue_data(struct perf_session *session, bool samples, bool events)if (auxtrace__dont_decode (session))return 0 ; +if (perf_data__is_pipe (session->data)) +return 0 ; +if (!session->auxtrace || !session->auxtrace->queue_data)return -EINVAL ;
tools/perf/util/intel-pt.c +6 -0
@@ -3942,6 +3942,12 @@ int intel_pt_process_auxtrace_info(union perf_event *event,intel_pt_setup_pebs_events (pt); +if (perf_data__is_pipe (session->data)) { +pr_warning ("WARNING: Intel PT with pipe mode is not recommended.\n" +" The output cannot relied upon. In particular,\n" +" timestamps and the order of events may be incorrect.\n" ); + } +if (pt->sampling_mode ||list_empty (&session->auxtrace_index)) err =auxtrace_queue_data (session, true, true);else
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 266/567 perf tools: Fix auto-complete on aarch64
In reply to Greg Kroah-HartmanFrom: Yicong Yang <[email protected]>
[ Upstream commit ffd1240e8f0814262ceb957dbe961f6e0aef1e7a ]
On aarch64 CPU related events are not under event_source/devices/cpu/events, they're under event_source/devices/armv8_pmuv3_0/events on my machine. Using current auto-complete script will generate below error:
[root@localhost bin]# perf stat -e
ls: cannot access '/sys/bus/event_source/devices/cpu/events': No such file or directory
Fix this by not testing /sys/bus/event_source/devices/cpu/events on aarch64 machine.
--- tools/perf/perf-completion.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
tools/perf/perf-completion.sh +8 -3
@@ -165,7 +165,12 @@ __perf_main () local cur1=${COMP_WORDS[COMP_CWORD]} local raw_evts=$($cmd list --raw-dump) - local arr s tmp result + local arr s tmp result cpu_evts + + # aarch64 doesn't have /sys/bus/event_source/devices/cpu/events + if [[ `uname -m` != aarch64 ]]; then + cpu_evts=$(ls /sys/bus/event_source/devices/cpu/events) + fi if [[ "$cur1" == */* && ${cur1#*/} =~ ^[A-Z] ]]; then OLD_IFS="$IFS"
@@ -183,9 +188,9 @@ __perf_main () fi done - evts=${result}" "$(ls /sys/bus/event_source/devices/cpu/events) + evts=${result}" "${cpu_evts} else - evts=${raw_evts}" "$(ls /sys/bus/event_source/devices/cpu/events) + evts=${raw_evts}" "${cpu_evts} fi if [[ "$cur1" == , ]]; then
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 267/567 sparc: allow PM configs for sparc32 COMPILE_TEST
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 7be6a87c2473957090995b7eb541e31d57a2c801 ]
When doing randconfig builds for sparc32 with COMPILE_TEST, some (non-Sparc) drivers cause kconfig warnings with the Kconfig symbols PM, PM_GENERIC_DOMAINS, or PM_GENERIC_DOMAINS_OF.
This is due to arch/sparc/Kconfig not using the PM Kconfig for Sparc32:
if SPARC64
source "kernel/power/Kconfig"
endif
Arnd suggested adding "|| COMPILE_TEST" to the conditional, instead of trying to track down every driver that selects any of these PM symbols.
Fixes the following kconfig warnings:
WARNING: unmet direct dependencies detected for PM
Depends on [n]: SPARC64 [=n]
Selected by [y]:
- SUN20I_PPU [=y] && (ARCH_SUNXI || COMPILE_TEST [=y])
WARNING: unmet direct dependencies detected for PM
Depends on [n]: SPARC64 [=n]
Selected by [y]:
- SUN20I_PPU [=y] && (ARCH_SUNXI || COMPILE_TEST [=y])
WARNING: unmet direct dependencies detected for PM_GENERIC_DOMAINS
Depends on [n]: SPARC64 [=n] && PM [=y]
Selected by [y]:
- QCOM_GDSC [=y] && COMMON_CLK [=y] && PM [=y]
- SUN20I_PPU [=y] && (ARCH_SUNXI || COMPILE_TEST [=y])
- MESON_GX_PM_DOMAINS [=y] && (ARCH_MESON || COMPILE_TEST [=y]) && PM [=y] && OF [=y]
- BCM2835_POWER [=y] && (ARCH_BCM2835 || COMPILE_TEST [=y] && OF [=y]) && PM [=y]
- BCM_PMB [=y] && (ARCH_BCMBCA || COMPILE_TEST [=y] && OF [=y]) && PM [=y]
- ROCKCHIP_PM_DOMAINS [=y] && (ARCH_ROCKCHIP || COMPILE_TEST [=y]) && PM [=y] Selected by [m]:
- ARM_SCPI_POWER_DOMAIN [=m] && (ARM_SCPI_PROTOCOL [=m] || COMPILE_TEST [=y] && OF [=y]) && PM [=y]
- MESON_EE_PM_DOMAINS [=m] && (ARCH_MESON || COMPILE_TEST [=y]) && PM [=y] && OF [=y]
- QCOM_AOSS_QMP [=m] && (ARCH_QCOM || COMPILE_TEST [=y]) && MAILBOX [=y] && COMMON_CLK [=y] && PM [=y]
WARNING: unmet direct dependencies detected for PM_GENERIC_DOMAINS_OF
Depends on [n]: SPARC64 [=n] && PM_GENERIC_DOMAINS [=y] && OF [=y] Selected by [y]:
- MESON_GX_PM_DOMAINS [=y] && (ARCH_MESON || COMPILE_TEST [=y]) && PM [=y] && OF [=y] Selected by [m]:
- MESON_EE_PM_DOMAINS [=m] && (ARCH_MESON || COMPILE_TEST [=y]) && PM [=y] && OF [=y]
--- arch/sparc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sparc/Kconfig +1 -1
@@ -286,7 +286,7 @@ config FORCE_MAX_ZONEORDER This config option is actually maximum order plus one. For example, a value of 13 means that the largest free memory block is 2^12 pages. -if SPARC64 +if SPARC64 || COMPILE_TEST source "kernel/power/Kconfig" endif
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 268/567 selftests/ftrace: Fix bash specific "==" operator
In reply to Greg Kroah-HartmanFrom: Masami Hiramatsu (Google) <[email protected]>
[ Upstream commit 1e6b485c922fbedf41d5a9f4e6449c5aeb923a32 ]
Since commit a1d6cd88c897 ("selftests/ftrace: event_triggers: wait longer for test_event_enable") introduced bash specific "==" comparation operator, that test will fail when we run it on a posix-shell. checkbashisms warned it as below.
possible bashism in ftrace/func_event_triggers.tc line 45 (should be 'b = a'):
if [ "$e" == $val ]; then
This replaces it with "=".
--- .../selftests/ftrace/test.d/ftrace/func_event_triggers.tc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/ftrace/test.d/ftrace/func_event_triggers.tc +1 -1
@@ -42,7 +42,7 @@ test_event_enabled() { while [ $check_times -ne 0 ]; do e=`cat $EVENT_ENABLE` - if [ "$e" == $val ]; then + if [ "$e" = $val ]; then return 0 fi sleep $SLEEP_TIME
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 269/567 printf: fix errname.c list
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 0c2baf6509af1d11310ae4c1c839481a6e9a4bc4 ]
On most architectures, gcc -Wextra warns about the list of error numbers containing both EDEADLK and EDEADLOCK:
lib/errname.c:15:67: warning: initialized field overwritten [-Woverride-init]
15 | #define E(err) [err + BUILD_BUG_ON_ZERO(err <= 0 || err > 300)] = "-" #err
| ^~~lib/errname.c:172:2: note: in expansion of macro 'E'
172 | E(EDEADLK), /* EDEADLOCK */
| ^On parisc, a similar error happens with -ECANCELLED, which is an alias for ECANCELED.
Make the EDEADLK printing conditional on the number being distinct from EDEADLOCK, and remove the -ECANCELLED bit completely as it can never be hit.
To ensure these are correct, add static_assert lines that verify all the remaining aliases are in fact identical to the canonical name.
--- lib/errname.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-)
lib/errname.c +14 -8
@@ -21,6 +21,7 @@ static const char *names_0[] = {E (EADDRNOTAVAIL ),E (EADV ),E (EAFNOSUPPORT ), +E (EAGAIN ),/* EWOULDBLOCK */ E (EALREADY ),E (EBADE ), E(EBADF),
@@ -31,15 +32,17 @@ static const char *names_0[] = {E (EBADSLT ),E (EBFONT ),E (EBUSY ), -#ifdef ECANCELLED -E (ECANCELLED ), -#endif +E (ECANCELED ),/* ECANCELLED */ E (ECHILD ),E (ECHRNG ),E (ECOMM ),E (ECONNABORTED ), +E (ECONNREFUSED ),/* EREFUSED */ E (ECONNRESET ), +E (EDEADLK ),/* EDEADLOCK */ +#if EDEADLK != EDEADLOCK /* mips, sparc, powerpc */E (EDEADLOCK ), +#endifE (EDESTADDRREQ ),E (EDOM ), E(EDOTDOT),
@@ -166,14 +169,17 @@ static const char *names_0[] = {E (EUSERS ),E (EXDEV ), E(EXFULL), - -E (ECANCELED ),/* ECANCELLED */ -E (EAGAIN ),/* EWOULDBLOCK */ -E (ECONNREFUSED ),/* EREFUSED */ - E(EDEADLK), /* EDEADLOCK */ };#undef E +#ifdef EREFUSED /* parisc */ +static_assert (EREFUSED ==ECONNREFUSED ); +#endif +#ifdef ECANCELLED /* parisc */ +static_assert (ECANCELLED ==ECANCELED ); +#endif +static_assert (EAGAIN ==EWOULDBLOCK );/* everywhere */ +#define E (err) [err - 512 + BUILD_BUG_ON_ZERO(err < 512 || err > 550)] = "-" #errstatic const char *names_512[] = {E (ERESTARTSYS ),
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 270/567 objtool: add UACCESS exceptions for __tsan_volatile_read/write
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit d5d469247264e56960705dc5ae7e1d014861fe40 ]
A lot of the tsan helpers are already excempt from the UACCESS warnings, but some more functions were added that need the same thing:
kernel/kcsan/core.o: warning: objtool: __tsan_volatile_read16+0x0: call to __tsan_unaligned_read16() with UACCESS enabled kernel/kcsan/core.o: warning: objtool: __tsan_volatile_write16+0x0: call to __tsan_unaligned_write16() with UACCESS enabled vmlinux.o: warning: objtool: __tsan_unaligned_volatile_read16+0x4: call to __tsan_unaligned_read16() with UACCESS enabled vmlinux.o: warning: objtool: __tsan_unaligned_volatile_write16+0x4: call to __tsan_unaligned_write16() with UACCESS enabled
As Marco points out, these functions don't even call each other explicitly but instead gcc (but not clang) notices the functions being identical and turns one symbol into a direct branch to the other.
--- tools/objtool/check.c | 2 ++ 1 file changed, 2 insertions(+)
tools/objtool/check.c +2 -0
@@ -908,6 +908,8 @@ static const char *uaccess_safe_builtin[] = {"__tsan_atomic64_compare_exchange_val" ,"__tsan_atomic_thread_fence" ,"__tsan_atomic_signal_fence" , +"__tsan_unaligned_read16" , +"__tsan_unaligned_write16" ,/* KCOV */ "write_comp_data" , "check_kcov_mode",
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 271/567 mfd: cs5535: Dont build on UML
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 5ec32a3e4053c1a726b45381d56aa9e39eaf3911 ]
The cs5535-mfd driver uses CPU-specific data that is not available for ARCH=um builds, so don't allow it to be built for UML.
Prevents these build errors:
In file included from ../arch/x86/include/asm/olpc.h:7,
from ../drivers/mfd/cs5535-mfd.c:17:
../arch/x86/include/asm/geode.h: In function ‘is_geode_gx’:../arch/x86/include/asm/geode.h:16:31: error: ‘struct cpuinfo_um’ has no member named ‘x86_vendor’
16 | return ((boot_cpu_data.x86_vendor == X86_VENDOR_NSC) &&../arch/x86/include/asm/geode.h:16:46: error: ‘X86_VENDOR_NSC’ undeclared (first use in this function); did you mean ‘X86_VENDOR_ANY’?
16 | return ((boot_cpu_data.x86_vendor == X86_VENDOR_NSC) &&../arch/x86/include/asm/geode.h:17:31: error: ‘struct cpuinfo_um’ has no member named ‘x86’
17 | (boot_cpu_data.x86 == 5) &&../arch/x86/include/asm/geode.h:18:31: error: ‘struct cpuinfo_um’ has no member named ‘x86_model’
18 | (boot_cpu_data.x86_model == 5));../arch/x86/include/asm/geode.h: In function ‘is_geode_lx’:../arch/x86/include/asm/geode.h:23:31: error: ‘struct cpuinfo_um’ has no member named ‘x86_vendor’
23 | return ((boot_cpu_data.x86_vendor == X86_VENDOR_AMD) &&../arch/x86/include/asm/geode.h:23:46: error: ‘X86_VENDOR_AMD’ undeclared (first use in this function); did you mean ‘X86_VENDOR_ANY’?
23 | return ((boot_cpu_data.x86_vendor == X86_VENDOR_AMD) &&../arch/x86/include/asm/geode.h:24:31: error: ‘struct cpuinfo_um’ has no member named ‘x86’
24 | (boot_cpu_data.x86 == 5) &&../arch/x86/include/asm/geode.h:25:31: error: ‘struct cpuinfo_um’ has no member named ‘x86_model’
25 | (boot_cpu_data.x86_model == 10));
--- drivers/mfd/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/mfd/Kconfig +1 -0
@@ -15,6 +15,7 @@ config MFD_CS5535 tristate "AMD CS5535 and CS5536 southbridge core functions" select MFD_CORE depends on PCI && (X86_32 || (X86 && COMPILE_TEST)) + depends on !UML help This is the core driver for CS5535/CS5536 MFD functions. This is necessary for using the board's GPIO and MFGPT functionality.
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 272/567 mfd: pcf50633-adc: Fix potential memleak in pcf50633_adc_async_read()
In reply to Greg Kroah-HartmanFrom: Qiheng Lin <[email protected]>
[ Upstream commit 8b450dcff23aa254844492831a8e2b508a9d522d ]
req is allocated in pcf50633_adc_async_read(), but adc_enqueue_request() could fail to insert the req into queue. We need to check the return value and free it in the case of failure.
--- drivers/mfd/pcf50633-adc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/mfd/pcf50633-adc.c +6 -1
@@ -136,6 +136,7 @@ int pcf50633_adc_async_read(struct pcf50633 *pcf, int mux, int avg, void *callback_param) {struct pcf50633_adc_request *req; +int ret;/* req is freed when the result is ready, in interrupt handler */ req =kmalloc (sizeof (*req),GFP_KERNEL );
@@ -147,7 +148,11 @@ int pcf50633_adc_async_read(struct pcf50633 *pcf, int mux, int avg, req->callback = callback; req->callback_param = callback_param; -return adc_enqueue_request (pcf, req); + ret =adc_enqueue_request (pcf, req); +if (ret) +kfree (req); + +return ret; }EXPORT_SYMBOL_GPL (pcf50633_adc_async_read);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 273/567 dmaengine: idxd: Set traffic class values in GRPCFG on DSA 2.0
In reply to Greg Kroah-HartmanFrom: Fenghua Yu <[email protected]>
[ Upstream commit 9735bde36487da43d3c3fc910df49639f72decbf ]
On DSA/IAX 1.0, TC-A and TC-B in GRPCFG are set as 1 to have best performance and cannot be changed through sysfs knobs unless override option is given.
The same values should be set on DSA 2.0 as well.
--- drivers/dma/idxd/device.c | 2 +- drivers/dma/idxd/init.c | 2 +- drivers/dma/idxd/sysfs.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/dma/idxd/device.c +1 -1
@@ -702,7 +702,7 @@ static void idxd_groups_clear_state(struct idxd_device *idxd) group->use_rdbuf_limit = false; group->rdbufs_allowed =0 ; group->rdbufs_reserved =0 ; -if (idxd->hw.version <DEVICE_VERSION_2 && !tc_override) { +if (idxd->hw.version <=DEVICE_VERSION_2 && !tc_override) { group->tc_a =1 ; group->tc_b =1 ; }else {
drivers/dma/idxd/init.c +1 -1
@@ -340,7 +340,7 @@ static int idxd_setup_groups(struct idxd_device *idxd) } idxd->groups[i] = group; -if (idxd->hw.version <DEVICE_VERSION_2 && !tc_override) { +if (idxd->hw.version <=DEVICE_VERSION_2 && !tc_override) { group->tc_a =1 ; group->tc_b =1 ; }else {
drivers/dma/idxd/sysfs.c +2 -2
@@ -327,7 +327,7 @@ static ssize_t group_traffic_class_a_store(struct device *dev,if (idxd->state ==IDXD_DEV_ENABLED )return -EPERM ; -if (idxd->hw.version <DEVICE_VERSION_2 && !tc_override) +if (idxd->hw.version <=DEVICE_VERSION_2 && !tc_override)return -EPERM ;if (val <0 || val >7 )
@@ -369,7 +369,7 @@ static ssize_t group_traffic_class_b_store(struct device *dev,if (idxd->state ==IDXD_DEV_ENABLED )return -EPERM ; -if (idxd->hw.version <DEVICE_VERSION_2 && !tc_override) +if (idxd->hw.version <=DEVICE_VERSION_2 && !tc_override)return -EPERM ;if (val <0 || val >7 )
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 274/567 dmaengine: HISI_DMA should depend on ARCH_HISI
In reply to Greg Kroah-HartmanFrom: Geert Uytterhoeven <[email protected]>
[ Upstream commit dcca9d045c0852584ad092123c7f6e6526a633b1 ]
The HiSilicon DMA Engine is only present on HiSilicon SoCs. Hence add a dependency on ARCH_HISI, to prevent asking the user about this driver when configuring a kernel without HiSilicon SoC support.
--- drivers/dma/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/Kconfig +1 -1
@@ -236,7 +236,7 @@ config FSL_RAID config HISI_DMA tristate "HiSilicon DMA Engine support" - depends on ARM64 || COMPILE_TEST + depends on ARCH_HISI || COMPILE_TEST depends on PCI_MSI select DMA_ENGINE select DMA_VIRTUAL_CHANNELS
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 275/567 iio: light: tsl2563: Do not hardcode interrupt trigger type
In reply to Greg Kroah-HartmanFrom: Ferry Toth <[email protected]>
[ Upstream commit 027641b52fe37b64af61025298ce160c8b9b7a73 ]
Instead of hardcoding IRQ trigger type to IRQF_TRIGGER_RAISING, let's respect the settings specified in the firmware description. To be compatible with the older firmware descriptions, if trigger type is not set up there, we'll set it to default (raising edge).
--- drivers/iio/light/tsl2563.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/iio/light/tsl2563.c +7 -1
@@ -705,6 +705,7 @@ static int tsl2563_probe(struct i2c_client *client,struct iio_dev *indio_dev;struct tsl2563_chip *chip;struct tsl2563_platform_data *pdata = client->dev.platform_data; +unsigned long irq_flags;int err =0 ;u8 id =0 ;
@@ -760,10 +761,15 @@ static int tsl2563_probe(struct i2c_client *client, indio_dev->info = &tsl2563_info_no_irq;if (client->irq) { + irq_flags =irq_get_trigger_type (client->irq); +if (irq_flags ==IRQF_TRIGGER_NONE ) + irq_flags =IRQF_TRIGGER_RISING ; + irq_flags |=IRQF_ONESHOT ; + err =devm_request_threaded_irq (&client->dev, client->irq,NULL , &tsl2563_event_handler, -IRQF_TRIGGER_RISING |IRQF_ONESHOT , + irq_flags,"tsl2563_event" , indio_dev);if (err) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 276/567 usb: gadget: fusb300_udc: free irq on the error path in fusb300_probe()
In reply to Greg Kroah-HartmanFrom: Gaosheng Cui <[email protected]>
[ Upstream commit a8d3392e0e5cfeb03f0cea1f2bc3f5f183c1deb4 ]
When request_irq(ires1->start) failed in w5300_hw_probe(), irq ires->start has not been freed, and on the clean_up3 error path, we also need to free ires1->start irq, fix it.
In addition, We should add free_irq in fusb300_remove(), and give the lables a proper name so that they can be understood easily, so add free_irq in fusb300_remove(), and update clean_up3 to err_alloc_request.
--- drivers/usb/gadget/udc/fusb300_udc.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/usb/gadget/udc/fusb300_udc.c +7 -3
@@ -1347,6 +1347,7 @@ static int fusb300_remove(struct platform_device *pdev)usb_del_gadget_udc (&fusb300->gadget);iounmap (fusb300->reg);free_irq (platform_get_irq (pdev,0 ), fusb300); +free_irq (platform_get_irq (pdev,1 ), fusb300);fusb300_free_request (&fusb300->ep[0 ]->ep, fusb300->ep0_req);for (i =0 ; i <FUSB300_MAX_NUM_EP ; i++)
@@ -1432,7 +1433,7 @@ static int fusb300_probe(struct platform_device *pdev) IRQF_SHARED, udc_name, fusb300);if (ret <0 ) {pr_err ("request_irq1 error (%d)\n" , ret); - goto clean_up; + goto err_request_irq1; }INIT_LIST_HEAD (&fusb300->gadget.ep_list);
@@ -1471,7 +1472,7 @@ static int fusb300_probe(struct platform_device *pdev) GFP_KERNEL);if (fusb300->ep0_req ==NULL ) { ret = -ENOMEM ; - goto clean_up3; + goto err_alloc_request; }init_controller (fusb300);
@@ -1486,7 +1487,10 @@ static int fusb300_probe(struct platform_device *pdev) err_add_udc:fusb300_free_request (&fusb300->ep[0 ]->ep, fusb300->ep0_req); -clean_up3: +err_alloc_request: +free_irq (ires1->start, fusb300); + +err_request_irq1:free_irq (ires->start, fusb300); clean_up:
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 277/567 i2c: designware: fix i2c_dw_clk_rate() return size to be u32
In reply to Greg Kroah-HartmanFrom: Hanna Hawa <[email protected]>
[ Upstream commit f2e1fa99550dd7a882229e2c2cd9ecab4ce773d0 ]
Make i2c_dw_clk_rate() to return u32 instead of unsigned long, as the function return the value of get_clk_rate_khz() which returns u32.
--- drivers/i2c/busses/i2c-designware-common.c | 2 +- drivers/i2c/busses/i2c-designware-core.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-designware-common.c +1 -1
@@ -465,7 +465,7 @@ void __i2c_dw_disable(struct dw_i2c_dev *dev)dev_warn (dev->dev,"timeout in disabling adapter\n" ); } -unsigned long i2c_dw_clk_rate (struct dw_i2c_dev *dev) +u32 i2c_dw_clk_rate (struct dw_i2c_dev *dev) {/* * Clock is not necessary if we got LCNT/HCNT values directly from
drivers/i2c/busses/i2c-designware-core.h +1 -1
@@ -310,7 +310,7 @@ int i2c_dw_init_regmap(struct dw_i2c_dev *dev);u32 i2c_dw_scl_hcnt (u32 ic_clk,u32 tSYMBOL,u32 tf,int cond,int offset);u32 i2c_dw_scl_lcnt (u32 ic_clk,u32 tLOW,u32 tf,int offset);int i2c_dw_set_sda_hold (struct dw_i2c_dev *dev); -unsigned long i2c_dw_clk_rate (struct dw_i2c_dev *dev); +u32 i2c_dw_clk_rate (struct dw_i2c_dev *dev);int i2c_dw_prepare_clk (struct dw_i2c_dev *dev,bool prepare);int i2c_dw_acquire_lock (struct dw_i2c_dev *dev);void i2c_dw_release_lock (struct dw_i2c_dev *dev);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 278/567 soundwire: cadence: Dont overflow the command FIFOs
In reply to Greg Kroah-HartmanFrom: Richard Fitzgerald <[email protected]>
[ Upstream commit 7cbfee2e2e40d2be54196362a845a3ea0a3f877d ]
The command FIFOs in the Cadence IP can be configured during design up to 32 entries, and the code in cadence_master.c was assuming the full 32-entry FIFO. But all current Intel implementations use an 8-entry FIFO.
Up to now the longest message used was 6 entries so this wasn't causing any problem. But future Cirrus Logic codecs have downloadable firmware or tuning blobs. It is more efficient for the codec driver to issue long transfers that can take advantage of any queuing in the Soundwire controller and avoid the overhead of repeatedly writing the page registers.
--- drivers/soundwire/cadence_master.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/soundwire/cadence_master.c +2 -1
@@ -127,7 +127,8 @@ MODULE_PARM_DESC(cdns_mcp_int_mask, "Cadence MCP IntMask");#define CDNS_MCP_CMD_BASE 0x80#define CDNS_MCP_RESP_BASE 0x80 -#define CDNS_MCP_CMD_LEN 0x20 +/* FIFO can hold 8 commands */ +#define CDNS_MCP_CMD_LEN 8#define CDNS_MCP_CMD_WORD_LEN 0x4#define CDNS_MCP_CMD_SSP_TAG BIT(31)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 279/567 driver core: fix potential null-ptr-deref in device_add()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit f6837f34a34973ef6600c08195ed300e24e97317 ]
I got the following null-ptr-deref report while doing fault injection test:
BUG: kernel NULL pointer dereference, address: 0000000000000058 CPU: 2 PID: 278 Comm: 37-i2c-ds2482 Tainted: G B W N 6.1.0-rc3+ RIP: 0010:klist_put+0x2d/0xd0 Call Trace: <TASK> klist_remove+0xf1/0x1c0 device_release_driver_internal+0x196/0x210 bus_remove_device+0x1bd/0x240 device_add+0xd3d/0x1100 w1_add_master_device+0x476/0x490 [wire] ds2482_probe+0x303/0x3e0 [ds2482]
This is how it happened:
w1_alloc_dev()
// The dev->driver is set to w1_master_driver. memcpy(&dev->dev, device, sizeof(struct device)); device_add()
bus_add_device()
dpm_sysfs_add() // It fails, calls bus_remove_device.
// error path
bus_remove_device()
// The dev->driver is not null, but driver is not bound.
__device_release_driver()
klist_remove(&dev->p->knode_driver) <-- It causes null-ptr-deref.
// normal path
bus_probe_device() // It's not called yet.
device_bind_driver()If dev->driver is set, in the error path after calling bus_add_device() in device_add(), bus_remove_device() is called, then the device will be detached from driver. But device_bind_driver() is not called yet, so it causes null-ptr-deref while access the 'knode_driver'. To fix this, set dev->driver to null in the error path before calling bus_remove_device().
--- drivers/base/core.c | 1 + 1 file changed, 1 insertion(+)
drivers/base/core.c +1 -0
@@ -3428,6 +3428,7 @@ int device_add(struct device *dev)device_pm_remove (dev);dpm_sysfs_remove (dev); DPMError: + dev->driver =NULL ;bus_remove_device (dev); BusError:device_remove_attrs (dev);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 280/567 kobject: modify kobject_get_path() to take a const *
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
[ Upstream commit 33a0a1e3b3d17445832177981dc7a1c6a5b009f8 ]
kobject_get_path() does not modify the kobject passed to it, so make the pointer constant.
Stable-dep-of: 3bb2a01caa81 ("kobject: Fix slab-out-of-bounds in fill_kobj_path()")
--- include/linux/kobject.h | 2 +- lib/kobject.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-)
include/linux/kobject.h +1 -1
@@ -116,7 +116,7 @@ extern void kobject_put(struct kobject *kobj);extern const void *kobject_namespace (struct kobject *kobj);extern void kobject_get_ownership (struct kobject *kobj,kuid_t *uid,kgid_t *gid); -extern char *kobject_get_path (struct kobject *kobj,gfp_t flag); +extern char *kobject_get_path (const struct kobject *kobj,gfp_t flag);/** * kobject_has_children - Returns whether a kobject has children.
lib/kobject.c +5 -5
@@ -126,10 +126,10 @@ static int create_dir(struct kobject *kobj)return 0 ; } -static int get_kobj_path_length (struct kobject *kobj) +static int get_kobj_path_length (const struct kobject *kobj) {int length =1 ; -struct kobject *parent = kobj; +const struct kobject *parent = kobj;/* walk up the ancestors until we hit the one pointing to the * root.
@@ -144,9 +144,9 @@ static int get_kobj_path_length(struct kobject *kobj)return length; } -static void fill_kobj_path (struct kobject *kobj,char *path,int length) +static void fill_kobj_path (const struct kobject *kobj,char *path,int length) { -struct kobject *parent; +const struct kobject *parent; --length;for (parent = kobj; parent; parent = parent->parent) {
@@ -168,7 +168,7 @@ static void fill_kobj_path(struct kobject *kobj, char *path, int length)* * Return: The newly allocated memory, caller must free with kfree(). */ -char *kobject_get_path (struct kobject *kobj,gfp_t gfp_mask) +char *kobject_get_path (const struct kobject *kobj,gfp_t gfp_mask) {char *path;int len;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 281/567 kobject: Fix slab-out-of-bounds in fill_kobj_path()
In reply to Greg Kroah-HartmanFrom: Wang Hai <[email protected]>
[ Upstream commit 3bb2a01caa813d3a1845d378bbe4169ef280d394 ]
In kobject_get_path(), if kobj->name is changed between calls get_kobj_path_length() and fill_kobj_path() and the length becomes longer, then fill_kobj_path() will have an out-of-bounds bug.
The actual current problem occurs when the ixgbe probe.
In ixgbe_mii_bus_init(), if the length of netdev->dev.kobj.name length becomes longer, out-of-bounds will occur.
cpu0 cpu1ixgbe_probe
register_netdev(netdev)
netdev_register_kobject
device_add
kobject_uevent // Sending ADD events
systemd-udevd // rename netdev
dev_change_name
device_rename
kobject_rename
ixgbe_mii_bus_init |
mdiobus_register |
__mdiobus_register |
device_register |
device_add |
kobject_uevent |
kobject_get_path |
len = get_kobj_path_length // old name |
path = kzalloc(len, gfp_mask); | kobj->name = name; /* name length becomes
* longer */
fill_kobj_path /* kobj path length is
* longer than path,
* resulting in out of
* bounds when filling path
*/
This is the kasan report:
==================================================================
BUG: KASAN: slab-out-of-bounds in fill_kobj_path+0x50/0xc0 Write of size 7 at addr ff1100090573d1fd by task kworker/28:1/673 Workqueue: events work_for_cpu_fn Call Trace: <TASK> dump_stack_lvl+0x34/0x48 print_address_description.constprop.0+0x86/0x1e7 print_report+0x36/0x4f kasan_report+0xad/0x130 kasan_check_range+0x35/0x1c0 memcpy+0x39/0x60 fill_kobj_path+0x50/0xc0 kobject_get_path+0x5a/0xc0 kobject_uevent_env+0x140/0x460 device_add+0x5c7/0x910 __mdiobus_register+0x14e/0x490 ixgbe_probe.cold+0x441/0x574 [ixgbe] local_pci_probe+0x78/0xc0 work_for_cpu_fn+0x26/0x40 process_one_work+0x3b6/0x6a0 worker_thread+0x368/0x520 kthread+0x165/0x1a0 ret_from_fork+0x1f/0x30
This reproducer triggers that bug:
while:
do
rmmod ixgbe
sleep 0.5
modprobe ixgbe
sleep 0.5When calling fill_kobj_path() to fill path, if the name length of kobj becomes longer, return failure and retry. This fixes the problem.
--- lib/kobject.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
lib/kobject.c +10 -2
@@ -144,7 +144,7 @@ static int get_kobj_path_length(const struct kobject *kobj)return length; } -static void fill_kobj_path (const struct kobject *kobj,char *path,int length) +static int fill_kobj_path (const struct kobject *kobj,char *path,int length) {const struct kobject *parent;
@@ -153,12 +153,16 @@ static void fill_kobj_path(const struct kobject *kobj, char *path, int length)int cur =strlen (kobject_name (parent));/* back up enough to print this name with '/' */ length -= cur; +if (length <=0 ) +return -EINVAL ;memcpy (path + length,kobject_name (parent), cur); *(path + --length) ='/' ; }pr_debug ("kobject: '%s' (%p): %s: path = '%s'\n" ,kobject_name (kobj), kobj, __func__, path); + +return 0 ; }/**
@@ -173,13 +177,17 @@ char *kobject_get_path(const struct kobject *kobj, gfp_t gfp_mask)char *path;int len; +retry: len =get_kobj_path_length (kobj);if (len ==0 )return NULL ; path =kzalloc (len, gfp_mask);if (!path)return NULL ; -fill_kobj_path (kobj, path, len); +if (fill_kobj_path (kobj, path, len)) { +kfree (path); + goto retry; + }return path; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 282/567 alpha/boot/tools/objstrip: fix the check for ELF header
In reply to Greg Kroah-HartmanFrom: Al Viro <[email protected]>
[ Upstream commit 1878787797cbb019eeefe6f905514dcd557302b6 ]
Just memcmp() with ELFMAG - that's the normal way to do it in userland code, which that thing is. Besides, that has the benefit of actually building - str_has_prefix() is *NOT* present in <string.h>.
--- arch/alpha/boot/tools/objstrip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/alpha/boot/tools/objstrip.c +1 -1
@@ -148,7 +148,7 @@ main (int argc, char *argv[])#ifdef __ELF__ elf = (struct elfhdr *) buf; -if (elf->e_ident[0 ] ==0x7f &&str_has_prefix ((char *)elf->e_ident +1 ,"ELF" )) { +if (memcmp (&elf->e_ident[EI_MAG0 ],ELFMAG ,SELFMAG ) ==0 ) {if (elf->e_type !=ET_EXEC ) {fprintf (stderr,"%s: %s is not an ELF executable\n" , prog_name, inname);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 283/567 media: uvcvideo: Do not check for V4L2_CTRL_WHICH_DEF_VAL
In reply to Greg Kroah-HartmanFrom: Ricardo Ribalda <[email protected]>
[ Upstream commit a2f8a484fbc96b8209a760cb3f2c95ca49c2cdb1 ]
The framework already checks for us if V4L2_CTRL_WHICH_DEF_VAL is written.
Stable-dep-of: 9f582f0418ed ("media: uvcvideo: Check for INACTIVE in uvc_ctrl_is_accessible()")
--- drivers/media/usb/uvc/uvc_v4l2.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/media/usb/uvc/uvc_v4l2.c +0 -4
@@ -1106,10 +1106,6 @@ static int uvc_ioctl_s_try_ext_ctrls(struct uvc_fh *handle,unsigned int i;int ret; -/* Default value cannot be changed */ -if (ctrls->which ==V4L2_CTRL_WHICH_DEF_VAL ) -return -EINVAL ; - ret =uvc_ctrl_begin (chain);if (ret <0 )return ret;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 284/567 media: uvcvideo: Remove s_ctrl and g_ctrl
In reply to Greg Kroah-HartmanFrom: Ricardo Ribalda <[email protected]>
[ Upstream commit 0c6bcbdfefa83b8a1e9659b3c127758dce0fe7ac ]
If we do not implement these callbacks the framework will call the ext_ctrl callbaks instead, which are a superset of this functions.
Stable-dep-of: 9f582f0418ed ("media: uvcvideo: Check for INACTIVE in uvc_ctrl_is_accessible()")
--- drivers/media/usb/uvc/uvc_v4l2.c | 56 -------------------------------- 1 file changed, 56 deletions(-)
drivers/media/usb/uvc/uvc_v4l2.c +0 -56
@@ -1000,60 +1000,6 @@ static int uvc_ioctl_query_ext_ctrl(struct file *file, void *fh,return 0 ; } -static int uvc_ioctl_g_ctrl (struct file *file,void *fh, -struct v4l2_control *ctrl) -{ -struct uvc_fh *handle = fh; -struct uvc_video_chain *chain = handle->chain; -struct v4l2_ext_control xctrl; -int ret; - -memset (&xctrl,0 ,sizeof (xctrl)); - xctrl.id = ctrl->id; - - ret =uvc_ctrl_begin (chain); -if (ret <0 ) -return ret; - - ret =uvc_ctrl_get (chain, &xctrl); -uvc_ctrl_rollback (handle); -if (ret <0 ) -return ret; - - ctrl->value = xctrl.value; -return 0 ; -} - -static int uvc_ioctl_s_ctrl (struct file *file,void *fh, -struct v4l2_control *ctrl) -{ -struct uvc_fh *handle = fh; -struct uvc_video_chain *chain = handle->chain; -struct v4l2_ext_control xctrl; -int ret; - -memset (&xctrl,0 ,sizeof (xctrl)); - xctrl.id = ctrl->id; - xctrl.value = ctrl->value; - - ret =uvc_ctrl_begin (chain); -if (ret <0 ) -return ret; - - ret =uvc_ctrl_set (handle, &xctrl); -if (ret <0 ) { -uvc_ctrl_rollback (handle); -return ret; - } - - ret =uvc_ctrl_commit (handle, &xctrl,1 ); -if (ret <0 ) -return ret; - - ctrl->value = xctrl.value; -return 0 ; -} -static int uvc_ioctl_g_ext_ctrls (struct file *file,void *fh,struct v4l2_ext_controls *ctrls) {
@@ -1539,8 +1485,6 @@ const struct v4l2_ioctl_ops uvc_ioctl_ops = { .vidioc_s_input = uvc_ioctl_s_input, .vidioc_queryctrl = uvc_ioctl_queryctrl, .vidioc_query_ext_ctrl = uvc_ioctl_query_ext_ctrl, - .vidioc_g_ctrl = uvc_ioctl_g_ctrl, - .vidioc_s_ctrl = uvc_ioctl_s_ctrl, .vidioc_g_ext_ctrls = uvc_ioctl_g_ext_ctrls, .vidioc_s_ext_ctrls = uvc_ioctl_s_ext_ctrls, .vidioc_try_ext_ctrls = uvc_ioctl_try_ext_ctrls,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 285/567 media: uvcvideo: refactor __uvc_ctrl_add_mapping
In reply to Greg Kroah-HartmanFrom: Ricardo Ribalda <[email protected]>
[ Upstream commit 866c6bdd5663d4df7cf384b381b6ef8ba9ffd0e4 ]
Pass the chain instead of the device. We want to keep the reference to the chain that controls belong to.
We need to delay the initialization of the controls after the chains have been initialized.
This is a cleanup needed for the next patches.
Stable-dep-of: 9f582f0418ed ("media: uvcvideo: Check for INACTIVE in uvc_ctrl_is_accessible()")
--- drivers/media/usb/uvc/uvc_ctrl.c | 41 ++++++++++++++++++++---------- drivers/media/usb/uvc/uvc_driver.c | 8 +++--- 2 files changed, 32 insertions(+), 17 deletions(-)
drivers/media/usb/uvc/uvc_ctrl.c +28 -13
@@ -2066,7 +2066,7 @@ static int uvc_ctrl_add_info(struct uvc_device *dev, struct uvc_control *ctrl,/* * Add a control mapping to a given control. */ -static int __uvc_ctrl_add_mapping (struct uvc_device *dev, +static int __uvc_ctrl_add_mapping (struct uvc_video_chain *chain,struct uvc_control *ctrl,const struct uvc_control_mapping *mapping) {struct uvc_control_mapping *map;
@@ -2095,7 +2095,7 @@ static int __uvc_ctrl_add_mapping(struct uvc_device *dev, map->set = uvc_set_le_value;list_add_tail (&map->list, &ctrl->info.mappings); -uvc_dbg (dev,CONTROL ,"Adding mapping '%s' to control %pUl/%u\n" , +uvc_dbg (chain->dev,CONTROL ,"Adding mapping '%s' to control %pUl/%u\n" , map->name, ctrl->info.entity, ctrl->info.selector);return 0 ;
@@ -2177,7 +2177,7 @@ int uvc_ctrl_add_mapping(struct uvc_video_chain *chain, goto done; } - ret =__uvc_ctrl_add_mapping (dev, ctrl, mapping); + ret =__uvc_ctrl_add_mapping (chain, ctrl, mapping);if (ret <0 )atomic_dec (&dev->nmappings);
@@ -2253,7 +2253,8 @@ static void uvc_ctrl_prune_entity(struct uvc_device *dev,* Add control information and hardcoded stock control mappings to the given * device. */ -static void uvc_ctrl_init_ctrl (struct uvc_device *dev,struct uvc_control *ctrl) +static void uvc_ctrl_init_ctrl (struct uvc_video_chain *chain, +struct uvc_control *ctrl) {const struct uvc_control_info *info = uvc_ctrls;const struct uvc_control_info *iend = info +ARRAY_SIZE (uvc_ctrls);
@@ -2272,14 +2273,14 @@ static void uvc_ctrl_init_ctrl(struct uvc_device *dev, struct uvc_control *ctrl)for (; info < iend; ++info) {if (uvc_entity_match_guid (ctrl->entity, info->entity) && ctrl->index == info->index) { -uvc_ctrl_add_info (dev, ctrl, info); +uvc_ctrl_add_info (chain->dev, ctrl, info);/* * Retrieve control flags from the device. Ignore errors * and work with default flag values from the uvc_ctrl * array when the device doesn't properly implement * GET_INFO on standard controls. */ -uvc_ctrl_get_flags (dev, ctrl, &ctrl->info); +uvc_ctrl_get_flags (chain->dev, ctrl, &ctrl->info);break ; } }
@@ -2290,22 +2291,20 @@ static void uvc_ctrl_init_ctrl(struct uvc_device *dev, struct uvc_control *ctrl)for (; mapping < mend; ++mapping) {if (uvc_entity_match_guid (ctrl->entity, mapping->entity) && ctrl->info.selector == mapping->selector) -__uvc_ctrl_add_mapping (dev, ctrl, mapping); +__uvc_ctrl_add_mapping (chain, ctrl, mapping); } }/* * Initialize device controls. */ -int uvc_ctrl_init_device (struct uvc_device *dev) +static int uvc_ctrl_init_chain (struct uvc_video_chain *chain) {struct uvc_entity *entity;unsigned int i; -INIT_WORK (&dev->async_ctrl.work, uvc_ctrl_status_event_work); -/* Walk the entities list and instantiate controls */ -list_for_each_entry (entity, &dev->entities, list) { +list_for_each_entry (entity, &chain->entities, chain) {struct uvc_control *ctrl;unsigned int bControlSize =0 , ncontrols;u8 *bmControls =NULL ;
@@ -2325,7 +2324,7 @@ int uvc_ctrl_init_device(struct uvc_device *dev) }/* Remove bogus/blacklisted controls */ -uvc_ctrl_prune_entity (dev, entity); +uvc_ctrl_prune_entity (chain->dev, entity);/* Count supported controls and allocate the controls array */ ncontrols =memweight (bmControls, bControlSize);
@@ -2347,7 +2346,7 @@ int uvc_ctrl_init_device(struct uvc_device *dev) ctrl->entity = entity; ctrl->index = i; -uvc_ctrl_init_ctrl (dev, ctrl); +uvc_ctrl_init_ctrl (chain, ctrl); ctrl++; } }
@@ -2355,6 +2354,22 @@ int uvc_ctrl_init_device(struct uvc_device *dev)return 0 ; } +int uvc_ctrl_init_device (struct uvc_device *dev) +{ +struct uvc_video_chain *chain; +int ret; + +INIT_WORK (&dev->async_ctrl.work, uvc_ctrl_status_event_work); + +list_for_each_entry (chain, &dev->chains, list) { + ret =uvc_ctrl_init_chain (chain); +if (ret) +return ret; + } + +return 0 ; +} +/* * Cleanup device controls. */
drivers/media/usb/uvc/uvc_driver.c +4 -4
@@ -2455,14 +2455,14 @@ static int uvc_probe(struct usb_interface *intf,if (v4l2_device_register (&intf->dev, &dev->vdev) <0 ) goto error; -/* Initialize controls. */ -if (uvc_ctrl_init_device (dev) <0 ) - goto error; -/* Scan the device for video chains. */ if (uvc_scan_device (dev) <0 ) goto error; +/* Initialize controls. */ +if (uvc_ctrl_init_device (dev) <0 ) + goto error; +/* Register video device nodes. */ if (uvc_register_chains (dev) <0 ) goto error;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 286/567 media: uvcvideo: Add support for V4L2_CTRL_TYPE_CTRL_CLASS
In reply to Greg Kroah-HartmanFrom: Ricardo Ribalda <[email protected]>
[ Upstream commit 9b31ea808a4468d5d606d1f82c58b7e7bfb99f66 ]
Create all the class controls for the device defined controls.
Fixes v4l2-compliance:
Control ioctls (Input 0):
fail: v4l2-test-controls.cpp(216): missing control class for class 00980000
fail: v4l2-test-controls.cpp(216): missing control tclass for class 009a0000
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: FAIL
Stable-dep-of: 9f582f0418ed ("media: uvcvideo: Check for INACTIVE in uvc_ctrl_is_accessible()")
--- drivers/media/usb/uvc/uvc_ctrl.c | 90 ++++++++++++++++++++++++++++++++ drivers/media/usb/uvc/uvcvideo.h | 1 + 2 files changed, 91 insertions(+)
drivers/media/usb/uvc/uvc_ctrl.c +90 -0
@@ -357,6 +357,11 @@ static const struct uvc_control_info uvc_ctrls[] = { }, }; +static const u32 uvc_control_classes[] = { +V4L2_CID_CAMERA_CLASS , +V4L2_CID_USER_CLASS , +}; +static const struct uvc_menu_info power_line_frequency_controls[] = { {0 ,"Disabled" }, {1 ,"50 Hz" },
@@ -1044,6 +1049,49 @@ static int __uvc_ctrl_get(struct uvc_video_chain *chain,return 0 ; } +static int __uvc_query_v4l2_class (struct uvc_video_chain *chain,u32 req_id, +u32 found_id) +{ +bool find_next = req_id &V4L2_CTRL_FLAG_NEXT_CTRL ; +unsigned int i; + + req_id &=V4L2_CTRL_ID_MASK ; + +for (i =0 ; i <ARRAY_SIZE (uvc_control_classes); i++) { +if (!(chain->ctrl_class_bitmap &BIT (i))) +continue ; +if (!find_next) { +if (uvc_control_classes[i] == req_id) +return i; +continue ; + } +if (uvc_control_classes[i] > req_id && + uvc_control_classes[i] < found_id) +return i; + } + +return -ENODEV ; +} + +static int uvc_query_v4l2_class (struct uvc_video_chain *chain,u32 req_id, +u32 found_id,struct v4l2_queryctrl *v4l2_ctrl) +{ +int idx; + + idx =__uvc_query_v4l2_class (chain, req_id, found_id); +if (idx <0 ) +return -ENODEV ; + +memset (v4l2_ctrl,0 ,sizeof (*v4l2_ctrl)); + v4l2_ctrl->id = uvc_control_classes[idx]; +strscpy (v4l2_ctrl->name,v4l2_ctrl_get_name (v4l2_ctrl->id), +sizeof (v4l2_ctrl->name)); + v4l2_ctrl->type =V4L2_CTRL_TYPE_CTRL_CLASS ; + v4l2_ctrl->flags =V4L2_CTRL_FLAG_WRITE_ONLY + |V4L2_CTRL_FLAG_READ_ONLY ; +return 0 ; +} + static int __uvc_query_v4l2_ctrl(struct uvc_video_chain *chain, struct uvc_control *ctrl, struct uvc_control_mapping *mapping,
@@ -1147,12 +1195,31 @@ int uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,if (ret <0 )return -ERESTARTSYS ; +/* Check if the ctrl is a know class */ +if (!(v4l2_ctrl->id &V4L2_CTRL_FLAG_NEXT_CTRL )) { + ret =uvc_query_v4l2_class (chain, v4l2_ctrl->id,0 , v4l2_ctrl); +if (!ret) + goto done; + } + ctrl =uvc_find_control (chain, v4l2_ctrl->id, &mapping);if (ctrl ==NULL ) { ret = -EINVAL ; goto done; } +/* +* If we're enumerating control with V4L2_CTRL_FLAG_NEXT_CTRL, check if +* a class should be inserted between the previous control and the one +* we have just found. +*/ +if (v4l2_ctrl->id &V4L2_CTRL_FLAG_NEXT_CTRL ) { + ret =uvc_query_v4l2_class (chain, v4l2_ctrl->id, mapping->id, + v4l2_ctrl); +if (!ret) + goto done; + } + ret =__uvc_query_v4l2_ctrl (chain, ctrl, mapping, v4l2_ctrl); done:mutex_unlock (&chain->ctrl_mutex);
@@ -1446,6 +1513,11 @@ static int uvc_ctrl_add_event(struct v4l2_subscribed_event *sev, unsigned elems)if (ret <0 )return -ERESTARTSYS ; +if (__uvc_query_v4l2_class (handle->chain, sev->id,0 ) >=0 ) { + ret =0 ; + goto done; + } + ctrl =uvc_find_control (handle->chain, sev->id, &mapping);if (ctrl ==NULL ) { ret = -EINVAL ;
@@ -1479,7 +1551,10 @@ static void uvc_ctrl_del_event(struct v4l2_subscribed_event *sev) struct uvc_fh *handle = container_of(sev->fh, struct uvc_fh, vfh);mutex_lock (&handle->chain->ctrl_mutex); +if (__uvc_query_v4l2_class (handle->chain, sev->id,0 ) >=0 ) + goto done;list_del (&sev->node); +done:mutex_unlock (&handle->chain->ctrl_mutex); }
@@ -1597,6 +1672,9 @@ int uvc_ctrl_get(struct uvc_video_chain *chain,struct uvc_control *ctrl;struct uvc_control_mapping *mapping; +if (__uvc_query_v4l2_class (chain, xctrl->id,0 ) >=0 ) +return -EACCES ; + ctrl =uvc_find_control (chain, xctrl->id, &mapping);if (ctrl ==NULL )return -EINVAL ;
@@ -1616,6 +1694,9 @@ int uvc_ctrl_set(struct uvc_fh *handle,s32 max;int ret; +if (__uvc_query_v4l2_class (chain, xctrl->id,0 ) >=0 ) +return -EACCES ; + ctrl =uvc_find_control (chain, xctrl->id, &mapping);if (ctrl ==NULL )return -EINVAL ;
@@ -2071,6 +2152,7 @@ static int __uvc_ctrl_add_mapping(struct uvc_video_chain *chain, {struct uvc_control_mapping *map;unsigned int size; +unsigned int i;/* Most mappings come from static kernel data and need to be duplicated. * Mappings that come from userspace will be unnecessarily duplicated,
@@ -2094,6 +2176,14 @@ static int __uvc_ctrl_add_mapping(struct uvc_video_chain *chain,if (map->set ==NULL ) map->set = uvc_set_le_value; +for (i =0 ; i <ARRAY_SIZE (uvc_control_classes); i++) { +if (V4L2_CTRL_ID2WHICH (uvc_control_classes[i]) == +V4L2_CTRL_ID2WHICH (map->id)) { + chain->ctrl_class_bitmap |=BIT (i); +break ; + } + } +list_add_tail (&map->list, &ctrl->info.mappings);uvc_dbg (chain->dev,CONTROL ,"Adding mapping '%s' to control %pUl/%u\n" , map->name, ctrl->info.entity, ctrl->info.selector);
drivers/media/usb/uvc/uvcvideo.h +1 -0
@@ -476,6 +476,7 @@ struct uvc_video_chain {struct v4l2_prio_state prio;/* V4L2 priority state */ u32 caps;/* V4L2 chain-wide caps */ +u8 ctrl_class_bitmap;/* Bitmap of valid classes */ };struct uvc_stats_frame {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 287/567 media: uvcvideo: Use control names from framework
In reply to Greg Kroah-HartmanFrom: Ricardo Ribalda <[email protected]>
[ Upstream commit 70fa906d6fceb07a49198d2f31cadecc76787419 ]
The framework already contains a map of IDs to names, lets use it when possible.
Stable-dep-of: 9f582f0418ed ("media: uvcvideo: Check for INACTIVE in uvc_ctrl_is_accessible()")
--- drivers/media/usb/uvc/uvc_ctrl.c | 57 ++++++++++++-------------------- drivers/media/usb/uvc/uvc_v4l2.c | 8 ++++- drivers/media/usb/uvc/uvcvideo.h | 2 +- 3 files changed, 30 insertions(+), 37 deletions(-)
drivers/media/usb/uvc/uvc_ctrl.c +22 -35
@@ -432,7 +432,6 @@ static void uvc_ctrl_set_rel_speed(struct uvc_control_mapping *mapping,static const struct uvc_control_mapping uvc_ctrl_mappings[] = { { .id =V4L2_CID_BRIGHTNESS , - .name ="Brightness" , .entity =UVC_GUID_UVC_PROCESSING , .selector =UVC_PU_BRIGHTNESS_CONTROL , .size =16 ,
@@ -442,7 +441,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { }, { .id = V4L2_CID_CONTRAST, - .name = "Contrast", .entity = UVC_GUID_UVC_PROCESSING, .selector = UVC_PU_CONTRAST_CONTROL, .size = 16,
@@ -452,7 +450,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { }, { .id = V4L2_CID_HUE, - .name = "Hue", .entity = UVC_GUID_UVC_PROCESSING, .selector = UVC_PU_HUE_CONTROL, .size = 16,
@@ -464,7 +461,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { }, { .id = V4L2_CID_SATURATION, - .name = "Saturation", .entity = UVC_GUID_UVC_PROCESSING, .selector = UVC_PU_SATURATION_CONTROL, .size = 16,
@@ -474,7 +470,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { }, { .id = V4L2_CID_SHARPNESS, - .name = "Sharpness", .entity = UVC_GUID_UVC_PROCESSING, .selector = UVC_PU_SHARPNESS_CONTROL, .size = 16,
@@ -484,7 +479,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { }, { .id = V4L2_CID_GAMMA, - .name = "Gamma", .entity = UVC_GUID_UVC_PROCESSING, .selector = UVC_PU_GAMMA_CONTROL, .size = 16,
@@ -494,7 +488,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { }, { .id = V4L2_CID_BACKLIGHT_COMPENSATION, - .name = "Backlight Compensation", .entity = UVC_GUID_UVC_PROCESSING, .selector = UVC_PU_BACKLIGHT_COMPENSATION_CONTROL, .size = 16,
@@ -504,7 +497,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { }, { .id = V4L2_CID_GAIN, - .name = "Gain", .entity = UVC_GUID_UVC_PROCESSING, .selector = UVC_PU_GAIN_CONTROL, .size = 16,
@@ -514,7 +506,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { }, { .id = V4L2_CID_POWER_LINE_FREQUENCY, - .name = "Power Line Frequency", .entity = UVC_GUID_UVC_PROCESSING, .selector = UVC_PU_POWER_LINE_FREQUENCY_CONTROL, .size = 2,
@@ -526,7 +517,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { }, { .id = V4L2_CID_HUE_AUTO, - .name = "Hue, Auto", .entity = UVC_GUID_UVC_PROCESSING, .selector = UVC_PU_HUE_AUTO_CONTROL, .size = 1,
@@ -537,7 +527,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { }, { .id = V4L2_CID_EXPOSURE_AUTO, - .name = "Exposure, Auto", .entity = UVC_GUID_UVC_CAMERA, .selector = UVC_CT_AE_MODE_CONTROL, .size = 4,
@@ -550,7 +539,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { }, { .id = V4L2_CID_EXPOSURE_AUTO_PRIORITY, - .name = "Exposure, Auto Priority", .entity = UVC_GUID_UVC_CAMERA, .selector = UVC_CT_AE_PRIORITY_CONTROL, .size = 1,
@@ -560,7 +548,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { }, { .id = V4L2_CID_EXPOSURE_ABSOLUTE, - .name = "Exposure (Absolute)", .entity = UVC_GUID_UVC_CAMERA, .selector = UVC_CT_EXPOSURE_TIME_ABSOLUTE_CONTROL, .size = 32,
@@ -572,7 +559,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { }, { .id = V4L2_CID_AUTO_WHITE_BALANCE, - .name = "White Balance Temperature, Auto", .entity = UVC_GUID_UVC_PROCESSING, .selector = UVC_PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL, .size = 1,
@@ -583,7 +569,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { }, { .id = V4L2_CID_WHITE_BALANCE_TEMPERATURE, - .name = "White Balance Temperature", .entity = UVC_GUID_UVC_PROCESSING, .selector = UVC_PU_WHITE_BALANCE_TEMPERATURE_CONTROL, .size = 16,
@@ -595,7 +580,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { }, { .id = V4L2_CID_AUTO_WHITE_BALANCE, - .name = "White Balance Component, Auto", .entity = UVC_GUID_UVC_PROCESSING, .selector = UVC_PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL, .size = 1,
@@ -607,7 +591,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { }, { .id = V4L2_CID_BLUE_BALANCE, - .name = "White Balance Blue Component", .entity = UVC_GUID_UVC_PROCESSING, .selector = UVC_PU_WHITE_BALANCE_COMPONENT_CONTROL, .size = 16,
@@ -619,7 +602,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { }, { .id = V4L2_CID_RED_BALANCE, - .name = "White Balance Red Component", .entity = UVC_GUID_UVC_PROCESSING, .selector = UVC_PU_WHITE_BALANCE_COMPONENT_CONTROL, .size = 16,
@@ -631,7 +613,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { }, { .id = V4L2_CID_FOCUS_ABSOLUTE, - .name = "Focus (absolute)", .entity = UVC_GUID_UVC_CAMERA, .selector = UVC_CT_FOCUS_ABSOLUTE_CONTROL, .size = 16,
@@ -643,7 +624,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { }, { .id = V4L2_CID_FOCUS_AUTO, - .name = "Focus, Auto", .entity = UVC_GUID_UVC_CAMERA, .selector = UVC_CT_FOCUS_AUTO_CONTROL, .size = 1,
@@ -654,7 +634,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { }, { .id = V4L2_CID_IRIS_ABSOLUTE, - .name = "Iris, Absolute", .entity = UVC_GUID_UVC_CAMERA, .selector = UVC_CT_IRIS_ABSOLUTE_CONTROL, .size = 16,
@@ -664,7 +643,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { }, { .id = V4L2_CID_IRIS_RELATIVE, - .name = "Iris, Relative", .entity = UVC_GUID_UVC_CAMERA, .selector = UVC_CT_IRIS_RELATIVE_CONTROL, .size = 8,
@@ -674,7 +652,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { }, { .id = V4L2_CID_ZOOM_ABSOLUTE, - .name = "Zoom, Absolute", .entity = UVC_GUID_UVC_CAMERA, .selector = UVC_CT_ZOOM_ABSOLUTE_CONTROL, .size = 16,
@@ -684,7 +661,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { }, { .id = V4L2_CID_ZOOM_CONTINUOUS, - .name = "Zoom, Continuous", .entity = UVC_GUID_UVC_CAMERA, .selector = UVC_CT_ZOOM_RELATIVE_CONTROL, .size = 0,
@@ -696,7 +672,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { }, { .id = V4L2_CID_PAN_ABSOLUTE, - .name = "Pan (Absolute)", .entity = UVC_GUID_UVC_CAMERA, .selector = UVC_CT_PANTILT_ABSOLUTE_CONTROL, .size = 32,
@@ -706,7 +681,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { }, { .id = V4L2_CID_TILT_ABSOLUTE, - .name = "Tilt (Absolute)", .entity = UVC_GUID_UVC_CAMERA, .selector = UVC_CT_PANTILT_ABSOLUTE_CONTROL, .size = 32,
@@ -716,7 +690,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { }, { .id = V4L2_CID_PAN_SPEED, - .name = "Pan (Speed)", .entity = UVC_GUID_UVC_CAMERA, .selector = UVC_CT_PANTILT_RELATIVE_CONTROL, .size = 16,
@@ -728,7 +701,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { }, { .id = V4L2_CID_TILT_SPEED, - .name = "Tilt (Speed)", .entity = UVC_GUID_UVC_CAMERA, .selector = UVC_CT_PANTILT_RELATIVE_CONTROL, .size = 16,
@@ -740,7 +712,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { }, { .id = V4L2_CID_PRIVACY, - .name = "Privacy", .entity = UVC_GUID_UVC_CAMERA, .selector = UVC_CT_PRIVACY_CONTROL, .size = 1,
@@ -750,7 +721,6 @@ static const struct uvc_control_mapping uvc_ctrl_mappings[] = { }, { .id = V4L2_CID_PRIVACY, - .name = "Privacy", .entity = UVC_GUID_EXT_GPIO_CONTROLLER, .selector = UVC_CT_PRIVACY_CONTROL, .size = 1,
@@ -1092,6 +1062,20 @@ static int uvc_query_v4l2_class(struct uvc_video_chain *chain, u32 req_id,return 0 ; } +static const char *uvc_map_get_name (const struct uvc_control_mapping *map) +{ +const char *name; + +if (map->name) +return map->name; + + name =v4l2_ctrl_get_name (map->id); +if (name) +return name; + +return "Unknown Control" ; +} + static int __uvc_query_v4l2_ctrl(struct uvc_video_chain *chain, struct uvc_control *ctrl, struct uvc_control_mapping *mapping,
@@ -1105,7 +1089,8 @@ static int __uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,memset (v4l2_ctrl,0 ,sizeof (*v4l2_ctrl)); v4l2_ctrl->id = mapping->id; v4l2_ctrl->type = mapping->v4l2_type; -strscpy (v4l2_ctrl->name, mapping->name,sizeof (v4l2_ctrl->name)); +strscpy (v4l2_ctrl->name,uvc_map_get_name (mapping), +sizeof (v4l2_ctrl->name)); v4l2_ctrl->flags =0 ;if (!(ctrl->info.flags &UVC_CTRL_FLAG_GET_CUR ))
@@ -2186,7 +2171,8 @@ static int __uvc_ctrl_add_mapping(struct uvc_video_chain *chain,list_add_tail (&map->list, &ctrl->info.mappings);uvc_dbg (chain->dev,CONTROL ,"Adding mapping '%s' to control %pUl/%u\n" , - map->name, ctrl->info.entity, ctrl->info.selector); +uvc_map_get_name (map), ctrl->info.entity, + ctrl->info.selector);return 0 ; }
@@ -2204,7 +2190,7 @@ int uvc_ctrl_add_mapping(struct uvc_video_chain *chain,if (mapping->id & ~V4L2_CTRL_ID_MASK ) {uvc_dbg (dev,CONTROL ,"Can't add mapping '%s', control id 0x%08x is invalid\n" , - mapping->name, mapping->id); +uvc_map_get_name (mapping), mapping->id);return -EINVAL ; }
@@ -2251,7 +2237,7 @@ int uvc_ctrl_add_mapping(struct uvc_video_chain *chain,if (mapping->id == map->id) {uvc_dbg (dev,CONTROL ,"Can't add mapping '%s', control id 0x%08x already exists\n" , - mapping->name, mapping->id); +uvc_map_get_name (mapping), mapping->id); ret = -EEXIST ; goto done; }
@@ -2262,7 +2248,7 @@ int uvc_ctrl_add_mapping(struct uvc_video_chain *chain,atomic_dec (&dev->nmappings);uvc_dbg (dev,CONTROL ,"Can't add mapping '%s', maximum mappings count (%u) exceeded\n" , - mapping->name,UVC_MAX_CONTROL_MAPPINGS ); +uvc_map_get_name (mapping),UVC_MAX_CONTROL_MAPPINGS ); ret = -ENOMEM ; goto done; }
@@ -2471,6 +2457,7 @@ static void uvc_ctrl_cleanup_mappings(struct uvc_device *dev,list_for_each_entry_safe (mapping, nm, &ctrl->info.mappings, list) {list_del (&mapping->list);kfree (mapping->menu_info); +kfree (mapping->name);kfree (mapping); } }
drivers/media/usb/uvc/uvc_v4l2.c +7 -1
@@ -40,7 +40,13 @@ static int uvc_ioctl_ctrl_map(struct uvc_video_chain *chain,return -ENOMEM ; map->id = xmap->id; -memcpy (map->name, xmap->name,sizeof (map->name)); +/* Non standard control id. */ +if (v4l2_ctrl_get_name (map->id) ==NULL ) { + map->name =kmemdup (xmap->name,sizeof (xmap->name), +GFP_KERNEL ); +if (!map->name) +return -ENOMEM ; + }memcpy (map->entity, xmap->entity,sizeof (map->entity)); map->selector = xmap->selector; map->size = xmap->size;
drivers/media/usb/uvc/uvcvideo.h +1 -1
@@ -241,7 +241,7 @@ struct uvc_control_mapping {struct list_head ev_subs;u32 id; -u8 name[32 ]; +char *name;u8 entity[16 ];u8 selector;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 288/567 media: uvcvideo: Check controls flags before accessing them
In reply to Greg Kroah-HartmanFrom: Ricardo Ribalda <[email protected]>
[ Upstream commit ee929d5a10ca433a1c21b9aaeb70a67c5507c101 ]
We can figure out if reading/writing a set of controls can fail without accessing them by checking their flags.
This way we can honor the API closer:
If an error is found when validating the list of controls passed with VIDIOC_G_EXT_CTRLS, then error_idx shall be set to ctrls->count to indicate to userspace that no actual hardware was touched.
Fixes v4l2-compliance:
Control ioctls (Input 0):
warn: v4l2-test-controls.cpp(765): g_ext_ctrls(0) invalid error_idx 0
fail: v4l2-test-controls.cpp(645): invalid error index write only control
test VIDIOC_G/S/TRY_EXT_CTRLS: FAIL
Stable-dep-of: 9f582f0418ed ("media: uvcvideo: Check for INACTIVE in uvc_ctrl_is_accessible()")
--- drivers/media/usb/uvc/uvc_ctrl.c | 22 ++++++++++++++++++ drivers/media/usb/uvc/uvc_v4l2.c | 39 ++++++++++++++++++++++++++++---- drivers/media/usb/uvc/uvcvideo.h | 2 ++ 3 files changed, 58 insertions(+), 5 deletions(-)
drivers/media/usb/uvc/uvc_ctrl.c +22 -0
@@ -1062,6 +1062,28 @@ static int uvc_query_v4l2_class(struct uvc_video_chain *chain, u32 req_id,return 0 ; } +int uvc_ctrl_is_accessible (struct uvc_video_chain *chain,u32 v4l2_id, +bool read) +{ +struct uvc_control_mapping *mapping; +struct uvc_control *ctrl; + +if (__uvc_query_v4l2_class (chain, v4l2_id,0 ) >=0 ) +return -EACCES ; + + ctrl =uvc_find_control (chain, v4l2_id, &mapping); +if (!ctrl) +return -EINVAL ; + +if (!(ctrl->info.flags &UVC_CTRL_FLAG_GET_CUR ) && read) +return -EACCES ; + +if (!(ctrl->info.flags &UVC_CTRL_FLAG_SET_CUR ) && !read) +return -EACCES ; + +return 0 ; +} +static const char *uvc_map_get_name (const struct uvc_control_mapping *map) {const char *name;
drivers/media/usb/uvc/uvc_v4l2.c +34 -5
@@ -1006,6 +1006,26 @@ static int uvc_ioctl_query_ext_ctrl(struct file *file, void *fh,return 0 ; } +static int uvc_ctrl_check_access (struct uvc_video_chain *chain, +struct v4l2_ext_controls *ctrls, +unsigned long ioctl) +{ +struct v4l2_ext_control *ctrl = ctrls->controls; +unsigned int i; +int ret =0 ; + +for (i =0 ; i < ctrls->count; ++ctrl, ++i) { + ret =uvc_ctrl_is_accessible (chain, ctrl->id, + ioctl ==VIDIOC_G_EXT_CTRLS ); +if (ret) +break ; + } + + ctrls->error_idx = ioctl ==VIDIOC_TRY_EXT_CTRLS ? i : ctrls->count; + +return ret; +} +static int uvc_ioctl_g_ext_ctrls (struct file *file,void *fh,struct v4l2_ext_controls *ctrls) {
@@ -1015,6 +1035,10 @@ static int uvc_ioctl_g_ext_ctrls(struct file *file, void *fh,unsigned int i;int ret; + ret =uvc_ctrl_check_access (chain, ctrls,VIDIOC_G_EXT_CTRLS ); +if (ret <0 ) +return ret; +if (ctrls->which ==V4L2_CTRL_WHICH_DEF_VAL ) {for (i =0 ; i < ctrls->count; ++ctrl, ++i) {struct v4l2_queryctrl qc = { .id = ctrl->id };
@@ -1051,13 +1075,17 @@ static int uvc_ioctl_g_ext_ctrls(struct file *file, void *fh,static int uvc_ioctl_s_try_ext_ctrls (struct uvc_fh *handle,struct v4l2_ext_controls *ctrls, -bool commit) +unsigned long ioctl) {struct v4l2_ext_control *ctrl = ctrls->controls;struct uvc_video_chain *chain = handle->chain;unsigned int i;int ret; + ret =uvc_ctrl_check_access (chain, ctrls, ioctl); +if (ret <0 ) +return ret; + ret =uvc_ctrl_begin (chain);if (ret <0 )return ret;
@@ -1066,14 +1094,15 @@ static int uvc_ioctl_s_try_ext_ctrls(struct uvc_fh *handle, ret =uvc_ctrl_set (handle, ctrl);if (ret <0 ) {uvc_ctrl_rollback (handle); - ctrls->error_idx = commit ? ctrls->count : i; + ctrls->error_idx = ioctl ==VIDIOC_S_EXT_CTRLS ? + ctrls->count : i;return ret; } } ctrls->error_idx =0 ; -if (commit) +if (ioctl ==VIDIOC_S_EXT_CTRLS )return uvc_ctrl_commit (handle, ctrls->controls, ctrls->count);else return uvc_ctrl_rollback (handle);
@@ -1084,7 +1113,7 @@ static int uvc_ioctl_s_ext_ctrls(struct file *file, void *fh, {struct uvc_fh *handle = fh; -return uvc_ioctl_s_try_ext_ctrls (handle, ctrls, true); +return uvc_ioctl_s_try_ext_ctrls (handle, ctrls,VIDIOC_S_EXT_CTRLS ); } static int uvc_ioctl_try_ext_ctrls(struct file *file, void *fh,
@@ -1092,7 +1121,7 @@ static int uvc_ioctl_try_ext_ctrls(struct file *file, void *fh, {struct uvc_fh *handle = fh; -return uvc_ioctl_s_try_ext_ctrls (handle, ctrls, false); +return uvc_ioctl_s_try_ext_ctrls (handle, ctrls,VIDIOC_TRY_EXT_CTRLS ); } static int uvc_ioctl_querymenu(struct file *file, void *fh,
drivers/media/usb/uvc/uvcvideo.h +2 -0
@@ -901,6 +901,8 @@ static inline int uvc_ctrl_rollback(struct uvc_fh *handle)int uvc_ctrl_get (struct uvc_video_chain *chain,struct v4l2_ext_control *xctrl);int uvc_ctrl_set (struct uvc_fh *handle,struct v4l2_ext_control *xctrl); +int uvc_ctrl_is_accessible (struct uvc_video_chain *chain,u32 v4l2_id, +bool read);int uvc_xu_ctrl_query (struct uvc_video_chain *chain,struct uvc_xu_control_query *xqry);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 289/567 media: uvcvideo: Check for INACTIVE in uvc_ctrl_is_accessible()
In reply to Greg Kroah-HartmanFrom: Hans Verkuil <[email protected]>
[ Upstream commit 9f582f0418ed1c18f92c9e4628075d6ec9a7d9fb ]
Check for inactive controls in uvc_ctrl_is_accessible().
Use the new value for the master_id controls if present, otherwise use the existing value to determine if it is OK to set the control. Doing this here avoids attempting to set an inactive control, which will return an error from the USB device, which returns an invalid errorcode.
This fixes:
warn: v4l2-test-controls.cpp(483): s_ctrl returned EIO
warn: v4l2-test-controls.cpp(483): s_ctrl returned EIO test VIDIOC_G/S_CTRL: OK
warn: v4l2-test-controls.cpp(739): s_ext_ctrls returned EIO
warn: v4l2-test-controls.cpp(739): s_ext_ctrls returned EIO
warn: v4l2-test-controls.cpp(816): s_ext_ctrls returned EIO test VIDIOC_G/S/TRY_EXT_CTRLS: OK
Tested with:
v4l2-ctl -c auto_exposure=1
OK
v4l2-ctl -c exposure_time_absolute=251
OK
v4l2-ctl -c auto_exposure=3
OK
v4l2-ctl -c exposure_time_absolute=251VIDIOC_S_EXT_CTRLS: failed: Input/output errorexposure_time_absolute: Input/output error
ERROR
v4l2-ctl -c auto_exposure=3,exposure_time_absolute=251,auto_exposure=1 v4l2-ctl -C auto_exposure,exposure_time_absoluteauto_exposure: 1exposure_time_absolute: 251
--- drivers/media/usb/uvc/uvc_ctrl.c | 42 +++++++++++++++++++++++++++++++- drivers/media/usb/uvc/uvc_v4l2.c | 3 +-- drivers/media/usb/uvc/uvcvideo.h | 3 ++- 3 files changed, 44 insertions(+), 4 deletions(-)
drivers/media/usb/uvc/uvc_ctrl.c +41 -1
@@ -1062,11 +1062,28 @@ static int uvc_query_v4l2_class(struct uvc_video_chain *chain, u32 req_id,return 0 ; } +/* +* Check if control @v4l2_id can be accessed by the given control @ioctl +* (VIDIOC_G_EXT_CTRLS, VIDIOC_TRY_EXT_CTRLS or VIDIOC_S_EXT_CTRLS). +* +* For set operations on slave controls, check if the master's value is set to +* manual, either in the others controls set in the same ioctl call, or from +* the master's current value. This catches VIDIOC_S_EXT_CTRLS calls that set +* both the master and slave control, such as for instance setting +* auto_exposure=1, exposure_time_absolute=251. +*/ int uvc_ctrl_is_accessible (struct uvc_video_chain *chain,u32 v4l2_id, -bool read) +const struct v4l2_ext_controls *ctrls, +unsigned long ioctl) { +struct uvc_control_mapping *master_map =NULL ; +struct uvc_control *master_ctrl =NULL ;struct uvc_control_mapping *mapping;struct uvc_control *ctrl; +bool read = ioctl ==VIDIOC_G_EXT_CTRLS ; +s32 val; +int ret; +int i;if (__uvc_query_v4l2_class (chain, v4l2_id,0 ) >=0 )return -EACCES ;
@@ -1081,6 +1098,29 @@ int uvc_ctrl_is_accessible(struct uvc_video_chain *chain, u32 v4l2_id,if (!(ctrl->info.flags &UVC_CTRL_FLAG_SET_CUR ) && !read)return -EACCES ; +if (ioctl !=VIDIOC_S_EXT_CTRLS || !mapping->master_id) +return 0 ; + +/* +* Iterate backwards in cases where the master control is accessed +* multiple times in the same ioctl. We want the last value. +*/ +for (i = ctrls->count -1 ; i >=0 ; i--) { +if (ctrls->controls[i].id == mapping->master_id) +return ctrls->controls[i].value == + mapping->master_manual ?0 : -EACCES ; + } + +__uvc_find_control (ctrl->entity, mapping->master_id, &master_map, + &master_ctrl,0 ); + +if (!master_ctrl || !(master_ctrl->info.flags &UVC_CTRL_FLAG_GET_CUR )) +return 0 ; + + ret =__uvc_ctrl_get (chain, master_ctrl, master_map, &val); +if (ret >=0 && val != mapping->master_manual) +return -EACCES ; +return 0 ; }
drivers/media/usb/uvc/uvc_v4l2.c +1 -2
@@ -1015,8 +1015,7 @@ static int uvc_ctrl_check_access(struct uvc_video_chain *chain,int ret =0 ;for (i =0 ; i < ctrls->count; ++ctrl, ++i) { - ret =uvc_ctrl_is_accessible (chain, ctrl->id, - ioctl ==VIDIOC_G_EXT_CTRLS ); + ret =uvc_ctrl_is_accessible (chain, ctrl->id, ctrls, ioctl);if (ret)break ; }
drivers/media/usb/uvc/uvcvideo.h +2 -1
@@ -902,7 +902,8 @@ static inline int uvc_ctrl_rollback(struct uvc_fh *handle)int uvc_ctrl_get (struct uvc_video_chain *chain,struct v4l2_ext_control *xctrl);int uvc_ctrl_set (struct uvc_fh *handle,struct v4l2_ext_control *xctrl);int uvc_ctrl_is_accessible (struct uvc_video_chain *chain,u32 v4l2_id, -bool read); +const struct v4l2_ext_controls *ctrls, +unsigned long ioctl);int uvc_xu_ctrl_query (struct uvc_video_chain *chain,struct uvc_xu_control_query *xqry);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 290/567 coresight: etm4x: Fix accesses to TRCSEQRSTEVR and TRCSEQSTR
In reply to Greg Kroah-HartmanFrom: Junhao He <[email protected]>
[ Upstream commit 589d928248b72f8377d45904a14bcf686aa8bbeb ]
The TRCSEQRSTEVR and TRCSEQSTR registers are not implemented if the TRCIDR5.NUMSEQSTATE == 0. Skip accessing the registers in such cases.
--- .../hwtracing/coresight/coresight-etm4x-core.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/hwtracing/coresight/coresight-etm4x-core.c +12 -6
@@ -384,8 +384,10 @@ static int etm4_enable_hw(struct etmv4_drvdata *drvdata)etm4x_relaxed_write32 (csa, config->vipcssctlr,TRCVIPCSSCTLR );for (i =0 ; i < drvdata->nrseqstate -1 ; i++)etm4x_relaxed_write32 (csa, config->seq_ctrl[i],TRCSEQEVRn (i)); -etm4x_relaxed_write32 (csa, config->seq_rst,TRCSEQRSTEVR ); -etm4x_relaxed_write32 (csa, config->seq_state,TRCSEQSTR ); +if (drvdata->nrseqstate) { +etm4x_relaxed_write32 (csa, config->seq_rst,TRCSEQRSTEVR ); +etm4x_relaxed_write32 (csa, config->seq_state,TRCSEQSTR ); + }etm4x_relaxed_write32 (csa, config->ext_inp,TRCEXTINSELR );for (i =0 ; i < drvdata->nr_cntr; i++) {etm4x_relaxed_write32 (csa, config->cntrldvr[i],TRCCNTRLDVRn (i));
@@ -1618,8 +1620,10 @@ static int etm4_cpu_save(struct etmv4_drvdata *drvdata)for (i =0 ; i < drvdata->nrseqstate -1 ; i++) state->trcseqevr[i] =etm4x_read32 (csa,TRCSEQEVRn (i)); - state->trcseqrstevr =etm4x_read32 (csa,TRCSEQRSTEVR ); - state->trcseqstr =etm4x_read32 (csa,TRCSEQSTR ); +if (drvdata->nrseqstate) { + state->trcseqrstevr =etm4x_read32 (csa,TRCSEQRSTEVR ); + state->trcseqstr =etm4x_read32 (csa,TRCSEQSTR ); + } state->trcextinselr =etm4x_read32 (csa,TRCEXTINSELR );for (i =0 ; i < drvdata->nr_cntr; i++) {
@@ -1731,8 +1735,10 @@ static void etm4_cpu_restore(struct etmv4_drvdata *drvdata)for (i =0 ; i < drvdata->nrseqstate -1 ; i++)etm4x_relaxed_write32 (csa, state->trcseqevr[i],TRCSEQEVRn (i)); -etm4x_relaxed_write32 (csa, state->trcseqrstevr,TRCSEQRSTEVR ); -etm4x_relaxed_write32 (csa, state->trcseqstr,TRCSEQSTR ); +if (drvdata->nrseqstate) { +etm4x_relaxed_write32 (csa, state->trcseqrstevr,TRCSEQRSTEVR ); +etm4x_relaxed_write32 (csa, state->trcseqstr,TRCSEQSTR ); + }etm4x_relaxed_write32 (csa, state->trcextinselr,TRCEXTINSELR );for (i =0 ; i < drvdata->nr_cntr; i++) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 291/567 coresight: cti: Prevent negative values of enable count
In reply to Greg Kroah-HartmanFrom: James Clark <[email protected]>
[ Upstream commit 3244fb6dbbf1ffc114cdf382cc167bdd8c18088a ]
Writing 0 to the enable control repeatedly results in a negative value for enable_req_count. After this, writing 1 to the enable control appears to not work until the count returns to positive.
Change it so that it's impossible for enable_req_count to be < 0. Return an error to indicate that the disable request was invalid.
--- drivers/hwtracing/coresight/coresight-cti-core.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/hwtracing/coresight/coresight-cti-core.c +9 -2
@@ -151,9 +151,16 @@ static int cti_disable_hw(struct cti_drvdata *drvdata) {struct cti_config *config = &drvdata->config;struct coresight_device *csdev = drvdata->csdev; +int ret =0 ;spin_lock (&drvdata->spinlock); +/* don't allow negative refcounts, return an error */ +if (!atomic_read (&drvdata->config.enable_req_count)) { + ret = -EINVAL ; + goto cti_not_disabled; + } +/* check refcount - disable on 0 */ if (atomic_dec_return (&drvdata->config.enable_req_count) >0 ) goto cti_not_disabled;
@@ -171,12 +178,12 @@ static int cti_disable_hw(struct cti_drvdata *drvdata)coresight_disclaim_device_unlocked (csdev);CS_LOCK (drvdata->base);spin_unlock (&drvdata->spinlock); -return 0 ; +return ret;/* not disabled this call */ cti_not_disabled:spin_unlock (&drvdata->spinlock); -return 0 ; +return ret; }void cti_write_single_reg (struct cti_drvdata *drvdata,int offset,u32 value)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 292/567 coresight: cti: Add PM runtime call in enable_store
In reply to Greg Kroah-HartmanFrom: Mao Jinlong <[email protected]>
[ Upstream commit eff674a9b86a6ffdd10c3af3863545acf7f1ce4f ]
In commit 6746eae4bbad ("coresight: cti: Fix hang in cti_disable_hw()") PM runtime calls are removed from cti_enable_hw/cti_disable_hw. When enabling CTI by writing enable sysfs node, clock for accessing CTI register won't be enabled. Device will crash due to register access issue. Add PM runtime call in enable_store to fix this issue.
--- drivers/hwtracing/coresight/coresight-cti-sysfs.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/hwtracing/coresight/coresight-cti-sysfs.c +11 -2
@@ -108,10 +108,19 @@ static ssize_t enable_store(struct device *dev,if (ret)return ret; -if (val) +if (val) { + ret =pm_runtime_resume_and_get (dev->parent); +if (ret) +return ret; ret =cti_enable (drvdata->csdev); -else +if (ret) +pm_runtime_put (dev->parent); + }else { ret =cti_disable (drvdata->csdev); +if (!ret) +pm_runtime_put (dev->parent); + } +if (ret)return ret;return size;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 293/567 ACPI: resource: Add helper function acpi_dev_get_memory_resources()
In reply to Greg Kroah-HartmanFrom: Heikki Krogerus <[email protected]>
[ Upstream commit 6bb057bfd9d509755349cd2a6ca5e5e6e6071304 ]
Wrapper function that finds all memory type resources by using acpi_dev_get_resources(). It removes the need for the drivers to check the resource data type separately.
Stable-dep-of: c3194949ae8f ("usb: typec: intel_pmc_mux: Don't leak the ACPI device reference count")
--- drivers/acpi/resource.c | 17 +++++++++++++++++ include/linux/acpi.h | 1 + 2 files changed, 18 insertions(+)
drivers/acpi/resource.c +17 -0
@@ -788,6 +788,23 @@ int acpi_dev_get_dma_resources(struct acpi_device *adev, struct list_head *list) }EXPORT_SYMBOL_GPL (acpi_dev_get_dma_resources); +/** +* acpi_dev_get_memory_resources - Get current memory resources of a device. +* @adev: ACPI device node to get the resources for. +* @list: Head of the resultant list of resources (must be empty). +* +* This is a helper function that locates all memory type resources of @adev +* with acpi_dev_get_resources(). +* +* The number of resources in the output list is returned on success, an error +* code reflecting the error condition is returned otherwise. +*/ +int acpi_dev_get_memory_resources (struct acpi_device *adev,struct list_head *list) +{ +return acpi_dev_get_resources (adev, list, is_memory,NULL ); +} +EXPORT_SYMBOL_GPL (acpi_dev_get_memory_resources); +/** * acpi_dev_filter_resource_type - Filter ACPI resource according to resource * types
include/linux/acpi.h +1 -0
@@ -484,6 +484,7 @@ int acpi_dev_get_resources(struct acpi_device *adev, struct list_head *list, void *preproc_data);int acpi_dev_get_dma_resources (struct acpi_device *adev,struct list_head *list); +int acpi_dev_get_memory_resources (struct acpi_device *adev,struct list_head *list);int acpi_dev_filter_resource_type (struct acpi_resource *ares,unsigned long types);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 294/567 usb: typec: intel_pmc_mux: Use the helper acpi_dev_get_memory_resources()
In reply to Greg Kroah-HartmanFrom: Heikki Krogerus <[email protected]>
[ Upstream commit 1538dc8c1561f0de4ba57a69e2a421a1a3951618 ]
It removes the need to check the resource data type separately.
Stable-dep-of: c3194949ae8f ("usb: typec: intel_pmc_mux: Don't leak the ACPI device reference count")
--- drivers/usb/typec/mux/intel_pmc_mux.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
drivers/usb/typec/mux/intel_pmc_mux.c +1 -10
@@ -563,15 +563,6 @@ static int pmc_usb_register_port(struct pmc_usb *pmc, int index,return ret; } -static int is_memory (struct acpi_resource *res,void *data) -{ -struct resource_win win = {}; -struct resource *r = &win.res; - -return !(acpi_dev_resource_memory (res, r) || -acpi_dev_resource_address_space (res, &win)); -} -/* IOM ACPI IDs and IOM_PORT_STATUS_OFFSET */ static const struct acpi_device_id iom_acpi_ids[] = {/* TigerLake */
@@ -605,7 +596,7 @@ static int pmc_usb_probe_iom(struct pmc_usb *pmc)return -ENODEV ;INIT_LIST_HEAD (&resource_list); - ret =acpi_dev_get_resources (adev, &resource_list, is_memory,NULL ); + ret =acpi_dev_get_memory_resources (adev, &resource_list);if (ret <0 )return ret;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 295/567 usb: typec: intel_pmc_mux: Dont leak the ACPI device reference count
In reply to Greg Kroah-HartmanFrom: Andy Shevchenko <[email protected]>
[ Upstream commit c3194949ae8fcbe2b7e38670e7c6a5cfd2605edc ]
When acpi_dev_get_memory_resources() fails, the reference count is left bumped. Drop it as it's done in the other error paths.
--- drivers/usb/typec/mux/intel_pmc_mux.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/typec/mux/intel_pmc_mux.c +3 -1
@@ -597,8 +597,10 @@ static int pmc_usb_probe_iom(struct pmc_usb *pmc)INIT_LIST_HEAD (&resource_list); ret =acpi_dev_get_memory_resources (adev, &resource_list); -if (ret <0 ) +if (ret <0 ) { +acpi_dev_put (adev);return ret; + } rentry = list_first_entry_or_null(&resource_list, struct resource_entry, node);if (rentry)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 296/567 PCI/IOV: Enlarge virtfn sysfs name buffer
In reply to Greg Kroah-HartmanFrom: Alexey V. Vissarionov <[email protected]>
[ Upstream commit ea0b5aa5f184cf8293c93163f0fb00505190d431 ]
The sysfs link name "virtfn%u" constructed by pci_iov_sysfs_link() requires 17 bytes to contain the longest possible string. Increase VIRTFN_ID_LEN to accommodate that.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/pci/iov.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/iov.c +1 -1
@@ -14,7 +14,7 @@#include <linux/delay.h> #include "pci.h" -#define VIRTFN_ID_LEN 16 +#define VIRTFN_ID_LEN 17/* "virtfn%u\0" for 2^32 - 1 */ int pci_iov_virtfn_bus (struct pci_dev *dev,int vf_id) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 297/567 PCI: switchtec: Return -EFAULT for copy_to_user() errors
In reply to Greg Kroah-HartmanFrom: Bjorn Helgaas <[email protected]>
[ Upstream commit ddc10938e08cd7aac63d8385f7305f7889df5179 ]
switchtec_dev_read() didn't handle copy_to_user() errors correctly: it assigned "rc = -EFAULT", but actually returned either "size", -ENXIO, or -EBADMSG instead.
Update the failure cases to unlock mrpc_mutex and return -EFAULT directly.
--- drivers/pci/switch/switchtec.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/pci/switch/switchtec.c +4 -5
@@ -552,21 +552,20 @@ static ssize_t switchtec_dev_read(struct file *filp, char __user *data, rc =copy_to_user (data, &stuser->return_code,sizeof (stuser->return_code));if (rc) { - rc = -EFAULT ; - goto out; +mutex_unlock (&stdev->mrpc_mutex); +return -EFAULT ; } data +=sizeof (stuser->return_code); rc =copy_to_user (data, &stuser->data, size -sizeof (stuser->return_code));if (rc) { - rc = -EFAULT ; - goto out; +mutex_unlock (&stdev->mrpc_mutex); +return -EFAULT ; }stuser_set_state (stuser,MRPC_IDLE ); -out:mutex_unlock (&stdev->mrpc_mutex);if (stuser->status ==SWITCHTEC_MRPC_STATUS_DONE )
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 298/567 tty: serial: fsl_lpuart: disable Rx/Tx DMA in lpuart32_shutdown()
In reply to Greg Kroah-HartmanFrom: Sherry Sun <[email protected]>
[ Upstream commit 1d4bd0e4ae4ba95892bef919a8d4d3f08f122d7e ]
UARTBAUD_RDMAE and UARTBAUD_TDMAE are enabled in lpuart32_startup(), but lpuart32_shutdown() not disable them, only free the dma ring buffer and release the dma channels, so here disable the Rx/Tx DMA first in lpuart32_shutdown().
--- drivers/tty/serial/fsl_lpuart.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/tty/serial/fsl_lpuart.c +5 -0
@@ -1807,6 +1807,11 @@ static void lpuart32_shutdown(struct uart_port *port)spin_lock_irqsave (&port->lock, flags); +/* disable Rx/Tx DMA */ + temp =lpuart32_read (port,UARTBAUD ); + temp &= ~(UARTBAUD_TDMAE |UARTBAUD_RDMAE ); +lpuart32_write (port, temp,UARTBAUD ); +/* disable Rx/Tx and interrupts */ temp =lpuart32_read (port,UARTCTRL ); temp &= ~(UARTCTRL_TE | UARTCTRL_RE |
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 299/567 tty: serial: fsl_lpuart: clear LPUART Status Register in lpuart32_shutdown()
In reply to Greg Kroah-HartmanFrom: Sherry Sun <[email protected]>
[ Upstream commit 4029dfc034febb54f6dd8ea83568accc943bc088 ]
The LPUART Status Register needs to be cleared when closing the uart port to get a clean environment when reopening the uart.
--- drivers/tty/serial/fsl_lpuart.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/tty/serial/fsl_lpuart.c +4 -0
@@ -1807,6 +1807,10 @@ static void lpuart32_shutdown(struct uart_port *port)spin_lock_irqsave (&port->lock, flags); +/* clear status */ + temp =lpuart32_read (&sport->port,UARTSTAT ); +lpuart32_write (&sport->port, temp,UARTSTAT ); +/* disable Rx/Tx DMA */ temp =lpuart32_read (port,UARTBAUD ); temp &= ~(UARTBAUD_TDMAE |UARTBAUD_RDMAE );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 300/567 tty: serial: qcom-geni-serial: stop operations in progress at shutdown
In reply to Greg Kroah-HartmanFrom: Bartosz Golaszewski <[email protected]>
[ Upstream commit d8aca2f96813d51df574a811eda9a2cbed00f261 ]
We don't stop transmissions in progress at shutdown. This is fine with FIFO SE mode but with DMA (support for which we'll introduce later) it causes trouble so fix it now.
--- drivers/tty/serial/qcom_geni_serial.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/tty/serial/qcom_geni_serial.c +2 -0
@@ -893,6 +893,8 @@ static int setup_fifos(struct qcom_geni_serial_port *port)static void qcom_geni_serial_shutdown (struct uart_port *uport) {disable_irq (uport->irq); +qcom_geni_serial_stop_tx (uport); +qcom_geni_serial_stop_rx (uport); }static int qcom_geni_serial_port_setup (struct uart_port *uport)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 301/567 serial: tegra: Add missing clk_disable_unprepare() in tegra_uart_hw_init()
In reply to Greg Kroah-HartmanFrom: Yi Yang <[email protected]>
[ Upstream commit 38f28cfe9d08e3a47ef008798b275fef8118fc20 ]
Add the missing clk_disable_unprepare() before return from tegra_uart_hw_init() in the error handling path.
When request_irq() fails in tegra_uart_startup(), 'tup->uart_clk' has been enabled, fix it by adding clk_disable_unprepare().
--- drivers/tty/serial/serial-tegra.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/tty/serial/serial-tegra.c +6 -1
@@ -1047,6 +1047,7 @@ static int tegra_uart_hw_init(struct tegra_uart_port *tup)if (tup->cdata->fifo_mode_enable_status) { ret =tegra_uart_wait_fifo_mode_enabled (tup);if (ret <0 ) { +clk_disable_unprepare (tup->uart_clk);dev_err (tup->uport.dev,"Failed to enable FIFO mode: %d\n" , ret);return ret;
@@ -1068,6 +1069,7 @@ static int tegra_uart_hw_init(struct tegra_uart_port *tup)*/ ret =tegra_set_baudrate (tup,TEGRA_UART_DEFAULT_BAUD );if (ret <0 ) { +clk_disable_unprepare (tup->uart_clk);dev_err (tup->uport.dev,"Failed to set baud rate\n" );return ret; }
@@ -1227,10 +1229,13 @@ static int tegra_uart_startup(struct uart_port *u) dev_name(u->dev), tup);if (ret <0 ) {dev_err (u->dev,"Failed to register ISR for IRQ %d\n" , u->irq); - goto fail_hw_init; + goto fail_request_irq; }return 0 ; +fail_request_irq: +/* tup->uart_clk is already enabled in tegra_uart_hw_init */ +clk_disable_unprepare (tup->uart_clk); fail_hw_init:if (!tup->use_rx_pio)tegra_uart_dma_channel_free (tup, true);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 302/567 Revert "char: pcmcia: cm4000_cs: Replace mdelay with usleep_range in set_protocol"
In reply to Greg Kroah-HartmanFrom: Duoming Zhou <[email protected]>
[ Upstream commit 70fae37a09268455b8ab4f64647086b61da6f39c ]
This reverts commit be826ada52f1fcabed5b5217c94609ebf5967211.
The function monitor_card() is a timer handler that runs in an atomic context, but it calls usleep_range() that can sleep. As a result, the sleep-in-atomic-context bugs will happen. The process is shown below:
(atomic context)monitor_card()
set_protocol()
usleep_range() //sleep
The origin commit c1986ee9bea3 ("[PATCH] New Omnikey Cardman 4000 driver") works fine.
--- drivers/char/pcmcia/cm4000_cs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/char/pcmcia/cm4000_cs.c +4 -2
@@ -530,7 +530,8 @@ static int set_protocol(struct cm4000_dev *dev, struct ptsreq *ptsreq)DEBUGP (5 , dev,"NumRecBytes is valid\n" );break ; } -usleep_range (10000 ,11000 ); +/* can not sleep as this is in atomic context */ +mdelay (10 ); }if (i ==100 ) { DEBUGP(5, dev, "Timeout waiting for NumRecBytes getting "
@@ -550,7 +551,8 @@ static int set_protocol(struct cm4000_dev *dev, struct ptsreq *ptsreq) }break ; } -usleep_range (10000 ,11000 ); +/* can not sleep as this is in atomic context */ +mdelay (10 ); }/* check whether it is a short PTS reply? */
Signature · 1 line
2.39.2