Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
- net/unix/af_unix.c | 2 +-
+ net/unix/af_unix.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
-diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
-index c6d3a19956004..5c4318f64d253 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
-@@ -888,7 +888,7 @@ static struct sock *unix_create1(struct net *net, struct socket *sock, int kern,
+@@ -873,7 +873,7 @@ static struct sock *unix_create1(struct
sk->sk_allocation = GFP_KERNEL_ACCOUNT;
sk->sk_write_space = unix_write_space;
sk->sk_destruct = unix_sock_destructor;
u = unix_sk(sk);
u->inflight = 0;
---
-2.43.0
-
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
- net/unix/diag.c | 2 +-
+ net/unix/diag.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
-diff --git a/net/unix/diag.c b/net/unix/diag.c
-index 63a0040e9fb45..86b3401dcc000 100644
--- a/net/unix/diag.c
+++ b/net/unix/diag.c
-@@ -165,7 +165,7 @@ static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, struct unix_diag_r
+@@ -164,7 +164,7 @@ static int sk_diag_fill(struct sock *sk,
sock_diag_put_meminfo(sk, skb, UNIX_DIAG_MEMINFO))
goto out_nlmsg_trim;
goto out_nlmsg_trim;
if ((req->udiag_show & UDIAG_SHOW_UID) &&
---
-2.43.0
-
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
- net/unix/af_unix.c | 7 ++-----
+ net/unix/af_unix.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
-diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
-index 9800d255a8bc7..628b3fcc74227 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
-@@ -1371,7 +1371,6 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr,
+@@ -1331,7 +1331,6 @@ static int unix_stream_connect(struct so
+ struct sock *other = NULL;
struct sk_buff *skb = NULL;
- long timeo;
- int err;
+ unsigned int hash;
- int st;
+ int err;
+ long timeo;
- err = unix_validate_addr(sunaddr, addr_len);
- if (err)
-@@ -1455,9 +1454,7 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr,
+@@ -1413,9 +1412,7 @@ restart:
Well, and we have to recheck the state after socket locked.
*/
case TCP_CLOSE:
/* This is ok... continue with connect */
break;
-@@ -1472,7 +1469,7 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr,
+@@ -1430,7 +1427,7 @@ restart:
unix_state_lock_nested(sk, U_LOCK_SECOND);
unix_state_unlock(sk);
unix_state_unlock(other);
sock_put(other);
---
-2.43.0
-
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
- net/unix/af_unix.c | 2 +-
+ net/unix/af_unix.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
-diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
-index d00d781f777be..c6d3a19956004 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
-@@ -2642,7 +2642,7 @@ static struct sk_buff *manage_oob(struct sk_buff *skb, struct sock *sk,
+@@ -2600,7 +2600,7 @@ static struct sk_buff *manage_oob(struct
static int unix_stream_read_sock(struct sock *sk, read_descriptor_t *desc,
sk_read_actor_t recv_actor)
{
return -ENOTCONN;
return unix_read_sock(sk, desc, recv_actor);
---
-2.43.0
-
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
- net/unix/af_unix.c | 8 ++++----
+ net/unix/af_unix.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
-diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
-index 628b3fcc74227..d00d781f777be 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
-@@ -2093,7 +2093,7 @@ static int unix_stream_sendmsg(struct socket *sock, struct msghdr *msg,
+@@ -2051,7 +2051,7 @@ static int unix_stream_sendmsg(struct so
}
if (msg->msg_namelen) {
goto out_err;
} else {
err = -ENOTCONN;
-@@ -2305,7 +2305,7 @@ static int unix_seqpacket_sendmsg(struct socket *sock, struct msghdr *msg,
+@@ -2263,7 +2263,7 @@ static int unix_seqpacket_sendmsg(struct
if (err)
return err;
return -ENOTCONN;
if (msg->msg_namelen)
-@@ -2319,7 +2319,7 @@ static int unix_seqpacket_recvmsg(struct socket *sock, struct msghdr *msg,
+@@ -2277,7 +2277,7 @@ static int unix_seqpacket_recvmsg(struct
{
struct sock *sk = sock->sk;
return -ENOTCONN;
return unix_dgram_recvmsg(sock, msg, size, flags);
-@@ -2666,7 +2666,7 @@ static int unix_stream_read_generic(struct unix_stream_read_state *state,
+@@ -2624,7 +2624,7 @@ static int unix_stream_read_generic(stru
size_t size = state->size;
unsigned int last_len;
err = -EINVAL;
goto out;
}
---
-2.43.0
-
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
- net/unix/diag.c | 8 ++++----
+ net/unix/diag.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
-diff --git a/net/unix/diag.c b/net/unix/diag.c
-index 15aaeabb1363b..94c8f509261d0 100644
--- a/net/unix/diag.c
+++ b/net/unix/diag.c
-@@ -65,7 +65,7 @@ static int sk_diag_dump_icons(struct sock *sk, struct sk_buff *nlskb)
+@@ -64,7 +64,7 @@ static int sk_diag_dump_icons(struct soc
u32 *buf;
int i;
spin_lock(&sk->sk_receive_queue.lock);
attr = nla_reserve(nlskb, UNIX_DIAG_ICONS,
-@@ -103,7 +103,7 @@ static int sk_diag_show_rqlen(struct sock *sk, struct sk_buff *nlskb)
+@@ -102,7 +102,7 @@ static int sk_diag_show_rqlen(struct soc
{
struct unix_diag_rqlen rql;
rql.udiag_rqueue = sk->sk_receive_queue.qlen;
rql.udiag_wqueue = sk->sk_max_ack_backlog;
} else {
-@@ -136,7 +136,7 @@ static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, struct unix_diag_r
+@@ -135,7 +135,7 @@ static int sk_diag_fill(struct sock *sk,
rep = nlmsg_data(nlh);
rep->udiag_family = AF_UNIX;
rep->udiag_type = sk->sk_type;
rep->pad = 0;
rep->udiag_ino = sk_ino;
sock_diag_save_cookie(sk, rep->udiag_cookie);
-@@ -219,7 +219,7 @@ static int unix_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
+@@ -218,7 +218,7 @@ static int unix_diag_dump(struct sk_buff
continue;
if (num < s_num)
goto next;
goto next;
if (sk_diag_dump(sk, skb, req, sk_user_ns(skb->sk),
NETLINK_CB(cb->skb).portid,
---
-2.43.0
-
Stable-dep-of: 83690b82d228 ("af_unix: Use skb_queue_empty_lockless() in unix_release_sock().")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
- net/unix/af_unix.c | 9 +++++----
+ net/unix/af_unix.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
-diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
-index 3fa86d70467c2..85b1c0d7c287a 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
-@@ -500,7 +500,7 @@ static void unix_dgram_disconnected(struct sock *sk, struct sock *other)
+@@ -485,7 +485,7 @@ static void unix_dgram_disconnected(stru
* when peer was not connected to us.
*/
if (!sock_flag(other, SOCK_DEAD) && unix_peer(other) == sk) {
sk_error_report(other);
}
}
-@@ -571,7 +571,7 @@ static void unix_release_sock(struct sock *sk, int embrion)
+@@ -556,7 +556,7 @@ static void unix_release_sock(struct soc
/* No more writes */
WRITE_ONCE(skpair->sk_shutdown, SHUTDOWN_MASK);
if (!skb_queue_empty(&sk->sk_receive_queue) || embrion)
unix_state_unlock(skpair);
skpair->sk_state_change(skpair);
sk_wake_async(skpair, SOCK_WAKE_WAITD, POLL_HUP);
-@@ -3108,7 +3108,7 @@ static __poll_t unix_poll(struct file *file, struct socket *sock, poll_table *wa
+@@ -3066,7 +3066,7 @@ static __poll_t unix_poll(struct file *f
state = READ_ONCE(sk->sk_state);
/* exceptional events? */
mask |= EPOLLERR;
if (shutdown == SHUTDOWN_MASK)
mask |= EPOLLHUP;
-@@ -3155,7 +3155,8 @@ static __poll_t unix_dgram_poll(struct file *file, struct socket *sock,
+@@ -3113,7 +3113,8 @@ static __poll_t unix_dgram_poll(struct f
state = READ_ONCE(sk->sk_state);
/* exceptional events? */
mask |= EPOLLERR |
(sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? EPOLLPRI : 0);
---
-2.43.0
-
+++ /dev/null
-From 871f1d52052c897d94a9ed0573e073d4fe7ff7e0 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Tue, 21 Jun 2022 10:19:08 -0700
-Subject: af_unix: Clean up some sock_net() uses.
-
-From: Kuniyuki Iwashima <kuniyu@amazon.com>
-
-[ Upstream commit 340c3d337119ea177a98338be2e3bc62ee87ac80 ]
-
-Some functions define a net pointer only for one-shot use. Others call
-sock_net() redundantly even when a net pointer is available. Let's fix
-these and make the code simpler.
-
-Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
-Signed-off-by: David S. Miller <davem@davemloft.net>
-Stable-dep-of: a9bf9c7dc6a5 ("af_unix: Annotate data-race of sk->sk_state in unix_stream_connect().")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- net/unix/af_unix.c | 33 ++++++++++++++-------------------
- net/unix/diag.c | 3 +--
- 2 files changed, 15 insertions(+), 21 deletions(-)
-
-diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
-index a848e777e448c..9800d255a8bc7 100644
---- a/net/unix/af_unix.c
-+++ b/net/unix/af_unix.c
-@@ -903,7 +903,7 @@ static struct sock *unix_create1(struct net *net, struct socket *sock, int kern,
- memset(&u->scm_stat, 0, sizeof(struct scm_stat));
- unix_insert_socket(unix_sockets_unbound(sk), sk);
-
-- sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
-+ sock_prot_inuse_add(net, sk->sk_prot, 1);
-
- return sk;
-
-@@ -1247,9 +1247,8 @@ static void unix_state_double_unlock(struct sock *sk1, struct sock *sk2)
- static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr,
- int alen, int flags)
- {
-- struct sock *sk = sock->sk;
-- struct net *net = sock_net(sk);
- struct sockaddr_un *sunaddr = (struct sockaddr_un *)addr;
-+ struct sock *sk = sock->sk;
- struct sock *other;
- int err;
-
-@@ -1270,7 +1269,7 @@ static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr,
- }
-
- restart:
-- other = unix_find_other(net, sunaddr, alen, sock->type);
-+ other = unix_find_other(sock_net(sk), sunaddr, alen, sock->type);
- if (IS_ERR(other)) {
- err = PTR_ERR(other);
- goto out;
-@@ -1366,15 +1365,13 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr,
- int addr_len, int flags)
- {
- struct sockaddr_un *sunaddr = (struct sockaddr_un *)uaddr;
-- struct sock *sk = sock->sk;
-- struct net *net = sock_net(sk);
-+ struct sock *sk = sock->sk, *newsk = NULL, *other = NULL;
- struct unix_sock *u = unix_sk(sk), *newu, *otheru;
-- struct sock *newsk = NULL;
-- struct sock *other = NULL;
-+ struct net *net = sock_net(sk);
- struct sk_buff *skb = NULL;
-- int st;
-- int err;
- long timeo;
-+ int err;
-+ int st;
-
- err = unix_validate_addr(sunaddr, addr_len);
- if (err)
-@@ -1394,7 +1391,7 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr,
- */
-
- /* create new sock for complete connection */
-- newsk = unix_create1(sock_net(sk), NULL, 0, sock->type);
-+ newsk = unix_create1(net, NULL, 0, sock->type);
- if (IS_ERR(newsk)) {
- err = PTR_ERR(newsk);
- newsk = NULL;
-@@ -1803,17 +1800,15 @@ static void scm_stat_del(struct sock *sk, struct sk_buff *skb)
- static int unix_dgram_sendmsg(struct socket *sock, struct msghdr *msg,
- size_t len)
- {
-- struct sock *sk = sock->sk;
-- struct net *net = sock_net(sk);
-- struct unix_sock *u = unix_sk(sk);
- DECLARE_SOCKADDR(struct sockaddr_un *, sunaddr, msg->msg_name);
-- struct sock *other = NULL;
-- int err;
-- struct sk_buff *skb;
-- long timeo;
-+ struct sock *sk = sock->sk, *other = NULL;
-+ struct unix_sock *u = unix_sk(sk);
- struct scm_cookie scm;
-+ struct sk_buff *skb;
- int data_len = 0;
- int sk_locked;
-+ long timeo;
-+ int err;
-
- wait_for_unix_gc();
- err = scm_send(sock, msg, &scm, false);
-@@ -1880,7 +1875,7 @@ static int unix_dgram_sendmsg(struct socket *sock, struct msghdr *msg,
- if (sunaddr == NULL)
- goto out_free;
-
-- other = unix_find_other(net, sunaddr, msg->msg_namelen,
-+ other = unix_find_other(sock_net(sk), sunaddr, msg->msg_namelen,
- sk->sk_type);
- if (IS_ERR(other)) {
- err = PTR_ERR(other);
-diff --git a/net/unix/diag.c b/net/unix/diag.c
-index 006438e2e07a2..15aaeabb1363b 100644
---- a/net/unix/diag.c
-+++ b/net/unix/diag.c
-@@ -312,7 +312,6 @@ static int unix_diag_get_exact(struct sk_buff *in_skb,
- static int unix_diag_handler_dump(struct sk_buff *skb, struct nlmsghdr *h)
- {
- int hdrlen = sizeof(struct unix_diag_req);
-- struct net *net = sock_net(skb->sk);
-
- if (nlmsg_len(h) < hdrlen)
- return -EINVAL;
-@@ -321,7 +320,7 @@ static int unix_diag_handler_dump(struct sk_buff *skb, struct nlmsghdr *h)
- struct netlink_dump_control c = {
- .dump = unix_diag_dump,
- };
-- return netlink_dump_start(net->diag_nlsk, skb, h, &c);
-+ return netlink_dump_start(sock_net(skb->sk)->diag_nlsk, skb, h, &c);
- } else
- return unix_diag_get_exact(skb, h, nlmsg_data(h));
- }
---
-2.43.0
-
+++ /dev/null
-From a521bba7af6be404371346310d94ccd7c1e8c224 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 24 Nov 2021 11:14:24 +0900
-Subject: af_unix: Copy unix_mkname() into unix_find_(bsd|abstract)().
-
-From: Kuniyuki Iwashima <kuniyu@amazon.co.jp>
-
-[ Upstream commit d2d8c9fddb1c11ccfa73bf0ad2b1e6b4ea7afdaf ]
-
-We should not call unix_mkname() before unix_find_other() and instead do
-the same thing where necessary based on the address type:
-
- - terminating the address with '\0' in unix_find_bsd()
- - calculating the hash in unix_find_abstract().
-
-Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.co.jp>
-Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-Stable-dep-of: a9bf9c7dc6a5 ("af_unix: Annotate data-race of sk->sk_state in unix_stream_connect().")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- net/unix/af_unix.c | 63 ++++++++++++++++++----------------------------
- 1 file changed, 25 insertions(+), 38 deletions(-)
-
-diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
-index 8aeafe66e6115..a848e777e448c 100644
---- a/net/unix/af_unix.c
-+++ b/net/unix/af_unix.c
-@@ -239,19 +239,25 @@ static int unix_validate_addr(struct sockaddr_un *sunaddr, int addr_len)
- return 0;
- }
-
-+static void unix_mkname_bsd(struct sockaddr_un *sunaddr, int addr_len)
-+{
-+ /* This may look like an off by one error but it is a bit more
-+ * subtle. 108 is the longest valid AF_UNIX path for a binding.
-+ * sun_path[108] doesn't as such exist. However in kernel space
-+ * we are guaranteed that it is a valid memory location in our
-+ * kernel address buffer because syscall functions always pass
-+ * a pointer of struct sockaddr_storage which has a bigger buffer
-+ * than 108.
-+ */
-+ ((char *)sunaddr)[addr_len] = 0;
-+}
-+
- static int unix_mkname(struct sockaddr_un *sunaddr, int len, unsigned int *hashp)
- {
- *hashp = 0;
-
- if (sunaddr->sun_path[0]) {
-- /*
-- * This may look like an off by one error but it is a bit more
-- * subtle. 108 is the longest valid AF_UNIX path for a binding.
-- * sun_path[108] doesn't as such exist. However in kernel space
-- * we are guaranteed that it is a valid memory location in our
-- * kernel address buffer.
-- */
-- ((char *)sunaddr)[len] = 0;
-+ unix_mkname_bsd(sunaddr, len);
- len = strlen(sunaddr->sun_path) +
- offsetof(struct sockaddr_un, sun_path) + 1;
- return len;
-@@ -959,13 +965,14 @@ static int unix_release(struct socket *sock)
- }
-
- static struct sock *unix_find_bsd(struct net *net, struct sockaddr_un *sunaddr,
-- int type)
-+ int addr_len, int type)
- {
- struct inode *inode;
- struct path path;
- struct sock *sk;
- int err;
-
-+ unix_mkname_bsd(sunaddr, addr_len);
- err = kern_path(sunaddr->sun_path, LOOKUP_FOLLOW, &path);
- if (err)
- goto fail;
-@@ -1003,9 +1010,9 @@ static struct sock *unix_find_bsd(struct net *net, struct sockaddr_un *sunaddr,
-
- static struct sock *unix_find_abstract(struct net *net,
- struct sockaddr_un *sunaddr,
-- int addr_len, int type,
-- unsigned int hash)
-+ int addr_len, int type)
- {
-+ unsigned int hash = unix_hash_fold(csum_partial(sunaddr, addr_len, 0));
- struct dentry *dentry;
- struct sock *sk;
-
-@@ -1022,15 +1029,14 @@ static struct sock *unix_find_abstract(struct net *net,
-
- static struct sock *unix_find_other(struct net *net,
- struct sockaddr_un *sunaddr,
-- int addr_len, int type,
-- unsigned int hash)
-+ int addr_len, int type)
- {
- struct sock *sk;
-
- if (sunaddr->sun_path[0])
-- sk = unix_find_bsd(net, sunaddr, type);
-+ sk = unix_find_bsd(net, sunaddr, addr_len, type);
- else
-- sk = unix_find_abstract(net, sunaddr, addr_len, type, hash);
-+ sk = unix_find_abstract(net, sunaddr, addr_len, type);
-
- return sk;
- }
-@@ -1245,7 +1251,6 @@ static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr,
- struct net *net = sock_net(sk);
- struct sockaddr_un *sunaddr = (struct sockaddr_un *)addr;
- struct sock *other;
-- unsigned int hash;
- int err;
-
- err = -EINVAL;
-@@ -1257,11 +1262,6 @@ static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr,
- if (err)
- goto out;
-
-- err = unix_mkname(sunaddr, alen, &hash);
-- if (err < 0)
-- goto out;
-- alen = err;
--
- if (test_bit(SOCK_PASSCRED, &sock->flags) &&
- !unix_sk(sk)->addr) {
- err = unix_autobind(sk);
-@@ -1270,7 +1270,7 @@ static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr,
- }
-
- restart:
-- other = unix_find_other(net, sunaddr, alen, sock->type, hash);
-+ other = unix_find_other(net, sunaddr, alen, sock->type);
- if (IS_ERR(other)) {
- err = PTR_ERR(other);
- goto out;
-@@ -1372,7 +1372,6 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr,
- struct sock *newsk = NULL;
- struct sock *other = NULL;
- struct sk_buff *skb = NULL;
-- unsigned int hash;
- int st;
- int err;
- long timeo;
-@@ -1381,11 +1380,6 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr,
- if (err)
- goto out;
-
-- err = unix_mkname(sunaddr, addr_len, &hash);
-- if (err < 0)
-- goto out;
-- addr_len = err;
--
- if (test_bit(SOCK_PASSCRED, &sock->flags) && !u->addr) {
- err = unix_autobind(sk);
- if (err)
-@@ -1416,7 +1410,7 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr,
-
- restart:
- /* Find listening sock. */
-- other = unix_find_other(net, sunaddr, addr_len, sk->sk_type, hash);
-+ other = unix_find_other(net, sunaddr, addr_len, sk->sk_type);
- if (IS_ERR(other)) {
- err = PTR_ERR(other);
- other = NULL;
-@@ -1814,9 +1808,7 @@ static int unix_dgram_sendmsg(struct socket *sock, struct msghdr *msg,
- struct unix_sock *u = unix_sk(sk);
- DECLARE_SOCKADDR(struct sockaddr_un *, sunaddr, msg->msg_name);
- struct sock *other = NULL;
-- int namelen = 0; /* fake GCC */
- int err;
-- unsigned int hash;
- struct sk_buff *skb;
- long timeo;
- struct scm_cookie scm;
-@@ -1836,11 +1828,6 @@ static int unix_dgram_sendmsg(struct socket *sock, struct msghdr *msg,
- err = unix_validate_addr(sunaddr, msg->msg_namelen);
- if (err)
- goto out;
--
-- err = unix_mkname(sunaddr, msg->msg_namelen, &hash);
-- if (err < 0)
-- goto out;
-- namelen = err;
- } else {
- sunaddr = NULL;
- err = -ENOTCONN;
-@@ -1893,8 +1880,8 @@ static int unix_dgram_sendmsg(struct socket *sock, struct msghdr *msg,
- if (sunaddr == NULL)
- goto out_free;
-
-- other = unix_find_other(net, sunaddr, namelen, sk->sk_type,
-- hash);
-+ other = unix_find_other(net, sunaddr, msg->msg_namelen,
-+ sk->sk_type);
- if (IS_ERR(other)) {
- err = PTR_ERR(other);
- other = NULL;
---
-2.43.0
-
+++ /dev/null
-From 66094a2eae821c3437f6bee8337b83adbd0663a4 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 24 Nov 2021 11:14:23 +0900
-Subject: af_unix: Cut unix_validate_addr() out of unix_mkname().
-
-From: Kuniyuki Iwashima <kuniyu@amazon.co.jp>
-
-[ Upstream commit b8a58aa6fccc5b2940f0da18c7f02e8a1deb693a ]
-
-unix_mkname() tests socket address length and family and does some
-processing based on the address type. It is called in the early stage,
-and therefore some instructions are redundant and can end up in vain.
-
-The address length/family tests are done twice in unix_bind(). Also, the
-address type is rechecked later in unix_bind() and unix_find_other(), where
-we can do the same processing. Moreover, in the BSD address case, the hash
-is set to 0 but never used and confusing.
-
-This patch moves the address tests out of unix_mkname(), and the following
-patches move the other part into appropriate places and remove
-unix_mkname() finally.
-
-Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.co.jp>
-Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-Stable-dep-of: a9bf9c7dc6a5 ("af_unix: Annotate data-race of sk->sk_state in unix_stream_connect().")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- net/unix/af_unix.c | 40 ++++++++++++++++++++++++++++++----------
- 1 file changed, 30 insertions(+), 10 deletions(-)
-
-diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
-index 0a1258b417a9d..8aeafe66e6115 100644
---- a/net/unix/af_unix.c
-+++ b/net/unix/af_unix.c
-@@ -227,15 +227,22 @@ static inline void unix_release_addr(struct unix_address *addr)
- * - if started by zero, it is abstract name.
- */
-
-+static int unix_validate_addr(struct sockaddr_un *sunaddr, int addr_len)
-+{
-+ if (addr_len <= offsetof(struct sockaddr_un, sun_path) ||
-+ addr_len > sizeof(*sunaddr))
-+ return -EINVAL;
-+
-+ if (sunaddr->sun_family != AF_UNIX)
-+ return -EINVAL;
-+
-+ return 0;
-+}
-+
- static int unix_mkname(struct sockaddr_un *sunaddr, int len, unsigned int *hashp)
- {
- *hashp = 0;
-
-- if (len <= offsetof(struct sockaddr_un, sun_path) ||
-- len > sizeof(*sunaddr))
-- return -EINVAL;
-- if (!sunaddr || sunaddr->sun_family != AF_UNIX)
-- return -EINVAL;
- if (sunaddr->sun_path[0]) {
- /*
- * This may look like an off by one error but it is a bit more
-@@ -1178,13 +1185,14 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
- unsigned int hash;
- struct unix_address *addr;
-
-- if (addr_len < offsetofend(struct sockaddr_un, sun_family) ||
-- sunaddr->sun_family != AF_UNIX)
-- return -EINVAL;
--
-- if (addr_len == offsetof(struct sockaddr_un, sun_path))
-+ if (addr_len == offsetof(struct sockaddr_un, sun_path) &&
-+ sunaddr->sun_family == AF_UNIX)
- return unix_autobind(sk);
-
-+ err = unix_validate_addr(sunaddr, addr_len);
-+ if (err)
-+ return err;
-+
- err = unix_mkname(sunaddr, addr_len, &hash);
- if (err < 0)
- return err;
-@@ -1245,6 +1253,10 @@ static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr,
- goto out;
-
- if (addr->sa_family != AF_UNSPEC) {
-+ err = unix_validate_addr(sunaddr, alen);
-+ if (err)
-+ goto out;
-+
- err = unix_mkname(sunaddr, alen, &hash);
- if (err < 0)
- goto out;
-@@ -1365,6 +1377,10 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr,
- int err;
- long timeo;
-
-+ err = unix_validate_addr(sunaddr, addr_len);
-+ if (err)
-+ goto out;
-+
- err = unix_mkname(sunaddr, addr_len, &hash);
- if (err < 0)
- goto out;
-@@ -1817,6 +1833,10 @@ static int unix_dgram_sendmsg(struct socket *sock, struct msghdr *msg,
- goto out;
-
- if (msg->msg_namelen) {
-+ err = unix_validate_addr(sunaddr, msg->msg_namelen);
-+ if (err)
-+ goto out;
-+
- err = unix_mkname(sunaddr, msg->msg_namelen, &hash);
- if (err < 0)
- goto out;
---
-2.43.0
-
+++ /dev/null
-From 37f21e3bf98191271a970d44f8437110434cf447 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 24 Nov 2021 11:14:21 +0900
-Subject: af_unix: Factorise unix_find_other() based on address types.
-
-From: Kuniyuki Iwashima <kuniyu@amazon.co.jp>
-
-[ Upstream commit fa39ef0e472961baef49ddb0e6f7b8ebb555bd8f ]
-
-As done in the commit fa42d910a38e ("unix_bind(): take BSD and abstract
-address cases into new helpers"), this patch moves BSD and abstract address
-cases from unix_find_other() into unix_find_bsd() and unix_find_abstract().
-
-Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.co.jp>
-Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-Stable-dep-of: a9bf9c7dc6a5 ("af_unix: Annotate data-race of sk->sk_state in unix_stream_connect().")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- net/unix/af_unix.c | 136 +++++++++++++++++++++++++++------------------
- 1 file changed, 81 insertions(+), 55 deletions(-)
-
-diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
-index 1fc3022510093..20a7be3effe83 100644
---- a/net/unix/af_unix.c
-+++ b/net/unix/af_unix.c
-@@ -951,6 +951,87 @@ static int unix_release(struct socket *sock)
- return 0;
- }
-
-+static struct sock *unix_find_bsd(struct net *net, struct sockaddr_un *sunaddr,
-+ int type, int *error)
-+{
-+ struct inode *inode;
-+ struct path path;
-+ struct sock *sk;
-+ int err;
-+
-+ err = kern_path(sunaddr->sun_path, LOOKUP_FOLLOW, &path);
-+ if (err)
-+ goto fail;
-+
-+ err = path_permission(&path, MAY_WRITE);
-+ if (err)
-+ goto path_put;
-+
-+ err = -ECONNREFUSED;
-+ inode = d_backing_inode(path.dentry);
-+ if (!S_ISSOCK(inode->i_mode))
-+ goto path_put;
-+
-+ sk = unix_find_socket_byinode(inode);
-+ if (!sk)
-+ goto path_put;
-+
-+ err = -EPROTOTYPE;
-+ if (sk->sk_type == type)
-+ touch_atime(&path);
-+ else
-+ goto sock_put;
-+
-+ path_put(&path);
-+
-+ return sk;
-+
-+sock_put:
-+ sock_put(sk);
-+path_put:
-+ path_put(&path);
-+fail:
-+ *error = err;
-+ return NULL;
-+}
-+
-+static struct sock *unix_find_abstract(struct net *net,
-+ struct sockaddr_un *sunaddr,
-+ int addr_len, int type,
-+ unsigned int hash, int *error)
-+{
-+ struct dentry *dentry;
-+ struct sock *sk;
-+
-+ sk = unix_find_socket_byname(net, sunaddr, addr_len, type ^ hash);
-+ if (!sk) {
-+ *error = -ECONNREFUSED;
-+ return NULL;
-+ }
-+
-+ dentry = unix_sk(sk)->path.dentry;
-+ if (dentry)
-+ touch_atime(&unix_sk(sk)->path);
-+
-+ return sk;
-+}
-+
-+static struct sock *unix_find_other(struct net *net,
-+ struct sockaddr_un *sunaddr,
-+ int addr_len, int type,
-+ unsigned int hash, int *error)
-+{
-+ struct sock *sk;
-+
-+ if (sunaddr->sun_path[0])
-+ sk = unix_find_bsd(net, sunaddr, type, error);
-+ else
-+ sk = unix_find_abstract(net, sunaddr, addr_len, type, hash,
-+ error);
-+
-+ return sk;
-+}
-+
- static int unix_autobind(struct sock *sk)
- {
- struct unix_sock *u = unix_sk(sk);
-@@ -1009,61 +1090,6 @@ out: mutex_unlock(&u->bindlock);
- return err;
- }
-
--static struct sock *unix_find_other(struct net *net,
-- struct sockaddr_un *sunname, int len,
-- int type, unsigned int hash, int *error)
--{
-- struct sock *u;
-- struct path path;
-- int err = 0;
--
-- if (sunname->sun_path[0]) {
-- struct inode *inode;
-- err = kern_path(sunname->sun_path, LOOKUP_FOLLOW, &path);
-- if (err)
-- goto fail;
-- inode = d_backing_inode(path.dentry);
-- err = path_permission(&path, MAY_WRITE);
-- if (err)
-- goto put_fail;
--
-- err = -ECONNREFUSED;
-- if (!S_ISSOCK(inode->i_mode))
-- goto put_fail;
-- u = unix_find_socket_byinode(inode);
-- if (!u)
-- goto put_fail;
--
-- if (u->sk_type == type)
-- touch_atime(&path);
--
-- path_put(&path);
--
-- err = -EPROTOTYPE;
-- if (u->sk_type != type) {
-- sock_put(u);
-- goto fail;
-- }
-- } else {
-- err = -ECONNREFUSED;
-- u = unix_find_socket_byname(net, sunname, len, type ^ hash);
-- if (u) {
-- struct dentry *dentry;
-- dentry = unix_sk(u)->path.dentry;
-- if (dentry)
-- touch_atime(&unix_sk(u)->path);
-- } else
-- goto fail;
-- }
-- return u;
--
--put_fail:
-- path_put(&path);
--fail:
-- *error = err;
-- return NULL;
--}
--
- static int unix_bind_bsd(struct sock *sk, struct unix_address *addr)
- {
- struct unix_sock *u = unix_sk(sk);
---
-2.43.0
-
+++ /dev/null
-From 6e28b0638dc4a6110a6b56646b3b62d9619a0076 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 24 Nov 2021 11:14:20 +0900
-Subject: af_unix: Pass struct sock to unix_autobind().
-
-From: Kuniyuki Iwashima <kuniyu@amazon.co.jp>
-
-[ Upstream commit f7ed31f4615f4e1d97c0e4325c5b8a240e10073c ]
-
-We do not use struct socket in unix_autobind() and pass struct sock to
-unix_bind_bsd() and unix_bind_abstract(). Let's pass it to unix_autobind()
-as well.
-
-Also, this patch fixes these errors by checkpatch.pl.
-
- ERROR: do not use assignment in if condition
- #1795: FILE: net/unix/af_unix.c:1795:
- + if (test_bit(SOCK_PASSCRED, &sock->flags) && !u->addr
-
- CHECK: Logical continuations should be on the previous line
- #1796: FILE: net/unix/af_unix.c:1796:
- + if (test_bit(SOCK_PASSCRED, &sock->flags) && !u->addr
- + && (err = unix_autobind(sock)) != 0)
-
-Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.co.jp>
-Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-Stable-dep-of: a9bf9c7dc6a5 ("af_unix: Annotate data-race of sk->sk_state in unix_stream_connect().")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- net/unix/af_unix.c | 36 +++++++++++++++++++++---------------
- 1 file changed, 21 insertions(+), 15 deletions(-)
-
-diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
-index 7d58067ffd3f8..1fc3022510093 100644
---- a/net/unix/af_unix.c
-+++ b/net/unix/af_unix.c
-@@ -951,15 +951,13 @@ static int unix_release(struct socket *sock)
- return 0;
- }
-
--static int unix_autobind(struct socket *sock)
-+static int unix_autobind(struct sock *sk)
- {
-- struct sock *sk = sock->sk;
-- struct net *net = sock_net(sk);
- struct unix_sock *u = unix_sk(sk);
-- static u32 ordernum = 1;
- struct unix_address *addr;
-- int err;
- unsigned int retries = 0;
-+ static u32 ordernum = 1;
-+ int err;
-
- err = mutex_lock_interruptible(&u->bindlock);
- if (err)
-@@ -986,7 +984,8 @@ static int unix_autobind(struct socket *sock)
- spin_lock(&unix_table_lock);
- ordernum = (ordernum+1)&0xFFFFF;
-
-- if (__unix_find_socket_byname(net, addr->name, addr->len, addr->hash)) {
-+ if (__unix_find_socket_byname(sock_net(sk), addr->name, addr->len,
-+ addr->hash)) {
- spin_unlock(&unix_table_lock);
- /*
- * __unix_find_socket_byname() may take long time if many names
-@@ -1162,7 +1161,7 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
- return -EINVAL;
-
- if (addr_len == offsetof(struct sockaddr_un, sun_path))
-- return unix_autobind(sock);
-+ return unix_autobind(sk);
-
- err = unix_mkname(sunaddr, addr_len, &hash);
- if (err < 0)
-@@ -1230,8 +1229,11 @@ static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr,
- alen = err;
-
- if (test_bit(SOCK_PASSCRED, &sock->flags) &&
-- !unix_sk(sk)->addr && (err = unix_autobind(sock)) != 0)
-- goto out;
-+ !unix_sk(sk)->addr) {
-+ err = unix_autobind(sk);
-+ if (err)
-+ goto out;
-+ }
-
- restart:
- other = unix_find_other(net, sunaddr, alen, sock->type, hash, &err);
-@@ -1344,9 +1346,11 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr,
- goto out;
- addr_len = err;
-
-- if (test_bit(SOCK_PASSCRED, &sock->flags) && !u->addr &&
-- (err = unix_autobind(sock)) != 0)
-- goto out;
-+ if (test_bit(SOCK_PASSCRED, &sock->flags) && !u->addr) {
-+ err = unix_autobind(sk);
-+ if (err)
-+ goto out;
-+ }
-
- timeo = sock_sndtimeo(sk, flags & O_NONBLOCK);
-
-@@ -1798,9 +1802,11 @@ static int unix_dgram_sendmsg(struct socket *sock, struct msghdr *msg,
- goto out;
- }
-
-- if (test_bit(SOCK_PASSCRED, &sock->flags) && !u->addr
-- && (err = unix_autobind(sock)) != 0)
-- goto out;
-+ if (test_bit(SOCK_PASSCRED, &sock->flags) && !u->addr) {
-+ err = unix_autobind(sk);
-+ if (err)
-+ goto out;
-+ }
-
- err = -EMSGSIZE;
- if (len > sk->sk_sndbuf - 32)
---
-2.43.0
-
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
- net/unix/af_unix.c | 18 +++++++++---------
+ net/unix/af_unix.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
-diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
-index 12099b06d7e88..c0351a141d0f7 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
-@@ -2607,18 +2607,18 @@ static struct sk_buff *manage_oob(struct sk_buff *skb, struct sock *sk,
+@@ -2565,18 +2565,18 @@ static struct sk_buff *manage_oob(struct
if (skb == u->oob_skb) {
if (copied) {
skb = NULL;
}
}
---
-2.43.0
-
+++ /dev/null
-From 8d66d269fbdf2e746bb696f4723f626698608dee Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 24 Nov 2021 11:14:22 +0900
-Subject: af_unix: Return an error as a pointer in unix_find_other().
-
-From: Kuniyuki Iwashima <kuniyu@amazon.co.jp>
-
-[ Upstream commit aed26f557bbc94f0c778f63d7dfe86af99208f68 ]
-
-We can return an error as a pointer and need not pass an additional
-argument to unix_find_other().
-
-Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.co.jp>
-Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-Stable-dep-of: a9bf9c7dc6a5 ("af_unix: Annotate data-race of sk->sk_state in unix_stream_connect().")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- net/unix/af_unix.c | 40 ++++++++++++++++++++++------------------
- 1 file changed, 22 insertions(+), 18 deletions(-)
-
-diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
-index 20a7be3effe83..0a1258b417a9d 100644
---- a/net/unix/af_unix.c
-+++ b/net/unix/af_unix.c
-@@ -952,7 +952,7 @@ static int unix_release(struct socket *sock)
- }
-
- static struct sock *unix_find_bsd(struct net *net, struct sockaddr_un *sunaddr,
-- int type, int *error)
-+ int type)
- {
- struct inode *inode;
- struct path path;
-@@ -991,23 +991,20 @@ static struct sock *unix_find_bsd(struct net *net, struct sockaddr_un *sunaddr,
- path_put:
- path_put(&path);
- fail:
-- *error = err;
-- return NULL;
-+ return ERR_PTR(err);
- }
-
- static struct sock *unix_find_abstract(struct net *net,
- struct sockaddr_un *sunaddr,
- int addr_len, int type,
-- unsigned int hash, int *error)
-+ unsigned int hash)
- {
- struct dentry *dentry;
- struct sock *sk;
-
- sk = unix_find_socket_byname(net, sunaddr, addr_len, type ^ hash);
-- if (!sk) {
-- *error = -ECONNREFUSED;
-- return NULL;
-- }
-+ if (!sk)
-+ return ERR_PTR(-ECONNREFUSED);
-
- dentry = unix_sk(sk)->path.dentry;
- if (dentry)
-@@ -1019,15 +1016,14 @@ static struct sock *unix_find_abstract(struct net *net,
- static struct sock *unix_find_other(struct net *net,
- struct sockaddr_un *sunaddr,
- int addr_len, int type,
-- unsigned int hash, int *error)
-+ unsigned int hash)
- {
- struct sock *sk;
-
- if (sunaddr->sun_path[0])
-- sk = unix_find_bsd(net, sunaddr, type, error);
-+ sk = unix_find_bsd(net, sunaddr, type);
- else
-- sk = unix_find_abstract(net, sunaddr, addr_len, type, hash,
-- error);
-+ sk = unix_find_abstract(net, sunaddr, addr_len, type, hash);
-
- return sk;
- }
-@@ -1262,9 +1258,11 @@ static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr,
- }
-
- restart:
-- other = unix_find_other(net, sunaddr, alen, sock->type, hash, &err);
-- if (!other)
-+ other = unix_find_other(net, sunaddr, alen, sock->type, hash);
-+ if (IS_ERR(other)) {
-+ err = PTR_ERR(other);
- goto out;
-+ }
-
- unix_state_double_lock(sk, other);
-
-@@ -1402,9 +1400,12 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr,
-
- restart:
- /* Find listening sock. */
-- other = unix_find_other(net, sunaddr, addr_len, sk->sk_type, hash, &err);
-- if (!other)
-+ other = unix_find_other(net, sunaddr, addr_len, sk->sk_type, hash);
-+ if (IS_ERR(other)) {
-+ err = PTR_ERR(other);
-+ other = NULL;
- goto out;
-+ }
-
- /* Latch state of peer */
- unix_state_lock(other);
-@@ -1873,9 +1874,12 @@ static int unix_dgram_sendmsg(struct socket *sock, struct msghdr *msg,
- goto out_free;
-
- other = unix_find_other(net, sunaddr, namelen, sk->sk_type,
-- hash, &err);
-- if (other == NULL)
-+ hash);
-+ if (IS_ERR(other)) {
-+ err = PTR_ERR(other);
-+ other = NULL;
- goto out_free;
-+ }
- }
-
- if (sk_filter(other, skb) < 0) {
---
-2.43.0
-
+++ /dev/null
-From 9f19d9848e020c6dd48d37bfff3428f2376e72dc Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 24 Nov 2021 11:14:19 +0900
-Subject: af_unix: Use offsetof() instead of sizeof().
-
-From: Kuniyuki Iwashima <kuniyu@amazon.co.jp>
-
-[ Upstream commit 755662ce78d14c1a9118df921c528b1f992ded2e ]
-
-The length of the AF_UNIX socket address contains an offset to the member
-sun_path of struct sockaddr_un.
-
-Currently, the preceding member is just sun_family, and its type is
-sa_family_t and resolved to short. Therefore, the offset is represented by
-sizeof(short). However, it is not clear and fragile to changes in struct
-sockaddr_storage or sockaddr_un.
-
-This commit makes it clear and robust by rewriting sizeof() with
-offsetof().
-
-Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.co.jp>
-Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-Stable-dep-of: a9bf9c7dc6a5 ("af_unix: Annotate data-race of sk->sk_state in unix_stream_connect().")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- net/unix/af_unix.c | 19 ++++++++++++-------
- net/unix/diag.c | 3 ++-
- 2 files changed, 14 insertions(+), 8 deletions(-)
-
-diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
-index 262aeaea9861c..7d58067ffd3f8 100644
---- a/net/unix/af_unix.c
-+++ b/net/unix/af_unix.c
-@@ -231,7 +231,8 @@ static int unix_mkname(struct sockaddr_un *sunaddr, int len, unsigned int *hashp
- {
- *hashp = 0;
-
-- if (len <= sizeof(short) || len > sizeof(*sunaddr))
-+ if (len <= offsetof(struct sockaddr_un, sun_path) ||
-+ len > sizeof(*sunaddr))
- return -EINVAL;
- if (!sunaddr || sunaddr->sun_family != AF_UNIX)
- return -EINVAL;
-@@ -244,7 +245,8 @@ static int unix_mkname(struct sockaddr_un *sunaddr, int len, unsigned int *hashp
- * kernel address buffer.
- */
- ((char *)sunaddr)[len] = 0;
-- len = strlen(sunaddr->sun_path)+1+sizeof(short);
-+ len = strlen(sunaddr->sun_path) +
-+ offsetof(struct sockaddr_un, sun_path) + 1;
- return len;
- }
-
-@@ -967,7 +969,8 @@ static int unix_autobind(struct socket *sock)
- goto out;
-
- err = -ENOMEM;
-- addr = kzalloc(sizeof(*addr) + sizeof(short) + 16, GFP_KERNEL);
-+ addr = kzalloc(sizeof(*addr) +
-+ offsetof(struct sockaddr_un, sun_path) + 16, GFP_KERNEL);
- if (!addr)
- goto out;
-
-@@ -975,7 +978,8 @@ static int unix_autobind(struct socket *sock)
- refcount_set(&addr->refcnt, 1);
-
- retry:
-- addr->len = sprintf(addr->name->sun_path+1, "%05x", ordernum) + 1 + sizeof(short);
-+ addr->len = sprintf(addr->name->sun_path + 1, "%05x", ordernum) +
-+ offsetof(struct sockaddr_un, sun_path) + 1;
- addr->hash = unix_hash_fold(csum_partial(addr->name, addr->len, 0));
- addr->hash ^= sk->sk_type;
-
-@@ -1157,7 +1161,7 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
- sunaddr->sun_family != AF_UNIX)
- return -EINVAL;
-
-- if (addr_len == sizeof(short))
-+ if (addr_len == offsetof(struct sockaddr_un, sun_path))
- return unix_autobind(sock);
-
- err = unix_mkname(sunaddr, addr_len, &hash);
-@@ -1607,7 +1611,7 @@ static int unix_getname(struct socket *sock, struct sockaddr *uaddr, int peer)
- if (!addr) {
- sunaddr->sun_family = AF_UNIX;
- sunaddr->sun_path[0] = 0;
-- err = sizeof(short);
-+ err = offsetof(struct sockaddr_un, sun_path);
- } else {
- err = addr->len;
- memcpy(sunaddr, addr->name, addr->len);
-@@ -3271,7 +3275,8 @@ static int unix_seq_show(struct seq_file *seq, void *v)
- seq_putc(seq, ' ');
-
- i = 0;
-- len = u->addr->len - sizeof(short);
-+ len = u->addr->len -
-+ offsetof(struct sockaddr_un, sun_path);
- if (!UNIX_ABSTRACT(s))
- len--;
- else {
-diff --git a/net/unix/diag.c b/net/unix/diag.c
-index daef19932f780..006438e2e07a2 100644
---- a/net/unix/diag.c
-+++ b/net/unix/diag.c
-@@ -19,7 +19,8 @@ static int sk_diag_dump_name(struct sock *sk, struct sk_buff *nlskb)
- if (!addr)
- return 0;
-
-- return nla_put(nlskb, UNIX_DIAG_NAME, addr->len - sizeof(short),
-+ return nla_put(nlskb, UNIX_DIAG_NAME,
-+ addr->len - offsetof(struct sockaddr_un, sun_path),
- addr->name->sun_path);
- }
-
---
-2.43.0
-
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
- net/unix/af_unix.c | 2 +-
+ net/unix/af_unix.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
-diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
-index 85b1c0d7c287a..12099b06d7e88 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
-@@ -570,7 +570,7 @@ static void unix_release_sock(struct sock *sk, int embrion)
+@@ -555,7 +555,7 @@ static void unix_release_sock(struct soc
unix_state_lock(skpair);
/* No more writes */
WRITE_ONCE(skpair->sk_shutdown, SHUTDOWN_MASK);
WRITE_ONCE(skpair->sk_err, ECONNRESET);
unix_state_unlock(skpair);
skpair->sk_state_change(skpair);
---
-2.43.0
-
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
- net/unix/diag.c | 2 +-
+ net/unix/diag.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
-diff --git a/net/unix/diag.c b/net/unix/diag.c
-index 94c8f509261d0..63a0040e9fb45 100644
--- a/net/unix/diag.c
+++ b/net/unix/diag.c
-@@ -104,7 +104,7 @@ static int sk_diag_show_rqlen(struct sock *sk, struct sk_buff *nlskb)
+@@ -103,7 +103,7 @@ static int sk_diag_show_rqlen(struct soc
struct unix_diag_rqlen rql;
if (READ_ONCE(sk->sk_state) == TCP_LISTEN) {
rql.udiag_wqueue = sk->sk_max_ack_backlog;
} else {
rql.udiag_rqueue = (u32) unix_inq_len(sk);
---
-2.43.0
-
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
- net/unix/af_unix.c | 10 ++--------
+ net/unix/af_unix.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
-diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
-index 5c4318f64d253..3fa86d70467c2 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
-@@ -190,15 +190,9 @@ static inline int unix_may_send(struct sock *sk, struct sock *osk)
+@@ -190,15 +190,9 @@ static inline int unix_may_send(struct s
return unix_peer(osk) == NULL || unix_our_peer(sk, osk);
}
}
struct sock *unix_peer_get(struct sock *s)
-@@ -1429,7 +1423,7 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr,
+@@ -1387,7 +1381,7 @@ restart:
if (other->sk_shutdown & RCV_SHUTDOWN)
goto out_unlock;
err = -EAGAIN;
if (!timeo)
goto out_unlock;
---
-2.43.0
-
+++ /dev/null
-From 800814a7df99f26dd955e9a8e65d85a5ce418e57 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Thu, 6 Jun 2024 23:32:48 +0300
-Subject: geneve: Fix incorrect inner network header offset when
- innerprotoinherit is set
-
-From: Gal Pressman <gal@nvidia.com>
-
-[ Upstream commit c6ae073f5903f6c6439d0ac855836a4da5c0a701 ]
-
-When innerprotoinherit is set, the tunneled packets do not have an inner
-Ethernet header.
-Change 'maclen' to not always assume the header length is ETH_HLEN, as
-there might not be a MAC header.
-
-This resolves issues with drivers (e.g. mlx5, in
-mlx5e_tx_tunnel_accel()) who rely on the skb inner network header offset
-to be correct, and use it for TX offloads.
-
-Fixes: d8a6213d70ac ("geneve: fix header validation in geneve[6]_xmit_skb")
-Signed-off-by: Gal Pressman <gal@nvidia.com>
-Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
-Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>
-Signed-off-by: David S. Miller <davem@davemloft.net>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/net/geneve.c | 10 ++++++----
- include/net/ip_tunnels.h | 5 +++--
- 2 files changed, 9 insertions(+), 6 deletions(-)
-
-diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
-index 3f076dadff78b..3cf59fd75f9b2 100644
---- a/drivers/net/geneve.c
-+++ b/drivers/net/geneve.c
-@@ -920,6 +920,7 @@ static int geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev,
- struct geneve_dev *geneve,
- const struct ip_tunnel_info *info)
- {
-+ bool inner_proto_inherit = geneve->cfg.inner_proto_inherit;
- bool xnet = !net_eq(geneve->net, dev_net(geneve->dev));
- struct geneve_sock *gs4 = rcu_dereference(geneve->sock4);
- const struct ip_tunnel_key *key = &info->key;
-@@ -931,7 +932,7 @@ static int geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev,
- __be16 sport;
- int err;
-
-- if (!skb_vlan_inet_prepare(skb))
-+ if (!skb_vlan_inet_prepare(skb, inner_proto_inherit))
- return -EINVAL;
-
- sport = udp_flow_src_port(geneve->net, skb, 1, USHRT_MAX, true);
-@@ -1004,7 +1005,7 @@ static int geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev,
- }
-
- err = geneve_build_skb(&rt->dst, skb, info, xnet, sizeof(struct iphdr),
-- geneve->cfg.inner_proto_inherit);
-+ inner_proto_inherit);
- if (unlikely(err))
- return err;
-
-@@ -1020,6 +1021,7 @@ static int geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
- struct geneve_dev *geneve,
- const struct ip_tunnel_info *info)
- {
-+ bool inner_proto_inherit = geneve->cfg.inner_proto_inherit;
- bool xnet = !net_eq(geneve->net, dev_net(geneve->dev));
- struct geneve_sock *gs6 = rcu_dereference(geneve->sock6);
- const struct ip_tunnel_key *key = &info->key;
-@@ -1029,7 +1031,7 @@ static int geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
- __be16 sport;
- int err;
-
-- if (!skb_vlan_inet_prepare(skb))
-+ if (!skb_vlan_inet_prepare(skb, inner_proto_inherit))
- return -EINVAL;
-
- sport = udp_flow_src_port(geneve->net, skb, 1, USHRT_MAX, true);
-@@ -1084,7 +1086,7 @@ static int geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
- ttl = ttl ? : ip6_dst_hoplimit(dst);
- }
- err = geneve_build_skb(dst, skb, info, xnet, sizeof(struct ipv6hdr),
-- geneve->cfg.inner_proto_inherit);
-+ inner_proto_inherit);
- if (unlikely(err))
- return err;
-
-diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h
-index eca36edb85570..526b492ebf78d 100644
---- a/include/net/ip_tunnels.h
-+++ b/include/net/ip_tunnels.h
-@@ -334,9 +334,10 @@ static inline bool pskb_inet_may_pull(struct sk_buff *skb)
-
- /* Variant of pskb_inet_may_pull().
- */
--static inline bool skb_vlan_inet_prepare(struct sk_buff *skb)
-+static inline bool skb_vlan_inet_prepare(struct sk_buff *skb,
-+ bool inner_proto_inherit)
- {
-- int nhlen = 0, maclen = ETH_HLEN;
-+ int nhlen = 0, maclen = inner_proto_inherit ? 0 : ETH_HLEN;
- __be16 type = skb->protocol;
-
- /* Essentially this is skb_protocol(skb, true)
---
-2.43.0
-
+++ /dev/null
-From b87525165dae63e1b49e64c38848199b7e00b719 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Tue, 1 Feb 2022 12:02:59 +0000
-Subject: genirq: Allow the PM device to originate from irq domain
-
-From: Marc Zyngier <maz@kernel.org>
-
-[ Upstream commit 1f8863bfb5ca500ea1c7669b16b1931ba27fce20 ]
-
-As a preparation to moving the reference to the device used for
-runtime power management, add a new 'dev' field to the irqdomain
-structure for that exact purpose.
-
-The irq_chip_pm_{get,put}() helpers are made aware of the dual
-location via a new private helper.
-
-No functional change intended.
-
-Signed-off-by: Marc Zyngier <maz@kernel.org>
-Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
-Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
-Tested-by: Tony Lindgren <tony@atomide.com>
-Acked-by: Bartosz Golaszewski <brgl@bgdev.pl>
-Link: https://lore.kernel.org/r/20220201120310.878267-2-maz@kernel.org
-Stable-dep-of: 08af509efdf8 ("gpio: tqmx86: store IRQ trigger type and unmask status separately")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- include/linux/irqdomain.h | 10 ++++++++++
- kernel/irq/chip.c | 23 ++++++++++++++++++-----
- 2 files changed, 28 insertions(+), 5 deletions(-)
-
-diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
-index 9ee238ad29ce9..a7c80bd4b45b6 100644
---- a/include/linux/irqdomain.h
-+++ b/include/linux/irqdomain.h
-@@ -147,6 +147,8 @@ struct irq_domain_chip_generic;
- * @gc: Pointer to a list of generic chips. There is a helper function for
- * setting up one or more generic chips for interrupt controllers
- * drivers using the generic chip library which uses this pointer.
-+ * @dev: Pointer to a device that the domain represent, and that will be
-+ * used for power management purposes.
- * @parent: Pointer to parent irq_domain to support hierarchy irq_domains
- *
- * Revmap data, used internally by irq_domain
-@@ -167,6 +169,7 @@ struct irq_domain {
- struct fwnode_handle *fwnode;
- enum irq_domain_bus_token bus_token;
- struct irq_domain_chip_generic *gc;
-+ struct device *dev;
- #ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
- struct irq_domain *parent;
- #endif
-@@ -222,6 +225,13 @@ static inline struct device_node *irq_domain_get_of_node(struct irq_domain *d)
- return to_of_node(d->fwnode);
- }
-
-+static inline void irq_domain_set_pm_device(struct irq_domain *d,
-+ struct device *dev)
-+{
-+ if (d)
-+ d->dev = dev;
-+}
-+
- #ifdef CONFIG_IRQ_DOMAIN
- struct fwnode_handle *__irq_domain_alloc_fwnode(unsigned int type, int id,
- const char *name, phys_addr_t *pa);
-diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
-index f3920374f71ce..7ea66e55ef86b 100644
---- a/kernel/irq/chip.c
-+++ b/kernel/irq/chip.c
-@@ -1559,6 +1559,17 @@ int irq_chip_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
- return 0;
- }
-
-+static struct device *irq_get_parent_device(struct irq_data *data)
-+{
-+ if (data->chip->parent_device)
-+ return data->chip->parent_device;
-+
-+ if (data->domain)
-+ return data->domain->dev;
-+
-+ return NULL;
-+}
-+
- /**
- * irq_chip_pm_get - Enable power for an IRQ chip
- * @data: Pointer to interrupt specific data
-@@ -1568,12 +1579,13 @@ int irq_chip_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
- */
- int irq_chip_pm_get(struct irq_data *data)
- {
-+ struct device *dev = irq_get_parent_device(data);
- int retval;
-
-- if (IS_ENABLED(CONFIG_PM) && data->chip->parent_device) {
-- retval = pm_runtime_get_sync(data->chip->parent_device);
-+ if (IS_ENABLED(CONFIG_PM) && dev) {
-+ retval = pm_runtime_get_sync(dev);
- if (retval < 0) {
-- pm_runtime_put_noidle(data->chip->parent_device);
-+ pm_runtime_put_noidle(dev);
- return retval;
- }
- }
-@@ -1591,10 +1603,11 @@ int irq_chip_pm_get(struct irq_data *data)
- */
- int irq_chip_pm_put(struct irq_data *data)
- {
-+ struct device *dev = irq_get_parent_device(data);
- int retval = 0;
-
-- if (IS_ENABLED(CONFIG_PM) && data->chip->parent_device)
-- retval = pm_runtime_put(data->chip->parent_device);
-+ if (IS_ENABLED(CONFIG_PM) && dev)
-+ retval = pm_runtime_put(dev);
-
- return (retval < 0) ? retval : 0;
- }
---
-2.43.0
-
+++ /dev/null
-From c411d53be49d2d1077438662267c7f084dc3ba34 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Tue, 19 Apr 2022 15:18:39 +0100
-Subject: gpio: Add helpers to ease the transition towards immutable irq_chip
-
-From: Marc Zyngier <maz@kernel.org>
-
-[ Upstream commit 36b78aae4bfee749bbde73be570796bfd0f56bec ]
-
-Add a couple of new helpers to make it slightly simpler to convert
-drivers to immutable irq_chip structures:
-
-- GPIOCHIP_IRQ_RESOURCE_HELPERS populates the irq_chip structure
- with the resource management callbacks
-
-- gpio_irq_chip_set_chip() populates the gpio_irq_chip.chip
- structure, avoiding the proliferation of ugly casts
-
-Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
-Reviewed-by: Bartosz Golaszewski <brgl@bgdev.pl>
-Signed-off-by: Marc Zyngier <maz@kernel.org>
-Link: https://lore.kernel.org/r/20220419141846.598305-4-maz@kernel.org
-Stable-dep-of: 08af509efdf8 ("gpio: tqmx86: store IRQ trigger type and unmask status separately")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- include/linux/gpio/driver.h | 12 ++++++++++++
- 1 file changed, 12 insertions(+)
-
-diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
-index b241fc23ff3a2..91f60d1e3eb31 100644
---- a/include/linux/gpio/driver.h
-+++ b/include/linux/gpio/driver.h
-@@ -599,6 +599,18 @@ void gpiochip_enable_irq(struct gpio_chip *gc, unsigned int offset);
- int gpiochip_irq_reqres(struct irq_data *data);
- void gpiochip_irq_relres(struct irq_data *data);
-
-+/* Paste this in your irq_chip structure */
-+#define GPIOCHIP_IRQ_RESOURCE_HELPERS \
-+ .irq_request_resources = gpiochip_irq_reqres, \
-+ .irq_release_resources = gpiochip_irq_relres
-+
-+static inline void gpio_irq_chip_set_chip(struct gpio_irq_chip *girq,
-+ const struct irq_chip *chip)
-+{
-+ /* Yes, dropping const is ugly, but it isn't like we have a choice */
-+ girq->chip = (struct irq_chip *)chip;
-+}
-+
- /* Line status inquiry for drivers */
- bool gpiochip_line_is_open_drain(struct gpio_chip *gc, unsigned int offset);
- bool gpiochip_line_is_open_source(struct gpio_chip *gc, unsigned int offset);
---
-2.43.0
-
+++ /dev/null
-From 2c04ad8df019c95f15df956c6a7e956d7c5aee2e Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Tue, 19 Apr 2022 15:18:37 +0100
-Subject: gpio: Don't fiddle with irqchips marked as immutable
-
-From: Marc Zyngier <maz@kernel.org>
-
-[ Upstream commit 6c846d026d490b2383d395bc8e7b06336219667b ]
-
-In order to move away from gpiolib messing with the internals of
-unsuspecting irqchips, add a flag by which irqchips advertise
-that they are not to be messed with, and do solemnly swear that
-they correctly call into the gpiolib helpers when required.
-
-Also nudge the users into converting their drivers to the
-new model.
-
-Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
-Reviewed-by: Bartosz Golaszewski <brgl@bgdev.pl>
-Signed-off-by: Marc Zyngier <maz@kernel.org>
-Link: https://lore.kernel.org/r/20220419141846.598305-2-maz@kernel.org
-Stable-dep-of: 08af509efdf8 ("gpio: tqmx86: store IRQ trigger type and unmask status separately")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/gpio/gpiolib.c | 7 ++++++-
- include/linux/irq.h | 2 ++
- kernel/irq/debugfs.c | 1 +
- 3 files changed, 9 insertions(+), 1 deletion(-)
-
-diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
-index 34a061b4becdb..bf77c3f5a4e56 100644
---- a/drivers/gpio/gpiolib.c
-+++ b/drivers/gpio/gpiolib.c
-@@ -1483,6 +1483,11 @@ static void gpiochip_set_irq_hooks(struct gpio_chip *gc)
- {
- struct irq_chip *irqchip = gc->irq.chip;
-
-+ if (irqchip->flags & IRQCHIP_IMMUTABLE)
-+ return;
-+
-+ chip_warn(gc, "not an immutable chip, please consider fixing it!\n");
-+
- if (!irqchip->irq_request_resources &&
- !irqchip->irq_release_resources) {
- irqchip->irq_request_resources = gpiochip_irq_reqres;
-@@ -1650,7 +1655,7 @@ static void gpiochip_irqchip_remove(struct gpio_chip *gc)
- irq_domain_remove(gc->irq.domain);
- }
-
-- if (irqchip) {
-+ if (irqchip && !(irqchip->flags & IRQCHIP_IMMUTABLE)) {
- if (irqchip->irq_request_resources == gpiochip_irq_reqres) {
- irqchip->irq_request_resources = NULL;
- irqchip->irq_release_resources = NULL;
-diff --git a/include/linux/irq.h b/include/linux/irq.h
-index f9e6449fbbbae..296ef3b7d7afa 100644
---- a/include/linux/irq.h
-+++ b/include/linux/irq.h
-@@ -570,6 +570,7 @@ struct irq_chip {
- * IRQCHIP_ENABLE_WAKEUP_ON_SUSPEND: Invokes __enable_irq()/__disable_irq() for wake irqs
- * in the suspend path if they are in disabled state
- * IRQCHIP_AFFINITY_PRE_STARTUP: Default affinity update before startup
-+ * IRQCHIP_IMMUTABLE: Don't ever change anything in this chip
- */
- enum {
- IRQCHIP_SET_TYPE_MASKED = (1 << 0),
-@@ -583,6 +584,7 @@ enum {
- IRQCHIP_SUPPORTS_NMI = (1 << 8),
- IRQCHIP_ENABLE_WAKEUP_ON_SUSPEND = (1 << 9),
- IRQCHIP_AFFINITY_PRE_STARTUP = (1 << 10),
-+ IRQCHIP_IMMUTABLE = (1 << 11),
- };
-
- #include <linux/irqdesc.h>
-diff --git a/kernel/irq/debugfs.c b/kernel/irq/debugfs.c
-index e4cff358b437e..7ff52d94b42c0 100644
---- a/kernel/irq/debugfs.c
-+++ b/kernel/irq/debugfs.c
-@@ -58,6 +58,7 @@ static const struct irq_bit_descr irqchip_flags[] = {
- BIT_MASK_DESCR(IRQCHIP_SUPPORTS_LEVEL_MSI),
- BIT_MASK_DESCR(IRQCHIP_SUPPORTS_NMI),
- BIT_MASK_DESCR(IRQCHIP_ENABLE_WAKEUP_ON_SUSPEND),
-+ BIT_MASK_DESCR(IRQCHIP_IMMUTABLE),
- };
-
- static void
---
-2.43.0
-
+++ /dev/null
-From 334f6b83bffa3d0ea9e1849a3604a20adb5190a6 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Tue, 19 Apr 2022 15:18:38 +0100
-Subject: gpio: Expose the gpiochip_irq_re[ql]res helpers
-
-From: Marc Zyngier <maz@kernel.org>
-
-[ Upstream commit 704f08753b6dcd0e08c1953af0b2c7f3fac87111 ]
-
-The GPIO subsystem has a couple of internal helpers to manage
-resources on behalf of the irqchip. Expose them so that GPIO
-drivers can use them directly.
-
-Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
-Reviewed-by: Bartosz Golaszewski <brgl@bgdev.pl>
-Signed-off-by: Marc Zyngier <maz@kernel.org>
-Link: https://lore.kernel.org/r/20220419141846.598305-3-maz@kernel.org
-Stable-dep-of: 08af509efdf8 ("gpio: tqmx86: store IRQ trigger type and unmask status separately")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/gpio/gpiolib.c | 6 ++++--
- include/linux/gpio/driver.h | 4 ++++
- 2 files changed, 8 insertions(+), 2 deletions(-)
-
-diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
-index bf77c3f5a4e56..9e91e7f9596d4 100644
---- a/drivers/gpio/gpiolib.c
-+++ b/drivers/gpio/gpiolib.c
-@@ -1431,19 +1431,21 @@ static int gpiochip_to_irq(struct gpio_chip *gc, unsigned int offset)
- return irq_create_mapping(domain, offset);
- }
-
--static int gpiochip_irq_reqres(struct irq_data *d)
-+int gpiochip_irq_reqres(struct irq_data *d)
- {
- struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
-
- return gpiochip_reqres_irq(gc, d->hwirq);
- }
-+EXPORT_SYMBOL(gpiochip_irq_reqres);
-
--static void gpiochip_irq_relres(struct irq_data *d)
-+void gpiochip_irq_relres(struct irq_data *d)
- {
- struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
-
- gpiochip_relres_irq(gc, d->hwirq);
- }
-+EXPORT_SYMBOL(gpiochip_irq_relres);
-
- static void gpiochip_irq_mask(struct irq_data *d)
- {
-diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
-index 65df2ce96f0b1..b241fc23ff3a2 100644
---- a/include/linux/gpio/driver.h
-+++ b/include/linux/gpio/driver.h
-@@ -595,6 +595,10 @@ void gpiochip_relres_irq(struct gpio_chip *gc, unsigned int offset);
- void gpiochip_disable_irq(struct gpio_chip *gc, unsigned int offset);
- void gpiochip_enable_irq(struct gpio_chip *gc, unsigned int offset);
-
-+/* irq_data versions of the above */
-+int gpiochip_irq_reqres(struct irq_data *data);
-+void gpiochip_irq_relres(struct irq_data *data);
-+
- /* Line status inquiry for drivers */
- bool gpiochip_line_is_open_drain(struct gpio_chip *gc, unsigned int offset);
- bool gpiochip_line_is_open_source(struct gpio_chip *gc, unsigned int offset);
---
-2.43.0
-
+++ /dev/null
-From 5152f2434b824ef78f204af311af419c45a7da21 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Tue, 1 Feb 2022 12:03:07 +0000
-Subject: gpio: tpmx86: Move PM device over to irq domain
-
-From: Marc Zyngier <maz@kernel.org>
-
-[ Upstream commit 924610607f191bee4379bc3775b0fd025ad7e922 ]
-
-Move the reference to the device over to the irq domain.
-
-Signed-off-by: Marc Zyngier <maz@kernel.org>
-Acked-by: Bartosz Golaszewski <brgl@bgdev.pl>
-Link: https://lore.kernel.org/r/20220201120310.878267-10-maz@kernel.org
-Stable-dep-of: 08af509efdf8 ("gpio: tqmx86: store IRQ trigger type and unmask status separately")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/gpio/gpio-tqmx86.c | 3 ++-
- 1 file changed, 2 insertions(+), 1 deletion(-)
-
-diff --git a/drivers/gpio/gpio-tqmx86.c b/drivers/gpio/gpio-tqmx86.c
-index 65184ad2df1a0..171d66fcd9096 100644
---- a/drivers/gpio/gpio-tqmx86.c
-+++ b/drivers/gpio/gpio-tqmx86.c
-@@ -283,7 +283,6 @@ static int tqmx86_gpio_probe(struct platform_device *pdev)
- u8 irq_status;
-
- irq_chip->name = chip->label;
-- irq_chip->parent_device = &pdev->dev;
- irq_chip->irq_mask = tqmx86_gpio_irq_mask;
- irq_chip->irq_unmask = tqmx86_gpio_irq_unmask;
- irq_chip->irq_set_type = tqmx86_gpio_irq_set_type;
-@@ -318,6 +317,8 @@ static int tqmx86_gpio_probe(struct platform_device *pdev)
- goto out_pm_dis;
- }
-
-+ irq_domain_set_pm_device(girq->domain, dev);
-+
- dev_info(dev, "GPIO functionality initialized with %d pins\n",
- chip->ngpio);
-
---
-2.43.0
-
+++ /dev/null
-From a201198bf9e9221693f5911c94f96b7b5b72ee22 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Mon, 20 Mar 2023 10:55:12 +0100
-Subject: gpio: tqmx86: Convert to immutable irq_chip
-
-From: Linus Walleij <linus.walleij@linaro.org>
-
-[ Upstream commit 8e43827b6ae727a745ce7a8cc19184b28905a965 ]
-
-Convert the driver to immutable irq-chip with a bit of
-intuition.
-
-Cc: Marc Zyngier <maz@kernel.org>
-Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-Reviewed-by: Marc Zyngier <maz@kernel.org>
-Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
-Stable-dep-of: 08af509efdf8 ("gpio: tqmx86: store IRQ trigger type and unmask status separately")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/gpio/gpio-tqmx86.c | 28 ++++++++++++++++++++--------
- 1 file changed, 20 insertions(+), 8 deletions(-)
-
-diff --git a/drivers/gpio/gpio-tqmx86.c b/drivers/gpio/gpio-tqmx86.c
-index 171d66fcd9096..51a996d387b89 100644
---- a/drivers/gpio/gpio-tqmx86.c
-+++ b/drivers/gpio/gpio-tqmx86.c
-@@ -16,6 +16,7 @@
- #include <linux/module.h>
- #include <linux/platform_device.h>
- #include <linux/pm_runtime.h>
-+#include <linux/seq_file.h>
- #include <linux/slab.h>
-
- #define TQMX86_NGPIO 8
-@@ -35,7 +36,6 @@
-
- struct tqmx86_gpio_data {
- struct gpio_chip chip;
-- struct irq_chip irq_chip;
- void __iomem *io_base;
- int irq;
- raw_spinlock_t spinlock;
-@@ -119,6 +119,7 @@ static void tqmx86_gpio_irq_mask(struct irq_data *data)
- gpiic &= ~mask;
- tqmx86_gpio_write(gpio, gpiic, TQMX86_GPIIC);
- raw_spin_unlock_irqrestore(&gpio->spinlock, flags);
-+ gpiochip_disable_irq(&gpio->chip, irqd_to_hwirq(data));
- }
-
- static void tqmx86_gpio_irq_unmask(struct irq_data *data)
-@@ -131,6 +132,7 @@ static void tqmx86_gpio_irq_unmask(struct irq_data *data)
-
- mask = TQMX86_GPII_MASK << (offset * TQMX86_GPII_BITS);
-
-+ gpiochip_enable_irq(&gpio->chip, irqd_to_hwirq(data));
- raw_spin_lock_irqsave(&gpio->spinlock, flags);
- gpiic = tqmx86_gpio_read(gpio, TQMX86_GPIIC);
- gpiic &= ~mask;
-@@ -223,6 +225,22 @@ static void tqmx86_init_irq_valid_mask(struct gpio_chip *chip,
- clear_bit(3, valid_mask);
- }
-
-+static void tqmx86_gpio_irq_print_chip(struct irq_data *d, struct seq_file *p)
-+{
-+ struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
-+
-+ seq_printf(p, gc->label);
-+}
-+
-+static const struct irq_chip tqmx86_gpio_irq_chip = {
-+ .irq_mask = tqmx86_gpio_irq_mask,
-+ .irq_unmask = tqmx86_gpio_irq_unmask,
-+ .irq_set_type = tqmx86_gpio_irq_set_type,
-+ .irq_print_chip = tqmx86_gpio_irq_print_chip,
-+ .flags = IRQCHIP_IMMUTABLE,
-+ GPIOCHIP_IRQ_RESOURCE_HELPERS,
-+};
-+
- static int tqmx86_gpio_probe(struct platform_device *pdev)
- {
- struct device *dev = &pdev->dev;
-@@ -279,14 +297,8 @@ static int tqmx86_gpio_probe(struct platform_device *pdev)
- pm_runtime_enable(&pdev->dev);
-
- if (irq > 0) {
-- struct irq_chip *irq_chip = &gpio->irq_chip;
- u8 irq_status;
-
-- irq_chip->name = chip->label;
-- irq_chip->irq_mask = tqmx86_gpio_irq_mask;
-- irq_chip->irq_unmask = tqmx86_gpio_irq_unmask;
-- irq_chip->irq_set_type = tqmx86_gpio_irq_set_type;
--
- /* Mask all interrupts */
- tqmx86_gpio_write(gpio, 0, TQMX86_GPIIC);
-
-@@ -295,7 +307,7 @@ static int tqmx86_gpio_probe(struct platform_device *pdev)
- tqmx86_gpio_write(gpio, irq_status, TQMX86_GPIIS);
-
- girq = &chip->irq;
-- girq->chip = irq_chip;
-+ gpio_irq_chip_set_chip(girq, &tqmx86_gpio_irq_chip);
- girq->parent_handler = tqmx86_gpio_irq_handler;
- girq->num_parents = 1;
- girq->parents = devm_kcalloc(&pdev->dev, 1,
---
-2.43.0
-
+++ /dev/null
-From 135e150c7b5356868851c3770f03ba6f820a6289 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Thu, 30 May 2024 12:20:02 +0200
-Subject: gpio: tqmx86: fix broken IRQ_TYPE_EDGE_BOTH interrupt type
-
-From: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
-
-[ Upstream commit 90dd7de4ef7ba584823dfbeba834c2919a4bb55b ]
-
-The TQMx86 GPIO controller only supports falling and rising edge
-triggers, but not both. Fix this by implementing a software both-edge
-mode that toggles the edge type after every interrupt.
-
-Fixes: b868db94a6a7 ("gpio: tqmx86: Add GPIO from for this IO controller")
-Co-developed-by: Gregor Herburger <gregor.herburger@tq-group.com>
-Signed-off-by: Gregor Herburger <gregor.herburger@tq-group.com>
-Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
-Link: https://lore.kernel.org/r/515324f0491c4d44f4ef49f170354aca002d81ef.1717063994.git.matthias.schiffer@ew.tq-group.com
-Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/gpio/gpio-tqmx86.c | 46 ++++++++++++++++++++++++++++++++++----
- 1 file changed, 42 insertions(+), 4 deletions(-)
-
-diff --git a/drivers/gpio/gpio-tqmx86.c b/drivers/gpio/gpio-tqmx86.c
-index 4040c1e870607..bb3304a4cb150 100644
---- a/drivers/gpio/gpio-tqmx86.c
-+++ b/drivers/gpio/gpio-tqmx86.c
-@@ -32,6 +32,10 @@
- #define TQMX86_GPII_NONE 0
- #define TQMX86_GPII_FALLING BIT(0)
- #define TQMX86_GPII_RISING BIT(1)
-+/* Stored in irq_type as a trigger type, but not actually valid as a register
-+ * value, so the name doesn't use "GPII"
-+ */
-+#define TQMX86_INT_BOTH (BIT(0) | BIT(1))
- #define TQMX86_GPII_MASK (BIT(0) | BIT(1))
- #define TQMX86_GPII_BITS 2
- /* Stored in irq_type with GPII bits */
-@@ -113,9 +117,15 @@ static void tqmx86_gpio_irq_config(struct tqmx86_gpio_data *gpio, int offset)
- {
- u8 type = TQMX86_GPII_NONE, gpiic;
-
-- if (gpio->irq_type[offset] & TQMX86_INT_UNMASKED)
-+ if (gpio->irq_type[offset] & TQMX86_INT_UNMASKED) {
- type = gpio->irq_type[offset] & TQMX86_GPII_MASK;
-
-+ if (type == TQMX86_INT_BOTH)
-+ type = tqmx86_gpio_get(&gpio->chip, offset + TQMX86_NGPO)
-+ ? TQMX86_GPII_FALLING
-+ : TQMX86_GPII_RISING;
-+ }
-+
- gpiic = tqmx86_gpio_read(gpio, TQMX86_GPIIC);
- gpiic &= ~(TQMX86_GPII_MASK << (offset * TQMX86_GPII_BITS));
- gpiic |= type << (offset * TQMX86_GPII_BITS);
-@@ -169,7 +179,7 @@ static int tqmx86_gpio_irq_set_type(struct irq_data *data, unsigned int type)
- new_type = TQMX86_GPII_FALLING;
- break;
- case IRQ_TYPE_EDGE_BOTH:
-- new_type = TQMX86_GPII_FALLING | TQMX86_GPII_RISING;
-+ new_type = TQMX86_INT_BOTH;
- break;
- default:
- return -EINVAL; /* not supported */
-@@ -189,8 +199,8 @@ static void tqmx86_gpio_irq_handler(struct irq_desc *desc)
- struct gpio_chip *chip = irq_desc_get_handler_data(desc);
- struct tqmx86_gpio_data *gpio = gpiochip_get_data(chip);
- struct irq_chip *irq_chip = irq_desc_get_chip(desc);
-- unsigned long irq_bits;
-- int i = 0;
-+ unsigned long irq_bits, flags;
-+ int i;
- u8 irq_status;
-
- chained_irq_enter(irq_chip, desc);
-@@ -199,6 +209,34 @@ static void tqmx86_gpio_irq_handler(struct irq_desc *desc)
- tqmx86_gpio_write(gpio, irq_status, TQMX86_GPIIS);
-
- irq_bits = irq_status;
-+
-+ raw_spin_lock_irqsave(&gpio->spinlock, flags);
-+ for_each_set_bit(i, &irq_bits, TQMX86_NGPI) {
-+ /*
-+ * Edge-both triggers are implemented by flipping the edge
-+ * trigger after each interrupt, as the controller only supports
-+ * either rising or falling edge triggers, but not both.
-+ *
-+ * Internally, the TQMx86 GPIO controller has separate status
-+ * registers for rising and falling edge interrupts. GPIIC
-+ * configures which bits from which register are visible in the
-+ * interrupt status register GPIIS and defines what triggers the
-+ * parent IRQ line. Writing to GPIIS always clears both rising
-+ * and falling interrupt flags internally, regardless of the
-+ * currently configured trigger.
-+ *
-+ * In consequence, we can cleanly implement the edge-both
-+ * trigger in software by first clearing the interrupt and then
-+ * setting the new trigger based on the current GPIO input in
-+ * tqmx86_gpio_irq_config() - even if an edge arrives between
-+ * reading the input and setting the trigger, we will have a new
-+ * interrupt pending.
-+ */
-+ if ((gpio->irq_type[i] & TQMX86_GPII_MASK) == TQMX86_INT_BOTH)
-+ tqmx86_gpio_irq_config(gpio, i);
-+ }
-+ raw_spin_unlock_irqrestore(&gpio->spinlock, flags);
-+
- for_each_set_bit(i, &irq_bits, TQMX86_NGPI)
- generic_handle_domain_irq(gpio->chip.irq.domain,
- i + TQMX86_NGPO);
---
-2.43.0
-
+++ /dev/null
-From 1cc4fa426d3b52405e0ad25e8145619bec69aac2 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Thu, 30 May 2024 12:20:00 +0200
-Subject: gpio: tqmx86: introduce shadow register for GPIO output value
-
-From: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
-
-[ Upstream commit 9d6a811b522ba558bcb4ec01d12e72a0af8e9f6e ]
-
-The TQMx86 GPIO controller uses the same register address for input and
-output data. Reading the register will always return current inputs
-rather than the previously set outputs (regardless of the current
-direction setting). Therefore, using a RMW pattern does not make sense
-when setting output values. Instead, the previously set output register
-value needs to be stored as a shadow register.
-
-As there is no reliable way to get the current output values from the
-hardware, also initialize all channels to 0, to ensure that stored and
-actual output values match. This should usually not have any effect in
-practise, as the TQMx86 UEFI sets all outputs to 0 during boot.
-
-Also prepare for extension of the driver to more than 8 GPIOs by using
-DECLARE_BITMAP.
-
-Fixes: b868db94a6a7 ("gpio: tqmx86: Add GPIO from for this IO controller")
-Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
-Reviewed-by: Andrew Lunn <andrew@lunn.ch>
-Link: https://lore.kernel.org/r/d0555933becd45fa92a85675d26e4d59343ddc01.1717063994.git.matthias.schiffer@ew.tq-group.com
-Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/gpio/gpio-tqmx86.c | 18 +++++++++++-------
- 1 file changed, 11 insertions(+), 7 deletions(-)
-
-diff --git a/drivers/gpio/gpio-tqmx86.c b/drivers/gpio/gpio-tqmx86.c
-index db54f6c6c159b..65184ad2df1a0 100644
---- a/drivers/gpio/gpio-tqmx86.c
-+++ b/drivers/gpio/gpio-tqmx86.c
-@@ -6,6 +6,7 @@
- * Vadim V.Vlasov <vvlasov@dev.rtsoft.ru>
- */
-
-+#include <linux/bitmap.h>
- #include <linux/bitops.h>
- #include <linux/errno.h>
- #include <linux/gpio/driver.h>
-@@ -38,6 +39,7 @@ struct tqmx86_gpio_data {
- void __iomem *io_base;
- int irq;
- raw_spinlock_t spinlock;
-+ DECLARE_BITMAP(output, TQMX86_NGPIO);
- u8 irq_type[TQMX86_NGPI];
- };
-
-@@ -64,15 +66,10 @@ static void tqmx86_gpio_set(struct gpio_chip *chip, unsigned int offset,
- {
- struct tqmx86_gpio_data *gpio = gpiochip_get_data(chip);
- unsigned long flags;
-- u8 val;
-
- raw_spin_lock_irqsave(&gpio->spinlock, flags);
-- val = tqmx86_gpio_read(gpio, TQMX86_GPIOD);
-- if (value)
-- val |= BIT(offset);
-- else
-- val &= ~BIT(offset);
-- tqmx86_gpio_write(gpio, val, TQMX86_GPIOD);
-+ __assign_bit(offset, gpio->output, value);
-+ tqmx86_gpio_write(gpio, bitmap_get_value8(gpio->output, 0), TQMX86_GPIOD);
- raw_spin_unlock_irqrestore(&gpio->spinlock, flags);
- }
-
-@@ -259,6 +256,13 @@ static int tqmx86_gpio_probe(struct platform_device *pdev)
-
- tqmx86_gpio_write(gpio, (u8)~TQMX86_DIR_INPUT_MASK, TQMX86_GPIODD);
-
-+ /*
-+ * Reading the previous output state is not possible with TQMx86 hardware.
-+ * Initialize all outputs to 0 to have a defined state that matches the
-+ * shadow register.
-+ */
-+ tqmx86_gpio_write(gpio, 0, TQMX86_GPIOD);
-+
- chip = &gpio->chip;
- chip->label = "gpio-tqmx86";
- chip->owner = THIS_MODULE;
---
-2.43.0
-
+++ /dev/null
-From 43f7494a9d3f5f4c7e14e1da229a8262775bf4e1 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Tue, 1 Aug 2023 23:38:39 +0300
-Subject: gpio: tqmx86: remove unneeded call to platform_set_drvdata()
-
-From: Andrei Coardos <aboutphysycs@gmail.com>
-
-[ Upstream commit 0a5e9306b812fe3517548fab92b3d3d6ce7576e5 ]
-
-This function call was found to be unnecessary as there is no equivalent
-platform_get_drvdata() call to access the private data of the driver. Also,
-the private data is defined in this driver, so there is no risk of it being
-accessed outside of this driver file.
-
-Reviewed-by: Alexandru Ardelean <alex@shruggie.ro>
-Signed-off-by: Andrei Coardos <aboutphysycs@gmail.com>
-Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
-Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
-Stable-dep-of: 9d6a811b522b ("gpio: tqmx86: introduce shadow register for GPIO output value")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/gpio/gpio-tqmx86.c | 2 --
- 1 file changed, 2 deletions(-)
-
-diff --git a/drivers/gpio/gpio-tqmx86.c b/drivers/gpio/gpio-tqmx86.c
-index 5b103221b58dd..db54f6c6c159b 100644
---- a/drivers/gpio/gpio-tqmx86.c
-+++ b/drivers/gpio/gpio-tqmx86.c
-@@ -259,8 +259,6 @@ static int tqmx86_gpio_probe(struct platform_device *pdev)
-
- tqmx86_gpio_write(gpio, (u8)~TQMX86_DIR_INPUT_MASK, TQMX86_GPIODD);
-
-- platform_set_drvdata(pdev, gpio);
--
- chip = &gpio->chip;
- chip->label = "gpio-tqmx86";
- chip->owner = THIS_MODULE;
---
-2.43.0
-
-From 5674c759de450d40158d8935e4f7dc431cd2bc03 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
+From 08af509efdf8dad08e972b48de0e2c2a7919ea8b Mon Sep 17 00:00:00 2001
+From: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
Date: Thu, 30 May 2024 12:20:01 +0200
Subject: gpio: tqmx86: store IRQ trigger type and unmask status separately
From: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
-[ Upstream commit 08af509efdf8dad08e972b48de0e2c2a7919ea8b ]
+commit 08af509efdf8dad08e972b48de0e2c2a7919ea8b upstream.
irq_set_type() should not implicitly unmask the IRQ.
Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
Link: https://lore.kernel.org/r/6aa4f207f77cb58ef64ffb947e91949b0f753ccd.1717063994.git.matthias.schiffer@ew.tq-group.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
- drivers/gpio/gpio-tqmx86.c | 48 ++++++++++++++++++++++----------------
- 1 file changed, 28 insertions(+), 20 deletions(-)
+ drivers/gpio/gpio-tqmx86.c | 46 +++++++++++++++++++++++++--------------------
+ 1 file changed, 26 insertions(+), 20 deletions(-)
-diff --git a/drivers/gpio/gpio-tqmx86.c b/drivers/gpio/gpio-tqmx86.c
-index 51a996d387b89..4040c1e870607 100644
--- a/drivers/gpio/gpio-tqmx86.c
+++ b/drivers/gpio/gpio-tqmx86.c
-@@ -29,15 +29,19 @@
+@@ -27,16 +27,20 @@
#define TQMX86_GPIIC 3 /* GPI Interrupt Configuration Register */
#define TQMX86_GPIIS 4 /* GPI Interrupt Status Register */
struct tqmx86_gpio_data {
struct gpio_chip chip;
+ struct irq_chip irq_chip;
void __iomem *io_base;
int irq;
+ /* Lock must be held for accessing output and irq_type fields */
raw_spinlock_t spinlock;
- DECLARE_BITMAP(output, TQMX86_NGPIO);
u8 irq_type[TQMX86_NGPI];
-@@ -104,21 +108,32 @@ static int tqmx86_gpio_get_direction(struct gpio_chip *chip,
+ };
+@@ -107,20 +111,30 @@ static int tqmx86_gpio_get_direction(str
return GPIO_LINE_DIRECTION_OUT;
}
+ gpio->irq_type[offset] &= ~TQMX86_INT_UNMASKED;
+ tqmx86_gpio_irq_config(gpio, offset);
raw_spin_unlock_irqrestore(&gpio->spinlock, flags);
-+
- gpiochip_disable_irq(&gpio->chip, irqd_to_hwirq(data));
}
-@@ -128,16 +143,12 @@ static void tqmx86_gpio_irq_unmask(struct irq_data *data)
+@@ -130,15 +144,10 @@ static void tqmx86_gpio_irq_unmask(struc
struct tqmx86_gpio_data *gpio = gpiochip_get_data(
irq_data_get_irq_chip_data(data));
unsigned long flags;
-
- mask = TQMX86_GPII_MASK << (offset * TQMX86_GPII_BITS);
- gpiochip_enable_irq(&gpio->chip, irqd_to_hwirq(data));
-+
raw_spin_lock_irqsave(&gpio->spinlock, flags);
- gpiic = tqmx86_gpio_read(gpio, TQMX86_GPIIC);
- gpiic &= ~mask;
raw_spin_unlock_irqrestore(&gpio->spinlock, flags);
}
-@@ -148,7 +159,7 @@ static int tqmx86_gpio_irq_set_type(struct irq_data *data, unsigned int type)
+@@ -149,7 +158,7 @@ static int tqmx86_gpio_irq_set_type(stru
unsigned int offset = (data->hwirq - TQMX86_NGPO);
unsigned int edge_type = type & IRQF_TRIGGER_MASK;
unsigned long flags;
switch (edge_type) {
case IRQ_TYPE_EDGE_RISING:
-@@ -164,13 +175,10 @@ static int tqmx86_gpio_irq_set_type(struct irq_data *data, unsigned int type)
+@@ -165,13 +174,10 @@ static int tqmx86_gpio_irq_set_type(stru
return -EINVAL; /* not supported */
}
raw_spin_unlock_irqrestore(&gpio->spinlock, flags);
return 0;
---
-2.43.0
-
+++ /dev/null
-From 6d7a7df8c8f8f6f5a5572b4d451c594a7e57b7a9 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Mon, 8 Nov 2021 18:32:12 -0800
-Subject: kernel.h: split out container_of() and typeof_member() macros
-
-From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
-
-[ Upstream commit d2a8ebbf8192b84b11f1b204c4f7c602df32aeac ]
-
-kernel.h is being used as a dump for all kinds of stuff for a long time.
-Here is the attempt cleaning it up by splitting out container_of() and
-typeof_member() macros.
-
-For time being include new header back to kernel.h to avoid twisted
-indirected includes for existing users.
-
-Note, there are _a lot_ of headers and modules that include kernel.h
-solely for one of these macros and this allows to unburden compiler for
-the twisted inclusion paths and to make new code cleaner in the future.
-
-Link: https://lkml.kernel.org/r/20211013170417.87909-3-andriy.shevchenko@linux.intel.com
-Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
-Cc: Boqun Feng <boqun.feng@gmail.com>
-Cc: Brendan Higgins <brendanhiggins@google.com>
-Cc: Ingo Molnar <mingo@redhat.com>
-Cc: Jonathan Cameron <jic23@kernel.org>
-Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
-Cc: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
-Cc: Peter Zijlstra <peterz@infradead.org>
-Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
-Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
-Cc: Thomas Gleixner <tglx@linutronix.de>
-Cc: Thorsten Leemhuis <regressions@leemhuis.info>
-Cc: Waiman Long <longman@redhat.com>
-Cc: Will Deacon <will@kernel.org>
-Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
-Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-Stable-dep-of: 1981b296f858 ("platform/x86: dell-smbios: Fix wrong token data in sysfs")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- include/linux/container_of.h | 40 ++++++++++++++++++++++++++++++++++++
- include/linux/kernel.h | 33 +----------------------------
- 2 files changed, 41 insertions(+), 32 deletions(-)
- create mode 100644 include/linux/container_of.h
-
-diff --git a/include/linux/container_of.h b/include/linux/container_of.h
-new file mode 100644
-index 0000000000000..dd56019838c67
---- /dev/null
-+++ b/include/linux/container_of.h
-@@ -0,0 +1,40 @@
-+/* SPDX-License-Identifier: GPL-2.0 */
-+#ifndef _LINUX_CONTAINER_OF_H
-+#define _LINUX_CONTAINER_OF_H
-+
-+#include <linux/build_bug.h>
-+#include <linux/err.h>
-+
-+#define typeof_member(T, m) typeof(((T*)0)->m)
-+
-+/**
-+ * container_of - cast a member of a structure out to the containing structure
-+ * @ptr: the pointer to the member.
-+ * @type: the type of the container struct this is embedded in.
-+ * @member: the name of the member within the struct.
-+ *
-+ */
-+#define container_of(ptr, type, member) ({ \
-+ void *__mptr = (void *)(ptr); \
-+ BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
-+ !__same_type(*(ptr), void), \
-+ "pointer type mismatch in container_of()"); \
-+ ((type *)(__mptr - offsetof(type, member))); })
-+
-+/**
-+ * container_of_safe - cast a member of a structure out to the containing structure
-+ * @ptr: the pointer to the member.
-+ * @type: the type of the container struct this is embedded in.
-+ * @member: the name of the member within the struct.
-+ *
-+ * If IS_ERR_OR_NULL(ptr), ptr is returned unchanged.
-+ */
-+#define container_of_safe(ptr, type, member) ({ \
-+ void *__mptr = (void *)(ptr); \
-+ BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
-+ !__same_type(*(ptr), void), \
-+ "pointer type mismatch in container_of()"); \
-+ IS_ERR_OR_NULL(__mptr) ? ERR_CAST(__mptr) : \
-+ ((type *)(__mptr - offsetof(type, member))); })
-+
-+#endif /* _LINUX_CONTAINER_OF_H */
-diff --git a/include/linux/kernel.h b/include/linux/kernel.h
-index f56cd8879a594..568da581f2bac 100644
---- a/include/linux/kernel.h
-+++ b/include/linux/kernel.h
-@@ -9,6 +9,7 @@
- #include <linux/stddef.h>
- #include <linux/types.h>
- #include <linux/compiler.h>
-+#include <linux/container_of.h>
- #include <linux/bitops.h>
- #include <linux/kstrtox.h>
- #include <linux/log2.h>
-@@ -52,8 +53,6 @@
- } \
- )
-
--#define typeof_member(T, m) typeof(((T*)0)->m)
--
- #define _RET_IP_ (unsigned long)__builtin_return_address(0)
- #define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; })
-
-@@ -483,36 +482,6 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
- #define __CONCAT(a, b) a ## b
- #define CONCATENATE(a, b) __CONCAT(a, b)
-
--/**
-- * container_of - cast a member of a structure out to the containing structure
-- * @ptr: the pointer to the member.
-- * @type: the type of the container struct this is embedded in.
-- * @member: the name of the member within the struct.
-- *
-- */
--#define container_of(ptr, type, member) ({ \
-- void *__mptr = (void *)(ptr); \
-- BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
-- !__same_type(*(ptr), void), \
-- "pointer type mismatch in container_of()"); \
-- ((type *)(__mptr - offsetof(type, member))); })
--
--/**
-- * container_of_safe - cast a member of a structure out to the containing structure
-- * @ptr: the pointer to the member.
-- * @type: the type of the container struct this is embedded in.
-- * @member: the name of the member within the struct.
-- *
-- * If IS_ERR_OR_NULL(ptr), ptr is returned unchanged.
-- */
--#define container_of_safe(ptr, type, member) ({ \
-- void *__mptr = (void *)(ptr); \
-- BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
-- !__same_type(*(ptr), void), \
-- "pointer type mismatch in container_of()"); \
-- IS_ERR_OR_NULL(__mptr) ? ERR_CAST(__mptr) : \
-- ((type *)(__mptr - offsetof(type, member))); })
--
- /* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */
- #ifdef CONFIG_FTRACE_MCOUNT_RECORD
- # define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD
---
-2.43.0
-
+++ /dev/null
-From e93e11a518b4e0f71efa8a5b7d2839095c1db1ed Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Fri, 27 May 2022 23:23:52 +0530
-Subject: mmc: core: Capture eMMC and SD card errors
-
-From: Shaik Sajida Bhanu <quic_c_sbhanu@quicinc.com>
-
-[ Upstream commit 91f059c95c6a5dbc0907a5f871e7915a5e93c1f9 ]
-
-Add changes to capture eMMC and SD card errors.
-This is useful for debug and testing.
-
-Signed-off-by: Liangliang Lu <quic_luliang@quicinc.com>
-Signed-off-by: Sayali Lokhande <quic_sayalil@quicinc.com>
-Signed-off-by: Bao D. Nguyen <quic_nguyenb@quicinc.com>
-Signed-off-by: Ram Prakash Gupta <quic_rampraka@quicinc.com>
-Signed-off-by: Shaik Sajida Bhanu <quic_c_sbhanu@quicinc.com>
-Acked-by: Adrian Hunter <adrian.hunter@intel.com>
-Link: https://lore.kernel.org/r/1653674036-21829-2-git-send-email-quic_c_sbhanu@quicinc.com
-Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-Stable-dep-of: b3855668d98c ("mmc: sdhci: Add support for "Tuning Error" interrupts")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/mmc/core/core.c | 10 +++++++++-
- include/linux/mmc/host.h | 26 ++++++++++++++++++++++++++
- 2 files changed, 35 insertions(+), 1 deletion(-)
-
-diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
-index a6dcc68d68eec..3a8e49ffe98ef 100644
---- a/drivers/mmc/core/core.c
-+++ b/drivers/mmc/core/core.c
-@@ -948,9 +948,11 @@ int mmc_execute_tuning(struct mmc_card *card)
- }
-
- /* Only print error when we don't check for card removal */
-- if (!host->detect_change)
-+ if (!host->detect_change) {
- pr_err("%s: tuning execution failed: %d\n",
- mmc_hostname(host), err);
-+ mmc_debugfs_err_stats_inc(host, MMC_ERR_TUNING);
-+ }
-
- return err;
- }
-@@ -2258,6 +2260,12 @@ void mmc_rescan(struct work_struct *work)
- if (freqs[i] <= host->f_min)
- break;
- }
-+
-+ /*
-+ * Ignore the command timeout errors observed during
-+ * the card init as those are excepted.
-+ */
-+ host->err_stats[MMC_ERR_CMD_TIMEOUT] = 0;
- mmc_release_host(host);
-
- out:
-diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
-index a4ec7269b6295..cdc82cc228601 100644
---- a/include/linux/mmc/host.h
-+++ b/include/linux/mmc/host.h
-@@ -93,6 +93,25 @@ struct mmc_clk_phase_map {
-
- struct mmc_host;
-
-+enum mmc_err_stat {
-+ MMC_ERR_CMD_TIMEOUT,
-+ MMC_ERR_CMD_CRC,
-+ MMC_ERR_DAT_TIMEOUT,
-+ MMC_ERR_DAT_CRC,
-+ MMC_ERR_AUTO_CMD,
-+ MMC_ERR_ADMA,
-+ MMC_ERR_TUNING,
-+ MMC_ERR_CMDQ_RED,
-+ MMC_ERR_CMDQ_GCE,
-+ MMC_ERR_CMDQ_ICCE,
-+ MMC_ERR_REQ_TIMEOUT,
-+ MMC_ERR_CMDQ_REQ_TIMEOUT,
-+ MMC_ERR_ICE_CFG,
-+ MMC_ERR_CTRL_TIMEOUT,
-+ MMC_ERR_UNEXPECTED_IRQ,
-+ MMC_ERR_MAX,
-+};
-+
- struct mmc_host_ops {
- /*
- * It is optional for the host to implement pre_req and post_req in
-@@ -499,6 +518,7 @@ struct mmc_host {
- /* Host Software Queue support */
- bool hsq_enabled;
-
-+ u32 err_stats[MMC_ERR_MAX];
- unsigned long private[] ____cacheline_aligned;
- };
-
-@@ -635,6 +655,12 @@ static inline enum dma_data_direction mmc_get_dma_dir(struct mmc_data *data)
- return data->flags & MMC_DATA_WRITE ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
- }
-
-+static inline void mmc_debugfs_err_stats_inc(struct mmc_host *host,
-+ enum mmc_err_stat stat)
-+{
-+ host->err_stats[stat] += 1;
-+}
-+
- int mmc_send_tuning(struct mmc_host *host, u32 opcode, int *cmd_error);
- int mmc_send_abort_tuning(struct mmc_host *host, u32 opcode);
-
---
-2.43.0
-
+++ /dev/null
-From 5f0d7873f6c22c8acf5dae68f0e6e0b5b2e2b8e5 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 10 Apr 2024 21:16:35 +0200
-Subject: mmc: sdhci: Add support for "Tuning Error" interrupts
-
-From: Adrian Hunter <adrian.hunter@intel.com>
-
-[ Upstream commit b3855668d98cf9c6aec2db999dd27d872f8ba878 ]
-
-Most Bay Trail devices do not enable UHS modes for the external sdcard slot
-the Lenovo Yoga Tablet 2 830 / 1050 and Lenovo Yoga Tablet 2 Pro 1380 (8",
-10" and 13") models however do enable this.
-
-Using a UHS cards in these tablets results in errors like this one:
-
-[ 225.272001] mmc2: Unexpected interrupt 0x04000000.
-[ 225.272024] mmc2: sdhci: ============ SDHCI REGISTER DUMP ===========
-[ 225.272034] mmc2: sdhci: Sys addr: 0x0712c400 | Version: 0x0000b502
-[ 225.272044] mmc2: sdhci: Blk size: 0x00007200 | Blk cnt: 0x00000007
-[ 225.272054] mmc2: sdhci: Argument: 0x00000000 | Trn mode: 0x00000023
-[ 225.272064] mmc2: sdhci: Present: 0x01e20002 | Host ctl: 0x00000016
-[ 225.272073] mmc2: sdhci: Power: 0x0000000f | Blk gap: 0x00000000
-[ 225.272082] mmc2: sdhci: Wake-up: 0x00000000 | Clock: 0x00000107
-[ 225.272092] mmc2: sdhci: Timeout: 0x0000000e | Int stat: 0x00000001
-[ 225.272101] mmc2: sdhci: Int enab: 0x03ff000b | Sig enab: 0x03ff000b
-[ 225.272110] mmc2: sdhci: ACmd stat: 0x00000000 | Slot int: 0x00000001
-[ 225.272119] mmc2: sdhci: Caps: 0x076864b2 | Caps_1: 0x00000004
-[ 225.272129] mmc2: sdhci: Cmd: 0x00000c1b | Max curr: 0x00000000
-[ 225.272138] mmc2: sdhci: Resp[0]: 0x00000c00 | Resp[1]: 0x00000000
-[ 225.272147] mmc2: sdhci: Resp[2]: 0x00000000 | Resp[3]: 0x00000900
-[ 225.272155] mmc2: sdhci: Host ctl2: 0x0000000c
-[ 225.272164] mmc2: sdhci: ADMA Err: 0x00000003 | ADMA Ptr: 0x0712c200
-[ 225.272172] mmc2: sdhci: ============================================
-
-which results in IO errors leading to issues accessing the sdcard.
-
-0x04000000 is a so-called "Tuning Error" which sofar the SDHCI driver
-does not support / enable. Modify the IRQ handler to process these.
-
-This fixes UHS microsd cards not working with these tablets.
-
-Link: https://lore.kernel.org/r/199bb4aa-c6b5-453e-be37-58bbf468800c@intel.com
-Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
-Cc: stable@vger.kernel.org
-Link: https://lore.kernel.org/r/20240410191639.526324-3-hdegoede@redhat.com
-Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/mmc/host/sdhci.c | 10 ++++++++--
- drivers/mmc/host/sdhci.h | 3 ++-
- 2 files changed, 10 insertions(+), 3 deletions(-)
-
-diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
-index 0c181ccd5d03a..167a18724e1a4 100644
---- a/drivers/mmc/host/sdhci.c
-+++ b/drivers/mmc/host/sdhci.c
-@@ -3425,12 +3425,18 @@ static void sdhci_data_irq(struct sdhci_host *host, u32 intmask)
- host->data->error = -EILSEQ;
- if (!mmc_op_tuning(SDHCI_GET_CMD(sdhci_readw(host, SDHCI_COMMAND))))
- sdhci_err_stats_inc(host, DAT_CRC);
-- } else if ((intmask & SDHCI_INT_DATA_CRC) &&
-+ } else if ((intmask & (SDHCI_INT_DATA_CRC | SDHCI_INT_TUNING_ERROR)) &&
- SDHCI_GET_CMD(sdhci_readw(host, SDHCI_COMMAND))
- != MMC_BUS_TEST_R) {
- host->data->error = -EILSEQ;
- if (!mmc_op_tuning(SDHCI_GET_CMD(sdhci_readw(host, SDHCI_COMMAND))))
- sdhci_err_stats_inc(host, DAT_CRC);
-+ if (intmask & SDHCI_INT_TUNING_ERROR) {
-+ u16 ctrl2 = sdhci_readw(host, SDHCI_HOST_CONTROL2);
-+
-+ ctrl2 &= ~SDHCI_CTRL_TUNED_CLK;
-+ sdhci_writew(host, ctrl2, SDHCI_HOST_CONTROL2);
-+ }
- } else if (intmask & SDHCI_INT_ADMA_ERROR) {
- pr_err("%s: ADMA error: 0x%08x\n", mmc_hostname(host->mmc),
- intmask);
-@@ -3967,7 +3973,7 @@ bool sdhci_cqe_irq(struct sdhci_host *host, u32 intmask, int *cmd_error,
- } else
- *cmd_error = 0;
-
-- if (intmask & (SDHCI_INT_DATA_END_BIT | SDHCI_INT_DATA_CRC)) {
-+ if (intmask & (SDHCI_INT_DATA_END_BIT | SDHCI_INT_DATA_CRC | SDHCI_INT_TUNING_ERROR)) {
- *data_error = -EILSEQ;
- if (!mmc_op_tuning(host->cmd->opcode))
- sdhci_err_stats_inc(host, DAT_CRC);
-diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
-index 0edd576dbe51d..e3906991016bd 100644
---- a/drivers/mmc/host/sdhci.h
-+++ b/drivers/mmc/host/sdhci.h
-@@ -151,6 +151,7 @@
- #define SDHCI_INT_BUS_POWER 0x00800000
- #define SDHCI_INT_AUTO_CMD_ERR 0x01000000
- #define SDHCI_INT_ADMA_ERROR 0x02000000
-+#define SDHCI_INT_TUNING_ERROR 0x04000000
-
- #define SDHCI_INT_NORMAL_MASK 0x00007FFF
- #define SDHCI_INT_ERROR_MASK 0xFFFF8000
-@@ -162,7 +163,7 @@
- SDHCI_INT_DATA_AVAIL | SDHCI_INT_SPACE_AVAIL | \
- SDHCI_INT_DATA_TIMEOUT | SDHCI_INT_DATA_CRC | \
- SDHCI_INT_DATA_END_BIT | SDHCI_INT_ADMA_ERROR | \
-- SDHCI_INT_BLK_GAP)
-+ SDHCI_INT_BLK_GAP | SDHCI_INT_TUNING_ERROR)
- #define SDHCI_INT_ALL_MASK ((unsigned int)-1)
-
- #define SDHCI_CQE_INT_ERR_MASK ( \
---
-2.43.0
-
+++ /dev/null
-From 8be3b882cfb789cc333ff564a974969e9620e80e Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Fri, 27 May 2022 23:23:53 +0530
-Subject: mmc: sdhci: Capture eMMC and SD card errors
-
-From: Shaik Sajida Bhanu <quic_c_sbhanu@quicinc.com>
-
-[ Upstream commit efe8f5c9b5e118070f424205078ababc46fd130a ]
-
-Add changes to capture eMMC and SD card errors.
-This is useful for debug and testing.
-
-Signed-off-by: Liangliang Lu <quic_luliang@quicinc.com>
-Signed-off-by: Sayali Lokhande <quic_sayalil@quicinc.com>
-Signed-off-by: Bao D. Nguyen <quic_nguyenb@quicinc.com>
-Signed-off-by: Shaik Sajida Bhanu <quic_c_sbhanu@quicinc.com>
-Acked-by: Adrian Hunter <adrian.hunter@intel.com>
-Link: https://lore.kernel.org/r/1653674036-21829-3-git-send-email-quic_c_sbhanu@quicinc.com
-Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-Stable-dep-of: b3855668d98c ("mmc: sdhci: Add support for "Tuning Error" interrupts")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/mmc/host/sdhci.c | 59 ++++++++++++++++++++++++++++++----------
- drivers/mmc/host/sdhci.h | 3 ++
- include/linux/mmc/mmc.h | 6 ++++
- 3 files changed, 53 insertions(+), 15 deletions(-)
-
-diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
-index ca8b147687986..0c181ccd5d03a 100644
---- a/drivers/mmc/host/sdhci.c
-+++ b/drivers/mmc/host/sdhci.c
-@@ -224,6 +224,7 @@ void sdhci_reset(struct sdhci_host *host, u8 mask)
- if (timedout) {
- pr_err("%s: Reset 0x%x never completed.\n",
- mmc_hostname(host->mmc), (int)mask);
-+ sdhci_err_stats_inc(host, CTRL_TIMEOUT);
- sdhci_dumpregs(host);
- return;
- }
-@@ -1720,6 +1721,7 @@ static bool sdhci_send_command_retry(struct sdhci_host *host,
- if (!timeout--) {
- pr_err("%s: Controller never released inhibit bit(s).\n",
- mmc_hostname(host->mmc));
-+ sdhci_err_stats_inc(host, CTRL_TIMEOUT);
- sdhci_dumpregs(host);
- cmd->error = -EIO;
- return false;
-@@ -1969,6 +1971,7 @@ void sdhci_enable_clk(struct sdhci_host *host, u16 clk)
- if (timedout) {
- pr_err("%s: Internal clock never stabilised.\n",
- mmc_hostname(host->mmc));
-+ sdhci_err_stats_inc(host, CTRL_TIMEOUT);
- sdhci_dumpregs(host);
- return;
- }
-@@ -1991,6 +1994,7 @@ void sdhci_enable_clk(struct sdhci_host *host, u16 clk)
- if (timedout) {
- pr_err("%s: PLL clock never stabilised.\n",
- mmc_hostname(host->mmc));
-+ sdhci_err_stats_inc(host, CTRL_TIMEOUT);
- sdhci_dumpregs(host);
- return;
- }
-@@ -3190,6 +3194,7 @@ static void sdhci_timeout_timer(struct timer_list *t)
- if (host->cmd && !sdhci_data_line_cmd(host->cmd)) {
- pr_err("%s: Timeout waiting for hardware cmd interrupt.\n",
- mmc_hostname(host->mmc));
-+ sdhci_err_stats_inc(host, REQ_TIMEOUT);
- sdhci_dumpregs(host);
-
- host->cmd->error = -ETIMEDOUT;
-@@ -3212,6 +3217,7 @@ static void sdhci_timeout_data_timer(struct timer_list *t)
- (host->cmd && sdhci_data_line_cmd(host->cmd))) {
- pr_err("%s: Timeout waiting for hardware interrupt.\n",
- mmc_hostname(host->mmc));
-+ sdhci_err_stats_inc(host, REQ_TIMEOUT);
- sdhci_dumpregs(host);
-
- if (host->data) {
-@@ -3263,17 +3269,21 @@ static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask, u32 *intmask_p)
- return;
- pr_err("%s: Got command interrupt 0x%08x even though no command operation was in progress.\n",
- mmc_hostname(host->mmc), (unsigned)intmask);
-+ sdhci_err_stats_inc(host, UNEXPECTED_IRQ);
- sdhci_dumpregs(host);
- return;
- }
-
- if (intmask & (SDHCI_INT_TIMEOUT | SDHCI_INT_CRC |
- SDHCI_INT_END_BIT | SDHCI_INT_INDEX)) {
-- if (intmask & SDHCI_INT_TIMEOUT)
-+ if (intmask & SDHCI_INT_TIMEOUT) {
- host->cmd->error = -ETIMEDOUT;
-- else
-+ sdhci_err_stats_inc(host, CMD_TIMEOUT);
-+ } else {
- host->cmd->error = -EILSEQ;
--
-+ if (!mmc_op_tuning(host->cmd->opcode))
-+ sdhci_err_stats_inc(host, CMD_CRC);
-+ }
- /* Treat data command CRC error the same as data CRC error */
- if (host->cmd->data &&
- (intmask & (SDHCI_INT_CRC | SDHCI_INT_TIMEOUT)) ==
-@@ -3295,6 +3305,8 @@ static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask, u32 *intmask_p)
- -ETIMEDOUT :
- -EILSEQ;
-
-+ sdhci_err_stats_inc(host, AUTO_CMD);
-+
- if (sdhci_auto_cmd23(host, mrq)) {
- mrq->sbc->error = err;
- __sdhci_finish_mrq(host, mrq);
-@@ -3371,6 +3383,7 @@ static void sdhci_data_irq(struct sdhci_host *host, u32 intmask)
- if (intmask & SDHCI_INT_DATA_TIMEOUT) {
- host->data_cmd = NULL;
- data_cmd->error = -ETIMEDOUT;
-+ sdhci_err_stats_inc(host, CMD_TIMEOUT);
- __sdhci_finish_mrq(host, data_cmd->mrq);
- return;
- }
-@@ -3399,23 +3412,30 @@ static void sdhci_data_irq(struct sdhci_host *host, u32 intmask)
-
- pr_err("%s: Got data interrupt 0x%08x even though no data operation was in progress.\n",
- mmc_hostname(host->mmc), (unsigned)intmask);
-+ sdhci_err_stats_inc(host, UNEXPECTED_IRQ);
- sdhci_dumpregs(host);
-
- return;
- }
-
-- if (intmask & SDHCI_INT_DATA_TIMEOUT)
-+ if (intmask & SDHCI_INT_DATA_TIMEOUT) {
- host->data->error = -ETIMEDOUT;
-- else if (intmask & SDHCI_INT_DATA_END_BIT)
-+ sdhci_err_stats_inc(host, DAT_TIMEOUT);
-+ } else if (intmask & SDHCI_INT_DATA_END_BIT) {
- host->data->error = -EILSEQ;
-- else if ((intmask & SDHCI_INT_DATA_CRC) &&
-+ if (!mmc_op_tuning(SDHCI_GET_CMD(sdhci_readw(host, SDHCI_COMMAND))))
-+ sdhci_err_stats_inc(host, DAT_CRC);
-+ } else if ((intmask & SDHCI_INT_DATA_CRC) &&
- SDHCI_GET_CMD(sdhci_readw(host, SDHCI_COMMAND))
-- != MMC_BUS_TEST_R)
-+ != MMC_BUS_TEST_R) {
- host->data->error = -EILSEQ;
-- else if (intmask & SDHCI_INT_ADMA_ERROR) {
-+ if (!mmc_op_tuning(SDHCI_GET_CMD(sdhci_readw(host, SDHCI_COMMAND))))
-+ sdhci_err_stats_inc(host, DAT_CRC);
-+ } else if (intmask & SDHCI_INT_ADMA_ERROR) {
- pr_err("%s: ADMA error: 0x%08x\n", mmc_hostname(host->mmc),
- intmask);
- sdhci_adma_show_error(host);
-+ sdhci_err_stats_inc(host, ADMA);
- host->data->error = -EIO;
- if (host->ops->adma_workaround)
- host->ops->adma_workaround(host, intmask);
-@@ -3613,6 +3633,7 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id)
- if (unexpected) {
- pr_err("%s: Unexpected interrupt 0x%08x.\n",
- mmc_hostname(host->mmc), unexpected);
-+ sdhci_err_stats_inc(host, UNEXPECTED_IRQ);
- sdhci_dumpregs(host);
- }
-
-@@ -3936,20 +3957,27 @@ bool sdhci_cqe_irq(struct sdhci_host *host, u32 intmask, int *cmd_error,
- if (!host->cqe_on)
- return false;
-
-- if (intmask & (SDHCI_INT_INDEX | SDHCI_INT_END_BIT | SDHCI_INT_CRC))
-+ if (intmask & (SDHCI_INT_INDEX | SDHCI_INT_END_BIT | SDHCI_INT_CRC)) {
- *cmd_error = -EILSEQ;
-- else if (intmask & SDHCI_INT_TIMEOUT)
-+ if (!mmc_op_tuning(host->cmd->opcode))
-+ sdhci_err_stats_inc(host, CMD_CRC);
-+ } else if (intmask & SDHCI_INT_TIMEOUT) {
- *cmd_error = -ETIMEDOUT;
-- else
-+ sdhci_err_stats_inc(host, CMD_TIMEOUT);
-+ } else
- *cmd_error = 0;
-
-- if (intmask & (SDHCI_INT_DATA_END_BIT | SDHCI_INT_DATA_CRC))
-+ if (intmask & (SDHCI_INT_DATA_END_BIT | SDHCI_INT_DATA_CRC)) {
- *data_error = -EILSEQ;
-- else if (intmask & SDHCI_INT_DATA_TIMEOUT)
-+ if (!mmc_op_tuning(host->cmd->opcode))
-+ sdhci_err_stats_inc(host, DAT_CRC);
-+ } else if (intmask & SDHCI_INT_DATA_TIMEOUT) {
- *data_error = -ETIMEDOUT;
-- else if (intmask & SDHCI_INT_ADMA_ERROR)
-+ sdhci_err_stats_inc(host, DAT_TIMEOUT);
-+ } else if (intmask & SDHCI_INT_ADMA_ERROR) {
- *data_error = -EIO;
-- else
-+ sdhci_err_stats_inc(host, ADMA);
-+ } else
- *data_error = 0;
-
- /* Clear selected interrupts. */
-@@ -3965,6 +3993,7 @@ bool sdhci_cqe_irq(struct sdhci_host *host, u32 intmask, int *cmd_error,
- sdhci_writel(host, intmask, SDHCI_INT_STATUS);
- pr_err("%s: CQE: Unexpected interrupt 0x%08x.\n",
- mmc_hostname(host->mmc), intmask);
-+ sdhci_err_stats_inc(host, UNEXPECTED_IRQ);
- sdhci_dumpregs(host);
- }
-
-diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
-index 6a5cc05576cd5..0edd576dbe51d 100644
---- a/drivers/mmc/host/sdhci.h
-+++ b/drivers/mmc/host/sdhci.h
-@@ -356,6 +356,9 @@ struct sdhci_adma2_64_desc {
- */
- #define MMC_CMD_TRANSFER_TIME (10 * NSEC_PER_MSEC) /* max 10 ms */
-
-+#define sdhci_err_stats_inc(host, err_name) \
-+ mmc_debugfs_err_stats_inc((host)->mmc, MMC_ERR_##err_name)
-+
- enum sdhci_cookie {
- COOKIE_UNMAPPED,
- COOKIE_PRE_MAPPED, /* mapped by sdhci_pre_req() */
-diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h
-index 545578fb814b0..6f7993803ee78 100644
---- a/include/linux/mmc/mmc.h
-+++ b/include/linux/mmc/mmc.h
-@@ -99,6 +99,12 @@ static inline bool mmc_op_multi(u32 opcode)
- opcode == MMC_READ_MULTIPLE_BLOCK;
- }
-
-+static inline bool mmc_op_tuning(u32 opcode)
-+{
-+ return opcode == MMC_SEND_TUNING_BLOCK ||
-+ opcode == MMC_SEND_TUNING_BLOCK_HS200;
-+}
-+
- /*
- * MMC_SWITCH argument format:
- *
---
-2.43.0
-
+++ /dev/null
-From 639b191590ec3b36f8e1c336f1c181b55743bbff Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 25 Aug 2021 18:33:45 +0900
-Subject: mmc: sdhci: Change the code to check auto_cmd23
-
-From: ChanWoo Lee <cw9316.lee@samsung.com>
-
-[ Upstream commit 38929d4f0d811df399c99398ce0599f546369bd4 ]
-
-It is replaced with a function that is already declared.
-//[1/5] mmc: sdhci: Add helpers for the auto-CMD23 flag
-//20200412090349.1607-2-adrian.hunter@intel.com
-
-Signed-off-by: ChanWoo Lee <cw9316.lee@samsung.com>
-Acked-by: Adrian Hunter <adrian.hunter@intel.com>
-Link: https://lore.kernel.org/r/20210825093345.14706-1-cw9316.lee@samsung.com
-Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-Stable-dep-of: b3855668d98c ("mmc: sdhci: Add support for "Tuning Error" interrupts")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/mmc/host/sdhci.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
-index d897c981b079f..ca8b147687986 100644
---- a/drivers/mmc/host/sdhci.c
-+++ b/drivers/mmc/host/sdhci.c
-@@ -3295,7 +3295,7 @@ static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask, u32 *intmask_p)
- -ETIMEDOUT :
- -EILSEQ;
-
-- if (mrq->sbc && (host->flags & SDHCI_AUTO_CMD23)) {
-+ if (sdhci_auto_cmd23(host, mrq)) {
- mrq->sbc->error = err;
- __sdhci_finish_mrq(host, mrq);
- return;
---
-2.43.0
-
+++ /dev/null
-From 22a477d9afb27913859c9a0b757f579b0ec260e3 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 16 Mar 2022 08:15:57 +0200
-Subject: net: geneve: support IPv4/IPv6 as inner protocol
-
-From: Eyal Birger <eyal.birger@gmail.com>
-
-[ Upstream commit 435fe1c0c1f74b682dba85641406abf4337aade6 ]
-
-This patch adds support for encapsulating IPv4/IPv6 within GENEVE.
-
-In order to use this, a new IFLA_GENEVE_INNER_PROTO_INHERIT flag needs
-to be provided at device creation. This property cannot be changed for
-the time being.
-
-In case IP traffic is received on a non-tun device the drop count is
-increased.
-
-Signed-off-by: Eyal Birger <eyal.birger@gmail.com>
-Link: https://lore.kernel.org/r/20220316061557.431872-1-eyal.birger@gmail.com
-Signed-off-by: Paolo Abeni <pabeni@redhat.com>
-Stable-dep-of: c6ae073f5903 ("geneve: Fix incorrect inner network header offset when innerprotoinherit is set")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/net/geneve.c | 82 +++++++++++++++++++++++++++---------
- include/uapi/linux/if_link.h | 1 +
- 2 files changed, 64 insertions(+), 19 deletions(-)
-
-diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
-index 0e4ea3c0fe829..3f076dadff78b 100644
---- a/drivers/net/geneve.c
-+++ b/drivers/net/geneve.c
-@@ -55,6 +55,7 @@ struct geneve_config {
- bool use_udp6_rx_checksums;
- bool ttl_inherit;
- enum ifla_geneve_df df;
-+ bool inner_proto_inherit;
- };
-
- /* Pseudo network device */
-@@ -250,17 +251,24 @@ static void geneve_rx(struct geneve_dev *geneve, struct geneve_sock *gs,
- }
- }
-
-- skb_reset_mac_header(skb);
-- skb->protocol = eth_type_trans(skb, geneve->dev);
-- skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN);
--
- if (tun_dst)
- skb_dst_set(skb, &tun_dst->dst);
-
-- /* Ignore packet loops (and multicast echo) */
-- if (ether_addr_equal(eth_hdr(skb)->h_source, geneve->dev->dev_addr)) {
-- geneve->dev->stats.rx_errors++;
-- goto drop;
-+ if (gnvh->proto_type == htons(ETH_P_TEB)) {
-+ skb_reset_mac_header(skb);
-+ skb->protocol = eth_type_trans(skb, geneve->dev);
-+ skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN);
-+
-+ /* Ignore packet loops (and multicast echo) */
-+ if (ether_addr_equal(eth_hdr(skb)->h_source,
-+ geneve->dev->dev_addr)) {
-+ geneve->dev->stats.rx_errors++;
-+ goto drop;
-+ }
-+ } else {
-+ skb_reset_mac_header(skb);
-+ skb->dev = geneve->dev;
-+ skb->pkt_type = PACKET_HOST;
- }
-
- /* Save offset of outer header relative to skb->head,
-@@ -358,6 +366,7 @@ static int geneve_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
- struct genevehdr *geneveh;
- struct geneve_dev *geneve;
- struct geneve_sock *gs;
-+ __be16 inner_proto;
- int opts_len;
-
- /* Need UDP and Geneve header to be present */
-@@ -369,7 +378,11 @@ static int geneve_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
- if (unlikely(geneveh->ver != GENEVE_VER))
- goto drop;
-
-- if (unlikely(geneveh->proto_type != htons(ETH_P_TEB)))
-+ inner_proto = geneveh->proto_type;
-+
-+ if (unlikely((inner_proto != htons(ETH_P_TEB) &&
-+ inner_proto != htons(ETH_P_IP) &&
-+ inner_proto != htons(ETH_P_IPV6))))
- goto drop;
-
- gs = rcu_dereference_sk_user_data(sk);
-@@ -380,9 +393,14 @@ static int geneve_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
- if (!geneve)
- goto drop;
-
-+ if (unlikely((!geneve->cfg.inner_proto_inherit &&
-+ inner_proto != htons(ETH_P_TEB)))) {
-+ geneve->dev->stats.rx_dropped++;
-+ goto drop;
-+ }
-+
- opts_len = geneveh->opt_len * 4;
-- if (iptunnel_pull_header(skb, GENEVE_BASE_HLEN + opts_len,
-- htons(ETH_P_TEB),
-+ if (iptunnel_pull_header(skb, GENEVE_BASE_HLEN + opts_len, inner_proto,
- !net_eq(geneve->net, dev_net(geneve->dev)))) {
- geneve->dev->stats.rx_dropped++;
- goto drop;
-@@ -736,7 +754,8 @@ static int geneve_stop(struct net_device *dev)
- }
-
- static void geneve_build_header(struct genevehdr *geneveh,
-- const struct ip_tunnel_info *info)
-+ const struct ip_tunnel_info *info,
-+ __be16 inner_proto)
- {
- geneveh->ver = GENEVE_VER;
- geneveh->opt_len = info->options_len / 4;
-@@ -744,7 +763,7 @@ static void geneve_build_header(struct genevehdr *geneveh,
- geneveh->critical = !!(info->key.tun_flags & TUNNEL_CRIT_OPT);
- geneveh->rsvd1 = 0;
- tunnel_id_to_vni(info->key.tun_id, geneveh->vni);
-- geneveh->proto_type = htons(ETH_P_TEB);
-+ geneveh->proto_type = inner_proto;
- geneveh->rsvd2 = 0;
-
- if (info->key.tun_flags & TUNNEL_GENEVE_OPT)
-@@ -753,10 +772,12 @@ static void geneve_build_header(struct genevehdr *geneveh,
-
- static int geneve_build_skb(struct dst_entry *dst, struct sk_buff *skb,
- const struct ip_tunnel_info *info,
-- bool xnet, int ip_hdr_len)
-+ bool xnet, int ip_hdr_len,
-+ bool inner_proto_inherit)
- {
- bool udp_sum = !!(info->key.tun_flags & TUNNEL_CSUM);
- struct genevehdr *gnvh;
-+ __be16 inner_proto;
- int min_headroom;
- int err;
-
-@@ -774,8 +795,9 @@ static int geneve_build_skb(struct dst_entry *dst, struct sk_buff *skb,
- goto free_dst;
-
- gnvh = __skb_push(skb, sizeof(*gnvh) + info->options_len);
-- geneve_build_header(gnvh, info);
-- skb_set_inner_protocol(skb, htons(ETH_P_TEB));
-+ inner_proto = inner_proto_inherit ? skb->protocol : htons(ETH_P_TEB);
-+ geneve_build_header(gnvh, info, inner_proto);
-+ skb_set_inner_protocol(skb, inner_proto);
- return 0;
-
- free_dst:
-@@ -981,7 +1003,8 @@ static int geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev,
- }
- }
-
-- err = geneve_build_skb(&rt->dst, skb, info, xnet, sizeof(struct iphdr));
-+ err = geneve_build_skb(&rt->dst, skb, info, xnet, sizeof(struct iphdr),
-+ geneve->cfg.inner_proto_inherit);
- if (unlikely(err))
- return err;
-
-@@ -1060,7 +1083,8 @@ static int geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
- ttl = key->ttl;
- ttl = ttl ? : ip6_dst_hoplimit(dst);
- }
-- err = geneve_build_skb(dst, skb, info, xnet, sizeof(struct ipv6hdr));
-+ err = geneve_build_skb(dst, skb, info, xnet, sizeof(struct ipv6hdr),
-+ geneve->cfg.inner_proto_inherit);
- if (unlikely(err))
- return err;
-
-@@ -1410,6 +1434,14 @@ static int geneve_configure(struct net *net, struct net_device *dev,
- dst_cache_reset(&geneve->cfg.info.dst_cache);
- memcpy(&geneve->cfg, cfg, sizeof(*cfg));
-
-+ if (geneve->cfg.inner_proto_inherit) {
-+ dev->header_ops = NULL;
-+ dev->type = ARPHRD_NONE;
-+ dev->hard_header_len = 0;
-+ dev->addr_len = 0;
-+ dev->flags = IFF_NOARP;
-+ }
-+
- err = register_netdevice(dev);
- if (err)
- return err;
-@@ -1583,10 +1615,18 @@ static int geneve_nl2info(struct nlattr *tb[], struct nlattr *data[],
- #endif
- }
-
-+ if (data[IFLA_GENEVE_INNER_PROTO_INHERIT]) {
-+ if (changelink) {
-+ attrtype = IFLA_GENEVE_INNER_PROTO_INHERIT;
-+ goto change_notsup;
-+ }
-+ cfg->inner_proto_inherit = true;
-+ }
-+
- return 0;
- change_notsup:
- NL_SET_ERR_MSG_ATTR(extack, data[attrtype],
-- "Changing VNI, Port, endpoint IP address family, external, and UDP checksum attributes are not supported");
-+ "Changing VNI, Port, endpoint IP address family, external, inner_proto_inherit, and UDP checksum attributes are not supported");
- return -EOPNOTSUPP;
- }
-
-@@ -1821,6 +1861,10 @@ static int geneve_fill_info(struct sk_buff *skb, const struct net_device *dev)
- if (nla_put_u8(skb, IFLA_GENEVE_TTL_INHERIT, ttl_inherit))
- goto nla_put_failure;
-
-+ if (geneve->cfg.inner_proto_inherit &&
-+ nla_put_flag(skb, IFLA_GENEVE_INNER_PROTO_INHERIT))
-+ goto nla_put_failure;
-+
- return 0;
-
- nla_put_failure:
-diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
-index 4ac53b30b6dc9..cc126982fa3c0 100644
---- a/include/uapi/linux/if_link.h
-+++ b/include/uapi/linux/if_link.h
-@@ -776,6 +776,7 @@ enum {
- IFLA_GENEVE_LABEL,
- IFLA_GENEVE_TTL_INHERIT,
- IFLA_GENEVE_DF,
-+ IFLA_GENEVE_INNER_PROTO_INHERIT,
- __IFLA_GENEVE_MAX
- };
- #define IFLA_GENEVE_MAX (__IFLA_GENEVE_MAX - 1)
---
-2.43.0
-
+++ /dev/null
-From 4c77ec8a31dac2f6b88e8a609212e082d3cc895e Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Sat, 12 Feb 2022 21:23:11 +0530
-Subject: net: lan743x: Add PCI11010 / PCI11414 device IDs
-
-From: Raju Lakkaraju <Raju.Lakkaraju@microchip.com>
-
-[ Upstream commit bb4f6bffe33c8791549cb634d7b053aa5c3d1131 ]
-
-PCI11010/PCI11414 devices are enhancement of Ethernet LAN743x chip family.
-
-Signed-off-by: Raju Lakkaraju <Raju.Lakkaraju@microchip.com>
-Signed-off-by: David S. Miller <davem@davemloft.net>
-Stable-dep-of: 7725363936a8 ("net: lan743x: disable WOL upon resume to restore full data path operation")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/net/ethernet/microchip/lan743x_main.c | 2 ++
- drivers/net/ethernet/microchip/lan743x_main.h | 11 +++++++++--
- 2 files changed, 11 insertions(+), 2 deletions(-)
-
-diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c
-index a3392c74372a8..d70e20e11ccb1 100644
---- a/drivers/net/ethernet/microchip/lan743x_main.c
-+++ b/drivers/net/ethernet/microchip/lan743x_main.c
-@@ -3075,6 +3075,8 @@ static const struct dev_pm_ops lan743x_pm_ops = {
- static const struct pci_device_id lan743x_pcidev_tbl[] = {
- { PCI_DEVICE(PCI_VENDOR_ID_SMSC, PCI_DEVICE_ID_SMSC_LAN7430) },
- { PCI_DEVICE(PCI_VENDOR_ID_SMSC, PCI_DEVICE_ID_SMSC_LAN7431) },
-+ { PCI_DEVICE(PCI_VENDOR_ID_SMSC, PCI_DEVICE_ID_SMSC_A011) },
-+ { PCI_DEVICE(PCI_VENDOR_ID_SMSC, PCI_DEVICE_ID_SMSC_A041) },
- { 0, }
- };
-
-diff --git a/drivers/net/ethernet/microchip/lan743x_main.h b/drivers/net/ethernet/microchip/lan743x_main.h
-index 6080028c1df2c..fba56cd0e9454 100644
---- a/drivers/net/ethernet/microchip/lan743x_main.h
-+++ b/drivers/net/ethernet/microchip/lan743x_main.h
-@@ -16,8 +16,13 @@
- #define ID_REV_ID_MASK_ (0xFFFF0000)
- #define ID_REV_ID_LAN7430_ (0x74300000)
- #define ID_REV_ID_LAN7431_ (0x74310000)
--#define ID_REV_IS_VALID_CHIP_ID_(id_rev) \
-- (((id_rev) & 0xFFF00000) == 0x74300000)
-+#define ID_REV_ID_LAN743X_ (0x74300000)
-+#define ID_REV_ID_A011_ (0xA0110000) // PCI11010
-+#define ID_REV_ID_A041_ (0xA0410000) // PCI11414
-+#define ID_REV_ID_A0X1_ (0xA0010000)
-+#define ID_REV_IS_VALID_CHIP_ID_(id_rev) \
-+ ((((id_rev) & 0xFFF00000) == ID_REV_ID_LAN743X_) || \
-+ (((id_rev) & 0xFF0F0000) == ID_REV_ID_A0X1_))
- #define ID_REV_CHIP_REV_MASK_ (0x0000FFFF)
- #define ID_REV_CHIP_REV_A0_ (0x00000000)
- #define ID_REV_CHIP_REV_B0_ (0x00000010)
-@@ -558,6 +563,8 @@ struct lan743x_adapter;
- #define PCI_VENDOR_ID_SMSC PCI_VENDOR_ID_EFAR
- #define PCI_DEVICE_ID_SMSC_LAN7430 (0x7430)
- #define PCI_DEVICE_ID_SMSC_LAN7431 (0x7431)
-+#define PCI_DEVICE_ID_SMSC_A011 (0xA011)
-+#define PCI_DEVICE_ID_SMSC_A041 (0xA041)
-
- #define PCI_CONFIG_LENGTH (0x1000)
-
---
-2.43.0
-
+++ /dev/null
-From b3b0875a3117bfcf82dd7b9331e6c8bc7f2404e9 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Sat, 12 Feb 2022 21:23:12 +0530
-Subject: net: lan743x: Add support for 4 Tx queues
-
-From: Raju Lakkaraju <Raju.Lakkaraju@microchip.com>
-
-[ Upstream commit cf9aaea8e55b3f80488975a76fa4ca2ffaedcedd ]
-
-Add support for 4 Tx queues
-
-Signed-off-by: Raju Lakkaraju <Raju.Lakkaraju@microchip.com>
-Signed-off-by: David S. Miller <davem@davemloft.net>
-Stable-dep-of: 7725363936a8 ("net: lan743x: disable WOL upon resume to restore full data path operation")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/net/ethernet/microchip/lan743x_main.c | 83 +++++++++++++++----
- drivers/net/ethernet/microchip/lan743x_main.h | 12 ++-
- drivers/net/ethernet/microchip/lan743x_ptp.c | 8 +-
- 3 files changed, 79 insertions(+), 24 deletions(-)
-
-diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c
-index d70e20e11ccb1..7ee2a91b929eb 100644
---- a/drivers/net/ethernet/microchip/lan743x_main.c
-+++ b/drivers/net/ethernet/microchip/lan743x_main.c
-@@ -18,6 +18,18 @@
- #include "lan743x_main.h"
- #include "lan743x_ethtool.h"
-
-+static bool is_pci11x1x_chip(struct lan743x_adapter *adapter)
-+{
-+ struct lan743x_csr *csr = &adapter->csr;
-+ u32 id_rev = csr->id_rev;
-+
-+ if (((id_rev & 0xFFFF0000) == ID_REV_ID_A011_) ||
-+ ((id_rev & 0xFFFF0000) == ID_REV_ID_A041_)) {
-+ return true;
-+ }
-+ return false;
-+}
-+
- static void lan743x_pci_cleanup(struct lan743x_adapter *adapter)
- {
- pci_release_selected_regions(adapter->pdev,
-@@ -262,7 +274,7 @@ static void lan743x_intr_shared_isr(void *context, u32 int_sts, u32 flags)
- }
- }
- if (int_sts & INT_BIT_ALL_TX_) {
-- for (channel = 0; channel < LAN743X_USED_TX_CHANNELS;
-+ for (channel = 0; channel < adapter->used_tx_channels;
- channel++) {
- u32 int_bit = INT_BIT_DMA_TX_(channel);
-
-@@ -459,6 +471,7 @@ static int lan743x_intr_open(struct lan743x_adapter *adapter)
- {
- struct msix_entry msix_entries[LAN743X_MAX_VECTOR_COUNT];
- struct lan743x_intr *intr = &adapter->intr;
-+ unsigned int used_tx_channels;
- u32 int_vec_en_auto_clr = 0;
- u32 int_vec_map0 = 0;
- u32 int_vec_map1 = 0;
-@@ -473,9 +486,10 @@ static int lan743x_intr_open(struct lan743x_adapter *adapter)
- sizeof(struct msix_entry) * LAN743X_MAX_VECTOR_COUNT);
- for (index = 0; index < LAN743X_MAX_VECTOR_COUNT; index++)
- msix_entries[index].entry = index;
-+ used_tx_channels = adapter->used_tx_channels;
- ret = pci_enable_msix_range(adapter->pdev,
- msix_entries, 1,
-- 1 + LAN743X_USED_TX_CHANNELS +
-+ 1 + used_tx_channels +
- LAN743X_USED_RX_CHANNELS);
-
- if (ret > 0) {
-@@ -582,8 +596,8 @@ static int lan743x_intr_open(struct lan743x_adapter *adapter)
- if (intr->number_of_vectors > 1) {
- int number_of_tx_vectors = intr->number_of_vectors - 1;
-
-- if (number_of_tx_vectors > LAN743X_USED_TX_CHANNELS)
-- number_of_tx_vectors = LAN743X_USED_TX_CHANNELS;
-+ if (number_of_tx_vectors > used_tx_channels)
-+ number_of_tx_vectors = used_tx_channels;
- flags = LAN743X_VECTOR_FLAG_SOURCE_STATUS_READ |
- LAN743X_VECTOR_FLAG_SOURCE_STATUS_W2C |
- LAN743X_VECTOR_FLAG_SOURCE_ENABLE_CHECK |
-@@ -621,9 +635,9 @@ static int lan743x_intr_open(struct lan743x_adapter *adapter)
- INT_VEC_EN_(vector));
- }
- }
-- if ((intr->number_of_vectors - LAN743X_USED_TX_CHANNELS) > 1) {
-+ if ((intr->number_of_vectors - used_tx_channels) > 1) {
- int number_of_rx_vectors = intr->number_of_vectors -
-- LAN743X_USED_TX_CHANNELS - 1;
-+ used_tx_channels - 1;
-
- if (number_of_rx_vectors > LAN743X_USED_RX_CHANNELS)
- number_of_rx_vectors = LAN743X_USED_RX_CHANNELS;
-@@ -2510,7 +2524,8 @@ static int lan743x_netdev_close(struct net_device *netdev)
- struct lan743x_adapter *adapter = netdev_priv(netdev);
- int index;
-
-- lan743x_tx_close(&adapter->tx[0]);
-+ for (index = 0; index < adapter->used_tx_channels; index++)
-+ lan743x_tx_close(&adapter->tx[index]);
-
- for (index = 0; index < LAN743X_USED_RX_CHANNELS; index++)
- lan743x_rx_close(&adapter->rx[index]);
-@@ -2556,12 +2571,19 @@ static int lan743x_netdev_open(struct net_device *netdev)
- goto close_rx;
- }
-
-- ret = lan743x_tx_open(&adapter->tx[0]);
-- if (ret)
-- goto close_rx;
--
-+ for (index = 0; index < adapter->used_tx_channels; index++) {
-+ ret = lan743x_tx_open(&adapter->tx[index]);
-+ if (ret)
-+ goto close_tx;
-+ }
- return 0;
-
-+close_tx:
-+ for (index = 0; index < adapter->used_tx_channels; index++) {
-+ if (adapter->tx[index].ring_cpu_ptr)
-+ lan743x_tx_close(&adapter->tx[index]);
-+ }
-+
- close_rx:
- for (index = 0; index < LAN743X_USED_RX_CHANNELS; index++) {
- if (adapter->rx[index].ring_cpu_ptr)
-@@ -2588,8 +2610,12 @@ static netdev_tx_t lan743x_netdev_xmit_frame(struct sk_buff *skb,
- struct net_device *netdev)
- {
- struct lan743x_adapter *adapter = netdev_priv(netdev);
-+ u8 ch = 0;
-+
-+ if (adapter->is_pci11x1x)
-+ ch = skb->queue_mapping % PCI11X1X_USED_TX_CHANNELS;
-
-- return lan743x_tx_xmit_frame(&adapter->tx[0], skb);
-+ return lan743x_tx_xmit_frame(&adapter->tx[ch], skb);
- }
-
- static int lan743x_netdev_ioctl(struct net_device *netdev,
-@@ -2720,6 +2746,15 @@ static int lan743x_hardware_init(struct lan743x_adapter *adapter,
- int index;
- int ret;
-
-+ adapter->is_pci11x1x = is_pci11x1x_chip(adapter);
-+ if (adapter->is_pci11x1x) {
-+ adapter->max_tx_channels = PCI11X1X_MAX_TX_CHANNELS;
-+ adapter->used_tx_channels = PCI11X1X_USED_TX_CHANNELS;
-+ } else {
-+ adapter->max_tx_channels = LAN743X_MAX_TX_CHANNELS;
-+ adapter->used_tx_channels = LAN743X_USED_TX_CHANNELS;
-+ }
-+
- adapter->intr.irq = adapter->pdev->irq;
- lan743x_csr_write(adapter, INT_EN_CLR, 0xFFFFFFFF);
-
-@@ -2750,10 +2785,13 @@ static int lan743x_hardware_init(struct lan743x_adapter *adapter,
- adapter->rx[index].channel_number = index;
- }
-
-- tx = &adapter->tx[0];
-- tx->adapter = adapter;
-- tx->channel_number = 0;
-- spin_lock_init(&tx->ring_lock);
-+ for (index = 0; index < adapter->used_tx_channels; index++) {
-+ tx = &adapter->tx[index];
-+ tx->adapter = adapter;
-+ tx->channel_number = index;
-+ spin_lock_init(&tx->ring_lock);
-+ }
-+
- return 0;
- }
-
-@@ -2805,8 +2843,17 @@ static int lan743x_pcidev_probe(struct pci_dev *pdev,
- struct net_device *netdev = NULL;
- int ret = -ENODEV;
-
-- netdev = devm_alloc_etherdev(&pdev->dev,
-- sizeof(struct lan743x_adapter));
-+ if (id->device == PCI_DEVICE_ID_SMSC_A011 ||
-+ id->device == PCI_DEVICE_ID_SMSC_A041) {
-+ netdev = devm_alloc_etherdev_mqs(&pdev->dev,
-+ sizeof(struct lan743x_adapter),
-+ PCI11X1X_USED_TX_CHANNELS,
-+ LAN743X_USED_RX_CHANNELS);
-+ } else {
-+ netdev = devm_alloc_etherdev(&pdev->dev,
-+ sizeof(struct lan743x_adapter));
-+ }
-+
- if (!netdev)
- goto return_error;
-
-diff --git a/drivers/net/ethernet/microchip/lan743x_main.h b/drivers/net/ethernet/microchip/lan743x_main.h
-index fba56cd0e9454..fab11e65ddac9 100644
---- a/drivers/net/ethernet/microchip/lan743x_main.h
-+++ b/drivers/net/ethernet/microchip/lan743x_main.h
-@@ -545,10 +545,12 @@
-
- #define LAN743X_MAX_RX_CHANNELS (4)
- #define LAN743X_MAX_TX_CHANNELS (1)
-+#define PCI11X1X_MAX_TX_CHANNELS (4)
- struct lan743x_adapter;
-
- #define LAN743X_USED_RX_CHANNELS (4)
- #define LAN743X_USED_TX_CHANNELS (1)
-+#define PCI11X1X_USED_TX_CHANNELS (4)
- #define LAN743X_INT_MOD (400)
-
- #if (LAN743X_USED_RX_CHANNELS > LAN743X_MAX_RX_CHANNELS)
-@@ -557,6 +559,9 @@ struct lan743x_adapter;
- #if (LAN743X_USED_TX_CHANNELS > LAN743X_MAX_TX_CHANNELS)
- #error Invalid LAN743X_USED_TX_CHANNELS
- #endif
-+#if (PCI11X1X_USED_TX_CHANNELS > PCI11X1X_MAX_TX_CHANNELS)
-+#error Invalid PCI11X1X_USED_TX_CHANNELS
-+#endif
-
- /* PCI */
- /* SMSC acquired EFAR late 1990's, MCHP acquired SMSC 2012 */
-@@ -727,8 +732,11 @@ struct lan743x_adapter {
- u8 mac_address[ETH_ALEN];
-
- struct lan743x_phy phy;
-- struct lan743x_tx tx[LAN743X_MAX_TX_CHANNELS];
-- struct lan743x_rx rx[LAN743X_MAX_RX_CHANNELS];
-+ struct lan743x_tx tx[PCI11X1X_USED_TX_CHANNELS];
-+ struct lan743x_rx rx[LAN743X_USED_RX_CHANNELS];
-+ bool is_pci11x1x;
-+ u8 max_tx_channels;
-+ u8 used_tx_channels;
-
- #define LAN743X_ADAPTER_FLAG_OTP BIT(0)
- u32 flags;
-diff --git a/drivers/net/ethernet/microchip/lan743x_ptp.c b/drivers/net/ethernet/microchip/lan743x_ptp.c
-index ab6d719d40f0c..0448544871920 100644
---- a/drivers/net/ethernet/microchip/lan743x_ptp.c
-+++ b/drivers/net/ethernet/microchip/lan743x_ptp.c
-@@ -1244,21 +1244,21 @@ int lan743x_ptp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
-
- switch (config.tx_type) {
- case HWTSTAMP_TX_OFF:
-- for (index = 0; index < LAN743X_MAX_TX_CHANNELS;
-- index++)
-+ for (index = 0; index < adapter->used_tx_channels;
-+ index++)
- lan743x_tx_set_timestamping_mode(&adapter->tx[index],
- false, false);
- lan743x_ptp_set_sync_ts_insert(adapter, false);
- break;
- case HWTSTAMP_TX_ON:
-- for (index = 0; index < LAN743X_MAX_TX_CHANNELS;
-+ for (index = 0; index < adapter->used_tx_channels;
- index++)
- lan743x_tx_set_timestamping_mode(&adapter->tx[index],
- true, false);
- lan743x_ptp_set_sync_ts_insert(adapter, false);
- break;
- case HWTSTAMP_TX_ONESTEP_SYNC:
-- for (index = 0; index < LAN743X_MAX_TX_CHANNELS;
-+ for (index = 0; index < adapter->used_tx_channels;
- index++)
- lan743x_tx_set_timestamping_mode(&adapter->tx[index],
- true, true);
---
-2.43.0
-
+++ /dev/null
-From 1f0c5fe9851ebeadb25922e9f8281387f47ceca4 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Thu, 16 Jun 2022 09:42:24 +0530
-Subject: net: lan743x: Add support to Secure-ON WOL
-
-From: Raju Lakkaraju <Raju.Lakkaraju@microchip.com>
-
-[ Upstream commit 6b3768ac8e2b3e3594f6851a073f2a11cfb82719 ]
-
-Add support to Magic Packet Detection with Secure-ON for PCI11010/PCI11414 chips
-
-Signed-off-by: Raju Lakkaraju <Raju.Lakkaraju@microchip.com>
-Reviewed-by: Andrew Lunn <andrew@lunn.ch>
-Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-Stable-dep-of: 7725363936a8 ("net: lan743x: disable WOL upon resume to restore full data path operation")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- .../net/ethernet/microchip/lan743x_ethtool.c | 12 ++++++++
- drivers/net/ethernet/microchip/lan743x_main.c | 29 +++++++++++++++++++
- drivers/net/ethernet/microchip/lan743x_main.h | 10 +++++++
- 3 files changed, 51 insertions(+)
-
-diff --git a/drivers/net/ethernet/microchip/lan743x_ethtool.c b/drivers/net/ethernet/microchip/lan743x_ethtool.c
-index 91a755efe2e6b..21a6ef873715e 100644
---- a/drivers/net/ethernet/microchip/lan743x_ethtool.c
-+++ b/drivers/net/ethernet/microchip/lan743x_ethtool.c
-@@ -787,7 +787,12 @@ static void lan743x_ethtool_get_wol(struct net_device *netdev,
- wol->supported |= WAKE_BCAST | WAKE_UCAST | WAKE_MCAST |
- WAKE_MAGIC | WAKE_PHY | WAKE_ARP;
-
-+ if (adapter->is_pci11x1x)
-+ wol->supported |= WAKE_MAGICSECURE;
-+
- wol->wolopts |= adapter->wolopts;
-+ if (adapter->wolopts & WAKE_MAGICSECURE)
-+ memcpy(wol->sopass, adapter->sopass, sizeof(wol->sopass));
- }
-
- static int lan743x_ethtool_set_wol(struct net_device *netdev,
-@@ -808,6 +813,13 @@ static int lan743x_ethtool_set_wol(struct net_device *netdev,
- adapter->wolopts |= WAKE_PHY;
- if (wol->wolopts & WAKE_ARP)
- adapter->wolopts |= WAKE_ARP;
-+ if (wol->wolopts & WAKE_MAGICSECURE &&
-+ wol->wolopts & WAKE_MAGIC) {
-+ memcpy(adapter->sopass, wol->sopass, sizeof(wol->sopass));
-+ adapter->wolopts |= WAKE_MAGICSECURE;
-+ } else {
-+ memset(adapter->sopass, 0, sizeof(u8) * SOPASS_MAX);
-+ }
-
- device_set_wakeup_enable(&adapter->pdev->dev, (bool)wol->wolopts);
-
-diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c
-index 7ee2a91b929eb..d3aebe9fea1a3 100644
---- a/drivers/net/ethernet/microchip/lan743x_main.c
-+++ b/drivers/net/ethernet/microchip/lan743x_main.c
-@@ -2964,6 +2964,7 @@ static void lan743x_pm_set_wol(struct lan743x_adapter *adapter)
- const u8 ipv6_multicast[3] = { 0x33, 0x33 };
- const u8 arp_type[2] = { 0x08, 0x06 };
- int mask_index;
-+ u32 sopass;
- u32 pmtctl;
- u32 wucsr;
- u32 macrx;
-@@ -3058,6 +3059,14 @@ static void lan743x_pm_set_wol(struct lan743x_adapter *adapter)
- pmtctl |= PMT_CTL_RX_FCT_RFE_D3_CLK_OVR_;
- }
-
-+ if (adapter->wolopts & WAKE_MAGICSECURE) {
-+ sopass = *(u32 *)adapter->sopass;
-+ lan743x_csr_write(adapter, MAC_MP_SO_LO, sopass);
-+ sopass = *(u16 *)&adapter->sopass[4];
-+ lan743x_csr_write(adapter, MAC_MP_SO_HI, sopass);
-+ wucsr |= MAC_MP_SO_EN_;
-+ }
-+
- lan743x_csr_write(adapter, MAC_WUCSR, wucsr);
- lan743x_csr_write(adapter, PMT_CTL, pmtctl);
- lan743x_csr_write(adapter, MAC_RX, macrx);
-@@ -3068,6 +3077,7 @@ static int lan743x_pm_suspend(struct device *dev)
- struct pci_dev *pdev = to_pci_dev(dev);
- struct net_device *netdev = pci_get_drvdata(pdev);
- struct lan743x_adapter *adapter = netdev_priv(netdev);
-+ u32 data;
-
- lan743x_pcidev_shutdown(pdev);
-
-@@ -3079,6 +3089,18 @@ static int lan743x_pm_suspend(struct device *dev)
- if (adapter->wolopts)
- lan743x_pm_set_wol(adapter);
-
-+ if (adapter->is_pci11x1x) {
-+ /* Save HW_CFG to config again in PM resume */
-+ data = lan743x_csr_read(adapter, HW_CFG);
-+ adapter->hw_cfg = data;
-+ data |= (HW_CFG_RST_PROTECT_PCIE_ |
-+ HW_CFG_D3_RESET_DIS_ |
-+ HW_CFG_D3_VAUX_OVR_ |
-+ HW_CFG_HOT_RESET_DIS_ |
-+ HW_CFG_RST_PROTECT_);
-+ lan743x_csr_write(adapter, HW_CFG, data);
-+ }
-+
- /* Host sets PME_En, put D3hot */
- return pci_prepare_to_sleep(pdev);
- }
-@@ -3094,6 +3116,10 @@ static int lan743x_pm_resume(struct device *dev)
- pci_restore_state(pdev);
- pci_save_state(pdev);
-
-+ /* Restore HW_CFG that was saved during pm suspend */
-+ if (adapter->is_pci11x1x)
-+ lan743x_csr_write(adapter, HW_CFG, adapter->hw_cfg);
-+
- ret = lan743x_hardware_init(adapter, pdev);
- if (ret) {
- netif_err(adapter, probe, adapter->netdev,
-@@ -3110,6 +3136,9 @@ static int lan743x_pm_resume(struct device *dev)
- lan743x_netdev_open(netdev);
-
- netif_device_attach(netdev);
-+ ret = lan743x_csr_read(adapter, MAC_WK_SRC);
-+ netif_info(adapter, drv, adapter->netdev,
-+ "Wakeup source : 0x%08X\n", ret);
-
- return 0;
- }
-diff --git a/drivers/net/ethernet/microchip/lan743x_main.h b/drivers/net/ethernet/microchip/lan743x_main.h
-index fab11e65ddac9..345313d845b6e 100644
---- a/drivers/net/ethernet/microchip/lan743x_main.h
-+++ b/drivers/net/ethernet/microchip/lan743x_main.h
-@@ -32,6 +32,11 @@
- #define FPGA_REV_GET_MAJOR_(fpga_rev) ((fpga_rev) & 0x000000FF)
-
- #define HW_CFG (0x010)
-+#define HW_CFG_RST_PROTECT_PCIE_ BIT(19)
-+#define HW_CFG_HOT_RESET_DIS_ BIT(15)
-+#define HW_CFG_D3_VAUX_OVR_ BIT(14)
-+#define HW_CFG_D3_RESET_DIS_ BIT(13)
-+#define HW_CFG_RST_PROTECT_ BIT(12)
- #define HW_CFG_RELOAD_TYPE_ALL_ (0x00000FC0)
- #define HW_CFG_EE_OTP_RELOAD_ BIT(4)
- #define HW_CFG_LRST_ BIT(1)
-@@ -153,6 +158,7 @@
- #define MAC_EEE_TX_LPI_REQ_DLY_CNT (0x130)
-
- #define MAC_WUCSR (0x140)
-+#define MAC_MP_SO_EN_ BIT(21)
- #define MAC_WUCSR_RFE_WAKE_EN_ BIT(14)
- #define MAC_WUCSR_PFDA_EN_ BIT(3)
- #define MAC_WUCSR_WAKE_EN_ BIT(2)
-@@ -160,6 +166,8 @@
- #define MAC_WUCSR_BCST_EN_ BIT(0)
-
- #define MAC_WK_SRC (0x144)
-+#define MAC_MP_SO_HI (0x148)
-+#define MAC_MP_SO_LO (0x14C)
-
- #define MAC_WUF_CFG0 (0x150)
- #define MAC_NUM_OF_WUF_CFG (32)
-@@ -721,6 +729,7 @@ struct lan743x_adapter {
- int msg_enable;
- #ifdef CONFIG_PM
- u32 wolopts;
-+ u8 sopass[SOPASS_MAX];
- #endif
- struct pci_dev *pdev;
- struct lan743x_csr csr;
-@@ -740,6 +749,7 @@ struct lan743x_adapter {
-
- #define LAN743X_ADAPTER_FLAG_OTP BIT(0)
- u32 flags;
-+ u32 hw_cfg;
- };
-
- #define LAN743X_COMPONENT_FLAG_RX(channel) BIT(20 + (channel))
---
-2.43.0
-
+++ /dev/null
-From 7fe418911185bf048fbe1328652d6132564e5476 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Fri, 14 Jun 2024 22:41:55 +0530
-Subject: net: lan743x: disable WOL upon resume to restore full data path
- operation
-
-From: Raju Lakkaraju <Raju.Lakkaraju@microchip.com>
-
-[ Upstream commit 7725363936a88351b71495774c1e0e852ae4cdca ]
-
-When Wake-on-LAN (WoL) is active and the system is in suspend mode, triggering
-a system event can wake the system from sleep, which may block the data path.
-To restore normal data path functionality after waking, disable all wake-up
-events. Furthermore, clear all Write 1 to Clear (W1C) status bits by writing
-1's to them.
-
-Fixes: 4d94282afd95 ("lan743x: Add power management support")
-Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>
-Signed-off-by: Raju Lakkaraju <Raju.Lakkaraju@microchip.com>
-Signed-off-by: Paolo Abeni <pabeni@redhat.com>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/net/ethernet/microchip/lan743x_main.c | 30 ++++++++++++++++---
- drivers/net/ethernet/microchip/lan743x_main.h | 24 +++++++++++++++
- 2 files changed, 50 insertions(+), 4 deletions(-)
-
-diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c
-index d3aebe9fea1a3..5bc728f669bf5 100644
---- a/drivers/net/ethernet/microchip/lan743x_main.c
-+++ b/drivers/net/ethernet/microchip/lan743x_main.c
-@@ -2975,7 +2975,7 @@ static void lan743x_pm_set_wol(struct lan743x_adapter *adapter)
-
- /* clear wake settings */
- pmtctl = lan743x_csr_read(adapter, PMT_CTL);
-- pmtctl |= PMT_CTL_WUPS_MASK_;
-+ pmtctl |= PMT_CTL_WUPS_MASK_ | PMT_CTL_RES_CLR_WKP_MASK_;
- pmtctl &= ~(PMT_CTL_GPIO_WAKEUP_EN_ | PMT_CTL_EEE_WAKEUP_EN_ |
- PMT_CTL_WOL_EN_ | PMT_CTL_MAC_D3_RX_CLK_OVR_ |
- PMT_CTL_RX_FCT_RFE_D3_CLK_OVR_ | PMT_CTL_ETH_PHY_WAKE_EN_);
-@@ -3110,6 +3110,7 @@ static int lan743x_pm_resume(struct device *dev)
- struct pci_dev *pdev = to_pci_dev(dev);
- struct net_device *netdev = pci_get_drvdata(pdev);
- struct lan743x_adapter *adapter = netdev_priv(netdev);
-+ u32 data;
- int ret;
-
- pci_set_power_state(pdev, PCI_D0);
-@@ -3128,6 +3129,30 @@ static int lan743x_pm_resume(struct device *dev)
- return ret;
- }
-
-+ ret = lan743x_csr_read(adapter, MAC_WK_SRC);
-+ netif_dbg(adapter, drv, adapter->netdev,
-+ "Wakeup source : 0x%08X\n", ret);
-+
-+ /* Clear the wol configuration and status bits. Note that
-+ * the status bits are "Write One to Clear (W1C)"
-+ */
-+ data = MAC_WUCSR_EEE_TX_WAKE_ | MAC_WUCSR_EEE_RX_WAKE_ |
-+ MAC_WUCSR_RFE_WAKE_FR_ | MAC_WUCSR_PFDA_FR_ | MAC_WUCSR_WUFR_ |
-+ MAC_WUCSR_MPR_ | MAC_WUCSR_BCAST_FR_;
-+ lan743x_csr_write(adapter, MAC_WUCSR, data);
-+
-+ data = MAC_WUCSR2_NS_RCD_ | MAC_WUCSR2_ARP_RCD_ |
-+ MAC_WUCSR2_IPV6_TCPSYN_RCD_ | MAC_WUCSR2_IPV4_TCPSYN_RCD_;
-+ lan743x_csr_write(adapter, MAC_WUCSR2, data);
-+
-+ data = MAC_WK_SRC_ETH_PHY_WK_ | MAC_WK_SRC_IPV6_TCPSYN_RCD_WK_ |
-+ MAC_WK_SRC_IPV4_TCPSYN_RCD_WK_ | MAC_WK_SRC_EEE_TX_WK_ |
-+ MAC_WK_SRC_EEE_RX_WK_ | MAC_WK_SRC_RFE_FR_WK_ |
-+ MAC_WK_SRC_PFDA_FR_WK_ | MAC_WK_SRC_MP_FR_WK_ |
-+ MAC_WK_SRC_BCAST_FR_WK_ | MAC_WK_SRC_WU_FR_WK_ |
-+ MAC_WK_SRC_WK_FR_SAVED_;
-+ lan743x_csr_write(adapter, MAC_WK_SRC, data);
-+
- /* open netdev when netdev is at running state while resume.
- * For instance, it is true when system wakesup after pm-suspend
- * However, it is false when system wakes up after suspend GUI menu
-@@ -3136,9 +3161,6 @@ static int lan743x_pm_resume(struct device *dev)
- lan743x_netdev_open(netdev);
-
- netif_device_attach(netdev);
-- ret = lan743x_csr_read(adapter, MAC_WK_SRC);
-- netif_info(adapter, drv, adapter->netdev,
-- "Wakeup source : 0x%08X\n", ret);
-
- return 0;
- }
-diff --git a/drivers/net/ethernet/microchip/lan743x_main.h b/drivers/net/ethernet/microchip/lan743x_main.h
-index 345313d845b6e..e8ce2496e33a4 100644
---- a/drivers/net/ethernet/microchip/lan743x_main.h
-+++ b/drivers/net/ethernet/microchip/lan743x_main.h
-@@ -49,6 +49,7 @@
- #define PMT_CTL_RX_FCT_RFE_D3_CLK_OVR_ BIT(18)
- #define PMT_CTL_GPIO_WAKEUP_EN_ BIT(15)
- #define PMT_CTL_EEE_WAKEUP_EN_ BIT(13)
-+#define PMT_CTL_RES_CLR_WKP_MASK_ GENMASK(9, 8)
- #define PMT_CTL_READY_ BIT(7)
- #define PMT_CTL_ETH_PHY_RST_ BIT(4)
- #define PMT_CTL_WOL_EN_ BIT(3)
-@@ -160,12 +161,31 @@
- #define MAC_WUCSR (0x140)
- #define MAC_MP_SO_EN_ BIT(21)
- #define MAC_WUCSR_RFE_WAKE_EN_ BIT(14)
-+#define MAC_WUCSR_EEE_TX_WAKE_ BIT(13)
-+#define MAC_WUCSR_EEE_RX_WAKE_ BIT(11)
-+#define MAC_WUCSR_RFE_WAKE_FR_ BIT(9)
-+#define MAC_WUCSR_PFDA_FR_ BIT(7)
-+#define MAC_WUCSR_WUFR_ BIT(6)
-+#define MAC_WUCSR_MPR_ BIT(5)
-+#define MAC_WUCSR_BCAST_FR_ BIT(4)
- #define MAC_WUCSR_PFDA_EN_ BIT(3)
- #define MAC_WUCSR_WAKE_EN_ BIT(2)
- #define MAC_WUCSR_MPEN_ BIT(1)
- #define MAC_WUCSR_BCST_EN_ BIT(0)
-
- #define MAC_WK_SRC (0x144)
-+#define MAC_WK_SRC_ETH_PHY_WK_ BIT(17)
-+#define MAC_WK_SRC_IPV6_TCPSYN_RCD_WK_ BIT(16)
-+#define MAC_WK_SRC_IPV4_TCPSYN_RCD_WK_ BIT(15)
-+#define MAC_WK_SRC_EEE_TX_WK_ BIT(14)
-+#define MAC_WK_SRC_EEE_RX_WK_ BIT(13)
-+#define MAC_WK_SRC_RFE_FR_WK_ BIT(12)
-+#define MAC_WK_SRC_PFDA_FR_WK_ BIT(11)
-+#define MAC_WK_SRC_MP_FR_WK_ BIT(10)
-+#define MAC_WK_SRC_BCAST_FR_WK_ BIT(9)
-+#define MAC_WK_SRC_WU_FR_WK_ BIT(8)
-+#define MAC_WK_SRC_WK_FR_SAVED_ BIT(7)
-+
- #define MAC_MP_SO_HI (0x148)
- #define MAC_MP_SO_LO (0x14C)
-
-@@ -226,6 +246,10 @@
- #define RFE_INDX(index) (0x580 + (index << 2))
-
- #define MAC_WUCSR2 (0x600)
-+#define MAC_WUCSR2_NS_RCD_ BIT(7)
-+#define MAC_WUCSR2_ARP_RCD_ BIT(6)
-+#define MAC_WUCSR2_IPV6_TCPSYN_RCD_ BIT(5)
-+#define MAC_WUCSR2_IPV4_TCPSYN_RCD_ BIT(4)
-
- #define INT_STS (0x780)
- #define INT_BIT_DMA_RX_(channel) BIT(24 + (channel))
---
-2.43.0
-
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
- drivers/platform/x86/dell/dell-smbios-base.c | 92 ++++++++------------
- 1 file changed, 36 insertions(+), 56 deletions(-)
+ drivers/platform/x86/dell/dell-smbios-base.c | 91 ++++++++++-----------------
+ 1 file changed, 35 insertions(+), 56 deletions(-)
-diff --git a/drivers/platform/x86/dell/dell-smbios-base.c b/drivers/platform/x86/dell/dell-smbios-base.c
-index e61bfaf8b5c48..86b95206cb1bd 100644
--- a/drivers/platform/x86/dell/dell-smbios-base.c
+++ b/drivers/platform/x86/dell/dell-smbios-base.c
-@@ -11,6 +11,7 @@
- */
- #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
-+#include <linux/container_of.h>
- #include <linux/kernel.h>
- #include <linux/module.h>
- #include <linux/capability.h>
-@@ -25,11 +26,16 @@ static u32 da_supported_commands;
+@@ -25,11 +25,16 @@ static u32 da_supported_commands;
static int da_num_tokens;
static struct platform_device *platform_device;
static struct calling_interface_token *da_tokens;
struct smbios_device {
struct list_head list;
struct device *device;
-@@ -416,47 +422,26 @@ static void __init find_tokens(const struct dmi_header *dm, void *dummy)
+@@ -416,47 +421,26 @@ static void __init find_tokens(const str
}
}
}
static struct attribute_group smbios_attribute_group = {
-@@ -473,22 +458,15 @@ static int build_tokens_sysfs(struct platform_device *dev)
+@@ -473,22 +457,15 @@ static int build_tokens_sysfs(struct pla
{
char *location_name;
char *value_name;
if (!token_attrs)
goto out_allocate_attrs;
-@@ -496,27 +474,32 @@ static int build_tokens_sysfs(struct platform_device *dev)
+@@ -496,27 +473,32 @@ static int build_tokens_sysfs(struct pla
/* skip empty */
if (da_tokens[i].tokenID == 0)
continue;
continue;
loop_fail_create_value:
-@@ -532,14 +515,12 @@ static int build_tokens_sysfs(struct platform_device *dev)
+@@ -532,14 +514,12 @@ loop_fail_create_value:
out_unwind_strings:
while (i--) {
return -ENOMEM;
}
-@@ -551,12 +532,11 @@ static void free_group(struct platform_device *pdev)
+@@ -551,12 +531,11 @@ static void free_group(struct platform_d
sysfs_remove_group(&pdev->dev.kobj,
&smbios_attribute_group);
for (i = 0; i < da_num_tokens; i++) {
}
static int __init dell_smbios_init(void)
---
-2.43.0
-
af_unix-annotate-data-races-around-sk-sk_state-in-un.patch
net-inline-sock_prot_inuse_add.patch
net-drop-nopreempt-requirement-on-sock_prot_inuse_ad.patch
-af_unix-use-offsetof-instead-of-sizeof.patch
-af_unix-pass-struct-sock-to-unix_autobind.patch
-af_unix-factorise-unix_find_other-based-on-address-t.patch
-af_unix-return-an-error-as-a-pointer-in-unix_find_ot.patch
-af_unix-cut-unix_validate_addr-out-of-unix_mkname.patch
-af_unix-copy-unix_mkname-into-unix_find_-bsd-abstrac.patch
-af_unix-clean-up-some-sock_net-uses.patch
af_unix-annotate-data-race-of-sk-sk_state-in-unix_st.patch
af_unix-annotate-data-races-around-sk-sk_state-in-se.patch
af_unix-annotate-data-race-of-sk-sk_state-in-unix_st.patch-5290
input-try-trimming-too-long-modalias-strings.patch
clk-sifive-do-not-register-clkdevs-for-prci-clocks.patch
sunrpc-return-proper-error-from-gss_wrap_req_priv.patch
-kernel.h-split-out-container_of-and-typeof_member-ma.patch
platform-x86-dell-smbios-base-use-sysfs_emit.patch
platform-x86-dell-smbios-fix-wrong-token-data-in-sys.patch
gpio-tqmx86-fix-typo-in-kconfig-label.patch
-gpio-tqmx86-remove-unneeded-call-to-platform_set_drv.patch
-gpio-tqmx86-introduce-shadow-register-for-gpio-outpu.patch
-genirq-allow-the-pm-device-to-originate-from-irq-dom.patch
-gpio-tpmx86-move-pm-device-over-to-irq-domain.patch
-gpio-don-t-fiddle-with-irqchips-marked-as-immutable.patch
-gpio-expose-the-gpiochip_irq_re-ql-res-helpers.patch
-gpio-add-helpers-to-ease-the-transition-towards-immu.patch
-gpio-tqmx86-convert-to-immutable-irq_chip.patch
-gpio-tqmx86-store-irq-trigger-type-and-unmask-status.patch
-gpio-tqmx86-fix-broken-irq_type_edge_both-interrupt-.patch
+gpio-tqmx86-store-irq-trigger-type-and-unmask-status-separately.patch
hid-core-remove-unnecessary-warn_on-in-implement.patch
iommu-amd-introduce-pci-segment-structure.patch
iommu-amd-fix-sysfs-leak-in-iommu-init.patch
drm-komeda-check-for-error-valued-pointer.patch
drm-bridge-panel-fix-runtime-warning-on-panel-bridge.patch
tcp-fix-race-in-tcp_v6_syn_recv_sock.patch
-net-geneve-support-ipv4-ipv6-as-inner-protocol.patch
-geneve-fix-incorrect-inner-network-header-offset-whe.patch
net-mlx5e-fix-features-validation-check-for-tunneled.patch
bluetooth-l2cap-fix-rejecting-l2cap_conn_param_updat.patch
netfilter-ipset-fix-race-between-namespace-cleanup-a.patch
xfrm6-check-ip6_dst_idev-return-value-in-xfrm6_get_s.patch
netns-make-get_net_ns-handle-zero-refcount-net.patch
qca_spi-make-interrupt-remembering-atomic.patch
-net-lan743x-add-pci11010-pci11414-device-ids.patch
-net-lan743x-add-support-for-4-tx-queues.patch
-net-lan743x-add-support-to-secure-on-wol.patch
-net-lan743x-disable-wol-upon-resume-to-restore-full-.patch
net-sched-act_api-rely-on-rcu-in-tcf_idr_check_alloc.patch
net-sched-act_api-fix-possible-infinite-loop-in-tcf_.patch
tipc-force-a-dst-refcount-before-doing-decryption.patch
arm-dts-samsung-smdkv310-fix-keypad-no-autorepeat.patch
arm-dts-samsung-exynos4412-origen-fix-keypad-no-auto.patch
arm-dts-samsung-smdk4412-fix-keypad-no-autorepeat.patch
-mmc-sdhci-change-the-code-to-check-auto_cmd23.patch
-mmc-core-capture-emmc-and-sd-card-errors.patch
-mmc-sdhci-capture-emmc-and-sd-card-errors.patch
-mmc-sdhci-add-support-for-tuning-error-interrupts.patch
rtlwifi-rtl8192de-style-clean-ups.patch
wifi-rtlwifi-rtl8192de-fix-5-ghz-tx-power.patch
pmdomain-ti-sci-fix-duplicate-pd-referrals.patch