6.1.57-rc1 review
Subsystems (7)
Greg Kroah-Hartman
maintainerPATCH 1/162 spi: zynqmp-gqspi: Convert to platform remove callback returning void
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit 3ffefa1d9c9eba60c7f8b4a9ce2df3e4c7f4a88e ]
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is (mostly) ignored and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new() which already returns void.
Trivially convert this driver from always returning zero in the remove callback to the void returning variant.
Stable-dep-of: 1527b076ae2c ("spi: zynqmp-gqspi: fix clock imbalance on probe failure")
--- drivers/spi/spi-zynqmp-gqspi.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/spi/spi-zynqmp-gqspi.c +2 -4
@@ -1240,7 +1240,7 @@ static int zynqmp_qspi_probe(struct platform_device *pdev)* * Return: 0 Always */ -static int zynqmp_qspi_remove (struct platform_device *pdev) +static void zynqmp_qspi_remove (struct platform_device *pdev) {struct zynqmp_qspi *xqspi =platform_get_drvdata (pdev);
@@ -1249,8 +1249,6 @@ static int zynqmp_qspi_remove(struct platform_device *pdev)clk_disable_unprepare (xqspi->pclk);pm_runtime_set_suspended (&pdev->dev);pm_runtime_disable (&pdev->dev); - -return 0 ; }static const struct of_device_id zynqmp_qspi_of_match[] = {
@@ -1262,7 +1260,7 @@ MODULE_DEVICE_TABLE(of, zynqmp_qspi_of_match);static struct platform_driver zynqmp_qspi_driver = { .probe = zynqmp_qspi_probe, - .remove = zynqmp_qspi_remove, + .remove_new = zynqmp_qspi_remove, .driver = { .name ="zynqmp-qspi" , .of_match_table = zynqmp_qspi_of_match,
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 10/162 mptcp: rename timer related helper to less confusing names
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
[ Upstream commit f6909dc1c1f4452879278128012da6c76bc186a5 ]
The msk socket uses to different timeout to track close related events and retransmissions. The existing helpers do not indicate clearly which timer they actually touch, making the related code quite confusing.
Change the existing helpers name to avoid such confusion. No functional change intended.
This patch is linked to the next one ("mptcp: fix dangling connection hang-up"). The two patches are supposed to be backported together.
Stable-dep-of: 27e5ccc2d5a5 ("mptcp: fix dangling connection hang-up")
--- net/mptcp/protocol.c | 42 +++++++++++++++++++++--------------------- net/mptcp/protocol.h | 2 +- net/mptcp/subflow.c | 2 +- 3 files changed, 23 insertions(+), 23 deletions(-)
net/mptcp/protocol.c +21 -21
@@ -401,7 +401,7 @@ static bool __mptcp_move_skb(struct mptcp_sock *msk, struct sock *ssk,return false; } -static void mptcp_stop_timer (struct sock *sk) +static void mptcp_stop_rtx_timer (struct sock *sk) {struct inet_connection_sock *icsk =inet_csk (sk);
@@ -865,12 +865,12 @@ static void __mptcp_flush_join_list(struct sock *sk, struct list_head *join_list } } -static bool mptcp_timer_pending (struct sock *sk) +static bool mptcp_rtx_timer_pending (struct sock *sk) {return timer_pending (&inet_csk (sk)->icsk_retransmit_timer); } -static void mptcp_reset_timer (struct sock *sk) +static void mptcp_reset_rtx_timer (struct sock *sk) {struct inet_connection_sock *icsk =inet_csk (sk);unsigned long tout;
@@ -1054,10 +1054,10 @@ static void __mptcp_clean_una(struct sock *sk) out:if (snd_una ==READ_ONCE (msk->snd_nxt) && snd_una ==READ_ONCE (msk->write_seq)) { -if (mptcp_timer_pending (sk) && !mptcp_data_fin_enabled (msk)) -mptcp_stop_timer (sk); +if (mptcp_rtx_timer_pending (sk) && !mptcp_data_fin_enabled (msk)) +mptcp_stop_rtx_timer (sk); }else { -mptcp_reset_timer (sk); +mptcp_reset_rtx_timer (sk); } }
@@ -1606,8 +1606,8 @@ void __mptcp_push_pending(struct sock *sk, unsigned int flags) out:/* ensure the rtx timer is running */ -if (!mptcp_timer_pending (sk)) -mptcp_reset_timer (sk); +if (!mptcp_rtx_timer_pending (sk)) +mptcp_reset_rtx_timer (sk);if (do_check_data_fin)mptcp_check_send_data_fin (sk); }
@@ -1665,8 +1665,8 @@ static void __mptcp_subflow_push_pending(struct sock *sk, struct sock *ssk)if (copied) {tcp_push (ssk,0 , info.mss_now,tcp_sk (ssk)->nonagle, info.size_goal); -if (!mptcp_timer_pending (sk)) -mptcp_reset_timer (sk); +if (!mptcp_rtx_timer_pending (sk)) +mptcp_reset_rtx_timer (sk);if (msk->snd_data_fin_enable && msk->snd_nxt +1 == msk->write_seq)
@@ -2227,7 +2227,7 @@ static void mptcp_retransmit_timer(struct timer_list *t)sock_put (sk); } -static void mptcp_timeout_timer (struct timer_list *t) +static void mptcp_tout_timer (struct timer_list *t) {struct sock *sk =from_timer (sk, t, sk_timer);
@@ -2597,14 +2597,14 @@ static void __mptcp_retrans(struct sock *sk) reset_timer:mptcp_check_and_set_pending (sk); -if (!mptcp_timer_pending (sk)) -mptcp_reset_timer (sk); +if (!mptcp_rtx_timer_pending (sk)) +mptcp_reset_rtx_timer (sk); }/* schedule the timeout timer for the relevant event: either close timeout * or mp_fail timeout. The close timeout takes precedence on the mp_fail one */ -void mptcp_reset_timeout (struct mptcp_sock *msk,unsigned long fail_tout) +void mptcp_reset_tout_timer (struct mptcp_sock *msk,unsigned long fail_tout) {struct sock *sk = (struct sock *)msk;unsigned long timeout, close_timeout;
@@ -2637,7 +2637,7 @@ static void mptcp_mp_fail_no_response(struct mptcp_sock *msk)WRITE_ONCE (mptcp_subflow_ctx (ssk)->fail_tout,0 );unlock_sock_fast (ssk, slow); -mptcp_reset_timeout (msk,0 ); +mptcp_reset_tout_timer (msk,0 ); }static void mptcp_do_fastclose (struct sock *sk)
@@ -2728,7 +2728,7 @@ static int __mptcp_init_sock(struct sock *sk)/* re-use the csk retrans timer for MPTCP-level retrans */ timer_setup (&msk->sk.icsk_retransmit_timer, mptcp_retransmit_timer,0 ); -timer_setup (&sk->sk_timer, mptcp_timeout_timer,0 ); +timer_setup (&sk->sk_timer, mptcp_tout_timer,0 );return 0 ; }
@@ -2820,8 +2820,8 @@ void mptcp_subflow_shutdown(struct sock *sk, struct sock *ssk, int how) }else {pr_debug ("Sending DATA_FIN on subflow %p" , ssk);tcp_send_ack (ssk); -if (!mptcp_timer_pending (sk)) -mptcp_reset_timer (sk); +if (!mptcp_rtx_timer_pending (sk)) +mptcp_reset_rtx_timer (sk); }break ; }
@@ -2904,7 +2904,7 @@ static void __mptcp_destroy_sock(struct sock *sk)might_sleep (); -mptcp_stop_timer (sk); +mptcp_stop_rtx_timer (sk);sk_stop_timer (sk, &sk->sk_timer); msk->pm.status =0 ;
@@ -3021,7 +3021,7 @@ bool __mptcp_close(struct sock *sk, long timeout)__mptcp_destroy_sock (sk); do_cancel_work = true; }else { -mptcp_reset_timeout (msk,0 ); +mptcp_reset_tout_timer (msk,0 ); }return do_cancel_work;
@@ -3084,7 +3084,7 @@ static int mptcp_disconnect(struct sock *sk, int flags)mptcp_check_listen_stop (sk);inet_sk_state_store (sk,TCP_CLOSE ); -mptcp_stop_timer (sk); +mptcp_stop_rtx_timer (sk);sk_stop_timer (sk, &sk->sk_timer);if (mptcp_sk (sk)->token)
net/mptcp/protocol.h +1 -1
@@ -681,7 +681,7 @@ void mptcp_get_options(const struct sk_buff *skb,void mptcp_finish_connect (struct sock *sk);void __mptcp_set_connected (struct sock *sk); -void mptcp_reset_timeout (struct mptcp_sock *msk,unsigned long fail_tout); +void mptcp_reset_tout_timer (struct mptcp_sock *msk,unsigned long fail_tout);static inline bool mptcp_is_fully_established (struct sock *sk) { return inet_sk_state_load(sk) == TCP_ESTABLISHED &&
net/mptcp/subflow.c +1 -1
@@ -1161,7 +1161,7 @@ static void mptcp_subflow_fail(struct mptcp_sock *msk, struct sock *ssk)WRITE_ONCE (subflow->fail_tout, fail_tout);tcp_send_ack (ssk); -mptcp_reset_timeout (msk, subflow->fail_tout); +mptcp_reset_tout_timer (msk, subflow->fail_tout); }static bool subflow_check_data_avail (struct sock *ssk)
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 11/162 mptcp: fix dangling connection hang-up
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
[ Upstream commit 27e5ccc2d5a50ed61bb73153edb1066104b108b3 ]
According to RFC 8684 section 3.3:
A connection is not closed unless [...] or an implementation-specific connection-level send timeout.
Currently the MPTCP protocol does not implement such timeout, and connection timing-out at the TCP-level never move to close state.
Introduces a catch-up condition at subflow close time to move the MPTCP socket to close, too.
That additionally allows removing similar existing inside the worker.
Finally, allow some additional timeout for plain ESTABLISHED mptcp sockets, as the protocol allows creating new subflows even at that point and making the connection functional again.
This issue is actually present since the beginning, but it is basically impossible to solve without a long chain of functional pre-requisites topped by commit bbd49d114d57 ("mptcp: consolidate transition to TCP_CLOSE in mptcp_do_fastclose()"). When backporting this current patch, please also backport this other commit as well.
--- net/mptcp/protocol.c | 90 ++++++++++++++++++++++---------------------- net/mptcp/protocol.h | 22 +++++++++++ net/mptcp/subflow.c | 1 + 3 files changed, 67 insertions(+), 46 deletions(-)
net/mptcp/protocol.c +44 -46
@@ -846,6 +846,7 @@ static bool __mptcp_finish_join(struct mptcp_sock *msk, struct sock *ssk)mptcp_sockopt_sync_locked (msk, ssk);mptcp_subflow_joined (msk, ssk); +mptcp_stop_tout_timer (sk);return true; }
@@ -2349,18 +2350,14 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,bool dispose_it, need_push = false;/* If the first subflow moved to a close state before accept, e.g. due -* to an incoming reset, mptcp either: -* - if either the subflow or the msk are dead, destroy the context -* (the subflow socket is deleted by inet_child_forget) and the msk -* - otherwise do nothing at the moment and take action at accept and/or -* listener shutdown - user-space must be able to accept() the closed -* socket. +* to an incoming reset or listener shutdown, the subflow socket is +* already deleted by inet_child_forget() and the mptcp socket can't +* survive too. */ -if (msk->in_accept_queue && msk->first == ssk) { -if (!sock_flag (sk,SOCK_DEAD ) && !sock_flag (ssk,SOCK_DEAD )) -return ; - +if (msk->in_accept_queue && msk->first == ssk && + (sock_flag (sk,SOCK_DEAD ) ||sock_flag (ssk,SOCK_DEAD ))) {/* ensure later check in mptcp_worker() will dispose the msk */ +mptcp_set_close_tout (sk, tcp_jiffies32 - (TCP_TIMEWAIT_LEN +1 ));sock_set_flag (sk,SOCK_DEAD );lock_sock_nested (ssk,SINGLE_DEPTH_NESTING );mptcp_subflow_drop_ctx (ssk);
@@ -2426,6 +2423,22 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,if (need_push)__mptcp_push_pending (sk,0 ); + +/* Catch every 'all subflows closed' scenario, including peers silently +* closing them, e.g. due to timeout. +* For established sockets, allow an additional timeout before closing, +* as the protocol can still create more subflows. +*/ +if (list_is_singular (&msk->conn_list) && msk->first && +inet_sk_state_load (msk->first) ==TCP_CLOSE ) { +if (sk->sk_state !=TCP_ESTABLISHED || + msk->in_accept_queue ||sock_flag (sk,SOCK_DEAD )) { +inet_sk_state_store (sk,TCP_CLOSE ); +mptcp_close_wake_up (sk); + }else { +mptcp_start_tout_timer (sk); + } + } } void mptcp_close_ssk(struct sock *sk, struct sock *ssk,
@@ -2469,23 +2482,14 @@ static void __mptcp_close_subflow(struct sock *sk) } -static bool mptcp_should_close (const struct sock *sk) +static bool mptcp_close_tout_expired (const struct sock *sk) { -s32 delta = tcp_jiffies32 -inet_csk (sk)->icsk_mtup.probe_timestamp; -struct mptcp_subflow_context *subflow; - -if (delta >=TCP_TIMEWAIT_LEN ||mptcp_sk (sk)->in_accept_queue) -return true; +if (!inet_csk (sk)->icsk_mtup.probe_timestamp || + sk->sk_state ==TCP_CLOSE ) +return false; -/* if all subflows are in closed status don't bother with additional -* timeout -*/ -mptcp_for_each_subflow (mptcp_sk (sk), subflow) { -if (inet_sk_state_load (mptcp_subflow_tcp_sock (subflow)) != -TCP_CLOSE ) -return false; - } -return true; +return time_after32 (tcp_jiffies32, +inet_csk (sk)->icsk_mtup.probe_timestamp +TCP_TIMEWAIT_LEN ); }static void mptcp_check_fastclose (struct mptcp_sock *msk)
@@ -2609,15 +2613,16 @@ void mptcp_reset_tout_timer(struct mptcp_sock *msk, unsigned long fail_tout)struct sock *sk = (struct sock *)msk;unsigned long timeout, close_timeout; -if (!fail_tout && !sock_flag (sk,SOCK_DEAD )) +if (!fail_tout && !inet_csk (sk)->icsk_mtup.probe_timestamp)return ; - close_timeout =inet_csk (sk)->icsk_mtup.probe_timestamp - tcp_jiffies32 + jiffies +TCP_TIMEWAIT_LEN ; + close_timeout =inet_csk (sk)->icsk_mtup.probe_timestamp - tcp_jiffies32 + jiffies + +TCP_TIMEWAIT_LEN ;/* the close timeout takes precedence on the fail one, and here at least one of * them is active */ - timeout =sock_flag (sk,SOCK_DEAD ) ? close_timeout : fail_tout; + timeout =inet_csk (sk)->icsk_mtup.probe_timestamp ? close_timeout : fail_tout;sk_reset_timer (sk, &sk->sk_timer, timeout); }
@@ -2636,8 +2641,6 @@ static void mptcp_mp_fail_no_response(struct mptcp_sock *msk)mptcp_subflow_reset (ssk);WRITE_ONCE (mptcp_subflow_ctx (ssk)->fail_tout,0 );unlock_sock_fast (ssk, slow); - -mptcp_reset_tout_timer (msk,0 ); }static void mptcp_do_fastclose (struct sock *sk)
@@ -2676,19 +2679,15 @@ static void mptcp_worker(struct work_struct *work)if (test_and_clear_bit (MPTCP_WORK_CLOSE_SUBFLOW , &msk->flags))__mptcp_close_subflow (sk); -/* There is no point in keeping around an orphaned sk timedout or -* closed, but we need the msk around to reply to incoming DATA_FIN, -* even if it is orphaned and in FIN_WAIT2 state -*/ -if (sock_flag (sk,SOCK_DEAD )) { -if (mptcp_should_close (sk)) { -inet_sk_state_store (sk,TCP_CLOSE ); -mptcp_do_fastclose (sk); - } -if (sk->sk_state ==TCP_CLOSE ) { -__mptcp_destroy_sock (sk); - goto unlock; - } +if (mptcp_close_tout_expired (sk)) { +inet_sk_state_store (sk,TCP_CLOSE ); +mptcp_do_fastclose (sk); +mptcp_close_wake_up (sk); + } + +if (sock_flag (sk,SOCK_DEAD ) && sk->sk_state ==TCP_CLOSE ) { +__mptcp_destroy_sock (sk); + goto unlock; }if (test_and_clear_bit (MPTCP_WORK_RTX , &msk->flags))
@@ -2984,7 +2983,6 @@ bool __mptcp_close(struct sock *sk, long timeout) cleanup:/* orphan all the subflows */ -inet_csk (sk)->icsk_mtup.probe_timestamp = tcp_jiffies32;mptcp_for_each_subflow (msk, subflow) {struct sock *ssk =mptcp_subflow_tcp_sock (subflow);bool slow =lock_sock_fast_nested (ssk);
@@ -3021,7 +3019,7 @@ bool __mptcp_close(struct sock *sk, long timeout)__mptcp_destroy_sock (sk); do_cancel_work = true; }else { -mptcp_reset_tout_timer (msk,0 ); +mptcp_start_tout_timer (sk); }return do_cancel_work;
@@ -3085,7 +3083,7 @@ static int mptcp_disconnect(struct sock *sk, int flags)inet_sk_state_store (sk,TCP_CLOSE );mptcp_stop_rtx_timer (sk); -sk_stop_timer (sk, &sk->sk_timer); +mptcp_stop_tout_timer (sk);if (mptcp_sk (sk)->token)mptcp_event (MPTCP_EVENT_CLOSED ,mptcp_sk (sk),NULL ,GFP_KERNEL );
net/mptcp/protocol.h +22 -0
@@ -682,6 +682,28 @@ void mptcp_get_options(const struct sk_buff *skb,void mptcp_finish_connect (struct sock *sk);void __mptcp_set_connected (struct sock *sk);void mptcp_reset_tout_timer (struct mptcp_sock *msk,unsigned long fail_tout); + +static inline void mptcp_stop_tout_timer (struct sock *sk) +{ +if (!inet_csk (sk)->icsk_mtup.probe_timestamp) +return ; + +sk_stop_timer (sk, &sk->sk_timer); +inet_csk (sk)->icsk_mtup.probe_timestamp =0 ; +} + +static inline void mptcp_set_close_tout (struct sock *sk,unsigned long tout) +{ +/* avoid 0 timestamp, as that means no close timeout */ +inet_csk (sk)->icsk_mtup.probe_timestamp = tout ? :1 ; +} + +static inline void mptcp_start_tout_timer (struct sock *sk) +{ +mptcp_set_close_tout (sk, tcp_jiffies32); +mptcp_reset_tout_timer (mptcp_sk (sk),0 ); +} +static inline bool mptcp_is_fully_established (struct sock *sk) { return inet_sk_state_load(sk) == TCP_ESTABLISHED &&
net/mptcp/subflow.c +1 -0
@@ -1527,6 +1527,7 @@ int __mptcp_subflow_connect(struct sock *sk, const struct mptcp_addr_info *loc,mptcp_sock_graft (ssk, sk->sk_socket);iput (SOCK_INODE (sf));WRITE_ONCE (msk->allow_infinite_fallback, false); +mptcp_stop_tout_timer (sk);return 0 ; failed_unlink:
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 12/162 mptcp: annotate lockless accesses to sk->sk_err
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 9ae8e5ad99b8ebcd3d3dd46075f3825e6f08f063 ]
mptcp_poll() reads sk->sk_err without socket lock held/owned.
Add READ_ONCE() and WRITE_ONCE() to avoid load/store tearing.
Stable-dep-of: d5fbeff1ab81 ("mptcp: move __mptcp_error_report in protocol.c")
--- net/mptcp/pm_netlink.c | 2 +- net/mptcp/protocol.c | 8 ++++---- net/mptcp/subflow.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-)
net/mptcp/pm_netlink.c +1 -1
@@ -2047,7 +2047,7 @@ static int mptcp_event_put_token_and_ssk(struct sk_buff *skb, nla_put_s32(skb, MPTCP_ATTR_IF_IDX, ssk->sk_bound_dev_if))return -EMSGSIZE ; - sk_err = ssk->sk_err; + sk_err =READ_ONCE (ssk->sk_err);if (sk_err && sk->sk_state ==TCP_ESTABLISHED &&nla_put_u8 (skb,MPTCP_ATTR_ERROR , sk_err))return -EMSGSIZE ;
net/mptcp/protocol.c +4 -4
@@ -2517,15 +2517,15 @@ static void mptcp_check_fastclose(struct mptcp_sock *msk)/* Mirror the tcp_reset() error propagation */ switch (sk->sk_state) {case TCP_SYN_SENT : - sk->sk_err =ECONNREFUSED ; +WRITE_ONCE (sk->sk_err,ECONNREFUSED );break ;case TCP_CLOSE_WAIT : - sk->sk_err =EPIPE ; +WRITE_ONCE (sk->sk_err,EPIPE );break ;case TCP_CLOSE :return ;default : - sk->sk_err =ECONNRESET ; +WRITE_ONCE (sk->sk_err,ECONNRESET ); }inet_sk_state_store (sk,TCP_CLOSE );
@@ -3893,7 +3893,7 @@ static __poll_t mptcp_poll(struct file *file, struct socket *sock,/* This barrier is coupled with smp_wmb() in __mptcp_error_report() */ smp_rmb (); -if (sk->sk_err) +if (READ_ONCE (sk->sk_err)) mask |=EPOLLERR ;return mask;
net/mptcp/subflow.c +2 -2
@@ -1248,7 +1248,7 @@ static bool subflow_check_data_avail(struct sock *ssk) subflow->reset_reason =MPTCP_RST_EMPTCP ; reset: - ssk->sk_err =EBADMSG ; +WRITE_ONCE (ssk->sk_err,EBADMSG );tcp_set_state (ssk,TCP_CLOSE );while ((skb =skb_peek (&ssk->sk_receive_queue)))sk_eat_skb (ssk, skb);
@@ -1332,7 +1332,7 @@ void __mptcp_error_report(struct sock *sk) ssk_state =inet_sk_state_load (ssk);if (ssk_state ==TCP_CLOSE && !sock_flag (sk,SOCK_DEAD ))inet_sk_state_store (sk, ssk_state); - sk->sk_err = -err; +WRITE_ONCE (sk->sk_err, -err);/* This barrier is coupled with smp_rmb() in mptcp_poll() */ smp_wmb ();
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 13/162 mptcp: move __mptcp_error_report in protocol.c
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
[ Upstream commit d5fbeff1ab812b6c473b6924bee8748469462e2c ]
This will simplify the next patch ("mptcp: process pending subflow error on close").
No functional change intended.
--- net/mptcp/protocol.c | 36 ++++++++++++++++++++++++++++++++++++ net/mptcp/subflow.c | 36 ------------------------------------ 2 files changed, 36 insertions(+), 36 deletions(-)
net/mptcp/protocol.c +36 -0
@@ -765,6 +765,42 @@ static bool __mptcp_ofo_queue(struct mptcp_sock *msk)return moved; } +void __mptcp_error_report (struct sock *sk) +{ +struct mptcp_subflow_context *subflow; +struct mptcp_sock *msk =mptcp_sk (sk); + +mptcp_for_each_subflow (msk, subflow) { +struct sock *ssk =mptcp_subflow_tcp_sock (subflow); +int err =sock_error (ssk); +int ssk_state; + +if (!err) +continue ; + +/* only propagate errors on fallen-back sockets or +* on MPC connect +*/ +if (sk->sk_state !=TCP_SYN_SENT && !__mptcp_check_fallback (msk)) +continue ; + +/* We need to propagate only transition to CLOSE state. +* Orphaned socket will see such state change via +* subflow_sched_work_if_closed() and that path will properly +* destroy the msk as needed. +*/ + ssk_state =inet_sk_state_load (ssk); +if (ssk_state ==TCP_CLOSE && !sock_flag (sk,SOCK_DEAD )) +inet_sk_state_store (sk, ssk_state); +WRITE_ONCE (sk->sk_err, -err); + +/* This barrier is coupled with smp_rmb() in mptcp_poll() */ +smp_wmb (); +sk_error_report (sk); +break ; + } +} +/* In most cases we will be able to lock the mptcp socket. If its already * owned, we need to defer to the work queue to avoid ABBA deadlock. */
net/mptcp/subflow.c +0 -36
@@ -1305,42 +1305,6 @@ void mptcp_space(const struct sock *ssk, int *space, int *full_space) *full_space =tcp_full_space (sk); } -void __mptcp_error_report (struct sock *sk) -{ -struct mptcp_subflow_context *subflow; -struct mptcp_sock *msk =mptcp_sk (sk); - -mptcp_for_each_subflow (msk, subflow) { -struct sock *ssk =mptcp_subflow_tcp_sock (subflow); -int err =sock_error (ssk); -int ssk_state; - -if (!err) -continue ; - -/* only propagate errors on fallen-back sockets or -* on MPC connect -*/ -if (sk->sk_state !=TCP_SYN_SENT && !__mptcp_check_fallback (msk)) -continue ; - -/* We need to propagate only transition to CLOSE state. -* Orphaned socket will see such state change via -* subflow_sched_work_if_closed() and that path will properly -* destroy the msk as needed. -*/ - ssk_state =inet_sk_state_load (ssk); -if (ssk_state ==TCP_CLOSE && !sock_flag (sk,SOCK_DEAD )) -inet_sk_state_store (sk, ssk_state); -WRITE_ONCE (sk->sk_err, -err); - -/* This barrier is coupled with smp_rmb() in mptcp_poll() */ -smp_wmb (); -sk_error_report (sk); -break ; - } -} -static void subflow_error_report (struct sock *ssk) {struct sock *sk =mptcp_subflow_ctx (ssk)->conn;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 2/162 spi: zynqmp-gqspi: fix clock imbalance on probe failure
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
[ Upstream commit 1527b076ae2cb6a9c590a02725ed39399fcad1cf ]
Make sure that the device is not runtime suspended before explicitly disabling the clocks on probe failure and on driver unbind to avoid a clock enable-count imbalance.
--- drivers/spi/spi-zynqmp-gqspi.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/spi/spi-zynqmp-gqspi.c +8 -4
@@ -1218,9 +1218,9 @@ static int zynqmp_qspi_probe(struct platform_device *pdev)return 0 ; clk_dis_all: -pm_runtime_put_sync (&pdev->dev); -pm_runtime_set_suspended (&pdev->dev);pm_runtime_disable (&pdev->dev); +pm_runtime_put_noidle (&pdev->dev); +pm_runtime_set_suspended (&pdev->dev);clk_disable_unprepare (xqspi->refclk); clk_dis_pclk:clk_disable_unprepare (xqspi->pclk);
@@ -1244,11 +1244,15 @@ static void zynqmp_qspi_remove(struct platform_device *pdev) {struct zynqmp_qspi *xqspi =platform_get_drvdata (pdev); +pm_runtime_get_sync (&pdev->dev); +zynqmp_gqspi_write (xqspi,GQSPI_EN_OFST ,0x0 ); + +pm_runtime_disable (&pdev->dev); +pm_runtime_put_noidle (&pdev->dev); +pm_runtime_set_suspended (&pdev->dev);clk_disable_unprepare (xqspi->refclk);clk_disable_unprepare (xqspi->pclk); -pm_runtime_set_suspended (&pdev->dev); -pm_runtime_disable (&pdev->dev); }static const struct of_device_id zynqmp_qspi_of_match[] = {
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 3/162 ALSA: hda/tas2781: Add tas2781 HDA driver
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shenghao Ding <[email protected]>
[ Upstream commit 3babae915f4c15d76a5134e55806a1c1588e2865 ]
Integrate tas2781 configs for Lenovo Laptops. All of the tas2781s in the laptop will be aggregated as one audio device. The code support realtek as the primary codec. Rename "struct cs35l41_dev_name" to "struct scodec_dev_name" for all other side codecs instead of the certain one.
Stable-dep-of: 41b07476da38 ("ALSA: hda/realtek - ALC287 Realtek I2S speaker platform support")
--- sound/pci/hda/patch_realtek.c | 88 +++++++++++++++++++++++++++++++++-- 1 file changed, 85 insertions(+), 3 deletions(-)
sound/pci/hda/patch_realtek.c +85 -3
@@ -6721,7 +6721,7 @@ static void comp_generic_playback_hook(struct hda_pcm_stream *hinfo, struct hda_ } } -struct cs35l41_dev_name { +struct scodec_dev_name {const char *bus;const char *hid;int index;
@@ -6730,7 +6730,7 @@ struct cs35l41_dev_name {/* match the device name in a slightly relaxed manner */ static int comp_match_cs35l41_dev_name (struct device *dev,void *data) { -struct cs35l41_dev_name *p = data; +struct scodec_dev_name *p = data;const char *d =dev_name (dev);int n =strlen (p->bus);char tmp[32 ];
@@ -6746,12 +6746,32 @@ static int comp_match_cs35l41_dev_name(struct device *dev, void *data)return !strcmp (d + n, tmp); } +static int comp_match_tas2781_dev_name (struct device *dev, +void *data) +{ +struct scodec_dev_name *p = data; +const char *d =dev_name (dev); +int n =strlen (p->bus); +char tmp[32 ]; + +/* check the bus name */ +if (strncmp (d, p->bus, n)) +return 0 ; +/* skip the bus number */ +if (isdigit (d[n])) + n++; +/* the rest must be exact matching */ +snprintf (tmp,sizeof (tmp),"-%s:00" , p->hid); + +return !strcmp (d + n, tmp); +} +static void cs35l41_generic_fixup (struct hda_codec *cdc,int action,const char *bus,const char *hid,int count) {struct device *dev =hda_codec_dev (cdc);struct alc_spec *spec = cdc->spec; -struct cs35l41_dev_name *rec; +struct scodec_dev_name *rec;int ret, i;switch (action) {
@@ -6776,6 +6796,41 @@ static void cs35l41_generic_fixup(struct hda_codec *cdc, int action, const char } } +static void tas2781_generic_fixup (struct hda_codec *cdc,int action, +const char *bus,const char *hid) +{ +struct device *dev =hda_codec_dev (cdc); +struct alc_spec *spec = cdc->spec; +struct scodec_dev_name *rec; +int ret; + +switch (action) { +case HDA_FIXUP_ACT_PRE_PROBE : + rec =devm_kmalloc (dev,sizeof (*rec),GFP_KERNEL ); +if (!rec) +return ; + rec->bus = bus; + rec->hid = hid; + rec->index =0 ; + spec->comps[0 ].codec = cdc; +component_match_add (dev, &spec->match, + comp_match_tas2781_dev_name, rec); + ret =component_master_add_with_match (dev, &comp_master_ops, + spec->match); +if (ret) +codec_err (cdc, +"Fail to register component aggregator %d\n" , + ret); +else + spec->gen.pcm_playback_hook = + comp_generic_playback_hook; +break ; +case HDA_FIXUP_ACT_FREE : +component_master_del (dev, &comp_master_ops); +break ; + } +} +static void cs35l41_fixup_i2c_two (struct hda_codec *cdc,const struct hda_fixup *fix,int action) {cs35l41_generic_fixup (cdc, action,"i2c" ,"CSC3551" ,2 );
@@ -6803,6 +6858,12 @@ static void alc287_fixup_legion_16ithg6_speakers(struct hda_codec *cdc, const stcs35l41_generic_fixup (cdc, action,"i2c" ,"CLSA0101" ,2 ); } +static void tas2781_fixup_i2c (struct hda_codec *cdc, +const struct hda_fixup *fix,int action) +{ +tas2781_generic_fixup (cdc, action,"i2c" ,"TIAS2781" ); +} +/* for alc295_fixup_hp_top_speakers */ #include "hp_x360_helper.c"
@@ -7227,6 +7288,7 @@ enum {ALC295_FIXUP_DELL_INSPIRON_TOP_SPEAKERS ,ALC236_FIXUP_DELL_DUAL_CODECS ,ALC287_FIXUP_CS35L41_I2C_2_THINKPAD_ACPI , + ALC287_FIXUP_TAS2781_I2C, };/* A special fixup for Lenovo C940 and Yoga Duet 7;
@@ -9296,6 +9358,12 @@ static const struct hda_fixup alc269_fixups[] = { .chained = true, .chain_id = ALC269_FIXUP_THINKPAD_ACPI, }, + [ALC287_FIXUP_TAS2781_I2C] = { + .type = HDA_FIXUP_FUNC, + .v.func = tas2781_fixup_i2c, + .chained = true, + .chain_id = ALC269_FIXUP_THINKPAD_ACPI, + }, }; static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -9867,6 +9935,20 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x17aa ,0x3853 ,"Lenovo Yoga 7 15ITL5" ,ALC287_FIXUP_YOGA7_14ITL_SPEAKERS ),SND_PCI_QUIRK (0x17aa ,0x3855 ,"Legion 7 16ITHG6" ,ALC287_FIXUP_LEGION_16ITHG6 ),SND_PCI_QUIRK (0x17aa ,0x3869 ,"Lenovo Yoga7 14IAL7" ,ALC287_FIXUP_YOGA9_14IAP7_BASS_SPK_PIN ), +SND_PCI_QUIRK (0x17aa ,0x387d ,"Yoga S780-16 pro Quad AAC" ,ALC287_FIXUP_TAS2781_I2C ), +SND_PCI_QUIRK (0x17aa ,0x387e ,"Yoga S780-16 pro Quad YC" ,ALC287_FIXUP_TAS2781_I2C ), +SND_PCI_QUIRK (0x17aa ,0x3881 ,"YB9 dual powe mode2 YC" ,ALC287_FIXUP_TAS2781_I2C ), +SND_PCI_QUIRK (0x17aa ,0x3884 ,"Y780 YG DUAL" ,ALC287_FIXUP_TAS2781_I2C ), +SND_PCI_QUIRK (0x17aa ,0x3886 ,"Y780 VECO DUAL" ,ALC287_FIXUP_TAS2781_I2C ), +SND_PCI_QUIRK (0x17aa ,0x38a7 ,"Y780P AMD YG dual" ,ALC287_FIXUP_TAS2781_I2C ), +SND_PCI_QUIRK (0x17aa ,0x38a8 ,"Y780P AMD VECO dual" ,ALC287_FIXUP_TAS2781_I2C ), +SND_PCI_QUIRK (0x17aa ,0x38ba ,"Yoga S780-14.5 Air AMD quad YC" ,ALC287_FIXUP_TAS2781_I2C ), +SND_PCI_QUIRK (0x17aa ,0x38bb ,"Yoga S780-14.5 Air AMD quad AAC" ,ALC287_FIXUP_TAS2781_I2C ), +SND_PCI_QUIRK (0x17aa ,0x38be ,"Yoga S980-14.5 proX YC Dual" ,ALC287_FIXUP_TAS2781_I2C ), +SND_PCI_QUIRK (0x17aa ,0x38bf ,"Yoga S980-14.5 proX LX Dual" ,ALC287_FIXUP_TAS2781_I2C ), +SND_PCI_QUIRK (0x17aa ,0x38c3 ,"Y980 DUAL" ,ALC287_FIXUP_TAS2781_I2C ), +SND_PCI_QUIRK (0x17aa ,0x38cb ,"Y790 YG DUAL" ,ALC287_FIXUP_TAS2781_I2C ), +SND_PCI_QUIRK (0x17aa ,0x38cd ,"Y790 VECO DUAL" ,ALC287_FIXUP_TAS2781_I2C ),SND_PCI_QUIRK (0x17aa ,0x3902 ,"Lenovo E50-80" ,ALC269_FIXUP_DMIC_THINKPAD_ACPI ),SND_PCI_QUIRK (0x17aa ,0x3977 ,"IdeaPad S210" ,ALC283_FIXUP_INT_MIC ), SND_PCI_QUIRK(0x17aa, 0x3978, "Lenovo B50-70", ALC269_FIXUP_DMIC_THINKPAD_ACPI),
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 4/162 ALSA: hda/realtek: Add quirk for HP Victus 16-d1xxx to enable mute LED
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: SungHwan Jung <[email protected]>
[ Upstream commit 93dc18e11b1ab2d485b69f91c973e6b83e47ebd0 ]
This quirk enables mute LED on HP Victus 16-d1xxx (8A25) laptops, which use ALC245 codec.
Stable-dep-of: 41b07476da38 ("ALSA: hda/realtek - ALC287 Realtek I2S speaker platform support")
--- sound/pci/hda/patch_realtek.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
sound/pci/hda/patch_realtek.c +22 -0
@@ -4639,6 +4639,22 @@ static void alc236_fixup_hp_mute_led_coefbit2(struct hda_codec *codec, } } +static void alc245_fixup_hp_mute_led_coefbit (struct hda_codec *codec, +const struct hda_fixup *fix, +int action) +{ +struct alc_spec *spec = codec->spec; + +if (action ==HDA_FIXUP_ACT_PRE_PROBE ) { + spec->mute_led_polarity =0 ; + spec->mute_led_coef.idx =0x0b ; + spec->mute_led_coef.mask =3 <<2 ; + spec->mute_led_coef.on =2 <<2 ; + spec->mute_led_coef.off =1 <<2 ; +snd_hda_gen_add_mute_led_cdev (codec, coef_mute_led_set); + } +} +/* turn on/off mic-mute LED per capture hook by coef bit */ static int coef_micmute_led_set (struct led_classdev *led_cdev,enum led_brightness brightness)
@@ -7289,6 +7305,7 @@ enum {ALC236_FIXUP_DELL_DUAL_CODECS ,ALC287_FIXUP_CS35L41_I2C_2_THINKPAD_ACPI ,ALC287_FIXUP_TAS2781_I2C , + ALC245_FIXUP_HP_MUTE_LED_COEFBIT, };/* A special fixup for Lenovo C940 and Yoga Duet 7;
@@ -9364,6 +9381,10 @@ static const struct hda_fixup alc269_fixups[] = { .chained = true, .chain_id = ALC269_FIXUP_THINKPAD_ACPI, }, + [ALC245_FIXUP_HP_MUTE_LED_COEFBIT] = { + .type = HDA_FIXUP_FUNC, + .v.func = alc245_fixup_hp_mute_led_coefbit, + }, }; static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -9630,6 +9651,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x103c ,0x89c6 ,"Zbook Fury 17 G9" ,ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x89ca ,"HP" ,ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF ),SND_PCI_QUIRK (0x103c ,0x89d3 ,"HP EliteBook 645 G9 (MB 89D2)" ,ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF ), +SND_PCI_QUIRK (0x103c ,0x8a25 ,"HP Victus 16-d1xxx (MB 8A25)" ,ALC245_FIXUP_HP_MUTE_LED_COEFBIT ),SND_PCI_QUIRK (0x103c ,0x8a78 ,"HP Dev One" ,ALC285_FIXUP_HP_LIMIT_INT_MIC_BOOST ),SND_PCI_QUIRK (0x103c ,0x8aa0 ,"HP ProBook 440 G9 (MB 8A9E)" ,ALC236_FIXUP_HP_GPIO_LED ), SND_PCI_QUIRK(0x103c, 0x8aa3, "HP ProBook 450 G9 (MB 8AA1)", ALC236_FIXUP_HP_GPIO_LED),
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 5/162 ALSA: hda/realtek: Add quirk for mute LEDs on HP ENVY x360 15-eu0xxx
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fabian Vogt <[email protected]>
[ Upstream commit c99c26b16c1544534ebd6a5f27a034f3e44d2597 ]
The LED for the mic mute button is controlled by GPIO2.
The mute button LED is slightly more complex, it's controlled by two bits in coeff 0x0b.
Stable-dep-of: 41b07476da38 ("ALSA: hda/realtek - ALC287 Realtek I2S speaker platform support")
--- sound/pci/hda/patch_realtek.c | 8 ++++++++ 1 file changed, 8 insertions(+)
sound/pci/hda/patch_realtek.c +8 -0
@@ -7306,6 +7306,7 @@ enum {ALC287_FIXUP_CS35L41_I2C_2_THINKPAD_ACPI ,ALC287_FIXUP_TAS2781_I2C ,ALC245_FIXUP_HP_MUTE_LED_COEFBIT , + ALC245_FIXUP_HP_X360_MUTE_LEDS, };/* A special fixup for Lenovo C940 and Yoga Duet 7;
@@ -9385,6 +9386,12 @@ static const struct hda_fixup alc269_fixups[] = { .type = HDA_FIXUP_FUNC, .v.func = alc245_fixup_hp_mute_led_coefbit, }, + [ALC245_FIXUP_HP_X360_MUTE_LEDS] = { + .type = HDA_FIXUP_FUNC, + .v.func = alc245_fixup_hp_mute_led_coefbit, + .chained = true, + .chain_id =ALC245_FIXUP_HP_GPIO_LED + }, };static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -9620,6 +9627,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x103c ,0x8870 ,"HP ZBook Fury 15.6 Inch G8 Mobile Workstation PC" ,ALC285_FIXUP_HP_GPIO_AMP_INIT ),SND_PCI_QUIRK (0x103c ,0x8873 ,"HP ZBook Studio 15.6 Inch G8 Mobile Workstation PC" ,ALC285_FIXUP_HP_GPIO_AMP_INIT ),SND_PCI_QUIRK (0x103c ,0x887a ,"HP Laptop 15s-eq2xxx" ,ALC236_FIXUP_HP_MUTE_LED_COEFBIT2 ), +SND_PCI_QUIRK (0x103c ,0x888a ,"HP ENVY x360 Convertible 15-eu0xxx" ,ALC245_FIXUP_HP_X360_MUTE_LEDS ),SND_PCI_QUIRK (0x103c ,0x888d ,"HP ZBook Power 15.6 inch G8 Mobile Workstation PC" ,ALC236_FIXUP_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8895 ,"HP EliteBook 855 G8 Notebook PC" ,ALC285_FIXUP_HP_SPEAKERS_MICMUTE_LED ), SND_PCI_QUIRK(0x103c, 0x8896, "HP EliteBook 855 G8 Notebook PC", ALC285_FIXUP_HP_MUTE_LED),
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 6/162 ALSA: hda/realtek - ALC287 I2S speaker platform support
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kailang Yang <[email protected]>
[ Upstream commit e43252db7e207a2e194e6a4883a43a31a776a968 ]
0x17 was only speaker pin, DAC assigned will be 0x03. Headphone assigned to 0x02.
Playback via headphone will get EQ filter processing. So,it needs to swap DAC.
Stable-dep-of: 41b07476da38 ("ALSA: hda/realtek - ALC287 Realtek I2S speaker platform support")
--- sound/pci/hda/patch_realtek.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
sound/pci/hda/patch_realtek.c +30 -0
@@ -7046,6 +7046,27 @@ static void alc295_fixup_dell_inspiron_top_speakers(struct hda_codec *codec, } } +/* Forcibly assign NID 0x03 to HP while NID 0x02 to SPK */ +static void alc287_fixup_bind_dacs (struct hda_codec *codec, +const struct hda_fixup *fix,int action) +{ +struct alc_spec *spec = codec->spec; +static const hda_nid_t conn[] = {0x02 ,0x03 };/* exclude 0x06 */ +static const hda_nid_t preferred_pairs[] = { +0x17 ,0x02 ,0x21 ,0x03 ,0 + }; + +if (action !=HDA_FIXUP_ACT_PRE_PROBE ) +return ; + +snd_hda_override_conn_list (codec,0x17 ,ARRAY_SIZE (conn), conn); + spec->gen.preferred_dacs = preferred_pairs; + spec->gen.auto_mute_via_amp =1 ; +snd_hda_codec_write_cache (codec,0x14 ,0 ,AC_VERB_SET_PIN_WIDGET_CONTROL , +0x0 );/* Make sure 0x14 was disable */ +} + +enum {ALC269_FIXUP_GPIO2 ,ALC269_FIXUP_SONY_VAIO ,
@@ -7307,6 +7328,7 @@ enum {ALC287_FIXUP_TAS2781_I2C ,ALC245_FIXUP_HP_MUTE_LED_COEFBIT ,ALC245_FIXUP_HP_X360_MUTE_LEDS , + ALC287_FIXUP_THINKPAD_I2S_SPK, };/* A special fixup for Lenovo C940 and Yoga Duet 7;
@@ -9392,6 +9414,10 @@ static const struct hda_fixup alc269_fixups[] = { .chained = true, .chain_id =ALC245_FIXUP_HP_GPIO_LED }, + [ALC287_FIXUP_THINKPAD_I2S_SPK] = { + .type = HDA_FIXUP_FUNC, + .v.func = alc287_fixup_bind_dacs, + }, };static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -10514,6 +10540,10 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = { {0x17, 0x90170111}, {0x19, 0x03a11030}, {0x21, 0x03211020}), + SND_HDA_PIN_QUIRK(0x10ec0287, 0x17aa, "Lenovo", ALC287_FIXUP_THINKPAD_I2S_SPK, + {0x17, 0x90170110}, + {0x19, 0x03a11030}, + {0x21, 0x03211020}), SND_HDA_PIN_QUIRK(0x10ec0286, 0x1025, "Acer", ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE, {0x12, 0x90a60130}, {0x17, 0x90170110},
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 7/162 ALSA: hda/realtek - ALC287 Realtek I2S speaker platform support
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kailang Yang <[email protected]>
[ Upstream commit 41b07476da38ac2878a14e5b8fe0312c41ea36e3 ]
New platform SSID:0x231f.
0x17 was only speaker pin, DAC assigned will be 0x03. Headphone assigned to 0x02.
Playback via headphone will get EQ filter processing. So, it needs to swap DAC.
--- sound/pci/hda/patch_realtek.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/pci/hda/patch_realtek.c +4 -0
@@ -10544,6 +10544,10 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = { {0x17, 0x90170110}, {0x19, 0x03a11030}, {0x21, 0x03211020}), + SND_HDA_PIN_QUIRK(0x10ec0287, 0x17aa, "Lenovo", ALC287_FIXUP_THINKPAD_I2S_SPK, + {0x17, 0x90170110}, /* 0x231f with RTK I2S AMP */ + {0x19, 0x04a11040}, + {0x21, 0x04211020}), SND_HDA_PIN_QUIRK(0x10ec0286, 0x1025, "Acer", ALC286_FIXUP_ACER_AIO_MIC_NO_PRESENCE, {0x12, 0x90a60130}, {0x17, 0x90170110},
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 8/162 ASoC: soc-utils: Export snd_soc_dai_is_dummy() symbol
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sameer Pujar <[email protected]>
[ Upstream commit f101583fa9f8c3f372d4feb61d67da0ccbf4d9a5 ]
Export symbol snd_soc_dai_is_dummy() for usage outside core driver modules. This is required by Tegra ASoC machine driver.
--- sound/soc/soc-utils.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/soc-utils.c +1 -0
@@ -217,6 +217,7 @@ int snd_soc_dai_is_dummy(struct snd_soc_dai *dai)return 1 ;return 0 ; } +EXPORT_SYMBOL_GPL (snd_soc_dai_is_dummy);int snd_soc_component_is_dummy (struct snd_soc_component *component) {
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 9/162 ASoC: tegra: Fix redundant PLLA and PLLA_OUT0 updates
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sameer Pujar <[email protected]>
[ Upstream commit e765886249c533e1bb5cbc3cd741bad677417312 ]
Tegra audio graph card has many DAI links which connects internal AHUB modules and external audio codecs. Since these are DPCM links, hw_params() call in the machine driver happens for each connected BE link and PLLA is updated every time. This is not really needed for all links as only I/O link DAIs derive respective clocks from PLLA_OUT0 and thus from PLLA. Hence add checks to limit the clock updates to DAIs over I/O links.
This found to be fixing a DMIC clock discrepancy which is suspected to happen because of back to back quick PLLA and PLLA_OUT0 rate updates. This was observed on Jetson TX2 platform where DMIC clock ended up with unexpected value.
--- sound/soc/tegra/tegra_audio_graph_card.c | 30 ++++++++++++++---------- 1 file changed, 17 insertions(+), 13 deletions(-)
sound/soc/tegra/tegra_audio_graph_card.c +17 -13
@@ -10,6 +10,7 @@#include <linux/platform_device.h> #include <sound/graph_card.h> #include <sound/pcm_params.h> +#include <sound/soc-dai.h> #define MAX_PLLA_OUT0_DIV 128
@@ -44,6 +45,21 @@ struct tegra_audio_cdata {unsigned int plla_out0_rates[NUM_RATE_TYPE ]; }; +static bool need_clk_update (struct snd_soc_dai *dai) +{ +if (snd_soc_dai_is_dummy (dai) || + !dai->driver->ops || + !dai->driver->name) +return false; + +if (strstr (dai->driver->name,"I2S" ) || +strstr (dai->driver->name,"DMIC" ) || +strstr (dai->driver->name,"DSPK" )) +return true; + +return false; +} +/* Setup PLL clock as per the given sample rate */ static int tegra_audio_graph_update_pll (struct snd_pcm_substream *substream,struct snd_pcm_hw_params *params)
@@ -140,19 +156,7 @@ static int tegra_audio_graph_hw_params(struct snd_pcm_substream *substream,struct snd_soc_dai *cpu_dai =asoc_rtd_to_cpu (rtd,0 );int err; -/* -* This gets called for each DAI link (FE or BE) when DPCM is used. -* We may not want to update PLLA rate for each call. So PLLA update -* must be restricted to external I/O links (I2S, DMIC or DSPK) since -* they actually depend on it. I/O modules update their clocks in -* hw_param() of their respective component driver and PLLA rate -* update here helps them to derive appropriate rates. -* -* TODO: When more HW accelerators get added (like sample rate -* converter, volume gain controller etc., which don't really -* depend on PLLA) we need a better way to filter here. -*/ -if (cpu_dai->driver->ops && rtd->dai_link->no_pcm) { +if (need_clk_update (cpu_dai)) { err =tegra_audio_graph_update_pll (substream, params);if (err)return err;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainercover 6.1.57-rc1 review
This is the start of the stable review cycle for the 6.1.57 release. There are 162 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 11 Oct 2023 13:00:55 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.1.57-rc1.gz
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-6.1.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 6.1.57-rc1
Jakub Kicinski <[email protected]>
netlink: remove the flex array from struct nlmsghdr
Filipe Manana <[email protected]>
btrfs: fix fscrypt name leak after failure to join log transaction
Christophe JAILLET <[email protected]>
btrfs: fix an error handling path in btrfs_rename()
Ido Schimmel <[email protected]>
vrf: Fix lockdep splat in output path
Eric Dumazet <[email protected]>
ipv6: remove nexthop_fib6_nh_bh()
John David Anglin <[email protected]>
parisc: Restore __ldcw_align for PA-RISC 2.0 processors
luosili <[email protected]>
ksmbd: fix uaf in smb20_oplock_break_ack
Namjae Jeon <[email protected]>
ksmbd: fix race condition between session lookup and expire
Tom Lendacky <[email protected]>
x86/sev: Use the GHCB protocol when available for SNP CPUID requests
Kailang Yang <[email protected]>
ALSA: hda/realtek - Fixed two speaker platform
Colin Ian King <[email protected]>
ALSA: hda/realtek: Fix spelling mistake "powe" -> "power"
Shay Drory <[email protected]>
RDMA/mlx5: Fix NULL string error
Hamdan Igbaria <[email protected]>
RDMA/mlx5: Fix mutex unlocking on error flow for steering anchor creation
Bernard Metzler <[email protected]>
RDMA/siw: Fix connection failure handling
Bart Van Assche <[email protected]>
RDMA/srp: Do not call scsi_done() from srp_abort()
Konstantin Meskhidze <[email protected]>
RDMA/uverbs: Fix typo of sizeof argument
Leon Romanovsky <[email protected]>
RDMA/cma: Fix truncation compilation warning in make_cma_ports
Mark Zhang <[email protected]>
RDMA/cma: Initialize ib_sa_multicast structure to 0 when join
Duje Mihanović <[email protected]>
gpio: pxa: disable pinctrl calls for MMP_GPIO
Bartosz Golaszewski <[email protected]>
gpio: aspeed: fix the GPIO number passed to pinctrl_gpio_set_config()
Christophe JAILLET <[email protected]>
IB/mlx4: Fix the size of a buffer in add_port_entries()
Dan Carpenter <[email protected]>
of: dynamic: Fix potential memory leak in of_changeset_action()
Leon Romanovsky <[email protected]>
RDMA/core: Require admin capabilities to set system parameters
Fedor Pchelkin <[email protected]>
dm zoned: free dmz->ddev array in dmz_put_zoned_devices
Helge Deller <[email protected]>
parisc: Fix crash with nr_cpus=1 option
Jordan Rife <[email protected]>
smb: use kernel_connect() and kernel_bind()
Artem Bityutskiy <[email protected]>
intel_idle: add Emerald Rapids Xeon support
Srinivas Pandruvada <[email protected]>
HID: intel-ish-hid: ipc: Disable and reenable ACPI GPE bit
Jiri Kosina <[email protected]>
HID: sony: remove duplicate NULL check before calling usb_free_urb()
Eric Dumazet <[email protected]>
netlink: annotate data-races around sk->sk_err
Tao Chen <[email protected]>
netlink: Fix potential skb memleak in netlink_ack
Jakub Kicinski <[email protected]>
netlink: split up copies in the ack construction
Xin Long <[email protected]>
sctp: update hb timer immediately after users change hb_interval
Xin Long <[email protected]>
sctp: update transport state when processing a dupcook packet
Neal Cardwell <[email protected]>
tcp: fix delayed ACKs for MSS boundary condition
Neal Cardwell <[email protected]>
tcp: fix quick-ack counting to count actual ACKs of new data
Chengfeng Ye <[email protected]>
tipc: fix a potential deadlock on &tx->lock
Ben Wolsieffer <[email protected]>
net: stmmac: dwmac-stm32: fix resume on STM32 MCU
Benjamin Poirier <[email protected]>
ipv4: Set offload_failed flag in fibmatch results
Florian Westphal <[email protected]>
netfilter: nf_tables: nft_set_rbtree: fix spurious insertion failure
Phil Sutter <[email protected]>
netfilter: nf_tables: Deduplicate nft_register_obj audit logs
Phil Sutter <[email protected]>
selftests: netfilter: Extend nft_audit.sh
Phil Sutter <[email protected]>
selftests: netfilter: Test nf_tables audit logging
Xin Long <[email protected]>
netfilter: handle the connecting collision properly in nf_conntrack_proto_sctp
David Wilder <[email protected]>
ibmveth: Remove condition to recompute TCP header checksum.
Dan Carpenter <[email protected]>
net: ethernet: ti: am65-cpsw: Fix error code in am65_cpsw_nuss_init_tx_chns()
Jeremy Cline <[email protected]>
net: nfc: llcp: Add lock when modifying device list
Shigeru Yoshida <[email protected]>
net: usb: smsc75xx: Fix uninit-value access in __smsc75xx_read_reg
Ilya Maximets <[email protected]>
ipv6: tcp: add a missing nf_reset_ct() in 3WHS handling
Fabio Estevam <[email protected]>
net: dsa: mv88e6xxx: Avoid EEPROM timeout when EEPROM is absent
Dinghao Liu <[email protected]>
ptp: ocp: Fix error handling in ptp_ocp_device_init
David Howells <[email protected]>
ipv4, ipv6: Fix handling of transhdrlen in __ip{,6}_append_data()
Eric Dumazet <[email protected]>
neighbour: fix data-races around n->output
Eric Dumazet <[email protected]>
neighbour: switch to standard rcu, instead of rcu_bh
Eric Dumazet <[email protected]>
neighbour: annotate lockless accesses to n->nud_state
Martin KaFai Lau <[email protected]>
bpf: Add BPF_FIB_LOOKUP_SKIP_NEIGH for bpf_fib_lookup
Eric Dumazet <[email protected]>
net: fix possible store tearing in neigh_periodic_work()
Mauricio Faria de Oliveira <[email protected]>
modpost: add missing else to the "of" check
Jakub Sitnicki <[email protected]>
bpf, sockmap: Reject sk_msg egress redirects to non-TCP sockets
John Fastabend <[email protected]>
bpf, sockmap: Do not inc copied_seq when PEEK flag set
John Fastabend <[email protected]>
bpf: tcp_read_skb needs to pop skb regardless of seq
Trond Myklebust <[email protected]>
NFSv4: Fix a nfs4_state_manager() race
Arnd Bergmann <[email protected]>
ima: rework CONFIG_IMA dependency block
Junxiao Bi <[email protected]>
scsi: target: core: Fix deadlock due to recursive locking
Oleksandr Tymoshenko <[email protected]>
ima: Finish deprecation of IMA_TRUSTED_KEYRING Kconfig
Michał Mirosław <[email protected]>
regulator/core: regulator_register: set device->class earlier
Yong Wu <[email protected]>
iommu/mediatek: Fix share pgtable for iova over 4GB
Breno Leitao <[email protected]>
perf/x86/amd: Do not WARN() on every IRQ
Johannes Berg <[email protected]>
wifi: mac80211: fix potential key use-after-free
Richard Fitzgerald <[email protected]>
regmap: rbtree: Fix wrong register marked as in-cache when creating new node
Sandipan Das <[email protected]>
perf/x86/amd/core: Fix overflow reset on hotplug
Felix Fietkau <[email protected]>
wifi: mt76: mt76x02: fix MT76x0 external LNA gain handling
Alexandra Diupina <[email protected]>
drivers/net: process the result of hdlc_open() and add call of hdlc_close() in uhdlc_close()
Luiz Augusto von Dentz <[email protected]>
Bluetooth: ISO: Fix handling of listen for unicast
Yao Xiao <[email protected]>
Bluetooth: Delete unused hci_req_prepare_suspend() declaration
Chen-Yu Tsai <[email protected]>
regulator: mt6358: split ops for buck and linear range LDO regulators
Chen-Yu Tsai <[email protected]>
regulator: mt6358: Use linear voltage helpers for single range regulators
Chen-Yu Tsai <[email protected]>
regulator: mt6358: Drop *_SSHUB regulators
Leon Hwang <[email protected]>
bpf: Fix tr dereferencing
Marek Behún <[email protected]>
leds: Drop BUG_ON check for LED_COLOR_ID_MULTI
Pin-yen Lin <[email protected]>
wifi: mwifiex: Fix oob check condition in mwifiex_process_rx_packet
Johannes Berg <[email protected]>
wifi: cfg80211: add missing kernel-doc for cqm_rssi_work
Johannes Berg <[email protected]>
wifi: cfg80211: fix cqm_config access race
Johannes Berg <[email protected]>
wifi: cfg80211: add a work abstraction with special semantics
Johannes Berg <[email protected]>
wifi: cfg80211: move wowlan disable under locks
Johannes Berg <[email protected]>
wifi: cfg80211: hold wiphy lock in auto-disconnect
Christophe JAILLET <[email protected]>
wifi: iwlwifi: mvm: Fix a memory corruption issue
Arnd Bergmann <[email protected]>
wifi: iwlwifi: dbg_ini: fix structure packing
Gao Xiang <[email protected]>
erofs: fix memory leak of LZMA global compressed deduplication
Zhihao Cheng <[email protected]>
ubi: Refuse attaching if mtd's erasesize is 0
Christophe JAILLET <[email protected]>
HID: sony: Fix a potential memory leak in sony_probe()
Rob Herring <[email protected]>
arm64: errata: Add Cortex-A520 speculative unprivileged load workaround
Rob Herring <[email protected]>
arm64: Add Cortex-A520 CPU part definition
Mario Limonciello <[email protected]>
drm/amd: Fix logic error in sienna_cichlid_update_pcie_parameters()
Mario Limonciello <[email protected]>
drm/amd: Fix detection of _PR3 on the PCIe root port
Jordan Rife <[email protected]>
net: prevent rewrite of msg_name in sock_sendmsg()
Qu Wenruo <[email protected]>
btrfs: reject unknown mount options early
Jordan Rife <[email protected]>
net: replace calls to sock->ops->connect() with kernel_connect()
Sricharan Ramabadhran <[email protected]>
PCI: qcom: Fix IPQ8074 enumeration
David Jeffery <[email protected]>
md/raid5: release batch_last before waiting for another stripe_head
Gustavo A. R. Silva <[email protected]>
wifi: mwifiex: Fix tlv_buf_left calculation
Luiz Augusto von Dentz <[email protected]>
Bluetooth: hci_sync: Fix handling of HCI_QUIRK_STRICT_DUPLICATE_FILTER
Luiz Augusto von Dentz <[email protected]>
Bluetooth: hci_codec: Fix leaking content of local_codecs
Gustavo A. R. Silva <[email protected]>
qed/red_ll2: Fix undefined behavior bug in struct qed_ll2_info
Geliang Tang <[email protected]>
mptcp: userspace pm allow creating id 0 subflow
Christian Marangi <[email protected]>
net: ethernet: mediatek: disable irq before schedule napi
Stefano Garzarella <[email protected]>
vringh: don't use vringh_kiov_advance() in vringh_iov_xfer()
Zhang Rui <[email protected]>
iommu/vt-d: Avoid memory allocation in iommu_suspend()
Dinghao Liu <[email protected]>
scsi: zfcp: Fix a double put in zfcp_port_enqueue()
Yajun Deng <[email protected]>
i40e: fix the wrong PTP frequency calculation
Aleksandr Mezin <[email protected]>
hwmon: (nzxt-smart2) add another USB ID
Herman Fries <[email protected]>
hwmon: (nzxt-smart2) Add device id
Ming Lei <[email protected]>
block: fix use-after-free of q->q_usage_counter
Ilya Dryomov <[email protected]>
rbd: take header_rwsem in rbd_dev_refresh() only when updating
Ilya Dryomov <[email protected]>
rbd: decouple parent info read-in from updating rbd_dev
Ilya Dryomov <[email protected]>
rbd: decouple header read-in from updating rbd_dev->header
Ilya Dryomov <[email protected]>
rbd: move rbd_dev_refresh() definition
Robin Murphy <[email protected]>
iommu/arm-smmu-v3: Avoid constructing invalid range commands
Robin Murphy <[email protected]>
iommu/arm-smmu-v3: Set TTL invalidation hint better
Wayne Lin <[email protected]>
drm/amd/display: Adjust the MST resume flow
Kristina Martsenko <[email protected]>
arm64: cpufeature: Fix CLRBHB and BC detection
Patrick Rohr <[email protected]>
net: release reference to inet6_dev pointer
Patrick Rohr <[email protected]>
net: change accept_ra_min_rtr_lft to affect all RA lifetimes
Patrick Rohr <[email protected]>
net: add sysctl accept_ra_min_rtr_lft
Gabriel Krisman Bertazi <[email protected]>
arm64: Avoid repeated AA64MMFR1_EL1 register read on pagefault path
Benjamin Coddington <[email protected]>
Revert "NFSv4: Retry LOCK on OLD_STATEID during delegation return"
Sweet Tea Dorminy <[email protected]>
btrfs: use struct fscrypt_str instead of struct qstr
Sweet Tea Dorminy <[email protected]>
btrfs: setup qstr from dentrys using fscrypt helper
Sweet Tea Dorminy <[email protected]>
btrfs: use struct qstr instead of name and namelen pairs
Zheng Yejian <[email protected]>
ring-buffer: Fix bytes info in per_cpu buffer stats
Vlastimil Babka <[email protected]>
ring-buffer: remove obsolete comment for free_buffer_page()
Johannes Weiner <[email protected]>
mm: page_alloc: fix CMA and HIGHATOMIC landing on the wrong buddy list
Mel Gorman <[email protected]>
mm/page_alloc: leave IRQs enabled for per-cpu page allocations
Mel Gorman <[email protected]>
mm/page_alloc: always remove pages from temporary list
Yang Shi <[email protected]>
mm: mempolicy: keep VMA walk if both MPOL_MF_STRICT and MPOL_MF_MOVE are specified
Vishal Moola (Oracle) <[email protected]>
mm/mempolicy: convert migrate_page_add() to migrate_folio_add()
Vishal Moola (Oracle) <[email protected]>
mm/mempolicy: convert queue_pages_pte_range() to queue_folios_pte_range()
Vishal Moola (Oracle) <[email protected]>
mm/mempolicy: convert queue_pages_pmd() to queue_folios_pmd()
Vishal Moola (Oracle) <[email protected]>
mm/memory: add vm_normal_folio()
Trond Myklebust <[email protected]>
NFSv4: Fix a state manager thread deadlock regression
Benjamin Coddington <[email protected]>
NFS: rename nfs_client_kset to nfs_kset
Benjamin Coddington <[email protected]>
NFS: Cleanup unused rpc_clnt variable
Damien Le Moal <[email protected]>
ata: libata-scsi: Fix delayed scsi_rescan_device() execution
Damien Le Moal <[email protected]>
scsi: Do not attempt to rescan suspended devices
Bart Van Assche <[email protected]>
scsi: core: Improve type safety of scsi_rescan_device()
Damien Le Moal <[email protected]>
scsi: sd: Do not issue commands to suspended disks on shutdown
Damien Le Moal <[email protected]>
scsi: sd: Differentiate system and runtime start/stop management
Damien Le Moal <[email protected]>
ata,scsi: do not issue START STOP UNIT on resume
Paolo Abeni <[email protected]>
mptcp: process pending subflow error on close
Paolo Abeni <[email protected]>
mptcp: move __mptcp_error_report in protocol.c
Eric Dumazet <[email protected]>
mptcp: annotate lockless accesses to sk->sk_err
Paolo Abeni <[email protected]>
mptcp: fix dangling connection hang-up
Paolo Abeni <[email protected]>
mptcp: rename timer related helper to less confusing names
Sameer Pujar <[email protected]>
ASoC: tegra: Fix redundant PLLA and PLLA_OUT0 updates
Sameer Pujar <[email protected]>
ASoC: soc-utils: Export snd_soc_dai_is_dummy() symbol
Kailang Yang <[email protected]>
ALSA: hda/realtek - ALC287 Realtek I2S speaker platform support
Kailang Yang <[email protected]>
ALSA: hda/realtek - ALC287 I2S speaker platform support
Fabian Vogt <[email protected]>
ALSA: hda/realtek: Add quirk for mute LEDs on HP ENVY x360 15-eu0xxx
SungHwan Jung <[email protected]>
ALSA: hda/realtek: Add quirk for HP Victus 16-d1xxx to enable mute LED
Shenghao Ding <[email protected]>
ALSA: hda/tas2781: Add tas2781 HDA driver
Johan Hovold <[email protected]>
spi: zynqmp-gqspi: fix clock imbalance on probe failure
Uwe Kleine-König <[email protected]>
spi: zynqmp-gqspi: Convert to platform remove callback returning void
-------------
Diffstat:
Documentation/arm64/silicon-errata.rst | 2 + Documentation/networking/ip-sysctl.rst | 8 + Makefile | 4 +- arch/arm64/Kconfig | 13 + arch/arm64/include/asm/cpufeature.h | 8 +- arch/arm64/include/asm/cputype.h | 2 + arch/arm64/kernel/cpu_errata.c | 8 + arch/arm64/kernel/cpufeature.c | 3 +- arch/arm64/kernel/entry.S | 4 + arch/arm64/tools/cpucaps | 1 + arch/arm64/tools/sysreg | 6 +- arch/parisc/include/asm/ldcw.h | 36 +- arch/parisc/include/asm/spinlock_types.h | 5 - arch/parisc/kernel/smp.c | 4 +- arch/x86/events/amd/core.c | 24 +- arch/x86/kernel/sev-shared.c | 69 +++- block/blk-sysfs.c | 3 +- drivers/ata/libata-core.c | 16 + drivers/ata/libata-scsi.c | 43 ++- drivers/base/regmap/regcache-rbtree.c | 3 +- drivers/block/rbd.c | 412 +++++++++++---------- drivers/firewire/sbp2.c | 9 +- drivers/gpio/gpio-aspeed.c | 2 +- drivers/gpio/gpio-pxa.c | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 93 ++++- .../drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c | 41 +- drivers/hid/hid-sony.c | 2 + drivers/hid/intel-ish-hid/ipc/pci-ish.c | 8 + drivers/hwmon/nzxt-smart2.c | 2 + drivers/idle/intel_idle.c | 2 + drivers/infiniband/core/cma.c | 2 +- drivers/infiniband/core/cma_configfs.c | 2 +- drivers/infiniband/core/nldev.c | 1 + drivers/infiniband/core/uverbs_main.c | 2 +- drivers/infiniband/hw/mlx4/sysfs.c | 2 +- drivers/infiniband/hw/mlx5/fs.c | 2 +- drivers/infiniband/hw/mlx5/main.c | 2 +- drivers/infiniband/sw/siw/siw_cm.c | 16 +- drivers/infiniband/ulp/srp/ib_srp.c | 16 +- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 18 +- drivers/iommu/intel/iommu.c | 16 - drivers/iommu/intel/iommu.h | 2 +- drivers/iommu/mtk_iommu.c | 9 +- drivers/leds/led-core.c | 4 - drivers/md/dm-zoned-target.c | 15 +- drivers/md/raid5.c | 7 + drivers/mtd/ubi/build.c | 7 + drivers/net/dsa/mv88e6xxx/chip.c | 6 +- drivers/net/dsa/mv88e6xxx/global1.c | 31 -- drivers/net/dsa/mv88e6xxx/global1.h | 1 - drivers/net/dsa/mv88e6xxx/global2.c | 2 +- drivers/net/dsa/mv88e6xxx/global2.h | 1 + drivers/net/ethernet/ibm/ibmveth.c | 25 +- drivers/net/ethernet/intel/i40e/i40e_ptp.c | 4 +- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 4 +- drivers/net/ethernet/qlogic/qed/qed_ll2.h | 2 +- drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c | 7 +- drivers/net/ethernet/ti/am65-cpsw-nuss.c | 1 + drivers/net/usb/smsc75xx.c | 4 +- drivers/net/vrf.c | 12 +- drivers/net/vxlan/vxlan_core.c | 4 +- drivers/net/wan/fsl_ucc_hdlc.c | 12 +- drivers/net/wireless/intel/iwlwifi/fw/error-dump.h | 6 +- drivers/net/wireless/intel/iwlwifi/mvm/fw.c | 2 +- .../net/wireless/marvell/mwifiex/11n_rxreorder.c | 4 +- drivers/net/wireless/marvell/mwifiex/sta_rx.c | 16 +- .../net/wireless/mediatek/mt76/mt76x02_eeprom.c | 7 - drivers/net/wireless/mediatek/mt76/mt76x2/eeprom.c | 13 +- drivers/of/dynamic.c | 6 +- drivers/pci/controller/dwc/pcie-qcom.c | 4 +- drivers/ptp/ptp_ocp.c | 1 - drivers/regulator/core.c | 4 +- drivers/regulator/mt6358-regulator.c | 153 +++----- drivers/s390/scsi/zfcp_aux.c | 9 +- drivers/scsi/aacraid/commsup.c | 2 +- drivers/scsi/mvumi.c | 2 +- drivers/scsi/scsi_lib.c | 2 +- drivers/scsi/scsi_priv.h | 1 - drivers/scsi/scsi_scan.c | 20 +- drivers/scsi/scsi_sysfs.c | 4 +- drivers/scsi/sd.c | 110 ++++-- drivers/scsi/sd.h | 1 + drivers/scsi/smartpqi/smartpqi_init.c | 2 +- drivers/scsi/storvsc_drv.c | 2 +- drivers/scsi/virtio_scsi.c | 2 +- drivers/spi/spi-zynqmp-gqspi.c | 18 +- drivers/target/target_core_device.c | 11 +- drivers/vhost/vringh.c | 12 +- fs/btrfs/ctree.h | 28 +- fs/btrfs/dir-item.c | 50 ++- fs/btrfs/inode-item.c | 73 ++-- fs/btrfs/inode-item.h | 20 +- fs/btrfs/inode.c | 267 ++++++++----- fs/btrfs/ioctl.c | 7 +- fs/btrfs/root-tree.c | 19 +- fs/btrfs/send.c | 12 +- fs/btrfs/super.c | 7 +- fs/btrfs/transaction.c | 40 +- fs/btrfs/tree-log.c | 279 +++++++------- fs/btrfs/tree-log.h | 4 +- fs/erofs/decompressor_lzma.c | 5 +- fs/nfs/nfs4proc.c | 10 +- fs/nfs/nfs4state.c | 47 ++- fs/nfs/sysfs.c | 16 +- fs/smb/client/connect.c | 10 +- fs/smb/server/connection.c | 2 + fs/smb/server/connection.h | 1 + fs/smb/server/mgmt/user_session.c | 10 +- fs/smb/server/smb2pdu.c | 4 +- include/linux/bpf.h | 2 +- include/linux/ipv6.h | 1 + include/linux/mm.h | 2 + include/linux/netfilter/nf_conntrack_sctp.h | 1 + include/linux/regulator/mt6358-regulator.h | 4 - include/net/arp.h | 8 +- include/net/cfg80211.h | 99 ++++- include/net/ndisc.h | 12 +- include/net/neighbour.h | 10 +- include/net/netlink.h | 21 ++ include/net/nexthop.h | 23 -- include/net/tcp.h | 6 +- include/scsi/scsi_device.h | 6 +- include/scsi/scsi_host.h | 2 +- include/uapi/linux/bpf.h | 6 + include/uapi/linux/ipv6.h | 1 + kernel/trace/ring_buffer.c | 32 +- mm/memory.c | 10 + mm/mempolicy.c | 122 +++--- mm/page_alloc.c | 138 ++++--- net/bluetooth/hci_core.c | 1 + net/bluetooth/hci_event.c | 1 + net/bluetooth/hci_request.h | 2 - net/bluetooth/hci_sync.c | 14 +- net/bluetooth/iso.c | 9 +- net/bridge/br_arp_nd_proxy.c | 4 +- net/bridge/br_netfilter_hooks.c | 5 +- net/core/filter.c | 59 +-- net/core/neighbour.c | 106 +++--- net/core/sock_map.c | 4 + net/ipv4/arp.c | 8 +- net/ipv4/fib_semantics.c | 8 +- net/ipv4/ip_output.c | 6 +- net/ipv4/nexthop.c | 12 +- net/ipv4/route.c | 8 +- net/ipv4/tcp.c | 10 +- net/ipv4/tcp_bpf.c | 4 +- net/ipv4/tcp_input.c | 13 + net/ipv4/tcp_output.c | 7 +- net/ipv6/addrconf.c | 27 +- net/ipv6/ip6_fib.c | 16 +- net/ipv6/ip6_output.c | 12 +- net/ipv6/ndisc.c | 17 +- net/ipv6/route.c | 14 +- net/ipv6/tcp_ipv6.c | 10 +- net/l2tp/l2tp_ip6.c | 2 +- net/mac80211/cfg.c | 3 + net/mac80211/key.c | 2 +- net/mptcp/pm_netlink.c | 2 +- net/mptcp/pm_userspace.c | 6 - net/mptcp/protocol.c | 177 +++++---- net/mptcp/protocol.h | 24 +- net/mptcp/subflow.c | 41 +- net/netfilter/ipvs/ip_vs_sync.c | 4 +- net/netfilter/nf_conntrack_proto_sctp.c | 43 ++- net/netfilter/nf_tables_api.c | 44 ++- net/netfilter/nft_set_rbtree.c | 46 ++- net/netlink/af_netlink.c | 37 +- net/nfc/llcp_core.c | 2 + net/rds/tcp_connect.c | 2 +- net/sctp/associola.c | 3 +- net/sctp/socket.c | 1 + net/socket.c | 29 +- net/tipc/crypto.c | 4 +- net/wireless/core.c | 150 +++++++- net/wireless/core.h | 14 +- net/wireless/nl80211.c | 93 +++-- net/wireless/sme.c | 4 +- net/wireless/sysfs.c | 8 +- scripts/mod/file2alias.c | 2 +- security/integrity/ima/Kconfig | 22 +- sound/pci/hda/patch_realtek.c | 154 +++++++- sound/soc/soc-utils.c | 1 + sound/soc/tegra/tegra_audio_graph_card.c | 30 +- tools/include/uapi/linux/bpf.h | 6 + tools/testing/selftests/netfilter/.gitignore | 1 + tools/testing/selftests/netfilter/Makefile | 4 +- tools/testing/selftests/netfilter/audit_logread.c | 165 +++++++++ tools/testing/selftests/netfilter/config | 1 + tools/testing/selftests/netfilter/nft_audit.sh | 193 ++++++++++ 190 files changed, 2961 insertions(+), 1642 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 15/162 ata,scsi: do not issue START STOP UNIT on resume
6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
[ Upstream commit 0a8589055936d8feb56477123a8373ac634018fa ]
During system resume, ata_port_pm_resume() triggers ata EH to
1) Resume the controller
2) Reset and rescan the ports
3) Revalidate devices
This EH execution is started asynchronously from ata_port_pm_resume(), which means that when sd_resume() is executed, none or only part of the above processing may have been executed. However, sd_resume() issues a START STOP UNIT to wake up the drive from sleep mode. This command is translated to ATA with ata_scsi_start_stop_xlat() and issued to the device. However, depending on the state of execution of the EH process and revalidation triggerred by ata_port_pm_resume(), two things may happen:
1) The START STOP UNIT fails if it is received before the controller has been reenabled at the beginning of the EH execution. This is visible with error messages like:
ata10.00: device reported invalid CHS sector 0
sd 9:0:0:0: [sdc] Start/Stop Unit failed: Result: hostbyte=DID_OK driverbyte=DRIVER_OK sd 9:0:0:0: [sdc] Sense Key : Illegal Request [current]
sd 9:0:0:0: [sdc] Add. Sense: Unaligned write command
sd 9:0:0:0: PM: dpm_run_callback(): scsi_bus_resume+0x0/0x90 returns -5 sd 9:0:0:0: PM: failed to resume async: error -5
2) The START STOP UNIT command is received while the EH process is on-going, which mean that it is stopped and must wait for its completion, at which point the command is rather useless as the drive is already fully spun up already. This case results also in a significant delay in sd_resume() which is observable by users as the entire system resume completion is delayed.
Given that ATA devices will be woken up by libata activity on resume, sd_resume() has no need to issue a START STOP UNIT command, which solves the above mentioned problems. Do not issue this command by introducing the new scsi_device flag no_start_on_resume and setting this flag to 1 in ata_scsi_dev_config(). sd_resume() is modified to issue a START STOP UNIT command only if this flag is not set.
Stable-dep-of: 99398d2070ab ("scsi: sd: Do not issue commands to suspended disks on shutdown")
--- drivers/ata/libata-scsi.c | 7 +++++++ drivers/scsi/sd.c | 9 ++++++--- include/scsi/scsi_device.h | 1 + 3 files changed, 14 insertions(+), 3 deletions(-)
drivers/ata/libata-scsi.c +7 -0
@@ -1081,7 +1081,14 @@ int ata_scsi_dev_config(struct scsi_device *sdev, struct ata_device *dev) } }else { sdev->sector_size =ata_id_logical_sector_size (dev->id); +/* +* Stop the drive on suspend but do not issue START STOP UNIT +* on resume as this is not necessary and may fail: the device +* will be woken up by ata_port_pm_resume() with a port reset +* and device revalidation. +*/ sdev->manage_start_stop =1 ; + sdev->no_start_on_resume =1 ; }/*
drivers/scsi/sd.c +6 -3
@@ -3718,7 +3718,7 @@ static int sd_suspend_runtime(struct device *dev)static int sd_resume (struct device *dev) {struct scsi_disk *sdkp =dev_get_drvdata (dev); -int ret; +int ret =0 ;if (!sdkp)/* E.g.: runtime resume at the start of sd_probe() */ return 0 ;
@@ -3726,8 +3726,11 @@ static int sd_resume(struct device *dev)if (!sdkp->device->manage_start_stop)return 0 ; -sd_printk (KERN_NOTICE , sdkp,"Starting disk\n" ); - ret =sd_start_stop_device (sdkp,1 ); +if (!sdkp->device->no_start_on_resume) { +sd_printk (KERN_NOTICE , sdkp,"Starting disk\n" ); + ret =sd_start_stop_device (sdkp,1 ); + } +if (!ret)opal_unlock_from_suspend (sdkp->opal_dev);return ret;
include/scsi/scsi_device.h +1 -0
@@ -193,6 +193,7 @@ struct scsi_device { unsigned no_start_on_add:1; /* do not issue start on add */ unsigned allow_restart:1; /* issue START_UNIT in error handler */ unsigned manage_start_stop:1; /* Let HLD (sd) manage start/stop */ + unsigned no_start_on_resume:1; /* Do not issue START_STOP_UNIT on resume */ unsigned start_stop_pwr_cond:1; /* Set power cond. in START_STOP_UNIT */ unsigned no_uld_attach:1; /* disable connecting to upper level drivers */ unsigned select_no_atn:1;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 24/162 mm/memory: add vm_normal_folio()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vishal Moola (Oracle) <[email protected]>
[ Upstream commit 318e9342fbbb6888d903d86e83865609901a1c65 ]
Patch series "Convert deactivate_page() to folio_deactivate()", v4.
Deactivate_page() has already been converted to use folios. This patch series modifies the callers of deactivate_page() to use folios. It also introduces vm_normal_folio() to assist with folio conversions, and converts deactivate_page() to folio_deactivate() which takes in a folio.
This patch (of 4):
Introduce a wrapper function called vm_normal_folio(). This function calls vm_normal_page() and returns the folio of the page found, or null if no page is found.
This function allows callers to get a folio from a pte, which will eventually allow them to completely replace their struct page variables with struct folio instead.
Stable-dep-of: 24526268f4e3 ("mm: mempolicy: keep VMA walk if both MPOL_MF_STRICT and MPOL_MF_MOVE are specified")
--- include/linux/mm.h | 2 ++ mm/memory.c | 10 ++++++++++ 2 files changed, 12 insertions(+)
include/linux/mm.h +2 -0
@@ -1906,6 +1906,8 @@ static inline bool can_do_mlock(void) { return false; }extern int user_shm_lock (size_t ,struct ucounts *);extern void user_shm_unlock (size_t ,struct ucounts *); +struct folio *vm_normal_folio (struct vm_area_struct *vma,unsigned long addr, +pte_t pte);struct page *vm_normal_page (struct vm_area_struct *vma,unsigned long addr,pte_t pte); struct page *vm_normal_page_pmd(struct vm_area_struct *vma, unsigned long addr,
mm/memory.c +10 -0
@@ -672,6 +672,16 @@ struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr,return pfn_to_page (pfn); } +struct folio *vm_normal_folio (struct vm_area_struct *vma,unsigned long addr, +pte_t pte) +{ +struct page *page =vm_normal_page (vma, addr, pte); + +if (page) +return page_folio (page); +return NULL ; +} +#ifdef CONFIG_TRANSPARENT_HUGEPAGE struct page *vm_normal_page_pmd (struct vm_area_struct *vma,unsigned long addr,pmd_t pmd)
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 25/162 mm/mempolicy: convert queue_pages_pmd() to queue_folios_pmd()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vishal Moola (Oracle) <[email protected]>
[ Upstream commit de1f5055523e9a035b38533f25a56df03d45034a ]
The function now operates on a folio instead of the page associated with a pmd.
This change is in preparation for the conversion of queue_pages_required() to queue_folio_required() and migrate_page_add() to migrate_folio_add().
Stable-dep-of: 24526268f4e3 ("mm: mempolicy: keep VMA walk if both MPOL_MF_STRICT and MPOL_MF_MOVE are specified")
--- mm/mempolicy.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
mm/mempolicy.c +12 -12
@@ -442,21 +442,21 @@ static inline bool queue_pages_required(struct page *page, }/* -* queue_pages_pmd() has three possible return values: -* 0 - pages are placed on the right node or queued successfully, or +* queue_folios_pmd() has three possible return values: +* 0 - folios are placed on the right node or queued successfully, or * special page is met, i.e. huge zero page. -* 1 - there is unmovable page, and MPOL_MF_MOVE* & MPOL_MF_STRICT were +* 1 - there is unmovable folio, and MPOL_MF_MOVE* & MPOL_MF_STRICT were * specified. * -EIO - is migration entry or only MPOL_MF_STRICT was specified and an -* existing page was already on a node that does not follow the +* existing folio was already on a node that does not follow the * policy. */ -static int queue_pages_pmd (pmd_t *pmd,spinlock_t *ptl,unsigned long addr, +static int queue_folios_pmd (pmd_t *pmd,spinlock_t *ptl,unsigned long addr,unsigned long end,struct mm_walk *walk)__releases (ptl) {int ret =0 ; -struct page *page; +struct folio *folio;struct queue_pages *qp = walk->private;unsigned long flags;
@@ -464,19 +464,19 @@ static int queue_pages_pmd(pmd_t *pmd, spinlock_t *ptl, unsigned long addr, ret = -EIO ; goto unlock; } - page =pmd_page (*pmd); -if (is_huge_zero_page (page)) { + folio =pfn_folio (pmd_pfn (*pmd)); +if (is_huge_zero_page (&folio->page)) { walk->action =ACTION_CONTINUE ; goto unlock; } -if (!queue_pages_required (page, qp)) +if (!queue_pages_required (&folio->page, qp)) goto unlock; flags = qp->flags; -/* go to thp migration */ +/* go to folio migration */ if (flags & (MPOL_MF_MOVE |MPOL_MF_MOVE_ALL )) {if (!vma_migratable (walk->vma) || -migrate_page_add (page, qp->pagelist, flags)) { +migrate_page_add (&folio->page, qp->pagelist, flags)) { ret =1 ; goto unlock; }
@@ -512,7 +512,7 @@ static int queue_pages_pte_range(pmd_t *pmd, unsigned long addr, ptl =pmd_trans_huge_lock (pmd, vma);if (ptl) -return queue_pages_pmd (pmd, ptl, addr, end, walk); +return queue_folios_pmd (pmd, ptl, addr, end, walk);if (pmd_trans_unstable (pmd))return 0 ;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 26/162 mm/mempolicy: convert queue_pages_pte_range() to queue_folios_pte_range()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vishal Moola (Oracle) <[email protected]>
[ Upstream commit 3dae02bbd07f40e37bbfec2d77119628db461eaa ]
This function now operates on folios associated with ptes instead of pages.
This change is in preparation for the conversion of queue_pages_required() to queue_folio_required() and migrate_page_add() to migrate_folio_add().
Stable-dep-of: 24526268f4e3 ("mm: mempolicy: keep VMA walk if both MPOL_MF_STRICT and MPOL_MF_MOVE are specified")
--- mm/mempolicy.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
mm/mempolicy.c +14 -14
@@ -491,19 +491,19 @@ static int queue_folios_pmd(pmd_t *pmd, spinlock_t *ptl, unsigned long addr,* Scan through pages checking if pages follow certain conditions, * and move them to the pagelist if they do. * -* queue_pages_pte_range() has three possible return values: -* 0 - pages are placed on the right node or queued successfully, or +* queue_folios_pte_range() has three possible return values: +* 0 - folios are placed on the right node or queued successfully, or * special page is met, i.e. zero page. -* 1 - there is unmovable page, and MPOL_MF_MOVE* & MPOL_MF_STRICT were +* 1 - there is unmovable folio, and MPOL_MF_MOVE* & MPOL_MF_STRICT were * specified. -* -EIO - only MPOL_MF_STRICT was specified and an existing page was already +* -EIO - only MPOL_MF_STRICT was specified and an existing folio was already * on a node that does not follow the policy. */ -static int queue_pages_pte_range (pmd_t *pmd,unsigned long addr, +static int queue_folios_pte_range (pmd_t *pmd,unsigned long addr,unsigned long end,struct mm_walk *walk) {struct vm_area_struct *vma = walk->vma; -struct page *page; +struct folio *folio;struct queue_pages *qp = walk->private;unsigned long flags = qp->flags;bool has_unmovable = false;
@@ -521,16 +521,16 @@ static int queue_pages_pte_range(pmd_t *pmd, unsigned long addr,for (; addr != end; pte++, addr +=PAGE_SIZE ) {if (!pte_present (*pte))continue ; - page =vm_normal_page (vma, addr, *pte); -if (!page ||is_zone_device_page (page)) + folio =vm_normal_folio (vma, addr, *pte); +if (!folio ||folio_is_zone_device (folio))continue ;/* -* vm_normal_page() filters out zero pages, but there might -* still be PageReserved pages to skip, perhaps in a VDSO. +* vm_normal_folio() filters out zero pages, but there might +* still be reserved folios to skip, perhaps in a VDSO. */ -if (PageReserved (page)) +if (folio_test_reserved (folio))continue ; -if (!queue_pages_required (page, qp)) +if (!queue_pages_required (&folio->page, qp))continue ;if (flags & (MPOL_MF_MOVE |MPOL_MF_MOVE_ALL )) {/* MPOL_MF_STRICT must be specified if we get here */
@@ -544,7 +544,7 @@ static int queue_pages_pte_range(pmd_t *pmd, unsigned long addr,* temporary off LRU pages in the range. Still * need migrate other LRU pages. */ -if (migrate_page_add (page, qp->pagelist, flags)) +if (migrate_page_add (&folio->page, qp->pagelist, flags)) has_unmovable = true; }else break ;
@@ -705,7 +705,7 @@ static int queue_pages_test_walk(unsigned long start, unsigned long end,static const struct mm_walk_ops queue_pages_walk_ops = { .hugetlb_entry = queue_pages_hugetlb, - .pmd_entry = queue_pages_pte_range, + .pmd_entry = queue_folios_pte_range, .test_walk = queue_pages_test_walk, };
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 27/162 mm/mempolicy: convert migrate_page_add() to migrate_folio_add()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vishal Moola (Oracle) <[email protected]>
[ Upstream commit 4a64981dfee9119aa2c1f243b48f34cbbd67779c ]
Replace migrate_page_add() with migrate_folio_add(). migrate_folio_add() does the same a migrate_page_add() but takes in a folio instead of a page. This removes a couple of calls to compound_head().
Stable-dep-of: 24526268f4e3 ("mm: mempolicy: keep VMA walk if both MPOL_MF_STRICT and MPOL_MF_MOVE are specified")
--- mm/mempolicy.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-)
mm/mempolicy.c +20 -19
@@ -414,7 +414,7 @@ static const struct mempolicy_operations mpol_ops[MPOL_MAX] = { }, }; -static int migrate_page_add (struct page *page,struct list_head *pagelist, +static int migrate_folio_add (struct folio *folio,struct list_head *foliolist,unsigned long flags);struct queue_pages {
@@ -476,7 +476,7 @@ static int queue_folios_pmd(pmd_t *pmd, spinlock_t *ptl, unsigned long addr,/* go to folio migration */ if (flags & (MPOL_MF_MOVE |MPOL_MF_MOVE_ALL )) {if (!vma_migratable (walk->vma) || -migrate_page_add (&folio->page, qp->pagelist, flags)) { +migrate_folio_add (folio, qp->pagelist, flags)) { ret =1 ; goto unlock; }
@@ -544,7 +544,7 @@ static int queue_folios_pte_range(pmd_t *pmd, unsigned long addr,* temporary off LRU pages in the range. Still * need migrate other LRU pages. */ -if (migrate_page_add (&folio->page, qp->pagelist, flags)) +if (migrate_folio_add (folio, qp->pagelist, flags)) has_unmovable = true; }else break ;
@@ -1012,27 +1012,28 @@ static long do_get_mempolicy(int *policy, nodemask_t *nmask, }#ifdef CONFIG_MIGRATION -/* -* page migration, thp tail pages can be passed. -*/ -static int migrate_page_add (struct page *page,struct list_head *pagelist, +static int migrate_folio_add (struct folio *folio,struct list_head *foliolist,unsigned long flags) { -struct page *head =compound_head (page);/* -* Avoid migrating a page that is shared with others. +* We try to migrate only unshared folios. If it is shared it +* is likely not worth migrating. +* +* To check if the folio is shared, ideally we want to make sure +* every page is mapped to the same process. Doing that is very +* expensive, so check the estimated mapcount of the folio instead. */ -if ((flags &MPOL_MF_MOVE_ALL ) ||page_mapcount (head) ==1 ) { -if (!isolate_lru_page (head)) { -list_add_tail (&head->lru, pagelist); -mod_node_page_state (page_pgdat (head), -NR_ISOLATED_ANON +page_is_file_lru (head), -thp_nr_pages (head)); +if ((flags &MPOL_MF_MOVE_ALL ) ||folio_estimated_sharers (folio) ==1 ) { +if (!folio_isolate_lru (folio)) { +list_add_tail (&folio->lru, foliolist); +node_stat_mod_folio (folio, +NR_ISOLATED_ANON +folio_is_file_lru (folio), +folio_nr_pages (folio)); }else if (flags &MPOL_MF_STRICT ) {/* -* Non-movable page may reach here. And, there may be -* temporary off LRU pages or non-LRU movable pages. -* Treat them as unmovable pages since they can't be +* Non-movable folio may reach here. And, there may be +* temporary off LRU folios or non-LRU movable folios. +* Treat them as unmovable folios since they can't be * isolated, so they can't be moved at the moment. It * should return -EIO for this case too. */
@@ -1224,7 +1225,7 @@ static struct page *new_page(struct page *page, unsigned long start) }#else -static int migrate_page_add (struct page *page,struct list_head *pagelist, +static int migrate_folio_add (struct folio *folio,struct list_head *foliolist,unsigned long flags) {return -EIO ;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 28/162 mm: mempolicy: keep VMA walk if both MPOL_MF_STRICT and MPOL_MF_MOVE are specified
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yang Shi <[email protected]>
[ Upstream commit 24526268f4e38c9ec0c4a30de4f37ad2a2a84e47 ]
When calling mbind() with MPOL_MF_{MOVE|MOVEALL} | MPOL_MF_STRICT, kernel should attempt to migrate all existing pages, and return -EIO if there is misplaced or unmovable page. Then commit 6f4576e3687b ("mempolicy: apply page table walker on queue_pages_range()") messed up the return value and didn't break VMA scan early ianymore when MPOL_MF_STRICT alone. The return value problem was fixed by commit a7f40cfe3b7a ("mm: mempolicy:
make mbind() return -EIO when MPOL_MF_STRICT is specified"), but it broke the VMA walk early if unmovable page is met, it may cause some pages are not migrated as expected.
The code should conceptually do:
if (MPOL_MF_MOVE|MOVEALL)
scan all vmas
try to migrate the existing pages
return success
else if (MPOL_MF_MOVE* | MPOL_MF_STRICT)
scan all vmas
try to migrate the existing pages
return -EIO if unmovable or migration failed
else /* MPOL_MF_STRICT alone */
break early if meets unmovable and don't call mbind_range() at all
else /* none of those flags */
check the ranges in test_walk, EFAULT without mbind_range() if discontig.
Fixed the behavior.
--- mm/mempolicy.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-)
mm/mempolicy.c +19 -20
@@ -424,6 +424,7 @@ struct queue_pages {unsigned long start;unsigned long end;struct vm_area_struct *first; +bool has_unmovable; };/*
@@ -444,9 +445,8 @@ static inline bool queue_pages_required(struct page *page,/* * queue_folios_pmd() has three possible return values: * 0 - folios are placed on the right node or queued successfully, or -* special page is met, i.e. huge zero page. -* 1 - there is unmovable folio, and MPOL_MF_MOVE* & MPOL_MF_STRICT were -* specified. +* special page is met, i.e. zero page, or unmovable page is found +* but continue walking (indicated by queue_pages.has_unmovable). * -EIO - is migration entry or only MPOL_MF_STRICT was specified and an * existing folio was already on a node that does not follow the * policy.
@@ -477,7 +477,7 @@ static int queue_folios_pmd(pmd_t *pmd, spinlock_t *ptl, unsigned long addr,if (flags & (MPOL_MF_MOVE |MPOL_MF_MOVE_ALL )) {if (!vma_migratable (walk->vma) ||migrate_folio_add (folio, qp->pagelist, flags)) { - ret =1 ; + qp->has_unmovable = true; goto unlock; } }else
@@ -493,9 +493,8 @@ static int queue_folios_pmd(pmd_t *pmd, spinlock_t *ptl, unsigned long addr,* * queue_folios_pte_range() has three possible return values: * 0 - folios are placed on the right node or queued successfully, or -* special page is met, i.e. zero page. -* 1 - there is unmovable folio, and MPOL_MF_MOVE* & MPOL_MF_STRICT were -* specified. +* special page is met, i.e. zero page, or unmovable page is found +* but continue walking (indicated by queue_pages.has_unmovable). * -EIO - only MPOL_MF_STRICT was specified and an existing folio was already * on a node that does not follow the policy. */
@@ -506,7 +505,6 @@ static int queue_folios_pte_range(pmd_t *pmd, unsigned long addr,struct folio *folio;struct queue_pages *qp = walk->private;unsigned long flags = qp->flags; -bool has_unmovable = false;pte_t *pte, *mapped_pte;spinlock_t *ptl;
@@ -533,11 +531,12 @@ static int queue_folios_pte_range(pmd_t *pmd, unsigned long addr,if (!queue_pages_required (&folio->page, qp))continue ;if (flags & (MPOL_MF_MOVE |MPOL_MF_MOVE_ALL )) { -/* MPOL_MF_STRICT must be specified if we get here */ -if (!vma_migratable (vma)) { - has_unmovable = true; -break ; - } +/* +* MPOL_MF_STRICT must be specified if we get here. +* Continue walking vmas due to MPOL_MF_MOVE* flags. +*/ +if (!vma_migratable (vma)) + qp->has_unmovable = true;/* * Do not abort immediately since there may be
@@ -545,16 +544,13 @@ static int queue_folios_pte_range(pmd_t *pmd, unsigned long addr,* need migrate other LRU pages. */ if (migrate_folio_add (folio, qp->pagelist, flags)) - has_unmovable = true; + qp->has_unmovable = true; }else break ; }pte_unmap_unlock (mapped_pte, ptl);cond_resched (); -if (has_unmovable) -return 1 ; -return addr != end ? -EIO :0 ; }
@@ -594,7 +590,7 @@ static int queue_pages_hugetlb(pte_t *pte, unsigned long hmask,* Detecting misplaced page but allow migrating pages which * have been queued. */ - ret =1 ; + qp->has_unmovable = true; goto unlock; }
@@ -608,7 +604,7 @@ static int queue_pages_hugetlb(pte_t *pte, unsigned long hmask,* Failed to isolate page but allow migrating pages * which have been queued. */ - ret =1 ; + qp->has_unmovable = true; } unlock:spin_unlock (ptl);
@@ -737,10 +733,13 @@ queue_pages_range(struct mm_struct *mm, unsigned long start, unsigned long end, .start = start, .end = end, .first = NULL, + .has_unmovable = false, }; err =walk_page_range (mm, start, end, &queue_pages_walk_ops, &qp); +if (qp.has_unmovable) + err =1 ;if (!qp.first)/* whole range in hole */ err = -EFAULT ;
@@ -1338,7 +1337,7 @@ static long do_mbind(unsigned long start, unsigned long len,putback_movable_pages (&pagelist); } -if ((ret >0 ) || (nr_failed && (flags &MPOL_MF_STRICT ))) +if (((ret >0 ) || nr_failed) && (flags &MPOL_MF_STRICT )) err = -EIO ; }else { up_out:
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 29/162 mm/page_alloc: always remove pages from temporary list
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mel Gorman <[email protected]>
[ Upstream commit c3e58a70425ac6ddaae1529c8146e88b4f7252bb ]
Patch series "Leave IRQs enabled for per-cpu page allocations", v3.
This patch (of 2):
free_unref_page_list() has neglected to remove pages properly from the list of pages to free since forever. It works by coincidence because list_add happened to do the right thing adding the pages to just the PCP lists. However, a later patch added pages to either the PCP list or the zone list but only properly deleted the page from the list in one path leading to list corruption and a subsequent failure. As a preparation patch, always delete the pages from one list properly before adding to another. On its own, this fixes nothing although it adds a fractional amount of overhead but is critical to the next patch.
Stable-dep-of: 7b086755fb8c ("mm: page_alloc: fix CMA and HIGHATOMIC landing on the wrong buddy list")
--- mm/page_alloc.c | 2 ++ 1 file changed, 2 insertions(+)
mm/page_alloc.c +2 -0
@@ -3547,6 +3547,8 @@ void free_unref_page_list(struct list_head *list)list_for_each_entry_safe (page, next, list, lru) {struct zone *zone =page_zone (page); +list_del (&page->lru); +/* Different zone, different pcp lock. */ if (zone != locked_zone) {if (pcp)
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 30/162 mm/page_alloc: leave IRQs enabled for per-cpu page allocations
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mel Gorman <[email protected]>
[ Upstream commit 5749077415994eb02d660b2559b9d8278521e73d ]
The pcp_spin_lock_irqsave protecting the PCP lists is IRQ-safe as a task allocating from the PCP must not re-enter the allocator from IRQ context. In each instance where IRQ-reentrancy is possible, the lock is acquired using pcp_spin_trylock_irqsave() even though IRQs are disabled and re-entrancy is impossible.
Demote the lock to pcp_spin_lock avoids an IRQ disable/enable in the common case at the cost of some IRQ allocations taking a slower path. If the PCP lists need to be refilled, the zone lock still needs to disable IRQs but that will only happen on PCP refill and drain. If an IRQ is raised when a PCP allocation is in progress, the trylock will fail and fallback to using the buddy lists directly. Note that this may not be a universal win if an interrupt-intensive workload also allocates heavily from interrupt context and contends heavily on the zone->lock as a result.
Stable-dep-of: 7b086755fb8c ("mm: page_alloc: fix CMA and HIGHATOMIC landing on the wrong buddy list")
--- mm/page_alloc.c | 124 +++++++++++++++++++++--------------------------- 1 file changed, 54 insertions(+), 70 deletions(-)
mm/page_alloc.c +54 -70
@@ -170,21 +170,12 @@ static DEFINE_MUTEX(pcp_batch_high_lock); _ret; \ }) -#define pcpu_spin_lock_irqsave (type, member, ptr, flags) \ +#define pcpu_spin_trylock (type, member, ptr) \ ({ \ type *_ret; \ pcpu_task_pin(); \ _ret = this_cpu_ptr(ptr); \ - spin_lock_irqsave(&_ret->member, flags); \ - _ret; \ -}) - -#define pcpu_spin_trylock_irqsave (type, member, ptr, flags) \ -({ \ - type *_ret; \ - pcpu_task_pin(); \ - _ret = this_cpu_ptr(ptr); \ - if (!spin_trylock_irqsave(&_ret->member, flags)) { \ + if (!spin_trylock(&_ret->member)) { \ pcpu_task_unpin(); \ _ret = NULL; \ } \
@@ -197,27 +188,16 @@ static DEFINE_MUTEX(pcp_batch_high_lock);pcpu_task_unpin (); \ }) -#define pcpu_spin_unlock_irqrestore (member, ptr, flags) \ -({ \ - spin_unlock_irqrestore(&ptr->member, flags); \ - pcpu_task_unpin(); \ -}) -/* struct per_cpu_pages specific helpers. */ #define pcp_spin_lock (ptr) \ pcpu_spin_lock(struct per_cpu_pages, lock, ptr) -#define pcp_spin_lock_irqsave (ptr, flags) \ - pcpu_spin_lock_irqsave(struct per_cpu_pages, lock, ptr, flags) - -#define pcp_spin_trylock_irqsave (ptr, flags) \ - pcpu_spin_trylock_irqsave(struct per_cpu_pages, lock, ptr, flags) +#define pcp_spin_trylock (ptr) \ + pcpu_spin_trylock(struct per_cpu_pages, lock, ptr)#define pcp_spin_unlock (ptr) \ pcpu_spin_unlock(lock, ptr) -#define pcp_spin_unlock_irqrestore (ptr, flags) \ - pcpu_spin_unlock_irqrestore(lock, ptr, flags)#ifdef CONFIG_USE_PERCPU_NUMA_NODE_ID DEFINE_PER_CPU (int, numa_node);EXPORT_PER_CPU_SYMBOL (numa_node);
@@ -1548,6 +1528,7 @@ static void free_pcppages_bulk(struct zone *zone, int count, struct per_cpu_pages *pcp, int pindex) { +unsigned long flags;int min_pindex =0 ;int max_pindex =NR_PCP_LISTS -1 ;unsigned int order;
@@ -1563,8 +1544,7 @@ static void free_pcppages_bulk(struct zone *zone, int count,/* Ensure requested pindex is drained first. */ pindex = pindex -1 ; -/* Caller must hold IRQ-safe pcp->lock so IRQs are disabled. */ -spin_lock (&zone->lock); +spin_lock_irqsave (&zone->lock, flags); isolated_pageblocks =has_isolate_pageblock (zone);while (count >0 ) {
@@ -1612,7 +1592,7 @@ static void free_pcppages_bulk(struct zone *zone, int count, }while (count >0 && !list_empty (list)); } -spin_unlock (&zone->lock); +spin_unlock_irqrestore (&zone->lock, flags); } static void free_one_page(struct zone *zone,
@@ -3126,10 +3106,10 @@ static int rmqueue_bulk(struct zone *zone, unsigned int order, unsigned long count, struct list_head *list, int migratetype, unsigned int alloc_flags) { + unsigned long flags;int i, allocated =0 ; -/* Caller must hold IRQ-safe pcp->lock so IRQs are disabled. */ -spin_lock (&zone->lock); +spin_lock_irqsave (&zone->lock, flags);for (i =0 ; i < count; ++i) {struct page *page =__rmqueue (zone, order, migratetype, alloc_flags);
@@ -3163,7 +3143,7 @@ static int rmqueue_bulk(struct zone *zone, unsigned int order,* pages added to the pcp list. */ __mod_zone_page_state (zone,NR_FREE_PAGES , -(i << order)); -spin_unlock (&zone->lock); +spin_unlock_irqrestore (&zone->lock, flags);return allocated; }
@@ -3180,16 +3160,9 @@ void drain_zone_pages(struct zone *zone, struct per_cpu_pages *pcp) batch =READ_ONCE (pcp->batch); to_drain =min (pcp->count, batch);if (to_drain >0 ) { -unsigned long flags; - -/* -* free_pcppages_bulk expects IRQs disabled for zone->lock -* so even though pcp->lock is not intended to be IRQ-safe, -* it's needed in this context. -*/ -spin_lock_irqsave (&pcp->lock, flags); +spin_lock (&pcp->lock);free_pcppages_bulk (zone, to_drain, pcp,0 ); -spin_unlock_irqrestore (&pcp->lock, flags); +spin_unlock (&pcp->lock); } }#endif
@@ -3203,12 +3176,9 @@ static void drain_pages_zone(unsigned int cpu, struct zone *zone) pcp =per_cpu_ptr (zone->per_cpu_pageset, cpu);if (pcp->count) { -unsigned long flags; - -/* See drain_zone_pages on why this is disabling IRQs */ -spin_lock_irqsave (&pcp->lock, flags); +spin_lock (&pcp->lock);free_pcppages_bulk (zone, pcp->count, pcp,0 ); -spin_unlock_irqrestore (&pcp->lock, flags); +spin_unlock (&pcp->lock); } }
@@ -3474,7 +3444,6 @@ static void free_unref_page_commit(struct zone *zone, struct per_cpu_pages *pcp,*/ void free_unref_page (struct page *page,unsigned int order) { -unsigned long flags;unsigned long __maybe_unused UP_flags;struct per_cpu_pages *pcp;struct zone *zone;
@@ -3502,10 +3471,10 @@ void free_unref_page(struct page *page, unsigned int order) zone =page_zone (page);pcp_trylock_prepare (UP_flags); - pcp =pcp_spin_trylock_irqsave (zone->per_cpu_pageset, flags); + pcp =pcp_spin_trylock (zone->per_cpu_pageset);if (pcp) {free_unref_page_commit (zone, pcp, page, migratetype, order); -pcp_spin_unlock_irqrestore (pcp, flags); +pcp_spin_unlock (pcp); }else {free_one_page (zone, page, pfn, order, migratetype,FPI_NONE ); }
@@ -3517,10 +3486,10 @@ void free_unref_page(struct page *page, unsigned int order)*/ void free_unref_page_list (struct list_head *list) { +unsigned long __maybe_unused UP_flags;struct page *page, *next;struct per_cpu_pages *pcp =NULL ;struct zone *locked_zone =NULL ; -unsigned long flags;int batch_count =0 ;int migratetype;
@@ -3548,21 +3517,36 @@ void free_unref_page_list(struct list_head *list)struct zone *zone =page_zone (page);list_del (&page->lru); + migratetype =get_pcppage_migratetype (page);/* Different zone, different pcp lock. */ if (zone != locked_zone) { -if (pcp) -pcp_spin_unlock_irqrestore (pcp, flags); +if (pcp) { +pcp_spin_unlock (pcp); +pcp_trylock_finish (UP_flags); + } +/* +* trylock is necessary as pages may be getting freed +* from IRQ or SoftIRQ context after an IO completion. +*/ +pcp_trylock_prepare (UP_flags); + pcp =pcp_spin_trylock (zone->per_cpu_pageset); +if (unlikely (!pcp)) { +pcp_trylock_finish (UP_flags); +free_one_page (zone, page,page_to_pfn (page), +0 , migratetype,FPI_NONE ); + locked_zone =NULL ; +continue ; + } locked_zone = zone; - pcp =pcp_spin_lock_irqsave (locked_zone->per_cpu_pageset, flags); + batch_count =0 ; }/* * Non-isolated types over MIGRATE_PCPTYPES get added * to the MIGRATE_MOVABLE pcp list. */ - migratetype =get_pcppage_migratetype (page);if (unlikely (migratetype >=MIGRATE_PCPTYPES )) migratetype =MIGRATE_MOVABLE ;
@@ -3570,18 +3554,23 @@ void free_unref_page_list(struct list_head *list)free_unref_page_commit (zone, pcp, page, migratetype,0 );/* -* Guard against excessive IRQ disabled times when we get -* a large list of pages to free. +* Guard against excessive lock hold times when freeing +* a large list of pages. Lock will be reacquired if +* necessary on the next iteration. */ if (++batch_count ==SWAP_CLUSTER_MAX ) { -pcp_spin_unlock_irqrestore (pcp, flags); +pcp_spin_unlock (pcp); +pcp_trylock_finish (UP_flags); batch_count =0 ; - pcp =pcp_spin_lock_irqsave (locked_zone->per_cpu_pageset, flags); + pcp =NULL ; + locked_zone =NULL ; } } -if (pcp) -pcp_spin_unlock_irqrestore (pcp, flags); +if (pcp) { +pcp_spin_unlock (pcp); +pcp_trylock_finish (UP_flags); + } }/*
@@ -3782,15 +3771,11 @@ static struct page *rmqueue_pcplist(struct zone *preferred_zone,struct per_cpu_pages *pcp;struct list_head *list;struct page *page; -unsigned long flags;unsigned long __maybe_unused UP_flags; -/* -* spin_trylock may fail due to a parallel drain. In the future, the -* trylock will also protect against IRQ reentrancy. -*/ +/* spin_trylock may fail due to a parallel drain or IRQ reentrancy. */ pcp_trylock_prepare (UP_flags); - pcp =pcp_spin_trylock_irqsave (zone->per_cpu_pageset, flags); + pcp =pcp_spin_trylock (zone->per_cpu_pageset);if (!pcp) {pcp_trylock_finish (UP_flags);return NULL ;
@@ -3804,7 +3789,7 @@ static struct page *rmqueue_pcplist(struct zone *preferred_zone, pcp->free_factor >>=1 ; list = &pcp->lists[order_to_pindex (migratetype, order)]; page =__rmqueue_pcplist (zone, order, migratetype, alloc_flags, pcp, list); -pcp_spin_unlock_irqrestore (pcp, flags); +pcp_spin_unlock (pcp);pcp_trylock_finish (UP_flags);if (page) {__count_zid_vm_events (PGALLOC ,page_zonenum (page),1 << order);
@@ -5375,7 +5360,6 @@ unsigned long __alloc_pages_bulk(gfp_t gfp, int preferred_nid, struct page **page_array) {struct page *page; -unsigned long flags;unsigned long __maybe_unused UP_flags;struct zone *zone;struct zoneref *z;
@@ -5457,9 +5441,9 @@ unsigned long __alloc_pages_bulk(gfp_t gfp, int preferred_nid,if (unlikely (!zone)) goto failed; -/* Is a parallel drain in progress? */ +/* spin_trylock may fail due to a parallel drain or IRQ reentrancy. */ pcp_trylock_prepare (UP_flags); - pcp =pcp_spin_trylock_irqsave (zone->per_cpu_pageset, flags); + pcp =pcp_spin_trylock (zone->per_cpu_pageset);if (!pcp) goto failed_irq;
@@ -5478,7 +5462,7 @@ unsigned long __alloc_pages_bulk(gfp_t gfp, int preferred_nid,if (unlikely (!page)) {/* Try and allocate at least one page */ if (!nr_account) { -pcp_spin_unlock_irqrestore (pcp, flags); +pcp_spin_unlock (pcp); goto failed_irq; }break ;
@@ -5493,7 +5477,7 @@ unsigned long __alloc_pages_bulk(gfp_t gfp, int preferred_nid, nr_populated++; } -pcp_spin_unlock_irqrestore (pcp, flags); +pcp_spin_unlock (pcp);pcp_trylock_finish (UP_flags);__count_zid_vm_events (PGALLOC ,zone_idx (zone), nr_account);
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 31/162 mm: page_alloc: fix CMA and HIGHATOMIC landing on the wrong buddy list
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Weiner <[email protected]>
[ Upstream commit 7b086755fb8cdbb6b3e45a1bbddc00e7f9b1dc03 ]
Commit 4b23a68f9536 ("mm/page_alloc: protect PCP lists with a spinlock") bypasses the pcplist on lock contention and returns the page directly to the buddy list of the page's migratetype.
For pages that don't have their own pcplist, such as CMA and HIGHATOMIC, the migratetype is temporarily updated such that the page can hitch a ride on the MOVABLE pcplist. Their true type is later reassessed when flushing in free_pcppages_bulk(). However, when lock contention is detected after the type was already overridden, the bypass will then put the page on the wrong buddy list.
Once on the MOVABLE buddy list, the page becomes eligible for fallbacks and even stealing. In the case of HIGHATOMIC, otherwise ineligible allocations can dip into the highatomic reserves. In the case of CMA, the page can be lost from the CMA region permanently.
Use a separate pcpmigratetype variable for the pcplist override. Use the original migratetype when going directly to the buddy. This fixes the bug and should make the intentions more obvious in the code.
Originally sent here to address the HIGHATOMIC case:
https://lore.kernel.org/lkml/[email protected]/
Changelog updated in response to the CMA-specific bug report.
--- mm/page_alloc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
mm/page_alloc.c +6 -6
@@ -3448,7 +3448,7 @@ void free_unref_page(struct page *page, unsigned int order)struct per_cpu_pages *pcp;struct zone *zone;unsigned long pfn =page_to_pfn (page); -int migratetype; +int migratetype, pcpmigratetype;if (!free_unref_page_prepare (page, pfn, order))return ;
@@ -3456,24 +3456,24 @@ void free_unref_page(struct page *page, unsigned int order)/* * We only track unmovable, reclaimable and movable on pcp lists. * Place ISOLATE pages on the isolated list because they are being -* offlined but treat HIGHATOMIC as movable pages so we can get those -* areas back if necessary. Otherwise, we may have to free +* offlined but treat HIGHATOMIC and CMA as movable pages so we can +* get those areas back if necessary. Otherwise, we may have to free * excessively into the page allocator */ - migratetype =get_pcppage_migratetype (page); + migratetype = pcpmigratetype =get_pcppage_migratetype (page);if (unlikely (migratetype >=MIGRATE_PCPTYPES )) {if (unlikely (is_migrate_isolate (migratetype))) {free_one_page (page_zone (page), page, pfn, order, migratetype,FPI_NONE );return ; } - migratetype =MIGRATE_MOVABLE ; + pcpmigratetype =MIGRATE_MOVABLE ; } zone =page_zone (page);pcp_trylock_prepare (UP_flags); pcp =pcp_spin_trylock (zone->per_cpu_pageset);if (pcp) { -free_unref_page_commit (zone, pcp, page, migratetype, order); +free_unref_page_commit (zone, pcp, page, pcpmigratetype, order);pcp_spin_unlock (pcp); }else {free_one_page (zone, page, pfn, order, migratetype,FPI_NONE );
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 32/162 ring-buffer: remove obsolete comment for free_buffer_page()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vlastimil Babka <[email protected]>
[ Upstream commit a98151ad53b53f010ee364ec2fd06445b328578b ]
The comment refers to mm/slob.c which is being removed. It comes from commit ed56829cb319 ("ring_buffer: reset buffer page when freeing") and according to Steven the borrowed code was a page mapcount and mapping reset, which was later removed by commit e4c2ce82ca27 ("ring_buffer:
allocate buffer page pointer"). Thus the comment is not accurate anyway, remove it.
Stable-dep-of: 45d99ea451d0 ("ring-buffer: Fix bytes info in per_cpu buffer stats")
--- kernel/trace/ring_buffer.c | 4 ---- 1 file changed, 4 deletions(-)
kernel/trace/ring_buffer.c +0 -4
@@ -354,10 +354,6 @@ static void rb_init_page(struct buffer_data_page *bpage)local_set (&bpage->commit,0 ); } -/* -* Also stolen from mm/slob.c. Thanks to Mathieu Desnoyers for pointing -* this issue out. -*/ static void free_buffer_page (struct buffer_page *bpage) {free_page ((unsigned long )bpage->page);
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 33/162 ring-buffer: Fix bytes info in per_cpu buffer stats
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zheng Yejian <[email protected]>
[ Upstream commit 45d99ea451d0c30bfd4864f0fe485d7dac014902 ]
The 'bytes' info in file 'per_cpu/cpu<X>/stats' means the number of bytes in cpu buffer that have not been consumed. However, currently after consuming data by reading file 'trace_pipe', the 'bytes' info was not changed as expected.
# cat per_cpu/cpu0/stats entries: 0 overrun: 0 commit overrun: 0 bytes: 568 <--- 'bytes' is problematical !!! oldest event ts: 8651.371479 now ts: 8653.912224 dropped events: 0 read events: 8
The root cause is incorrect stat on cpu_buffer->read_bytes. To fix it:
1. When stat 'read_bytes', account consumed event in rb_advance_reader();
2. When stat 'entries_bytes', exclude the discarded padding event which is smaller than minimum size because it is invisible to reader. Then use rb_page_commit() instead of BUF_PAGE_SIZE at where accounting for page-based read/remove/overrun.
Also correct the comments of ring_buffer_bytes_cpu() in this patch.
--- kernel/trace/ring_buffer.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-)
kernel/trace/ring_buffer.c +15 -13
@@ -354,6 +354,11 @@ static void rb_init_page(struct buffer_data_page *bpage)local_set (&bpage->commit,0 ); } +static __always_inline unsigned int rb_page_commit(struct buffer_page *bpage) +{ +return local_read (&bpage->page->commit); +} +static void free_buffer_page (struct buffer_page *bpage) {free_page ((unsigned long )bpage->page);
@@ -2020,7 +2025,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned long nr_pages)* Increment overrun to account for the lost events. */ local_add (page_entries, &cpu_buffer->overrun); -local_sub (BUF_PAGE_SIZE , &cpu_buffer->entries_bytes); +local_sub (rb_page_commit (to_remove_page), &cpu_buffer->entries_bytes);local_inc (&cpu_buffer->pages_lost); }
@@ -2364,11 +2369,6 @@ rb_reader_event(struct ring_buffer_per_cpu *cpu_buffer) cpu_buffer->reader_page->read); } -static __always_inline unsigned rb_page_commit (struct buffer_page *bpage) -{ -return local_read (&bpage->page->commit); -} -static struct ring_buffer_event *rb_iter_head_event (struct ring_buffer_iter *iter) {
@@ -2514,7 +2514,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,* the counters. */ local_add (entries, &cpu_buffer->overrun); -local_sub (BUF_PAGE_SIZE , &cpu_buffer->entries_bytes); +local_sub (rb_page_commit (next_page), &cpu_buffer->entries_bytes);local_inc (&cpu_buffer->pages_lost);/*
@@ -2657,9 +2657,6 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer, event =__rb_page_index (tail_page, tail); -/* account for padding bytes */ -local_add (BUF_PAGE_SIZE - tail, &cpu_buffer->entries_bytes); -/* * Save the original length to the meta data. * This will be used by the reader to add lost event
@@ -2673,7 +2670,8 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,* write counter enough to allow another writer to slip * in on this page. * We put in a discarded commit instead, to make sure -* that this space is not used again. +* that this space is not used again, and this space will +* not be accounted into 'entries_bytes'. * * If we are less than the minimum size, we don't need to * worry about it.
@@ -2698,6 +2696,9 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,/* time delta must be non zero */ event->time_delta =1 ; +/* account for padding bytes */ +local_add (BUF_PAGE_SIZE - tail, &cpu_buffer->entries_bytes); +/* Make sure the padding is visible before the tail_page->write update */ smp_wmb ();
@@ -4215,7 +4216,7 @@ u64 ring_buffer_oldest_event_ts(struct trace_buffer *buffer, int cpu)EXPORT_SYMBOL_GPL (ring_buffer_oldest_event_ts);/** -* ring_buffer_bytes_cpu - get the number of bytes consumed in a cpu buffer +* ring_buffer_bytes_cpu - get the number of bytes unconsumed in a cpu buffer * @buffer: The ring buffer * @cpu: The per CPU buffer to read from. */
@@ -4725,6 +4726,7 @@ static void rb_advance_reader(struct ring_buffer_per_cpu *cpu_buffer) length =rb_event_length (event); cpu_buffer->reader_page->read += length; + cpu_buffer->read_bytes += length; }static void rb_advance_iter (struct ring_buffer_iter *iter)
@@ -5820,7 +5822,7 @@ int ring_buffer_read_page(struct trace_buffer *buffer, }else {/* update the entry counter */ cpu_buffer->read +=rb_page_entries (reader); - cpu_buffer->read_bytes +=BUF_PAGE_SIZE ; + cpu_buffer->read_bytes +=rb_page_commit (reader);/* swap the pages */ rb_init_page (bpage);
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 16/162 scsi: sd: Differentiate system and runtime start/stop management
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
[ Upstream commit 3cc2ffe5c16dc65dfac354bc5b5bc98d3b397567 ]
The underlying device and driver of a SCSI disk may have different system and runtime power mode control requirements. This is because runtime power management affects only the SCSI disk, while system level power management affects all devices, including the controller for the SCSI disk.
For instance, issuing a START STOP UNIT command when a SCSI disk is runtime suspended and resumed is fine: the command is translated to a STANDBY IMMEDIATE command to spin down the ATA disk and to a VERIFY command to wake it up. The SCSI disk runtime operations have no effect on the ata port device used to connect the ATA disk. However, for system suspend/resume operations, the ATA port used to connect the device will also be suspended and resumed, with the resume operation requiring re-validating the device link and the device itself. In this case, issuing a VERIFY command to spinup the disk must be done before starting to revalidate the device, when the ata port is being resumed. In such case, we must not allow the SCSI disk driver to issue START STOP UNIT commands.
Allow a low level driver to refine the SCSI disk start/stop management by differentiating system and runtime cases with two new SCSI device
flags: manage_system_start_stop and manage_runtime_start_stop. These new flags replace the current manage_start_stop flag. Drivers setting the manage_start_stop are modifed to set both new flags, thus preserving the existing start/stop management behavior. For backward compatibility, the old manage_start_stop sysfs device attribute is kept as a read-only attribute showing a value of 1 for devices enabling both new flags and 0 otherwise.
Stable-dep-of: 99398d2070ab ("scsi: sd: Do not issue commands to suspended disks on shutdown")
--- drivers/ata/libata-scsi.c | 3 +- drivers/firewire/sbp2.c | 9 ++-- drivers/scsi/sd.c | 90 ++++++++++++++++++++++++++++++-------- include/scsi/scsi_device.h | 5 ++- 4 files changed, 84 insertions(+), 23 deletions(-)
drivers/ata/libata-scsi.c +2 -1
@@ -1087,7 +1087,8 @@ int ata_scsi_dev_config(struct scsi_device *sdev, struct ata_device *dev)* will be woken up by ata_port_pm_resume() with a port reset * and device revalidation. */ - sdev->manage_start_stop =1 ; + sdev->manage_system_start_stop = true; + sdev->manage_runtime_start_stop = true; sdev->no_start_on_resume =1 ; }
drivers/firewire/sbp2.c +6 -3
@@ -81,7 +81,8 @@ MODULE_PARM_DESC(exclusive_login, "Exclusive login to sbp2 device "* * - power condition * Set the power condition field in the START STOP UNIT commands sent by -* sd_mod on suspend, resume, and shutdown (if manage_start_stop is on). +* sd_mod on suspend, resume, and shutdown (if manage_system_start_stop or +* manage_runtime_start_stop is on). * Some disks need this to spin down or to resume properly. * * - override internal blacklist
@@ -1517,8 +1518,10 @@ static int sbp2_scsi_slave_configure(struct scsi_device *sdev) sdev->use_10_for_rw =1 ; -if (sbp2_param_exclusive_login) - sdev->manage_start_stop =1 ; +if (sbp2_param_exclusive_login) { + sdev->manage_system_start_stop = true; + sdev->manage_runtime_start_stop = true; + }if (sdev->type ==TYPE_ROM ) sdev->use_10_for_ms =1 ;
drivers/scsi/sd.c +72 -18
169 lines not on this page · raw message
include/scsi/scsi_device.h +4 -1
@@ -161,6 +161,10 @@ struct scsi_device {* pass settings from slave_alloc to scsi * core. */ unsigned int eh_timeout;/* Error handling timeout */ + +bool manage_system_start_stop;/* Let HLD (sd) manage system start/stop */ +bool manage_runtime_start_stop;/* Let HLD (sd) manage runtime start/stop */ + unsigned removable:1; unsigned changed:1; /* Data invalid due to media change */ unsigned busy:1; /* Used to prevent races */
@@ -192,7 +196,6 @@ struct scsi_device { unsigned use_192_bytes_for_3f:1; /* ask for 192 bytes from page 0x3f */ unsigned no_start_on_add:1; /* do not issue start on add */ unsigned allow_restart:1; /* issue START_UNIT in error handler */ - unsigned manage_start_stop:1; /* Let HLD (sd) manage start/stop */ unsigned no_start_on_resume:1; /* Do not issue START_STOP_UNIT on resume */ unsigned start_stop_pwr_cond:1; /* Set power cond. in START_STOP_UNIT */ unsigned no_uld_attach:1; /* disable connecting to upper level drivers */
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 34/162 btrfs: use struct qstr instead of name and namelen pairs
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sweet Tea Dorminy <[email protected]>
[ Upstream commit e43eec81c5167b655b72c781b0e75e62a05e415e ]
Many functions throughout btrfs take name buffer and name length arguments. Most of these functions at the highest level are usually called with these arguments extracted from a supplied dentry's name. But the entire name can be passed instead, making each function a little more elegant.
Each function whose arguments are currently the name and length extracted from a dentry is herein converted to instead take a pointer to the name in the dentry. The couple of calls to these calls without a struct dentry are converted to create an appropriate qstr to pass in. Additionally, every function which is only called with a name/len extracted directly from a qstr is also converted.
This change has positive effect on stack consumption, frame of many functions is reduced but this will be used in the future for fscrypt related structures.
Stable-dep-of: 9af86694fd5d ("btrfs: file_remove_privs needs an exclusive lock in direct io write")
--- fs/btrfs/ctree.h | 26 ++-- fs/btrfs/dir-item.c | 50 ++++---- fs/btrfs/inode-item.c | 73 ++++++----- fs/btrfs/inode-item.h | 20 ++- fs/btrfs/inode.c | 130 +++++++++----------- fs/btrfs/ioctl.c | 7 +- fs/btrfs/root-tree.c | 19 ++- fs/btrfs/send.c | 12 +- fs/btrfs/super.c | 3 +- fs/btrfs/transaction.c | 11 +- fs/btrfs/tree-log.c | 267 +++++++++++++++++++---------------------- fs/btrfs/tree-log.h | 4 +- 12 files changed, 287 insertions(+), 335 deletions(-)
fs/btrfs/ctree.h +12 -14
@@ -3238,11 +3238,11 @@ static inline void btrfs_clear_sb_rdonly(struct super_block *sb)/* root-item.c */ int btrfs_add_root_ref (struct btrfs_trans_handle *trans,u64 root_id, -u64 ref_id,u64 dirid,u64 sequence,const char *name, -int name_len); +u64 ref_id,u64 dirid,u64 sequence, +const struct qstr *name);int btrfs_del_root_ref (struct btrfs_trans_handle *trans,u64 root_id, -u64 ref_id,u64 dirid,u64 *sequence,const char *name, -int name_len); +u64 ref_id,u64 dirid,u64 *sequence, +const struct qstr *name);int btrfs_del_root (struct btrfs_trans_handle *trans,const struct btrfs_key *key); int btrfs_insert_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,
@@ -3271,25 +3271,23 @@ int btrfs_uuid_tree_iterate(struct btrfs_fs_info *fs_info);/* dir-item.c */ int btrfs_check_dir_item_collision (struct btrfs_root *root,u64 dir, -const char *name,int name_len); -int btrfs_insert_dir_item (struct btrfs_trans_handle *trans,const char *name, -int name_len,struct btrfs_inode *dir, +const struct qstr *name); +int btrfs_insert_dir_item (struct btrfs_trans_handle *trans, +const struct qstr *name,struct btrfs_inode *dir,struct btrfs_key *location,u8 type,u64 index);struct btrfs_dir_item *btrfs_lookup_dir_item (struct btrfs_trans_handle *trans,struct btrfs_root *root,struct btrfs_path *path,u64 dir, -const char *name,int name_len, -int mod); +const struct qstr *name,int mod);struct btrfs_dir_item *btrfs_lookup_dir_index_item (struct btrfs_trans_handle *trans,struct btrfs_root *root,struct btrfs_path *path,u64 dir, -u64 index,const char *name,int name_len, -int mod); +u64 index,const struct qstr *name,int mod);struct btrfs_dir_item *btrfs_search_dir_index_item (struct btrfs_root *root,struct btrfs_path *path,u64 dirid, -const char *name,int name_len); +const struct qstr *name); int btrfs_delete_one_dir_name(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path,
@@ -3370,10 +3368,10 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry);int btrfs_set_inode_index (struct btrfs_inode *dir,u64 *index);int btrfs_unlink_inode (struct btrfs_trans_handle *trans,struct btrfs_inode *dir,struct btrfs_inode *inode, -const char *name,int name_len); +const struct qstr *name);int btrfs_add_link (struct btrfs_trans_handle *trans,struct btrfs_inode *parent_inode,struct btrfs_inode *inode, -const char *name,int name_len,int add_backref,u64 index); +const struct qstr *name,int add_backref,u64 index);int btrfs_delete_subvolume (struct inode *dir,struct dentry *dentry);int btrfs_truncate_block (struct btrfs_inode *inode,loff_t from,loff_t len,int front);
fs/btrfs/dir-item.c +24 -26
140 lines not on this page · raw message
fs/btrfs/inode-item.c +36 -37
246 lines not on this page · raw message
fs/btrfs/inode-item.h +9 -11
@@ -64,33 +64,31 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,struct btrfs_root *root, struct btrfs_truncate_control *control);int btrfs_insert_inode_ref (struct btrfs_trans_handle *trans, -struct btrfs_root *root, -const char *name,int name_len, +struct btrfs_root *root,const struct qstr *name,u64 inode_objectid,u64 ref_objectid,u64 index);int btrfs_del_inode_ref (struct btrfs_trans_handle *trans, -struct btrfs_root *root, -const char *name,int name_len, -u64 inode_objectid,u64 ref_objectid,u64 *index); +struct btrfs_root *root,const struct qstr *name, +u64 inode_objectid,u64 ref_objectid,u64 *index);int btrfs_insert_empty_inode (struct btrfs_trans_handle *trans,struct btrfs_root *root,struct btrfs_path *path,u64 objectid); -int btrfs_lookup_inode (struct btrfs_trans_handle *trans,struct btrfs_root - *root,struct btrfs_path *path, +int btrfs_lookup_inode (struct btrfs_trans_handle *trans, +struct btrfs_root *root,struct btrfs_path *path,struct btrfs_key *location,int mod);struct btrfs_inode_extref *btrfs_lookup_inode_extref (struct btrfs_trans_handle *trans,struct btrfs_root *root,struct btrfs_path *path, -const char *name,int name_len, +const struct qstr *name,u64 inode_objectid,u64 ref_objectid,int ins_len,int cow);struct btrfs_inode_ref *btrfs_find_name_in_backref (struct extent_buffer *leaf, -int slot,const char *name, -int name_len); +int slot, +const struct qstr *name);struct btrfs_inode_extref *btrfs_find_name_in_ext_backref (struct extent_buffer *leaf,int slot,u64 ref_objectid, -const char *name,int name_len); +const struct qstr *name);#endif
fs/btrfs/inode.c +54 -76
384 lines not on this page · raw message
fs/btrfs/ioctl.c +4 -3
@@ -951,6 +951,7 @@ static noinline int btrfs_mksubvol(const struct path *parent,struct inode *dir =d_inode (parent->dentry);struct btrfs_fs_info *fs_info =btrfs_sb (dir->i_sb);struct dentry *dentry; +struct qstr name_str =QSTR_INIT (name, namelen);int error; error =down_write_killable_nested (&dir->i_rwsem,I_MUTEX_PARENT );
@@ -971,8 +972,7 @@ static noinline int btrfs_mksubvol(const struct path *parent,* check for them now when we can safely fail */ error =btrfs_check_dir_item_collision (BTRFS_I (dir)->root, - dir->i_ino, name, - namelen); + dir->i_ino, &name_str);if (error) goto out_dput;
@@ -3782,6 +3782,7 @@ static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp)struct btrfs_trans_handle *trans;struct btrfs_path *path =NULL ;struct btrfs_disk_key disk_key; +struct qstr name =QSTR_INIT ("default" ,7 );u64 objectid =0 ;u64 dir_id;int ret;
@@ -3825,7 +3826,7 @@ static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp) dir_id =btrfs_super_root_dir (fs_info->super_copy); di =btrfs_lookup_dir_item (trans, fs_info->tree_root, path, - dir_id,"default" ,7 ,1 ); + dir_id, &name,1 );if (IS_ERR_OR_NULL (di)) {btrfs_release_path (path);btrfs_end_transaction (trans);
fs/btrfs/root-tree.c +9 -10
@@ -327,9 +327,8 @@ int btrfs_del_root(struct btrfs_trans_handle *trans, }int btrfs_del_root_ref (struct btrfs_trans_handle *trans,u64 root_id, -u64 ref_id,u64 dirid,u64 *sequence,const char *name, -int name_len) - +u64 ref_id,u64 dirid,u64 *sequence, +const struct qstr *name) {struct btrfs_root *tree_root = trans->fs_info->tree_root;struct btrfs_path *path;
@@ -356,8 +355,8 @@ int btrfs_del_root_ref(struct btrfs_trans_handle *trans, u64 root_id, struct btrfs_root_ref); ptr = (unsigned long )(ref +1 );if ((btrfs_root_ref_dirid (leaf, ref) != dirid) || - (btrfs_root_ref_name_len (leaf, ref) != name_len) || -memcmp_extent_buffer (leaf, name, ptr, name_len)) { + (btrfs_root_ref_name_len (leaf, ref) != name->len) || +memcmp_extent_buffer (leaf, name->name, ptr, name->len)) { ret = -ENOENT ; goto out; }
@@ -400,8 +399,8 @@ int btrfs_del_root_ref(struct btrfs_trans_handle *trans, u64 root_id,* Will return 0, -ENOMEM, or anything from the CoW path */ int btrfs_add_root_ref (struct btrfs_trans_handle *trans,u64 root_id, -u64 ref_id,u64 dirid,u64 sequence,const char *name, -int name_len) +u64 ref_id,u64 dirid,u64 sequence, +const struct qstr *name) {struct btrfs_root *tree_root = trans->fs_info->tree_root;struct btrfs_key key;
@@ -420,7 +419,7 @@ int btrfs_add_root_ref(struct btrfs_trans_handle *trans, u64 root_id, key.offset = ref_id; again: ret =btrfs_insert_empty_item (trans, tree_root, path, &key, -sizeof (*ref) + name_len); +sizeof (*ref) + name->len);if (ret) {btrfs_abort_transaction (trans, ret);btrfs_free_path (path);
@@ -431,9 +430,9 @@ int btrfs_add_root_ref(struct btrfs_trans_handle *trans, u64 root_id, ref = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_root_ref);btrfs_set_root_ref_dirid (leaf, ref, dirid);btrfs_set_root_ref_sequence (leaf, ref, sequence); -btrfs_set_root_ref_name_len (leaf, ref, name_len); +btrfs_set_root_ref_name_len (leaf, ref, name->len); ptr = (unsigned long )(ref +1 ); -write_extent_buffer (leaf, name, ptr, name_len); +write_extent_buffer (leaf, name->name, ptr, name->len);btrfs_mark_buffer_dirty (leaf);if (key.type ==BTRFS_ROOT_BACKREF_KEY ) {
fs/btrfs/send.c +8 -4
@@ -1596,13 +1596,17 @@ static int gen_unique_name(struct send_ctx *sctx,return -ENOMEM ;while (1 ) { +struct qstr tmp_name; + len =snprintf (tmp,sizeof (tmp),"o%llu-%llu-%llu" , ino, gen, idx);ASSERT (len <sizeof (tmp)); + tmp_name.name = tmp; + tmp_name.len =strlen (tmp); di =btrfs_lookup_dir_item (NULL , sctx->send_root, path,BTRFS_FIRST_FREE_OBJECTID , - tmp,strlen (tmp),0 ); + &tmp_name,0 );btrfs_release_path (path);if (IS_ERR (di)) { ret =PTR_ERR (di);
@@ -1622,7 +1626,7 @@ static int gen_unique_name(struct send_ctx *sctx, di =btrfs_lookup_dir_item (NULL , sctx->parent_root, path,BTRFS_FIRST_FREE_OBJECTID , - tmp,strlen (tmp),0 ); + &tmp_name,0 );btrfs_release_path (path);if (IS_ERR (di)) { ret =PTR_ERR (di);
@@ -1752,13 +1756,13 @@ static int lookup_dir_item_inode(struct btrfs_root *root,struct btrfs_dir_item *di;struct btrfs_key key;struct btrfs_path *path; +struct qstr name_str =QSTR_INIT (name, name_len); path =alloc_path_for_send ();if (!path)return -ENOMEM ; - di =btrfs_lookup_dir_item (NULL , root, path, - dir, name, name_len,0 ); + di =btrfs_lookup_dir_item (NULL , root, path, dir, &name_str,0 );if (IS_ERR_OR_NULL (di)) { ret = di ?PTR_ERR (di) : -ENOENT ; goto out;
fs/btrfs/super.c +2 -1
@@ -1398,6 +1398,7 @@ static int get_default_subvol_objectid(struct btrfs_fs_info *fs_info, u64 *objecstruct btrfs_dir_item *di;struct btrfs_path *path;struct btrfs_key location; +struct qstr name =QSTR_INIT ("default" ,7 );u64 dir_id; path =btrfs_alloc_path ();
@@ -1410,7 +1411,7 @@ static int get_default_subvol_objectid(struct btrfs_fs_info *fs_info, u64 *objec* to mount. */ dir_id =btrfs_super_root_dir (fs_info->super_copy); - di =btrfs_lookup_dir_item (NULL , root, path, dir_id,"default" ,7 ,0 ); + di =btrfs_lookup_dir_item (NULL , root, path, dir_id, &name,0 );if (IS_ERR (di)) {btrfs_free_path (path);return PTR_ERR (di);
fs/btrfs/transaction.c +5 -6
@@ -1694,8 +1694,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,/* check if there is a file/dir which has the same name. */ dir_item =btrfs_lookup_dir_item (NULL , parent_root, path,btrfs_ino (BTRFS_I (parent_inode)), - dentry->d_name.name, - dentry->d_name.len,0 ); + &dentry->d_name,0 );if (dir_item !=NULL && !IS_ERR (dir_item)) { pending->error = -EEXIST ; goto dir_item_existed;
@@ -1790,7 +1789,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans, ret =btrfs_add_root_ref (trans, objectid, parent_root->root_key.objectid,btrfs_ino (BTRFS_I (parent_inode)), index, - dentry->d_name.name, dentry->d_name.len); + &dentry->d_name);if (ret) {btrfs_abort_transaction (trans, ret); goto fail;
@@ -1822,9 +1821,9 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,if (ret <0 ) goto fail; - ret =btrfs_insert_dir_item (trans, dentry->d_name.name, - dentry->d_name.len,BTRFS_I (parent_inode), - &key,BTRFS_FT_DIR , index); + ret =btrfs_insert_dir_item (trans, &dentry->d_name, +BTRFS_I (parent_inode), &key,BTRFS_FT_DIR , + index);/* We have check then name at the beginning, so it is impossible. */ BUG_ON (ret == -EEXIST || ret == -EOVERFLOW );if (ret) {
fs/btrfs/tree-log.c +122 -145
666 lines not on this page · raw message
fs/btrfs/tree-log.h +2 -2
@@ -84,11 +84,11 @@ int btrfs_log_dentry_safe(struct btrfs_trans_handle *trans, struct btrfs_log_ctx *ctx);void btrfs_del_dir_entries_in_log (struct btrfs_trans_handle *trans,struct btrfs_root *root, -const char *name,int name_len, +const struct qstr *name,struct btrfs_inode *dir,u64 index);void btrfs_del_inode_ref_in_log (struct btrfs_trans_handle *trans,struct btrfs_root *root, -const char *name,int name_len, +const struct qstr *name,struct btrfs_inode *inode,u64 dirid);void btrfs_end_log_trans (struct btrfs_root *root);void btrfs_pin_log_trans (struct btrfs_root *root);
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 35/162 btrfs: setup qstr from dentrys using fscrypt helper
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sweet Tea Dorminy <[email protected]>
[ Upstream commit ab3c5c18e8fa3f8ea116016095d25adab466cd39 ]
Most places where we get a struct qstr, we are doing so from a dentry. With fscrypt, the dentry's name may be encrypted on-disk, so fscrypt provides a helper to convert a dentry name to the appropriate disk name if necessary. Convert each of the dentry name accesses to use fscrypt_setup_filename(), then convert the resulting fscrypt_name back to an unencrypted qstr. This does not work for nokey names, but the specific locations that could spawn nokey names are noted.
At present, since there are no encrypted directories, nothing goes down the filename encryption paths.
Stable-dep-of: 9af86694fd5d ("btrfs: file_remove_privs needs an exclusive lock in direct io write")
--- fs/btrfs/ctree.h | 3 + fs/btrfs/inode.c | 192 +++++++++++++++++++++++++++++++---------- fs/btrfs/transaction.c | 40 ++++++--- fs/btrfs/tree-log.c | 11 ++- 4 files changed, 189 insertions(+), 57 deletions(-)
fs/btrfs/ctree.h +3 -0
@@ -28,6 +28,7 @@#include <linux/refcount.h> #include <linux/crc32c.h> #include <linux/iomap.h> +#include <linux/fscrypt.h> #include "extent-io-tree.h" #include "extent_io.h" #include "extent_map.h"
@@ -3396,6 +3397,8 @@ struct btrfs_new_inode_args {*/ struct posix_acl *default_acl;struct posix_acl *acl; +struct fscrypt_name fname; +struct qstr name; };int btrfs_new_inode_prepare (struct btrfs_new_inode_args *args,unsigned int *trans_num_items);
fs/btrfs/inode.c +148 -44
477 lines not on this page · raw message
fs/btrfs/transaction.c +28 -12
@@ -6,6 +6,7 @@#include <linux/fs.h> #include <linux/slab.h> #include <linux/sched.h> +#include <linux/sched/mm.h> #include <linux/writeback.h> #include <linux/pagemap.h> #include <linux/blkdev.h>
@@ -1627,10 +1628,9 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,struct btrfs_root *root = pending->root;struct btrfs_root *parent_root;struct btrfs_block_rsv *rsv; -struct inode *parent_inode; +struct inode *parent_inode = pending->dir;struct btrfs_path *path;struct btrfs_dir_item *dir_item; -struct dentry *dentry;struct extent_buffer *tmp;struct extent_buffer *old;struct timespec64 cur_time;
@@ -1639,6 +1639,9 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,u64 index =0 ;u64 objectid;u64 root_flags; +unsigned int nofs_flags; +struct fscrypt_name fname; +struct qstr name;ASSERT (pending->path); path = pending->path;
@@ -1646,9 +1649,23 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,ASSERT (pending->root_item); new_root_item = pending->root_item; +/* +* We're inside a transaction and must make sure that any potential +* allocations with GFP_KERNEL in fscrypt won't recurse back to +* filesystem. +*/ + nofs_flags =memalloc_nofs_save (); + pending->error =fscrypt_setup_filename (parent_inode, + &pending->dentry->d_name,0 , + &fname); +memalloc_nofs_restore (nofs_flags); +if (pending->error) + goto free_pending; + name = (struct qstr )FSTR_TO_QSTR (&fname.disk_name); + pending->error =btrfs_get_free_objectid (tree_root, &objectid);if (pending->error) - goto no_free_objectid; + goto free_fname;/* * Make qgroup to skip current new snapshot's qgroupid, as it is
@@ -1677,8 +1694,6 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,trace_btrfs_space_reservation (fs_info,"transaction" , trans->transid, trans->bytes_reserved,1 ); - dentry = pending->dentry; - parent_inode = pending->dir; parent_root =BTRFS_I (parent_inode)->root; ret =record_root_in_trans (trans, parent_root,0 );if (ret)
@@ -1694,7 +1709,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,/* check if there is a file/dir which has the same name. */ dir_item =btrfs_lookup_dir_item (NULL , parent_root, path,btrfs_ino (BTRFS_I (parent_inode)), - &dentry->d_name,0 ); + &name,0 );if (dir_item !=NULL && !IS_ERR (dir_item)) { pending->error = -EEXIST ; goto dir_item_existed;
@@ -1789,7 +1804,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans, ret =btrfs_add_root_ref (trans, objectid, parent_root->root_key.objectid,btrfs_ino (BTRFS_I (parent_inode)), index, - &dentry->d_name); + &name);if (ret) {btrfs_abort_transaction (trans, ret); goto fail;
@@ -1821,9 +1836,8 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,if (ret <0 ) goto fail; - ret =btrfs_insert_dir_item (trans, &dentry->d_name, -BTRFS_I (parent_inode), &key,BTRFS_FT_DIR , - index); + ret =btrfs_insert_dir_item (trans, &name,BTRFS_I (parent_inode), &key, +BTRFS_FT_DIR , index);/* We have check then name at the beginning, so it is impossible. */ BUG_ON (ret == -EEXIST || ret == -EOVERFLOW );if (ret) {
@@ -1832,7 +1846,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans, }btrfs_i_size_write (BTRFS_I (parent_inode), parent_inode->i_size + - dentry->d_name.len *2 ); + name.len *2 ); parent_inode->i_mtime =current_time (parent_inode); parent_inode->i_ctime = parent_inode->i_mtime; ret =btrfs_update_inode_fallback (trans, parent_root,BTRFS_I (parent_inode));
@@ -1864,7 +1878,9 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans, trans->bytes_reserved =0 ; clear_skip_qgroup:btrfs_clear_skip_qgroup (trans); -no_free_objectid: +free_fname: +fscrypt_free_filename (&fname); +free_pending:kfree (new_root_item); pending->root_item =NULL ;btrfs_free_path (path);
fs/btrfs/tree-log.c +10 -1
@@ -7471,9 +7471,16 @@ void btrfs_log_new_name(struct btrfs_trans_handle *trans,if (old_dir && old_dir->logged_trans == trans->transid) {struct btrfs_root *log = old_dir->root->log_root;struct btrfs_path *path; +struct fscrypt_name fname; +struct qstr name;ASSERT (old_dir_index >=BTRFS_DIR_START_INDEX ); + ret =fscrypt_setup_filename (&old_dir->vfs_inode, + &old_dentry->d_name,0 , &fname); +if (ret) + goto out; + name = (struct qstr )FSTR_TO_QSTR (&fname.disk_name);/* * We have two inodes to update in the log, the old directory and * the inode that got renamed, so we must pin the log to prevent
@@ -7493,6 +7500,7 @@ void btrfs_log_new_name(struct btrfs_trans_handle *trans, path =btrfs_alloc_path ();if (!path) { ret = -ENOMEM ; +fscrypt_free_filename (&fname); goto out; }
@@ -7508,7 +7516,7 @@ void btrfs_log_new_name(struct btrfs_trans_handle *trans,*/ mutex_lock (&old_dir->log_mutex); ret =del_logged_dentry (trans, log, path,btrfs_ino (old_dir), - &old_dentry->d_name, old_dir_index); + &name, old_dir_index);if (ret >0 ) {/* * The dentry does not exist in the log, so record its
@@ -7522,6 +7530,7 @@ void btrfs_log_new_name(struct btrfs_trans_handle *trans,mutex_unlock (&old_dir->log_mutex);btrfs_free_path (path); +fscrypt_free_filename (&fname);if (ret <0 ) goto out; }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 36/162 btrfs: use struct fscrypt_str instead of struct qstr
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sweet Tea Dorminy <[email protected]>
[ Upstream commit 6db75318823a169e836a478ca57d6a7c0a156b77 ]
While struct qstr is more natural without fscrypt, since it's provided by dentries, struct fscrypt_str is provided by the fscrypt handlers processing dentries, and is thus more natural in the fscrypt world. Replace all of the struct qstr uses with struct fscrypt_str.
Stable-dep-of: 9af86694fd5d ("btrfs: file_remove_privs needs an exclusive lock in direct io write")
--- fs/btrfs/ctree.h | 19 +++++---- fs/btrfs/dir-item.c | 10 ++--- fs/btrfs/inode-item.c | 14 +++---- fs/btrfs/inode-item.h | 10 ++--- fs/btrfs/inode.c | 87 +++++++++++++++++------------------------- fs/btrfs/ioctl.c | 4 +- fs/btrfs/root-tree.c | 4 +- fs/btrfs/send.c | 4 +- fs/btrfs/super.c | 2 +- fs/btrfs/transaction.c | 13 +++---- fs/btrfs/tree-log.c | 42 ++++++++++---------- fs/btrfs/tree-log.h | 4 +- 12 files changed, 95 insertions(+), 118 deletions(-)
fs/btrfs/ctree.h +9 -10
@@ -3240,10 +3240,10 @@ static inline void btrfs_clear_sb_rdonly(struct super_block *sb)/* root-item.c */ int btrfs_add_root_ref (struct btrfs_trans_handle *trans,u64 root_id,u64 ref_id,u64 dirid,u64 sequence, -const struct qstr *name); +const struct fscrypt_str *name);int btrfs_del_root_ref (struct btrfs_trans_handle *trans,u64 root_id,u64 ref_id,u64 dirid,u64 *sequence, -const struct qstr *name); +const struct fscrypt_str *name);int btrfs_del_root (struct btrfs_trans_handle *trans,const struct btrfs_key *key); int btrfs_insert_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,
@@ -3272,23 +3272,23 @@ int btrfs_uuid_tree_iterate(struct btrfs_fs_info *fs_info);/* dir-item.c */ int btrfs_check_dir_item_collision (struct btrfs_root *root,u64 dir, -const struct qstr *name); +const struct fscrypt_str *name);int btrfs_insert_dir_item (struct btrfs_trans_handle *trans, -const struct qstr *name,struct btrfs_inode *dir, +const struct fscrypt_str *name,struct btrfs_inode *dir,struct btrfs_key *location,u8 type,u64 index);struct btrfs_dir_item *btrfs_lookup_dir_item (struct btrfs_trans_handle *trans,struct btrfs_root *root,struct btrfs_path *path,u64 dir, -const struct qstr *name,int mod); +const struct fscrypt_str *name,int mod);struct btrfs_dir_item *btrfs_lookup_dir_index_item (struct btrfs_trans_handle *trans,struct btrfs_root *root,struct btrfs_path *path,u64 dir, -u64 index,const struct qstr *name,int mod); +u64 index,const struct fscrypt_str *name,int mod);struct btrfs_dir_item *btrfs_search_dir_index_item (struct btrfs_root *root,struct btrfs_path *path,u64 dirid, -const struct qstr *name); +const struct fscrypt_str *name); int btrfs_delete_one_dir_name(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path,
@@ -3369,10 +3369,10 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry);int btrfs_set_inode_index (struct btrfs_inode *dir,u64 *index);int btrfs_unlink_inode (struct btrfs_trans_handle *trans,struct btrfs_inode *dir,struct btrfs_inode *inode, -const struct qstr *name); +const struct fscrypt_str *name);int btrfs_add_link (struct btrfs_trans_handle *trans,struct btrfs_inode *parent_inode,struct btrfs_inode *inode, -const struct qstr *name,int add_backref,u64 index); +const struct fscrypt_str *name,int add_backref,u64 index);int btrfs_delete_subvolume (struct inode *dir,struct dentry *dentry);int btrfs_truncate_block (struct btrfs_inode *inode,loff_t from,loff_t len,int front);
@@ -3398,7 +3398,6 @@ struct btrfs_new_inode_args {struct posix_acl *default_acl;struct posix_acl *acl;struct fscrypt_name fname; -struct qstr name; };int btrfs_new_inode_prepare (struct btrfs_new_inode_args *args,unsigned int *trans_num_items);
fs/btrfs/dir-item.c +5 -5
@@ -104,7 +104,7 @@ int btrfs_insert_xattr_item(struct btrfs_trans_handle *trans,* Will return 0 or -ENOMEM */ int btrfs_insert_dir_item (struct btrfs_trans_handle *trans, -const struct qstr *name,struct btrfs_inode *dir, +const struct fscrypt_str *name,struct btrfs_inode *dir,struct btrfs_key *location,u8 type,u64 index) {int ret =0 ;
@@ -206,7 +206,7 @@ static struct btrfs_dir_item *btrfs_lookup_match_dir(struct btrfs_dir_item *btrfs_lookup_dir_item (struct btrfs_trans_handle *trans,struct btrfs_root *root,struct btrfs_path *path,u64 dir, -const struct qstr *name, +const struct fscrypt_str *name,int mod) {struct btrfs_key key;
@@ -225,7 +225,7 @@ struct btrfs_dir_item *btrfs_lookup_dir_item(struct btrfs_trans_handle *trans, }int btrfs_check_dir_item_collision (struct btrfs_root *root,u64 dir, -const struct qstr *name) +const struct fscrypt_str *name) {int ret;struct btrfs_key key;
@@ -302,7 +302,7 @@ struct btrfs_dir_item * btrfs_lookup_dir_index_item(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, u64 dir, - u64 index, const struct qstr *name, int mod) + u64 index, const struct fscrypt_str *name, int mod) { struct btrfs_dir_item *di;struct btrfs_key key;
@@ -321,7 +321,7 @@ btrfs_lookup_dir_index_item(struct btrfs_trans_handle *trans,struct btrfs_dir_item *btrfs_search_dir_index_item (struct btrfs_root *root,struct btrfs_path *path, -u64 dirid,const struct qstr *name) +u64 dirid,const struct fscrypt_str *name) {struct btrfs_dir_item *di;struct btrfs_key key;
fs/btrfs/inode-item.c +7 -7
@@ -11,7 +11,7 @@struct btrfs_inode_ref *btrfs_find_name_in_backref (struct extent_buffer *leaf,int slot, -const struct qstr *name) +const struct fscrypt_str *name) {struct btrfs_inode_ref *ref;unsigned long ptr;
@@ -38,7 +38,7 @@ struct btrfs_inode_ref *btrfs_find_name_in_backref(struct extent_buffer *leaf,struct btrfs_inode_extref *btrfs_find_name_in_ext_backref (struct extent_buffer *leaf,int slot,u64 ref_objectid, -const struct qstr *name) +const struct fscrypt_str *name) {struct btrfs_inode_extref *extref;unsigned long ptr;
@@ -77,7 +77,7 @@ struct btrfs_inode_extref * btrfs_lookup_inode_extref(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, - const struct qstr *name, + const struct fscrypt_str *name, u64 inode_objectid, u64 ref_objectid, int ins_len, int cow) {
@@ -100,7 +100,7 @@ btrfs_lookup_inode_extref(struct btrfs_trans_handle *trans,static int btrfs_del_inode_extref (struct btrfs_trans_handle *trans,struct btrfs_root *root, -const struct qstr *name, +const struct fscrypt_str *name,u64 inode_objectid,u64 ref_objectid,u64 *index) {
@@ -170,7 +170,7 @@ static int btrfs_del_inode_extref(struct btrfs_trans_handle *trans, }int btrfs_del_inode_ref (struct btrfs_trans_handle *trans, -struct btrfs_root *root,const struct qstr *name, +struct btrfs_root *root,const struct fscrypt_str *name,u64 inode_objectid,u64 ref_objectid,u64 *index) {struct btrfs_path *path;
@@ -247,7 +247,7 @@ int btrfs_del_inode_ref(struct btrfs_trans_handle *trans,*/ static int btrfs_insert_inode_extref (struct btrfs_trans_handle *trans,struct btrfs_root *root, -const struct qstr *name, +const struct fscrypt_str *name,u64 inode_objectid,u64 ref_objectid,u64 index) {
@@ -302,7 +302,7 @@ static int btrfs_insert_inode_extref(struct btrfs_trans_handle *trans,/* Will return 0, -ENOMEM, -EMLINK, or -EEXIST or anything from the CoW path */ int btrfs_insert_inode_ref (struct btrfs_trans_handle *trans, -struct btrfs_root *root,const struct qstr *name, +struct btrfs_root *root,const struct fscrypt_str *name,u64 inode_objectid,u64 ref_objectid,u64 index) {struct btrfs_fs_info *fs_info = root->fs_info;
fs/btrfs/inode-item.h +5 -5
@@ -64,10 +64,10 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,struct btrfs_root *root, struct btrfs_truncate_control *control);int btrfs_insert_inode_ref (struct btrfs_trans_handle *trans, -struct btrfs_root *root,const struct qstr *name, +struct btrfs_root *root,const struct fscrypt_str *name,u64 inode_objectid,u64 ref_objectid,u64 index);int btrfs_del_inode_ref (struct btrfs_trans_handle *trans, -struct btrfs_root *root,const struct qstr *name, +struct btrfs_root *root,const struct fscrypt_str *name,u64 inode_objectid,u64 ref_objectid,u64 *index); int btrfs_insert_empty_inode(struct btrfs_trans_handle *trans, struct btrfs_root *root,
@@ -80,15 +80,15 @@ struct btrfs_inode_extref *btrfs_lookup_inode_extref(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_path *path, - const struct qstr *name, + const struct fscrypt_str *name, u64 inode_objectid, u64 ref_objectid, int ins_len, int cow);struct btrfs_inode_ref *btrfs_find_name_in_backref (struct extent_buffer *leaf,int slot, -const struct qstr *name); +const struct fscrypt_str *name);struct btrfs_inode_extref *btrfs_find_name_in_ext_backref (struct extent_buffer *leaf,int slot,u64 ref_objectid, -const struct qstr *name); +const struct fscrypt_str *name);#endif
fs/btrfs/inode.c +34 -53
336 lines not on this page · raw message
fs/btrfs/ioctl.c +2 -2
@@ -951,7 +951,7 @@ static noinline int btrfs_mksubvol(const struct path *parent,struct inode *dir =d_inode (parent->dentry);struct btrfs_fs_info *fs_info =btrfs_sb (dir->i_sb);struct dentry *dentry; -struct qstr name_str =QSTR_INIT (name, namelen); +struct fscrypt_str name_str =FSTR_INIT ((char *)name, namelen);int error; error =down_write_killable_nested (&dir->i_rwsem,I_MUTEX_PARENT );
@@ -3782,7 +3782,7 @@ static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp)struct btrfs_trans_handle *trans;struct btrfs_path *path =NULL ;struct btrfs_disk_key disk_key; -struct qstr name =QSTR_INIT ("default" ,7 ); +struct fscrypt_str name =FSTR_INIT ("default" ,7 );u64 objectid =0 ;u64 dir_id;int ret;
fs/btrfs/root-tree.c +2 -2
@@ -328,7 +328,7 @@ int btrfs_del_root(struct btrfs_trans_handle *trans,int btrfs_del_root_ref (struct btrfs_trans_handle *trans,u64 root_id,u64 ref_id,u64 dirid,u64 *sequence, -const struct qstr *name) +const struct fscrypt_str *name) {struct btrfs_root *tree_root = trans->fs_info->tree_root;struct btrfs_path *path;
@@ -400,7 +400,7 @@ int btrfs_del_root_ref(struct btrfs_trans_handle *trans, u64 root_id,*/ int btrfs_add_root_ref (struct btrfs_trans_handle *trans,u64 root_id,u64 ref_id,u64 dirid,u64 sequence, -const struct qstr *name) +const struct fscrypt_str *name) {struct btrfs_root *tree_root = trans->fs_info->tree_root;struct btrfs_key key;
fs/btrfs/send.c +2 -2
@@ -1596,7 +1596,7 @@ static int gen_unique_name(struct send_ctx *sctx,return -ENOMEM ;while (1 ) { -struct qstr tmp_name; +struct fscrypt_str tmp_name; len =snprintf (tmp,sizeof (tmp),"o%llu-%llu-%llu" , ino, gen, idx);
@@ -1756,7 +1756,7 @@ static int lookup_dir_item_inode(struct btrfs_root *root,struct btrfs_dir_item *di;struct btrfs_key key;struct btrfs_path *path; -struct qstr name_str =QSTR_INIT (name, name_len); +struct fscrypt_str name_str =FSTR_INIT ((char *)name, name_len); path =alloc_path_for_send ();if (!path)
fs/btrfs/super.c +1 -1
@@ -1398,7 +1398,7 @@ static int get_default_subvol_objectid(struct btrfs_fs_info *fs_info, u64 *objecstruct btrfs_dir_item *di;struct btrfs_path *path;struct btrfs_key location; -struct qstr name =QSTR_INIT ("default" ,7 ); +struct fscrypt_str name =FSTR_INIT ("default" ,7 );u64 dir_id; path =btrfs_alloc_path ();
fs/btrfs/transaction.c +6 -7
@@ -1641,7 +1641,6 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,u64 root_flags;unsigned int nofs_flags;struct fscrypt_name fname; -struct qstr name;ASSERT (pending->path); path = pending->path;
@@ -1661,7 +1660,6 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,memalloc_nofs_restore (nofs_flags);if (pending->error) goto free_pending; - name = (struct qstr )FSTR_TO_QSTR (&fname.disk_name); pending->error =btrfs_get_free_objectid (tree_root, &objectid);if (pending->error)
@@ -1709,7 +1707,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,/* check if there is a file/dir which has the same name. */ dir_item =btrfs_lookup_dir_item (NULL , parent_root, path,btrfs_ino (BTRFS_I (parent_inode)), - &name,0 ); + &fname.disk_name,0 );if (dir_item !=NULL && !IS_ERR (dir_item)) { pending->error = -EEXIST ; goto dir_item_existed;
@@ -1804,7 +1802,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans, ret =btrfs_add_root_ref (trans, objectid, parent_root->root_key.objectid,btrfs_ino (BTRFS_I (parent_inode)), index, - &name); + &fname.disk_name);if (ret) {btrfs_abort_transaction (trans, ret); goto fail;
@@ -1836,8 +1834,9 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,if (ret <0 ) goto fail; - ret =btrfs_insert_dir_item (trans, &name,BTRFS_I (parent_inode), &key, -BTRFS_FT_DIR , index); + ret =btrfs_insert_dir_item (trans, &fname.disk_name, +BTRFS_I (parent_inode), &key,BTRFS_FT_DIR , + index);/* We have check then name at the beginning, so it is impossible. */ BUG_ON (ret == -EEXIST || ret == -EOVERFLOW );if (ret) {
@@ -1846,7 +1845,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans, }btrfs_i_size_write (BTRFS_I (parent_inode), parent_inode->i_size + - name.len *2 ); + fname.disk_name.len *2 ); parent_inode->i_mtime =current_time (parent_inode); parent_inode->i_ctime = parent_inode->i_mtime; ret =btrfs_update_inode_fallback (trans, parent_root,BTRFS_I (parent_inode));
fs/btrfs/tree-log.c +20 -22
174 lines not on this page · raw message
fs/btrfs/tree-log.h +2 -2
@@ -84,11 +84,11 @@ int btrfs_log_dentry_safe(struct btrfs_trans_handle *trans, struct btrfs_log_ctx *ctx);void btrfs_del_dir_entries_in_log (struct btrfs_trans_handle *trans,struct btrfs_root *root, -const struct qstr *name, +const struct fscrypt_str *name,struct btrfs_inode *dir,u64 index);void btrfs_del_inode_ref_in_log (struct btrfs_trans_handle *trans,struct btrfs_root *root, -const struct qstr *name, +const struct fscrypt_str *name,struct btrfs_inode *inode,u64 dirid);void btrfs_end_log_trans (struct btrfs_root *root);void btrfs_pin_log_trans (struct btrfs_root *root);
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 37/162 Revert "NFSv4: Retry LOCK on OLD_STATEID during delegation return"
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Coddington <[email protected]>
[ Upstream commit 5b4a82a0724af1dfd1320826e0266117b6a57fbd ]
Olga Kornievskaia reports that this patch breaks NFSv4.0 state recovery. It also introduces additional complexity in the error paths for cases not related to the original problem. Let's revert it for now, and address the original problem in another manner.
This reverts commit f5ea16137a3fa2858620dc9084466491c128535f.
--- fs/nfs/nfs4proc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
fs/nfs/nfs4proc.c +2 -4
@@ -7157,7 +7157,6 @@ static void nfs4_lock_done(struct rpc_task *task, void *calldata) {struct nfs4_lockdata *data = calldata;struct nfs4_lock_state *lsp = data->lsp; -struct nfs_server *server =NFS_SERVER (d_inode (data->ctx->dentry));if (!nfs4_sequence_done (task, &data->res.seq_res))return ;
@@ -7165,7 +7164,8 @@ static void nfs4_lock_done(struct rpc_task *task, void *calldata) data->rpc_status = task->tk_status;switch (task->tk_status) {case 0 : -renew_lease (server, data->timestamp); +renew_lease (NFS_SERVER (d_inode (data->ctx->dentry)), + data->timestamp);if (data->arg.new_lock && !data->cancelled) { data->fl.fl_flags &= ~(FL_SLEEP |FL_ACCESS );if (locks_lock_inode_wait (lsp->ls_state->inode, &data->fl) <0 )
@@ -7193,8 +7193,6 @@ static void nfs4_lock_done(struct rpc_task *task, void *calldata)if (!nfs4_stateid_match (&data->arg.open_stateid, &lsp->ls_state->open_stateid)) goto out_restart; -else if (nfs4_async_handle_error (task, server, lsp->ls_state,NULL ) == -EAGAIN ) - goto out_restart; }else if (!nfs4_stateid_match (&data->arg.lock_stateid, &lsp->ls_stateid)) goto out_restart;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 38/162 arm64: Avoid repeated AA64MMFR1_EL1 register read on pagefault path
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gabriel Krisman Bertazi <[email protected]>
[ Upstream commit a89c6bcdac22bec1bfbe6e64060b4cf5838d4f47 ]
Accessing AA64MMFR1_EL1 is expensive in KVM guests, since it is emulated in the hypervisor. In fact, ARM documentation mentions some feature registers are not supposed to be accessed frequently by the OS, and therefore should be emulated for guests [1].
Commit 0388f9c74330 ("arm64: mm: Implement arch_wants_old_prefaulted_pte()") introduced a read of this register in the page fault path. But, even when the feature of setting faultaround pages with the old flag is disabled for a given cpu, we are still paying the cost of checking the register on every pagefault. This results in an explosion of vmexit events in KVM guests, which directly impacts the performance of virtualized workloads. For instance, running kernbench yields a 15% increase in system time solely due to the increased vmexit cycles.
This patch avoids the extra cost by using the sanitized cached value. It should be safe to do so, since this register mustn't change for a given cpu.
--- arch/arm64/include/asm/cpufeature.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
arch/arm64/include/asm/cpufeature.h +5 -1
@@ -863,7 +863,11 @@ static inline bool cpu_has_hw_af(void)if (!IS_ENABLED (CONFIG_ARM64_HW_AFDBM ))return false; - mmfr1 =read_cpuid (ID_AA64MMFR1_EL1 ); +/* +* Use cached version to avoid emulated msr operation on KVM +* guests. +*/ + mmfr1 =read_sanitised_ftr_reg (SYS_ID_AA64MMFR1_EL1 );return cpuid_feature_extract_unsigned_field (mmfr1,ID_AA64MMFR1_EL1_HAFDBS_SHIFT ); }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 39/162 net: add sysctl accept_ra_min_rtr_lft
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Patrick Rohr <[email protected]>
commit 1671bcfd76fdc0b9e65153cf759153083755fe4c upstream.
This change adds a new sysctl accept_ra_min_rtr_lft to specify the minimum acceptable router lifetime in an RA. If the received RA router lifetime is less than the configured value (and not 0), the RA is ignored.
This is useful for mobile devices, whose battery life can be impacted by networks that configure RAs with a short lifetime. On such networks, the device should never gain IPv6 provisioning and should attempt to drop RAs via hardware offload, if available.
--- Documentation/networking/ip-sysctl.rst | 8 ++++++++ include/linux/ipv6.h | 1 + include/uapi/linux/ipv6.h | 1 + net/ipv6/addrconf.c | 10 ++++++++++ net/ipv6/ndisc.c | 18 ++++++++++++++++-- 5 files changed, 36 insertions(+), 2 deletions(-)
Documentation/networking/ip-sysctl.rst +8 -0
@@ -2148,6 +2148,14 @@ accept_ra_min_hop_limit - INTEGER Default: 1 +accept_ra_min_rtr_lft - INTEGER + Minimum acceptable router lifetime in Router Advertisement. + + RAs with a router lifetime less than this value shall be + ignored. RAs with a router lifetime of 0 are unaffected. + + Default: 0 + accept_ra_pinfo - BOOLEAN Learn Prefix Information in Router Advertisement.
include/linux/ipv6.h +1 -0
@@ -33,6 +33,7 @@ struct ipv6_devconf {__s32 accept_ra_defrtr;__u32 ra_defrtr_metric;__s32 accept_ra_min_hop_limit; +__s32 accept_ra_min_rtr_lft;__s32 accept_ra_pinfo;__s32 ignore_routes_with_linkdown;#ifdef CONFIG_IPV6_ROUTER_PREF
include/uapi/linux/ipv6.h +1 -0
@@ -198,6 +198,7 @@ enum {DEVCONF_IOAM6_ID_WIDE ,DEVCONF_NDISC_EVICT_NOCARRIER ,DEVCONF_ACCEPT_UNTRACKED_NA , +DEVCONF_ACCEPT_RA_MIN_RTR_LFT , DEVCONF_MAX };
net/ipv6/addrconf.c +10 -0
@@ -202,6 +202,7 @@ static struct ipv6_devconf ipv6_devconf .ra_defrtr_metric = IP6_RT_PRIO_USER, .accept_ra_from_local = 0, .accept_ra_min_hop_limit= 1, + .accept_ra_min_rtr_lft = 0, .accept_ra_pinfo =1 , #ifdef CONFIG_IPV6_ROUTER_PREF .accept_ra_rtr_pref = 1,
@@ -262,6 +263,7 @@ static struct ipv6_devconf ipv6_devconf_ .ra_defrtr_metric = IP6_RT_PRIO_USER, .accept_ra_from_local = 0, .accept_ra_min_hop_limit= 1, + .accept_ra_min_rtr_lft = 0, .accept_ra_pinfo =1 , #ifdef CONFIG_IPV6_ROUTER_PREF .accept_ra_rtr_pref = 1,
@@ -5601,6 +5603,7 @@ static inline void ipv6_store_devconf(st array[DEVCONF_IOAM6_ID_WIDE ] = cnf->ioam6_id_wide; array[DEVCONF_NDISC_EVICT_NOCARRIER ] = cnf->ndisc_evict_nocarrier; array[DEVCONF_ACCEPT_UNTRACKED_NA ] = cnf->accept_untracked_na; + array[DEVCONF_ACCEPT_RA_MIN_RTR_LFT ] = cnf->accept_ra_min_rtr_lft; }static inline size_t inet6_ifla6_size (void )
@@ -6793,6 +6796,13 @@ static const struct ctl_table addrconf_s .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, + }, + { + .procname = "accept_ra_min_rtr_lft", + .data = &ipv6_devconf.accept_ra_min_rtr_lft, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec, }, { .procname = "accept_ra_pinfo",
net/ipv6/ndisc.c +16 -2
@@ -1284,6 +1284,8 @@ static void ndisc_router_discovery(strucreturn ; } + lifetime =ntohs (ra_msg->icmph.icmp6_rt_lifetime); +if (!ipv6_accept_ra (in6_dev)) { ND_PRINTK(2, info, "RA: %s, did not accept ra for dev: %s\n",
@@ -1291,6 +1293,13 @@ static void ndisc_router_discovery(struc goto skip_linkparms; } +if (lifetime !=0 && lifetime < in6_dev->cnf.accept_ra_min_rtr_lft) { +ND_PRINTK (2 , info, +"RA: router lifetime (%ds) is too short: %s\n" , + lifetime, skb->dev->name); + goto skip_linkparms; + } +#ifdef CONFIG_IPV6_NDISC_NODETYPE /* skip link-specific parameters from interior routers */ if (skb->ndisc_nodetype ==NDISC_NODETYPE_NODEFAULT ) {
@@ -1343,8 +1352,6 @@ static void ndisc_router_discovery(struc goto skip_defrtr; } - lifetime =ntohs (ra_msg->icmph.icmp6_rt_lifetime); -#ifdef CONFIG_IPV6_ROUTER_PREF pref = ra_msg->icmph.icmp6_router_pref;/* 10b is handled as if it were 00b (medium) */
@@ -1495,6 +1502,13 @@ skip_linkparms: goto out; } +if (lifetime !=0 && lifetime < in6_dev->cnf.accept_ra_min_rtr_lft) { +ND_PRINTK (2 , info, +"RA: router lifetime (%ds) is too short: %s\n" , + lifetime, skb->dev->name); + goto out; + } +#ifdef CONFIG_IPV6_ROUTE_INFO if (!in6_dev->cnf.accept_ra_from_local && ipv6_chk_addr(dev_net(in6_dev->dev), &ipv6_hdr(skb)->saddr,
Greg Kroah-Hartman
maintainerPATCH 40/162 net: change accept_ra_min_rtr_lft to affect all RA lifetimes
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Patrick Rohr <[email protected]>
commit 5027d54a9c30bc7ec808360378e2b4753f053f25 upstream.
accept_ra_min_rtr_lft only considered the lifetime of the default route and discarded entire RAs accordingly.
This change renames accept_ra_min_rtr_lft to accept_ra_min_lft, and applies the value to individual RA sections; in particular, router lifetime, PIO preferred lifetime, and RIO lifetime. If any of those lifetimes are lower than the configured value, the specific RA section is ignored.
In order for the sysctl to be useful to Android, it should really apply to all lifetimes in the RA, since that is what determines the minimum frequency at which RAs must be processed by the kernel. Android uses hardware offloads to drop RAs for a fraction of the minimum of all lifetimes present in the RA (some networks have very frequent RAs (5s) with high lifetimes (2h)). Despite this, we have encountered networks that set the router lifetime to 30s which results in very frequent CPU wakeups. Instead of disabling IPv6 (and dropping IPv6 ethertype in the WiFi firmware) entirely on such networks, it seems better to ignore the misconfigured routers while still processing RAs from other IPv6 routers on the same network (i.e. to support IoT applications).
The previous implementation dropped the entire RA based on router lifetime. This turned out to be hard to expand to the other lifetimes present in the RA in a consistent manner; dropping the entire RA based on RIO/PIO lifetimes would essentially require parsing the whole thing twice.
--- Documentation/networking/ip-sysctl.rst | 8 ++++---- include/linux/ipv6.h | 2 +- include/uapi/linux/ipv6.h | 2 +- net/ipv6/addrconf.c | 13 ++++++++----- net/ipv6/ndisc.c | 27 +++++++++++---------------- 5 files changed, 25 insertions(+), 27 deletions(-)
Documentation/networking/ip-sysctl.rst +4 -4
@@ -2148,11 +2148,11 @@ accept_ra_min_hop_limit - INTEGER Default: 1 -accept_ra_min_rtr_lft - INTEGER - Minimum acceptable router lifetime in Router Advertisement. +accept_ra_min_lft - INTEGER + Minimum acceptable lifetime value in Router Advertisement. - RAs with a router lifetime less than this value shall be - ignored. RAs with a router lifetime of 0 are unaffected. + RA sections with a lifetime less than this value shall be + ignored. Zero lifetimes stay unaffected. Default: 0
include/linux/ipv6.h +1 -1
@@ -33,7 +33,7 @@ struct ipv6_devconf {__s32 accept_ra_defrtr;__u32 ra_defrtr_metric;__s32 accept_ra_min_hop_limit; -__s32 accept_ra_min_rtr_lft; +__s32 accept_ra_min_lft;__s32 accept_ra_pinfo;__s32 ignore_routes_with_linkdown;#ifdef CONFIG_IPV6_ROUTER_PREF
include/uapi/linux/ipv6.h +1 -1
@@ -198,7 +198,7 @@ enum {DEVCONF_IOAM6_ID_WIDE ,DEVCONF_NDISC_EVICT_NOCARRIER ,DEVCONF_ACCEPT_UNTRACKED_NA , -DEVCONF_ACCEPT_RA_MIN_RTR_LFT , +DEVCONF_ACCEPT_RA_MIN_LFT , DEVCONF_MAX };
net/ipv6/addrconf.c +8 -5
@@ -202,7 +202,7 @@ static struct ipv6_devconf ipv6_devconf .ra_defrtr_metric = IP6_RT_PRIO_USER, .accept_ra_from_local = 0, .accept_ra_min_hop_limit= 1, - .accept_ra_min_rtr_lft = 0, + .accept_ra_min_lft = 0, .accept_ra_pinfo =1 , #ifdef CONFIG_IPV6_ROUTER_PREF .accept_ra_rtr_pref = 1,
@@ -263,7 +263,7 @@ static struct ipv6_devconf ipv6_devconf_ .ra_defrtr_metric = IP6_RT_PRIO_USER, .accept_ra_from_local = 0, .accept_ra_min_hop_limit= 1, - .accept_ra_min_rtr_lft = 0, + .accept_ra_min_lft = 0, .accept_ra_pinfo =1 , #ifdef CONFIG_IPV6_ROUTER_PREF .accept_ra_rtr_pref = 1,
@@ -2733,6 +2733,9 @@ void addrconf_prefix_rcv(struct net_devireturn ; } +if (valid_lft !=0 && valid_lft < in6_dev->cnf.accept_ra_min_lft) +return ; +/* * Two things going on here: * 1) Add routes for on-link prefixes
@@ -5603,7 +5606,7 @@ static inline void ipv6_store_devconf(st array[DEVCONF_IOAM6_ID_WIDE ] = cnf->ioam6_id_wide; array[DEVCONF_NDISC_EVICT_NOCARRIER ] = cnf->ndisc_evict_nocarrier; array[DEVCONF_ACCEPT_UNTRACKED_NA ] = cnf->accept_untracked_na; - array[DEVCONF_ACCEPT_RA_MIN_RTR_LFT ] = cnf->accept_ra_min_rtr_lft; + array[DEVCONF_ACCEPT_RA_MIN_LFT ] = cnf->accept_ra_min_lft; }static inline size_t inet6_ifla6_size (void )
@@ -6798,8 +6801,8 @@ static const struct ctl_table addrconf_s .proc_handler = proc_dointvec, }, { - .procname = "accept_ra_min_rtr_lft", - .data = &ipv6_devconf.accept_ra_min_rtr_lft, + .procname = "accept_ra_min_lft", + .data = &ipv6_devconf.accept_ra_min_lft, .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec,
net/ipv6/ndisc.c +11 -16
@@ -1284,8 +1284,6 @@ static void ndisc_router_discovery(strucreturn ; } - lifetime =ntohs (ra_msg->icmph.icmp6_rt_lifetime); -if (!ipv6_accept_ra (in6_dev)) { ND_PRINTK(2, info, "RA: %s, did not accept ra for dev: %s\n",
@@ -1293,13 +1291,6 @@ static void ndisc_router_discovery(struc goto skip_linkparms; } -if (lifetime !=0 && lifetime < in6_dev->cnf.accept_ra_min_rtr_lft) { -ND_PRINTK (2 , info, -"RA: router lifetime (%ds) is too short: %s\n" , - lifetime, skb->dev->name); - goto skip_linkparms; - } -#ifdef CONFIG_IPV6_NDISC_NODETYPE /* skip link-specific parameters from interior routers */ if (skb->ndisc_nodetype ==NDISC_NODETYPE_NODEFAULT ) {
@@ -1340,6 +1331,14 @@ static void ndisc_router_discovery(struc goto skip_defrtr; } + lifetime =ntohs (ra_msg->icmph.icmp6_rt_lifetime); +if (lifetime !=0 && lifetime < in6_dev->cnf.accept_ra_min_lft) { +ND_PRINTK (2 , info, +"RA: router lifetime (%ds) is too short: %s\n" , + lifetime, skb->dev->name); + goto skip_defrtr; + } +/* Do not accept RA with source-addr found on local machine unless * accept_ra_from_local is set to true. */
@@ -1502,13 +1501,6 @@ skip_linkparms: goto out; } -if (lifetime !=0 && lifetime < in6_dev->cnf.accept_ra_min_rtr_lft) { -ND_PRINTK (2 , info, -"RA: router lifetime (%ds) is too short: %s\n" , - lifetime, skb->dev->name); - goto out; - } -#ifdef CONFIG_IPV6_ROUTE_INFO if (!in6_dev->cnf.accept_ra_from_local && ipv6_chk_addr(dev_net(in6_dev->dev), &ipv6_hdr(skb)->saddr,
@@ -1533,6 +1525,9 @@ skip_linkparms:if (ri->prefix_len ==0 && !in6_dev->cnf.accept_ra_defrtr)continue ; +if (ri->lifetime !=0 && +ntohl (ri->lifetime) < in6_dev->cnf.accept_ra_min_lft) +continue ;if (ri->prefix_len < in6_dev->cnf.accept_ra_rt_info_min_plen)continue ;if (ri->prefix_len > in6_dev->cnf.accept_ra_rt_info_max_plen)
Greg Kroah-Hartman
maintainerPATCH 41/162 net: release reference to inet6_dev pointer
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Patrick Rohr <[email protected]>
commit 5cb249686e67dbef3ffe53887fa725eefc5a7144 upstream.
addrconf_prefix_rcv returned early without releasing the inet6_dev pointer when the PIO lifetime is less than accept_ra_min_lft.
--- net/ipv6/addrconf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/addrconf.c +1 -1
@@ -2734,7 +2734,7 @@ void addrconf_prefix_rcv(struct net_devi }if (valid_lft !=0 && valid_lft < in6_dev->cnf.accept_ra_min_lft) -return ; + goto put;/* * Two things going on here:
Greg Kroah-Hartman
maintainerPATCH 42/162 arm64: cpufeature: Fix CLRBHB and BC detection
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kristina Martsenko <[email protected]>
commit 479965a2b7ec481737df0cadf553331063b9c343 upstream.
ClearBHB support is indicated by the CLRBHB field in ID_AA64ISAR2_EL1. Following some refactoring the kernel incorrectly checks the BC field instead. Fix the detection to use the right field.
(Note: The original ClearBHB support had it as FTR_HIGHER_SAFE, but this patch uses FTR_LOWER_SAFE, which seems more correct.)
Also fix the detection of BC (hinted conditional branches) to use FTR_LOWER_SAFE, so that it is not reported on mismatched systems.
--- arch/arm64/include/asm/cpufeature.h | 2 +- arch/arm64/kernel/cpufeature.c | 3 ++- arch/arm64/tools/sysreg | 6 +++++- 3 files changed, 8 insertions(+), 3 deletions(-)
arch/arm64/include/asm/cpufeature.h +1 -1
@@ -670,7 +670,7 @@ static inline bool supports_clearbhb(int isar2 =read_sanitised_ftr_reg (SYS_ID_AA64ISAR2_EL1 );return cpuid_feature_extract_unsigned_field (isar2, -ID_AA64ISAR2_EL1_BC_SHIFT ); +ID_AA64ISAR2_EL1_CLRBHB_SHIFT ); }const struct cpumask *system_32bit_el0_cpumask (void );
arch/arm64/kernel/cpufeature.c +2 -1
@@ -212,7 +212,8 @@ static const struct arm64_ftr_bits ftr_i };static const struct arm64_ftr_bits ftr_id_aa64isar2[] = { -ARM64_FTR_BITS (FTR_HIDDEN ,FTR_STRICT ,FTR_HIGHER_SAFE ,ID_AA64ISAR2_EL1_BC_SHIFT ,4 ,0 ), +ARM64_FTR_BITS (FTR_HIDDEN ,FTR_STRICT ,FTR_LOWER_SAFE ,ID_AA64ISAR2_EL1_CLRBHB_SHIFT ,4 ,0 ), +ARM64_FTR_BITS (FTR_HIDDEN ,FTR_STRICT ,FTR_LOWER_SAFE ,ID_AA64ISAR2_EL1_BC_SHIFT ,4 ,0 ),ARM64_FTR_BITS (FTR_VISIBLE_IF_IS_ENABLED (CONFIG_ARM64_PTR_AUTH ),FTR_STRICT ,FTR_EXACT ,ID_AA64ISAR2_EL1_APA3_SHIFT ,4 ,0 ), ARM64_FTR_BITS(FTR_VISIBLE_IF_IS_ENABLED(CONFIG_ARM64_PTR_AUTH),
arch/arm64/tools/sysreg +5 -1
@@ -484,7 +484,11 @@ EndEnum EndSysreg Sysreg ID_AA64ISAR2_EL1 3 0 0 6 2 -Res0 63:28 +Res0 63:32 +Enum 31:28 CLRBHB + 0b0000 NI + 0b0001 IMP +EndEnum Enum 27:24 PAC_frac 0b0000 NI 0b0001 IMP
Greg Kroah-Hartman
maintainerPATCH 17/162 scsi: sd: Do not issue commands to suspended disks on shutdown
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
[ Upstream commit 99398d2070ab03d13f90b758ad397e19a65fffb0 ]
If an error occurs when resuming a host adapter before the devices attached to the adapter are resumed, the adapter low level driver may remove the scsi host, resulting in a call to sd_remove() for the disks of the host. This in turn results in a call to sd_shutdown() which will issue a synchronize cache command and a start stop unit command to spindown the disk. sd_shutdown() issues the commands only if the device is not already runtime suspended but does not check the power state for system-wide suspend/resume. That is, the commands may be issued with the device in a suspended state, which causes PM resume to hang, forcing a reset of the machine to recover.
Fix this by tracking the suspended state of a disk by introducing the suspended boolean field in the scsi_disk structure. This flag is set to true when the disk is suspended is sd_suspend_common() and resumed with sd_resume(). When suspended is true, sd_shutdown() is not executed from sd_remove().
--- drivers/scsi/sd.c | 17 +++++++++++++---- drivers/scsi/sd.h | 1 + 2 files changed, 14 insertions(+), 4 deletions(-)
drivers/scsi/sd.c +13 -4
@@ -3626,7 +3626,8 @@ static int sd_remove(struct device *dev)device_del (&sdkp->disk_dev);del_gendisk (sdkp->disk); -sd_shutdown (dev); +if (!sdkp->suspended) +sd_shutdown (dev);put_disk (sdkp->disk);return 0 ;
@@ -3753,6 +3754,9 @@ static int sd_suspend_common(struct device *dev, bool runtime) ret =0 ; } +if (!ret) + sdkp->suspended = true; +return ret; }
@@ -3772,21 +3776,26 @@ static int sd_suspend_runtime(struct device *dev)static int sd_resume (struct device *dev,bool runtime) {struct scsi_disk *sdkp =dev_get_drvdata (dev); -int ret; +int ret =0 ;if (!sdkp)/* E.g.: runtime resume at the start of sd_probe() */ return 0 ; -if (!sd_do_start_stop (sdkp->device, runtime)) +if (!sd_do_start_stop (sdkp->device, runtime)) { + sdkp->suspended = false;return 0 ; + }if (!sdkp->device->no_start_on_resume) {sd_printk (KERN_NOTICE , sdkp,"Starting disk\n" ); ret =sd_start_stop_device (sdkp,1 ); } -if (!ret) +if (!ret) {opal_unlock_from_suspend (sdkp->opal_dev); + sdkp->suspended = false; + } +return ret; }
drivers/scsi/sd.h +1 -0
@@ -131,6 +131,7 @@ struct scsi_disk {u8 provisioning_mode;u8 zeroing_mode;u8 nr_actuators;/* Number of actuators */ +bool suspended;/* Disk is suspended (stopped) */ unsigned ATO : 1; /* state of disk ATO bit */ unsigned cache_override : 1; /* temp override of WCE,RCD */ unsigned WCE : 1; /* state of disk WCE bit */
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 18/162 scsi: core: Improve type safety of scsi_rescan_device()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <[email protected]>
[ Upstream commit 79519528a180c64a90863db2ce70887de6c49d16 ]
Most callers of scsi_rescan_device() have the scsi_device pointer readily available. Pass a struct scsi_device pointer to scsi_rescan_device() instead of a struct device pointer. This change prevents that a pointer to another struct device would be passed accidentally to scsi_rescan_device().
Remove the scsi_rescan_device() declaration from the scsi_priv.h header file since it duplicates the declaration in <scsi/scsi_host.h>.
Stable-dep-of: 8b4d9469d0b0 ("ata: libata-scsi: Fix delayed scsi_rescan_device() execution")
--- drivers/ata/libata-scsi.c | 2 +- drivers/scsi/aacraid/commsup.c | 2 +- drivers/scsi/mvumi.c | 2 +- drivers/scsi/scsi_lib.c | 2 +- drivers/scsi/scsi_priv.h | 1 - drivers/scsi/scsi_scan.c | 4 ++-- drivers/scsi/scsi_sysfs.c | 4 ++-- drivers/scsi/smartpqi/smartpqi_init.c | 2 +- drivers/scsi/storvsc_drv.c | 2 +- drivers/scsi/virtio_scsi.c | 2 +- include/scsi/scsi_host.h | 2 +- 11 files changed, 12 insertions(+), 13 deletions(-)
drivers/ata/libata-scsi.c +1 -1
@@ -4678,7 +4678,7 @@ void ata_scsi_dev_rescan(struct work_struct *work) }spin_unlock_irqrestore (ap->lock, flags); -scsi_rescan_device (&(sdev->sdev_gendev)); +scsi_rescan_device (sdev);scsi_device_put (sdev);spin_lock_irqsave (ap->lock, flags); }
drivers/scsi/aacraid/commsup.c +1 -1
@@ -1451,7 +1451,7 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr)#endif break ; } -scsi_rescan_device (&device->sdev_gendev); +scsi_rescan_device (device);break ;default :
drivers/scsi/mvumi.c +1 -1
@@ -1500,7 +1500,7 @@ static void mvumi_rescan_devices(struct mvumi_hba *mhba, int id) sdev =scsi_device_lookup (mhba->shost,0 , id,0 );if (sdev) { -scsi_rescan_device (&sdev->sdev_gendev); +scsi_rescan_device (sdev);scsi_device_put (sdev); } }
drivers/scsi/scsi_lib.c +1 -1
@@ -2445,7 +2445,7 @@ static void scsi_evt_emit(struct scsi_device *sdev, struct scsi_event *evt) envp[idx++] ="SDEV_MEDIA_CHANGE=1" ;break ;case SDEV_EVT_INQUIRY_CHANGE_REPORTED : -scsi_rescan_device (&sdev->sdev_gendev); +scsi_rescan_device (sdev); envp[idx++] ="SDEV_UA=INQUIRY_DATA_HAS_CHANGED" ;break ;case SDEV_EVT_CAPACITY_CHANGE_REPORTED :
drivers/scsi/scsi_priv.h +0 -1
@@ -132,7 +132,6 @@ extern int scsi_complete_async_scans(void);extern int scsi_scan_host_selected (struct Scsi_Host *,unsigned int ,unsigned int ,u64 ,enum scsi_scan_mode );extern void scsi_forget_host (struct Scsi_Host *); -extern void scsi_rescan_device (struct device *);/* scsi_sysctl.c */ #ifdef CONFIG_SYSCTL
drivers/scsi/scsi_scan.c +2 -2
@@ -1611,9 +1611,9 @@ int scsi_add_device(struct Scsi_Host *host, uint channel, }EXPORT_SYMBOL (scsi_add_device); -void scsi_rescan_device (struct device *dev) +void scsi_rescan_device (struct scsi_device *sdev) { -struct scsi_device *sdev =to_scsi_device (dev); +struct device *dev = &sdev->sdev_gendev;device_lock (dev);
drivers/scsi/scsi_sysfs.c +2 -2
@@ -762,7 +762,7 @@ static ssize_t store_rescan_field (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { -scsi_rescan_device (dev); +scsi_rescan_device (to_scsi_device(dev ));return count; } static DEVICE_ATTR(rescan, S_IWUSR, NULL, store_rescan_field);
@@ -855,7 +855,7 @@ store_state_field(struct device *dev, struct device_attribute *attr,* waiting for pending I/O to finish. */ blk_mq_run_hw_queues (sdev->request_queue, true); -scsi_rescan_device (dev); +scsi_rescan_device (sdev); }return ret ==0 ? count : -EINVAL ;
drivers/scsi/smartpqi/smartpqi_init.c +1 -1
@@ -2278,7 +2278,7 @@ static void pqi_update_device_list(struct pqi_ctrl_info *ctrl_info, device->advertised_queue_depth = device->queue_depth;scsi_change_queue_depth (device->sdev, device->advertised_queue_depth);if (device->rescan) { -scsi_rescan_device (&device->sdev->sdev_gendev); +scsi_rescan_device (device->sdev); device->rescan = false; } }
drivers/scsi/storvsc_drv.c +1 -1
@@ -471,7 +471,7 @@ static void storvsc_device_scan(struct work_struct *work) sdev =scsi_device_lookup (wrk->host,0 , wrk->tgt_id, wrk->lun);if (!sdev) goto done; -scsi_rescan_device (&sdev->sdev_gendev); +scsi_rescan_device (sdev);scsi_device_put (sdev); done:
drivers/scsi/virtio_scsi.c +1 -1
@@ -325,7 +325,7 @@ static void virtscsi_handle_param_change(struct virtio_scsi *vscsi,/* Handle "Parameters changed", "Mode parameters changed", and "Capacity data has changed". */ if (asc ==0x2a && (ascq ==0x00 || ascq ==0x01 || ascq ==0x09 )) -scsi_rescan_device (&sdev->sdev_gendev); +scsi_rescan_device (sdev);scsi_device_put (sdev); }
include/scsi/scsi_host.h +1 -1
@@ -752,7 +752,7 @@ extern int __must_check scsi_add_host_with_dma(struct Scsi_Host *, struct device *, struct device *);extern void scsi_scan_host (struct Scsi_Host *); -extern void scsi_rescan_device (struct device *); +extern void scsi_rescan_device (struct scsi_device *);extern void scsi_remove_host (struct Scsi_Host *);extern struct Scsi_Host *scsi_host_get (struct Scsi_Host *);extern int scsi_host_busy (struct Scsi_Host *shost);
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 19/162 scsi: Do not attempt to rescan suspended devices
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
[ Upstream commit ff48b37802e5c134e2dfc4d091f10b2eb5065a72 ]
scsi_rescan_device() takes a scsi device lock before executing a device handler and device driver rescan methods. Waiting for the completion of any command issued to the device by these methods will thus be done with the device lock held. As a result, there is a risk of deadlocking within the power management code if scsi_rescan_device() is called to handle a device resume with the associated scsi device not yet resumed.
Avoid such situation by checking that the target scsi device is in the running state, that is, fully capable of executing commands, before proceeding with the rescan and bailout returning -EWOULDBLOCK otherwise. With this error return, the caller can retry rescaning the device after a delay.
The state check is done with the device lock held and is thus safe against incoming suspend power management operations.
Stable-dep-of: 8b4d9469d0b0 ("ata: libata-scsi: Fix delayed scsi_rescan_device() execution")
--- drivers/scsi/scsi_scan.c | 18 +++++++++++++++++- include/scsi/scsi_host.h | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-)
drivers/scsi/scsi_scan.c +17 -1
@@ -1611,12 +1611,24 @@ int scsi_add_device(struct Scsi_Host *host, uint channel, }EXPORT_SYMBOL (scsi_add_device); -void scsi_rescan_device (struct scsi_device *sdev) +int scsi_rescan_device (struct scsi_device *sdev) {struct device *dev = &sdev->sdev_gendev; +int ret =0 ;device_lock (dev); +/* +* Bail out if the device is not running. Otherwise, the rescan may +* block waiting for commands to be executed, with us holding the +* device lock. This can result in a potential deadlock in the power +* management core code when system resume is on-going. +*/ +if (sdev->sdev_state !=SDEV_RUNNING ) { + ret = -EWOULDBLOCK ; + goto unlock; + } +scsi_attach_vpd (sdev);if (sdev->handler && sdev->handler->rescan)
@@ -1629,7 +1641,11 @@ void scsi_rescan_device(struct scsi_device *sdev) drv->rescan (dev);module_put (dev->driver->owner); } + +unlock:device_unlock (dev); + +return ret; }EXPORT_SYMBOL (scsi_rescan_device);
include/scsi/scsi_host.h +1 -1
@@ -752,7 +752,7 @@ extern int __must_check scsi_add_host_with_dma(struct Scsi_Host *, struct device *, struct device *);extern void scsi_scan_host (struct Scsi_Host *); -extern void scsi_rescan_device (struct scsi_device *); +extern int scsi_rescan_device (struct scsi_device *sdev);extern void scsi_remove_host (struct Scsi_Host *);extern struct Scsi_Host *scsi_host_get (struct Scsi_Host *);extern int scsi_host_busy (struct Scsi_Host *shost);
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 20/162 ata: libata-scsi: Fix delayed scsi_rescan_device() execution
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
[ Upstream commit 8b4d9469d0b0e553208ee6f62f2807111fde18b9 ]
Commit 6aa0365a3c85 ("ata: libata-scsi: Avoid deadlock on rescan after device resume") modified ata_scsi_dev_rescan() to check the scsi device "is_suspended" power field to ensure that the scsi device associated with an ATA device is fully resumed when scsi_rescan_device() is executed. However, this fix is problematic as:
1) It relies on a PM internal field that should not be used without PM device locking protection.
2) The check for is_suspended and the call to scsi_rescan_device() are not atomic and a suspend PM event may be triggered between them, casuing scsi_rescan_device() to be called on a suspended device and in that function blocking while holding the scsi device lock. This would deadlock a following resume operation.
These problems can trigger PM deadlocks on resume, especially with resume operations triggered quickly after or during suspend operations. E.g., a simple bash script like:
for (( i=0; i<10; i++ )); do
echo "+2 > /sys/class/rtc/rtc0/wakealarm
echo mem > /sys/power/state
done
that triggers a resume 2 seconds after starting suspending a system can quickly lead to a PM deadlock preventing the system from correctly resuming.
Fix this by replacing the check on is_suspended with a check on the return value given by scsi_rescan_device() as that function will fail if called against a suspended device. Also make sure rescan tasks already scheduled are first cancelled before suspending an ata port.
--- drivers/ata/libata-core.c | 16 ++++++++++++++++ drivers/ata/libata-scsi.c | 33 +++++++++++++++------------------ 2 files changed, 31 insertions(+), 18 deletions(-)
drivers/ata/libata-core.c +16 -0
@@ -5022,11 +5022,27 @@ static const unsigned int ata_port_suspend_ehi = ATA_EHI_QUIETstatic void ata_port_suspend (struct ata_port *ap,pm_message_t mesg) { +/* +* We are about to suspend the port, so we do not care about +* scsi_rescan_device() calls scheduled by previous resume operations. +* The next resume will schedule the rescan again. So cancel any rescan +* that is not done yet. +*/ +cancel_delayed_work_sync (&ap->scsi_rescan_task); +ata_port_request_pm (ap, mesg,0 , ata_port_suspend_ehi, false); }static void ata_port_suspend_async (struct ata_port *ap,pm_message_t mesg) { +/* +* We are about to suspend the port, so we do not care about +* scsi_rescan_device() calls scheduled by previous resume operations. +* The next resume will schedule the rescan again. So cancel any rescan +* that is not done yet. +*/ +cancel_delayed_work_sync (&ap->scsi_rescan_task); +ata_port_request_pm (ap, mesg,0 , ata_port_suspend_ehi, true); }
drivers/ata/libata-scsi.c +15 -18
@@ -4648,7 +4648,7 @@ void ata_scsi_dev_rescan(struct work_struct *work)struct ata_link *link;struct ata_device *dev;unsigned long flags; -bool delay_rescan = false; +int ret =0 ;mutex_lock (&ap->scsi_scan_mutex);spin_lock_irqsave (ap->lock, flags);
@@ -4657,37 +4657,34 @@ void ata_scsi_dev_rescan(struct work_struct *work)ata_for_each_dev (dev, link,ENABLED ) {struct scsi_device *sdev = dev->sdev; +/* +* If the port was suspended before this was scheduled, +* bail out. +*/ +if (ap->pflags &ATA_PFLAG_SUSPENDED ) + goto unlock; +if (!sdev)continue ;if (scsi_device_get (sdev))continue ; -/* -* If the rescan work was scheduled because of a resume -* event, the port is already fully resumed, but the -* SCSI device may not yet be fully resumed. In such -* case, executing scsi_rescan_device() may cause a -* deadlock with the PM code on device_lock(). Prevent -* this by giving up and retrying rescan after a short -* delay. -*/ - delay_rescan = sdev->sdev_gendev.power.is_suspended; -if (delay_rescan) { -scsi_device_put (sdev); -break ; - } -spin_unlock_irqrestore (ap->lock, flags); -scsi_rescan_device (sdev); + ret =scsi_rescan_device (sdev);scsi_device_put (sdev);spin_lock_irqsave (ap->lock, flags); + +if (ret) + goto unlock; } } +unlock:spin_unlock_irqrestore (ap->lock, flags);mutex_unlock (&ap->scsi_scan_mutex); -if (delay_rescan) +/* Reschedule with a delay if scsi_rescan_device() returned an error */ +if (ret)schedule_delayed_work (&ap->scsi_rescan_task,msecs_to_jiffies (5 )); }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 21/162 NFS: Cleanup unused rpc_clnt variable
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Coddington <[email protected]>
[ Upstream commit e025f0a73f6acb920d86549b2177a5883535421d ]
The root rpc_clnt is not used here, clean it up.
Stable-dep-of: 956fd46f97d2 ("NFSv4: Fix a state manager thread deadlock regression")
--- fs/nfs/nfs4state.c | 4 ---- 1 file changed, 4 deletions(-)
fs/nfs/nfs4state.c +0 -4
@@ -1209,10 +1209,6 @@ 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_AVAILABLE , &clp->cl_state) !=0 ) {
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 22/162 NFS: rename nfs_client_kset to nfs_kset
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Coddington <[email protected]>
[ Upstream commit 8b18a2edecc0741b0eecf8b18fdb356a0f8682de ]
Be brief and match the subsystem name. There's no need to distinguish this kset variable from the server.
Stable-dep-of: 956fd46f97d2 ("NFSv4: Fix a state manager thread deadlock regression")
--- fs/nfs/sysfs.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
fs/nfs/sysfs.c +8 -8
@@ -18,7 +18,7 @@#include "sysfs.h" struct kobject *nfs_client_kobj; -static struct kset *nfs_client_kset; +static struct kset *nfs_kset;static void nfs_netns_object_release (struct kobject *kobj) {
@@ -55,13 +55,13 @@ static struct kobject *nfs_netns_object_alloc(const char *name,int nfs_sysfs_init (void ) { - nfs_client_kset =kset_create_and_add ("nfs" ,NULL , fs_kobj); -if (!nfs_client_kset) + nfs_kset =kset_create_and_add ("nfs" ,NULL , fs_kobj); +if (!nfs_kset)return -ENOMEM ; - nfs_client_kobj =nfs_netns_object_alloc ("net" , nfs_client_kset,NULL ); + nfs_client_kobj =nfs_netns_object_alloc ("net" , nfs_kset,NULL );if (!nfs_client_kobj) { -kset_unregister (nfs_client_kset); - nfs_client_kset =NULL ; +kset_unregister (nfs_kset); + nfs_kset =NULL ;return -ENOMEM ; }return 0 ;
@@ -70,7 +70,7 @@ int nfs_sysfs_init(void)void nfs_sysfs_exit (void ) {kobject_put (nfs_client_kobj); -kset_unregister (nfs_client_kset); +kset_unregister (nfs_kset); } static ssize_t nfs_netns_identifier_show(struct kobject *kobj,
@@ -159,7 +159,7 @@ static struct nfs_netns_client *nfs_netns_client_alloc(struct kobject *parent, p =kzalloc (sizeof (*p),GFP_KERNEL );if (p) { p->net = net; - p->kobject.kset = nfs_client_kset; + p->kobject.kset = nfs_kset;if (kobject_init_and_add (&p->kobject, &nfs_netns_client_type, parent,"nfs_client" ) ==0 )return p;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 23/162 NFSv4: Fix a state manager thread deadlock regression
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Trond Myklebust <[email protected]>
[ Upstream commit 956fd46f97d238032cb5fa4771cdaccc6e760f9a ]
Commit 4dc73c679114 reintroduces the deadlock that was fixed by commit aeabb3c96186 ("NFSv4: Fix a NFSv4 state manager deadlock") because it prevents the setup of new threads to handle reboot recovery, while the older recovery thread is stuck returning delegations.
--- fs/nfs/nfs4proc.c | 4 +++- fs/nfs/nfs4state.c | 36 +++++++++++++++++++++++++----------- 2 files changed, 28 insertions(+), 12 deletions(-)
fs/nfs/nfs4proc.c +3 -1
@@ -10629,7 +10629,9 @@ static void nfs4_disable_swap(struct inode *inode)*/ struct nfs_client *clp =NFS_SERVER (inode)->nfs_client; -nfs4_schedule_state_manager (clp); +set_bit (NFS4CLNT_RUN_MANAGER , &clp->cl_state); +clear_bit (NFS4CLNT_MANAGER_AVAILABLE , &clp->cl_state); +wake_up_var (&clp->cl_state); }static const struct inode_operations nfs4_dir_inode_operations = {
fs/nfs/nfs4state.c +25 -11
@@ -1209,13 +1209,23 @@ void nfs4_schedule_state_manager(struct nfs_client *clp) {struct task_struct *task;char buf[INET6_ADDRSTRLEN +sizeof ("-manager" ) +1 ]; +struct rpc_clnt *clnt = clp->cl_rpcclient; +bool swapon = false;set_bit (NFS4CLNT_RUN_MANAGER , &clp->cl_state); -if (test_and_set_bit (NFS4CLNT_MANAGER_AVAILABLE , &clp->cl_state) !=0 ) { -wake_up_var (&clp->cl_state); -return ; + +if (atomic_read (&clnt->cl_swapper)) { + swapon = !test_and_set_bit (NFS4CLNT_MANAGER_AVAILABLE , + &clp->cl_state); +if (!swapon) { +wake_up_var (&clp->cl_state); +return ; + } } -set_bit (NFS4CLNT_MANAGER_RUNNING , &clp->cl_state); + +if (test_and_set_bit (NFS4CLNT_MANAGER_RUNNING , &clp->cl_state) !=0 ) +return ; +__module_get (THIS_MODULE );refcount_inc (&clp->cl_count);
@@ -1232,8 +1242,9 @@ void nfs4_schedule_state_manager(struct nfs_client *clp) __func__, PTR_ERR(task));if (!nfs_client_init_is_complete (clp))nfs_mark_client_ready (clp,PTR_ERR (task)); +if (swapon) +clear_bit (NFS4CLNT_MANAGER_AVAILABLE , &clp->cl_state);nfs4_clear_state_manager_bit (clp); -clear_bit (NFS4CLNT_MANAGER_AVAILABLE , &clp->cl_state);nfs_put_client (clp);module_put (THIS_MODULE ); }
@@ -2737,22 +2748,25 @@ static int nfs4_run_state_manager(void *ptr)allow_signal (SIGKILL ); again: -set_bit (NFS4CLNT_MANAGER_RUNNING , &clp->cl_state);nfs4_state_manager (clp); -if (atomic_read (&cl->cl_swapper)) { + +if (test_bit (NFS4CLNT_MANAGER_AVAILABLE , &clp->cl_state) && + !test_bit (NFS4CLNT_MANAGER_RUNNING , &clp->cl_state)) {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)) +if (!atomic_read (&cl->cl_swapper)) +clear_bit (NFS4CLNT_MANAGER_AVAILABLE , &clp->cl_state); +if (refcount_read (&clp->cl_count) >1 && !signalled () && + !test_and_set_bit (NFS4CLNT_MANAGER_RUNNING , &clp->cl_state)) goto again;/* Either no longer a swapper, or were signalled */ +clear_bit (NFS4CLNT_MANAGER_AVAILABLE , &clp->cl_state); } -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)) + !test_and_set_bit (NFS4CLNT_MANAGER_RUNNING , &clp->cl_state)) goto again;nfs_put_client (clp);
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 14/162 mptcp: process pending subflow error on close
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
[ Upstream commit 9f1a98813b4b686482e5ef3c9d998581cace0ba6 ]
On incoming TCP reset, subflow closing could happen before error propagation. That in turn could cause the socket error being ignored, and a missing socket state transition, as reported by Daire-Byrne.
Address the issues explicitly checking for subflow socket error at close time. To avoid code duplication, factor-out of __mptcp_error_report() a new helper implementing the relevant bits.
--- net/mptcp/protocol.c | 63 ++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 29 deletions(-)
net/mptcp/protocol.c +34 -29
@@ -765,40 +765,44 @@ static bool __mptcp_ofo_queue(struct mptcp_sock *msk)return moved; } -void __mptcp_error_report (struct sock *sk) +static bool __mptcp_subflow_error_report (struct sock *sk,struct sock *ssk) { -struct mptcp_subflow_context *subflow; -struct mptcp_sock *msk =mptcp_sk (sk); +int err =sock_error (ssk); +int ssk_state; -mptcp_for_each_subflow (msk, subflow) { -struct sock *ssk =mptcp_subflow_tcp_sock (subflow); -int err =sock_error (ssk); -int ssk_state; +if (!err) +return false; -if (!err) -continue ; +/* only propagate errors on fallen-back sockets or +* on MPC connect +*/ +if (sk->sk_state !=TCP_SYN_SENT && !__mptcp_check_fallback (mptcp_sk (sk))) +return false; -/* only propagate errors on fallen-back sockets or -* on MPC connect -*/ -if (sk->sk_state !=TCP_SYN_SENT && !__mptcp_check_fallback (msk)) -continue ; +/* We need to propagate only transition to CLOSE state. +* Orphaned socket will see such state change via +* subflow_sched_work_if_closed() and that path will properly +* destroy the msk as needed. +*/ + ssk_state =inet_sk_state_load (ssk); +if (ssk_state ==TCP_CLOSE && !sock_flag (sk,SOCK_DEAD )) +inet_sk_state_store (sk, ssk_state); +WRITE_ONCE (sk->sk_err, -err); -/* We need to propagate only transition to CLOSE state. -* Orphaned socket will see such state change via -* subflow_sched_work_if_closed() and that path will properly -* destroy the msk as needed. -*/ - ssk_state =inet_sk_state_load (ssk); -if (ssk_state ==TCP_CLOSE && !sock_flag (sk,SOCK_DEAD )) -inet_sk_state_store (sk, ssk_state); -WRITE_ONCE (sk->sk_err, -err); - -/* This barrier is coupled with smp_rmb() in mptcp_poll() */ -smp_wmb (); -sk_error_report (sk); -break ; - } +/* This barrier is coupled with smp_rmb() in mptcp_poll() */ +smp_wmb (); +sk_error_report (sk); +return true; +} + +void __mptcp_error_report (struct sock *sk) +{ +struct mptcp_subflow_context *subflow; +struct mptcp_sock *msk =mptcp_sk (sk); + +mptcp_for_each_subflow (msk, subflow) +if (__mptcp_subflow_error_report (sk,mptcp_subflow_tcp_sock (subflow))) +break ; }/* In most cases we will be able to lock the mptcp socket. If its already
@@ -2446,6 +2450,7 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk, } out_release: +__mptcp_subflow_error_report (sk, ssk);release_sock (ssk);sock_put (ssk);
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 44/162 iommu/arm-smmu-v3: Set TTL invalidation hint better
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Robin Murphy <[email protected]>
[ Upstream commit 6833b8f2e19945a41e4d5efd8c6d9f4cae9a5b7d ]
When io-pgtable unmaps a whole table, rather than waste time walking it to find the leaf entries to invalidate exactly, it simply expects .tlb_flush_walk with nominal last-level granularity to invalidate any leaf entries at higher intermediate levels as well. This works fine with page-based invalidation, but with range commands we need to be careful with the TTL hint - unconditionally setting it based on the given level 3 granule means that an invalidation for a level 1 table would strictly not be required to affect level 2 block entries. It's easy to comply with the expected behaviour by simply not setting the TTL hint for non-leaf invalidations, so let's do that.
--- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +7 -2
@@ -1889,8 +1889,13 @@ static void __arm_smmu_tlb_inv_range(struct arm_smmu_cmdq_ent *cmd,/* Convert page size of 12,14,16 (log2) to 1,2,3 */ cmd->tlbi.tg = (tg -10 ) /2 ; -/* Determine what level the granule is at */ - cmd->tlbi.ttl =4 - ((ilog2 (granule) -3 ) / (tg -3 )); +/* +* Determine what level the granule is at. For non-leaf, io-pgtable +* assumes .tlb_flush_walk can invalidate multiple levels at once, +* so ignore the nominal last-level granule and leave TTL=0. +*/ +if (cmd->tlbi.leaf) + cmd->tlbi.ttl =4 - ((ilog2 (granule) -3 ) / (tg -3 )); num_pages = size >> tg; }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 53/162 i40e: fix the wrong PTP frequency calculation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yajun Deng <[email protected]>
The new adjustment should be based on the base frequency, not the I40E_PTP_40GB_INCVAL in i40e_ptp_adjfine().
This issue was introduced in commit 3626a690b717 ("i40e: use mul_u64_u64_div_u64 for PTP frequency calculation"), frequency is left just as base I40E_PTP_40GB_INCVAL before the commit. After the commit, frequency is the I40E_PTP_40GB_INCVAL times the ptp_adj_mult value. But then the diff is applied on the wrong value, and no multiplication is done afterwards.
It was accidentally fixed in commit 1060707e3809 ("ptp: introduce helpers to adjust by scaled parts per million"). It uses adjust_by_scaled_ppm correctly performs the calculation and uses the base adjustment, so there's no error here. But it is a new feature and doesn't need to backported to the stable releases.
This issue affects both v6.0 and v6.1, and the v6.1 version is an LTS release. Therefore, the patch only needs to be applied to v6.1 stable.
--- drivers/net/ethernet/intel/i40e/i40e_ptp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_ptp.c +2 -2
@@ -361,9 +361,9 @@ static int i40e_ptp_adjfine(struct ptp_c 1000000ULL << 16);if (neg_adj) - adj =I40E_PTP_40GB_INCVAL - diff; + adj = freq - diff;else - adj =I40E_PTP_40GB_INCVAL + diff; + adj = freq + diff;wr32 (hw,I40E_PRTTSYN_INC_L , adj &0xFFFFFFFF );wr32 (hw,I40E_PRTTSYN_INC_H , adj >>32 );
Greg Kroah-Hartman
maintainerPATCH 54/162 scsi: zfcp: Fix a double put in zfcp_port_enqueue()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dinghao Liu <[email protected]>
commit b481f644d9174670b385c3a699617052cd2a79d3 upstream.
When device_register() fails, zfcp_port_release() will be called after put_device(). As a result, zfcp_ccw_adapter_put() will be called twice: one in zfcp_port_release() and one in the error path after device_register(). So the reference on the adapter object is doubly put, which may lead to a premature free. Fix this by adjusting the error tag after device_register().
--- drivers/s390/scsi/zfcp_aux.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/s390/scsi/zfcp_aux.c +5 -4
@@ -518,12 +518,12 @@ struct zfcp_port *zfcp_port_enqueue(struif (port) {put_device (&port->dev); retval = -EEXIST ; - goto err_out; + goto err_put; } port =kzalloc (sizeof (struct zfcp_port ),GFP_KERNEL );if (!port) - goto err_out; + goto err_put;rwlock_init (&port->unit_list_lock);INIT_LIST_HEAD (&port->unit_list);
@@ -546,7 +546,7 @@ struct zfcp_port *zfcp_port_enqueue(struif (dev_set_name (&port->dev,"0x%016llx" , (unsigned long long )wwpn)) {kfree (port); - goto err_out; + goto err_put; } retval = -EINVAL ;
@@ -563,7 +563,8 @@ struct zfcp_port *zfcp_port_enqueue(strureturn port; -err_out: +err_put:zfcp_ccw_adapter_put (adapter); +err_out:return ERR_PTR (retval); }
Greg Kroah-Hartman
maintainerPATCH 55/162 iommu/vt-d: Avoid memory allocation in iommu_suspend()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Rui <[email protected]>
commit 59df44bfb0ca4c3ee1f1c3c5d0ee8e314844799e upstream.
The iommu_suspend() syscore suspend callback is invoked with IRQ disabled. Allocating memory with the GFP_KERNEL flag may re-enable IRQs during the suspend callback, which can cause intermittent suspend/hibernation problems with the following kernel traces:
Calling iommu_suspend+0x0/0x1d0
------------[ cut here ]------------ WARNING: CPU: 0 PID: 15 at kernel/time/timekeeping.c:868 ktime_get+0x9b/0xb0 ... CPU: 0 PID: 15 Comm: rcu_preempt Tainted: G U E 6.3-intel #r1 RIP: 0010:ktime_get+0x9b/0xb0 ... Call Trace: <IRQ> tick_sched_timer+0x22/0x90 ? __pfx_tick_sched_timer+0x10/0x10 __hrtimer_run_queues+0x111/0x2b0 hrtimer_interrupt+0xfa/0x230 __sysvec_apic_timer_interrupt+0x63/0x140 sysvec_apic_timer_interrupt+0x7b/0xa0 </IRQ> <TASK> asm_sysvec_apic_timer_interrupt+0x1f/0x30 ... ------------[ cut here ]------------ Interrupts enabled after iommu_suspend+0x0/0x1d0 WARNING: CPU: 0 PID: 27420 at drivers/base/syscore.c:68 syscore_suspend+0x147/0x270 CPU: 0 PID: 27420 Comm: rtcwake Tainted: G U W E 6.3-intel #r1 RIP: 0010:syscore_suspend+0x147/0x270 ... Call Trace: <TASK> hibernation_snapshot+0x25b/0x670 hibernate+0xcd/0x390 state_store+0xcf/0xe0 kobj_attr_store+0x13/0x30 sysfs_kf_write+0x3f/0x50 kernfs_fop_write_iter+0x128/0x200 vfs_write+0x1fd/0x3c0 ksys_write+0x6f/0xf0 __x64_sys_write+0x1d/0x30 do_syscall_64+0x3b/0x90 entry_SYSCALL_64_after_hwframe+0x72/0xdc
Given that only 4 words memory is needed, avoid the memory allocation in iommu_suspend().
--- drivers/iommu/intel/iommu.c | 16 ---------------- drivers/iommu/intel/iommu.h | 2 +- 2 files changed, 1 insertion(+), 17 deletions(-)
drivers/iommu/intel/iommu.c +0 -16
@@ -3163,13 +3163,6 @@ static int iommu_suspend(void)struct intel_iommu *iommu =NULL ;unsigned long flag; -for_each_active_iommu (iommu, drhd) { - iommu->iommu_state =kcalloc (MAX_SR_DMAR_REGS ,sizeof (u32), -GFP_KERNEL ); -if (!iommu->iommu_state) - goto nomem; - } -iommu_flush_all ();for_each_active_iommu (iommu, drhd) {
@@ -3189,12 +3182,6 @@ static int iommu_suspend(void)raw_spin_unlock_irqrestore (&iommu->register_lock, flag); }return 0 ; - -nomem: -for_each_active_iommu (iommu, drhd) -kfree (iommu->iommu_state); - -return -ENOMEM ; }static void iommu_resume (void )
@@ -3226,9 +3213,6 @@ static void iommu_resume(void)raw_spin_unlock_irqrestore (&iommu->register_lock, flag); } - -for_each_active_iommu (iommu, drhd) -kfree (iommu->iommu_state); }static struct syscore_ops iommu_syscore_ops = {
drivers/iommu/intel/iommu.h +1 -1
@@ -595,7 +595,7 @@ struct intel_iommu {struct iopf_queue *iopf_queue;unsigned char iopfq_name[16 ];struct q_inval *qi;/* Queued invalidation info */ -u32 *iommu_state;/* Store iommu states between suspend and resume.*/ +u32 iommu_state[MAX_SR_DMAR_REGS ];/* Store iommu states between suspend and resume.*/ #ifdef CONFIG_IRQ_REMAP struct ir_table *ir_table;/* Interrupt remapping info */
Greg Kroah-Hartman
maintainerPATCH 56/162 vringh: dont use vringh_kiov_advance() in vringh_iov_xfer()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefano Garzarella <[email protected]>
commit 7aed44babc7f97e82b38e9a68515e699692cc100 upstream.
In the while loop of vringh_iov_xfer(), partlen could be 0 if one of the iov has 0 lenght.
In this case, we should skip the iov and go to the next one. But calling vringh_kiov_advance() with 0 lenght does not cause the advancement, since it returns immediately if asked to advance by 0 bytes.
Let's restore the code that was there before commit b8c06ad4d67d ("vringh: implement vringh_kiov_advance()"), avoiding using vringh_kiov_advance().
--- drivers/vhost/vringh.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/vhost/vringh.c +11 -1
@@ -123,8 +123,18 @@ static inline ssize_t vringh_iov_xfer(st done += partlen; len -= partlen; ptr += partlen; + iov->consumed += partlen; + iov->iov[iov->i].iov_len -= partlen; + iov->iov[iov->i].iov_base += partlen; -vringh_kiov_advance (iov, partlen); +if (!iov->iov[iov->i].iov_len) { +/* Fix up old iov element then increment. */ + iov->iov[iov->i].iov_len = iov->consumed; + iov->iov[iov->i].iov_base -= iov->consumed; + + iov->consumed =0 ; + iov->i++; + } }return done; }
Greg Kroah-Hartman
maintainerPATCH 57/162 net: ethernet: mediatek: disable irq before schedule napi
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Marangi <[email protected]>
commit fcdfc462881d8acf9db77f483b2c821e286ca97b upstream.
While searching for possible refactor of napi_schedule_prep and __napi_schedule it was notice that the mtk eth driver disable the interrupt for rx and tx AFTER napi is scheduled.
While this is a very hard to repro case it might happen to have situation where the interrupt is disabled and never enabled again as the napi completes and the interrupt is enabled before.
This is caused by the fact that a napi driven by interrupt expect a logic with:
1. interrupt received. napi prepared -> interrupt disabled -> napi scheduled
2. napi triggered. ring cleared -> interrupt enabled -> wait for new interrupt
To prevent this case, disable the interrupt BEFORE the napi is scheduled.
--- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/mediatek/mtk_eth_soc.c +2 -2
@@ -2862,8 +2862,8 @@ static irqreturn_t mtk_handle_irq_rx(int eth->rx_events++;if (likely (napi_schedule_prep (ð->rx_napi))) { -__napi_schedule (ð->rx_napi);mtk_rx_irq_disable (eth, eth->soc->txrx.rx_irq_done_mask); +__napi_schedule (ð->rx_napi); }return IRQ_HANDLED ;
@@ -2875,8 +2875,8 @@ static irqreturn_t mtk_handle_irq_tx(int eth->tx_events++;if (likely (napi_schedule_prep (ð->tx_napi))) { -__napi_schedule (ð->tx_napi);mtk_tx_irq_disable (eth,MTK_TX_DONE_INT ); +__napi_schedule (ð->tx_napi); }return IRQ_HANDLED ;
Greg Kroah-Hartman
maintainerPATCH 58/162 mptcp: userspace pm allow creating id 0 subflow
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geliang Tang <[email protected]>
commit e5ed101a602873d65d2d64edaba93e8c73ec1b0f upstream.
This patch drops id 0 limitation in mptcp_nl_cmd_sf_create() to allow creating additional subflows with the local addr ID 0.
There is no reason not to allow additional subflows from this local
address: we should be able to create new subflows from the initial endpoint. This limitation was breaking fullmesh support from userspace.
--- net/mptcp/pm_userspace.c | 6 ------ 1 file changed, 6 deletions(-)
net/mptcp/pm_userspace.c +0 -6
@@ -309,12 +309,6 @@ int mptcp_nl_cmd_sf_create(struct sk_buf goto create_err; } -if (addr_l.id ==0 ) { -NL_SET_ERR_MSG_ATTR (info->extack, laddr,"missing local addr id" ); - err = -EINVAL ; - goto create_err; - } - err =mptcp_pm_parse_addr (raddr, info, &addr_r);if (err <0 ) {NL_SET_ERR_MSG_ATTR (info->extack, raddr,"error parsing remote addr" );
Greg Kroah-Hartman
maintainerPATCH 59/162 qed/red_ll2: Fix undefined behavior bug in struct qed_ll2_info
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gustavo A. R. Silva <[email protected]>
commit eea03d18af9c44235865a4bc9bec4d780ef6cf21 upstream.
The flexible structure (a structure that contains a flexible-array member at the end) qed_ll2_tx_packet is nested within the second layer of struct qed_ll2_info:
struct qed_ll2_tx_packet {
...
/* Flexible Array of bds_set determined by max_bds_per_packet */
struct {
struct core_tx_bd *txq_bd;
dma_addr_t tx_frag;
u16 frag_len;
} bds_set[];
};struct qed_ll2_tx_queue {
...
struct qed_ll2_tx_packet cur_completing_packet;
};struct qed_ll2_info {
...
struct qed_ll2_tx_queue tx_queue;
struct qed_ll2_cbs cbs;
};The problem is that member cbs in struct qed_ll2_info is placed just after an object of type struct qed_ll2_tx_queue, which is in itself an implicit flexible structure, which by definition ends in a flexible array member, in this case bds_set. This causes an undefined behavior bug at run-time when dynamic memory is allocated for bds_set, which could lead to a serious issue if cbs in struct qed_ll2_info is overwritten by the contents of bds_set. Notice that the type of cbs is a structure full of function pointers (and a cookie :) ):
include/linux/qed/qed_ll2_if.h:
107 typedef
108 void (*qed_ll2_complete_rx_packet_cb)(void *cxt,
109 struct qed_ll2_comp_rx_data *data);
110
111 typedef
112 void (*qed_ll2_release_rx_packet_cb)(void *cxt,
113 u8 connection_handle, 114 void *cookie, 115 dma_addr_t rx_buf_addr, 116 bool b_last_packet); 117 118 typedef 119 void (*qed_ll2_complete_tx_packet_cb)(void *cxt, 120 u8 connection_handle, 121 void *cookie, 122 dma_addr_t first_frag_addr, 123 bool b_last_fragment, 124 bool b_last_packet); 125 126 typedef 127 void (*qed_ll2_release_tx_packet_cb)(void *cxt, 128 u8 connection_handle, 129 void *cookie, 130 dma_addr_t first_frag_addr, 131 bool b_last_fragment, bool b_last_packet);
132
133 typedef
134 void (*qed_ll2_slowpath_cb)(void *cxt, u8 connection_handle,
135 u32 opaque_data_0, u32 opaque_data_1);
136
137 struct qed_ll2_cbs {
138 qed_ll2_complete_rx_packet_cb rx_comp_cb; 139 qed_ll2_release_rx_packet_cb rx_release_cb; 140 qed_ll2_complete_tx_packet_cb tx_comp_cb; 141 qed_ll2_release_tx_packet_cb tx_release_cb; 142 qed_ll2_slowpath_cb slowpath_cb; 143 void *cookie;
144 };
Fix this by moving the declaration of cbs to the middle of its containing structure qed_ll2_info, preventing it from being overwritten by the contents of bds_set at run-time.
This bug was introduced in 2017, when bds_set was converted to a one-element array, and started to be used as a Variable Length Object (VLO) at run-time.
--- drivers/net/ethernet/qlogic/qed/qed_ll2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/qlogic/qed/qed_ll2.h +1 -1
@@ -110,9 +110,9 @@ struct qed_ll2_info {enum core_tx_dest tx_dest;u8 tx_stats_en;bool main_func_queue; +struct qed_ll2_cbs cbs;struct qed_ll2_rx_queue rx_queue;struct qed_ll2_tx_queue tx_queue; -struct qed_ll2_cbs cbs; };extern const struct qed_ll2_ops qed_ll2_ops_pass;
Greg Kroah-Hartman
maintainerPATCH 60/162 Bluetooth: hci_codec: Fix leaking content of local_codecs
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
commit b938790e70540bf4f2e653dcd74b232494d06c8f upstream.
The following memory leak can be observed when the controller supports codecs which are stored in local_codecs list but the elements are never freed:
unreferenced object 0xffff88800221d840 (size 32):
comm "kworker/u3:0", pid 36, jiffies 4294898739 (age 127.060s) hex dump (first 32 bytes):
f8 d3 02 03 80 88 ff ff 80 d8 21 02 80 88 ff ff ..........!.....
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<ffffffffb324f557>] __kmalloc+0x47/0x120
[<ffffffffb39ef37d>] hci_codec_list_add.isra.0+0x2d/0x160
[<ffffffffb39ef643>] hci_read_codec_capabilities+0x183/0x270
[<ffffffffb39ef9ab>] hci_read_supported_codecs+0x1bb/0x2d0
[<ffffffffb39f162e>] hci_read_local_codecs_sync+0x3e/0x60
[<ffffffffb39ff1b3>] hci_dev_open_sync+0x943/0x11e0
[<ffffffffb396d55d>] hci_power_on+0x10d/0x3f0
[<ffffffffb30c99b4>] process_one_work+0x404/0x800
[<ffffffffb30ca134>] worker_thread+0x374/0x670
[<ffffffffb30d9108>] kthread+0x188/0x1c0
[<ffffffffb304db6b>] ret_from_fork+0x2b/0x50
[<ffffffffb300206a>] ret_from_fork_asm+0x1a/0x30--- net/bluetooth/hci_core.c | 1 + net/bluetooth/hci_event.c | 1 + net/bluetooth/hci_sync.c | 1 + 3 files changed, 3 insertions(+)
net/bluetooth/hci_core.c +1 -0
@@ -2783,6 +2783,7 @@ void hci_release_dev(struct hci_dev *hdehci_conn_params_clear_all (hdev);hci_discovery_filter_clear (hdev);hci_blocked_keys_clear (hdev); +hci_codec_list_clear (&hdev->local_codecs);hci_dev_unlock (hdev);ida_simple_remove (&hci_index_ida, hdev->id);
net/bluetooth/hci_event.c +1 -0
@@ -32,6 +32,7 @@#include "hci_request.h" #include "hci_debugfs.h" +#include "hci_codec.h" #include "a2mp.h" #include "amp.h" #include "smp.h"
net/bluetooth/hci_sync.c +1 -0
@@ -5033,6 +5033,7 @@ int hci_dev_close_sync(struct hci_dev *hmemset (hdev->eir,0 ,sizeof (hdev->eir));memset (hdev->dev_class,0 ,sizeof (hdev->dev_class));bacpy (&hdev->random_addr,BDADDR_ANY ); +hci_codec_list_clear (&hdev->local_codecs);hci_dev_put (hdev);return err;
Greg Kroah-Hartman
maintainerPATCH 61/162 Bluetooth: hci_sync: Fix handling of HCI_QUIRK_STRICT_DUPLICATE_FILTER
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
commit 941c998b42f5c90384f49da89a6e11233de567cf upstream.
When HCI_QUIRK_STRICT_DUPLICATE_FILTER is set LE scanning requires periodic restarts of the scanning procedure as the controller would consider device previously found as duplicated despite of RSSI changes, but in order to set the scan timeout properly set le_scan_restart needs to be synchronous so it shall not use hci_cmd_sync_queue which defers the command processing to cmd_sync_work.
--- net/bluetooth/hci_sync.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
net/bluetooth/hci_sync.c +4 -9
@@ -412,11 +412,6 @@ static int hci_le_scan_restart_sync(stru LE_SCAN_FILTER_DUP_ENABLE); } -static int le_scan_restart_sync (struct hci_dev *hdev,void *data) -{ -return hci_le_scan_restart_sync (hdev); -} -static void le_scan_restart (struct work_struct *work) { struct hci_dev *hdev = container_of(work, struct hci_dev,
@@ -426,15 +421,15 @@ static void le_scan_restart(struct work_bt_dev_dbg (hdev,"" ); -hci_dev_lock (hdev); - - status =hci_cmd_sync_queue (hdev, le_scan_restart_sync,NULL ,NULL ); + status =hci_le_scan_restart_sync (hdev);if (status) {bt_dev_err (hdev,"failed to restart LE scan: status %d" , status); - goto unlock; +return ; } +hci_dev_lock (hdev); +if (!test_bit (HCI_QUIRK_STRICT_DUPLICATE_FILTER , &hdev->quirks) || !hdev->discovery.scan_start) goto unlock;
Greg Kroah-Hartman
maintainerPATCH 62/162 wifi: mwifiex: Fix tlv_buf_left calculation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gustavo A. R. Silva <[email protected]>
commit eec679e4ac5f47507774956fb3479c206e761af7 upstream.
In a TLV encoding scheme, the Length part represents the length after the header containing the values for type and length. In this case, tlv_len should be:
tlv_len == (sizeof(*tlv_rxba) - 1) - sizeof(tlv_rxba->header) + tlv_bitmap_len
Notice that the - 1 accounts for the one-element array bitmap, which 1-byte size is already included in sizeof(*tlv_rxba).
So, if the above is correct, there is a double-counting of some members in struct mwifiex_ie_types_rxba_sync, when tlv_buf_left and tmp are calculated:
968 tlv_buf_left -= (sizeof(*tlv_rxba) + tlv_len);
969 tmp = (u8 *)tlv_rxba + tlv_len + sizeof(*tlv_rxba);
in specific, members:
drivers/net/wireless/marvell/mwifiex/fw.h:777
777 u8 mac[ETH_ALEN]; 778 u8 tid; 779 u8 reserved; 780 __le16 seq_num; 781 __le16 bitmap_len;
This is clearly wrong, and affects the subsequent decoding of data in event_buf through tlv_rxba:
970 tlv_rxba = (struct mwifiex_ie_types_rxba_sync *)tmp;
Fix this by using sizeof(tlv_rxba->header) instead of sizeof(*tlv_rxba) in the calculation of tlv_buf_left and tmp.
This results in the following binary differences before/after changes:
| drivers/net/wireless/marvell/mwifiex/11n_rxreorder.o | @@ -4698,11 +4698,11 @@ | drivers/net/wireless/marvell/mwifiex/11n_rxreorder.c:968 | tlv_buf_left -= (sizeof(tlv_rxba->header) + tlv_len); | - 1da7: lea -0x11(%rbx),%edx | + 1da7: lea -0x4(%rbx),%edx | 1daa: movzwl %bp,%eax | drivers/net/wireless/marvell/mwifiex/11n_rxreorder.c:969 | tmp = (u8 *)tlv_rxba + sizeof(tlv_rxba->header) + tlv_len; | - 1dad: lea 0x11(%r15,%rbp,1),%r15 | + 1dad: lea 0x4(%r15,%rbp,1),%r15
The above reflects the desired change: avoid counting 13 too many bytes; which is the total size of the double-counted members in struct mwifiex_ie_types_rxba_sync:
$ pahole -C mwifiex_ie_types_rxba_sync drivers/net/wireless/marvell/mwifiex/11n_rxreorder.o
struct mwifiex_ie_types_rxba_sync {
struct mwifiex_ie_types_header header; /* 0 4 */ |-----------------------------------------------------------------------
| u8 mac[6]; /* 4 6 */ |
| u8 tid; /* 10 1 */ |
| u8 reserved; /* 11 1 */ |
| __le16 seq_num; /* 12 2 */ |
| __le16 bitmap_len; /* 14 2 */ |
| u8 bitmap[1]; /* 16 1 */ |
|----------------------------------------------------------------------|
| 13 bytes|
-----------
/* size: 17, cachelines: 1, members: 7 */
/* last cacheline: 17 bytes */
} __attribute__((__packed__));--- drivers/net/wireless/marvell/mwifiex/11n_rxreorder.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/marvell/mwifiex/11n_rxreorder.c +2 -2
@@ -965,8 +965,8 @@ void mwifiex_11n_rxba_sync_event(struct } } - tlv_buf_left -= (sizeof (*tlv_rxba) + tlv_len); - tmp = (u8 *)tlv_rxba + tlv_len +sizeof (*tlv_rxba); + tlv_buf_left -= (sizeof (tlv_rxba->header) + tlv_len); + tmp = (u8 *)tlv_rxba +sizeof (tlv_rxba->header) + tlv_len; tlv_rxba = (struct mwifiex_ie_types_rxba_sync *)tmp; } }
Greg Kroah-Hartman
maintainerPATCH 45/162 iommu/arm-smmu-v3: Avoid constructing invalid range commands
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Robin Murphy <[email protected]>
[ Upstream commit eb6c97647be227822c7ce23655482b05e348fba5 ]
Although io-pgtable's non-leaf invalidations are always for full tables, I missed that SVA also uses non-leaf invalidations, while being at the mercy of whatever range the MMU notifier throws at it. This means it definitely wants the previous TTL fix as well, since it also doesn't know exactly which leaf level(s) may need invalidating, but it can also give us less-aligned ranges wherein certain corners may lead to building an invalid command where TTL, Num and Scale are all 0. It should be fine to handle this by over-invalidating an extra page, since falling back to a non-range command opens up a whole can of errata-flavoured worms.
--- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +10 -5
@@ -1886,18 +1886,23 @@ static void __arm_smmu_tlb_inv_range(struct arm_smmu_cmdq_ent *cmd,/* Get the leaf page size */ tg =__ffs (smmu_domain->domain.pgsize_bitmap); + num_pages = size >> tg; +/* Convert page size of 12,14,16 (log2) to 1,2,3 */ cmd->tlbi.tg = (tg -10 ) /2 ;/* -* Determine what level the granule is at. For non-leaf, io-pgtable -* assumes .tlb_flush_walk can invalidate multiple levels at once, -* so ignore the nominal last-level granule and leave TTL=0. +* Determine what level the granule is at. For non-leaf, both +* io-pgtable and SVA pass a nominal last-level granule because +* they don't know what level(s) actually apply, so ignore that +* and leave TTL=0. However for various errata reasons we still +* want to use a range command, so avoid the SVA corner case +* where both scale and num could be 0 as well. */ if (cmd->tlbi.leaf) cmd->tlbi.ttl =4 - ((ilog2 (granule) -3 ) / (tg -3 )); - - num_pages = size >> tg; +else if ((num_pages &CMDQ_TLBI_RANGE_NUM_MAX ) ==1 ) + num_pages++; } cmds.num =0 ;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 63/162 md/raid5: release batch_last before waiting for another stripe_head
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Jeffery <[email protected]>
commit 2fd7b0f6d5ad655b1d947d3acdd82f687c31465e upstream.
When raid5_get_active_stripe is called with a ctx containing a stripe_head in its batch_last pointer, it can cause a deadlock if the task sleeps waiting on another stripe_head to become available. The stripe_head held by batch_last can be blocking the advancement of other stripe_heads, leading to no stripe_heads being released so raid5_get_active_stripe waits forever.
Like with the quiesce state handling earlier in the function, batch_last needs to be released by raid5_get_active_stripe before it waits for another stripe_head.
--- drivers/md/raid5.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/md/raid5.c +7 -0
@@ -854,6 +854,13 @@ struct stripe_head *raid5_get_active_strset_bit (R5_INACTIVE_BLOCKED , &conf->cache_state);r5l_wake_reclaim (conf->log,0 ); + +/* release batch_last before wait to avoid risk of deadlock */ +if (ctx && ctx->batch_last) { +raid5_release_stripe (ctx->batch_last); + ctx->batch_last =NULL ; + } +wait_event_lock_irq (conf->wait_for_stripe,is_inactive_blocked (conf, hash), *(conf->hash_locks + hash));
Greg Kroah-Hartman
maintainerPATCH 64/162 PCI: qcom: Fix IPQ8074 enumeration
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sricharan Ramabadhran <[email protected]>
commit 6a878a54d0053ef21f3b829dc267487c2302b012 upstream.
PARF_SLV_ADDR_SPACE_SIZE_2_3_3 is used by qcom_pcie_post_init_2_3_3(). This PCIe slave address space size register offset is 0x358 but was incorrectly changed to 0x16c by 39171b33f652 ("PCI: qcom: Remove PCIE20_ prefix from register definitions").
This prevented access to slave address space registers like iATU, etc., so the IPQ8074 PCIe controller was not enumerated.
Revert back to the correct 0x358 offset and remove the unused PARF_SLV_ADDR_SPACE_SIZE_2_3_3.
--- drivers/pci/controller/dwc/pcie-qcom.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/pci/controller/dwc/pcie-qcom.c +1 -3
@@ -40,7 +40,6 @@#define PARF_PHY_REFCLK 0x4c#define PARF_CONFIG_BITS 0x50#define PARF_DBI_BASE_ADDR 0x168 -#define PARF_SLV_ADDR_SPACE_SIZE_2_3_3 0x16c/* Register offset specific to IP ver 2.3.3 */ #define PARF_MHI_CLOCK_RESET_CTRL 0x174#define PARF_AXI_MSTR_WR_ADDR_HALT 0x178#define PARF_AXI_MSTR_WR_ADDR_HALT_V2 0x1a8
@@ -1148,8 +1147,7 @@ static int qcom_pcie_post_init_2_3_3(stru16 offset =dw_pcie_find_capability (pci,PCI_CAP_ID_EXP );u32 val; -writel (SLV_ADDR_SPACE_SZ , - pcie->parf +PARF_SLV_ADDR_SPACE_SIZE_2_3_3 ); +writel (SLV_ADDR_SPACE_SZ , pcie->parf +PARF_SLV_ADDR_SPACE_SIZE ); val =readl (pcie->parf +PARF_PHY_CTRL ); val &= ~BIT (0 );
Greg Kroah-Hartman
maintainerPATCH 65/162 net: replace calls to sock->ops->connect() with kernel_connect()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jordan Rife <[email protected]>
commit 26297b4ce1ce4ea40bc9a48ec99f45da3f64d2e2 upstream.
commit 0bdf399342c5 ("net: Avoid address overwrite in kernel_connect") ensured that kernel_connect() will not overwrite the address parameter in cases where BPF connect hooks perform an address rewrite. This change replaces direct calls to sock->ops->connect() in net with kernel_connect() to make these call safe.
--- net/netfilter/ipvs/ip_vs_sync.c | 4 ++-- net/rds/tcp_connect.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
net/netfilter/ipvs/ip_vs_sync.c +2 -2
@@ -1507,8 +1507,8 @@ static int make_send_sock(struct netns_i }get_mcast_sockaddr (&mcast_addr, &salen, &ipvs->mcfg, id); - result = sock->ops->connect (sock, (struct sockaddr *) &mcast_addr, - salen,0 ); + result =kernel_connect (sock, (struct sockaddr *)&mcast_addr, + salen,0 );if (result <0 ) {pr_err ("Error connecting to the multicast addr\n" ); goto error;
net/rds/tcp_connect.c +1 -1
@@ -173,7 +173,7 @@ int rds_tcp_conn_path_connect(struct rds* own the socket */ rds_tcp_set_callbacks (sock, cp); - ret = sock->ops->connect (sock, addr, addrlen,O_NONBLOCK ); + ret =kernel_connect (sock, addr, addrlen,O_NONBLOCK );rdsdebug ("connect to address %pI6c returned %d\n" , &conn->c_faddr, ret);if (ret == -EINPROGRESS )
Greg Kroah-Hartman
maintainerPATCH 66/162 btrfs: reject unknown mount options early
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
commit 5f521494cc73520ffac18ede0758883b9aedd018 upstream.
[BUG]
The following script would allow invalid mount options to be specified (although such invalid options would just be ignored):
# mkfs.btrfs -f $dev # mount $dev $mnt1 <<< Successful mount expected # mount $dev $mnt2 -o junk <<< Failed mount expected # echo $? 0
[CAUSE]
For the 2nd mount, since the fs is already mounted, we won't go through open_ctree() thus no btrfs_parse_options(), but only through btrfs_parse_subvol_options().
However we do not treat unrecognized options from valid but irrelevant options, thus those invalid options would just be ignored by btrfs_parse_subvol_options().
[FIX]
Add the handling for Opt_err to handle invalid options and error out, while still ignore other valid options inside btrfs_parse_subvol_options().
--- fs/btrfs/super.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/btrfs/super.c +4 -0
@@ -1260,6 +1260,10 @@ static int btrfs_parse_subvol_options(co *subvol_objectid = subvolid;break ; +case Opt_err: +btrfs_err (NULL ,"unrecognized mount option '%s'" , p); + error = -EINVAL ; + goto out;default :break ; }
Greg Kroah-Hartman
maintainerPATCH 67/162 net: prevent rewrite of msg_name in sock_sendmsg()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jordan Rife <[email protected]>
commit 86a7e0b69bd5b812e48a20c66c2161744f3caa16 upstream.
Callers of sock_sendmsg(), and similarly kernel_sendmsg(), in kernel space may observe their value of msg_name change in cases where BPF sendmsg hooks rewrite the send address. This has been confirmed to break NFS mounts running in UDP mode and has the potential to break other systems.
This patch:
1) Creates a new function called __sock_sendmsg() with same logic as the old sock_sendmsg() function.
2) Replaces calls to sock_sendmsg() made by __sys_sendto() and __sys_sendmsg() with __sock_sendmsg() to avoid an unnecessary copy, as these system calls are already protected.
3) Modifies sock_sendmsg() so that it makes a copy of msg_name if present before passing it down the stack to insulate callers from changes to the send address.
--- net/socket.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-)
net/socket.c +23 -6
@@ -720,6 +720,14 @@ static inline int sock_sendmsg_nosec(strreturn ret; } +static int __sock_sendmsg (struct socket *sock,struct msghdr *msg) +{ +int err =security_socket_sendmsg (sock, msg, +msg_data_left (msg)); + +return err ?:sock_sendmsg_nosec (sock, msg); +} +/** * sock_sendmsg - send a message through @sock * @sock: socket
@@ -730,10 +738,19 @@ static inline int sock_sendmsg_nosec(str*/ int sock_sendmsg (struct socket *sock,struct msghdr *msg) { -int err =security_socket_sendmsg (sock, msg, -msg_data_left (msg)); +struct sockaddr_storage *save_addr = (struct sockaddr_storage *)msg->msg_name; +struct sockaddr_storage address; +int ret; -return err ?:sock_sendmsg_nosec (sock, msg); +if (msg->msg_name) { +memcpy (&address, msg->msg_name, msg->msg_namelen); + msg->msg_name = &address; + } + + ret =__sock_sendmsg (sock, msg); + msg->msg_name = save_addr; + +return ret; }EXPORT_SYMBOL (sock_sendmsg);
@@ -1110,7 +1127,7 @@ static ssize_t sock_write_iter(struct kiif (sock->type ==SOCK_SEQPACKET ) msg.msg_flags |=MSG_EOR ; - res =sock_sendmsg (sock, &msg); + res =__sock_sendmsg (sock, &msg); *from = msg.msg_iter;return res; }
@@ -2114,7 +2131,7 @@ int __sys_sendto(int fd, void __user *buif (sock->file->f_flags &O_NONBLOCK ) flags |=MSG_DONTWAIT ; msg.msg_flags = flags; - err =sock_sendmsg (sock, &msg); + err =__sock_sendmsg (sock, &msg); out_put:fput_light (sock->file, fput_needed);
@@ -2479,7 +2496,7 @@ static int ____sys_sendmsg(struct socket err =sock_sendmsg_nosec (sock, msg_sys); goto out_freectl; } - err =sock_sendmsg (sock, msg_sys); + err =__sock_sendmsg (sock, msg_sys);/* * If this is sendmmsg() and sending to current destination address was * successful, remember it.
Greg Kroah-Hartman
maintainerPATCH 68/162 drm/amd: Fix detection of _PR3 on the PCIe root port
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mario Limonciello <[email protected]>
commit 134b8c5d8674e7cde380f82e9aedfd46dcdd16f7 upstream.
On some systems with Navi3x dGPU will attempt to use BACO for runtime PM but fails to resume properly. This is because on these systems the root port goes into D3cold which is incompatible with BACO.
This happens because in this case dGPU is connected to a bridge between root port which causes BOCO detection logic to fail. Fix the intent of the logic by looking at root port, not the immediate upstream bridge for _PR3.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
@@ -2179,7 +2179,7 @@ static int amdgpu_device_ip_early_init(s adev->flags |=AMD_IS_PX ;if (!(adev->flags &AMD_IS_APU )) { - parent =pci_upstream_bridge (adev->pdev); + parent =pcie_find_root_port (adev->pdev); adev->has_pr3 = parent ?pci_pr3_present (parent) : false; }
Greg Kroah-Hartman
maintainerPATCH 69/162 drm/amd: Fix logic error in sienna_cichlid_update_pcie_parameters()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mario Limonciello <[email protected]>
commit 2a1fe39a5be785e962e387146aed34fa9a829f3f upstream.
While aligning SMU11 with SMU13 implementation an assumption was made that dpm_context->dpm_tables.pcie_table was populated in dpm table initialization like in SMU13 but it isn't.
So restore some of the original logic and instead just check for amdgpu_device_pcie_dynamic_switching_supported() to decide whether to hardcode values; erring on the side of performance.
--- drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c | 41 ++++++++-------- 1 file changed, 23 insertions(+), 18 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +23 -18
@@ -2081,36 +2081,41 @@ static int sienna_cichlid_display_disablreturn ret; } +#define MAX (a, b) ((a) > (b) ? (a) : (b)) +static int sienna_cichlid_update_pcie_parameters (struct smu_context *smu,uint32_t pcie_gen_cap,uint32_t pcie_width_cap) {struct smu_11_0_dpm_context *dpm_context = smu->smu_dpm.dpm_context;struct smu_11_0_pcie_table *pcie_table = &dpm_context->dpm_tables.pcie_table; -u32 smu_pcie_arg; +uint8_t *table_member1, *table_member2; +uint32_t min_gen_speed, max_gen_speed; +uint32_t min_lane_width, max_lane_width; +uint32_t smu_pcie_arg;int ret, i; -/* PCIE gen speed and lane width override */ -if (!amdgpu_device_pcie_dynamic_switching_supported ()) { -if (pcie_table->pcie_gen[NUM_LINK_LEVELS -1 ] < pcie_gen_cap) - pcie_gen_cap = pcie_table->pcie_gen[NUM_LINK_LEVELS -1 ]; +GET_PPTABLE_MEMBER (PcieGenSpeed, &table_member1); +GET_PPTABLE_MEMBER (PcieLaneCount, &table_member2); -if (pcie_table->pcie_lane[NUM_LINK_LEVELS -1 ] < pcie_width_cap) - pcie_width_cap = pcie_table->pcie_lane[NUM_LINK_LEVELS -1 ]; + min_gen_speed =MAX (0 , table_member1[0 ]); + max_gen_speed =MIN (pcie_gen_cap, table_member1[1 ]); + min_gen_speed = min_gen_speed > max_gen_speed ? + max_gen_speed : min_gen_speed; + min_lane_width =MAX (1 , table_member2[0 ]); + max_lane_width =MIN (pcie_width_cap, table_member2[1 ]); + min_lane_width = min_lane_width > max_lane_width ? + max_lane_width : min_lane_width; -/* Force all levels to use the same settings */ -for (i =0 ; i <NUM_LINK_LEVELS ; i++) { - pcie_table->pcie_gen[i] = pcie_gen_cap; - pcie_table->pcie_lane[i] = pcie_width_cap; - } +if (!amdgpu_device_pcie_dynamic_switching_supported ()) { + pcie_table->pcie_gen[0 ] = max_gen_speed; + pcie_table->pcie_lane[0 ] = max_lane_width; }else { -for (i =0 ; i <NUM_LINK_LEVELS ; i++) { -if (pcie_table->pcie_gen[i] > pcie_gen_cap) - pcie_table->pcie_gen[i] = pcie_gen_cap; -if (pcie_table->pcie_lane[i] > pcie_width_cap) - pcie_table->pcie_lane[i] = pcie_width_cap; - } + pcie_table->pcie_gen[0 ] = min_gen_speed; + pcie_table->pcie_lane[0 ] = min_lane_width; } + pcie_table->pcie_gen[1 ] = max_gen_speed; + pcie_table->pcie_lane[1 ] = max_lane_width;for (i =0 ; i <NUM_LINK_LEVELS ; i++) { smu_pcie_arg = (i << 16 |
Greg Kroah-Hartman
maintainerPATCH 70/162 arm64: Add Cortex-A520 CPU part definition
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rob Herring <[email protected]>
commit a654a69b9f9c06b2e56387d0b99f0e3e6b0ff4ef upstream.
Add the CPU Part number for the new Arm design.
--- arch/arm64/include/asm/cputype.h | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/include/asm/cputype.h +2 -0
@@ -79,6 +79,7 @@#define ARM_CPU_PART_CORTEX_A78AE 0xD42#define ARM_CPU_PART_CORTEX_X1 0xD44#define ARM_CPU_PART_CORTEX_A510 0xD46 +#define ARM_CPU_PART_CORTEX_A520 0xD80#define ARM_CPU_PART_CORTEX_A710 0xD47#define ARM_CPU_PART_CORTEX_X2 0xD48#define ARM_CPU_PART_NEOVERSE_N2 0xD49
@@ -141,6 +142,7 @@#define MIDR_CORTEX_A78AE MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A78AE)#define MIDR_CORTEX_X1 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_X1)#define MIDR_CORTEX_A510 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A510) +#define MIDR_CORTEX_A520 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A520)#define MIDR_CORTEX_A710 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A710)#define MIDR_CORTEX_X2 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_X2)#define MIDR_NEOVERSE_N2 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_NEOVERSE_N2)
Greg Kroah-Hartman
maintainerPATCH 71/162 arm64: errata: Add Cortex-A520 speculative unprivileged load workaround
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rob Herring <[email protected]>
commit 471470bc7052d28ce125901877dd10e4c048e513 upstream.
Implement the workaround for ARM Cortex-A520 erratum 2966298. On an affected Cortex-A520 core, a speculatively executed unprivileged load might leak data from a privileged load via a cache side channel. The issue only exists for loads within a translation regime with the same translation (e.g. same ASID and VMID). Therefore, the issue only affects the return to EL0.
The workaround is to execute a TLBI before returning to EL0 after all loads of privileged data. A non-shareable TLBI to any address is sufficient.
The workaround isn't necessary if page table isolation (KPTI) is enabled, but for simplicity it will be. Page table isolation should normally be disabled for Cortex-A520 as it supports the CSV3 feature and the E0PD feature (used when KASLR is enabled).
--- Documentation/arm64/silicon-errata.rst | 2 ++ arch/arm64/Kconfig | 13 +++++++++++++ arch/arm64/kernel/cpu_errata.c | 8 ++++++++ arch/arm64/kernel/entry.S | 4 ++++ arch/arm64/tools/cpucaps | 1 + 5 files changed, 28 insertions(+)
Documentation/arm64/silicon-errata.rst +2 -0
@@ -63,6 +63,8 @@ stable kernels. +----------------+-----------------+-----------------+-----------------------------+ | ARM | Cortex-A510 | #1902691 | ARM64_ERRATUM_1902691 | +----------------+-----------------+-----------------+-----------------------------+ +| ARM | Cortex-A520 | #2966298 | ARM64_ERRATUM_2966298 | ++----------------+-----------------+-----------------+-----------------------------+ | ARM | Cortex-A53 | #826319 | ARM64_ERRATUM_826319 | +----------------+-----------------+-----------------+-----------------------------+ | ARM | Cortex-A53 | #827319 | ARM64_ERRATUM_827319 |
arch/arm64/Kconfig +13 -0
@@ -983,6 +983,19 @@ config ARM64_ERRATUM_2457168 If unsure, say Y. +config ARM64_ERRATUM_2966298 + bool "Cortex-A520: 2966298: workaround for speculatively executed unprivileged load" + default y + help + This option adds the workaround for ARM Cortex-A520 erratum 2966298. + + On an affected Cortex-A520 core, a speculatively executed unprivileged + load might leak data from a privileged level via a cache side channel. + + Work around this problem by executing a TLBI before returning to EL0. + + If unsure, say Y. + config CAVIUM_ERRATUM_22375 bool "Cavium erratum 22375, 24313" default y
arch/arm64/kernel/cpu_errata.c +8 -0
@@ -723,6 +723,14 @@ const struct arm64_cpu_capabilities arm6 .cpu_enable = cpu_clear_bf16_from_user_emulation, },#endif +#ifdef CONFIG_ARM64_ERRATUM_2966298 + { + .desc = "ARM erratum 2966298", + .capability = ARM64_WORKAROUND_2966298, + /* Cortex-A520 r0p0 - r0p1 */ + ERRATA_MIDR_REV_RANGE(MIDR_CORTEX_A520, 0, 0, 1), + }, +#endif #ifdef CONFIG_AMPERE_ERRATUM_AC03_CPU_38 { .desc = "AmpereOne erratum AC03_CPU_38",
arch/arm64/kernel/entry.S +4 -0
@@ -419,6 +419,10 @@ alternative_else_nop_endif ldp x28, x29, [sp, #16 * 14] .if \el == 0 +alternative_if ARM64_WORKAROUND_2966298 + tlbi vale1, xzr + dsb nsh +alternative_else_nop_endif alternative_if_not ARM64_UNMAP_KERNEL_AT_EL0 ldr lr, [sp, #S_LR] add sp, sp, #PT_REGS_SIZE // restore sp
arch/arm64/tools/cpucaps +1 -0
@@ -71,6 +71,7 @@ WORKAROUND_2064142 WORKAROUND_2077057 WORKAROUND_2457168 WORKAROUND_2658417 +WORKAROUND_2966298 WORKAROUND_AMPERE_AC03_CPU_38 WORKAROUND_TRBE_OVERWRITE_FILL_MODE WORKAROUND_TSB_FLUSH_FAILURE
Greg Kroah-Hartman
maintainerPATCH 46/162 rbd: move rbd_dev_refresh() definition
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Dryomov <[email protected]>
commit 0b035401c57021fc6c300272cbb1c5a889d4fe45 upstream.
Move rbd_dev_refresh() definition further down to avoid having to move struct parent_image_info definition in the next commit. This spares some forward declarations too.
--- drivers/block/rbd.c | 68 ++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 35 deletions(-)
drivers/block/rbd.c +33 -35
@@ -633,8 +633,6 @@ static void rbd_dev_remove_parent(struct rbd_device *rbd_dev);static int rbd_dev_refresh (struct rbd_device *rbd_dev);static int rbd_dev_v2_header_onetime (struct rbd_device *rbd_dev); -static int rbd_dev_header_info (struct rbd_device *rbd_dev); -static int rbd_dev_v2_parent_info (struct rbd_device *rbd_dev);static const char *rbd_dev_v2_snap_name (struct rbd_device *rbd_dev,u64 snap_id); static int _rbd_dev_v2_snap_size(struct rbd_device *rbd_dev, u64 snap_id,
@@ -4932,39 +4930,6 @@ static void rbd_dev_update_size(struct rbd_device *rbd_dev) } } -static int rbd_dev_refresh (struct rbd_device *rbd_dev) -{ -u64 mapping_size; -int ret; - -down_write (&rbd_dev->header_rwsem); - mapping_size = rbd_dev->mapping.size; - - ret =rbd_dev_header_info (rbd_dev); -if (ret) - goto out; - -/* -* If there is a parent, see if it has disappeared due to the -* mapped image getting flattened. -*/ -if (rbd_dev->parent) { - ret =rbd_dev_v2_parent_info (rbd_dev); -if (ret) - goto out; - } - -rbd_assert (!rbd_is_snap (rbd_dev)); - rbd_dev->mapping.size = rbd_dev->header.image_size; - -out: -up_write (&rbd_dev->header_rwsem); -if (!ret && mapping_size != rbd_dev->mapping.size) -rbd_dev_update_size (rbd_dev); - -return ret; -} -static const struct blk_mq_ops rbd_mq_ops = { .queue_rq = rbd_queue_rq, };
@@ -7044,6 +7009,39 @@ static int rbd_dev_image_probe(struct rbd_device *rbd_dev, int depth)return ret; } +static int rbd_dev_refresh (struct rbd_device *rbd_dev) +{ +u64 mapping_size; +int ret; + +down_write (&rbd_dev->header_rwsem); + mapping_size = rbd_dev->mapping.size; + + ret =rbd_dev_header_info (rbd_dev); +if (ret) + goto out; + +/* +* If there is a parent, see if it has disappeared due to the +* mapped image getting flattened. +*/ +if (rbd_dev->parent) { + ret =rbd_dev_v2_parent_info (rbd_dev); +if (ret) + goto out; + } + +rbd_assert (!rbd_is_snap (rbd_dev)); + rbd_dev->mapping.size = rbd_dev->header.image_size; + +out: +up_write (&rbd_dev->header_rwsem); +if (!ret && mapping_size != rbd_dev->mapping.size) +rbd_dev_update_size (rbd_dev); + +return ret; +} +static ssize_t do_rbd_add (struct bus_type *bus,const char *buf,size_t count)
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 47/162 rbd: decouple header read-in from updating rbd_dev->header
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Dryomov <[email protected]>
commit 510a7330c82a7754d5df0117a8589e8a539067c7 upstream.
Make rbd_dev_header_info() populate a passed struct rbd_image_header instead of rbd_dev->header and introduce rbd_dev_update_header() for updating mutable fields in rbd_dev->header upon refresh. The initial read-in of both mutable and immutable fields in rbd_dev_image_probe() passes in rbd_dev->header so no update step is required there.
rbd_init_layout() is now called directly from rbd_dev_image_probe() instead of individually in format 1 and format 2 implementations.
--- drivers/block/rbd.c | 206 ++++++++++++++++++++++++-------------------- 1 file changed, 114 insertions(+), 92 deletions(-)
drivers/block/rbd.c +114 -92
@@ -632,7 +632,8 @@ void rbd_warn(struct rbd_device *rbd_dev, const char *fmt, ...)static void rbd_dev_remove_parent (struct rbd_device *rbd_dev);static int rbd_dev_refresh (struct rbd_device *rbd_dev); -static int rbd_dev_v2_header_onetime (struct rbd_device *rbd_dev); +static int rbd_dev_v2_header_onetime (struct rbd_device *rbd_dev, +struct rbd_image_header *header);static const char *rbd_dev_v2_snap_name (struct rbd_device *rbd_dev,u64 snap_id); static int _rbd_dev_v2_snap_size(struct rbd_device *rbd_dev, u64 snap_id,
@@ -993,15 +994,24 @@ static void rbd_init_layout(struct rbd_device *rbd_dev)RCU_INIT_POINTER (rbd_dev->layout.pool_ns,NULL ); } +static void rbd_image_header_cleanup (struct rbd_image_header *header) +{ +kfree (header->object_prefix); +ceph_put_snap_context (header->snapc); +kfree (header->snap_sizes); +kfree (header->snap_names); + +memset (header,0 ,sizeof (*header)); +} +/* * Fill an rbd image header with information from the given format 1 * on-disk header. */ -static int rbd_header_from_disk (struct rbd_device *rbd_dev, -struct rbd_image_header_ondisk *ondisk) +static int rbd_header_from_disk (struct rbd_image_header *header, +struct rbd_image_header_ondisk *ondisk, +bool first_time) { -struct rbd_image_header *header = &rbd_dev->header; -bool first_time = header->object_prefix ==NULL ;struct ceph_snap_context *snapc;char *object_prefix =NULL ;char *snap_names =NULL ;
@@ -1068,11 +1078,6 @@ static int rbd_header_from_disk(struct rbd_device *rbd_dev,if (first_time) { header->object_prefix = object_prefix; header->obj_order = ondisk->options.order; -rbd_init_layout (rbd_dev); - }else { -ceph_put_snap_context (header->snapc); -kfree (header->snap_names); -kfree (header->snap_sizes); }/* The remaining fields always get updated (when we refresh) */
@@ -4858,7 +4863,9 @@ static int rbd_obj_read_sync(struct rbd_device *rbd_dev,* return, the rbd_dev->header field will contain up-to-date * information about the image. */ -static int rbd_dev_v1_header_info (struct rbd_device *rbd_dev) +static int rbd_dev_v1_header_info (struct rbd_device *rbd_dev, +struct rbd_image_header *header, +bool first_time) {struct rbd_image_header_ondisk *ondisk =NULL ;u32 snap_count =0 ;
@@ -4906,7 +4913,7 @@ static int rbd_dev_v1_header_info(struct rbd_device *rbd_dev) snap_count =le32_to_cpu (ondisk->snap_count); }while (snap_count != want_count); - ret =rbd_header_from_disk (rbd_dev, ondisk); + ret =rbd_header_from_disk (header, ondisk, first_time); out:kfree (ondisk);
@@ -5469,17 +5476,12 @@ static int _rbd_dev_v2_snap_size(struct rbd_device *rbd_dev, u64 snap_id,return 0 ; } -static int rbd_dev_v2_image_size (struct rbd_device *rbd_dev) -{ -return _rbd_dev_v2_snap_size (rbd_dev,CEPH_NOSNAP , - &rbd_dev->header.obj_order, - &rbd_dev->header.image_size); -} - -static int rbd_dev_v2_object_prefix (struct rbd_device *rbd_dev) +static int rbd_dev_v2_object_prefix (struct rbd_device *rbd_dev, +char **pobject_prefix) {size_t size;void *reply_buf; +char *object_prefix;int ret;void *p;
@@ -5497,16 +5499,16 @@ static int rbd_dev_v2_object_prefix(struct rbd_device *rbd_dev) goto out; p = reply_buf; - rbd_dev->header.object_prefix =ceph_extract_encoded_string (&p, - p + ret,NULL ,GFP_NOIO ); + object_prefix =ceph_extract_encoded_string (&p, p + ret,NULL , +GFP_NOIO ); +if (IS_ERR (object_prefix)) { + ret =PTR_ERR (object_prefix); + goto out; + } ret =0 ; -if (IS_ERR (rbd_dev->header.object_prefix)) { - ret =PTR_ERR (rbd_dev->header.object_prefix); - rbd_dev->header.object_prefix =NULL ; - }else { -dout (" object_prefix = %s\n" , rbd_dev->header.object_prefix); - } + *pobject_prefix = object_prefix; +dout (" object_prefix = %s\n" , object_prefix); out:kfree (reply_buf);
@@ -5557,13 +5559,6 @@ static int _rbd_dev_v2_snap_features(struct rbd_device *rbd_dev, u64 snap_id,return 0 ; } -static int rbd_dev_v2_features (struct rbd_device *rbd_dev) -{ -return _rbd_dev_v2_snap_features (rbd_dev,CEPH_NOSNAP , -rbd_is_ro (rbd_dev), - &rbd_dev->header.features); -} -/* * These are generic image flags, but since they are used only for * object map, store them in rbd_dev->object_map_flags.
@@ -5838,14 +5833,14 @@ static int rbd_dev_v2_parent_info(struct rbd_device *rbd_dev)return ret; } -static int rbd_dev_v2_striping_info (struct rbd_device *rbd_dev) +static int rbd_dev_v2_striping_info (struct rbd_device *rbd_dev, +u64 *stripe_unit,u64 *stripe_count) {struct {__le64 stripe_unit;__le64 stripe_count; } __attribute__ ((packed)) striping_info_buf = {0 };size_t size =sizeof (striping_info_buf); -void *p;int ret; ret = rbd_obj_method_sync(rbd_dev, &rbd_dev->header_oid,
@@ -5857,27 +5852,33 @@ static int rbd_dev_v2_striping_info(struct rbd_device *rbd_dev)if (ret < size)return -ERANGE ; - p = &striping_info_buf; - rbd_dev->header.stripe_unit =ceph_decode_64 (&p); - rbd_dev->header.stripe_count =ceph_decode_64 (&p); + *stripe_unit =le64_to_cpu (striping_info_buf.stripe_unit); + *stripe_count =le64_to_cpu (striping_info_buf.stripe_count); +dout (" stripe_unit = %llu stripe_count = %llu\n" , *stripe_unit, + *stripe_count); +return 0 ; } -static int rbd_dev_v2_data_pool (struct rbd_device *rbd_dev) +static int rbd_dev_v2_data_pool (struct rbd_device *rbd_dev,s64 *data_pool_id) { -__le64 data_pool_id; +__le64 data_pool_buf;int ret; ret =rbd_obj_method_sync (rbd_dev, &rbd_dev->header_oid, &rbd_dev->header_oloc,"get_data_pool" , -NULL ,0 , &data_pool_id,sizeof (data_pool_id)); +NULL ,0 , &data_pool_buf, +sizeof (data_pool_buf)); +dout ("%s: rbd_obj_method_sync returned %d\n" , __func__, ret);if (ret <0 )return ret; -if (ret <sizeof (data_pool_id)) +if (ret <sizeof (data_pool_buf))return -EBADMSG ; - rbd_dev->header.data_pool_id =le64_to_cpu (data_pool_id); -WARN_ON (rbd_dev->header.data_pool_id ==CEPH_NOPOOL ); + *data_pool_id =le64_to_cpu (data_pool_buf); +dout (" data_pool_id = %lld\n" , *data_pool_id); +WARN_ON (*data_pool_id ==CEPH_NOPOOL ); +return 0 ; }
@@ -6069,7 +6070,8 @@ static int rbd_spec_fill_names(struct rbd_device *rbd_dev)return ret; } -static int rbd_dev_v2_snap_context (struct rbd_device *rbd_dev) +static int rbd_dev_v2_snap_context (struct rbd_device *rbd_dev, +struct ceph_snap_context **psnapc) {size_t size;int ret;
@@ -6130,9 +6132,7 @@ static int rbd_dev_v2_snap_context(struct rbd_device *rbd_dev)for (i =0 ; i < snap_count; i++) snapc->snaps[i] =ceph_decode_64 (&p); -ceph_put_snap_context (rbd_dev->header.snapc); - rbd_dev->header.snapc = snapc; - + *psnapc = snapc;dout (" snap context seq = %llu, snap_count = %u\n" , (unsigned long long )seq, (unsigned int )snap_count); out:
@@ -6181,38 +6181,42 @@ static const char *rbd_dev_v2_snap_name(struct rbd_device *rbd_dev,return snap_name; } -static int rbd_dev_v2_header_info (struct rbd_device *rbd_dev) +static int rbd_dev_v2_header_info (struct rbd_device *rbd_dev, +struct rbd_image_header *header, +bool first_time) { -bool first_time = rbd_dev->header.object_prefix ==NULL ;int ret; - ret =rbd_dev_v2_image_size (rbd_dev); + ret =_rbd_dev_v2_snap_size (rbd_dev,CEPH_NOSNAP , + first_time ? &header->obj_order :NULL , + &header->image_size);if (ret)return ret;if (first_time) { - ret =rbd_dev_v2_header_onetime (rbd_dev); + ret =rbd_dev_v2_header_onetime (rbd_dev, header);if (ret)return ret; } - ret =rbd_dev_v2_snap_context (rbd_dev); -if (ret && first_time) { -kfree (rbd_dev->header.object_prefix); - rbd_dev->header.object_prefix =NULL ; - } + ret =rbd_dev_v2_snap_context (rbd_dev, &header->snapc); +if (ret) +return ret; -return ret; +return 0 ; } -static int rbd_dev_header_info (struct rbd_device *rbd_dev) +static int rbd_dev_header_info (struct rbd_device *rbd_dev, +struct rbd_image_header *header, +bool first_time) {rbd_assert (rbd_image_format_valid (rbd_dev->image_format)); +rbd_assert (!header->object_prefix && !header->snapc);if (rbd_dev->image_format ==1 ) -return rbd_dev_v1_header_info (rbd_dev); +return rbd_dev_v1_header_info (rbd_dev, header, first_time); -return rbd_dev_v2_header_info (rbd_dev); +return rbd_dev_v2_header_info (rbd_dev, header, first_time); }/*
@@ -6700,60 +6704,49 @@ static int rbd_dev_image_id(struct rbd_device *rbd_dev)*/ static void rbd_dev_unprobe (struct rbd_device *rbd_dev) { -struct rbd_image_header *header; -rbd_dev_parent_put (rbd_dev);rbd_object_map_free (rbd_dev);rbd_dev_mapping_clear (rbd_dev);/* Free dynamic fields from the header, then zero it out */ - header = &rbd_dev->header; -ceph_put_snap_context (header->snapc); -kfree (header->snap_sizes); -kfree (header->snap_names); -kfree (header->object_prefix); -memset (header,0 ,sizeof (*header)); +rbd_image_header_cleanup (&rbd_dev->header); } -static int rbd_dev_v2_header_onetime (struct rbd_device *rbd_dev) +static int rbd_dev_v2_header_onetime (struct rbd_device *rbd_dev, +struct rbd_image_header *header) {int ret; - ret =rbd_dev_v2_object_prefix (rbd_dev); + ret =rbd_dev_v2_object_prefix (rbd_dev, &header->object_prefix);if (ret) - goto out_err; +return ret;/* * Get the and check features for the image. Currently the * features are assumed to never change. */ - ret =rbd_dev_v2_features (rbd_dev); + ret =_rbd_dev_v2_snap_features (rbd_dev,CEPH_NOSNAP , +rbd_is_ro (rbd_dev), &header->features);if (ret) - goto out_err; +return ret;/* If the image supports fancy striping, get its parameters */ -if (rbd_dev->header.features &RBD_FEATURE_STRIPINGV2 ) { - ret =rbd_dev_v2_striping_info (rbd_dev); -if (ret <0 ) - goto out_err; +if (header->features &RBD_FEATURE_STRIPINGV2 ) { + ret =rbd_dev_v2_striping_info (rbd_dev, &header->stripe_unit, + &header->stripe_count); +if (ret) +return ret; } -if (rbd_dev->header.features &RBD_FEATURE_DATA_POOL ) { - ret =rbd_dev_v2_data_pool (rbd_dev); +if (header->features &RBD_FEATURE_DATA_POOL ) { + ret =rbd_dev_v2_data_pool (rbd_dev, &header->data_pool_id);if (ret) - goto out_err; +return ret; } -rbd_init_layout (rbd_dev);return 0 ; - -out_err: - rbd_dev->header.features =0 ; -kfree (rbd_dev->header.object_prefix); - rbd_dev->header.object_prefix =NULL ; -return ret; }/*
@@ -6948,13 +6941,15 @@ static int rbd_dev_image_probe(struct rbd_device *rbd_dev, int depth)if (!depth)down_write (&rbd_dev->header_rwsem); - ret =rbd_dev_header_info (rbd_dev); + ret =rbd_dev_header_info (rbd_dev, &rbd_dev->header, true);if (ret) {if (ret == -ENOENT && !need_watch)rbd_print_dne (rbd_dev, false); goto err_out_probe; } +rbd_init_layout (rbd_dev); +/* * If this image is the one being mapped, we have pool name and * id, image name and id, and snap name - need to fill snap id.
@@ -7009,15 +7004,39 @@ static int rbd_dev_image_probe(struct rbd_device *rbd_dev, int depth)return ret; } +static void rbd_dev_update_header (struct rbd_device *rbd_dev, +struct rbd_image_header *header) +{ +rbd_assert (rbd_image_format_valid (rbd_dev->image_format)); +rbd_assert (rbd_dev->header.object_prefix);/* !first_time */ + + rbd_dev->header.image_size = header->image_size; + +ceph_put_snap_context (rbd_dev->header.snapc); + rbd_dev->header.snapc = header->snapc; + header->snapc =NULL ; + +if (rbd_dev->image_format ==1 ) { +kfree (rbd_dev->header.snap_names); + rbd_dev->header.snap_names = header->snap_names; + header->snap_names =NULL ; + +kfree (rbd_dev->header.snap_sizes); + rbd_dev->header.snap_sizes = header->snap_sizes; + header->snap_sizes =NULL ; + } +} +static int rbd_dev_refresh (struct rbd_device *rbd_dev) { +struct rbd_image_header header = {0 };u64 mapping_size;int ret;down_write (&rbd_dev->header_rwsem); mapping_size = rbd_dev->mapping.size; - ret =rbd_dev_header_info (rbd_dev); + ret =rbd_dev_header_info (rbd_dev, &header, false);if (ret) goto out;
@@ -7031,6 +7050,8 @@ static int rbd_dev_refresh(struct rbd_device *rbd_dev) goto out; } +rbd_dev_update_header (rbd_dev, &header); +rbd_assert (!rbd_is_snap (rbd_dev)); rbd_dev->mapping.size = rbd_dev->header.image_size;
@@ -7039,6 +7060,7 @@ static int rbd_dev_refresh(struct rbd_device *rbd_dev)if (!ret && mapping_size != rbd_dev->mapping.size)rbd_dev_update_size (rbd_dev); +rbd_image_header_cleanup (&header);return ret; }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 48/162 rbd: decouple parent info read-in from updating rbd_dev
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Dryomov <[email protected]>
commit c10311776f0a8ddea2276df96e255625b07045a8 upstream.
Unlike header read-in, parent info read-in is already decoupled in get_parent_info(), but it's buried in rbd_dev_v2_parent_info() along with the processing logic.
Separate the initial read-in and update read-in logic into rbd_dev_setup_parent() and rbd_dev_update_parent() respectively and have rbd_dev_v2_parent_info() just populate struct parent_image_info (i.e. what get_parent_info() did). Some existing QoI issues, like flatten of a standalone clone being disregarded on refresh, remain.
--- drivers/block/rbd.c | 142 +++++++++++++++++++++++++------------------- 1 file changed, 80 insertions(+), 62 deletions(-)
drivers/block/rbd.c +80 -62
@@ -5595,6 +5595,14 @@ struct parent_image_info {u64 overlap; }; +static void rbd_parent_info_cleanup (struct parent_image_info *pii) +{ +kfree (pii->pool_ns); +kfree (pii->image_id); + +memset (pii,0 ,sizeof (*pii)); +} +/* * The caller is responsible for @pii. */
@@ -5664,6 +5672,9 @@ static int __get_parent_info(struct rbd_device *rbd_dev,if (pii->has_overlap)ceph_decode_64_safe (&p, end, pii->overlap, e_inval); +dout ("%s pool_id %llu pool_ns %s image_id %s snap_id %llu has_overlap %d overlap %llu\n" , + __func__, pii->pool_id, pii->pool_ns, pii->image_id, pii->snap_id, + pii->has_overlap, pii->overlap);return 0 ; e_inval:
@@ -5702,14 +5713,17 @@ static int __get_parent_info_legacy(struct rbd_device *rbd_dev, pii->has_overlap = true;ceph_decode_64_safe (&p, end, pii->overlap, e_inval); +dout ("%s pool_id %llu pool_ns %s image_id %s snap_id %llu has_overlap %d overlap %llu\n" , + __func__, pii->pool_id, pii->pool_ns, pii->image_id, pii->snap_id, + pii->has_overlap, pii->overlap);return 0 ; e_inval:return -EINVAL ; } -static int get_parent_info (struct rbd_device *rbd_dev, -struct parent_image_info *pii) +static int rbd_dev_v2_parent_info (struct rbd_device *rbd_dev, +struct parent_image_info *pii) {struct page *req_page, *reply_page;void *p;
@@ -5737,7 +5751,7 @@ static int get_parent_info(struct rbd_device *rbd_dev,return ret; } -static int rbd_dev_v2_parent_info (struct rbd_device *rbd_dev) +static int rbd_dev_setup_parent (struct rbd_device *rbd_dev) {struct rbd_spec *parent_spec;struct parent_image_info pii = {0 };
@@ -5747,37 +5761,12 @@ static int rbd_dev_v2_parent_info(struct rbd_device *rbd_dev)if (!parent_spec)return -ENOMEM ; - ret =get_parent_info (rbd_dev, &pii); + ret =rbd_dev_v2_parent_info (rbd_dev, &pii);if (ret) goto out_err; -dout ("%s pool_id %llu pool_ns %s image_id %s snap_id %llu has_overlap %d overlap %llu\n" , - __func__, pii.pool_id, pii.pool_ns, pii.image_id, pii.snap_id, - pii.has_overlap, pii.overlap); - -if (pii.pool_id ==CEPH_NOPOOL || !pii.has_overlap) { -/* -* Either the parent never existed, or we have -* record of it but the image got flattened so it no -* longer has a parent. When the parent of a -* layered image disappears we immediately set the -* overlap to 0. The effect of this is that all new -* requests will be treated as if the image had no -* parent. -* -* If !pii.has_overlap, the parent image spec is not -* applicable. It's there to avoid duplication in each -* snapshot record. -*/ -if (rbd_dev->parent_overlap) { - rbd_dev->parent_overlap =0 ; -rbd_dev_parent_put (rbd_dev); -pr_info ("%s: clone image has been flattened\n" , - rbd_dev->disk->disk_name); - } - +if (pii.pool_id ==CEPH_NOPOOL || !pii.has_overlap) goto out;/* No parent? No problem. */ - }/* The ceph file layout needs to fit pool id in 32 bits */
@@ -5789,46 +5778,34 @@ static int rbd_dev_v2_parent_info(struct rbd_device *rbd_dev) }/* -* The parent won't change (except when the clone is -* flattened, already handled that). So we only need to -* record the parent spec we have not already done so. +* The parent won't change except when the clone is flattened, +* so we only need to record the parent image spec once. */ -if (!rbd_dev->parent_spec) { - parent_spec->pool_id = pii.pool_id; -if (pii.pool_ns && *pii.pool_ns) { - parent_spec->pool_ns = pii.pool_ns; - pii.pool_ns =NULL ; - } - parent_spec->image_id = pii.image_id; - pii.image_id =NULL ; - parent_spec->snap_id = pii.snap_id; - - rbd_dev->parent_spec = parent_spec; - parent_spec =NULL ;/* rbd_dev now owns this */ + parent_spec->pool_id = pii.pool_id; +if (pii.pool_ns && *pii.pool_ns) { + parent_spec->pool_ns = pii.pool_ns; + pii.pool_ns =NULL ; } + parent_spec->image_id = pii.image_id; + pii.image_id =NULL ; + parent_spec->snap_id = pii.snap_id; + +rbd_assert (!rbd_dev->parent_spec); + rbd_dev->parent_spec = parent_spec; + parent_spec =NULL ;/* rbd_dev now owns this */ /* -* We always update the parent overlap. If it's zero we issue -* a warning, as we will proceed as if there was no parent. +* Record the parent overlap. If it's zero, issue a warning as +* we will proceed as if there is no parent. */ -if (!pii.overlap) { -if (parent_spec) { -/* refresh, careful to warn just once */ -if (rbd_dev->parent_overlap) -rbd_warn (rbd_dev, -"clone now standalone (overlap became 0)" ); - }else { -/* initial probe */ -rbd_warn (rbd_dev,"clone is standalone (overlap 0)" ); - } - } +if (!pii.overlap) +rbd_warn (rbd_dev,"clone is standalone (overlap 0)" ); rbd_dev->parent_overlap = pii.overlap; out: ret =0 ; out_err: -kfree (pii.pool_ns); -kfree (pii.image_id); +rbd_parent_info_cleanup (&pii);rbd_spec_put (parent_spec);return ret; }
@@ -6978,7 +6955,7 @@ static int rbd_dev_image_probe(struct rbd_device *rbd_dev, int depth) }if (rbd_dev->header.features &RBD_FEATURE_LAYERING ) { - ret =rbd_dev_v2_parent_info (rbd_dev); + ret =rbd_dev_setup_parent (rbd_dev);if (ret) goto err_out_probe; }
@@ -7027,9 +7004,47 @@ static void rbd_dev_update_header(struct rbd_device *rbd_dev, } } +static void rbd_dev_update_parent (struct rbd_device *rbd_dev, +struct parent_image_info *pii) +{ +if (pii->pool_id ==CEPH_NOPOOL || !pii->has_overlap) { +/* +* Either the parent never existed, or we have +* record of it but the image got flattened so it no +* longer has a parent. When the parent of a +* layered image disappears we immediately set the +* overlap to 0. The effect of this is that all new +* requests will be treated as if the image had no +* parent. +* +* If !pii.has_overlap, the parent image spec is not +* applicable. It's there to avoid duplication in each +* snapshot record. +*/ +if (rbd_dev->parent_overlap) { + rbd_dev->parent_overlap =0 ; +rbd_dev_parent_put (rbd_dev); +pr_info ("%s: clone has been flattened\n" , + rbd_dev->disk->disk_name); + } + }else { +rbd_assert (rbd_dev->parent_spec); + +/* +* Update the parent overlap. If it became zero, issue +* a warning as we will proceed as if there is no parent. +*/ +if (!pii->overlap && rbd_dev->parent_overlap) +rbd_warn (rbd_dev, +"clone has become standalone (overlap 0)" ); + rbd_dev->parent_overlap = pii->overlap; + } +} +static int rbd_dev_refresh (struct rbd_device *rbd_dev) {struct rbd_image_header header = {0 }; +struct parent_image_info pii = {0 };u64 mapping_size;int ret;
@@ -7045,12 +7060,14 @@ static int rbd_dev_refresh(struct rbd_device *rbd_dev)* mapped image getting flattened. */ if (rbd_dev->parent) { - ret =rbd_dev_v2_parent_info (rbd_dev); + ret =rbd_dev_v2_parent_info (rbd_dev, &pii);if (ret) goto out; }rbd_dev_update_header (rbd_dev, &header); +if (rbd_dev->parent) +rbd_dev_update_parent (rbd_dev, &pii);rbd_assert (!rbd_is_snap (rbd_dev)); rbd_dev->mapping.size = rbd_dev->header.image_size;
@@ -7060,6 +7077,7 @@ static int rbd_dev_refresh(struct rbd_device *rbd_dev)if (!ret && mapping_size != rbd_dev->mapping.size)rbd_dev_update_size (rbd_dev); +rbd_parent_info_cleanup (&pii);rbd_image_header_cleanup (&header);return ret; }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 49/162 rbd: take header_rwsem in rbd_dev_refresh() only when updating
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Dryomov <[email protected]>
commit 0b207d02bd9ab8dcc31b262ca9f60dbc1822500d upstream.
rbd_dev_refresh() has been holding header_rwsem across header and parent info read-in unnecessarily for ages. With commit 870611e4877e ("rbd: get snapshot context after exclusive lock is ensured to be held"), the potential for deadlocks became much more real owning to
a) header_rwsem now nesting inside lock_rwsem and b) rw_semaphores not allowing new readers after a writer is registered.
For example, assuming that I/O request 1, I/O request 2 and header read-in request all target the same OSD:
1. I/O request 1 comes in and gets submitted
2. watch error occurs
3. rbd_watch_errcb() takes lock_rwsem for write, clears owner_cid and releases lock_rwsem
4. after reestablishing the watch, rbd_reregister_watch() calls rbd_dev_refresh() which takes header_rwsem for write and submits a header read-in request
5. I/O request 2 comes in: after taking lock_rwsem for read in __rbd_img_handle_request(), it blocks trying to take header_rwsem for read in rbd_img_object_requests()
6. another watch error occurs
7. rbd_watch_errcb() blocks trying to take lock_rwsem for write
8. I/O request 1 completion is received by the messenger but can't be processed because lock_rwsem won't be granted anymore
9. header read-in request completion can't be received, let alone processed, because the messenger is stranded
Change rbd_dev_refresh() to take header_rwsem only for actually updating rbd_dev->header. Header and parent info read-in don't need any locking.
--- drivers/block/rbd.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/block/rbd.c +11 -11
@@ -6987,7 +6987,14 @@ static void rbd_dev_update_header(struct rbd_device *rbd_dev,rbd_assert (rbd_image_format_valid (rbd_dev->image_format));rbd_assert (rbd_dev->header.object_prefix);/* !first_time */ - rbd_dev->header.image_size = header->image_size; +if (rbd_dev->header.image_size != header->image_size) { + rbd_dev->header.image_size = header->image_size; + +if (!rbd_is_snap (rbd_dev)) { + rbd_dev->mapping.size = header->image_size; +rbd_dev_update_size (rbd_dev); + } + }ceph_put_snap_context (rbd_dev->header.snapc); rbd_dev->header.snapc = header->snapc;
@@ -7045,11 +7052,9 @@ static int rbd_dev_refresh(struct rbd_device *rbd_dev) {struct rbd_image_header header = {0 };struct parent_image_info pii = {0 }; -u64 mapping_size;int ret; -down_write (&rbd_dev->header_rwsem); - mapping_size = rbd_dev->mapping.size; +dout ("%s rbd_dev %p\n" , __func__, rbd_dev); ret =rbd_dev_header_info (rbd_dev, &header, false);if (ret)
@@ -7065,18 +7070,13 @@ static int rbd_dev_refresh(struct rbd_device *rbd_dev) goto out; } +down_write (&rbd_dev->header_rwsem);rbd_dev_update_header (rbd_dev, &header);if (rbd_dev->parent)rbd_dev_update_parent (rbd_dev, &pii); - -rbd_assert (!rbd_is_snap (rbd_dev)); - rbd_dev->mapping.size = rbd_dev->header.image_size; - -out:up_write (&rbd_dev->header_rwsem); -if (!ret && mapping_size != rbd_dev->mapping.size) -rbd_dev_update_size (rbd_dev); +out:rbd_parent_info_cleanup (&pii);rbd_image_header_cleanup (&header);return ret;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 50/162 block: fix use-after-free of q->q_usage_counter
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Lei <[email protected]>
commit d36a9ea5e7766961e753ee38d4c331bbe6ef659b upstream.
For blk-mq, queue release handler is usually called after blk_mq_freeze_queue_wait() returns. However, the q_usage_counter->release() handler may not be run yet at that time, so this can cause a use-after-free.
Fix the issue by moving percpu_ref_exit() into blk_free_queue_rcu(). Since ->release() is called with rcu read lock held, it is agreed that the race should be covered in caller per discussion from the two links.
--- block/blk-sysfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
block/blk-sysfs.c +1 -2
@@ -737,6 +737,7 @@ static void blk_free_queue_rcu(struct rc struct request_queue *q = container_of(rcu_head, struct request_queue, rcu_head); +percpu_ref_exit (&q->q_usage_counter);kmem_cache_free (blk_get_queue_kmem_cache (blk_queue_has_srcu (q)), q); }
@@ -762,8 +763,6 @@ static void blk_release_queue(struct kobmight_sleep (); -percpu_ref_exit (&q->q_usage_counter); -if (q->poll_stat)blk_stat_remove_callback (q, q->poll_cb);blk_stat_free_callback (q->poll_cb);
Greg Kroah-Hartman
maintainerPATCH 51/162 hwmon: (nzxt-smart2) Add device id
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herman Fries <[email protected]>
commit e247510e1baad04e9b7b8ed7190dbb00989387b9 upstream.
Adding support for new device id
1e71:2019 NZXT NZXT RGB & Fan Controller
--- drivers/hwmon/nzxt-smart2.c | 1 + 1 file changed, 1 insertion(+)
drivers/hwmon/nzxt-smart2.c +1 -0
@@ -791,6 +791,7 @@ static const struct hid_device_id nzxt_s { HID_USB_DEVICE(0x1e71, 0x2009) }, /* NZXT RGB & Fan Controller */ { HID_USB_DEVICE(0x1e71, 0x200e) }, /* NZXT RGB & Fan Controller */ { HID_USB_DEVICE(0x1e71, 0x2010) }, /* NZXT RGB & Fan Controller */ + { HID_USB_DEVICE(0x1e71, 0x2019) }, /* NZXT RGB & Fan Controller */ {}, };
Greg Kroah-Hartman
maintainerPATCH 52/162 hwmon: (nzxt-smart2) add another USB ID
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aleksandr Mezin <[email protected]>
commit 4a148e9b1ee04e608263fa9536a96214d5561220 upstream.
This seems to be a new revision of the device. RGB controls have changed, but this driver doesn't touch them anyway.
Fan speed control reported to be working with existing userspace (hidraw) software, so I assume it's compatible. Fan channel count is the same.
Recently added (0x1e71, 0x2019) seems to be the same device.
Discovered in liquidctl project:
https://github.com/liquidctl/liquidctl/issues/541
--- drivers/hwmon/nzxt-smart2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/hwmon/nzxt-smart2.c +2 -1
@@ -791,7 +791,8 @@ static const struct hid_device_id nzxt_s { HID_USB_DEVICE(0x1e71, 0x2009) }, /* NZXT RGB & Fan Controller */ { HID_USB_DEVICE(0x1e71, 0x200e) }, /* NZXT RGB & Fan Controller */ { HID_USB_DEVICE(0x1e71, 0x2010) }, /* NZXT RGB & Fan Controller */ - { HID_USB_DEVICE(0x1e71, 0x2019) }, /* NZXT RGB & Fan Controller */ + { HID_USB_DEVICE(0x1e71, 0x2011) }, /* NZXT RGB & Fan Controller (6 RGB) */ + { HID_USB_DEVICE(0x1e71, 0x2019) }, /* NZXT RGB & Fan Controller (6 RGB) */ {}, };
Greg Kroah-Hartman
maintainerPATCH 43/162 drm/amd/display: Adjust the MST resume flow
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wayne Lin <[email protected]>
commit ec5fa9fcdeca69edf7dab5ca3b2e0ceb1c08fe9a upstream.
[Why]
In drm_dp_mst_topology_mgr_resume() today, it will resume the mst branch to be ready handling mst mode and also consecutively do the mst topology probing. Which will cause the dirver have chance to fire hotplug event before restoring the old state. Then Userspace will react to the hotplug event based on a wrong state.
[How]
Adjust the mst resume flow as:
1. set dpcd to resume mst branch status
2. restore source old state
3. Do mst resume topology probing
For drm_dp_mst_topology_mgr_resume(), it's better to adjust it to pull out topology probing work into a 2nd part procedure of the mst resume. Will have a follow up patch in drm.
[ Adjust for missing variable rename in
f0127cb11299 ("drm/amdgpu/display/mst: adjust the naming of mst_port and port of aconnector") ]
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 93 ++++++++++++++++++---- 1 file changed, 80 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +80 -13
@@ -2344,14 +2344,62 @@ static int dm_late_init(void *handle)return detect_mst_link_for_all_connectors (adev_to_drm (adev)); } +static void resume_mst_branch_status (struct drm_dp_mst_topology_mgr *mgr) +{ +int ret; +u8 guid[16 ]; +u64 tmp64; + +mutex_lock (&mgr->lock); +if (!mgr->mst_primary) + goto out_fail; + +if (drm_dp_read_dpcd_caps (mgr->aux, mgr->dpcd) <0 ) { +drm_dbg_kms (mgr->dev,"dpcd read failed - undocked during suspend?\n" ); + goto out_fail; + } + + ret =drm_dp_dpcd_writeb (mgr->aux,DP_MSTM_CTRL , +DP_MST_EN | +DP_UP_REQ_EN | +DP_UPSTREAM_IS_SRC ); +if (ret <0 ) { +drm_dbg_kms (mgr->dev,"mst write failed - undocked during suspend?\n" ); + goto out_fail; + } + +/* Some hubs forget their guids after they resume */ + ret =drm_dp_dpcd_read (mgr->aux,DP_GUID , guid,16 ); +if (ret !=16 ) { +drm_dbg_kms (mgr->dev,"dpcd read failed - undocked during suspend?\n" ); + goto out_fail; + } + +if (memchr_inv (guid,0 ,16 ) ==NULL ) { + tmp64 =get_jiffies_64 (); +memcpy (&guid[0 ], &tmp64,sizeof (u64)); +memcpy (&guid[8 ], &tmp64,sizeof (u64)); + + ret =drm_dp_dpcd_write (mgr->aux,DP_GUID , guid,16 ); + +if (ret !=16 ) { +drm_dbg_kms (mgr->dev,"check mstb guid failed - undocked during suspend?\n" ); + goto out_fail; + } + } + +memcpy (mgr->mst_primary->guid, guid,16 ); + +out_fail: +mutex_unlock (&mgr->lock); +} +static void s3_handle_mst (struct drm_device *dev,bool suspend) {struct amdgpu_dm_connector *aconnector;struct drm_connector *connector;struct drm_connector_list_iter iter;struct drm_dp_mst_topology_mgr *mgr; -int ret; -bool need_hotplug = false;drm_connector_list_iter_begin (dev, &iter);drm_for_each_connector_iter (connector, &iter) {
@@ -2373,18 +2421,15 @@ static void s3_handle_mst(struct drm_devif (!dp_is_lttpr_present (aconnector->dc_link))dc_link_aux_try_to_configure_timeout (aconnector->dc_link->ddc,LINK_AUX_DEFAULT_TIMEOUT_PERIOD ); - ret =drm_dp_mst_topology_mgr_resume (mgr, true); -if (ret <0 ) { -dm_helpers_dp_mst_stop_top_mgr (aconnector->dc_link->ctx, - aconnector->dc_link); - need_hotplug = true; - } +/* TODO: move resume_mst_branch_status() into drm mst resume again +* once topology probing work is pulled out from mst resume into mst +* resume 2nd step. mst resume 2nd step should be called after old +* state getting restored (i.e. drm_atomic_helper_resume()). +*/ +resume_mst_branch_status (mgr); } }drm_connector_list_iter_end (&iter); - -if (need_hotplug) -drm_kms_helper_hotplug_event (dev); }static int amdgpu_dm_smu_write_watermarks_table (struct amdgpu_device *adev)
@@ -2773,7 +2818,8 @@ static int dm_resume(void *handle)struct dm_atomic_state *dm_state =to_dm_atomic_state (dm->atomic_obj.state);enum dc_connection_type new_connection_type = dc_connection_none;struct dc_state *dc_state; -int i, r, j; +int i, r, j, ret; +bool need_hotplug = false;if (amdgpu_in_reset (adev)) { dc_state = dm->cached_dc_state;
@@ -2871,7 +2917,7 @@ static int dm_resume(void *handle)continue ;/* -* this is the case when traversing through already created +* this is the case when traversing through already created end sink * MST connectors, should be skipped */ if (aconnector && aconnector->mst_port)
@@ -2931,6 +2977,27 @@ static int dm_resume(void *handle) dm->cached_state =NULL ; +/* Do mst topology probing after resuming cached state*/ +drm_connector_list_iter_begin (ddev, &iter); +drm_for_each_connector_iter (connector, &iter) { + aconnector =to_amdgpu_dm_connector (connector); +if (aconnector->dc_link->type != dc_connection_mst_branch || + aconnector->mst_port) +continue ; + + ret =drm_dp_mst_topology_mgr_resume (&aconnector->mst_mgr, true); + +if (ret <0 ) { +dm_helpers_dp_mst_stop_top_mgr (aconnector->dc_link->ctx, + aconnector->dc_link); + need_hotplug = true; + } + } +drm_connector_list_iter_end (&iter); + +if (need_hotplug) +drm_kms_helper_hotplug_event (ddev); +amdgpu_dm_irq_resume_late (adev);amdgpu_dm_smu_write_watermarks_table (adev);
Greg Kroah-Hartman
maintainerPATCH 73/162 ubi: Refuse attaching if mtds erasesize is 0
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhihao Cheng <[email protected]>
[ Upstream commit 017c73a34a661a861712f7cc1393a123e5b2208c ]
There exists mtd devices with zero erasesize, which will trigger a divide-by-zero exception while attaching ubi device. Fix it by refusing attaching if mtd's erasesize is 0.
--- drivers/mtd/ubi/build.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/mtd/ubi/build.c +7 -0
@@ -893,6 +893,13 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,return -EINVAL ; } +/* UBI cannot work on flashes with zero erasesize. */ +if (!mtd->erasesize) { +pr_err ("ubi: refuse attaching mtd%d - zero erasesize flash is not supported\n" , + mtd->index); +return -EINVAL ; + } +if (ubi_num ==UBI_DEV_NUM_AUTO ) {/* Search for an empty slot in the @ubi_devices array */ for (ubi_num =0 ; ubi_num <UBI_MAX_DEVICES ; ubi_num++)
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 82/162 wifi: mwifiex: Fix oob check condition in mwifiex_process_rx_packet
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pin-yen Lin <[email protected]>
[ Upstream commit aef7a0300047e7b4707ea0411dc9597cba108fc8 ]
Only skip the code path trying to access the rfc1042 headers when the buffer is too small, so the driver can still process packets without rfc1042 headers.
--- drivers/net/wireless/marvell/mwifiex/sta_rx.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/net/wireless/marvell/mwifiex/sta_rx.c +9 -7
@@ -86,7 +86,8 @@ int mwifiex_process_rx_packet(struct mwifiex_private *priv, rx_pkt_len =le16_to_cpu (local_rx_pd->rx_pkt_length); rx_pkt_hdr = (void *)local_rx_pd + rx_pkt_off; -if (sizeof (*rx_pkt_hdr) + rx_pkt_off > skb->len) { +if (sizeof (rx_pkt_hdr->eth803_hdr) +sizeof (rfc1042_header) + + rx_pkt_off > skb->len) {mwifiex_dbg (priv->adapter,ERROR ,"wrong rx packet offset: len=%d, rx_pkt_off=%d\n" , skb->len, rx_pkt_off);
@@ -95,12 +96,13 @@ int mwifiex_process_rx_packet(struct mwifiex_private *priv,return -1 ; } -if ((!memcmp (&rx_pkt_hdr->rfc1042_hdr, bridge_tunnel_header, -sizeof (bridge_tunnel_header))) || - (!memcmp (&rx_pkt_hdr->rfc1042_hdr, rfc1042_header, -sizeof (rfc1042_header)) && -ntohs (rx_pkt_hdr->rfc1042_hdr.snap_type) !=ETH_P_AARP && -ntohs (rx_pkt_hdr->rfc1042_hdr.snap_type) !=ETH_P_IPX )) { +if (sizeof (*rx_pkt_hdr) + rx_pkt_off <= skb->len && + ((!memcmp (&rx_pkt_hdr->rfc1042_hdr, bridge_tunnel_header, +sizeof (bridge_tunnel_header))) || + (!memcmp (&rx_pkt_hdr->rfc1042_hdr, rfc1042_header, +sizeof (rfc1042_header)) && +ntohs (rx_pkt_hdr->rfc1042_hdr.snap_type) !=ETH_P_AARP && +ntohs (rx_pkt_hdr->rfc1042_hdr.snap_type) !=ETH_P_IPX ))) {/* * Replace the 803 header and rfc1042 header (llc/snap) with an * EthernetII header, keep the src/dst and snap_type
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 83/162 leds: Drop BUG_ON check for LED_COLOR_ID_MULTI
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Behún <[email protected]>
[ Upstream commit 9dc1664fab2246bc2c3e9bf2cf21518a857f9b5b ]
Commit c3f853184bed ("leds: Fix BUG_ON check for LED_COLOR_ID_MULTI that is always false") fixed a no-op BUG_ON. This turned out to cause a regression, since some in-tree device-tree files already use LED_COLOR_ID_MULTI.
Drop the BUG_ON altogether.
--- drivers/leds/led-core.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/leds/led-core.c +0 -4
@@ -424,10 +424,6 @@ int led_compose_name(struct device *dev, struct led_init_data *init_data,led_parse_fwnode_props (dev, fwnode, &props); -/* We want to label LEDs that can produce full range of colors -* as RGB, not multicolor */ -BUG_ON (props.color ==LED_COLOR_ID_MULTI ); -if (props.label) {/* * If init_data.devicename is NULL, then it indicates that
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 84/162 bpf: Fix tr dereferencing
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Hwang <[email protected]>
[ Upstream commit b724a6418f1f853bcb39c8923bf14a50c7bdbd07 ]
Fix 'tr' dereferencing bug when CONFIG_BPF_JIT is turned off.
When CONFIG_BPF_JIT is turned off, 'bpf_trampoline_get()' returns NULL, which is same as the cases when CONFIG_BPF_JIT is turned on.
--- include/linux/bpf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/bpf.h +1 -1
@@ -1065,7 +1065,7 @@ static inline int bpf_trampoline_unlink_prog(struct bpf_tramp_link *link,static inline struct bpf_trampoline *bpf_trampoline_get (u64 key,struct bpf_attach_target_info *tgt_info) { -return ERR_PTR (-EOPNOTSUPP ); +return NULL ; }static inline void bpf_trampoline_put (struct bpf_trampoline *tr) {}#define DEFINE_BPF_DISPATCHER (name)
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 85/162 regulator: mt6358: Drop *_SSHUB regulators
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen-Yu Tsai <[email protected]>
[ Upstream commit 04ba665248ed91576d326041108e5fc2ec2254eb ]
The *_SSHUB regulators are actually alternate configuration interfaces for their non *_SSHUB counterparts. They are not separate regulator outputs. These registers are intended for the companion processor to use to configure the power rails while the main processor is sleeping. They are not intended for the main operating system to use.
Since they are not real outputs they shouldn't be modeled separately. Remove them. Luckily no device tree actually uses them.
Stable-dep-of: 7e37c851374e ("regulator: mt6358: split ops for buck and linear range LDO regulators")
--- drivers/regulator/mt6358-regulator.c | 14 -------------- include/linux/regulator/mt6358-regulator.h | 4 ---- 2 files changed, 18 deletions(-)
drivers/regulator/mt6358-regulator.c +0 -14
@@ -505,9 +505,6 @@ static struct mt6358_regulator_info mt6358_regulators[] = {MT6358_BUCK ("buck_vcore" ,VCORE ,500000 ,1293750 ,6250 , buck_volt_range1,0x7f ,MT6358_BUCK_VCORE_DBG0 ,0x7f ,MT6358_VCORE_VGPU_ANA_CON0 ,1 ), -MT6358_BUCK ("buck_vcore_sshub" ,VCORE_SSHUB ,500000 ,1293750 ,6250 , - buck_volt_range1,0x7f ,MT6358_BUCK_VCORE_SSHUB_ELR0 ,0x7f , -MT6358_VCORE_VGPU_ANA_CON0 ,1 ),MT6358_BUCK ("buck_vpa" ,VPA ,500000 ,3650000 ,50000 , buck_volt_range3,0x3f ,MT6358_BUCK_VPA_DBG0 ,0x3f , MT6358_VPA_ANA_CON0, 3),
@@ -587,10 +584,6 @@ static struct mt6358_regulator_info mt6358_regulators[] = {MT6358_LDO1 ("ldo_vsram_others" ,VSRAM_OTHERS ,500000 ,1293750 ,6250 , buck_volt_range1,MT6358_LDO_VSRAM_OTHERS_DBG0 ,0x7f00 ,MT6358_LDO_VSRAM_CON2 ,0x7f ), -MT6358_LDO1 ("ldo_vsram_others_sshub" ,VSRAM_OTHERS_SSHUB ,500000 , -1293750 ,6250 , buck_volt_range1, -MT6358_LDO_VSRAM_OTHERS_SSHUB_CON1 ,0x7f , -MT6358_LDO_VSRAM_OTHERS_SSHUB_CON1 ,0x7f ),MT6358_LDO1 ("ldo_vsram_gpu" ,VSRAM_GPU ,500000 ,1293750 ,6250 , buck_volt_range1,MT6358_LDO_VSRAM_GPU_DBG0 ,0x7f00 , MT6358_LDO_VSRAM_CON3, 0x7f),
@@ -607,9 +600,6 @@ static struct mt6358_regulator_info mt6366_regulators[] = {MT6366_BUCK ("buck_vcore" ,VCORE ,500000 ,1293750 ,6250 , buck_volt_range1,0x7f ,MT6358_BUCK_VCORE_DBG0 ,0x7f ,MT6358_VCORE_VGPU_ANA_CON0 ,1 ), -MT6366_BUCK ("buck_vcore_sshub" ,VCORE_SSHUB ,500000 ,1293750 ,6250 , - buck_volt_range1,0x7f ,MT6358_BUCK_VCORE_SSHUB_ELR0 ,0x7f , -MT6358_VCORE_VGPU_ANA_CON0 ,1 ),MT6366_BUCK ("buck_vpa" ,VPA ,500000 ,3650000 ,50000 , buck_volt_range3,0x3f ,MT6358_BUCK_VPA_DBG0 ,0x3f , MT6358_VPA_ANA_CON0, 3),
@@ -678,10 +668,6 @@ static struct mt6358_regulator_info mt6366_regulators[] = {MT6366_LDO1 ("ldo_vsram_others" ,VSRAM_OTHERS ,500000 ,1293750 ,6250 , buck_volt_range1,MT6358_LDO_VSRAM_OTHERS_DBG0 ,0x7f00 ,MT6358_LDO_VSRAM_CON2 ,0x7f ), -MT6366_LDO1 ("ldo_vsram_others_sshub" ,VSRAM_OTHERS_SSHUB ,500000 , -1293750 ,6250 , buck_volt_range1, -MT6358_LDO_VSRAM_OTHERS_SSHUB_CON1 ,0x7f , -MT6358_LDO_VSRAM_OTHERS_SSHUB_CON1 ,0x7f ),MT6366_LDO1 ("ldo_vsram_gpu" ,VSRAM_GPU ,500000 ,1293750 ,6250 , buck_volt_range1,MT6358_LDO_VSRAM_GPU_DBG0 ,0x7f00 , MT6358_LDO_VSRAM_CON3, 0x7f),
include/linux/regulator/mt6358-regulator.h +0 -4
@@ -48,8 +48,6 @@ enum {MT6358_ID_VLDO28 ,MT6358_ID_VAUD28 ,MT6358_ID_VSIM2 , -MT6358_ID_VCORE_SSHUB , -MT6358_ID_VSRAM_OTHERS_SSHUB , MT6358_ID_RG_MAX, };
@@ -90,8 +88,6 @@ enum {MT6366_ID_VMC ,MT6366_ID_VAUD28 ,MT6366_ID_VSIM2 , -MT6366_ID_VCORE_SSHUB , -MT6366_ID_VSRAM_OTHERS_SSHUB , MT6366_ID_RG_MAX, };
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 86/162 regulator: mt6358: Use linear voltage helpers for single range regulators
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen-Yu Tsai <[email protected]>
[ Upstream commit ea861df772fd8cca715d43f62fe13c09c975f7a2 ]
Some of the regulators on the MT6358/MT6366 PMICs have just one linear voltage range. These are the bulk regulators and VSRAM_* LDOs. Currently they are modeled with one linear range, but also have their minimum, maximum, and step voltage described.
Convert them to the linear voltage helpers. These helpers are a bit simpler, and we can also drop the linear range definitions. Also reflow the touched lines now that they are shorter.
Stable-dep-of: 7e37c851374e ("regulator: mt6358: split ops for buck and linear range LDO regulators")
--- drivers/regulator/mt6358-regulator.c | 121 +++++++++------------------ 1 file changed, 40 insertions(+), 81 deletions(-)
drivers/regulator/mt6358-regulator.c +40 -81
@@ -35,7 +35,7 @@ struct mt6358_regulator_info { };#define MT6358_BUCK (match, vreg, min, max, step, \ - volt_ranges, vosel_mask, _da_vsel_reg, _da_vsel_mask, \ + vosel_mask, _da_vsel_reg, _da_vsel_mask, \ _modeset_reg, _modeset_shift) \ [MT6358_ID_##vreg] = { \ .desc = { \
@@ -46,8 +46,8 @@ struct mt6358_regulator_info { .id = MT6358_ID_##vreg, \ .owner = THIS_MODULE, \ .n_voltages = ((max) - (min)) / (step) + 1, \ - .linear_ranges = volt_ranges, \ - .n_linear_ranges = ARRAY_SIZE(volt_ranges), \ + .min_uV = (min), \ + .uV_step = (step), \ .vsel_reg = MT6358_BUCK_##vreg##_ELR0, \ .vsel_mask = vosel_mask, \ .enable_reg = MT6358_BUCK_##vreg##_CON0, \
@@ -87,7 +87,7 @@ struct mt6358_regulator_info { }#define MT6358_LDO1 (match, vreg, min, max, step, \ - volt_ranges, _da_vsel_reg, _da_vsel_mask, \ + _da_vsel_reg, _da_vsel_mask, \ vosel, vosel_mask) \ [MT6358_ID_##vreg] = { \ .desc = { \
@@ -98,8 +98,8 @@ struct mt6358_regulator_info { .id = MT6358_ID_##vreg, \ .owner = THIS_MODULE, \ .n_voltages = ((max) - (min)) / (step) + 1, \ - .linear_ranges = volt_ranges, \ - .n_linear_ranges = ARRAY_SIZE(volt_ranges), \ + .min_uV = (min), \ + .uV_step = (step), \ .vsel_reg = vosel, \ .vsel_mask = vosel_mask, \ .enable_reg = MT6358_LDO_##vreg##_CON0, \
@@ -131,7 +131,7 @@ struct mt6358_regulator_info { }#define MT6366_BUCK (match, vreg, min, max, step, \ - volt_ranges, vosel_mask, _da_vsel_reg, _da_vsel_mask, \ + vosel_mask, _da_vsel_reg, _da_vsel_mask, \ _modeset_reg, _modeset_shift) \ [MT6366_ID_##vreg] = { \ .desc = { \
@@ -142,8 +142,8 @@ struct mt6358_regulator_info { .id = MT6366_ID_##vreg, \ .owner = THIS_MODULE, \ .n_voltages = ((max) - (min)) / (step) + 1, \ - .linear_ranges = volt_ranges, \ - .n_linear_ranges = ARRAY_SIZE(volt_ranges), \ + .min_uV = (min), \ + .uV_step = (step), \ .vsel_reg = MT6358_BUCK_##vreg##_ELR0, \ .vsel_mask = vosel_mask, \ .enable_reg = MT6358_BUCK_##vreg##_CON0, \
@@ -183,7 +183,7 @@ struct mt6358_regulator_info { }#define MT6366_LDO1 (match, vreg, min, max, step, \ - volt_ranges, _da_vsel_reg, _da_vsel_mask, \ + _da_vsel_reg, _da_vsel_mask, \ vosel, vosel_mask) \ [MT6366_ID_##vreg] = { \ .desc = { \
@@ -194,8 +194,8 @@ struct mt6358_regulator_info { .id = MT6366_ID_##vreg, \ .owner = THIS_MODULE, \ .n_voltages = ((max) - (min)) / (step) + 1, \ - .linear_ranges = volt_ranges, \ - .n_linear_ranges = ARRAY_SIZE(volt_ranges), \ + .min_uV = (min), \ + .uV_step = (step), \ .vsel_reg = vosel, \ .vsel_mask = vosel_mask, \ .enable_reg = MT6358_LDO_##vreg##_CON0, \
@@ -226,21 +226,6 @@ struct mt6358_regulator_info { .qi = BIT(15), \ } -static const struct linear_range buck_volt_range1[] = { -REGULATOR_LINEAR_RANGE (500000 ,0 ,0x7f ,6250 ), -}; - -static const struct linear_range buck_volt_range2[] = { -REGULATOR_LINEAR_RANGE (500000 ,0 ,0x7f ,12500 ), -}; - -static const struct linear_range buck_volt_range3[] = { -REGULATOR_LINEAR_RANGE (500000 ,0 ,0x3f ,50000 ), -}; - -static const struct linear_range buck_volt_range4[] = { -REGULATOR_LINEAR_RANGE (1000000 ,0 ,0x7f ,12500 ), -};static const unsigned int vdram2_voltages[] = {600000 ,1800000 ,
@@ -464,8 +449,8 @@ static unsigned int mt6358_regulator_get_mode(struct regulator_dev *rdev) }static const struct regulator_ops mt6358_volt_range_ops = { - .list_voltage = regulator_list_voltage_linear_range, - .map_voltage = regulator_map_voltage_linear_range, + .list_voltage = regulator_list_voltage_linear, + .map_voltage = regulator_map_voltage_linear, .set_voltage_sel = regulator_set_voltage_sel_regmap, .get_voltage_sel = mt6358_get_buck_voltage_sel, .set_voltage_time_sel = regulator_set_voltage_time_sel,
@@ -500,32 +485,23 @@ static const struct regulator_ops mt6358_volt_fixed_ops = {/* The array is indexed by id(MT6358_ID_XXX) */ static struct mt6358_regulator_info mt6358_regulators[] = {MT6358_BUCK ("buck_vdram1" ,VDRAM1 ,500000 ,2087500 ,12500 , - buck_volt_range2,0x7f ,MT6358_BUCK_VDRAM1_DBG0 ,0x7f , -MT6358_VDRAM1_ANA_CON0 ,8 ), +0x7f ,MT6358_BUCK_VDRAM1_DBG0 ,0x7f ,MT6358_VDRAM1_ANA_CON0 ,8 ),MT6358_BUCK ("buck_vcore" ,VCORE ,500000 ,1293750 ,6250 , - buck_volt_range1,0x7f ,MT6358_BUCK_VCORE_DBG0 ,0x7f , -MT6358_VCORE_VGPU_ANA_CON0 ,1 ), +0x7f ,MT6358_BUCK_VCORE_DBG0 ,0x7f ,MT6358_VCORE_VGPU_ANA_CON0 ,1 ),MT6358_BUCK ("buck_vpa" ,VPA ,500000 ,3650000 ,50000 , - buck_volt_range3,0x3f ,MT6358_BUCK_VPA_DBG0 ,0x3f , -MT6358_VPA_ANA_CON0 ,3 ), +0x3f ,MT6358_BUCK_VPA_DBG0 ,0x3f ,MT6358_VPA_ANA_CON0 ,3 ),MT6358_BUCK ("buck_vproc11" ,VPROC11 ,500000 ,1293750 ,6250 , - buck_volt_range1,0x7f ,MT6358_BUCK_VPROC11_DBG0 ,0x7f , -MT6358_VPROC_ANA_CON0 ,1 ), +0x7f ,MT6358_BUCK_VPROC11_DBG0 ,0x7f ,MT6358_VPROC_ANA_CON0 ,1 ),MT6358_BUCK ("buck_vproc12" ,VPROC12 ,500000 ,1293750 ,6250 , - buck_volt_range1,0x7f ,MT6358_BUCK_VPROC12_DBG0 ,0x7f , -MT6358_VPROC_ANA_CON0 ,2 ), +0x7f ,MT6358_BUCK_VPROC12_DBG0 ,0x7f ,MT6358_VPROC_ANA_CON0 ,2 ),MT6358_BUCK ("buck_vgpu" ,VGPU ,500000 ,1293750 ,6250 , - buck_volt_range1,0x7f ,MT6358_BUCK_VGPU_ELR0 ,0x7f , -MT6358_VCORE_VGPU_ANA_CON0 ,2 ), +0x7f ,MT6358_BUCK_VGPU_ELR0 ,0x7f ,MT6358_VCORE_VGPU_ANA_CON0 ,2 ),MT6358_BUCK ("buck_vs2" ,VS2 ,500000 ,2087500 ,12500 , - buck_volt_range2,0x7f ,MT6358_BUCK_VS2_DBG0 ,0x7f , -MT6358_VS2_ANA_CON0 ,8 ), +0x7f ,MT6358_BUCK_VS2_DBG0 ,0x7f ,MT6358_VS2_ANA_CON0 ,8 ),MT6358_BUCK ("buck_vmodem" ,VMODEM ,500000 ,1293750 ,6250 , - buck_volt_range1,0x7f ,MT6358_BUCK_VMODEM_DBG0 ,0x7f , -MT6358_VMODEM_ANA_CON0 ,8 ), +0x7f ,MT6358_BUCK_VMODEM_DBG0 ,0x7f ,MT6358_VMODEM_ANA_CON0 ,8 ),MT6358_BUCK ("buck_vs1" ,VS1 ,1000000 ,2587500 ,12500 , - buck_volt_range4,0x7f ,MT6358_BUCK_VS1_DBG0 ,0x7f , -MT6358_VS1_ANA_CON0 ,8 ), +0x7f ,MT6358_BUCK_VS1_DBG0 ,0x7f ,MT6358_VS1_ANA_CON0 ,8 ),MT6358_REG_FIXED ("ldo_vrf12" ,VRF12 ,MT6358_LDO_VRF12_CON0 ,0 ,1200000 ), MT6358_REG_FIXED("ldo_vio18", VIO18,
@@ -579,48 +555,35 @@ static struct mt6358_regulator_info mt6358_regulators[] = { MT6358_LDO("ldo_vsim2", VSIM2, vsim_voltages, vsim_idx, MT6358_LDO_VSIM2_CON0, 0, MT6358_VSIM2_ANA_CON0, 0xf00), MT6358_LDO1("ldo_vsram_proc11", VSRAM_PROC11, 500000, 1293750, 6250, - buck_volt_range1, MT6358_LDO_VSRAM_PROC11_DBG0, 0x7f00, - MT6358_LDO_VSRAM_CON0, 0x7f), + MT6358_LDO_VSRAM_PROC11_DBG0, 0x7f00, MT6358_LDO_VSRAM_CON0, 0x7f), MT6358_LDO1("ldo_vsram_others", VSRAM_OTHERS, 500000, 1293750, 6250, - buck_volt_range1, MT6358_LDO_VSRAM_OTHERS_DBG0, 0x7f00, - MT6358_LDO_VSRAM_CON2, 0x7f), + MT6358_LDO_VSRAM_OTHERS_DBG0, 0x7f00, MT6358_LDO_VSRAM_CON2, 0x7f), MT6358_LDO1("ldo_vsram_gpu", VSRAM_GPU, 500000, 1293750, 6250, - buck_volt_range1, MT6358_LDO_VSRAM_GPU_DBG0, 0x7f00, - MT6358_LDO_VSRAM_CON3, 0x7f), + MT6358_LDO_VSRAM_GPU_DBG0, 0x7f00, MT6358_LDO_VSRAM_CON3, 0x7f),MT6358_LDO1 ("ldo_vsram_proc12" ,VSRAM_PROC12 ,500000 ,1293750 ,6250 , - buck_volt_range1,MT6358_LDO_VSRAM_PROC12_DBG0 ,0x7f00 , - MT6358_LDO_VSRAM_CON1, 0x7f), + MT6358_LDO_VSRAM_PROC12_DBG0, 0x7f00, MT6358_LDO_VSRAM_CON1, 0x7f), };/* The array is indexed by id(MT6366_ID_XXX) */ static struct mt6358_regulator_info mt6366_regulators[] = {MT6366_BUCK ("buck_vdram1" ,VDRAM1 ,500000 ,2087500 ,12500 , - buck_volt_range2,0x7f ,MT6358_BUCK_VDRAM1_DBG0 ,0x7f , -MT6358_VDRAM1_ANA_CON0 ,8 ), +0x7f ,MT6358_BUCK_VDRAM1_DBG0 ,0x7f ,MT6358_VDRAM1_ANA_CON0 ,8 ),MT6366_BUCK ("buck_vcore" ,VCORE ,500000 ,1293750 ,6250 , - buck_volt_range1,0x7f ,MT6358_BUCK_VCORE_DBG0 ,0x7f , -MT6358_VCORE_VGPU_ANA_CON0 ,1 ), +0x7f ,MT6358_BUCK_VCORE_DBG0 ,0x7f ,MT6358_VCORE_VGPU_ANA_CON0 ,1 ),MT6366_BUCK ("buck_vpa" ,VPA ,500000 ,3650000 ,50000 , - buck_volt_range3,0x3f ,MT6358_BUCK_VPA_DBG0 ,0x3f , -MT6358_VPA_ANA_CON0 ,3 ), +0x3f ,MT6358_BUCK_VPA_DBG0 ,0x3f ,MT6358_VPA_ANA_CON0 ,3 ),MT6366_BUCK ("buck_vproc11" ,VPROC11 ,500000 ,1293750 ,6250 , - buck_volt_range1,0x7f ,MT6358_BUCK_VPROC11_DBG0 ,0x7f , -MT6358_VPROC_ANA_CON0 ,1 ), +0x7f ,MT6358_BUCK_VPROC11_DBG0 ,0x7f ,MT6358_VPROC_ANA_CON0 ,1 ),MT6366_BUCK ("buck_vproc12" ,VPROC12 ,500000 ,1293750 ,6250 , - buck_volt_range1,0x7f ,MT6358_BUCK_VPROC12_DBG0 ,0x7f , -MT6358_VPROC_ANA_CON0 ,2 ), +0x7f ,MT6358_BUCK_VPROC12_DBG0 ,0x7f ,MT6358_VPROC_ANA_CON0 ,2 ),MT6366_BUCK ("buck_vgpu" ,VGPU ,500000 ,1293750 ,6250 , - buck_volt_range1,0x7f ,MT6358_BUCK_VGPU_ELR0 ,0x7f , -MT6358_VCORE_VGPU_ANA_CON0 ,2 ), +0x7f ,MT6358_BUCK_VGPU_ELR0 ,0x7f ,MT6358_VCORE_VGPU_ANA_CON0 ,2 ),MT6366_BUCK ("buck_vs2" ,VS2 ,500000 ,2087500 ,12500 , - buck_volt_range2,0x7f ,MT6358_BUCK_VS2_DBG0 ,0x7f , -MT6358_VS2_ANA_CON0 ,8 ), +0x7f ,MT6358_BUCK_VS2_DBG0 ,0x7f ,MT6358_VS2_ANA_CON0 ,8 ),MT6366_BUCK ("buck_vmodem" ,VMODEM ,500000 ,1293750 ,6250 , - buck_volt_range1,0x7f ,MT6358_BUCK_VMODEM_DBG0 ,0x7f , -MT6358_VMODEM_ANA_CON0 ,8 ), +0x7f ,MT6358_BUCK_VMODEM_DBG0 ,0x7f ,MT6358_VMODEM_ANA_CON0 ,8 ),MT6366_BUCK ("buck_vs1" ,VS1 ,1000000 ,2587500 ,12500 , - buck_volt_range4,0x7f ,MT6358_BUCK_VS1_DBG0 ,0x7f , -MT6358_VS1_ANA_CON0 ,8 ), +0x7f ,MT6358_BUCK_VS1_DBG0 ,0x7f ,MT6358_VS1_ANA_CON0 ,8 ),MT6366_REG_FIXED ("ldo_vrf12" ,VRF12 ,MT6358_LDO_VRF12_CON0 ,0 ,1200000 ), MT6366_REG_FIXED("ldo_vio18", VIO18,
@@ -663,17 +626,13 @@ static struct mt6358_regulator_info mt6366_regulators[] = {MT6366_LDO ("ldo_vsim2" ,VSIM2 , vsim_voltages, vsim_idx,MT6358_LDO_VSIM2_CON0 ,0 ,MT6358_VSIM2_ANA_CON0 ,0xf00 ),MT6366_LDO1 ("ldo_vsram_proc11" ,VSRAM_PROC11 ,500000 ,1293750 ,6250 , - buck_volt_range1,MT6358_LDO_VSRAM_PROC11_DBG0 ,0x7f00 , -MT6358_LDO_VSRAM_CON0 ,0x7f ), +MT6358_LDO_VSRAM_PROC11_DBG0 ,0x7f00 ,MT6358_LDO_VSRAM_CON0 ,0x7f ),MT6366_LDO1 ("ldo_vsram_others" ,VSRAM_OTHERS ,500000 ,1293750 ,6250 , - buck_volt_range1,MT6358_LDO_VSRAM_OTHERS_DBG0 ,0x7f00 , -MT6358_LDO_VSRAM_CON2 ,0x7f ), +MT6358_LDO_VSRAM_OTHERS_DBG0 ,0x7f00 ,MT6358_LDO_VSRAM_CON2 ,0x7f ),MT6366_LDO1 ("ldo_vsram_gpu" ,VSRAM_GPU ,500000 ,1293750 ,6250 , - buck_volt_range1,MT6358_LDO_VSRAM_GPU_DBG0 ,0x7f00 , -MT6358_LDO_VSRAM_CON3 ,0x7f ), +MT6358_LDO_VSRAM_GPU_DBG0 ,0x7f00 ,MT6358_LDO_VSRAM_CON3 ,0x7f ),MT6366_LDO1 ("ldo_vsram_proc12" ,VSRAM_PROC12 ,500000 ,1293750 ,6250 , - buck_volt_range1,MT6358_LDO_VSRAM_PROC12_DBG0 ,0x7f00 , - MT6358_LDO_VSRAM_CON1, 0x7f), + MT6358_LDO_VSRAM_PROC12_DBG0, 0x7f00, MT6358_LDO_VSRAM_CON1, 0x7f), };static int mt6358_regulator_probe (struct platform_device *pdev)
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 87/162 regulator: mt6358: split ops for buck and linear range LDO regulators
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen-Yu Tsai <[email protected]>
[ Upstream commit 7e37c851374eca2d1f6128de03195c9f7b4baaf2 ]
The buck and linear range LDO (VSRAM_*) regulators share one set of ops. This set includes support for get/set mode. However this only makes sense for buck regulators, not LDOs. The callbacks were not checking whether the register offset and/or mask for mode setting was valid or not. This ends up making the kernel report "normal" mode operation for the LDOs.
Create a new set of ops without the get/set mode callbacks for the linear range LDO regulators.
--- drivers/regulator/mt6358-regulator.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
drivers/regulator/mt6358-regulator.c +15 -3
@@ -41,7 +41,7 @@ struct mt6358_regulator_info { .desc = { \ .name = #vreg, \ .of_match = of_match_ptr(match), \ - .ops = &mt6358_volt_range_ops, \ + .ops = &mt6358_buck_ops, \ .type = REGULATOR_VOLTAGE, \ .id = MT6358_ID_##vreg, \ .owner = THIS_MODULE, \
@@ -137,7 +137,7 @@ struct mt6358_regulator_info { .desc = { \ .name = #vreg, \ .of_match = of_match_ptr(match), \ - .ops = &mt6358_volt_range_ops, \ + .ops = &mt6358_buck_ops, \ .type = REGULATOR_VOLTAGE, \ .id = MT6366_ID_##vreg, \ .owner = THIS_MODULE, \
@@ -448,7 +448,7 @@ static unsigned int mt6358_regulator_get_mode(struct regulator_dev *rdev) } } -static const struct regulator_ops mt6358_volt_range_ops = { +static const struct regulator_ops mt6358_buck_ops = { .list_voltage = regulator_list_voltage_linear, .map_voltage = regulator_map_voltage_linear, .set_voltage_sel = regulator_set_voltage_sel_regmap,
@@ -462,6 +462,18 @@ static const struct regulator_ops mt6358_volt_range_ops = { .get_mode = mt6358_regulator_get_mode, }; +static const struct regulator_ops mt6358_volt_range_ops = { + .list_voltage = regulator_list_voltage_linear, + .map_voltage = regulator_map_voltage_linear, + .set_voltage_sel = regulator_set_voltage_sel_regmap, + .get_voltage_sel = mt6358_get_buck_voltage_sel, + .set_voltage_time_sel = regulator_set_voltage_time_sel, + .enable = regulator_enable_regmap, + .disable = regulator_disable_regmap, + .is_enabled = regulator_is_enabled_regmap, + .get_status = mt6358_get_status, +}; +static const struct regulator_ops mt6358_volt_table_ops = { .list_voltage = regulator_list_voltage_table, .map_voltage = regulator_map_voltage_iterate,
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 88/162 Bluetooth: Delete unused hci_req_prepare_suspend() declaration
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yao Xiao <[email protected]>
[ Upstream commit cbaabbcdcbd355f0a1ccc09a925575c51c270750 ]
hci_req_prepare_suspend() has been deprecated in favor of hci_suspend_sync().
--- net/bluetooth/hci_request.h | 2 -- 1 file changed, 2 deletions(-)
net/bluetooth/hci_request.h +0 -2
@@ -71,7 +71,5 @@ struct sk_buff *hci_prepare_cmd(struct hci_dev *hdev, u16 opcode, u32 plen,void hci_req_add_le_scan_disable (struct hci_request *req,bool rpa_le_conn);void hci_req_add_le_passive_scan (struct hci_request *req); -void hci_req_prepare_suspend (struct hci_dev *hdev,enum suspended_state next); -void hci_request_setup (struct hci_dev *hdev);void hci_request_cancel_all (struct hci_dev *hdev);
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 89/162 Bluetooth: ISO: Fix handling of listen for unicast
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit e0275ea52169412b8faccb4e2f4fed8a057844c6 ]
iso_listen_cis shall only return -EADDRINUSE if the listening socket has the destination set to BDADDR_ANY otherwise if the destination is set to a specific address it is for broadcast which shall be ignored.
--- net/bluetooth/iso.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
net/bluetooth/iso.c +6 -3
@@ -458,7 +458,7 @@ static void iso_recv_frame(struct iso_conn *conn, struct sk_buff *skb) }/* -------- Socket interface ---------- */ -static struct sock *__iso_get_sock_listen_by_addr (bdaddr_t *ba) +static struct sock *__iso_get_sock_listen_by_addr (bdaddr_t *src,bdaddr_t *dst) {struct sock *sk;
@@ -466,7 +466,10 @@ static struct sock *__iso_get_sock_listen_by_addr(bdaddr_t *ba)if (sk->sk_state !=BT_LISTEN )continue ; -if (!bacmp (&iso_pi (sk)->src, ba)) +if (bacmp (&iso_pi (sk)->dst, dst)) +continue ; + +if (!bacmp (&iso_pi (sk)->src, src))return sk; }
@@ -910,7 +913,7 @@ static int iso_listen_cis(struct sock *sk)write_lock (&iso_sk_list.lock); -if (__iso_get_sock_listen_by_addr (&iso_pi (sk)->src)) +if (__iso_get_sock_listen_by_addr (&iso_pi (sk)->src, &iso_pi (sk)->dst)) err = -EADDRINUSE ;write_unlock (&iso_sk_list.lock);
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 90/162 drivers/net: process the result of hdlc_open() and add call of hdlc_close() in uhdlc_close()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexandra Diupina <[email protected]>
[ Upstream commit a59addacf899b1b21a7b7449a1c52c98704c2472 ]
Process the result of hdlc_open() and call uhdlc_close() in case of an error. It is necessary to pass the error code up the control flow, similar to a possible error in request_irq().
Also add a hdlc_close() call to the uhdlc_close() because the comment to hdlc_close() says it must be called by the hardware driver when the HDLC device is being closed
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/net/wan/fsl_ucc_hdlc.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/net/wan/fsl_ucc_hdlc.c +10 -2
@@ -34,6 +34,8 @@#define TDM_PPPOHT_SLIC_MAXIN #define RX_BD_ERRORS (R_CD_S | R_OV_S | R_CR_S | R_AB_S | R_NO_S | R_LG_S) +static int uhdlc_close (struct net_device *dev); +static struct ucc_tdm_info utdm_primary_info = { .uf_info = { .tsa =0 ,
@@ -708,6 +710,7 @@ static int uhdlc_open(struct net_device *dev)hdlc_device *hdlc =dev_to_hdlc (dev);struct ucc_hdlc_private *priv = hdlc->priv;struct ucc_tdm *utdm = priv->utdm; +int rc =0 ;if (priv->hdlc_busy !=1 ) { if (request_irq(priv->ut_info->uf_info.irq,
@@ -731,10 +734,13 @@ static int uhdlc_open(struct net_device *dev)napi_enable (&priv->napi);netdev_reset_queue (dev);netif_start_queue (dev); -hdlc_open (dev); + + rc =hdlc_open (dev); +if (rc) +uhdlc_close (dev); } -return 0 ; +return rc; }static void uhdlc_memclean (struct ucc_hdlc_private *priv)
@@ -824,6 +830,8 @@ static int uhdlc_close(struct net_device *dev)netdev_reset_queue (dev); priv->hdlc_busy =0 ; +hdlc_close (dev); +return 0 ; }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 91/162 wifi: mt76: mt76x02: fix MT76x0 external LNA gain handling
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Fietkau <[email protected]>
[ Upstream commit 684e45e120b82deccaf8b85633905304a3bbf56d ]
On MT76x0, LNA gain should be applied for both external and internal LNA. On MT76x2, LNA gain should be treated as 0 for external LNA. Move the LNA type based logic to mt76x2 in order to fix mt76x0.
--- drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.c | 7 ------- drivers/net/wireless/mediatek/mt76/mt76x2/eeprom.c | 13 +++++++++++-- 2 files changed, 11 insertions(+), 9 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.c +0 -7
@@ -131,15 +131,8 @@ u8 mt76x02_get_lna_gain(struct mt76x02_dev *dev, s8 *lna_2g, s8 *lna_5g, struct ieee80211_channel *chan) { -u16 val;u8 lna; - val =mt76x02_eeprom_get (dev,MT_EE_NIC_CONF_1 ); -if (val &MT_EE_NIC_CONF_1_LNA_EXT_2G ) - *lna_2g =0 ; -if (val &MT_EE_NIC_CONF_1_LNA_EXT_5G ) -memset (lna_5g,0 ,sizeof (s8) *3 ); -if (chan->band ==NL80211_BAND_2GHZ ) lna = *lna_2g;else if (chan->hw_value <=64 )
drivers/net/wireless/mediatek/mt76/mt76x2/eeprom.c +11 -2
@@ -256,7 +256,8 @@ void mt76x2_read_rx_gain(struct mt76x02_dev *dev)struct ieee80211_channel *chan = dev->mphy.chandef.chan;int channel = chan->hw_value;s8 lna_5g[3 ], lna_2g; -u8 lna; +bool use_lna; +u8 lna =0 ;u16 val;if (chan->band ==NL80211_BAND_2GHZ )
@@ -275,7 +276,15 @@ void mt76x2_read_rx_gain(struct mt76x02_dev *dev) dev->cal.rx.mcu_gain |= (lna_5g[1 ] &0xff ) <<16 ; dev->cal.rx.mcu_gain |= (lna_5g[2 ] &0xff ) <<24 ; - lna =mt76x02_get_lna_gain (dev, &lna_2g, lna_5g, chan); + val =mt76x02_eeprom_get (dev,MT_EE_NIC_CONF_1 ); +if (chan->band ==NL80211_BAND_2GHZ ) + use_lna = !(val &MT_EE_NIC_CONF_1_LNA_EXT_2G ); +else + use_lna = !(val &MT_EE_NIC_CONF_1_LNA_EXT_5G ); + +if (use_lna) + lna =mt76x02_get_lna_gain (dev, &lna_2g, lna_5g, chan); + dev->cal.rx.lna_gain =mt76x02_sign_extend (lna,8 ); }EXPORT_SYMBOL_GPL (mt76x2_read_rx_gain);
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 74/162 erofs: fix memory leak of LZMA global compressed deduplication
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gao Xiang <[email protected]>
[ Upstream commit 75a5221630fe5aa3fedba7a06be618db0f79ba1e ]
When stressing microLZMA EROFS images with the new global compressed deduplication feature enabled (-Ededupe), I found some short-lived temporary pages weren't properly released, which could slowly cause unexpected OOMs hours later.
Let's fix it now (LZ4 and DEFLATE don't have this issue.)
--- fs/erofs/decompressor_lzma.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/erofs/decompressor_lzma.c +4 -1
@@ -217,9 +217,12 @@ int z_erofs_lzma_decompress(struct z_erofs_decompress_req *rq, strm->buf.out_size =min_t (u32, outlen,PAGE_SIZE - pageofs); outlen -= strm->buf.out_size; -if (!rq->out[no] && rq->fillgaps)/* deduped */ +if (!rq->out[no] && rq->fillgaps) {/* deduped */ rq->out[no] =erofs_allocpage (pagepool,GFP_KERNEL | __GFP_NOFAIL); +set_page_private (rq->out[no], +Z_EROFS_SHORTLIVED_PAGE ); + }if (rq->out[no]) strm->buf.out =kmap (rq->out[no]) + pageofs; pageofs =0 ;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 92/162 perf/x86/amd/core: Fix overflow reset on hotplug
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sandipan Das <[email protected]>
[ Upstream commit 23d2626b841c2adccdeb477665313c02dff02dc3 ]
Kernels older than v5.19 do not support PerfMonV2 and the PMI handler does not clear the overflow bits of the PerfCntrGlobalStatus register. Because of this, loading a recent kernel using kexec from an older kernel can result in inconsistent register states on Zen 4 systems.
The PMI handler of the new kernel gets confused and shows a warning when an overflow occurs because some of the overflow bits are set even if the corresponding counters are inactive. These are remnants from overflows that were handled by the older kernel.
During CPU hotplug, the PerfCntrGlobalCtl and PerfCntrGlobalStatus registers should always be cleared for PerfMonV2-capable processors. However, a condition used for NB event constaints applicable only to older processors currently prevents this from happening. Move the reset sequence to an appropriate place and also clear the LBR Freeze bit.
--- arch/x86/events/amd/core.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
arch/x86/events/amd/core.c +8 -6
@@ -534,8 +534,12 @@ static void amd_pmu_cpu_reset(int cpu)/* Clear enable bits i.e. PerfCntrGlobalCtl.PerfCntrEn */ wrmsrl (MSR_AMD64_PERF_CNTR_GLOBAL_CTL ,0 ); -/* Clear overflow bits i.e. PerfCntrGLobalStatus.PerfCntrOvfl */ -wrmsrl (MSR_AMD64_PERF_CNTR_GLOBAL_STATUS_CLR , amd_pmu_global_cntr_mask); +/* +* Clear freeze and overflow bits i.e. PerfCntrGLobalStatus.LbrFreeze +* and PerfCntrGLobalStatus.PerfCntrOvfl +*/ +wrmsrl (MSR_AMD64_PERF_CNTR_GLOBAL_STATUS_CLR , +GLOBAL_STATUS_LBRS_FROZEN | amd_pmu_global_cntr_mask); }static int amd_pmu_cpu_prepare (int cpu)
@@ -570,6 +574,7 @@ static void amd_pmu_cpu_starting(int cpu)int i, nb_id; cpuc->perf_ctr_virt_mask =AMD64_EVENTSEL_HOSTONLY ; +amd_pmu_cpu_reset (cpu);if (!x86_pmu.amd_nb_constraints)return ;
@@ -591,8 +596,6 @@ static void amd_pmu_cpu_starting(int cpu) cpuc->amd_nb->nb_id = nb_id; cpuc->amd_nb->refcnt++; - -amd_pmu_cpu_reset (cpu); }static void amd_pmu_cpu_dead (int cpu)
@@ -601,6 +604,7 @@ static void amd_pmu_cpu_dead(int cpu)kfree (cpuhw->lbr_sel); cpuhw->lbr_sel =NULL ; +amd_pmu_cpu_reset (cpu);if (!x86_pmu.amd_nb_constraints)return ;
@@ -613,8 +617,6 @@ static void amd_pmu_cpu_dead(int cpu) cpuhw->amd_nb =NULL ; } - -amd_pmu_cpu_reset (cpu); }static inline void amd_pmu_set_global_ctl (u64 ctl)
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 93/162 regmap: rbtree: Fix wrong register marked as in-cache when creating new node
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Fitzgerald <[email protected]>
[ Upstream commit 7a795ac8d49e2433e1b97caf5e99129daf8e1b08 ]
When regcache_rbtree_write() creates a new rbtree_node it was passing the wrong bit number to regcache_rbtree_set_register(). The bit number is the offset __in number of registers__, but in the case of creating a new block regcache_rbtree_write() was not dividing by the address stride to get the number of registers.
Fix this by dividing by map->reg_stride.
Compare with regcache_rbtree_read() where the bit is checked.
This bug meant that the wrong register was marked as present. The register that was written to the cache could not be read from the cache because it was not marked as cached. But a nearby register could be marked as having a cached value even if it was never written to the cache.
--- drivers/base/regmap/regcache-rbtree.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/base/regmap/regcache-rbtree.c +2 -1
@@ -453,7 +453,8 @@ static int regcache_rbtree_write(struct regmap *map, unsigned int reg,if (!rbnode)return -ENOMEM ;regcache_rbtree_set_register (map, rbnode, - reg - rbnode->base_reg, value); + (reg - rbnode->base_reg) / map->reg_stride, + value);regcache_rbtree_insert (map, &rbtree_ctx->root, rbnode); rbtree_ctx->cached_rbnode = rbnode; }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 94/162 wifi: mac80211: fix potential key use-after-free
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 31db78a4923ef5e2008f2eed321811ca79e7f71b ]
When ieee80211_key_link() is called by ieee80211_gtk_rekey_add() but returns 0 due to KRACK protection (identical key reinstall), ieee80211_gtk_rekey_add() will still return a pointer into the key, in a potential use-after-free. This normally doesn't happen since it's only called by iwlwifi in case of WoWLAN rekey offload which has its own KRACK protection, but still better to fix, do that by returning an error code and converting that to success on the cfg80211 boundary only, leaving the error for bad callers of ieee80211_gtk_rekey_add().
--- net/mac80211/cfg.c | 3 +++ net/mac80211/key.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-)
net/mac80211/cfg.c +3 -0
@@ -566,6 +566,9 @@ static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev, } err =ieee80211_key_link (key, link, sta); +/* KRACK protection, shouldn't happen but just silently accept key */ +if (err == -EALREADY ) + err =0 ; out_unlock:mutex_unlock (&local->sta_mtx);
net/mac80211/key.c +1 -1
@@ -901,7 +901,7 @@ int ieee80211_key_link(struct ieee80211_key *key,*/ if (ieee80211_key_identical (sdata, old_key, key)) {ieee80211_key_free_unused (key); - ret =0 ; + ret = -EALREADY ; goto out; }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 95/162 perf/x86/amd: Do not WARN() on every IRQ
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <[email protected]>
[ Upstream commit 599522d9d2e19d6240e4312577f1c5f3ffca22f6 ]
Zen 4 systems running buggy microcode can hit a WARN_ON() in the PMI handler, as shown below, several times while perf runs. A simple perf top run is enough to render the system unusable:
WARNING: CPU: 18 PID: 20608 at arch/x86/events/amd/core.c:944 amd_pmu_v2_handle_irq+0x1be/0x2b0
This happens because the Performance Counter Global Status Register (PerfCntGlobalStatus) has one or more bits set which are considered reserved according to the "AMD64 Architecture Programmer’s Manual, Volume 2: System Programming, 24593":
https://www.amd.com/system/files/TechDocs/24593.pdf
To make this less intrusive, warn just once if any reserved bit is set and prompt the user to update the microcode. Also sanitize the value to what the code is handling, so that the overflow events continue to be handled for the number of counters that are known to be sane.
Going forward, the following microcode patch levels are recommended for Zen 4 processors in order to avoid such issues with reserved bits:
Family=0x19 Model=0x11 Stepping=0x01: Patch=0x0a10113e Family=0x19 Model=0x11 Stepping=0x02: Patch=0x0a10123e Family=0x19 Model=0xa0 Stepping=0x01: Patch=0x0aa00116 Family=0x19 Model=0xa0 Stepping=0x02: Patch=0x0aa00212
Commit f2eb058afc57 ("linux-firmware: Update AMD cpu microcode") from the linux-firmware tree has binaries that meet the minimum required patch levels.
[ sandipan: - add message to prompt users to update microcode
- rework commit message and call out required microcode levels ]
--- arch/x86/events/amd/core.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
arch/x86/events/amd/core.c +9 -1
@@ -886,7 +886,7 @@ static int amd_pmu_v2_handle_irq(struct pt_regs *regs)struct hw_perf_event *hwc;struct perf_event *event;int handled =0 , idx; -u64 status, mask; +u64 reserved, status, mask;bool pmu_enabled;/*
@@ -911,6 +911,14 @@ static int amd_pmu_v2_handle_irq(struct pt_regs *regs) status &= ~GLOBAL_STATUS_LBRS_FROZEN ; } + reserved = status & ~amd_pmu_global_cntr_mask; +if (reserved) +pr_warn_once ("Reserved PerfCntrGlobalStatus bits are set (0x%llx), please consider updating microcode\n" , + reserved); + +/* Clear any reserved bits set by buggy microcode */ + status &= amd_pmu_global_cntr_mask; +for (idx =0 ; idx < x86_pmu.num_counters; idx++) {if (!test_bit (idx, cpuc->active_mask))continue ;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 96/162 iommu/mediatek: Fix share pgtable for iova over 4GB
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yong Wu <[email protected]>
[ Upstream commit b07eba71a512eb196cbcc29765c29c8c29b11b59 ]
In mt8192/mt8186, there is only one MM IOMMU that supports 16GB iova space, which is shared by display, vcodec and camera. These two SoC use one pgtable and have not the flag SHARE_PGTABLE, we should also keep share pgtable for this case.
In mtk_iommu_domain_finalise, MM IOMMU always share pgtable, thus remove the flag SHARE_PGTABLE checking. Infra IOMMU always uses independent pgtable.
--- drivers/iommu/mtk_iommu.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/iommu/mtk_iommu.c +4 -5
@@ -223,7 +223,7 @@ struct mtk_iommu_data {struct device *smicomm_dev;struct mtk_iommu_bank_data *bank; -struct mtk_iommu_domain *share_dom;/* For 2 HWs share pgtable */ +struct mtk_iommu_domain *share_dom;struct regmap *pericfg;struct mutex mutex;/* Protect m4u_group/m4u_dom above */
@@ -579,8 +579,8 @@ static int mtk_iommu_domain_finalise(struct mtk_iommu_domain *dom,struct mtk_iommu_domain *share_dom = data->share_dom;const struct mtk_iommu_iova_region *region; -/* Always use share domain in sharing pgtable case */ -if (MTK_IOMMU_HAS_FLAG (data->plat_data,SHARE_PGTABLE ) && share_dom) { +/* Share pgtable when 2 MM IOMMU share the pgtable or one IOMMU use multiple iova ranges */ +if (share_dom) { dom->iop = share_dom->iop; dom->cfg = share_dom->cfg; dom->domain.pgsize_bitmap = share_dom->cfg.pgsize_bitmap;
@@ -613,8 +613,7 @@ static int mtk_iommu_domain_finalise(struct mtk_iommu_domain *dom,/* Update our support page sizes bitmap */ dom->domain.pgsize_bitmap = dom->cfg.pgsize_bitmap; -if (MTK_IOMMU_HAS_FLAG (data->plat_data,SHARE_PGTABLE )) - data->share_dom = dom; + data->share_dom = dom; update_iova_region:/* Update the iova region for this domain */
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 97/162 regulator/core: regulator_register: set device->class earlier
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michał Mirosław <[email protected]>
[ Upstream commit 8adb4e647a83cb5928c05dae95b010224aea0705 ]
When fixing a memory leak in commit d3c731564e09 ("regulator: plug of_node leak in regulator_register()'s error path") it moved the device_initialize() call earlier, but did not move the dev->class initialization. The bug was spotted and fixed by reverting part of the commit (in commit 5f4b204b6b81 "regulator: core: fix kobject release warning and memory leak in regulator_register()") but introducing a different bug: now early error paths use kfree(dev) instead of put_device() for an already initialized struct device.
Move the missing assignments to just after device_initialize().
--- drivers/regulator/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/regulator/core.c +2 -2
@@ -5543,6 +5543,8 @@ regulator_register(struct device *dev, goto rinse; }device_initialize (&rdev->dev); +dev_set_drvdata (&rdev->dev, rdev); + rdev->dev.class = ®ulator_class;spin_lock_init (&rdev->err_lock);/*
@@ -5604,11 +5606,9 @@ regulator_register(struct device *dev, rdev->supply_name = regulator_desc->supply_name;/* register with sysfs */ - rdev->dev.class = ®ulator_class; rdev->dev.parent = config->dev;dev_set_name (&rdev->dev,"regulator.%lu" , (unsigned long )atomic_inc_return (®ulator_no)); -dev_set_drvdata (&rdev->dev, rdev);/* set regulator constraints */ if (init_data)
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 98/162 ima: Finish deprecation of IMA_TRUSTED_KEYRING Kconfig
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oleksandr Tymoshenko <[email protected]>
[ Upstream commit be210c6d3597faf330cb9af33b9f1591d7b2a983 ]
The removal of IMA_TRUSTED_KEYRING made IMA_LOAD_X509 and IMA_BLACKLIST_KEYRING unavailable because the latter two depend on the former. Since IMA_TRUSTED_KEYRING was deprecated in favor of INTEGRITY_TRUSTED_KEYRING use it as a dependency for the two Kconfigs affected by the deprecation.
--- security/integrity/ima/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
security/integrity/ima/Kconfig +2 -2
@@ -268,7 +268,7 @@ config IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY config IMA_BLACKLIST_KEYRING bool "Create IMA machine owner blacklist keyrings (EXPERIMENTAL)" depends on SYSTEM_TRUSTED_KEYRING - depends on IMA_TRUSTED_KEYRING + depends on INTEGRITY_TRUSTED_KEYRING default n help This option creates an IMA blacklist keyring, which contains all
@@ -278,7 +278,7 @@ config IMA_BLACKLIST_KEYRING config IMA_LOAD_X509 bool "Load X509 certificate onto the '.ima' trusted keyring" - depends on IMA_TRUSTED_KEYRING + depends on INTEGRITY_TRUSTED_KEYRING default n help File signature verification is based on the public keys
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 99/162 scsi: target: core: Fix deadlock due to recursive locking
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junxiao Bi <[email protected]>
[ Upstream commit a154f5f643c6ecddd44847217a7a3845b4350003 ]
The following call trace shows a deadlock issue due to recursive locking of mutex "device_mutex". First lock acquire is in target_for_each_device() and second in target_free_device().
PID: 148266 TASK: ffff8be21ffb5d00 CPU: 10 COMMAND: "iscsi_ttx"
#0 [ffffa2bfc9ec3b18] __schedule at ffffffffa8060e7f
#1 [ffffa2bfc9ec3ba0] schedule at ffffffffa8061224
#2 [ffffa2bfc9ec3bb8] schedule_preempt_disabled at ffffffffa80615ee
#3 [ffffa2bfc9ec3bc8] __mutex_lock at ffffffffa8062fd7
#4 [ffffa2bfc9ec3c40] __mutex_lock_slowpath at ffffffffa80631d3
#5 [ffffa2bfc9ec3c50] mutex_lock at ffffffffa806320c
#6 [ffffa2bfc9ec3c68] target_free_device at ffffffffc0935998 [target_core_mod]
#7 [ffffa2bfc9ec3c90] target_core_dev_release at ffffffffc092f975 [target_core_mod] #8 [ffffa2bfc9ec3ca0] config_item_put at ffffffffa79d250f
#9 [ffffa2bfc9ec3cd0] config_item_put at ffffffffa79d2583
#10 [ffffa2bfc9ec3ce0] target_devices_idr_iter at ffffffffc0933f3a [target_core_mod] #11 [ffffa2bfc9ec3d00] idr_for_each at ffffffffa803f6fc
#12 [ffffa2bfc9ec3d60] target_for_each_device at ffffffffc0935670 [target_core_mod] #13 [ffffa2bfc9ec3d98] transport_deregister_session at ffffffffc0946408 [target_core_mod] #14 [ffffa2bfc9ec3dc8] iscsit_close_session at ffffffffc09a44a6 [iscsi_target_mod] #15 [ffffa2bfc9ec3df0] iscsit_close_connection at ffffffffc09a4a88 [iscsi_target_mod] #16 [ffffa2bfc9ec3df8] finish_task_switch at ffffffffa76e5d07
#17 [ffffa2bfc9ec3e78] iscsit_take_action_for_connection_exit at ffffffffc0991c23 [iscsi_target_mod] #18 [ffffa2bfc9ec3ea0] iscsi_target_tx_thread at ffffffffc09a403b [iscsi_target_mod] #19 [ffffa2bfc9ec3f08] kthread at ffffffffa76d8080
#20 [ffffa2bfc9ec3f50] ret_from_fork at ffffffffa8200364
--- drivers/target/target_core_device.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/target/target_core_device.c +4 -7
@@ -883,7 +883,6 @@ sector_t target_to_linux_sector(struct se_device *dev, sector_t lb)EXPORT_SYMBOL (target_to_linux_sector);struct devices_idr_iter { -struct config_item *prev_item;int (*fn)(struct se_device *dev,void *data);void *data; };
@@ -893,11 +892,9 @@ static int target_devices_idr_iter(int id, void *p, void *data) {struct devices_idr_iter *iter = data;struct se_device *dev = p; +struct config_item *item;int ret; -config_item_put (iter->prev_item); - iter->prev_item =NULL ; -/* * We add the device early to the idr, so it can be used * by backend modules during configuration. We do not want
@@ -907,12 +904,13 @@ static int target_devices_idr_iter(int id, void *p, void *data)if (!target_dev_configured (dev))return 0 ; - iter->prev_item =config_item_get_unless_zero (&dev->dev_group.cg_item); -if (!iter->prev_item) + item =config_item_get_unless_zero (&dev->dev_group.cg_item); +if (!item)return 0 ;mutex_unlock (&device_mutex); ret = iter->fn (dev, iter->data); +config_item_put (item);mutex_lock (&device_mutex);return ret;
@@ -935,7 +933,6 @@ int target_for_each_device(int (*fn)(struct se_device *dev, void *data),mutex_lock (&device_mutex); ret =idr_for_each (&devices_idr, target_devices_idr_iter, &iter);mutex_unlock (&device_mutex); -config_item_put (iter.prev_item);return ret; }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 100/162 ima: rework CONFIG_IMA dependency block
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
[ Upstream commit 91e326563ee34509c35267808a4b1b3ea3db62a8 ]
Changing the direct dependencies of IMA_BLACKLIST_KEYRING and IMA_LOAD_X509 caused them to no longer depend on IMA, but a a configuration without IMA results in link failures:
arm-linux-gnueabi-ld: security/integrity/iint.o: in function `integrity_load_keys':
iint.c:(.init.text+0xd8): undefined reference to `ima_load_x509'
aarch64-linux-ld: security/integrity/digsig_asymmetric.o: in function `asymmetric_verify':
digsig_asymmetric.c:(.text+0x104): undefined reference to `ima_blacklist_keyring'
Adding explicit dependencies on IMA would fix this, but a more reliable way to do this is to enclose the entire Kconfig file in an 'if IMA' block. This also allows removing the existing direct dependencies.
--- security/integrity/ima/Kconfig | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)
security/integrity/ima/Kconfig +6 -12
@@ -29,9 +29,11 @@ config IMA to learn more about IMA. If unsure, say N. +if IMA + config IMA_KEXEC bool "Enable carrying the IMA measurement list across a soft boot" - depends on IMA && TCG_TPM && HAVE_IMA_KEXEC + depends on TCG_TPM && HAVE_IMA_KEXEC default n help TPM PCRs are only reset on a hard reboot. In order to validate
@@ -43,7 +45,6 @@ config IMA_KEXEC config IMA_MEASURE_PCR_IDX int - depends on IMA range 8 14 default 10 help
@@ -53,7 +54,7 @@ config IMA_MEASURE_PCR_IDX config IMA_LSM_RULES bool - depends on IMA && AUDIT && (SECURITY_SELINUX || SECURITY_SMACK || SECURITY_APPARMOR) + depends on AUDIT && (SECURITY_SELINUX || SECURITY_SMACK || SECURITY_APPARMOR) default y help Disabling this option will disregard LSM based policy rules.
@@ -61,7 +62,6 @@ config IMA_LSM_RULES choice prompt "Default template" default IMA_NG_TEMPLATE - depends on IMA help Select the default IMA measurement template.
@@ -80,14 +80,12 @@ endchoice config IMA_DEFAULT_TEMPLATE string - depends on IMA default "ima-ng" if IMA_NG_TEMPLATE default "ima-sig" if IMA_SIG_TEMPLATE choice prompt "Default integrity hash algorithm" default IMA_DEFAULT_HASH_SHA1 - depends on IMA help Select the default hash algorithm used for the measurement list, integrity appraisal and audit log. The compiled default
@@ -117,7 +115,6 @@ endchoice config IMA_DEFAULT_HASH string - depends on IMA default "sha1" if IMA_DEFAULT_HASH_SHA1 default "sha256" if IMA_DEFAULT_HASH_SHA256 default "sha512" if IMA_DEFAULT_HASH_SHA512
@@ -126,7 +123,6 @@ config IMA_DEFAULT_HASH config IMA_WRITE_POLICY bool "Enable multiple writes to the IMA policy" - depends on IMA default n help IMA policy can now be updated multiple times. The new rules get
@@ -137,7 +133,6 @@ config IMA_WRITE_POLICY config IMA_READ_POLICY bool "Enable reading back the current IMA policy" - depends on IMA default y if IMA_WRITE_POLICY default n if !IMA_WRITE_POLICY help
@@ -147,7 +142,6 @@ config IMA_READ_POLICY config IMA_APPRAISE bool "Appraise integrity measurements" - depends on IMA default n help This option enables local measurement integrity appraisal.
@@ -303,7 +297,6 @@ config IMA_APPRAISE_SIGNED_INIT config IMA_MEASURE_ASYMMETRIC_KEYS bool - depends on IMA depends on ASYMMETRIC_PUBLIC_KEY_SUBTYPE=y default y
@@ -322,7 +315,8 @@ config IMA_SECURE_AND_OR_TRUSTED_BOOT config IMA_DISABLE_HTABLE bool "Disable htable to allow measurement of duplicate records" - depends on IMA default n help This option disables htable to allow measurement of duplicate records. + +endif
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 75/162 wifi: iwlwifi: dbg_ini: fix structure packing
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
[ Upstream commit 424c82e8ad56756bb98b08268ffcf68d12d183eb ]
The iwl_fw_ini_error_dump_range structure has conflicting alignment requirements for the inner union and the outer struct:
In file included from drivers/net/wireless/intel/iwlwifi/fw/dbg.c:9:drivers/net/wireless/intel/iwlwifi/fw/error-dump.h:312:2: error: field within 'struct iwl_fw_ini_error_dump_range' is less aligned than 'union iwl_fw_ini_error_dump_range::(anonymous at drivers/net/wireless/intel/iwlwifi/fw/error-dump.h:312:2)' and is usually due to 'struct iwl_fw_ini_error_dump_range' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access]
union {As the original intention was apparently to make the entire structure unaligned, mark the innermost members the same way so the union becomes packed as well.
--- drivers/net/wireless/intel/iwlwifi/fw/error-dump.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/intel/iwlwifi/fw/error-dump.h +3 -3
@@ -295,9 +295,9 @@ struct iwl_fw_ini_fifo_hdr {struct iwl_fw_ini_error_dump_range {__le32 range_data_size;union { -__le32 internal_base_addr; -__le64 dram_base_addr; -__le32 page_num; + __le32 internal_base_addr __packed; + __le64 dram_base_addr __packed; + __le32 page_num __packed;struct iwl_fw_ini_fifo_hdr fifo_hdr;struct iwl_cmd_header fw_pkt_hdr; };
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 76/162 wifi: iwlwifi: mvm: Fix a memory corruption issue
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe JAILLET <[email protected]>
[ Upstream commit 8ba438ef3cacc4808a63ed0ce24d4f0942cfe55d ]
A few lines above, space is kzalloc()'ed for:
sizeof(struct iwl_nvm_data) + sizeof(struct ieee80211_channel) + sizeof(struct ieee80211_rate)
'mvm->nvm_data' is a 'struct iwl_nvm_data', so it is fine.
At the end of this structure, there is the 'channels' flex array. Each element is of type 'struct ieee80211_channel'.
So only 1 element is allocated in this array.
When doing:
mvm->nvm_data->bands[0].channels = mvm->nvm_data->channels;
We point at the first element of the 'channels' flex array. So this is fine.
However, when doing:
mvm->nvm_data->bands[0].bitrates =
(void *)((u8 *)mvm->nvm_data->channels + 1);
because of the "(u8 *)" cast, we add only 1 to the address of the beginning of the flex array.
It is likely that we want point at the 'struct ieee80211_rate' allocated just after.
Remove the spurious casting so that the pointer arithmetic works as expected.
--- drivers/net/wireless/intel/iwlwifi/mvm/fw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/mvm/fw.c +1 -1
@@ -796,7 +796,7 @@ int iwl_run_init_mvm_ucode(struct iwl_mvm *mvm) mvm->nvm_data->bands[0 ].n_channels =1 ; mvm->nvm_data->bands[0 ].n_bitrates =1 ; mvm->nvm_data->bands[0 ].bitrates = - (void *)((u8 *)mvm->nvm_data->channels +1 ); + (void *)(mvm->nvm_data->channels +1 ); mvm->nvm_data->bands[0 ].bitrates->hw_value =10 ; }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 77/162 wifi: cfg80211: hold wiphy lock in auto-disconnect
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit e9da6df7492a981b071bafd169fb4c35b45f5ebf ]
Most code paths in cfg80211 already hold the wiphy lock, mostly by virtue of being called from nl80211, so make the auto-disconnect worker also hold it, aligning the locking promises between different parts of cfg80211.
Stable-dep-of: 37c20b2effe9 ("wifi: cfg80211: fix cqm_config access race")
--- net/wireless/core.c | 6 ++---- net/wireless/sme.c | 4 +++- 2 files changed, 5 insertions(+), 5 deletions(-)
net/wireless/core.c +2 -4
@@ -1162,10 +1162,6 @@ static void _cfg80211_unregister_wdev(struct wireless_dev *wdev,kfree_sensitive (wdev->wext.keys); wdev->wext.keys =NULL ;#endif -/* only initialized if we have a netdev */ -if (wdev->netdev) -flush_work (&wdev->disconnect_wk); -cfg80211_cqm_config_free (wdev);/*
@@ -1439,6 +1435,8 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb,cfg80211_leave (rdev, wdev);cfg80211_remove_links (wdev);wiphy_unlock (&rdev->wiphy); +/* since we just did cfg80211_leave() nothing to do there */ +cancel_work_sync (&wdev->disconnect_wk);break ;case NETDEV_DOWN :wiphy_lock (&rdev->wiphy);
net/wireless/sme.c +3 -1
@@ -5,7 +5,7 @@* (for nl80211's connect() and wext) * * Copyright 2009 Johannes Berg <[email protected]> -* Copyright (C) 2009, 2020, 2022 Intel Corporation. All rights reserved. +* Copyright (C) 2009, 2020, 2022-2023 Intel Corporation. All rights reserved. * Copyright 2017 Intel Deutschland GmbH */
@@ -1555,6 +1555,7 @@ void cfg80211_autodisconnect_wk(struct work_struct *work) container_of(work, struct wireless_dev, disconnect_wk);struct cfg80211_registered_device *rdev =wiphy_to_rdev (wdev->wiphy); +wiphy_lock (wdev->wiphy);wdev_lock (wdev);if (wdev->conn_owner_nlportid) {
@@ -1593,4 +1594,5 @@ void cfg80211_autodisconnect_wk(struct work_struct *work) }wdev_unlock (wdev); +wiphy_unlock (wdev->wiphy); }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 78/162 wifi: cfg80211: move wowlan disable under locks
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit a993df0f9143e63eca38c96a30daf08db99a98a3 ]
This is a driver callback, and the driver should be able to assume that it's called with the wiphy lock held. Move the call up so that's true, it has no other effect since the device is already unregistering and we cannot reach this function through other paths.
Stable-dep-of: 37c20b2effe9 ("wifi: cfg80211: fix cqm_config access race")
--- net/wireless/core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/wireless/core.c +4 -4
@@ -1049,6 +1049,10 @@ void wiphy_unregister(struct wiphy *wiphy) cfg80211_rdev_list_generation++;device_del (&rdev->wiphy.dev); +#ifdef CONFIG_PM +if (rdev->wiphy.wowlan_config && rdev->ops->set_wakeup) +rdev_set_wakeup (rdev, false); +#endif wiphy_unlock (&rdev->wiphy);rtnl_unlock ();
@@ -1064,10 +1068,6 @@ void wiphy_unregister(struct wiphy *wiphy)flush_work (&rdev->mgmt_registrations_update_wk);flush_work (&rdev->background_cac_abort_wk); -#ifdef CONFIG_PM -if (rdev->wiphy.wowlan_config && rdev->ops->set_wakeup) -rdev_set_wakeup (rdev, false); -#endif cfg80211_rdev_free_wowlan (rdev);cfg80211_rdev_free_coalesce (rdev); }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 79/162 wifi: cfg80211: add a work abstraction with special semantics
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit a3ee4dc84c4e9d14cb34dad095fd678127aca5b6 ]
Add a work abstraction at the cfg80211 level that will always hold the wiphy_lock() for any work executed and therefore also can be canceled safely (without waiting) while holding that. This improves on what we do now as with the new wiphy works we don't have to worry about locking while cancelling them safely.
Also, don't let such works run while the device is suspended, since they'll likely need to interact with the device. Flush them before suspend though.
Stable-dep-of: 37c20b2effe9 ("wifi: cfg80211: fix cqm_config access race")
--- include/net/cfg80211.h | 95 ++++++++++++++++++++++++++++++-- net/wireless/core.c | 122 +++++++++++++++++++++++++++++++++++++++++ net/wireless/core.h | 7 +++ net/wireless/sysfs.c | 8 ++- 4 files changed, 227 insertions(+), 5 deletions(-)
include/net/cfg80211.h +91 -4
@@ -5621,12 +5621,17 @@ struct cfg80211_cqm_config;* wiphy_lock - lock the wiphy * @wiphy: the wiphy to lock * -* This is mostly exposed so it can be done around registering and -* unregistering netdevs that aren't created through cfg80211 calls, -* since that requires locking in cfg80211 when the notifiers is -* called, but that cannot differentiate which way it's called. +* This is needed around registering and unregistering netdevs that +* aren't created through cfg80211 calls, since that requires locking +* in cfg80211 when the notifiers is called, but that cannot +* differentiate which way it's called. +* +* It can also be used by drivers for their own purposes. * * When cfg80211 ops are called, the wiphy is already locked. +* +* Note that this makes sure that no workers that have been queued +* with wiphy_queue_work() are running. */ static inline void wiphy_lock(struct wiphy *wiphy) __acquires(&wiphy->mtx)
@@ -5646,6 +5651,88 @@ static inline void wiphy_unlock(struct wiphy *wiphy)mutex_unlock (&wiphy->mtx); } +struct wiphy_work ; +typedef void (*wiphy_work_func_t )(struct wiphy *,struct wiphy_work *); + +struct wiphy_work { +struct list_head entry; +wiphy_work_func_t func; +}; + +static inline void wiphy_work_init (struct wiphy_work *work, +wiphy_work_func_t func) +{ +INIT_LIST_HEAD (&work->entry); + work->func = func; +} + +/** +* wiphy_work_queue - queue work for the wiphy +* @wiphy: the wiphy to queue for +* @work: the work item +* +* This is useful for work that must be done asynchronously, and work +* queued here has the special property that the wiphy mutex will be +* held as if wiphy_lock() was called, and that it cannot be running +* after wiphy_lock() was called. Therefore, wiphy_cancel_work() can +* use just cancel_work() instead of cancel_work_sync(), it requires +* being in a section protected by wiphy_lock(). +*/ +void wiphy_work_queue (struct wiphy *wiphy,struct wiphy_work *work); + +/** +* wiphy_work_cancel - cancel previously queued work +* @wiphy: the wiphy, for debug purposes +* @work: the work to cancel +* +* Cancel the work *without* waiting for it, this assumes being +* called under the wiphy mutex acquired by wiphy_lock(). +*/ +void wiphy_work_cancel (struct wiphy *wiphy,struct wiphy_work *work); + +struct wiphy_delayed_work { +struct wiphy_work work; +struct wiphy *wiphy; +struct timer_list timer; +}; + +void wiphy_delayed_work_timer (struct timer_list *t); + +static inline void wiphy_delayed_work_init (struct wiphy_delayed_work *dwork, +wiphy_work_func_t func) +{ +timer_setup (&dwork->timer, wiphy_delayed_work_timer,0 ); +wiphy_work_init (&dwork->work, func); +} + +/** +* wiphy_delayed_work_queue - queue delayed work for the wiphy +* @wiphy: the wiphy to queue for +* @dwork: the delayable worker +* @delay: number of jiffies to wait before queueing +* +* This is useful for work that must be done asynchronously, and work +* queued here has the special property that the wiphy mutex will be +* held as if wiphy_lock() was called, and that it cannot be running +* after wiphy_lock() was called. Therefore, wiphy_cancel_work() can +* use just cancel_work() instead of cancel_work_sync(), it requires +* being in a section protected by wiphy_lock(). +*/ +void wiphy_delayed_work_queue (struct wiphy *wiphy, +struct wiphy_delayed_work *dwork, +unsigned long delay); + +/** +* wiphy_delayed_work_cancel - cancel previously queued delayed work +* @wiphy: the wiphy, for debug purposes +* @dwork: the delayed work to cancel +* +* Cancel the work *without* waiting for it, this assumes being +* called under the wiphy mutex acquired by wiphy_lock(). +*/ +void wiphy_delayed_work_cancel (struct wiphy *wiphy, +struct wiphy_delayed_work *dwork); +/** * struct wireless_dev - wireless device state *
net/wireless/core.c +122 -0
155 lines not on this page · raw message
net/wireless/core.h +7 -0
@@ -108,6 +108,12 @@ struct cfg80211_registered_device {/* lock for all wdev lists */ spinlock_t mgmt_registrations_lock; +struct work_struct wiphy_work; +struct list_head wiphy_work_list; +/* protects the list above */ +spinlock_t wiphy_work_lock; +bool suspended; +/* must be last because of the way we do wiphy_priv(), * and it should at least be aligned to NETDEV_ALIGN */ struct wiphy wiphy__aligned(NETDEV_ALIGN) ;
@@ -450,6 +456,7 @@ int cfg80211_change_iface(struct cfg80211_registered_device *rdev, struct net_device *dev, enum nl80211_iftype ntype, struct vif_params *params);void cfg80211_process_rdev_events (struct cfg80211_registered_device *rdev); +void cfg80211_process_wiphy_works (struct cfg80211_registered_device *rdev);void cfg80211_process_wdev_events (struct wireless_dev *wdev); bool cfg80211_does_bw_fit_range(const struct ieee80211_freq_range *freq_range,
net/wireless/sysfs.c +7 -1
@@ -5,7 +5,7 @@* * Copyright 2005-2006 Jiri Benc <[email protected]> * Copyright 2006 Johannes Berg <[email protected]> -* Copyright (C) 2020-2021 Intel Corporation +* Copyright (C) 2020-2021, 2023 Intel Corporation */ #include <linux/device.h>
@@ -105,14 +105,18 @@ static int wiphy_suspend(struct device *dev)cfg80211_leave_all (rdev);cfg80211_process_rdev_events (rdev); } +cfg80211_process_wiphy_works (rdev);if (rdev->ops->suspend) ret =rdev_suspend (rdev, rdev->wiphy.wowlan_config);if (ret ==1 ) {/* Driver refuse to configure wowlan */ cfg80211_leave_all (rdev);cfg80211_process_rdev_events (rdev); +cfg80211_process_wiphy_works (rdev); ret =rdev_suspend (rdev,NULL ); } +if (ret ==0 ) + rdev->suspended = true; }wiphy_unlock (&rdev->wiphy);rtnl_unlock ();
@@ -132,6 +136,8 @@ static int wiphy_resume(struct device *dev)wiphy_lock (&rdev->wiphy);if (rdev->wiphy.registered && rdev->ops->resume) ret =rdev_resume (rdev); + rdev->suspended = false; +schedule_work (&rdev->wiphy_work);wiphy_unlock (&rdev->wiphy);if (ret)
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 80/162 wifi: cfg80211: fix cqm_config access race
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 37c20b2effe987b806c8de6d12978e4ffeff026f ]
Max Schulze reports crashes with brcmfmac. The reason seems to be a race between userspace removing the CQM config and the driver calling cfg80211_cqm_rssi_notify(), where if the data is freed while cfg80211_cqm_rssi_notify() runs it will crash since it assumes wdev->cqm_config is set. This can't be fixed with a simple non-NULL check since there's nothing we can do for locking easily, so use RCU instead to protect the pointer, but that requires pulling the updates out into an asynchronous worker so they can sleep and call back into the driver.
Since we need to change the free anyway, also change it to go back to the old settings if changing the settings fails.
--- include/net/cfg80211.h | 3 +- net/wireless/core.c | 14 +++---- net/wireless/core.h | 7 +++- net/wireless/nl80211.c | 93 +++++++++++++++++++++++++++--------------- 4 files changed, 75 insertions(+), 42 deletions(-)
include/net/cfg80211.h +2 -1
@@ -5877,7 +5877,8 @@ struct wireless_dev { } wext;#endif -struct cfg80211_cqm_config *cqm_config; +struct wiphy_work cqm_rssi_work; +struct cfg80211_cqm_config __rcu *cqm_config;struct list_head pmsr_list;spinlock_t pmsr_lock;
net/wireless/core.c +7 -7
@@ -1176,16 +1176,11 @@ void wiphy_rfkill_set_hw_state_reason(struct wiphy *wiphy, bool blocked, }EXPORT_SYMBOL (wiphy_rfkill_set_hw_state_reason); -void cfg80211_cqm_config_free (struct wireless_dev *wdev) -{ -kfree (wdev->cqm_config); - wdev->cqm_config =NULL ; -} -static void _cfg80211_unregister_wdev (struct wireless_dev *wdev,bool unregister_netdev) {struct cfg80211_registered_device *rdev =wiphy_to_rdev (wdev->wiphy); +struct cfg80211_cqm_config *cqm_config;unsigned int link_id;ASSERT_RTNL ();
@@ -1224,7 +1219,10 @@ static void _cfg80211_unregister_wdev(struct wireless_dev *wdev,kfree_sensitive (wdev->wext.keys); wdev->wext.keys =NULL ;#endif -cfg80211_cqm_config_free (wdev); +wiphy_work_cancel (wdev->wiphy, &wdev->cqm_rssi_work); +/* deleted from the list, so can't be found from nl80211 any more */ + cqm_config =rcu_access_pointer (wdev->cqm_config); +kfree_rcu (cqm_config, rcu_head);/* * Ensure that all events have been processed and
@@ -1376,6 +1374,8 @@ void cfg80211_init_wdev(struct wireless_dev *wdev) wdev->wext.connect.auth_type =NL80211_AUTHTYPE_AUTOMATIC ;#endif +wiphy_work_init (&wdev->cqm_rssi_work, cfg80211_cqm_rssi_notify_work); +if (wdev->wiphy->flags &WIPHY_FLAG_PS_ON_BY_DEFAULT ) wdev->ps = true;else
net/wireless/core.h +5 -2
@@ -293,12 +293,17 @@ struct cfg80211_beacon_registration { };struct cfg80211_cqm_config { +struct rcu_head rcu_head;u32 rssi_hyst;s32 last_rssi_event_value; +enum nl80211_cqm_rssi_threshold_event last_rssi_event_type;int n_rssi_thresholds;s32 rssi_thresholds[]; }; +void cfg80211_cqm_rssi_notify_work (struct wiphy *wiphy, +struct wiphy_work *work); +void cfg80211_destroy_ifaces (struct cfg80211_registered_device *rdev);/* free object */
@@ -563,8 +568,6 @@ cfg80211_bss_update(struct cfg80211_registered_device *rdev,#define CFG80211_DEV_WARN_ON (cond) ({bool __r = (cond); __r; })#endif -void cfg80211_cqm_config_free (struct wireless_dev *wdev); -void cfg80211_release_pmsr (struct wireless_dev *wdev,u32 portid);void cfg80211_pmsr_wdev_down (struct wireless_dev *wdev);void cfg80211_pmsr_free_wk (struct work_struct *work);
net/wireless/nl80211.c +61 -32
189 lines not on this page · raw message
Signature · 1 line
2.40.1
Re: [PATCH 6.1 003/162] ALSA: hda/tas2781: Add tas2781 HDA driver
In reply to Greg Kroah-HartmanQuoted 15 lines · Greg Kroah-Hartman
6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shenghao Ding <[email protected]>
[ Upstream commit
3babae915f4c15d76a5134e55806a1c1588e2865]Integrate tas2781 configs for Lenovo Laptops. All of the tas2781s in the laptop will be aggregated as one audio device. The code support realtek as the primary codec. Rename "struct
cs35l41_dev_name" to "structscodec_dev_name" for all other side codecs instead of the certain one.
Quoted 5 lines
Signed-off-by Shenghao Ding <[email protected]>Signed-off-by Takashi Iwai <[email protected]>Stable-dep-of:
41b07476da38("ALSA: hda/realtek - ALC287 Realtek I2S speaker platform support")Signed-off-by Sasha Levin <[email protected]>
I'm afraid this and related stuff doesn't fit with 6.1.y.
thanks,
Takashi
Quoted 162 lines
--- sound/pci/hda/patch_realtek.c | 88 +++++++++++++++++++++++++++++++++-- 1 file changed, 85 insertions(+), 3 deletions(-)sound/pci/hda/patch_realtek.c +85
-3@@ -6721,7 +6721,7 @@ static void comp_generic_playback_hook(struct hda_pcm_stream *hinfo, struct hda_ } } -struct cs35l41_dev_name { +struct scodec_dev_name {const char *bus;const char *hid;int index;@@ -6730,7 +6730,7 @@ struct cs35l41_dev_name {/* match the device name in a slightly relaxed manner */ static int comp_match_cs35l41_dev_name (struct device *dev,void *data) { -struct cs35l41_dev_name *p = data; +struct scodec_dev_name *p = data;const char *d =dev_name (dev);int n =strlen (p->bus);char tmp[32 ];@@ -6746,12 +6746,32 @@ static int comp_match_cs35l41_dev_name(struct device *dev, void *data)return !strcmp (d + n, tmp); } +static int comp_match_tas2781_dev_name (struct device *dev, +void *data) +{ +struct scodec_dev_name *p = data; +const char *d =dev_name (dev); +int n =strlen (p->bus); +char tmp[32 ]; + +/* check the bus name */ +if (strncmp (d, p->bus, n)) +return 0 ; +/* skip the bus number */ +if (isdigit (d[n])) + n++; +/* the rest must be exact matching */ +snprintf (tmp,sizeof (tmp),"-%s:00" , p->hid); + +return !strcmp (d + n, tmp); +} +static void cs35l41_generic_fixup (struct hda_codec *cdc,int action,const char *bus,const char *hid,int count) {struct device *dev =hda_codec_dev (cdc);struct alc_spec *spec = cdc->spec; -struct cs35l41_dev_name *rec; +struct scodec_dev_name *rec;int ret, i;switch (action) {@@ -6776,6 +6796,41 @@ static void cs35l41_generic_fixup(struct hda_codec *cdc, int action, const char } } +static void tas2781_generic_fixup (struct hda_codec *cdc,int action, +const char *bus,const char *hid) +{ +struct device *dev =hda_codec_dev (cdc); +struct alc_spec *spec = cdc->spec; +struct scodec_dev_name *rec; +int ret; + +switch (action) { +case HDA_FIXUP_ACT_PRE_PROBE : + rec =devm_kmalloc (dev,sizeof (*rec),GFP_KERNEL ); +if (!rec) +return ; + rec->bus = bus; + rec->hid = hid; + rec->index =0 ; + spec->comps[0 ].codec = cdc; +component_match_add (dev, &spec->match, + comp_match_tas2781_dev_name, rec); + ret =component_master_add_with_match (dev, &comp_master_ops, + spec->match); +if (ret) +codec_err (cdc, +"Fail to register component aggregator %d\n" , + ret); +else + spec->gen.pcm_playback_hook = + comp_generic_playback_hook; +break ; +case HDA_FIXUP_ACT_FREE : +component_master_del (dev, &comp_master_ops); +break ; + } +} +static void cs35l41_fixup_i2c_two (struct hda_codec *cdc,const struct hda_fixup *fix,int action) {cs35l41_generic_fixup (cdc, action,"i2c" ,"CSC3551" ,2 );@@ -6803,6 +6858,12 @@ static void alc287_fixup_legion_16ithg6_speakers(struct hda_codec *cdc, const stcs35l41_generic_fixup (cdc, action,"i2c" ,"CLSA0101" ,2 ); } +static void tas2781_fixup_i2c (struct hda_codec *cdc, +const struct hda_fixup *fix,int action) +{ +tas2781_generic_fixup (cdc, action,"i2c" ,"TIAS2781" ); +} +/* for alc295_fixup_hp_top_speakers */ #include "hp_x360_helper.c" @@ -7227,6 +7288,7 @@ enum {ALC295_FIXUP_DELL_INSPIRON_TOP_SPEAKERS ,ALC236_FIXUP_DELL_DUAL_CODECS ,ALC287_FIXUP_CS35L41_I2C_2_THINKPAD_ACPI , + ALC287_FIXUP_TAS2781_I2C, };/* A special fixup for Lenovo C940 and Yoga Duet 7; @@ -9296,6 +9358,12 @@ static const struct hda_fixup alc269_fixups[] = { .chained = true, .chain_id = ALC269_FIXUP_THINKPAD_ACPI, }, + [ALC287_FIXUP_TAS2781_I2C] = { + .type = HDA_FIXUP_FUNC, + .v.func = tas2781_fixup_i2c, + .chained = true, + .chain_id = ALC269_FIXUP_THINKPAD_ACPI, + }, }; static const struct snd_pci_quirk alc269_fixup_tbl[] = {@@ -9867,6 +9935,20 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {SND_PCI_QUIRK (0x17aa ,0x3853 ,"Lenovo Yoga 7 15ITL5" ,ALC287_FIXUP_YOGA7_14ITL_SPEAKERS ),SND_PCI_QUIRK (0x17aa ,0x3855 ,"Legion 7 16ITHG6" ,ALC287_FIXUP_LEGION_16ITHG6 ),SND_PCI_QUIRK (0x17aa ,0x3869 ,"Lenovo Yoga7 14IAL7" ,ALC287_FIXUP_YOGA9_14IAP7_BASS_SPK_PIN ), +SND_PCI_QUIRK (0x17aa ,0x387d ,"Yoga S780-16 pro Quad AAC" ,ALC287_FIXUP_TAS2781_I2C ), +SND_PCI_QUIRK (0x17aa ,0x387e ,"Yoga S780-16 pro Quad YC" ,ALC287_FIXUP_TAS2781_I2C ), +SND_PCI_QUIRK (0x17aa ,0x3881 ,"YB9 dual powe mode2 YC" ,ALC287_FIXUP_TAS2781_I2C ), +SND_PCI_QUIRK (0x17aa ,0x3884 ,"Y780 YG DUAL" ,ALC287_FIXUP_TAS2781_I2C ), +SND_PCI_QUIRK (0x17aa ,0x3886 ,"Y780 VECO DUAL" ,ALC287_FIXUP_TAS2781_I2C ), +SND_PCI_QUIRK (0x17aa ,0x38a7 ,"Y780P AMD YG dual" ,ALC287_FIXUP_TAS2781_I2C ), +SND_PCI_QUIRK (0x17aa ,0x38a8 ,"Y780P AMD VECO dual" ,ALC287_FIXUP_TAS2781_I2C ), +SND_PCI_QUIRK (0x17aa ,0x38ba ,"Yoga S780-14.5 Air AMD quad YC" ,ALC287_FIXUP_TAS2781_I2C ), +SND_PCI_QUIRK (0x17aa ,0x38bb ,"Yoga S780-14.5 Air AMD quad AAC" ,ALC287_FIXUP_TAS2781_I2C ), +SND_PCI_QUIRK (0x17aa ,0x38be ,"Yoga S980-14.5 proX YC Dual" ,ALC287_FIXUP_TAS2781_I2C ), +SND_PCI_QUIRK (0x17aa ,0x38bf ,"Yoga S980-14.5 proX LX Dual" ,ALC287_FIXUP_TAS2781_I2C ), +SND_PCI_QUIRK (0x17aa ,0x38c3 ,"Y980 DUAL" ,ALC287_FIXUP_TAS2781_I2C ), +SND_PCI_QUIRK (0x17aa ,0x38cb ,"Y790 YG DUAL" ,ALC287_FIXUP_TAS2781_I2C ), +SND_PCI_QUIRK (0x17aa ,0x38cd ,"Y790 VECO DUAL" ,ALC287_FIXUP_TAS2781_I2C ),SND_PCI_QUIRK (0x17aa ,0x3902 ,"Lenovo E50-80" ,ALC269_FIXUP_DMIC_THINKPAD_ACPI ),SND_PCI_QUIRK (0x17aa ,0x3977 ,"IdeaPad S210" ,ALC283_FIXUP_INT_MIC ), SND_PCI_QUIRK(0x17aa, 0x3978, "Lenovo B50-70", ALC269_FIXUP_DMIC_THINKPAD_ACPI),Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 81/162 wifi: cfg80211: add missing kernel-doc for cqm_rssi_work
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit d1383077c225ceb87ac7a3b56b2c505193f77ed7 ]
As reported by Stephen, I neglected to add the kernel-doc for the new struct member. Fix that.
--- include/net/cfg80211.h | 1 + 1 file changed, 1 insertion(+)
include/net/cfg80211.h +1 -0
@@ -5805,6 +5805,7 @@ void wiphy_delayed_work_cancel(struct wiphy *wiphy,* @event_lock: (private) lock for event list * @owner_nlportid: (private) owner socket port ID * @nl_owner_dead: (private) owner socket went away +* @cqm_rssi_work: (private) CQM RSSI reporting work * @cqm_config: (private) nl80211 RSSI monitor state * @pmsr_list: (private) peer measurement requests * @pmsr_lock: (private) peer measurements requests/results lock
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 72/162 HID: sony: Fix a potential memory leak in sony_probe()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe JAILLET <[email protected]>
[ Upstream commit e1cd4004cde7c9b694bbdd8def0e02288ee58c74 ]
If an error occurs after a successful usb_alloc_urb() call, usb_free_urb() should be called.
--- drivers/hid/hid-sony.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/hid/hid-sony.c +3 -0
@@ -3074,6 +3074,9 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)return ret; err: +if (sc->ghl_urb) +usb_free_urb (sc->ghl_urb); +hid_hw_stop (hdev);return ret; }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 102/162 bpf: tcp_read_skb needs to pop skb regardless of seq
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Fastabend <[email protected]>
[ Upstream commit 9b7177b1df64b8d7f85700027c324aadd6aded00 ]
Before fix e5c6de5fa0258 tcp_read_skb() would increment the tp->copied-seq value. This (as described in the commit) would cause an error for apps because once that is incremented the application might believe there is no data to be read. Then some apps would stall or abort believing no data is available.
However, the fix is incomplete because it introduces another issue in the skb dequeue. The loop does tcp_recv_skb() in a while loop to consume as many skbs as possible. The problem is the call is ...
tcp_recv_skb(sk, seq, &offset)
... where 'seq' is:
u32 seq = tp->copied_seq;
Now we can hit a case where we've yet incremented copied_seq from BPF side, but then tcp_recv_skb() fails this test ...
if (offset < skb->len || (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN))
... so that instead of returning the skb we call tcp_eat_recv_skb() which frees the skb. This is because the routine believes the SKB has been collapsed per comment:
/* This looks weird, but this can happen if TCP collapsing
* splitted a fat GRO packet, while we released socket lock
* in skb_splice_bits()
*/
This can't happen here we've unlinked the full SKB and orphaned it. Anyways it would confuse any BPF programs if the data were suddenly moved underneath it.
To fix this situation do simpler operation and just skb_peek() the data of the queue followed by the unlink. It shouldn't need to check this condition and tcp_read_skb() reads entire skbs so there is no need to handle the 'offset!=0' case as we would see in tcp_read_sock().
--- net/ipv4/tcp.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
net/ipv4/tcp.c +2 -8
@@ -1755,16 +1755,13 @@ EXPORT_SYMBOL(tcp_read_sock);int tcp_read_skb (struct sock *sk,skb_read_actor_t recv_actor) { -struct tcp_sock *tp =tcp_sk (sk); -u32 seq = tp->copied_seq;struct sk_buff *skb;int copied =0 ; -u32 offset;if (sk->sk_state ==TCP_LISTEN )return -ENOTCONN ; -while ((skb =tcp_recv_skb (sk, seq, &offset)) !=NULL ) { +while ((skb =skb_peek (&sk->sk_receive_queue)) !=NULL ) {u8 tcp_flags;int used;
@@ -1777,13 +1774,10 @@ int tcp_read_skb(struct sock *sk, skb_read_actor_t recv_actor) copied = used;break ; } - seq += used; copied += used; -if (tcp_flags &TCPHDR_FIN ) { - ++seq; +if (tcp_flags &TCPHDR_FIN )break ; - } }return copied; }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 111/162 ipv4, ipv6: Fix handling of transhdrlen in __ip{,6}_append_data()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit 9d4c75800f61e5d75c1659ba201b6c0c7ead3070 ]
Including the transhdrlen in length is a problem when the packet is partially filled (e.g. something like send(MSG_MORE) happened previously) when appending to an IPv4 or IPv6 packet as we don't want to repeat the transport header or account for it twice. This can happen under some circumstances, such as splicing into an L2TP socket.
The symptom observed is a warning in __ip6_append_data():
WARNING: CPU: 1 PID: 5042 at net/ipv6/ip6_output.c:1800 __ip6_append_data.isra.0+0x1be8/0x47f0 net/ipv6/ip6_output.c:1800
that occurs when MSG_SPLICE_PAGES is used to append more data to an already partially occupied skbuff. The warning occurs when 'copy' is larger than the amount of data in the message iterator. This is because the requested length includes the transport header length when it shouldn't. This can be triggered by, for example:
sfd = socket(AF_INET6, SOCK_DGRAM, IPPROTO_L2TP);
bind(sfd, ...); // ::1
connect(sfd, ...); // ::1 port 7
send(sfd, buffer, 4100, MSG_MORE);
sendfile(sfd, dfd, NULL, 1024);Fix this by only adding transhdrlen into the length if the write queue is empty in l2tp_ip6_sendmsg(), analogously to how UDP does things.
l2tp_ip_sendmsg() looks like it won't suffer from this problem as it builds the UDP packet itself.
--- net/l2tp/l2tp_ip6.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/l2tp/l2tp_ip6.c +1 -1
@@ -510,7 +510,6 @@ static int l2tp_ip6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)*/ if (len >INT_MAX - transhdrlen)return -EMSGSIZE ; - ulen = len + transhdrlen;/* Mirror BSD error message compatibility */ if (msg->msg_flags &MSG_OOB )
@@ -631,6 +630,7 @@ static int l2tp_ip6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) back_from_confirm:lock_sock (sk); + ulen = len +skb_queue_empty (&sk->sk_write_queue) ? transhdrlen :0 ; err = ip6_append_data(sk, ip_generic_getfrag, msg, ulen, transhdrlen, &ipc6, &fl6, (struct rt6_info *)dst,
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 112/162 ptp: ocp: Fix error handling in ptp_ocp_device_init
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dinghao Liu <[email protected]>
[ Upstream commit caa0578c1d487d39e4bb947a1b4965417053b409 ]
When device_add() fails, ptp_ocp_dev_release() will be called after put_device(). Therefore, it seems that the ptp_ocp_dev_release() before put_device() is redundant.
--- drivers/ptp/ptp_ocp.c | 1 - 1 file changed, 1 deletion(-)
drivers/ptp/ptp_ocp.c +0 -1
@@ -3532,7 +3532,6 @@ ptp_ocp_device_init(struct ptp_ocp *bp, struct pci_dev *pdev)return 0 ; out: -ptp_ocp_dev_release (&bp->dev);put_device (&bp->dev);return err; }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 113/162 net: dsa: mv88e6xxx: Avoid EEPROM timeout when EEPROM is absent
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fabio Estevam <[email protected]>
[ Upstream commit 6ccf50d4d4741e064ba35511a95402c63bbe21a8 ]
Since commit 23d775f12dcd ("net: dsa: mv88e6xxx: Wait for EEPROM done before HW reset") the following error is seen on a imx8mn board with a 88E6320 switch:
mv88e6085 30be0000.ethernet-1:00: Timeout waiting for EEPROM done
This board does not have an EEPROM attached to the switch though.
This problem is well explained by Andrew Lunn:
"If there is an EEPROM, and the EEPROM contains a lot of data, it could be that when we perform a hardware reset towards the end of probe, it interrupts an I2C bus transaction, leaving the I2C bus in a bad state, and future reads of the EEPROM do not work.
The work around for this was to poll the EEInt status and wait for it to go true before performing the hardware reset.
However, we have discovered that for some boards which do not have an EEPROM, EEInt never indicates complete. As a result, mv88e6xxx_g1_wait_eeprom_done() spins for a second and then prints a warning.
We probably need a different solution than calling mv88e6xxx_g1_wait_eeprom_done(). The datasheet for 6352 documents the EEPROM Command register:
bit 15 is:
EEPROM Unit Busy. This bit must be set to a one to start an EEPROM operation (see EEOp below). Only one EEPROM operation can be executing at one time so this bit must be zero before setting it to a one. When the requested EEPROM operation completes this bit will automatically be cleared to a zero. The transition of this bit from a one to a zero can be used to generate an interrupt (the EEInt in Global 1, offset 0x00).
and more interesting is bit 11:
Register Loader Running. This bit is set to one whenever the register loader is busy executing instructions contained in the EEPROM."
Change to using mv88e6xxx_g2_eeprom_wait() to fix the timeout error when the EEPROM chip is not present.
--- drivers/net/dsa/mv88e6xxx/chip.c | 6 ++++-- drivers/net/dsa/mv88e6xxx/global1.c | 31 ----------------------------- drivers/net/dsa/mv88e6xxx/global1.h | 1 - drivers/net/dsa/mv88e6xxx/global2.c | 2 +- drivers/net/dsa/mv88e6xxx/global2.h | 1 + 5 files changed, 6 insertions(+), 35 deletions(-)
drivers/net/dsa/mv88e6xxx/chip.c +4 -2
@@ -3012,14 +3012,16 @@ static void mv88e6xxx_hardware_reset(struct mv88e6xxx_chip *chip)* from the wrong location resulting in the switch booting * to wrong mode and inoperable. */ -mv88e6xxx_g1_wait_eeprom_done (chip); +if (chip->info->ops->get_eeprom) +mv88e6xxx_g2_eeprom_wait (chip);gpiod_set_value_cansleep (gpiod,1 );usleep_range (10000 ,20000 );gpiod_set_value_cansleep (gpiod,0 );usleep_range (10000 ,20000 ); -mv88e6xxx_g1_wait_eeprom_done (chip); +if (chip->info->ops->get_eeprom) +mv88e6xxx_g2_eeprom_wait (chip); } }
drivers/net/dsa/mv88e6xxx/global1.c +0 -31
@@ -75,37 +75,6 @@ static int mv88e6xxx_g1_wait_init_ready(struct mv88e6xxx_chip *chip)return mv88e6xxx_g1_wait_bit (chip,MV88E6XXX_G1_STS , bit,1 ); } -void mv88e6xxx_g1_wait_eeprom_done (struct mv88e6xxx_chip *chip) -{ -const unsigned long timeout = jiffies +1 *HZ ; -u16 val; -int err; - -/* Wait up to 1 second for the switch to finish reading the -* EEPROM. -*/ -while (time_before (jiffies, timeout)) { - err =mv88e6xxx_g1_read (chip,MV88E6XXX_G1_STS , &val); -if (err) { -dev_err (chip->dev,"Error reading status" ); -return ; - } - -/* If the switch is still resetting, it may not -* respond on the bus, and so MDIO read returns -* 0xffff. Differentiate between that, and waiting for -* the EEPROM to be done by bit 0 being set. -*/ -if (val !=0xffff && - val &BIT (MV88E6XXX_G1_STS_IRQ_EEPROM_DONE )) -return ; - -usleep_range (1000 ,2000 ); - } - -dev_err (chip->dev,"Timeout waiting for EEPROM done" ); -} -/* Offset 0x01: Switch MAC Address Register Bytes 0 & 1 * Offset 0x02: Switch MAC Address Register Bytes 2 & 3 * Offset 0x03: Switch MAC Address Register Bytes 4 & 5
drivers/net/dsa/mv88e6xxx/global1.h +0 -1
@@ -281,7 +281,6 @@ int mv88e6xxx_g1_set_switch_mac(struct mv88e6xxx_chip *chip, u8 *addr);int mv88e6185_g1_reset (struct mv88e6xxx_chip *chip);int mv88e6352_g1_reset (struct mv88e6xxx_chip *chip);int mv88e6250_g1_reset (struct mv88e6xxx_chip *chip); -void mv88e6xxx_g1_wait_eeprom_done (struct mv88e6xxx_chip *chip);int mv88e6185_g1_ppu_enable (struct mv88e6xxx_chip *chip);int mv88e6185_g1_ppu_disable (struct mv88e6xxx_chip *chip);
drivers/net/dsa/mv88e6xxx/global2.c +1 -1
@@ -340,7 +340,7 @@ int mv88e6xxx_g2_pot_clear(struct mv88e6xxx_chip *chip)* Offset 0x15: EEPROM Addr (for 8-bit data access) */ -static int mv88e6xxx_g2_eeprom_wait (struct mv88e6xxx_chip *chip) +int mv88e6xxx_g2_eeprom_wait (struct mv88e6xxx_chip *chip) {int bit =__bf_shf (MV88E6XXX_G2_EEPROM_CMD_BUSY );int err;
drivers/net/dsa/mv88e6xxx/global2.h +1 -0
@@ -359,6 +359,7 @@ int mv88e6xxx_g2_trunk_clear(struct mv88e6xxx_chip *chip);int mv88e6xxx_g2_device_mapping_write (struct mv88e6xxx_chip *chip,int target,int port); +int mv88e6xxx_g2_eeprom_wait (struct mv88e6xxx_chip *chip);extern const struct mv88e6xxx_irq_ops mv88e6097_watchdog_ops;extern const struct mv88e6xxx_irq_ops mv88e6250_watchdog_ops;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 114/162 ipv6: tcp: add a missing nf_reset_ct() in 3WHS handling
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Maximets <[email protected]>
[ Upstream commit 9593c7cb6cf670ef724d17f7f9affd7a8d2ad0c5 ]
Commit b0e214d21203 ("netfilter: keep conntrack reference until IPsecv6 policy checks are done") is a direct copy of the old commit b59c270104f0 ("[NETFILTER]: Keep conntrack reference until IPsec policy checks are done") but for IPv6. However, it also copies a bug that this old commit had. That is: when the third packet of 3WHS connection establishment contains payload, it is added into socket receive queue without the XFRM check and the drop of connection tracking context.
That leads to nf_conntrack module being impossible to unload as it waits for all the conntrack references to be dropped while the packet release is deferred in per-cpu cache indefinitely, if not consumed by the application.
The issue for IPv4 was fixed in commit 6f0012e35160 ("tcp: add a missing nf_reset_ct() in 3WHS handling") by adding a missing XFRM check and correctly dropping the conntrack context. However, the issue was introduced to IPv6 code afterwards. Fixing it the same way for IPv6 now.
--- net/ipv6/tcp_ipv6.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
net/ipv6/tcp_ipv6.c +7 -3
@@ -1644,9 +1644,12 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb)struct sock *nsk; sk = req->rsk_listener; - drop_reason =tcp_inbound_md5_hash (sk, skb, - &hdr->saddr, &hdr->daddr, -AF_INET6 , dif, sdif); +if (!xfrm6_policy_check (sk,XFRM_POLICY_IN , skb)) + drop_reason =SKB_DROP_REASON_XFRM_POLICY ; +else + drop_reason =tcp_inbound_md5_hash (sk, skb, + &hdr->saddr, &hdr->daddr, +AF_INET6 , dif, sdif);if (drop_reason) {sk_drops_add (sk, skb);reqsk_put (req);
@@ -1693,6 +1696,7 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb) } goto discard_and_relse; } +nf_reset_ct (skb);if (nsk == sk) {reqsk_put (req);tcp_v6_restore_cb (skb);
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 115/162 net: usb: smsc75xx: Fix uninit-value access in __smsc75xx_read_reg
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shigeru Yoshida <[email protected]>
[ Upstream commit e9c65989920f7c28775ec4e0c11b483910fb67b8 ]
syzbot reported the following uninit-value access issue:
=====================================================
BUG: KMSAN: uninit-value in smsc75xx_wait_ready drivers/net/usb/smsc75xx.c:975 [inline] BUG: KMSAN: uninit-value in smsc75xx_bind+0x5c9/0x11e0 drivers/net/usb/smsc75xx.c:1482 CPU: 0 PID: 8696 Comm: kworker/0:3 Not tainted 5.8.0-rc5-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: usb_hub_wq hub_event Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x21c/0x280 lib/dump_stack.c:118 kmsan_report+0xf7/0x1e0 mm/kmsan/kmsan_report.c:121 __msan_warning+0x58/0xa0 mm/kmsan/kmsan_instr.c:215 smsc75xx_wait_ready drivers/net/usb/smsc75xx.c:975 [inline] smsc75xx_bind+0x5c9/0x11e0 drivers/net/usb/smsc75xx.c:1482 usbnet_probe+0x1152/0x3f90 drivers/net/usb/usbnet.c:1737 usb_probe_interface+0xece/0x1550 drivers/usb/core/driver.c:374 really_probe+0xf20/0x20b0 drivers/base/dd.c:529 driver_probe_device+0x293/0x390 drivers/base/dd.c:701 __device_attach_driver+0x63f/0x830 drivers/base/dd.c:807 bus_for_each_drv+0x2ca/0x3f0 drivers/base/bus.c:431 __device_attach+0x4e2/0x7f0 drivers/base/dd.c:873 device_initial_probe+0x4a/0x60 drivers/base/dd.c:920 bus_probe_device+0x177/0x3d0 drivers/base/bus.c:491 device_add+0x3b0e/0x40d0 drivers/base/core.c:2680 usb_set_configuration+0x380f/0x3f10 drivers/usb/core/message.c:2032 usb_generic_driver_probe+0x138/0x300 drivers/usb/core/generic.c:241 usb_probe_device+0x311/0x490 drivers/usb/core/driver.c:272 really_probe+0xf20/0x20b0 drivers/base/dd.c:529 driver_probe_device+0x293/0x390 drivers/base/dd.c:701 __device_attach_driver+0x63f/0x830 drivers/base/dd.c:807 bus_for_each_drv+0x2ca/0x3f0 drivers/base/bus.c:431 __device_attach+0x4e2/0x7f0 drivers/base/dd.c:873 device_initial_probe+0x4a/0x60 drivers/base/dd.c:920 bus_probe_device+0x177/0x3d0 drivers/base/bus.c:491 device_add+0x3b0e/0x40d0 drivers/base/core.c:2680 usb_new_device+0x1bd4/0x2a30 drivers/usb/core/hub.c:2554 hub_port_connect drivers/usb/core/hub.c:5208 [inline] hub_port_connect_change drivers/usb/core/hub.c:5348 [inline] port_event drivers/usb/core/hub.c:5494 [inline] hub_event+0x5e7b/0x8a70 drivers/usb/core/hub.c:5576 process_one_work+0x1688/0x2140 kernel/workqueue.c:2269 worker_thread+0x10bc/0x2730 kernel/workqueue.c:2415 kthread+0x551/0x590 kernel/kthread.c:292 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293
Local variable ----buf.i87@smsc75xx_bind created at:
__smsc75xx_read_reg drivers/net/usb/smsc75xx.c:83 [inline] smsc75xx_wait_ready drivers/net/usb/smsc75xx.c:968 [inline] smsc75xx_bind+0x485/0x11e0 drivers/net/usb/smsc75xx.c:1482 __smsc75xx_read_reg drivers/net/usb/smsc75xx.c:83 [inline] smsc75xx_wait_ready drivers/net/usb/smsc75xx.c:968 [inline] smsc75xx_bind+0x485/0x11e0 drivers/net/usb/smsc75xx.c:1482
This issue is caused because usbnet_read_cmd() reads less bytes than requested (zero byte in the reproducer). In this case, 'buf' is not properly filled.
This patch fixes the issue by returning -ENODATA if usbnet_read_cmd() reads less bytes than requested.
--- drivers/net/usb/smsc75xx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/usb/smsc75xx.c +3 -1
@@ -90,7 +90,9 @@ static int __must_check __smsc75xx_read_reg(struct usbnet *dev, u32 index, ret =fn (dev,USB_VENDOR_REQUEST_READ_REGISTER ,USB_DIR_IN |USB_TYPE_VENDOR |USB_RECIP_DEVICE ,0 , index, &buf,4 ); -if (unlikely (ret <0 )) { +if (unlikely (ret <4 )) { + ret = ret <0 ? ret : -ENODATA ; +netdev_warn (dev->net,"Failed to read reg index 0x%08x: %d\n" , index, ret);return ret;
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 116/162 net: nfc: llcp: Add lock when modifying device list
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeremy Cline <[email protected]>
[ Upstream commit dfc7f7a988dad34c3bf4c053124fb26aa6c5f916 ]
The device list needs its associated lock held when modifying it, or the list could become corrupted, as syzbot discovered.
--- net/nfc/llcp_core.c | 2 ++ 1 file changed, 2 insertions(+)
net/nfc/llcp_core.c +2 -0
@@ -1636,7 +1636,9 @@ int nfc_llcp_register_device(struct nfc_dev *ndev)timer_setup (&local->sdreq_timer, nfc_llcp_sdreq_timer,0 );INIT_WORK (&local->sdreq_timeout_work, nfc_llcp_sdreq_timeout_work); +spin_lock (&llcp_devices_lock);list_add (&local->list, &llcp_devices); +spin_unlock (&llcp_devices_lock);return 0 ; }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 117/162 net: ethernet: ti: am65-cpsw: Fix error code in am65_cpsw_nuss_init_tx_chns()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 37d4f55567982e445f86dc0ff4ecfa72921abfe8 ]
This accidentally returns success, but it should return a negative error code.
--- drivers/net/ethernet/ti/am65-cpsw-nuss.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/ti/am65-cpsw-nuss.c +1 -0
@@ -1614,6 +1614,7 @@ static int am65_cpsw_nuss_init_tx_chns(struct am65_cpsw_common *common)if (tx_chn->irq <=0 ) {dev_err (dev,"Failed to get tx dma irq %d\n" , tx_chn->irq); + ret = tx_chn->irq ?: -ENXIO ; goto err; }
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 118/162 ibmveth: Remove condition to recompute TCP header checksum.
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Wilder <[email protected]>
[ Upstream commit 51e7a66666e0ca9642c59464ef8359f0ac604d41 ]
In some OVS environments the TCP pseudo header checksum may need to be recomputed. Currently this is only done when the interface instance is configured for "Trunk Mode". We found the issue also occurs in some Kubernetes environments, these environments do not use "Trunk Mode", therefor the condition is removed.
Performance tests with this change show only a fractional decrease in throughput (< 0.2%).
--- drivers/net/ethernet/ibm/ibmveth.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-)
drivers/net/ethernet/ibm/ibmveth.c +12 -13
@@ -1308,24 +1308,23 @@ static void ibmveth_rx_csum_helper(struct sk_buff *skb,* the user space for finding a flow. During this process, OVS computes * checksum on the first packet when CHECKSUM_PARTIAL flag is set. * -* So, re-compute TCP pseudo header checksum when configured for -* trunk mode. +* So, re-compute TCP pseudo header checksum. */ +if (iph_proto ==IPPROTO_TCP ) {struct tcphdr *tcph = (struct tcphdr *)(skb->data + iphlen); +if (tcph->check ==0x0000 ) {/* Recompute TCP pseudo header checksum */ -if (adapter->is_active_trunk) { - tcphdrlen = skb->len - iphlen; -if (skb_proto ==ETH_P_IP ) - tcph->check = - ~csum_tcpudp_magic (iph->saddr, - iph->daddr, tcphdrlen, iph_proto,0 ); -else if (skb_proto ==ETH_P_IPV6 ) - tcph->check = - ~csum_ipv6_magic (&iph6->saddr, - &iph6->daddr, tcphdrlen, iph_proto,0 ); - } + tcphdrlen = skb->len - iphlen; +if (skb_proto ==ETH_P_IP ) + tcph->check = + ~csum_tcpudp_magic (iph->saddr, + iph->daddr, tcphdrlen, iph_proto,0 ); +else if (skb_proto ==ETH_P_IPV6 ) + tcph->check = + ~csum_ipv6_magic (&iph6->saddr, + &iph6->daddr, tcphdrlen, iph_proto,0 );/* Setup SKB fields for checksum offload */ skb_partial_csum_set (skb, iphlen, offsetof(struct tcphdr , check));
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 119/162 netfilter: handle the connecting collision properly in nf_conntrack_proto_sctp
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xin Long <[email protected]>
[ Upstream commit 8e56b063c86569e51eed1c5681ce6361fa97fc7a ]
In Scenario A and B below, as the delayed INIT_ACK always changes the peer vtag, SCTP ct with the incorrect vtag may cause packet loss.
Scenario A: INIT_ACK is delayed until the peer receives its own INIT_ACK
192.168.1.2 > 192.168.1.1: [INIT] [init tag: 1328086772]
192.168.1.1 > 192.168.1.2: [INIT] [init tag: 1414468151]
192.168.1.2 > 192.168.1.1: [INIT ACK] [init tag: 1328086772]
192.168.1.1 > 192.168.1.2: [INIT ACK] [init tag: 1650211246] *
192.168.1.2 > 192.168.1.1: [COOKIE ECHO]
192.168.1.1 > 192.168.1.2: [COOKIE ECHO]
192.168.1.2 > 192.168.1.1: [COOKIE ACK]Scenario B: INIT_ACK is delayed until the peer completes its own handshake
192.168.1.2 > 192.168.1.1: sctp (1) [INIT] [init tag: 3922216408]
192.168.1.1 > 192.168.1.2: sctp (1) [INIT] [init tag: 144230885]
192.168.1.2 > 192.168.1.1: sctp (1) [INIT ACK] [init tag: 3922216408]
192.168.1.1 > 192.168.1.2: sctp (1) [COOKIE ECHO]
192.168.1.2 > 192.168.1.1: sctp (1) [COOKIE ACK]192.168.1.1 > 192.168.1.2: sctp (1) [INIT ACK] [init tag: 3914796021] *
This patch fixes it as below:
In SCTP_CID_INIT processing:
- clear ct->proto.sctp.init[!dir] if ct->proto.sctp.init[dir] && ct->proto.sctp.init[!dir]. (Scenario E)
- set ct->proto.sctp.init[dir].
In SCTP_CID_INIT_ACK processing:
- drop it if !ct->proto.sctp.init[!dir] && ct->proto.sctp.vtag[!dir] && ct->proto.sctp.vtag[!dir] != ih->init_tag. (Scenario B, Scenario C)
- drop it if ct->proto.sctp.init[dir] && ct->proto.sctp.init[!dir] && ct->proto.sctp.vtag[!dir] != ih->init_tag. (Scenario A)
In SCTP_CID_COOKIE_ACK processing:
- clear ct->proto.sctp.init[dir] and ct->proto.sctp.init[!dir]. (Scenario D)
Also, it's important to allow the ct state to move forward with cookie_echo and cookie_ack from the opposite dir for the collision scenarios.
There are also other Scenarios where it should allow the packet through, addressed by the processing above:
Scenario C: new CT is created by INIT_ACK.
Scenario D: start INIT on the existing ESTABLISHED ct.
Scenario E: start INIT after the old collision on the existing ESTABLISHED ct.
192.168.1.2 > 192.168.1.1: sctp (1) [INIT] [init tag: 3922216408] 192.168.1.1 > 192.168.1.2: sctp (1) [INIT] [init tag: 144230885] (both side are stopped, then start new connection again in hours) 192.168.1.2 > 192.168.1.1: sctp (1) [INIT] [init tag: 242308742]
--- include/linux/netfilter/nf_conntrack_sctp.h | 1 + net/netfilter/nf_conntrack_proto_sctp.c | 43 ++++++++++++++++----- 2 files changed, 34 insertions(+), 10 deletions(-)
include/linux/netfilter/nf_conntrack_sctp.h +1 -0
@@ -9,6 +9,7 @@ struct ip_ct_sctp {enum sctp_conntrack state;__be32 vtag[IP_CT_DIR_MAX ]; +u8 init[IP_CT_DIR_MAX ];u8 last_dir;u8 flags; };
net/netfilter/nf_conntrack_proto_sctp.c +33 -10
75 lines not on this page · raw message
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 120/162 selftests: netfilter: Test nf_tables audit logging
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Phil Sutter <[email protected]>
[ Upstream commit e8dbde59ca3fe925d0105bfb380e8429928b16dd ]
Compare NETFILTER_CFG type audit logs emitted from kernel upon ruleset modifications against expected output.
Stable-dep-of: 0d880dc6f032 ("netfilter: nf_tables: Deduplicate nft_register_obj audit logs")
--- tools/testing/selftests/netfilter/.gitignore | 1 + tools/testing/selftests/netfilter/Makefile | 4 +- .../selftests/netfilter/audit_logread.c | 165 ++++++++++++++++++ tools/testing/selftests/netfilter/config | 1 + .../testing/selftests/netfilter/nft_audit.sh | 108 ++++++++++++ 5 files changed, 277 insertions(+), 2 deletions(-) create mode 100644 tools/testing/selftests/netfilter/audit_logread.c create mode 100755 tools/testing/selftests/netfilter/nft_audit.sh
tools/testing/selftests/netfilter/.gitignore +1 -0
@@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only nf-queue connect_close +audit_logread
tools/testing/selftests/netfilter/Makefile +2 -2
@@ -6,13 +6,13 @@ TEST_PROGS := nft_trans_stress.sh nft_fib.sh nft_nat.sh bridge_brouter.sh \ nft_concat_range.sh nft_conntrack_helper.sh \ nft_queue.sh nft_meta.sh nf_nat_edemux.sh \ ipip-conntrack-mtu.sh conntrack_tcp_unreplied.sh \ - conntrack_vrf.sh nft_synproxy.sh rpath.sh + conntrack_vrf.sh nft_synproxy.sh rpath.sh nft_audit.sh HOSTPKG_CONFIG := pkg-config CFLAGS += $(shell $(HOSTPKG_CONFIG) --cflags libmnl 2>/dev/null) LDLIBS += $(shell $(HOSTPKG_CONFIG) --libs libmnl 2>/dev/null || echo -lmnl) -TEST_GEN_FILES = nf-queue connect_close +TEST_GEN_FILES = nf-queue connect_close audit_logread include ../lib.mk
tools/testing/selftests/netfilter/audit_logread.c new file +165 -0
165 lines not on this page · raw message
tools/testing/selftests/netfilter/config +1 -0
@@ -6,3 +6,4 @@ CONFIG_NFT_REDIR=m CONFIG_NFT_MASQ=m CONFIG_NFT_FLOW_OFFLOAD=m CONFIG_NF_CT_NETLINK=m +CONFIG_AUDIT=y
tools/testing/selftests/netfilter/nft_audit.sh new file +108 -0
108 lines not on this page · raw message
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 103/162 bpf, sockmap: Do not inc copied_seq when PEEK flag set
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Fastabend <[email protected]>
[ Upstream commit da9e915eaf5dadb1963b7738cdfa42ed55212445 ]
When data is peek'd off the receive queue we shouldn't considered it copied from tcp_sock side. When we increment copied_seq this will confuse tcp_data_ready() because copied_seq can be arbitrarily increased. From application side it results in poll() operations not waking up when expected.
Notice tcp stack without BPF recvmsg programs also does not increment copied_seq.
We broke this when we moved copied_seq into recvmsg to only update when actual copy was happening. But, it wasn't working correctly either before because the tcp_data_ready() tried to use the copied_seq value to see if data was read by user yet. See fixes tags.
--- net/ipv4/tcp_bpf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/ipv4/tcp_bpf.c +3 -1
@@ -217,6 +217,7 @@ static int tcp_bpf_recvmsg_parser(struct sock *sk, int *addr_len) {struct tcp_sock *tcp =tcp_sk (sk); +int peek = flags &MSG_PEEK ;u32 seq = tcp->copied_seq;struct sk_psock *psock;int copied =0 ;
@@ -306,7 +307,8 @@ static int tcp_bpf_recvmsg_parser(struct sock *sk, copied = -EAGAIN ; } out: -WRITE_ONCE (tcp->copied_seq, seq); +if (!peek) +WRITE_ONCE (tcp->copied_seq, seq);tcp_rcv_space_adjust (sk);if (copied >0 )__tcp_cleanup_rbuf (sk, copied);
Signature · 1 line
2.40.1
Greg Kroah-Hartman
maintainerPATCH 121/162 selftests: netfilter: Extend nft_audit.sh
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Phil Sutter <[email protected]>
[ Upstream commit 203bb9d39866d3c5a8135433ce3742fe4f9d5741 ]
Add tests for sets and elements and deletion of all kinds. Also reorder rule reset tests: By moving the bulk rule add command up, the two 'reset rules' tests become identical.
While at it, fix for a failing bulk rule add test's error status getting lost due to its use in a pipe. Avoid this by using a temporary file.
Headings in diff output for failing tests contain no useful data, strip them.
Stable-dep-of: 0d880dc6f032 ("netfilter: nf_tables: Deduplicate nft_register_obj audit logs")
--- .../testing/selftests/netfilter/nft_audit.sh | 97 ++++++++++++++++--- 1 file changed, 81 insertions(+), 16 deletions(-)
tools/testing/selftests/netfilter/nft_audit.sh +81 -16
@@ -12,10 +12,11 @@ nft --version >/dev/null 2>&1 || { } logfile=$(mktemp) +rulefile=$(mktemp) echo "logging into $logfile" ./audit_logread >"$logfile" & logread_pid=$! -trap 'kill $logread_pid; rm -f $logfile' EXIT +trap 'kill $logread_pid; rm -f $logfile $rulefile' EXIT exec 3<"$logfile" do_test() { # (cmd, log)
@@ -26,12 +27,14 @@ do_test() { # (cmd, log) res=$(diff -a -u <(echo "$2") - <&3) [ $? -eq 0 ] && { echo "OK"; return; } echo "FAIL" - echo "$res" - ((RC++)) + grep -v '^\(---\|+++\|@@\)' <<< "$res" + ((RC--)) } nft flush ruleset +# adding tables, chains and rules + for table in t1 t2; do do_test "nft add table $table" \ "table=$table family=2 entries=1 op=nft_register_table"
@@ -62,6 +65,28 @@ for table in t1 t2; do "table=$table family=2 entries=6 op=nft_register_rule" done +for ((i = 0; i < 500; i++)); do + echo "add rule t2 c3 counter accept comment \"rule $i\"" +done >$rulefile +do_test "nft -f $rulefile" \ +'table=t2 family=2 entries=500 op=nft_register_rule' + +# adding sets and elements + +settype='type inet_service; counter' +setelem='{ 22, 80, 443 }' +setblock="{ $settype; elements = $setelem; }" +do_test "nft add set t1 s $setblock" \ +"table=t1 family=2 entries=4 op=nft_register_set" + +do_test "nft add set t1 s2 $setblock; add set t1 s3 { $settype; }" \ +"table=t1 family=2 entries=5 op=nft_register_set" + +do_test "nft add element t1 s3 $setelem" \ +"table=t1 family=2 entries=3 op=nft_register_setelem" + +# resetting rules + do_test 'nft reset rules t1 c2' \ 'table=t1 family=2 entries=3 op=nft_reset_rule'
@@ -70,19 +95,6 @@ do_test 'nft reset rules table t1' \ table=t1 family=2 entries=3 op=nft_reset_rule table=t1 family=2 entries=3 op=nft_reset_rule' -do_test 'nft reset rules' \ -'table=t1 family=2 entries=3 op=nft_reset_rule -table=t1 family=2 entries=3 op=nft_reset_rule -table=t1 family=2 entries=3 op=nft_reset_rule -table=t2 family=2 entries=3 op=nft_reset_rule -table=t2 family=2 entries=3 op=nft_reset_rule -table=t2 family=2 entries=3 op=nft_reset_rule' - -for ((i = 0; i < 500; i++)); do - echo "add rule t2 c3 counter accept comment \"rule $i\"" -done | do_test 'nft -f -' \ -'table=t2 family=2 entries=500 op=nft_register_rule' - do_test 'nft reset rules t2 c3' \ 'table=t2 family=2 entries=189 op=nft_reset_rule table=t2 family=2 entries=188 op=nft_reset_rule
@@ -105,4 +117,57 @@ table=t2 family=2 entries=180 op=nft_reset_rule table=t2 family=2 entries=188 op=nft_reset_rule table=t2 family=2 entries=135 op=nft_reset_rule' +# resetting sets and elements + +elem=(22 ,80 ,443) +relem="" +for i in {1..3}; do + relem+="${elem[((i - 1))]}" + do_test "nft reset element t1 s { $relem }" \ + "table=t1 family=2 entries=$i op=nft_reset_setelem" +done + +do_test 'nft reset set t1 s' \ +'table=t1 family=2 entries=3 op=nft_reset_setelem' + +# deleting rules + +readarray -t handles < <(nft -a list chain t1 c1 | \ + sed -n 's/.*counter.* handle \(.*\)$/\1/p') + +do_test "nft delete rule t1 c1 handle ${handles[0]}" \ +'table=t1 family=2 entries=1 op=nft_unregister_rule' + +cmd='delete rule t1 c1 handle' +do_test "nft $cmd ${handles[1]}; $cmd ${handles[2]}" \ +'table=t1 family=2 entries=2 op=nft_unregister_rule' + +do_test 'nft flush chain t1 c2' \ +'table=t1 family=2 entries=3 op=nft_unregister_rule' + +do_test 'nft flush table t2' \ +'table=t2 family=2 entries=509 op=nft_unregister_rule' + +# deleting chains + +do_test 'nft delete chain t2 c2' \ +'table=t2 family=2 entries=1 op=nft_unregister_chain' + +# deleting sets and elements + +do_test 'nft delete element t1 s { 22 }' \ +'table=t1 family=2 entries=1 op=nft_unregister_setelem' + +do_test 'nft delete element t1 s { 80, 443 }' \ +'table=t1 family=2 entries=2 op=nft_unregister_setelem' + +do_test 'nft flush set t1 s2' \ +'table=t1 family=2 entries=3 op=nft_unregister_setelem' + +do_test 'nft delete set t1 s2' \ +'table=t1 family=2 entries=1 op=nft_unregister_set' + +do_test 'nft delete set t1 s3' \ +'table=t1 family=2 entries=1 op=nft_unregister_set' + exit $RC
Signature · 1 line
2.40.1