5.18.18-rc1 review
Subsystems (12)
Greg Kroah-Hartman
maintainerPATCH 344/1095 raw: use more conventional iterators
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit ba44f8182ec299c5d1c8a72fc0fde4ec127b5a6d ]
In order to prepare the following patch,
I change raw v4 & v6 code to use more conventional iterators.
--- include/net/raw.h | 5 +-- include/net/rawv6.h | 6 +-- net/ipv4/raw.c | 93 ++++++++++++++------------------------- net/ipv4/raw_diag.c | 33 +++++++------- net/ipv6/raw.c | 105 ++++++++++++++++---------------------------- 5 files changed, 92 insertions(+), 150 deletions(-)
include/net/raw.h +2 -3
@@ -20,9 +20,8 @@extern struct proto raw_prot;extern struct raw_hashinfo raw_v4_hashinfo; -struct sock *__raw_v4_lookup (struct net *net,struct sock *sk, -unsigned short num,__be32 raddr, -__be32 laddr,int dif,int sdif); +bool raw_v4_match (struct net *net,struct sock *sk,unsigned short num, +__be32 raddr,__be32 laddr,int dif,int sdif);int raw_abort (struct sock *sk,int err);void raw_icmp_error (struct sk_buff *,int ,u32 );
include/net/rawv6.h +3 -3
@@ -5,9 +5,9 @@#include <net/protocol.h> extern struct raw_hashinfo raw_v6_hashinfo; -struct sock *__raw_v6_lookup (struct net *net,struct sock *sk, -unsigned short num,const struct in6_addr *loc_addr, -const struct in6_addr *rmt_addr,int dif,int sdif); +bool raw_v6_match (struct net *net,struct sock *sk,unsigned short num, +const struct in6_addr *loc_addr, +const struct in6_addr *rmt_addr,int dif,int sdif);int raw_abort (struct sock *sk,int err);
net/ipv4/raw.c +33 -60
140 lines not on this page · raw message
net/ipv4/raw_diag.c +16 -17
@@ -34,31 +34,30 @@ raw_get_hashinfo(const struct inet_diag_req_v2 *r)* use helper to figure it out. */ -static struct sock *raw_lookup (struct net *net,struct sock *from, -const struct inet_diag_req_v2 *req) +static bool raw_lookup (struct net *net,struct sock *sk, +const struct inet_diag_req_v2 *req) {struct inet_diag_req_raw *r = (void *)req; -struct sock *sk =NULL ;if (r->sdiag_family ==AF_INET ) - sk =__raw_v4_lookup (net, from, r->sdiag_raw_protocol, - r->id.idiag_dst[0 ], - r->id.idiag_src[0 ], - r->id.idiag_if,0 ); +return raw_v4_match (net, sk, r->sdiag_raw_protocol, + r->id.idiag_dst[0 ], + r->id.idiag_src[0 ], + r->id.idiag_if,0 );#if IS_ENABLED (CONFIG_IPV6 ) else - sk =__raw_v6_lookup (net, from, r->sdiag_raw_protocol, - (const struct in6_addr *)r->id.idiag_src, - (const struct in6_addr *)r->id.idiag_dst, - r->id.idiag_if,0 ); + return raw_v6_match(net, sk, r->sdiag_raw_protocol, + (const struct in6_addr *)r->id.idiag_src, + (const struct in6_addr *)r->id.idiag_dst, + r->id.idiag_if,0 );#endif -return sk; +return false; }static struct sock *raw_sock_get (struct net *net,const struct inet_diag_req_v2 *r) {struct raw_hashinfo *hashinfo =raw_get_hashinfo (r); -struct sock *sk =NULL , *s; +struct sock *sk;int slot;if (IS_ERR (hashinfo))
@@ -66,9 +65,8 @@ static struct sock *raw_sock_get(struct net *net, const struct inet_diag_req_v2read_lock (&hashinfo->lock);for (slot =0 ; slot <RAW_HTABLE_SIZE ; slot++) { -sk_for_each (s, &hashinfo->ht[slot]) { - sk =raw_lookup (net, s, r); -if (sk) { +sk_for_each (sk, &hashinfo->ht[slot]) { +if (raw_lookup (net, sk, r)) {/* * Grab it and keep until we fill * diag meaage to be reported, so
@@ -81,10 +79,11 @@ static struct sock *raw_sock_get(struct net *net, const struct inet_diag_req_v2 } } } + sk =ERR_PTR (-ENOENT ); out_unlock:read_unlock (&hashinfo->lock); -return sk ? sk :ERR_PTR (-ENOENT ); +return sk; } static int raw_diag_dump_one(struct netlink_callback *cb,
net/ipv6/raw.c +38 -67
161 lines not on this page · raw message
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 345/1095 raw: convert raw sockets to RCU
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 0daf07e527095e64ee8927ce297ab626643e9f51 ]
Using rwlock in networking code is extremely risky. writers can starve if enough readers are constantly grabing the rwlock.
I thought rwlock were at fault and sent this patch:
https://lkml.org/lkml/2022/6/17/272
But Peter and Linus essentially told me rwlock had to be unfair.
We need to get rid of rwlock in networking code.
Without this fix, following script triggers soft lockups:
for i in {1..48}
do
ping -f -n -q 127.0.0.1 &
sleep 0.1
done
--- include/net/raw.h | 11 +++++- include/net/rawv6.h | 1 + net/ipv4/af_inet.c | 2 ++ net/ipv4/raw.c | 83 +++++++++++++++++++++------------------------ net/ipv4/raw_diag.c | 22 +++++++----- net/ipv6/af_inet6.c | 3 ++ net/ipv6/raw.c | 28 +++++++-------- 7 files changed, 80 insertions(+), 70 deletions(-)
include/net/raw.h +10 -1
@@ -33,9 +33,18 @@ int raw_rcv(struct sock *, struct sk_buff *);struct raw_hashinfo {rwlock_t lock; -struct hlist_head ht[RAW_HTABLE_SIZE ]; +struct hlist_nulls_head ht[RAW_HTABLE_SIZE ]; }; +static inline void raw_hashinfo_init (struct raw_hashinfo *hashinfo) +{ +int i; + +rwlock_init (&hashinfo->lock); +for (i =0 ; i <RAW_HTABLE_SIZE ; i++) +INIT_HLIST_NULLS_HEAD (&hashinfo->ht[i], i); +} +#ifdef CONFIG_PROC_FS int raw_proc_init (void );void raw_proc_exit (void );
include/net/rawv6.h +1 -0
@@ -3,6 +3,7 @@#define _NET_RAWV6_H#include <net/protocol.h> +#include <net/raw.h> extern struct raw_hashinfo raw_v6_hashinfo; bool raw_v6_match(struct net *net, struct sock *sk, unsigned short num,
net/ipv4/af_inet.c +2 -0
@@ -1920,6 +1920,8 @@ static int __init inet_init(void)sock_skb_cb_check_size (sizeof (struct inet_skb_parm )); +raw_hashinfo_init (&raw_v4_hashinfo); + rc =proto_register (&tcp_prot,1 );if (rc) goto out;
net/ipv4/raw.c +38 -45
193 lines not on this page · raw message
net/ipv4/raw_diag.c +13 -9
@@ -57,31 +57,32 @@ static bool raw_lookup(struct net *net, struct sock *sk,static struct sock *raw_sock_get (struct net *net,const struct inet_diag_req_v2 *r) {struct raw_hashinfo *hashinfo =raw_get_hashinfo (r); +struct hlist_nulls_head *hlist; +struct hlist_nulls_node *hnode;struct sock *sk;int slot;if (IS_ERR (hashinfo))return ERR_CAST (hashinfo); -read_lock (&hashinfo->lock); +rcu_read_lock ();for (slot =0 ; slot <RAW_HTABLE_SIZE ; slot++) { -sk_for_each (sk, &hashinfo->ht[slot]) { + hlist = &hashinfo->ht[slot]; +hlist_nulls_for_each_entry (sk, hnode, hlist, sk_nulls_node) {if (raw_lookup (net, sk, r)) {/* * Grab it and keep until we fill -* diag meaage to be reported, so +* diag message to be reported, so * caller should call sock_put then. -* We can do that because we're keeping -* hashinfo->lock here. */ -sock_hold (sk); - goto out_unlock; +if (refcount_inc_not_zero (&sk->sk_refcnt)) + goto out_unlock; } } } sk =ERR_PTR (-ENOENT ); out_unlock: -read_unlock (&hashinfo->lock); +rcu_read_unlock ();return sk; }
@@ -141,6 +142,8 @@ static void raw_diag_dump(struct sk_buff *skb, struct netlink_callback *cb,struct raw_hashinfo *hashinfo =raw_get_hashinfo (r);struct net *net =sock_net (skb->sk);struct inet_diag_dump_data *cb_data; +struct hlist_nulls_head *hlist; +struct hlist_nulls_node *hnode;int num, s_num, slot, s_slot;struct sock *sk =NULL ;struct nlattr *bc;
@@ -157,7 +160,8 @@ static void raw_diag_dump(struct sk_buff *skb, struct netlink_callback *cb,for (slot = s_slot; slot <RAW_HTABLE_SIZE ; s_num =0 , slot++) { num =0 ; -sk_for_each (sk, &hashinfo->ht[slot]) { + hlist = &hashinfo->ht[slot]; +hlist_nulls_for_each_entry (sk, hnode, hlist, sk_nulls_node) {struct inet_sock *inet =inet_sk (sk);if (!net_eq (sock_net (sk), net))
net/ipv6/af_inet6.c +3 -0
@@ -63,6 +63,7 @@#include <net/compat.h> #include <net/xfrm.h> #include <net/ioam6.h> +#include <net/rawv6.h> #include <linux/uaccess.h> #include <linux/mroute6.h>
@@ -1074,6 +1075,8 @@ static int __init inet6_init(void) goto out; } +raw_hashinfo_init (&raw_v6_hashinfo); + err =proto_register (&tcpv6_prot,1 );if (err) goto out;
net/ipv6/raw.c +13 -15
@@ -61,9 +61,7 @@#define ICMPV6_HDRLEN 4/* ICMPv6 header, RFC 4443 Section 2.1 */ -struct raw_hashinfo raw_v6_hashinfo = { - .lock =__RW_LOCK_UNLOCKED (raw_v6_hashinfo.lock), -}; +struct raw_hashinfo raw_v6_hashinfo;EXPORT_SYMBOL_GPL (raw_v6_hashinfo); bool raw_v6_match(struct net *net, struct sock *sk, unsigned short num,
@@ -143,9 +141,10 @@ EXPORT_SYMBOL(rawv6_mh_filter_unregister);static bool ipv6_raw_deliver (struct sk_buff *skb,int nexthdr) {struct net *net =dev_net (skb->dev); +struct hlist_nulls_head *hlist; +struct hlist_nulls_node *hnode;const struct in6_addr *saddr;const struct in6_addr *daddr; -struct hlist_head *head;struct sock *sk;bool delivered = false;__u8 hash;
@@ -154,11 +153,9 @@ static bool ipv6_raw_deliver(struct sk_buff *skb, int nexthdr) daddr = saddr +1 ; hash = nexthdr & (RAW_HTABLE_SIZE -1 ); - head = &raw_v6_hashinfo.ht[hash]; -if (hlist_empty (head)) -return false; -read_lock (&raw_v6_hashinfo.lock); - sk_for_each(sk, head) { + hlist = &raw_v6_hashinfo.ht[hash]; +rcu_read_lock (); + hlist_nulls_for_each_entry(sk, hnode, hlist, sk_nulls_node) { int filtered; if (!raw_v6_match(net, sk, nexthdr, daddr, saddr,
@@ -203,7 +200,7 @@ static bool ipv6_raw_deliver(struct sk_buff *skb, int nexthdr) } } } -read_unlock (&raw_v6_hashinfo.lock); +rcu_read_unlock ();return delivered; }
@@ -337,14 +334,15 @@ void raw6_icmp_error(struct sk_buff *skb, int nexthdr, {const struct in6_addr *saddr, *daddr;struct net *net =dev_net (skb->dev); -struct hlist_head *head; +struct hlist_nulls_head *hlist; +struct hlist_nulls_node *hnode;struct sock *sk;int hash; hash = nexthdr & (RAW_HTABLE_SIZE -1 ); - head = &raw_v6_hashinfo.ht[hash]; -read_lock (&raw_v6_hashinfo.lock); -sk_for_each (sk, head) { + hlist = &raw_v6_hashinfo.ht[hash]; +rcu_read_lock (); +hlist_nulls_for_each_entry (sk, hnode, hlist, sk_nulls_node) {/* Note: ipv6_hdr(skb) != skb->data */ const struct ipv6hdr *ip6h = (const struct ipv6hdr *)skb->data; saddr = &ip6h->saddr;
@@ -355,7 +353,7 @@ void raw6_icmp_error(struct sk_buff *skb, int nexthdr,continue ;rawv6_err (sk, skb,NULL , type, code, inner_offset, info); } -read_unlock (&raw_v6_hashinfo.lock); +rcu_read_unlock (); }static inline int rawv6_rcv_skb (struct sock *sk,struct sk_buff *skb)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 346/1095 raw: Fix mixed declarations error in raw_icmp_error().
In reply to Greg Kroah-HartmanFrom: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 5da39e31b1b0eb62b8ed369ad9615da850239e9e ]
The trailing semicolon causes a compiler error, so let's remove it.
net/ipv4/raw.c: In function ‘raw_icmp_error’:net/ipv4/raw.c:266:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
266 | struct hlist_nulls_head *hlist;
| ^~~~~~--- net/ipv4/raw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/raw.c +1 -1
@@ -262,7 +262,7 @@ static void raw_err(struct sock *sk, struct sk_buff *skb, u32 info)void raw_icmp_error (struct sk_buff *skb,int protocol,u32 info) { -struct net *net =dev_net (skb->dev);; +struct net *net =dev_net (skb->dev);struct hlist_nulls_head *hlist;struct hlist_nulls_node *hnode;int dif = skb->dev->ifindex;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 347/1095 media: atmel: atmel-sama7g5-isc: fix warning in configs without OF
In reply to Greg Kroah-HartmanFrom: Eugen Hristev <[email protected]>
[ Upstream commit b2bae4b8e637dd751d27918a6b27bd5abcd08859 ]
All warnings (new ones prefixed by >>):
Quoted 1 line
Quoted 1 line
drivers/media/platform/atmel/atmel-sama7g5-isc.c:610:34: warning: unused variable 'microchip_xisc_of_match' [-Wunused-const-variable]
static const struct of_device_id microchip_xisc_of_match[] = {
^13 warnings generated.
vim +/microchip_xisc_of_match +610 drivers/media/platform/atmel/atmel-sama7g5-isc.c
609
Quoted 1 line
610 static const struct
of_device_idmicrochip_xisc_of_match[] = {
611 { .compatible = "microchip,sama7g5-isc" },
612 { }
613 };
614 MODULE_DEVICE_TABLE(of, microchip_xisc_of_match); 615
Fixed warning by guarding the atmel_isc_of_match by CONFIG_OF.
--- drivers/media/platform/atmel/atmel-sama7g5-isc.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/platform/atmel/atmel-sama7g5-isc.c +2 -0
@@ -612,11 +612,13 @@ static const struct dev_pm_ops microchip_xisc_dev_pm_ops = {SET_RUNTIME_PM_OPS (xisc_runtime_suspend, xisc_runtime_resume,NULL ) }; +#if IS_ENABLED (CONFIG_OF )static const struct of_device_id microchip_xisc_of_match[] = { { .compatible ="microchip,sama7g5-isc" }, { } };MODULE_DEVICE_TABLE (of, microchip_xisc_of_match); +#endif static struct platform_driver microchip_xisc_driver = { .probe = microchip_xisc_probe,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 348/1095 media: camss: csid: fix wrong size passed to devm_kmalloc_array()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 4c25384d136642d72098e36201ca988533e73065 ]
'supplies' is a pointer, the real size of struct regulator_bulk_data should be pass to devm_kmalloc_array().
--- drivers/media/platform/qcom/camss/camss-csid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/qcom/camss/camss-csid.c +1 -1
@@ -666,7 +666,7 @@ int msm_csid_subdev_init(struct camss *camss, struct csid_device *csid,if (csid->num_supplies) { csid->supplies =devm_kmalloc_array (camss->dev, csid->num_supplies, -sizeof (csid->supplies), +sizeof (*csid->supplies),GFP_KERNEL );if (!csid->supplies)return -ENOMEM ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 349/1095 media: tw686x: Register the irq at the end of probe
In reply to Greg Kroah-HartmanFrom: Zheyu Ma <[email protected]>
[ Upstream commit fb730334e0f759d00f72168fbc555e5a95e35210 ]
We got the following warning when booting the kernel:
[ 3.243674] INFO: trying to register non-static key. [ 3.243922] The code is fine but needs lockdep annotation, or maybe [ 3.244230] you didn't initialize this object before use? [ 3.245642] Call Trace: [ 3.247836] lock_acquire+0xff/0x2d0 [ 3.248727] tw686x_audio_irq+0x1a5/0xcc0 [tw686x] [ 3.249211] tw686x_irq+0x1f9/0x480 [tw686x]
The lock 'vc->qlock' will be initialized in tw686x_video_init(), but the driver registers the irq before calling the tw686x_video_init(), and we got the warning.
Fix this by registering the irq at the end of probe
--- drivers/media/pci/tw686x/tw686x-core.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)
drivers/media/pci/tw686x/tw686x-core.c +8 -10
@@ -315,13 +315,6 @@ static int tw686x_probe(struct pci_dev *pci_dev,spin_lock_init (&dev->lock); - err =request_irq (pci_dev->irq, tw686x_irq,IRQF_SHARED , - dev->name, dev); -if (err <0 ) { -dev_err (&pci_dev->dev,"unable to request interrupt\n" ); - goto iounmap; - } -timer_setup (&dev->dma_delay_timer, tw686x_dma_delay,0 );/*
@@ -333,18 +326,23 @@ static int tw686x_probe(struct pci_dev *pci_dev, err =tw686x_video_init (dev);if (err) {dev_err (&pci_dev->dev,"can't register video\n" ); - goto free_irq; + goto iounmap; } err =tw686x_audio_init (dev);if (err)dev_warn (&pci_dev->dev,"can't register audio\n" ); + err =request_irq (pci_dev->irq, tw686x_irq,IRQF_SHARED , + dev->name, dev); +if (err <0 ) { +dev_err (&pci_dev->dev,"unable to request interrupt\n" ); + goto iounmap; + } +pci_set_drvdata (pci_dev, dev);return 0 ; -free_irq: -free_irq (pci_dev->irq, dev); iounmap:pci_iounmap (pci_dev, dev->mmio); free_region:
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 350/1095 media: amphion: return error if format is unsupported by vpu
In reply to Greg Kroah-HartmanFrom: Ming Qian <[email protected]>
[ Upstream commit a3a2efca36a3a1ddba229a7be7991e8b5de4ac35 ]
return error if format is unsupported by vpu,
otherwise the vpu will be stalled at decoding
--- drivers/media/platform/amphion/vpu_malone.c | 2 ++ drivers/media/platform/amphion/vpu_v4l2.c | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-)
drivers/media/platform/amphion/vpu_malone.c +2 -0
@@ -609,6 +609,8 @@ static int vpu_malone_set_params(struct vpu_shared_addr *shared,enum vpu_malone_format malone_format; malone_format =vpu_malone_format_remap (params->codec_format); +if (WARN_ON (malone_format ==MALONE_FMT_NULL )) +return -EINVAL ; iface->udata_buffer[instance].base = params->udata.base; iface->udata_buffer[instance].slot_size = params->udata.size;
drivers/media/platform/amphion/vpu_v4l2.c +4 -2
@@ -440,10 +440,12 @@ static int vpu_vb2_start_streaming(struct vb2_queue *q, unsigned int count) fmt->sizeimage[1 ], fmt->bytesperline[1 ], fmt->sizeimage[2 ], fmt->bytesperline[2 ], q->num_buffers); -call_void_vop (inst, start, q->type); + ret =call_vop (inst, start, q->type);vb2_clear_last_buffer_dequeued (q); +if (ret) +vpu_vb2_buffers_return (inst, q->type,VB2_BUF_STATE_QUEUED ); -return 0 ; +return ret; }static void vpu_vb2_stop_streaming (struct vb2_queue *q)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 351/1095 media: Hantro: Correct G2 init qp field
In reply to Greg Kroah-HartmanFrom: Benjamin Gaignard <[email protected]>
[ Upstream commit 300065f966d30baa59a13849753305aac8c320c3 ]
Documentation said that g2 init_qp field use bits 24 to 30 of the 8th register.
Change the field mask to be able to set 7 bits and not only 6 of them.
Conformance test INITQP_B_Main10_Sony_1 decoding is OK with this patch.
--- drivers/staging/media/hantro/hantro_g2_regs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/hantro/hantro_g2_regs.h +1 -1
@@ -107,7 +107,7 @@#define g2_start_code_e G2_DEC_REG(10, 31, 0x1)#define g2_init_qp_old G2_DEC_REG(10, 25, 0x3f) -#define g2_init_qp G2_DEC_REG(10, 24, 0x3f) +#define g2_init_qp G2_DEC_REG(10, 24, 0x7f)#define g2_num_tile_cols_old G2_DEC_REG(10, 20, 0x1f)#define g2_num_tile_cols G2_DEC_REG(10, 19, 0x1f)#define g2_num_tile_rows_old G2_DEC_REG(10, 15, 0x1f)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 352/1095 media: imx-jpeg: Correct some definition according specification
In reply to Greg Kroah-HartmanFrom: Ming Qian <[email protected]>
[ Upstream commit 5a601f89e846c1b6005ab274d039e5036fc22015 ]
the register CAST_NOMFRSIZE_LO should be equal to CAST_STATUS16 the register CAST_NOMFRSIZE_HI should be equal to CAST_STATUS17 the register CAST_OFBSIZE_LO should be equal to CAST_STATUS18 the register CAST_OFBSIZE_HI should be equal to CAST_STATUS19
--- drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.h +4 -4
@@ -53,10 +53,10 @@#define CAST_REC_REGS_SEL CAST_STATUS4#define CAST_LUMTH CAST_STATUS5#define CAST_CHRTH CAST_STATUS6 -#define CAST_NOMFRSIZE_LO CAST_STATUS7 -#define CAST_NOMFRSIZE_HI CAST_STATUS8 -#define CAST_OFBSIZE_LO CAST_STATUS9 -#define CAST_OFBSIZE_HI CAST_STATUS10 +#define CAST_NOMFRSIZE_LO CAST_STATUS16 +#define CAST_NOMFRSIZE_HI CAST_STATUS17 +#define CAST_OFBSIZE_LO CAST_STATUS18 +#define CAST_OFBSIZE_HI CAST_STATUS19#define MXC_MAX_SLOTS 1/* TODO use all 4 slots*/ /* JPEG-Decoder Wrapper Slot Registers 0..3 */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 353/1095 media: imx-jpeg: Leave a blank space before the configuration data
In reply to Greg Kroah-HartmanFrom: Ming Qian <[email protected]>
[ Upstream commit 6285cdea19daf764bf00f662a59fc83ef67345cf ]
There is a hardware bug that it will load the first 128 bytes of configuration data twice, it will led to some configure error.
so shift the configuration data 128 bytes, and make the first 128 bytes all zero,
then hardware will load the 128 zero twice, and ignore them as garbage.
then the configuration data can be loaded correctly
--- drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c +8 -1
@@ -508,6 +508,7 @@ static bool mxc_jpeg_alloc_slot_data(struct mxc_jpeg_dev *jpeg, GFP_ATOMIC);if (!cfg_stm) goto err; +memset (cfg_stm,0 ,MXC_JPEG_MAX_CFG_STREAM ); jpeg->slot_data[slot].cfg_stream_vaddr = cfg_stm; skip_alloc:
@@ -743,7 +744,13 @@ static unsigned int mxc_jpeg_setup_cfg_stream(void *cfg_stream_vaddr, u32 fourcc, u16 w, u16 h) { - unsigned int offset = 0; +/* +* There is a hardware issue that first 128 bytes of configuration data +* can't be loaded correctly. +* To avoid this issue, we need to write the configuration from +* an offset which should be no less than 0x80 (128 bytes). +*/ +unsigned int offset =0x80 ;u8 *cfg = (u8 *)cfg_stream_vaddr;struct mxc_jpeg_sof *sof;struct mxc_jpeg_sos *sos;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 354/1095 media: imx-jpeg: Refactor function mxc_jpeg_parse
In reply to Greg Kroah-HartmanFrom: Ming Qian <[email protected]>
[ Upstream commit 8dd504a3a0a5f73b4c137ce3afc35936a4ecd871 ]
Refine code to support dynamic resolution change
--- drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c +6 -7
@@ -1252,8 +1252,7 @@ static void mxc_jpeg_sizeimage(struct mxc_jpeg_q_data *q) } } -static int mxc_jpeg_parse (struct mxc_jpeg_ctx *ctx, -u8 *src_addr,u32 size,bool *dht_needed) +static int mxc_jpeg_parse (struct mxc_jpeg_ctx *ctx,struct vb2_buffer *vb) {struct device *dev = ctx->mxc_jpeg->dev;struct mxc_jpeg_q_data *q_data_out, *q_data_cap;
@@ -1263,6 +1262,9 @@ static int mxc_jpeg_parse(struct mxc_jpeg_ctx *ctx,struct v4l2_jpeg_header header;struct mxc_jpeg_sof *psof =NULL ;struct mxc_jpeg_sos *psos =NULL ; +struct mxc_jpeg_src_buf *jpeg_src_buf =vb2_to_mxc_buf (vb); +u8 *src_addr = (u8 *)vb2_plane_vaddr (vb,0 ); +u32 size =vb2_get_plane_payload (vb,0 );int ret;memset (&header,0 ,sizeof (header));
@@ -1273,7 +1275,7 @@ static int mxc_jpeg_parse(struct mxc_jpeg_ctx *ctx, }/* if DHT marker present, no need to inject default one */ - *dht_needed = (header.num_dht ==0 ); + jpeg_src_buf->dht_needed = (header.num_dht ==0 ); q_data_out =mxc_jpeg_get_q_data (ctx,V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE );
@@ -1388,10 +1390,7 @@ static void mxc_jpeg_buf_queue(struct vb2_buffer *vb) jpeg_src_buf =vb2_to_mxc_buf (vb); jpeg_src_buf->jpeg_parse_error = false; - ret =mxc_jpeg_parse (ctx, - (u8 *)vb2_plane_vaddr (vb,0 ), -vb2_get_plane_payload (vb,0 ), - &jpeg_src_buf->dht_needed); + ret =mxc_jpeg_parse (ctx, vb);if (ret) jpeg_src_buf->jpeg_parse_error = true;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 355/1095 media: imx-jpeg: Identify and handle precision correctly
In reply to Greg Kroah-HartmanFrom: Ming Qian <[email protected]>
[ Upstream commit bec0a3a67389ede106d0661a007edf832878d8b2 ]
The decoder will save the precision that was detected from jpeg header and use it later, when choosing the pixel format and also calculate bytesperline according to precision.
The 12bit jpeg is not supported yet,
but driver shouldn't led to serious problem if user enqueue a 12 bit jpeg. And the 12bit jpeg is supported by hardware, driver may support it later.
[hverkuil: document the new precision field]
--- .../media/platform/nxp/imx-jpeg/mxc-jpeg.c | 37 +++++++++++++------ .../media/platform/nxp/imx-jpeg/mxc-jpeg.h | 2 + 2 files changed, 27 insertions(+), 12 deletions(-)
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c +25 -12
@@ -82,6 +82,7 @@ static const struct mxc_jpeg_fmt mxc_formats[] = { .h_align = 3, .v_align = 3, .flags = MXC_JPEG_FMT_TYPE_RAW, + .precision = 8, }, { .name = "ARGB", /* ARGBARGB packed format */
@@ -93,6 +94,7 @@ static const struct mxc_jpeg_fmt mxc_formats[] = { .h_align = 3, .v_align = 3, .flags = MXC_JPEG_FMT_TYPE_RAW, + .precision = 8, }, { .name = "YUV420", /* 1st plane = Y, 2nd plane = UV */
@@ -104,6 +106,7 @@ static const struct mxc_jpeg_fmt mxc_formats[] = { .h_align = 4, .v_align = 4, .flags = MXC_JPEG_FMT_TYPE_RAW, + .precision = 8, }, { .name = "YUV422", /* YUYV */
@@ -115,6 +118,7 @@ static const struct mxc_jpeg_fmt mxc_formats[] = { .h_align = 4, .v_align = 3, .flags = MXC_JPEG_FMT_TYPE_RAW, + .precision = 8, }, { .name = "YUV444", /* YUVYUV */
@@ -126,6 +130,7 @@ static const struct mxc_jpeg_fmt mxc_formats[] = { .h_align = 3, .v_align = 3, .flags = MXC_JPEG_FMT_TYPE_RAW, + .precision = 8, }, { .name = "Gray", /* Gray (Y8/Y12) or Single Comp */
@@ -137,6 +142,7 @@ static const struct mxc_jpeg_fmt mxc_formats[] = { .h_align = 3, .v_align = 3, .flags = MXC_JPEG_FMT_TYPE_RAW, + .precision = 8, }, };
@@ -1182,14 +1188,17 @@ static u32 mxc_jpeg_get_image_format(struct device *dev,for (i =0 ; i <MXC_JPEG_NUM_FORMATS ; i++)if (mxc_formats[i].subsampling == header->frame.subsampling && - mxc_formats[i].nc == header->frame.num_components) { + mxc_formats[i].nc == header->frame.num_components && + mxc_formats[i].precision == header->frame.precision) { fourcc = mxc_formats[i].fourcc;break ; }if (fourcc ==0 ) { -dev_err (dev,"Could not identify image format nc=%d, subsampling=%d\n" , +dev_err (dev, +"Could not identify image format nc=%d, subsampling=%d, precision=%d\n" , header->frame.num_components, - header->frame.subsampling); + header->frame.subsampling, + header->frame.precision);return fourcc; }/*
@@ -1215,18 +1224,22 @@ static void mxc_jpeg_bytesperline(struct mxc_jpeg_q_data *q,/* bytesperline unused for compressed formats */ q->bytesperline[0 ] =0 ; q->bytesperline[1 ] =0 ; - }else if (q->fmt->fourcc ==V4L2_PIX_FMT_NV12M ) { + }else if (q->fmt->subsampling ==V4L2_JPEG_CHROMA_SUBSAMPLING_420 ) {/* When the image format is planar the bytesperline value * applies to the first plane and is divided by the same factor * as the width field for the other planes */ - q->bytesperline[0 ] = q->w * (precision /8 ) * - (q->fmt->depth /8 ); + q->bytesperline[0 ] = q->w *DIV_ROUND_UP (precision,8 ); q->bytesperline[1 ] = q->bytesperline[0 ]; + }else if (q->fmt->subsampling ==V4L2_JPEG_CHROMA_SUBSAMPLING_422 ) { + q->bytesperline[0 ] = q->w *DIV_ROUND_UP (precision,8 ) *2 ; + q->bytesperline[1 ] =0 ; + }else if (q->fmt->subsampling ==V4L2_JPEG_CHROMA_SUBSAMPLING_444 ) { + q->bytesperline[0 ] = q->w *DIV_ROUND_UP (precision,8 ) * q->fmt->nc; + q->bytesperline[1 ] =0 ; }else { -/* single plane formats */ - q->bytesperline[0 ] = q->w * (precision /8 ) * - (q->fmt->depth /8 ); +/* grayscale */ + q->bytesperline[0 ] = q->w *DIV_ROUND_UP (precision,8 ); q->bytesperline[1 ] =0 ; } }
@@ -1360,7 +1373,7 @@ static int mxc_jpeg_parse(struct mxc_jpeg_ctx *ctx, struct vb2_buffer *vb) (fourcc >> 24) & 0xff);/* setup bytesperline/sizeimage for capture queue */ -mxc_jpeg_bytesperline (q_data_cap, header.frame.precision); +mxc_jpeg_bytesperline (q_data_cap, q_data_cap->fmt->precision);mxc_jpeg_sizeimage (q_data_cap);/*
@@ -1516,7 +1529,7 @@ static void mxc_jpeg_set_default_params(struct mxc_jpeg_ctx *ctx) q[i]->h =MXC_JPEG_DEFAULT_HEIGHT ; q[i]->w_adjusted =MXC_JPEG_DEFAULT_WIDTH ; q[i]->h_adjusted =MXC_JPEG_DEFAULT_HEIGHT ; -mxc_jpeg_bytesperline (q[i],8 ); +mxc_jpeg_bytesperline (q[i], q[i]->fmt->precision);mxc_jpeg_sizeimage (q[i]); } }
@@ -1658,7 +1671,7 @@ static int mxc_jpeg_try_fmt(struct v4l2_format *f, const struct mxc_jpeg_fmt *fm }/* calculate bytesperline & sizeimage into the tmp_q */ -mxc_jpeg_bytesperline (&tmp_q,8 ); +mxc_jpeg_bytesperline (&tmp_q, fmt->precision);mxc_jpeg_sizeimage (&tmp_q);/* adjust user format according to our calculations */
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.h +2 -0
@@ -49,6 +49,7 @@ enum mxc_jpeg_mode {* @h_align: horizontal alignment order (align to 2^h_align) * @v_align: vertical alignment order (align to 2^v_align) * @flags: flags describing format applicability +* @precision: jpeg sample precision */ struct mxc_jpeg_fmt {const char *name;
@@ -60,6 +61,7 @@ struct mxc_jpeg_fmt {int h_align;int v_align;u32 flags; +u8 precision; };struct mxc_jpeg_desc {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 356/1095 media: imx-jpeg: Handle source change in a function
In reply to Greg Kroah-HartmanFrom: Ming Qian <[email protected]>
[ Upstream commit 831f87424dd3973612782983ef7352789795b4df ]
Refine code to support dynamic resolution change
--- .../media/platform/nxp/imx-jpeg/mxc-jpeg.c | 114 ++++++++++-------- 1 file changed, 65 insertions(+), 49 deletions(-)
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c +65 -49
@@ -315,6 +315,9 @@ struct mxc_jpeg_src_buf {/* mxc-jpeg specific */ bool dht_needed;bool jpeg_parse_error; +const struct mxc_jpeg_fmt *fmt; +int w; +int h; };static inline struct mxc_jpeg_src_buf *vb2_to_mxc_buf (struct vb2_buffer *vb)
@@ -327,6 +330,9 @@ static unsigned int debug;module_param (debug, int,0644 );MODULE_PARM_DESC (debug,"Debug level (0-3)" ); +static void mxc_jpeg_bytesperline (struct mxc_jpeg_q_data *q,u32 precision); +static void mxc_jpeg_sizeimage (struct mxc_jpeg_q_data *q); +static void _bswap16 (u16 *a) { *a = ((*a &0x00FF ) <<8 ) | ((*a &0xFF00 ) >>8 );
@@ -929,6 +935,59 @@ static void mxc_jpeg_config_enc_desc(struct vb2_buffer *out_buf,mxc_jpeg_set_desc (cfg_desc_handle, reg, slot); } +static bool mxc_jpeg_source_change (struct mxc_jpeg_ctx *ctx, +struct mxc_jpeg_src_buf *jpeg_src_buf) +{ +struct device *dev = ctx->mxc_jpeg->dev; +struct mxc_jpeg_q_data *q_data_cap; +bool src_chg = false; + +if (!jpeg_src_buf->fmt) +return src_chg; + + q_data_cap =mxc_jpeg_get_q_data (ctx,V4L2_BUF_TYPE_VIDEO_CAPTURE ); +if (q_data_cap->w != jpeg_src_buf->w || q_data_cap->h != jpeg_src_buf->h) { +dev_dbg (dev,"Detected jpeg res=(%dx%d)->(%dx%d), pixfmt=%c%c%c%c\n" , + q_data_cap->w, q_data_cap->h, + jpeg_src_buf->w, jpeg_src_buf->h, + (jpeg_src_buf->fmt->fourcc &0xff ), + (jpeg_src_buf->fmt->fourcc >>8 ) &0xff , + (jpeg_src_buf->fmt->fourcc >>16 ) &0xff , + (jpeg_src_buf->fmt->fourcc >>24 ) &0xff ); + +/* +* set-up the capture queue with the pixelformat and resolution +* detected from the jpeg output stream +*/ + q_data_cap->w = jpeg_src_buf->w; + q_data_cap->h = jpeg_src_buf->h; + q_data_cap->fmt = jpeg_src_buf->fmt; + q_data_cap->w_adjusted = q_data_cap->w; + q_data_cap->h_adjusted = q_data_cap->h; + +/* +* align up the resolution for CAST IP, +* but leave the buffer resolution unchanged +*/ +v4l_bound_align_image (&q_data_cap->w_adjusted, + q_data_cap->w_adjusted,/* adjust up */ +MXC_JPEG_MAX_WIDTH , + q_data_cap->fmt->h_align, + &q_data_cap->h_adjusted, + q_data_cap->h_adjusted,/* adjust up */ +MXC_JPEG_MAX_HEIGHT , + q_data_cap->fmt->v_align, +0 ); + +/* setup bytesperline/sizeimage for capture queue */ +mxc_jpeg_bytesperline (q_data_cap, jpeg_src_buf->fmt->precision); +mxc_jpeg_sizeimage (q_data_cap); +notify_src_chg (ctx); + src_chg = true; + } +return src_chg; +} +static void mxc_jpeg_device_run (void *priv) {struct mxc_jpeg_ctx *ctx = priv;
@@ -1216,8 +1275,7 @@ static u32 mxc_jpeg_get_image_format(struct device *dev,return fourcc; } -static void mxc_jpeg_bytesperline (struct mxc_jpeg_q_data *q, -u32 precision) +static void mxc_jpeg_bytesperline (struct mxc_jpeg_q_data *q,u32 precision) {/* Bytes distance between the leftmost pixels in two adjacent lines */ if (q->fmt->fourcc ==V4L2_PIX_FMT_JPEG ) {
@@ -1268,9 +1326,7 @@ static void mxc_jpeg_sizeimage(struct mxc_jpeg_q_data *q)static int mxc_jpeg_parse (struct mxc_jpeg_ctx *ctx,struct vb2_buffer *vb) {struct device *dev = ctx->mxc_jpeg->dev; -struct mxc_jpeg_q_data *q_data_out, *q_data_cap; -enum v4l2_buf_type cap_type =V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE ; -bool src_chg = false; +struct mxc_jpeg_q_data *q_data_out;u32 fourcc;struct v4l2_jpeg_header header;struct mxc_jpeg_sof *psof =NULL ;
@@ -1338,51 +1394,11 @@ static int mxc_jpeg_parse(struct mxc_jpeg_ctx *ctx, struct vb2_buffer *vb)if (fourcc ==0 )return -EINVAL ; -/* -* set-up the capture queue with the pixelformat and resolution -* detected from the jpeg output stream -*/ - q_data_cap =mxc_jpeg_get_q_data (ctx, cap_type); -if (q_data_cap->w != header.frame.width || - q_data_cap->h != header.frame.height) - src_chg = true; - q_data_cap->w = header.frame.width; - q_data_cap->h = header.frame.height; - q_data_cap->fmt =mxc_jpeg_find_format (ctx, fourcc); - q_data_cap->w_adjusted = q_data_cap->w; - q_data_cap->h_adjusted = q_data_cap->h; -/* -* align up the resolution for CAST IP, -* but leave the buffer resolution unchanged -*/ -v4l_bound_align_image (&q_data_cap->w_adjusted, - q_data_cap->w_adjusted,/* adjust up */ -MXC_JPEG_MAX_WIDTH , - q_data_cap->fmt->h_align, - &q_data_cap->h_adjusted, - q_data_cap->h_adjusted,/* adjust up */ -MXC_JPEG_MAX_HEIGHT , - q_data_cap->fmt->v_align, -0 ); -dev_dbg (dev,"Detected jpeg res=(%dx%d)->(%dx%d), pixfmt=%c%c%c%c\n" , - q_data_cap->w, q_data_cap->h, - q_data_cap->w_adjusted, q_data_cap->h_adjusted, - (fourcc &0xff ), - (fourcc >>8 ) &0xff , - (fourcc >>16 ) &0xff , - (fourcc >>24 ) &0xff ); - -/* setup bytesperline/sizeimage for capture queue */ -mxc_jpeg_bytesperline (q_data_cap, q_data_cap->fmt->precision); -mxc_jpeg_sizeimage (q_data_cap); + jpeg_src_buf->fmt =mxc_jpeg_find_format (ctx, fourcc); + jpeg_src_buf->w = header.frame.width; + jpeg_src_buf->h = header.frame.height; -/* -* if the CAPTURE format was updated with new values, regardless of -* whether they match the values set by the client or not, signal -* a source change event -*/ -if (src_chg) -notify_src_chg (ctx); +mxc_jpeg_source_change (ctx, jpeg_src_buf);return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 357/1095 media: imx-jpeg: Support dynamic resolution change
In reply to Greg Kroah-HartmanFrom: Ming Qian <[email protected]>
[ Upstream commit b4e1fb8643daabba850e97df532191acffc23e6a ]
To support dynamic resolution change,
driver should meet the following conditions:
1. the previous pictures are all decoded before source change event.
2. prevent decoding new resolution pictures with incorrect capture buffer, until user handle source change event and setup capture.
3. report correct fmt and resolution during source change.
--- .../media/platform/nxp/imx-jpeg/mxc-jpeg.c | 69 ++++++++++++++----- .../media/platform/nxp/imx-jpeg/mxc-jpeg.h | 2 + 2 files changed, 55 insertions(+), 16 deletions(-)
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c +53 -16
@@ -940,13 +940,14 @@ static bool mxc_jpeg_source_change(struct mxc_jpeg_ctx *ctx, {struct device *dev = ctx->mxc_jpeg->dev;struct mxc_jpeg_q_data *q_data_cap; -bool src_chg = false;if (!jpeg_src_buf->fmt) -return src_chg; +return false; q_data_cap =mxc_jpeg_get_q_data (ctx,V4L2_BUF_TYPE_VIDEO_CAPTURE ); -if (q_data_cap->w != jpeg_src_buf->w || q_data_cap->h != jpeg_src_buf->h) { +if (q_data_cap->fmt != jpeg_src_buf->fmt || + q_data_cap->w != jpeg_src_buf->w || + q_data_cap->h != jpeg_src_buf->h) { dev_dbg(dev, "Detected jpeg res=(%dx%d)->(%dx%d), pixfmt=%c%c%c%c\n", q_data_cap->w, q_data_cap->h, jpeg_src_buf->w, jpeg_src_buf->h,
@@ -983,9 +984,16 @@ static bool mxc_jpeg_source_change(struct mxc_jpeg_ctx *ctx,mxc_jpeg_bytesperline (q_data_cap, jpeg_src_buf->fmt->precision);mxc_jpeg_sizeimage (q_data_cap);notify_src_chg (ctx); - src_chg = true; + ctx->source_change =1 ; } -return src_chg; +return ctx->source_change ? true : false; +} + +static int mxc_jpeg_job_ready (void *priv) +{ +struct mxc_jpeg_ctx *ctx = priv; + +return ctx->source_change ?0 :1 ; }static void mxc_jpeg_device_run (void *priv)
@@ -1035,6 +1043,13 @@ static void mxc_jpeg_device_run(void *priv)return ; } +if (ctx->mxc_jpeg->mode ==MXC_JPEG_DECODE ) { +if (ctx->source_change ||mxc_jpeg_source_change (ctx, jpeg_src_buf)) { +spin_unlock_irqrestore (&ctx->mxc_jpeg->hw_lock, flags); +v4l2_m2m_job_finish (jpeg->m2m_dev, ctx->fh.m2m_ctx); +return ; + } + }mxc_jpeg_enable (reg);mxc_jpeg_set_l_endian (reg,1 );
@@ -1081,6 +1096,7 @@ static void mxc_jpeg_set_last_buffer_dequeued(struct mxc_jpeg_ctx *ctx) q->last_buffer_dequeued = true;wake_up (&q->done_wq); ctx->stopped =0 ; + ctx->header_parsed = false; } static int mxc_jpeg_decoder_cmd(struct file *file, void *priv,
@@ -1174,6 +1190,8 @@ static int mxc_jpeg_start_streaming(struct vb2_queue *q, unsigned int count)struct mxc_jpeg_q_data *q_data =mxc_jpeg_get_q_data (ctx, q->type);int ret; +if (ctx->mxc_jpeg->mode ==MXC_JPEG_DECODE &&V4L2_TYPE_IS_CAPTURE (q->type)) + ctx->source_change =0 ;dev_dbg (ctx->mxc_jpeg->dev,"Start streaming ctx=%p" , ctx); q_data->sequence =0 ;
@@ -1352,16 +1370,15 @@ static int mxc_jpeg_parse(struct mxc_jpeg_ctx *ctx, struct vb2_buffer *vb)dev_warn (dev,"Invalid user resolution 0x0" );dev_warn (dev,"Keeping resolution from JPEG: %dx%d" , header.frame.width, header.frame.height); - q_data_out->w = header.frame.width; - q_data_out->h = header.frame.height; }else if (header.frame.width != q_data_out->w || header.frame.height != q_data_out->h) {dev_err (dev,"Resolution mismatch: %dx%d (JPEG) versus %dx%d(user)" , header.frame.width, header.frame.height, q_data_out->w, q_data_out->h); -return -EINVAL ; } + q_data_out->w = header.frame.width; + q_data_out->h = header.frame.height;if (header.frame.width %8 !=0 || header.frame.height %8 !=0 ) {dev_err (dev,"JPEG width or height not multiple of 8: %dx%d\n" , header.frame.width, header.frame.height);
@@ -1397,8 +1414,10 @@ static int mxc_jpeg_parse(struct mxc_jpeg_ctx *ctx, struct vb2_buffer *vb) jpeg_src_buf->fmt =mxc_jpeg_find_format (ctx, fourcc); jpeg_src_buf->w = header.frame.width; jpeg_src_buf->h = header.frame.height; + ctx->header_parsed = true; -mxc_jpeg_source_change (ctx, jpeg_src_buf); +if (!v4l2_m2m_num_src_bufs_ready (ctx->fh.m2m_ctx)) +mxc_jpeg_source_change (ctx, jpeg_src_buf);return 0 ; }
@@ -1475,6 +1494,7 @@ static void mxc_jpeg_buf_finish(struct vb2_buffer *vb)if (list_empty (&q->done_list)) { vbuf->flags |=V4L2_BUF_FLAG_LAST ; ctx->stopped =0 ; + ctx->header_parsed = false; } }
@@ -1620,26 +1640,42 @@ static int mxc_jpeg_enum_fmt_vid_cap(struct file *file, void *priv, struct v4l2_fmtdesc *f) {struct mxc_jpeg_ctx *ctx =mxc_jpeg_fh_to_ctx (priv); +struct mxc_jpeg_q_data *q_data =mxc_jpeg_get_q_data (ctx, f->type); -if (ctx->mxc_jpeg->mode ==MXC_JPEG_ENCODE ) +if (ctx->mxc_jpeg->mode ==MXC_JPEG_ENCODE ) {return enum_fmt (mxc_formats,MXC_JPEG_NUM_FORMATS , f,MXC_JPEG_FMT_TYPE_ENC ); -else + }else if (!ctx->header_parsed) {return enum_fmt (mxc_formats,MXC_JPEG_NUM_FORMATS , f,MXC_JPEG_FMT_TYPE_RAW ); + }else { +/* For the decoder CAPTURE queue, only enumerate the raw formats +* supported for the format currently active on OUTPUT +* (more precisely what was propagated on capture queue +* after jpeg parse on the output buffer) +*/ +if (f->index) +return -EINVAL ; + f->pixelformat = q_data->fmt->fourcc; +strscpy (f->description, q_data->fmt->name,sizeof (f->description)); +return 0 ; + } }static int mxc_jpeg_enum_fmt_vid_out (struct file *file,void *priv,struct v4l2_fmtdesc *f) {struct mxc_jpeg_ctx *ctx =mxc_jpeg_fh_to_ctx (priv); +u32 type = ctx->mxc_jpeg->mode ==MXC_JPEG_DECODE ?MXC_JPEG_FMT_TYPE_ENC : +MXC_JPEG_FMT_TYPE_RAW ; +int ret; + ret =enum_fmt (mxc_formats,MXC_JPEG_NUM_FORMATS , f, type); +if (ret) +return ret;if (ctx->mxc_jpeg->mode ==MXC_JPEG_DECODE ) -return enum_fmt (mxc_formats,MXC_JPEG_NUM_FORMATS , f, -MXC_JPEG_FMT_TYPE_ENC ); -else -return enum_fmt (mxc_formats,MXC_JPEG_NUM_FORMATS , f, -MXC_JPEG_FMT_TYPE_RAW ); + f->flags =V4L2_FMT_FLAG_DYN_RESOLUTION ; +return 0 ; } static int mxc_jpeg_try_fmt(struct v4l2_format *f, const struct mxc_jpeg_fmt *fmt,
@@ -1997,6 +2033,7 @@ static const struct v4l2_file_operations mxc_jpeg_fops = { };static const struct v4l2_m2m_ops mxc_jpeg_m2m_ops = { + .job_ready = mxc_jpeg_job_ready, .device_run = mxc_jpeg_device_run, };
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.h +2 -0
@@ -95,6 +95,8 @@ struct mxc_jpeg_ctx {unsigned int stopping;unsigned int stopped;unsigned int slot; +unsigned int source_change; +bool header_parsed; };struct mxc_jpeg_slot_data {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 358/1095 media: imx-jpeg: Align upwards buffer size
In reply to Greg Kroah-HartmanFrom: Ming Qian <[email protected]>
[ Upstream commit 9e7aa76cdb02923ee23a0ddd48f38bdc3512f92b ]
The hardware can support any image size WxH,
with arbitrary W (image width) and H (image height) dimensions.
Align upwards buffer size for both encoder and decoder. and leave the picture resolution unchanged.
For decoder, the risk of memory out of bounds can be avoided. For both encoder and decoder, the driver will lift the limitation of resolution alignment.
For example, the decoder can support jpeg whose resolution is 227x149 the encoder can support nv12 1080P, won't change it to 1920x1072.
--- .../media/platform/nxp/imx-jpeg/mxc-jpeg.c | 88 ++++++++----------- 1 file changed, 37 insertions(+), 51 deletions(-)
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c +37 -51
@@ -894,8 +894,8 @@ static void mxc_jpeg_config_enc_desc(struct vb2_buffer *out_buf, jpeg->slot_data[slot].cfg_stream_size =mxc_jpeg_setup_cfg_stream (cfg_stream_vaddr, q_data->fmt->fourcc, - q_data->w_adjusted, - q_data->h_adjusted); + q_data->w, + q_data->h);/* chain the config descriptor with the encoding descriptor */ cfg_desc->next_descpt_ptr = desc_handle |MXC_NXT_DESCPT_EN ;
@@ -977,7 +977,7 @@ static bool mxc_jpeg_source_change(struct mxc_jpeg_ctx *ctx, &q_data_cap->h_adjusted, q_data_cap->h_adjusted,/* adjust up */ MXC_JPEG_MAX_HEIGHT , - q_data_cap->fmt->v_align, +0 , 0);/* setup bytesperline/sizeimage for capture queue */
@@ -1161,16 +1161,28 @@ static int mxc_jpeg_queue_setup(struct vb2_queue *q, {struct mxc_jpeg_ctx *ctx =vb2_get_drv_priv (q);struct mxc_jpeg_q_data *q_data =NULL ; +struct mxc_jpeg_q_data tmp_q;int i; q_data =mxc_jpeg_get_q_data (ctx, q->type);if (!q_data)return -EINVAL ; + tmp_q.fmt = q_data->fmt; + tmp_q.w = q_data->w_adjusted; + tmp_q.h = q_data->h_adjusted; +for (i =0 ; i <MXC_JPEG_MAX_PLANES ; i++) { + tmp_q.bytesperline[i] = q_data->bytesperline[i]; + tmp_q.sizeimage[i] = q_data->sizeimage[i]; + } +mxc_jpeg_sizeimage (&tmp_q); +for (i =0 ; i <MXC_JPEG_MAX_PLANES ; i++) + tmp_q.sizeimage[i] =max (tmp_q.sizeimage[i], q_data->sizeimage[i]); +/* Handle CREATE_BUFS situation - *nplanes != 0 */ if (*nplanes) {for (i =0 ; i < *nplanes; i++) { -if (sizes[i] < q_data->sizeimage[i]) +if (sizes[i] < tmp_q.sizeimage[i])return -EINVAL ; }return 0 ;
@@ -1179,7 +1191,7 @@ static int mxc_jpeg_queue_setup(struct vb2_queue *q,/* Handle REQBUFS situation */ *nplanes = q_data->fmt->colplanes;for (i =0 ; i < *nplanes; i++) - sizes[i] = q_data->sizeimage[i]; + sizes[i] = tmp_q.sizeimage[i];return 0 ; }
@@ -1379,11 +1391,6 @@ static int mxc_jpeg_parse(struct mxc_jpeg_ctx *ctx, struct vb2_buffer *vb) } q_data_out->w = header.frame.width; q_data_out->h = header.frame.height; -if (header.frame.width %8 !=0 || header.frame.height %8 !=0 ) { -dev_err (dev,"JPEG width or height not multiple of 8: %dx%d\n" , - header.frame.width, header.frame.height); -return -EINVAL ; - }if (header.frame.width >MXC_JPEG_MAX_WIDTH || header.frame.height >MXC_JPEG_MAX_HEIGHT ) { dev_err(dev, "JPEG width or height should be <= 8192: %dx%d\n",
@@ -1695,22 +1702,17 @@ static int mxc_jpeg_try_fmt(struct v4l2_format *f, const struct mxc_jpeg_fmt *fm pix_mp->num_planes = fmt->colplanes; pix_mp->pixelformat = fmt->fourcc; -/* -* use MXC_JPEG_H_ALIGN instead of fmt->v_align, for vertical -* alignment, to loosen up the alignment to multiple of 8, -* otherwise NV12-1080p fails as 1080 is not a multiple of 16 -*/ + pix_mp->width = w; + pix_mp->height = h;v4l_bound_align_image (&w, -MXC_JPEG_MIN_WIDTH , - w,/* adjust downwards*/ + w,/* adjust upwards*/ +MXC_JPEG_MAX_WIDTH , fmt->h_align, &h, -MXC_JPEG_MIN_HEIGHT , - h,/* adjust downwards*/ -MXC_JPEG_H_ALIGN , + h,/* adjust upwards*/ +MXC_JPEG_MAX_HEIGHT , +0 ,0 ); - pix_mp->width = w;/* negotiate the width */ - pix_mp->height = h;/* negotiate the height */ /* get user input into the tmp_q */ tmp_q.w = w;
@@ -1836,35 +1838,19 @@ static int mxc_jpeg_s_fmt(struct mxc_jpeg_ctx *ctx, q_data->w_adjusted = q_data->w; q_data->h_adjusted = q_data->h; -if (jpeg->mode ==MXC_JPEG_DECODE ) { -/* -* align up the resolution for CAST IP, -* but leave the buffer resolution unchanged -*/ -v4l_bound_align_image (&q_data->w_adjusted, - q_data->w_adjusted,/* adjust upwards */ -MXC_JPEG_MAX_WIDTH , - q_data->fmt->h_align, - &q_data->h_adjusted, - q_data->h_adjusted,/* adjust upwards */ -MXC_JPEG_MAX_HEIGHT , - q_data->fmt->v_align, -0 ); - }else { -/* -* align down the resolution for CAST IP, -* but leave the buffer resolution unchanged -*/ -v4l_bound_align_image (&q_data->w_adjusted, -MXC_JPEG_MIN_WIDTH , - q_data->w_adjusted,/* adjust downwards*/ - q_data->fmt->h_align, - &q_data->h_adjusted, -MXC_JPEG_MIN_HEIGHT , - q_data->h_adjusted,/* adjust downwards*/ - q_data->fmt->v_align, -0 ); - } +/* +* align up the resolution for CAST IP, +* but leave the buffer resolution unchanged +*/ +v4l_bound_align_image (&q_data->w_adjusted, + q_data->w_adjusted,/* adjust upwards */ +MXC_JPEG_MAX_WIDTH , + q_data->fmt->h_align, + &q_data->h_adjusted, + q_data->h_adjusted,/* adjust upwards */ +MXC_JPEG_MAX_HEIGHT , + q_data->fmt->v_align, +0 );for (i =0 ; i < pix_mp->num_planes; i++) { q_data->bytesperline[i] = pix_mp->plane_fmt[i].bytesperline;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 359/1095 media: imx-jpeg: Implement drain using v4l2-mem2mem helpers
In reply to Greg Kroah-HartmanFrom: Ming Qian <[email protected]>
[ Upstream commit 4911c5acf9351c4caf692895c7cf6a4fa46c26b0 ]
v4l2 m2m has supplied some helper function to handle drain, so the driver can use the helper function directly.
--- .../media/platform/nxp/imx-jpeg/mxc-jpeg.c | 155 +++++++++--------- .../media/platform/nxp/imx-jpeg/mxc-jpeg.h | 2 - 2 files changed, 73 insertions(+), 84 deletions(-)
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c +73 -82
@@ -559,6 +559,18 @@ static void mxc_jpeg_free_slot_data(struct mxc_jpeg_dev *jpeg, jpeg->slot_data[slot].used = false; } +static void mxc_jpeg_check_and_set_last_buffer (struct mxc_jpeg_ctx *ctx, +struct vb2_v4l2_buffer *src_buf, +struct vb2_v4l2_buffer *dst_buf) +{ +if (v4l2_m2m_is_last_draining_src_buf (ctx->fh.m2m_ctx, src_buf)) { + dst_buf->flags |=V4L2_BUF_FLAG_LAST ; +v4l2_m2m_mark_stopped (ctx->fh.m2m_ctx); +notify_eos (ctx); + ctx->header_parsed = false; + } +} +static irqreturn_t mxc_jpeg_dec_irq (int irq,void *priv) {struct mxc_jpeg_dev *jpeg = priv;
@@ -633,6 +645,7 @@ static irqreturn_t mxc_jpeg_dec_irq(int irq, void *priv)dev_dbg (dev,"Decoder DHT cfg finished. Start decoding...\n" ); goto job_unlock; } +if (jpeg->mode ==MXC_JPEG_ENCODE ) { payload =readl (reg +MXC_SLOT_OFFSET (slot,SLOT_BUF_PTR ));vb2_set_plane_payload (&dst_buf->vb2_buf,0 , payload);
@@ -661,6 +674,7 @@ static irqreturn_t mxc_jpeg_dec_irq(int irq, void *priv) buffers_done: jpeg->slot_data[slot].used = false;/* unused, but don't free */ +mxc_jpeg_check_and_set_last_buffer (ctx, src_buf, dst_buf);v4l2_m2m_src_buf_remove (ctx->fh.m2m_ctx);v4l2_m2m_dst_buf_remove (ctx->fh.m2m_ctx);v4l2_m2m_buf_done (src_buf, buf_state);
@@ -1034,6 +1048,7 @@ static void mxc_jpeg_device_run(void *priv) jpeg_src_buf->jpeg_parse_error = true; }if (jpeg_src_buf->jpeg_parse_error) { +mxc_jpeg_check_and_set_last_buffer (ctx, src_buf, dst_buf);v4l2_m2m_src_buf_remove (ctx->fh.m2m_ctx);v4l2_m2m_dst_buf_remove (ctx->fh.m2m_ctx);v4l2_m2m_buf_done (src_buf,VB2_BUF_STATE_ERROR );
@@ -1084,45 +1099,33 @@ static void mxc_jpeg_device_run(void *priv)spin_unlock_irqrestore (&ctx->mxc_jpeg->hw_lock, flags); } -static void mxc_jpeg_set_last_buffer_dequeued (struct mxc_jpeg_ctx *ctx) -{ -struct vb2_queue *q; - - ctx->stopped =1 ; - q =v4l2_m2m_get_dst_vq (ctx->fh.m2m_ctx); -if (!list_empty (&q->done_list)) -return ; - - q->last_buffer_dequeued = true; -wake_up (&q->done_wq); - ctx->stopped =0 ; - ctx->header_parsed = false; -} -static int mxc_jpeg_decoder_cmd (struct file *file,void *priv,struct v4l2_decoder_cmd *cmd) {struct v4l2_fh *fh = file->private_data;struct mxc_jpeg_ctx *ctx =mxc_jpeg_fh_to_ctx (fh); -struct device *dev = ctx->mxc_jpeg->dev;int ret; ret =v4l2_m2m_ioctl_try_decoder_cmd (file, fh, cmd);if (ret <0 )return ret; -if (cmd->cmd ==V4L2_DEC_CMD_STOP ) { -dev_dbg (dev,"Received V4L2_DEC_CMD_STOP" ); -if (v4l2_m2m_num_src_bufs_ready (fh->m2m_ctx) ==0 ) { -/* No more src bufs, notify app EOS */ -notify_eos (ctx); -mxc_jpeg_set_last_buffer_dequeued (ctx); - }else { -/* will send EOS later*/ - ctx->stopping =1 ; - } +if (!vb2_is_streaming (v4l2_m2m_get_src_vq (fh->m2m_ctx))) +return 0 ; + + ret =v4l2_m2m_ioctl_decoder_cmd (file, priv, cmd); +if (ret <0 ) +return ret; + +if (cmd->cmd ==V4L2_DEC_CMD_STOP && +v4l2_m2m_has_stopped (fh->m2m_ctx)) { +notify_eos (ctx); + ctx->header_parsed = false; } +if (cmd->cmd ==V4L2_DEC_CMD_START && +v4l2_m2m_has_stopped (fh->m2m_ctx)) +vb2_clear_last_buffer_dequeued (&fh->m2m_ctx->cap_q_ctx.q);return 0 ; }
@@ -1131,24 +1134,27 @@ static int mxc_jpeg_encoder_cmd(struct file *file, void *priv, {struct v4l2_fh *fh = file->private_data;struct mxc_jpeg_ctx *ctx =mxc_jpeg_fh_to_ctx (fh); -struct device *dev = ctx->mxc_jpeg->dev;int ret; ret =v4l2_m2m_ioctl_try_encoder_cmd (file, fh, cmd);if (ret <0 )return ret; -if (cmd->cmd ==V4L2_ENC_CMD_STOP ) { -dev_dbg (dev,"Received V4L2_ENC_CMD_STOP" ); -if (v4l2_m2m_num_src_bufs_ready (fh->m2m_ctx) ==0 ) { -/* No more src bufs, notify app EOS */ -notify_eos (ctx); -mxc_jpeg_set_last_buffer_dequeued (ctx); - }else { -/* will send EOS later*/ - ctx->stopping =1 ; - } - } +if (!vb2_is_streaming (v4l2_m2m_get_src_vq (fh->m2m_ctx)) || + !vb2_is_streaming (v4l2_m2m_get_dst_vq (fh->m2m_ctx))) +return 0 ; + + ret =v4l2_m2m_ioctl_encoder_cmd (file, fh, cmd); +if (ret <0 ) +return 0 ; + +if (cmd->cmd ==V4L2_ENC_CMD_STOP && +v4l2_m2m_has_stopped (fh->m2m_ctx)) +notify_eos (ctx); + +if (cmd->cmd ==V4L2_ENC_CMD_START && +v4l2_m2m_has_stopped (fh->m2m_ctx)) +vb2_clear_last_buffer_dequeued (&fh->m2m_ctx->cap_q_ctx.q);return 0 ; }
@@ -1202,6 +1208,8 @@ static int mxc_jpeg_start_streaming(struct vb2_queue *q, unsigned int count)struct mxc_jpeg_q_data *q_data =mxc_jpeg_get_q_data (ctx, q->type);int ret; +v4l2_m2m_update_start_streaming_state (ctx->fh.m2m_ctx, q); +if (ctx->mxc_jpeg->mode ==MXC_JPEG_DECODE &&V4L2_TYPE_IS_CAPTURE (q->type)) ctx->source_change =0 ;dev_dbg (ctx->mxc_jpeg->dev,"Start streaming ctx=%p" , ctx);
@@ -1233,11 +1241,15 @@ static void mxc_jpeg_stop_streaming(struct vb2_queue *q)break ;v4l2_m2m_buf_done (vbuf,VB2_BUF_STATE_ERROR ); } -pm_runtime_put_sync (&ctx->mxc_jpeg->pdev->dev); -if (V4L2_TYPE_IS_OUTPUT (q->type)) { - ctx->stopping =0 ; - ctx->stopped =0 ; + +v4l2_m2m_update_stop_streaming_state (ctx->fh.m2m_ctx, q); +if (V4L2_TYPE_IS_OUTPUT (q->type) && +v4l2_m2m_has_stopped (ctx->fh.m2m_ctx)) { +notify_eos (ctx); + ctx->header_parsed = false; } + +pm_runtime_put_sync (&ctx->mxc_jpeg->pdev->dev); } static int mxc_jpeg_valid_comp_id(struct device *dev,
@@ -1436,6 +1448,20 @@ static void mxc_jpeg_buf_queue(struct vb2_buffer *vb)struct mxc_jpeg_ctx *ctx =vb2_get_drv_priv (vb->vb2_queue);struct mxc_jpeg_src_buf *jpeg_src_buf; +if (V4L2_TYPE_IS_CAPTURE (vb->vb2_queue->type) && +vb2_is_streaming (vb->vb2_queue) && +v4l2_m2m_dst_buf_is_last (ctx->fh.m2m_ctx)) { +struct mxc_jpeg_q_data *q_data; + + q_data =mxc_jpeg_get_q_data (ctx, vb->vb2_queue->type); + vbuf->field =V4L2_FIELD_NONE ; + vbuf->sequence = q_data->sequence++; +v4l2_m2m_last_buffer_done (ctx->fh.m2m_ctx, vbuf); +notify_eos (ctx); + ctx->header_parsed = false; +return ; + } +if (vb->vb2_queue->type ==V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE ) goto end;
@@ -1485,24 +1511,11 @@ static int mxc_jpeg_buf_prepare(struct vb2_buffer *vb) }vb2_set_plane_payload (vb, i, sizeimage); } -return 0 ; -} - -static void mxc_jpeg_buf_finish (struct vb2_buffer *vb) -{ -struct vb2_v4l2_buffer *vbuf =to_vb2_v4l2_buffer (vb); -struct mxc_jpeg_ctx *ctx =vb2_get_drv_priv (vb->vb2_queue); -struct vb2_queue *q = vb->vb2_queue; - -if (V4L2_TYPE_IS_OUTPUT (vb->type)) -return ; -if (!ctx->stopped) -return ; -if (list_empty (&q->done_list)) { - vbuf->flags |=V4L2_BUF_FLAG_LAST ; - ctx->stopped =0 ; - ctx->header_parsed = false; +if (V4L2_TYPE_IS_CAPTURE (vb->vb2_queue->type)) { +vb2_set_plane_payload (vb,0 ,0 ); +vb2_set_plane_payload (vb,1 ,0 ); } +return 0 ; }static const struct vb2_ops mxc_jpeg_qops = {
@@ -1511,7 +1524,6 @@ static const struct vb2_ops mxc_jpeg_qops = { .wait_finish = vb2_ops_wait_finish, .buf_out_validate = mxc_jpeg_buf_out_validate, .buf_prepare = mxc_jpeg_buf_prepare, - .buf_finish = mxc_jpeg_buf_finish, .start_streaming = mxc_jpeg_start_streaming, .stop_streaming = mxc_jpeg_stop_streaming, .buf_queue = mxc_jpeg_buf_queue,
@@ -1932,27 +1944,6 @@ static int mxc_jpeg_subscribe_event(struct v4l2_fh *fh, } } -static int mxc_jpeg_dqbuf (struct file *file,void *priv, -struct v4l2_buffer *buf) -{ -struct v4l2_fh *fh = file->private_data; -struct mxc_jpeg_ctx *ctx =mxc_jpeg_fh_to_ctx (priv); -struct device *dev = ctx->mxc_jpeg->dev; -int num_src_ready =v4l2_m2m_num_src_bufs_ready (fh->m2m_ctx); -int ret; - -dev_dbg (dev,"DQBUF type=%d, index=%d" , buf->type, buf->index); -if (ctx->stopping ==1 && num_src_ready ==0 ) { -/* No more src bufs, notify app EOS */ -notify_eos (ctx); - ctx->stopping =0 ; -mxc_jpeg_set_last_buffer_dequeued (ctx); - } - - ret =v4l2_m2m_dqbuf (file, fh->m2m_ctx, buf); -return ret; -} -static const struct v4l2_ioctl_ops mxc_jpeg_ioctl_ops = { .vidioc_querycap = mxc_jpeg_querycap, .vidioc_enum_fmt_vid_cap = mxc_jpeg_enum_fmt_vid_cap,
@@ -1976,7 +1967,7 @@ static const struct v4l2_ioctl_ops mxc_jpeg_ioctl_ops = { .vidioc_encoder_cmd = mxc_jpeg_encoder_cmd, .vidioc_qbuf = v4l2_m2m_ioctl_qbuf, - .vidioc_dqbuf = mxc_jpeg_dqbuf, + .vidioc_dqbuf = v4l2_m2m_ioctl_dqbuf, .vidioc_create_bufs = v4l2_m2m_ioctl_create_bufs, .vidioc_prepare_buf = v4l2_m2m_ioctl_prepare_buf,
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.h +0 -2
@@ -92,8 +92,6 @@ struct mxc_jpeg_ctx {struct mxc_jpeg_q_data cap_q;struct v4l2_fh fh;enum mxc_jpeg_enc_state enc_state; -unsigned int stopping; -unsigned int stopped;unsigned int slot;unsigned int source_change;bool header_parsed;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 360/1095 media: rcar-vin: Fix channel routing for Ebisu
In reply to Greg Kroah-HartmanFrom: Niklas Söderlund <[email protected]>
[ Upstream commit 5b9b598453d3ae5fa66d7ab591008373a89b91a0 ]
When converting to full Virtual Channel routing an error crept into the routing table for Ebisu (r8a77990). The routing information is used at probe time preventing rcar-vin from probing correctly on this SoC, solve by correcting the routing table.
--- drivers/media/platform/renesas/rcar-vin/rcar-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/renesas/rcar-vin/rcar-core.c +1 -1
@@ -1264,7 +1264,7 @@ static const struct rvin_info rcar_info_r8a77980 = { };static const struct rvin_group_route rcar_info_r8a77990_routes[] = { - { .master =0 , .csi =RVIN_CSI40 , .chsel =0x03 }, + { .master =4 , .csi =RVIN_CSI40 , .chsel =0x03 }, {/* Sentinel */ } };
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 361/1095 ath9k: fix use-after-free in ath9k_hif_usb_rx_cb
In reply to Greg Kroah-HartmanFrom: Pavel Skripkin <[email protected]>
[ Upstream commit 0ac4827f78c7ffe8eef074bc010e7e34bc22f533 ]
Syzbot reported use-after-free Read in ath9k_hif_usb_rx_cb() [0]. The problem was in incorrect htc_handle->drv_priv initialization.
Probable call trace which can trigger use-after-free:
ath9k_htc_probe_device()
/* htc_handle->drv_priv = priv; */
ath9k_htc_wait_for_target() <--- Failed
ieee80211_free_hw() <--- priv pointer is freed
<IRQ>
...ath9k_hif_usb_rx_cb()
ath9k_hif_usb_rx_stream()
RX_STAT_INC() <--- htc_handle->drv_priv access
In order to not add fancy protection for drv_priv we can move htc_handle->drv_priv initialization at the end of the ath9k_htc_probe_device() and add helper macro to make
all *_STAT_* macros NULL safe, since syzbot has reported related NULL deref in that macros [1]
--- drivers/net/wireless/ath/ath9k/htc.h | 10 +++++----- drivers/net/wireless/ath/ath9k/htc_drv_init.c | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-)
drivers/net/wireless/ath/ath9k/htc.h +5 -5
@@ -327,11 +327,11 @@ static inline struct ath9k_htc_tx_ctl *HTC_SKB_CB(struct sk_buff *skb) }#ifdef CONFIG_ATH9K_HTC_DEBUGFS - -#define TX_STAT_INC (c) (hif_dev->htc_handle->drv_priv->debug.tx_stats.c++) -#define TX_STAT_ADD (c, a) (hif_dev->htc_handle->drv_priv->debug.tx_stats.c += a) -#define RX_STAT_INC (c) (hif_dev->htc_handle->drv_priv->debug.skbrx_stats.c++) -#define RX_STAT_ADD (c, a) (hif_dev->htc_handle->drv_priv->debug.skbrx_stats.c += a) +#define __STAT_SAFE (expr) (hif_dev->htc_handle->drv_priv ? (expr) : 0) +#define TX_STAT_INC (c) __STAT_SAFE(hif_dev->htc_handle->drv_priv->debug.tx_stats.c++) +#define TX_STAT_ADD (c, a) __STAT_SAFE(hif_dev->htc_handle->drv_priv->debug.tx_stats.c += a) +#define RX_STAT_INC (c) __STAT_SAFE(hif_dev->htc_handle->drv_priv->debug.skbrx_stats.c++) +#define RX_STAT_ADD (c, a) __STAT_SAFE(hif_dev->htc_handle->drv_priv->debug.skbrx_stats.c += a)#define CAB_STAT_INC priv->debug.tx_stats.cab_queued++#define TX_QSTAT_INC (q) (priv->debug.tx_stats.queue_stats[q]++)
drivers/net/wireless/ath/ath9k/htc_drv_init.c +2 -1
@@ -944,7 +944,6 @@ int ath9k_htc_probe_device(struct htc_target *htc_handle, struct device *dev, priv->hw = hw; priv->htc = htc_handle; priv->dev = dev; - htc_handle->drv_priv = priv;SET_IEEE80211_DEV (hw, priv->dev); ret =ath9k_htc_wait_for_target (priv);
@@ -965,6 +964,8 @@ int ath9k_htc_probe_device(struct htc_target *htc_handle, struct device *dev,if (ret) goto err_init; + htc_handle->drv_priv = priv; +return 0 ; err_init:
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 362/1095 wifi: iwlegacy: 4965: fix potential off-by-one overflow in il4965_rs_fill_link_cmd()
In reply to Greg Kroah-HartmanFrom: Alexey Kodanev <[email protected]>
[ Upstream commit a8eb8e6f7159c7c20c0ddac428bde3d110890aa7 ]
As a result of the execution of the inner while loop, the value of 'idx' can be equal to LINK_QUAL_MAX_RETRY_NUM. However, this is not checked after the loop and 'idx' is used to write the LINK_QUAL_MAX_RETRY_NUM size array 'lq_cmd->rs_table[idx]' below in the outer loop.
The fix is to check the new value of 'idx' inside the nested loop, and break both loops if index equals the size. Checking it at the start is now pointless, so let's remove it.
Detected using the static analysis tool - Svace.
--- drivers/net/wireless/intel/iwlegacy/4965-rs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/wireless/intel/iwlegacy/4965-rs.c +4 -1
@@ -2403,7 +2403,7 @@ il4965_rs_fill_link_cmd(struct il_priv *il, struct il_lq_sta *lq_sta,/* Repeat initial/next rate. * For legacy IL_NUMBER_TRY == 1, this loop will not execute. * For HT IL_HT_NUMBER_TRY == 3, this executes twice. */ -while (repeat_rate >0 && idx <LINK_QUAL_MAX_RETRY_NUM ) { +while (repeat_rate >0 ) {if (is_legacy (tbl_type.lq_type)) {if (ant_toggle_cnt <NUM_TRY_BEFORE_ANT_TOGGLE ) ant_toggle_cnt++;
@@ -2422,6 +2422,8 @@ il4965_rs_fill_link_cmd(struct il_priv *il, struct il_lq_sta *lq_sta,cpu_to_le32 (new_rate); repeat_rate--; idx++; +if (idx >=LINK_QUAL_MAX_RETRY_NUM ) + goto out; } il4965_rs_get_tbl_info_from_mcs(new_rate, lq_sta->band,
@@ -2466,6 +2468,7 @@ il4965_rs_fill_link_cmd(struct il_priv *il, struct il_lq_sta *lq_sta, repeat_rate--; } +out: lq_cmd->agg_params.agg_frame_cnt_limit =LINK_QUAL_AGG_FRAME_LIMIT_DEF ; lq_cmd->agg_params.agg_dis_start_th =LINK_QUAL_AGG_DISABLE_START_DEF ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 363/1095 wifi: rtw89: 8852a: rfk: fix div 0 exception
In reply to Greg Kroah-HartmanFrom: Ping-Ke Shih <[email protected]>
[ Upstream commit 683a4647a7a3044868cfdc14c117525091b9fa0c ]
The DPK is a kind of RF calibration whose algorithm is to fine tune parameters and calibrate, and check the result. If the result isn't good enough, it could adjust parameters and try again.
This issue is to read and show the result, but it could be a negative calibration result that causes divisor 0 and core dump. So, fix it by phy_div() that does division only if divisor isn't zero; otherwise, zero is adopted.
divide error: 0000 [#1] PREEMPT SMP NOPTI
CPU: 1 PID: 728 Comm: wpa_supplicant Not tainted 5.10.114-16019-g462a1661811a #1 <HASH:d024 28> RIP: 0010:rtw8852a_dpk+0x14ae/0x288f [rtw89_core] RSP: 0018:ffffa9bb412a7520 EFLAGS: 00010246 RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000 RDX: 0000000000000000 RSI: 00000000000180fc RDI: ffffa141d01023c0 RBP: ffffa9bb412a76a0 R08: 0000000000001319 R09: 00000000ffffff92 R10: ffffffffc0292de3 R11: ffffffffc00d2f51 R12: 0000000000000000 R13: ffffa141d01023c0 R14: ffffffffc0290250 R15: ffffa141d0102638 FS: 00007fa99f5c2740(0000) GS:ffffa142e5e80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000013e8e010 CR3: 0000000110d2c000 CR4: 0000000000750ee0 PKRU: 55555554 Call Trace: rtw89_core_sta_add+0x95/0x9c [rtw89_core <HASH:d239 29>] rtw89_ops_sta_state+0x5d/0x108 [rtw89_core <HASH:d239 29>] drv_sta_state+0x115/0x66f [mac80211 <HASH:81fe 30>] sta_info_insert_rcu+0x45c/0x713 [mac80211 <HASH:81fe 30>] sta_info_insert+0xf/0x1b [mac80211 <HASH:81fe 30>] ieee80211_prep_connection+0x9d6/0xb0c [mac80211 <HASH:81fe 30>] ieee80211_mgd_auth+0x2aa/0x352 [mac80211 <HASH:81fe 30>] cfg80211_mlme_auth+0x160/0x1f6 [cfg80211 <HASH:00cd 31>] nl80211_authenticate+0x2e5/0x306 [cfg80211 <HASH:00cd 31>] genl_rcv_msg+0x371/0x3a1 ? nl80211_stop_sched_scan+0xe5/0xe5 [cfg80211 <HASH:00cd 31>] ? genl_rcv+0x36/0x36 netlink_rcv_skb+0x8a/0xf9 genl_rcv+0x28/0x36 netlink_unicast+0x27b/0x3a0 netlink_sendmsg+0x2aa/0x469 sock_sendmsg_nosec+0x49/0x4d ____sys_sendmsg+0xe5/0x213 __sys_sendmsg+0xec/0x157 ? syscall_enter_from_user_mode+0xd7/0x116 do_syscall_64+0x43/0x55 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x7fa99f6e689b
--- drivers/net/wireless/realtek/rtw89/rtw8852a_rfk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/realtek/rtw89/rtw8852a_rfk.c +2 -2
@@ -2330,8 +2330,8 @@ static u8 _dpk_pas_read(struct rtw89_dev *rtwdev, bool is_check) val2_q =abs (sign_extend32 (val2_q,11 ));rtw89_debug (rtwdev,RTW89_DBG_RFK ,"[DPK] PAS_delta = 0x%x\n" , - (val1_i * val1_i + val1_q * val1_q) / - (val2_i * val2_i + val2_q * val2_q)); +phy_div (val1_i * val1_i + val1_q * val1_q, + val2_i * val2_i + val2_q * val2_q)); }else {for (i =0 ; i <32 ; i++) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 364/1095 drm/radeon: fix incorrrect SPDX-License-Identifiers
In reply to Greg Kroah-HartmanFrom: Alex Deucher <[email protected]>
[ Upstream commit 1f43b8903f3aae4a26a603c36f6d5dd25d6edb51 ]
radeon is MIT. This were incorrectly changed in
commit b24413180f56 ("License cleanup: add SPDX GPL-2.0 license identifier to files with no license") and
commit d198b34f3855 (".gitignore: add SPDX License Identifier")
and:
commit ec8f24b7faaf ("treewide: Add SPDX license identifier - Makefile/Kconfig")
--- drivers/gpu/drm/radeon/.gitignore | 2 +- drivers/gpu/drm/radeon/Kconfig | 2 +- drivers/gpu/drm/radeon/Makefile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/radeon/.gitignore +1 -1
@@ -1,4 +1,4 @@ -# SPDX-License-Identifier: GPL-2.0-only +# SPDX-License-Identifier: MIT mkregtable *_reg_safe.h
drivers/gpu/drm/radeon/Kconfig +1 -1
@@ -1,4 +1,4 @@ -# SPDX-License-Identifier: GPL-2.0-only +# SPDX-License-Identifier: MIT config DRM_RADEON_USERPTR bool "Always enable userptr support" depends on DRM_RADEON
drivers/gpu/drm/radeon/Makefile +1 -1
@@ -1,4 +1,4 @@ -# SPDX-License-Identifier: GPL-2.0 +# SPDX-License-Identifier: MIT # # Makefile for the drm device driver. This driver provides support for the # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 365/1095 rcutorture: Make kvm.sh allow more memory for --kasan runs
In reply to Greg Kroah-HartmanFrom: Paul E. McKenney <[email protected]>
[ Upstream commit 31015625768e6d8bc808a892b221b69afaaa8d07 ]
KASAN allots significant memory to track allocation state, and the amount of memory has increased recently, which results in frequent OOMs on a few of the rcutorture scenarios. This commit therefore provides 2G of memory for --kasan runs, up from the 512M default.
--- tools/testing/selftests/rcutorture/bin/kvm.sh | 6 ++++++ 1 file changed, 6 insertions(+)
tools/testing/selftests/rcutorture/bin/kvm.sh +6 -0
@@ -44,6 +44,7 @@ TORTURE_KCONFIG_KASAN_ARG="" TORTURE_KCONFIG_KCSAN_ARG="" TORTURE_KMAKE_ARG="" TORTURE_QEMU_MEM=512 +torture_qemu_mem_default=1 TORTURE_REMOTE= TORTURE_SHUTDOWN_GRACE=180 TORTURE_SUITE=rcu
@@ -180,6 +181,10 @@ do ;; --kasan) TORTURE_KCONFIG_KASAN_ARG="CONFIG_DEBUG_INFO=y CONFIG_KASAN=y"; export TORTURE_KCONFIG_KASAN_ARG + if test -n "$torture_qemu_mem_default" + then + TORTURE_QEMU_MEM=2G + fi ;; --kconfig|--kconfigs) checkarg --kconfig "(Kconfig options)" $# "$2" '^CONFIG_[A-Z0-9_]\+=\([ynm]\|[0-9]\+\)\( CONFIG_[A-Z0-9_]\+=\([ynm]\|[0-9]\+\)\)*$' '^error$'
@@ -202,6 +207,7 @@ do --memory) checkarg --memory "(memory size)" $# "$2" '^[0-9]\+[MG]\?$' error TORTURE_QEMU_MEM=$2 + torture_qemu_mem_default= shift ;; --no-initrd)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 366/1095 torture: Adjust to again produce debugging information
In reply to Greg Kroah-HartmanFrom: Paul E. McKenney <[email protected]>
[ Upstream commit 5c92d7501699a5deb72a579f808500db5bb6f92a ]
A recent change to the DEBUG_INFO Kconfig option means that simply adding CONFIG_DEBUG_INFO=y to the .config file and running "make oldconfig" no longer works. It is instead necessary to add CONFIG_DEBUG_INFO_NONE=n and (for example) CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y. This combination will then result in CONFIG_DEBUG_INFO being selected.
This commit therefore updates the Kconfig options produced in response to the kvm.sh --gdb, --kasan, and --kcsan Kconfig options.
--- tools/testing/selftests/rcutorture/bin/kvm.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/rcutorture/bin/kvm.sh +3 -3
@@ -164,7 +164,7 @@ do shift ;; --gdb) - TORTURE_KCONFIG_GDB_ARG="CONFIG_DEBUG_INFO=y"; export TORTURE_KCONFIG_GDB_ARG + TORTURE_KCONFIG_GDB_ARG="CONFIG_DEBUG_INFO_NONE=n CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y"; export TORTURE_KCONFIG_GDB_ARG TORTURE_BOOT_GDB_ARG="nokaslr"; export TORTURE_BOOT_GDB_ARG TORTURE_QEMU_GDB_ARG="-s -S"; export TORTURE_QEMU_GDB_ARG ;;
@@ -180,7 +180,7 @@ do shift ;; --kasan) - TORTURE_KCONFIG_KASAN_ARG="CONFIG_DEBUG_INFO=y CONFIG_KASAN=y"; export TORTURE_KCONFIG_KASAN_ARG + TORTURE_KCONFIG_KASAN_ARG="CONFIG_DEBUG_INFO_NONE=n CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y CONFIG_KASAN=y"; export TORTURE_KCONFIG_KASAN_ARG if test -n "$torture_qemu_mem_default" then TORTURE_QEMU_MEM=2G
@@ -192,7 +192,7 @@ do shift ;; --kcsan) - TORTURE_KCONFIG_KCSAN_ARG="CONFIG_DEBUG_INFO=y CONFIG_KCSAN=y CONFIG_KCSAN_STRICT=y CONFIG_KCSAN_REPORT_ONCE_IN_MS=100000 CONFIG_KCSAN_VERBOSE=y CONFIG_DEBUG_LOCK_ALLOC=y CONFIG_PROVE_LOCKING=y"; export TORTURE_KCONFIG_KCSAN_ARG + TORTURE_KCONFIG_KCSAN_ARG="CONFIG_DEBUG_INFO_NONE=n CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y CONFIG_KCSAN=y CONFIG_KCSAN_STRICT=y CONFIG_KCSAN_REPORT_ONCE_IN_MS=100000 CONFIG_KCSAN_VERBOSE=y CONFIG_DEBUG_LOCK_ALLOC=y CONFIG_PROVE_LOCKING=y"; export TORTURE_KCONFIG_KCSAN_ARG ;; --kmake-arg|--kmake-args) checkarg --kmake-arg "(kernel make arguments)" $# "$2" '.*' '^error$'
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 367/1095 rcutorture: Fix ksoftirqd boosting timing and iteration
In reply to Greg Kroah-HartmanFrom: Frederic Weisbecker <[email protected]>
[ Upstream commit 3002153a91a9732a6d1d0bb95138593c7da15743 ]
The RCU priority boosting can fail in two situations:
1) If (nr_cpus= > maxcpus=), which means if the total number of CPUs is higher than those brought online at boot, then torture_onoff() may later bring up CPUs that weren't online on boot. Now since rcutorture initialization only boosts the ksoftirqds of the CPUs that have been set online on boot, the CPUs later set online by torture_onoff won't benefit from the boost, making RCU priority boosting fail.
2) The ksoftirqd kthreads are boosted after the creation of rcu_torture_boost() kthreads, which opens a window large enough for these rcu_torture_boost() kthreads to wait (despite running at FIFO priority) for ksoftirqds that are still running at SCHED_NORMAL priority.
The issues can trigger for example with:
./kvm.sh --configs TREE01 --kconfig "CONFIG_RCU_BOOST=y" [ 34.968561] rcu-torture: !!! [ 34.968627] ------------[ cut here ]------------ [ 35.014054] WARNING: CPU: 4 PID: 114 at kernel/rcu/rcutorture.c:1979 rcu_torture_stats_print+0x5ad/0x610 [ 35.052043] Modules linked in: [ 35.069138] CPU: 4 PID: 114 Comm: rcu_torture_sta Not tainted 5.18.0-rc1 #1 [ 35.096424] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.14.0-0-g155821a-rebuilt.opensuse.org 04/01/2014 [ 35.154570] RIP: 0010:rcu_torture_stats_print+0x5ad/0x610 [ 35.198527] Code: 63 1b 02 00 74 02 0f 0b 48 83 3d 35 63 1b 02 00 74 02 0f 0b 48 83 3d 21 63 1b 02 00 74 02 0f 0b 48 83 3d 0d 63 1b 02 00 74 02 <0f> 0b 83 eb 01 0f 8e ba fc ff ff 0f 0b e9 b3 fc ff f82 [ 37.251049] RSP: 0000:ffffa92a0050bdf8 EFLAGS: 00010202 [ 37.277320] rcu: De-offloading 8 [ 37.290367] RAX: 0000000000000000 RBX: 0000000000000001 RCX: 0000000000000001 [ 37.290387] RDX: 0000000000000000 RSI: 00000000ffffbfff RDI: 00000000ffffffff [ 37.290398] RBP: 000000000000007b R08: 0000000000000000 R09: c0000000ffffbfff [ 37.290407] R10: 000000000000002a R11: ffffa92a0050bc18 R12: ffffa92a0050be20 [ 37.290417] R13: ffffa92a0050be78 R14: 0000000000000000 R15: 000000000001bea0 [ 37.290427] FS: 0000000000000000(0000) GS:ffff96045eb00000(0000) knlGS:0000000000000000 [ 37.290448] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 37.290460] CR2: 0000000000000000 CR3: 000000001dc0c000 CR4: 00000000000006e0 [ 37.290470] Call Trace: [ 37.295049] <TASK> [ 37.295065] ? preempt_count_add+0x63/0x90 [ 37.295095] ? _raw_spin_lock_irqsave+0x12/0x40 [ 37.295125] ? rcu_torture_stats_print+0x610/0x610 [ 37.295143] rcu_torture_stats+0x29/0x70 [ 37.295160] kthread+0xe3/0x110 [ 37.295176] ? kthread_complete_and_exit+0x20/0x20 [ 37.295193] ret_from_fork+0x22/0x30 [ 37.295218] </TASK>
Fix this with boosting the ksoftirqds kthreads from the boosting hotplug callback itself and before the boosting kthreads are created.
--- kernel/rcu/rcutorture.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-)
kernel/rcu/rcutorture.c +13 -15
@@ -2030,6 +2030,19 @@ static int rcutorture_booster_init(unsigned int cpu)if (boost_tasks[cpu] !=NULL )return 0 ;/* Already created, nothing more to do. */ +// Testing RCU priority boosting requires rcutorture do +// some serious abuse. Counter this by running ksoftirqd +// at higher priority. +if (IS_BUILTIN (CONFIG_RCU_TORTURE_TEST )) { +struct sched_param sp; +struct task_struct *t; + + t =per_cpu (ksoftirqd, cpu); +WARN_ON_ONCE (!t); + sp.sched_priority =2 ; +sched_setscheduler_nocheck (t,SCHED_FIFO , &sp); + } +/* Don't allow time recalculation while creating a new task. */ mutex_lock (&boost_mutex);rcu_torture_disable_rt_throttle ();
@@ -3281,21 +3294,6 @@ rcu_torture_init(void) rcutor_hp = firsterr;if (torture_init_error (firsterr)) goto unwind; - -// Testing RCU priority boosting requires rcutorture do -// some serious abuse. Counter this by running ksoftirqd -// at higher priority. -if (IS_BUILTIN (CONFIG_RCU_TORTURE_TEST )) { -for_each_online_cpu (cpu) { -struct sched_param sp; -struct task_struct *t; - - t =per_cpu (ksoftirqd, cpu); -WARN_ON_ONCE (!t); - sp.sched_priority =2 ; -sched_setscheduler_nocheck (t,SCHED_FIFO , &sp); - } - } } shutdown_jiffies = jiffies + shutdown_secs *HZ ; firsterr =torture_shutdown_init (shutdown_secs, rcu_torture_cleanup);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 368/1095 test_bpf: fix incorrect netdev features
In reply to Greg Kroah-HartmanFrom: Jian Shen <[email protected]>
[ Upstream commit 9676feccacdb0571791c88b23e3b7ac4e7c9c457 ]
The prototype of .features is netdev_features_t, it should use NETIF_F_LLTX and NETIF_F_HW_VLAN_STAG_TX, not NETIF_F_LLTX_BIT and NETIF_F_HW_VLAN_STAG_TX_BIT.
--- lib/test_bpf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/test_bpf.c +2 -2
@@ -14456,9 +14456,9 @@ static struct skb_segment_test skb_segment_tests[] __initconst = { .build_skb = build_test_skb_linear_no_head_frag, .features =NETIF_F_SG |NETIF_F_FRAGLIST |NETIF_F_HW_VLAN_CTAG_TX |NETIF_F_GSO | -NETIF_F_LLTX_BIT |NETIF_F_GRO | +NETIF_F_LLTX |NETIF_F_GRO |NETIF_F_IPV6_CSUM |NETIF_F_RXCSUM | -NETIF_F_HW_VLAN_STAG_TX_BIT +NETIF_F_HW_VLAN_STAG_TX } };
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 369/1095 selftests/bpf: Fix rare segfault in sock_fields prog test
In reply to Greg Kroah-HartmanFrom: Jörn-Thorben Hinz <[email protected]>
[ Upstream commit 6dc7a0baf1a70b7d22662d38481824c14ddd80c5 ]
test_sock_fields__detach() got called with a null pointer here when one of the CHECKs or ASSERTs up to the test_sock_fields__open_and_load() call resulted in a jump to the "done" label.
A skeletons *__detach() is not safe to call with a null pointer, though. This led to a segfault.
Go the easy route and only call test_sock_fields__destroy() which is null-pointer safe and includes detaching.
Came across this while looking[1] to introduce the usage of bpf_tcp_helpers.h (included in progs/test_sock_fields.c) together with vmlinux.h.
[1] https://lore.kernel.org/bpf/629bc069dd807d7ac646f836e9dca28bbc1108e2.camel@mailbox.tu-berlin.de/
--- tools/testing/selftests/bpf/prog_tests/sock_fields.c | 1 - 1 file changed, 1 deletion(-)
tools/testing/selftests/bpf/prog_tests/sock_fields.c +0 -1
@@ -394,7 +394,6 @@ void serial_test_sock_fields(void)test (); done: -test_sock_fields__detach (skel);test_sock_fields__destroy (skel);if (child_cg_fd >=0 )close (child_cg_fd);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 370/1095 crypto: ccp - During shutdown, check SEV data pointer before using
In reply to Greg Kroah-HartmanFrom: Tom Lendacky <[email protected]>
[ Upstream commit 1b05ece0c931536c0a38a9385e243a7962e933f6 ]
On shutdown, each CCP device instance performs shutdown processing. However, __sev_platform_shutdown_locked() uses the controlling psp structure to obtain the pointer to the sev_device structure. However, during driver initialization, it is possible that an error can be received from the firmware that results in the sev_data pointer being cleared from the controlling psp structure. The __sev_platform_shutdown_locked() function does not check for this situation and will segfault.
While not common, this scenario should be accounted for. Add a check for a NULL sev_device structure before attempting to use it.
--- drivers/crypto/ccp/sev-dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/ccp/sev-dev.c +1 -1
@@ -503,7 +503,7 @@ static int __sev_platform_shutdown_locked(int *error)struct sev_device *sev = psp_master->sev_data;int ret; -if (sev->state ==SEV_STATE_UNINIT ) +if (!sev || sev->state ==SEV_STATE_UNINIT )return 0 ; ret =__sev_do_cmd_locked (SEV_CMD_SHUTDOWN ,NULL , error);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 371/1095 drm: bridge: adv7511: Add check for mipi_dsi_driver_register
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit 831463667b5f4f1e5bce9c3b94e9e794d2bc8923 ]
As mipi_dsi_driver_register could return error if fails, it should be better to check the return value and return error if fails.
Moreover, if i2c_add_driver fails, mipi_dsi_driver_register should be reverted.
--- drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +14 -3
@@ -1384,10 +1384,21 @@ static struct i2c_driver adv7511_driver = {static int __init adv7511_init (void ) { -if (IS_ENABLED (CONFIG_DRM_MIPI_DSI )) -mipi_dsi_driver_register (&adv7533_dsi_driver); +int ret; + +if (IS_ENABLED (CONFIG_DRM_MIPI_DSI )) { + ret =mipi_dsi_driver_register (&adv7533_dsi_driver); +if (ret) +return ret; + } -return i2c_add_driver (&adv7511_driver); + ret =i2c_add_driver (&adv7511_driver); +if (ret) { +if (IS_ENABLED (CONFIG_DRM_MIPI_DSI )) +mipi_dsi_driver_unregister (&adv7533_dsi_driver); + } + +return ret; }module_init (adv7511_init);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 372/1095 media: imx-jpeg: Disable slot interrupt when frame done
In reply to Greg Kroah-HartmanFrom: Ming Qian <[email protected]>
[ Upstream commit 22a2bc88c139dc9757bdb1d0a3665ac27edc79a5 ]
The interrupt STMBUF_HALF may be triggered after frame done. It may led to system hang if driver try to access the register after power off.
Disable the slot interrupt when frame done.
--- drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c | 5 +++++ drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.h | 1 + drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c | 10 ++-------- 3 files changed, 8 insertions(+), 8 deletions(-)
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c +5 -0
@@ -79,6 +79,11 @@ void mxc_jpeg_enable_irq(void __iomem *reg, int slot)writel (0xFFFFFFFF , reg +MXC_SLOT_OFFSET (slot,SLOT_IRQ_EN )); } +void mxc_jpeg_disable_irq (void __iomem *reg,int slot) +{ +writel (0x0 , reg +MXC_SLOT_OFFSET (slot,SLOT_IRQ_EN )); +} +void mxc_jpeg_sw_reset (void __iomem *reg) {/*
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.h +1 -0
@@ -125,6 +125,7 @@ u32 mxc_jpeg_get_offset(void __iomem *reg, int slot);void mxc_jpeg_enable_slot (void __iomem *reg,int slot);void mxc_jpeg_set_l_endian (void __iomem *reg,int le);void mxc_jpeg_enable_irq (void __iomem *reg,int slot); +void mxc_jpeg_disable_irq (void __iomem *reg,int slot);int mxc_jpeg_set_input (void __iomem *reg,u32 in_buf,u32 bufsize);int mxc_jpeg_set_output (void __iomem *reg,u16 out_pitch,u32 out_buf,u16 w,u16 h);
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c +2 -8
@@ -593,15 +593,8 @@ static irqreturn_t mxc_jpeg_dec_irq(int irq, void *priv)dev_dbg (dev,"Irq %d on slot %d.\n" , irq, slot); ctx =v4l2_m2m_get_curr_priv (jpeg->m2m_dev); -if (!ctx) { -dev_err (dev, -"Instance released before the end of transaction.\n" ); -/* soft reset only resets internal state, not registers */ -mxc_jpeg_sw_reset (reg); -/* clear all interrupts */ -writel (0xFFFFFFFF , reg +MXC_SLOT_OFFSET (slot,SLOT_STATUS )); +if (WARN_ON (!ctx)) goto job_unlock; - }if (slot != ctx->slot) {/* TODO investigate when adding multi-instance support */
@@ -673,6 +666,7 @@ static irqreturn_t mxc_jpeg_dec_irq(int irq, void *priv) buf_state =VB2_BUF_STATE_DONE ; buffers_done: +mxc_jpeg_disable_irq (reg, ctx->slot); jpeg->slot_data[slot].used = false;/* unused, but don't free */ mxc_jpeg_check_and_set_last_buffer (ctx, src_buf, dst_buf);v4l2_m2m_src_buf_remove (ctx->fh.m2m_ctx);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 373/1095 media: amphion: output firmware error message
In reply to Greg Kroah-HartmanFrom: Ming Qian <[email protected]>
[ Upstream commit 89e3f3fb3d9014efa59ed6bb526d5f1a00168452 ]
Firmware may send the error event with some error message, and it help locate the firmware error,
so output the error message if it exists
--- drivers/media/platform/amphion/vpu_msgs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/media/platform/amphion/vpu_msgs.c +6 -1
@@ -150,7 +150,12 @@ static void vpu_session_handle_eos(struct vpu_inst *inst, struct vpu_rpc_event *static void vpu_session_handle_error (struct vpu_inst *inst,struct vpu_rpc_event *pkt) { -dev_err (inst->dev,"unsupported stream\n" ); +char *str = (char *)pkt->data; + +if (strlen (str)) +dev_err (inst->dev,"instance %d firmware error : %s\n" , inst->id, str); +else +dev_err (inst->dev,"instance %d is unsupported stream\n" , inst->id);call_void_vop (inst, event_notify,VPU_MSG_ID_UNSUPPORTED ,NULL );vpu_v4l2_set_error (inst); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 374/1095 drm/mcde: Fix refcount leak in mcde_dsi_bind
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit 3a149169e4a2f9127022fec6ef5d71b4e804b3b9 ]
Every iteration of for_each_available_child_of_node() decrements the reference counter of the previous node. There is no decrement when break out from the loop and results in refcount leak. Add missing of_node_put() to fix this.
--- drivers/gpu/drm/mcde/mcde_dsi.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/mcde/mcde_dsi.c +1 -0
@@ -1111,6 +1111,7 @@ static int mcde_dsi_bind(struct device *dev, struct device *master, bridge =of_drm_find_bridge (child);if (!bridge) {dev_err (dev,"failed to find bridge\n" ); +of_node_put (child);return -EINVAL ; } }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 375/1095 media: hdpvr: fix error value returns in hdpvr_read
In reply to Greg Kroah-HartmanFrom: Niels Dossche <[email protected]>
[ Upstream commit 359c27c6ddbde404f44a9c0d3ec88ccd1e2042f2 ]
Error return values are supposed to be negative in hdpvr_read. Most error returns are currently handled via an unsigned integer "ret". When setting a negative error value to "ret", the value actually becomes a large positive value, because "ret" is unsigned. Later on, the "ret" value is returned. But as ssize_t is a 64-bit signed number, the error return value stays a large positive integer instead of a negative integer. This can cause an error value to be interpreted as the read size, which can cause a buffer overread for applications relying on the returned size.
--- drivers/media/usb/hdpvr/hdpvr-video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/usb/hdpvr/hdpvr-video.c +1 -1
@@ -409,7 +409,7 @@ static ssize_t hdpvr_read(struct file *file, char __user *buffer, size_t count,struct hdpvr_device *dev =video_drvdata (file);struct hdpvr_buffer *buf =NULL ;struct urb *urb; -unsigned int ret =0 ; +int ret =0 ;int rem, cnt;if (*pos)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 376/1095 media: v4l2-mem2mem: prevent pollerr when last_buffer_dequeued is set
In reply to Greg Kroah-HartmanFrom: Ming Qian <[email protected]>
[ Upstream commit d4de27a9b1eadd33a2e40de87a646d1bf5fef756 ]
If the last buffer was dequeued from the capture queue, signal userspace. DQBUF(CAPTURE) will return -EPIPE.
But if output queue is empty and capture queue is empty, v4l2_m2m_poll_for_data will return EPOLLERR, This is very easy to happen in drain.
When last_buffer_dequeued is set, we shouldn't return EPOLLERR, but return EPOLLIN | EPOLLRDNORM.
--- drivers/media/v4l2-core/v4l2-mem2mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/v4l2-core/v4l2-mem2mem.c +1 -1
@@ -924,7 +924,7 @@ static __poll_t v4l2_m2m_poll_for_data(struct file *file,if ((!src_q->streaming || src_q->error ||list_empty (&src_q->queued_list)) && (!dst_q->streaming || dst_q->error || -list_empty (&dst_q->queued_list))) + (list_empty (&dst_q->queued_list) && !dst_q->last_buffer_dequeued)))return EPOLLERR ;spin_lock_irqsave (&src_q->done_lock, flags);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 377/1095 media: sta2x11: remove VIRT_TO_BUS dependency
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit a157802359f7451ed8046b2b6dbaca187797e062 ]
This driver does not use the virt_to_bus() function, though it depends on x86 specific fixups in the swiotlb code, which was last rewritten in commit e380a0394c36 ("x86/PCI: sta2x11: use default DMA address translation").
It is possible that the driver still fails to build on some architectures that are missing CONFIG_VIRT_TO_BUS, but it is always set on x86 machines with the STA2X11 platform enabled.
More likely though is that it was never meant to depend on CONFIG_VIRT_TO_BUS, and the Kconfig dependency was kept from an out-of-tree version when the driver was originally merged.
--- drivers/media/pci/sta2x11/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/pci/sta2x11/Kconfig +1 -1
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config STA2X11_VIP tristate "STA2X11 VIP Video For Linux" - depends on PCI && VIDEO_DEV && VIRT_TO_BUS && I2C + depends on PCI && VIDEO_DEV && I2C depends on STA2X11 || COMPILE_TEST select GPIOLIB if MEDIA_SUBDRV_AUTOSELECT select VIDEO_ADV7180 if MEDIA_SUBDRV_AUTOSELECT
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 378/1095 media: mediatek: vcodec: Initialize decoder parameters after getting dec_capability
In reply to Greg Kroah-HartmanFrom: Yunfei Dong <[email protected]>
[ Upstream commit faddaa735c208560a3f419038e8d154a01b584e3 ]
Need to get dec_capability from scp first, then initialize decoder supported format and other parameters according to dec_capability value.
--- drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c | 2 -- drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c +0 -2
@@ -112,8 +112,6 @@ void mtk_vcodec_dec_set_default_params(struct mtk_vcodec_ctx *ctx) {struct mtk_q_data *q_data; - ctx->dev->vdec_pdata->init_vdec_params (ctx); - ctx->m2m_ctx->q_lock = &ctx->dev->dev_mutex; ctx->fh.m2m_ctx = ctx->m2m_ctx; ctx->fh.ctrl_handler = &ctx->ctrl_hdl;
drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c +2 -0
@@ -211,6 +211,8 @@ static int fops_vcodec_open(struct file *file) dev->dec_capability =mtk_vcodec_fw_get_vdec_capa (dev->fw_handler); + ctx->dev->vdec_pdata->init_vdec_params (ctx); +mtk_v4l2_debug (0 ,"decoder capability %x" , dev->dec_capability); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 379/1095 media: mediatek: vcodec: Skip SOURCE_CHANGE & EOS events for stateless
In reply to Greg Kroah-HartmanFrom: Chen-Yu Tsai <[email protected]>
[ Upstream commit e13ca460e20ed42fe57a3845b0bb9a82f81f05cd ]
The stateless decoder API does not specify the usage of SOURCE_CHANGE and EOF events. These events are used by stateful decoders to signal changes in the bitstream. They do not make sense for stateless decoders.
Do not handle subscription for these two types of events for stateless decoder instances. This fixes the last v4l2-compliance error:
Control ioctls:
fail: v4l2-test-controls.cpp(946): have_source_change || have_eos test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: FAIL
--- drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c +5 -0
@@ -194,6 +194,11 @@ static int vidioc_vdec_querycap(struct file *file, void *priv,static int vidioc_vdec_subscribe_evt (struct v4l2_fh *fh,const struct v4l2_event_subscription *sub) { +struct mtk_vcodec_ctx *ctx =fh_to_ctx (fh); + +if (ctx->dev->vdec_pdata->uses_stateless_api) +return v4l2_ctrl_subscribe_event (fh, sub); +switch (sub->type) {case V4L2_EVENT_EOS :return v4l2_event_subscribe (fh, sub,2 ,NULL );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 380/1095 media: driver/nxp/imx-jpeg: fix a unexpected return value problem
In reply to Greg Kroah-HartmanFrom: Jian Zhang <[email protected]>
[ Upstream commit 5b304046a81eda221b5d06a9c62f7b5e45530fa5 ]
In function mxc_jpeg_probe(), when devm_clk_get() fail, the return value will be unexpected, and it should be the devm_clk_get's error code.
--- drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c +2 -0
@@ -2121,12 +2121,14 @@ static int mxc_jpeg_probe(struct platform_device *pdev) jpeg->clk_ipg =devm_clk_get (dev,"ipg" );if (IS_ERR (jpeg->clk_ipg)) {dev_err (dev,"failed to get clock: ipg\n" ); + ret =PTR_ERR (jpeg->clk_ipg); goto err_clk; } jpeg->clk_per =devm_clk_get (dev,"per" );if (IS_ERR (jpeg->clk_per)) {dev_err (dev,"failed to get clock: per\n" ); + ret =PTR_ERR (jpeg->clk_per); goto err_clk; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 381/1095 media: tw686x: Fix memory leak in tw686x_video_init
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit e0b212ec9d8177d6f7c404315293f6a085d6ee42 ]
video_device_alloc() allocates memory for vdev,
when video_register_device() fails, it doesn't release the memory and leads to memory leak, call video_device_release() to fix this.
--- drivers/media/pci/tw686x/tw686x-video.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/pci/tw686x/tw686x-video.c +3 -1
@@ -1282,8 +1282,10 @@ int tw686x_video_init(struct tw686x_dev *dev)video_set_drvdata (vdev, vc); err =video_register_device (vdev,VFL_TYPE_VIDEO ,-1 ); -if (err <0 ) +if (err <0 ) { +video_device_release (vdev); goto error; + } vc->num = vdev->num; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 382/1095 media: mediatek: vcodec: Fix non subdev architecture open power fail
In reply to Greg Kroah-HartmanFrom: Yunfei Dong <[email protected]>
[ Upstream commit 083f54a7c9c66496b9d9f3c50dfdca24e6aa7012 ]
According to subdev_bitmap bit value to open hardware power, need to set subdev_bitmap value for non subdev architecture.
--- drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c +2 -0
@@ -393,6 +393,8 @@ static int mtk_vcodec_probe(struct platform_device *pdev)mtk_v4l2_err ("Main device of_platform_populate failed." ); goto err_reg_cont; } + }else { +set_bit (MTK_VDEC_CORE , dev->subdev_bitmap); } ret =video_register_device (vfd_dec,VFL_TYPE_VIDEO ,-1 );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 383/1095 drm/vc4: kms: Use maximum FIFO load for the HVS clock rate
In reply to Greg Kroah-HartmanFrom: Maxime Ripard <[email protected]>
[ Upstream commit 1701a23a4ef0993964ccc2f2d5d13f83a5ff4c70 ]
The core clock computation takes into account both the load due to the input (ie, planes) and its output (ie, encoders).
However, while the input load needs to consider all the planes, and thus sum all of their associated loads, the output happens mostly in parallel.
Therefore, we need to consider only the maximum of all the output loads, and not the sum like we were doing. This resulted in a clock rate way too high which could be discarded for being too high by the clock framework.
Since recent changes, the clock framework will even downright reject it, leading to a core clock being too low for its current needs.
--- drivers/gpu/drm/vc4/vc4_kms.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_kms.c +3 -1
@@ -890,7 +890,9 @@ vc4_core_clock_atomic_check(struct drm_atomic_state *state)continue ; num_outputs++; - cob_rate += hvs_new_state->fifo_state[i].fifo_load; + cob_rate = max_t(unsigned long, + hvs_new_state->fifo_state[i].fifo_load, + cob_rate); } pixel_rate = load_state->hvs_load;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 384/1095 drm/vc4: plane: Remove subpixel positioning check
In reply to Greg Kroah-HartmanFrom: Dom Cobley <[email protected]>
[ Upstream commit 517db1ab1566dba3093dbdb8de4263ba4aa66416 ]
There is little harm in ignoring fractional coordinates (they just get truncated).
Without this:
modetest -M vc4 -F tiles,gradient -s 32:1920x1080-60 -P89@74:1920x1080*.1.1@XR24
is rejected. We have the same issue in Kodi when trying to use zoom options on video.
Note: even if all coordinates are fully integer. e.g. src:[0,0,1920,1080] dest:[-10,-10,1940,1100]
it will still get rejected as drm_atomic_helper_check_plane_state uses drm_rect_clip_scaled which transforms this to fractional src coords
--- drivers/gpu/drm/vc4/vc4_plane.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)
drivers/gpu/drm/vc4/vc4_plane.c +9 -13
@@ -339,7 +339,6 @@ static int vc4_plane_setup_clipping_and_scaling(struct drm_plane_state *state)struct vc4_plane_state *vc4_state =to_vc4_plane_state (state);struct drm_framebuffer *fb = state->fb;struct drm_gem_cma_object *bo =drm_fb_cma_get_gem_obj (fb,0 ); -u32 subpixel_src_mask = (1 <<16 ) -1 ;int num_planes = fb->format->num_planes;struct drm_crtc_state *crtc_state;u32 h_subsample = fb->format->hsub;
@@ -361,18 +360,15 @@ static int vc4_plane_setup_clipping_and_scaling(struct drm_plane_state *state)for (i =0 ; i < num_planes; i++) vc4_state->offsets[i] = bo->paddr + fb->offsets[i]; -/* We don't support subpixel source positioning for scaling. */ -if ((state->src.x1 & subpixel_src_mask) || - (state->src.x2 & subpixel_src_mask) || - (state->src.y1 & subpixel_src_mask) || - (state->src.y2 & subpixel_src_mask)) { -return -EINVAL ; - } - - vc4_state->src_x = state->src.x1 >>16 ; - vc4_state->src_y = state->src.y1 >>16 ; - vc4_state->src_w[0 ] = (state->src.x2 - state->src.x1) >>16 ; - vc4_state->src_h[0 ] = (state->src.y2 - state->src.y1) >>16 ; +/* +* We don't support subpixel source positioning for scaling, +* but fractional coordinates can be generated by clipping +* so just round for now +*/ + vc4_state->src_x =DIV_ROUND_CLOSEST (state->src.x1,1 <<16 ); + vc4_state->src_y =DIV_ROUND_CLOSEST (state->src.y1,1 <<16 ); + vc4_state->src_w[0 ] =DIV_ROUND_CLOSEST (state->src.x2,1 <<16 ) - vc4_state->src_x; + vc4_state->src_h[0 ] =DIV_ROUND_CLOSEST (state->src.y2,1 <<16 ) - vc4_state->src_y; vc4_state->crtc_x = state->dst.x1; vc4_state->crtc_y = state->dst.y1;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 385/1095 drm/vc4: plane: Fix margin calculations for the right/bottom edges
In reply to Greg Kroah-HartmanFrom: Dave Stevenson <[email protected]>
[ Upstream commit b7c3d6821627861f4ea3e1f2b595d0ed9e80aac8 ]
The current plane margin calculation code clips the right and bottom edges of the range based using the left and top margins.
This is obviously wrong, so let's fix it.
--- drivers/gpu/drm/vc4/vc4_plane.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/vc4/vc4_plane.c +4 -4
@@ -310,16 +310,16 @@ static int vc4_plane_margins_adj(struct drm_plane_state *pstate) adjhdisplay, crtc_state->mode.hdisplay); vc4_pstate->crtc_x += left; -if (vc4_pstate->crtc_x > crtc_state->mode.hdisplay - left) - vc4_pstate->crtc_x = crtc_state->mode.hdisplay - left; +if (vc4_pstate->crtc_x > crtc_state->mode.hdisplay - right) + vc4_pstate->crtc_x = crtc_state->mode.hdisplay - right; adjvdisplay = crtc_state->mode.vdisplay - (top + bottom); vc4_pstate->crtc_y =DIV_ROUND_CLOSEST (vc4_pstate->crtc_y * adjvdisplay, crtc_state->mode.vdisplay); vc4_pstate->crtc_y += top; -if (vc4_pstate->crtc_y > crtc_state->mode.vdisplay - top) - vc4_pstate->crtc_y = crtc_state->mode.vdisplay - top; +if (vc4_pstate->crtc_y > crtc_state->mode.vdisplay - bottom) + vc4_pstate->crtc_y = crtc_state->mode.vdisplay - bottom; vc4_pstate->crtc_w = DIV_ROUND_CLOSEST(vc4_pstate->crtc_w * adjhdisplay,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 386/1095 drm/vc4: dsi: Release workaround buffer and DMA
In reply to Greg Kroah-HartmanFrom: Dave Stevenson <[email protected]>
[ Upstream commit 89c4bbe2a01ea401c2b0fabc104720809084b77f ]
On Pi0-3 the driver allocates a buffer and requests a DMA channel because the ARM can't write to DSI1's registers directly.
However, we never release that buffer or channel. Let's add a device-managed action to release each.
--- drivers/gpu/drm/vc4/vc4_dsi.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_dsi.c +28 -1
@@ -1487,13 +1487,29 @@ vc4_dsi_init_phy_clocks(struct vc4_dsi *dsi) dsi->clk_onecell); } +static void vc4_dsi_dma_mem_release (void *ptr) +{ +struct vc4_dsi *dsi = ptr; +struct device *dev = &dsi->pdev->dev; + +dma_free_coherent (dev,4 , dsi->reg_dma_mem, dsi->reg_dma_paddr); + dsi->reg_dma_mem =NULL ; +} + +static void vc4_dsi_dma_chan_release (void *ptr) +{ +struct vc4_dsi *dsi = ptr; + +dma_release_channel (dsi->reg_dma_chan); + dsi->reg_dma_chan =NULL ; +} +static int vc4_dsi_bind (struct device *dev,struct device *master,void *data) {struct platform_device *pdev =to_platform_device (dev);struct drm_device *drm =dev_get_drvdata (master);struct vc4_dsi *dsi =dev_get_drvdata (dev);struct vc4_dsi_encoder *vc4_dsi_encoder; -dma_cap_mask_t dma_mask;int ret; dsi->variant =of_device_get_match_data (dev);
@@ -1527,6 +1543,8 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data)* so set up a channel for talking to it. */ if (dsi->variant->broken_axi_workaround) { +dma_cap_mask_t dma_mask; + dsi->reg_dma_mem =dma_alloc_coherent (dev,4 , &dsi->reg_dma_paddr,GFP_KERNEL );
@@ -1535,8 +1553,13 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data)return -ENOMEM ; } + ret =devm_add_action_or_reset (dev, vc4_dsi_dma_mem_release, dsi); +if (ret) +return ret; +dma_cap_zero (dma_mask);dma_cap_set (DMA_MEMCPY , dma_mask); + dsi->reg_dma_chan =dma_request_chan_by_mask (&dma_mask);if (IS_ERR (dsi->reg_dma_chan)) { ret =PTR_ERR (dsi->reg_dma_chan);
@@ -1546,6 +1569,10 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data)return ret; } + ret =devm_add_action_or_reset (dev, vc4_dsi_dma_chan_release, dsi); +if (ret) +return ret; +/* Get the physical address of the device's registers. The * struct resource for the regs gives us the bus address * instead.
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 387/1095 drm/vc4: dsi: Correct DSI divider calculations
In reply to Greg Kroah-HartmanFrom: Dave Stevenson <[email protected]>
[ Upstream commit 3b45eee87da171caa28f61240ddb5c21170cda53 ]
The divider calculations tried to find the divider just faster than the clock requested. However if it required a divider of 7 then the for loop aborted without handling the "error" case, and could end up with a clock lower than requested.
The integer divider from parent PLL to DSI clock is also capable of going up to /255, not just /7 that the driver was trying. This allows for slower link frequencies on the DSI bus where the resolution permits.
Correct the loop so that we always have a clock greater than requested, and covering the whole range of dividers.
--- drivers/gpu/drm/vc4/vc4_dsi.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/vc4/vc4_dsi.c +2 -4
@@ -805,11 +805,9 @@ static bool vc4_dsi_encoder_mode_fixup(struct drm_encoder *encoder,/* Find what divider gets us a faster clock than the requested * pixel clock. */ -for (divider =1 ; divider <8 ; divider++) { -if (parent_rate / divider < pll_clock) { - divider--; +for (divider =1 ; divider <255 ; divider++) { +if (parent_rate / (divider +1 ) < pll_clock)break ; - } }/* Now that we've picked a PLL divider, calculate back to its
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 388/1095 drm/vc4: dsi: Correct pixel order for DSI0
In reply to Greg Kroah-HartmanFrom: Dave Stevenson <[email protected]>
[ Upstream commit edfe84ae0df16be1251b5a8e840d95f1f3827500 ]
For slightly unknown reasons, dsi0 takes a different pixel format to dsi1, and that has to be set in the pixel valve.
Amend the setup accordingly.
--- drivers/gpu/drm/vc4/vc4_crtc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_crtc.c +2 -1
@@ -317,7 +317,8 @@ static void vc4_crtc_config_pv(struct drm_crtc *crtc, struct drm_encoder *encodeu32 pixel_rep = (mode->flags &DRM_MODE_FLAG_DBLCLK ) ?2 :1 ;bool is_dsi = (vc4_encoder->type ==VC4_ENCODER_TYPE_DSI0 || vc4_encoder->type ==VC4_ENCODER_TYPE_DSI1 ); -u32 format = is_dsi ?PV_CONTROL_FORMAT_DSIV_24 :PV_CONTROL_FORMAT_24 ; +bool is_dsi1 = vc4_encoder->type ==VC4_ENCODER_TYPE_DSI1 ; +u32 format = is_dsi1 ?PV_CONTROL_FORMAT_DSIV_24 :PV_CONTROL_FORMAT_24 ;u8 ppc = pv_data->pixels_per_clock;bool debug_dump_regs = false;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 389/1095 drm/vc4: dsi: Register dsi0 as the correct vc4 encoder type
In reply to Greg Kroah-HartmanFrom: Dave Stevenson <[email protected]>
[ Upstream commit 4d9273c978d4c1af15d7874c10c732ec83d444d0 ]
vc4_dsi was registering both dsi0 and dsi1 as VC4_ENCODER_TYPE_DSI1 which seemed to work OK for a single DSI display, but fails if there are two DSI displays connected.
Update to register the correct type.
--- drivers/gpu/drm/vc4/vc4_dsi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_dsi.c +2 -1
@@ -1518,7 +1518,8 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data)return -ENOMEM ;INIT_LIST_HEAD (&dsi->bridge_chain); - vc4_dsi_encoder->base.type =VC4_ENCODER_TYPE_DSI1 ; + vc4_dsi_encoder->base.type = dsi->variant->port ? +VC4_ENCODER_TYPE_DSI1 :VC4_ENCODER_TYPE_DSI0 ; vc4_dsi_encoder->dsi = dsi; dsi->encoder = &vc4_dsi_encoder->base.base;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 390/1095 drm/vc4: dsi: Fix dsi0 interrupt support
In reply to Greg Kroah-HartmanFrom: Dave Stevenson <[email protected]>
[ Upstream commit bc5b815e06f90cccdb6461aba1e49fdc2f3c8cd1 ]
DSI0 seemingly had very little or no testing as a load of the register mappings were incorrect/missing, so host transfers always timed out due to enabling/checking incorrect bits in the interrupt enable and status registers.
--- drivers/gpu/drm/vc4/vc4_dsi.c | 111 ++++++++++++++++++++++++++-------- 1 file changed, 85 insertions(+), 26 deletions(-)
drivers/gpu/drm/vc4/vc4_dsi.c +85 -26
@@ -181,8 +181,50 @@#define DSI0_TXPKT_PIX_FIFO 0x20/* AKA PIX_FIFO */ -#define DSI0_INT_STAT 0x24 -#define DSI0_INT_EN 0x28 +#define DSI0_INT_STAT 0x24 +#define DSI0_INT_EN 0x28 +# define DSI0_INT_FIFO_ERR BIT(25) +# define DSI0_INT_CMDC_DONE_MASK VC4_MASK(24, 23) +# define DSI0_INT_CMDC_DONE_SHIFT 23 +# define DSI0_INT_CMDC_DONE_NO_REPEAT 1 +# define DSI0_INT_CMDC_DONE_REPEAT 3 +# define DSI0_INT_PHY_DIR_RTF BIT(22) +# define DSI0_INT_PHY_D1_ULPS BIT(21) +# define DSI0_INT_PHY_D1_STOP BIT(20) +# define DSI0_INT_PHY_RXLPDT BIT(19) +# define DSI0_INT_PHY_RXTRIG BIT(18) +# define DSI0_INT_PHY_D0_ULPS BIT(17) +# define DSI0_INT_PHY_D0_LPDT BIT(16) +# define DSI0_INT_PHY_D0_FTR BIT(15) +# define DSI0_INT_PHY_D0_STOP BIT(14) +/* Signaled when the clock lane enters the given state. */ +# define DSI0_INT_PHY_CLK_ULPS BIT(13) +# define DSI0_INT_PHY_CLK_HS BIT(12) +# define DSI0_INT_PHY_CLK_FTR BIT(11) +/* Signaled on timeouts */ +# define DSI0_INT_PR_TO BIT(10) +# define DSI0_INT_TA_TO BIT(9) +# define DSI0_INT_LPRX_TO BIT(8) +# define DSI0_INT_HSTX_TO BIT(7) +/* Contention on a line when trying to drive the line low */ +# define DSI0_INT_ERR_CONT_LP1 BIT(6) +# define DSI0_INT_ERR_CONT_LP0 BIT(5) +/* Control error: incorrect line state sequence on data lane 0. */ +# define DSI0_INT_ERR_CONTROL BIT(4) +# define DSI0_INT_ERR_SYNC_ESC BIT(3) +# define DSI0_INT_RX2_PKT BIT(2) +# define DSI0_INT_RX1_PKT BIT(1) +# define DSI0_INT_CMD_PKT BIT(0) + +#define DSI0_INTERRUPTS_ALWAYS_ENABLED (DSI0_INT_ERR_SYNC_ESC | \ + DSI0_INT_ERR_CONTROL | \ + DSI0_INT_ERR_CONT_LP0 | \ + DSI0_INT_ERR_CONT_LP1 | \ + DSI0_INT_HSTX_TO | \ + DSI0_INT_LPRX_TO | \ + DSI0_INT_TA_TO | \ + DSI0_INT_PR_TO) +# define DSI1_INT_PHY_D3_ULPS BIT(30)# define DSI1_INT_PHY_D3_STOP BIT(29)# define DSI1_INT_PHY_D2_ULPS BIT(28)
@@ -892,6 +934,9 @@ static void vc4_dsi_encoder_enable(struct drm_encoder *encoder)DSI_PORT_WRITE (PHY_AFEC0 , afec0); +/* AFEC reset hold time */ +mdelay (1 ); + DSI_PORT_WRITE(PHY_AFEC1, VC4_SET_FIELD(6, DSI0_PHY_AFEC1_IDR_DLANE1) | VC4_SET_FIELD(6, DSI0_PHY_AFEC1_IDR_DLANE0) |
@@ -1058,12 +1103,9 @@ static void vc4_dsi_encoder_enable(struct drm_encoder *encoder)DSI_PORT_WRITE (CTRL ,DSI_PORT_READ (CTRL ) |DSI1_CTRL_EN );/* Bring AFE out of reset. */ -if (dsi->variant->port ==0 ) { - }else { -DSI_PORT_WRITE (PHY_AFEC0 , -DSI_PORT_READ (PHY_AFEC0 ) & - ~DSI1_PHY_AFEC0_RESET ); - } +DSI_PORT_WRITE (PHY_AFEC0 , +DSI_PORT_READ (PHY_AFEC0 ) & + ~DSI_PORT_BIT (PHY_AFEC0_RESET ));vc4_dsi_ulps (dsi, false);
@@ -1182,13 +1224,28 @@ static ssize_t vc4_dsi_host_transfer(struct mipi_dsi_host *host,/* Enable the appropriate interrupt for the transfer completion. */ dsi->xfer_result =0 ;reinit_completion (&dsi->xfer_completion); -DSI_PORT_WRITE (INT_STAT ,DSI1_INT_TXPKT1_DONE |DSI1_INT_PHY_DIR_RTF ); -if (msg->rx_len) { -DSI_PORT_WRITE (INT_EN , (DSI1_INTERRUPTS_ALWAYS_ENABLED | -DSI1_INT_PHY_DIR_RTF )); +if (dsi->variant->port ==0 ) { +DSI_PORT_WRITE (INT_STAT , +DSI0_INT_CMDC_DONE_MASK |DSI1_INT_PHY_DIR_RTF ); +if (msg->rx_len) { +DSI_PORT_WRITE (INT_EN , (DSI0_INTERRUPTS_ALWAYS_ENABLED | +DSI0_INT_PHY_DIR_RTF )); + }else { +DSI_PORT_WRITE (INT_EN , + (DSI0_INTERRUPTS_ALWAYS_ENABLED | +VC4_SET_FIELD (DSI0_INT_CMDC_DONE_NO_REPEAT , +DSI0_INT_CMDC_DONE ))); + } }else { -DSI_PORT_WRITE (INT_EN , (DSI1_INTERRUPTS_ALWAYS_ENABLED | -DSI1_INT_TXPKT1_DONE )); +DSI_PORT_WRITE (INT_STAT , +DSI1_INT_TXPKT1_DONE |DSI1_INT_PHY_DIR_RTF ); +if (msg->rx_len) { +DSI_PORT_WRITE (INT_EN , (DSI1_INTERRUPTS_ALWAYS_ENABLED | +DSI1_INT_PHY_DIR_RTF )); + }else { +DSI_PORT_WRITE (INT_EN , (DSI1_INTERRUPTS_ALWAYS_ENABLED | +DSI1_INT_TXPKT1_DONE )); + } }/* Send the packet. */
@@ -1205,7 +1262,7 @@ static ssize_t vc4_dsi_host_transfer(struct mipi_dsi_host *host, ret = dsi->xfer_result; } -DSI_PORT_WRITE (INT_EN ,DSI1_INTERRUPTS_ALWAYS_ENABLED ); +DSI_PORT_WRITE (INT_EN ,DSI_PORT_BIT (INTERRUPTS_ALWAYS_ENABLED ));if (ret) goto reset_fifo_and_return;
@@ -1251,7 +1308,7 @@ static ssize_t vc4_dsi_host_transfer(struct mipi_dsi_host *host, DSI_PORT_BIT(CTRL_RESET_FIFOS));DSI_PORT_WRITE (TXPKT1C ,0 ); -DSI_PORT_WRITE (INT_EN ,DSI1_INTERRUPTS_ALWAYS_ENABLED ); +DSI_PORT_WRITE (INT_EN ,DSI_PORT_BIT (INTERRUPTS_ALWAYS_ENABLED ));return ret; }
@@ -1388,26 +1445,28 @@ static irqreturn_t vc4_dsi_irq_handler(int irq, void *data)DSI_PORT_WRITE (INT_STAT , stat);dsi_handle_error (dsi, &ret, stat, -DSI1_INT_ERR_SYNC_ESC ,"LPDT sync" ); +DSI_PORT_BIT (INT_ERR_SYNC_ESC ),"LPDT sync" );dsi_handle_error (dsi, &ret, stat, -DSI1_INT_ERR_CONTROL ,"data lane 0 sequence" ); +DSI_PORT_BIT (INT_ERR_CONTROL ),"data lane 0 sequence" );dsi_handle_error (dsi, &ret, stat, -DSI1_INT_ERR_CONT_LP0 ,"LP0 contention" ); +DSI_PORT_BIT (INT_ERR_CONT_LP0 ),"LP0 contention" );dsi_handle_error (dsi, &ret, stat, -DSI1_INT_ERR_CONT_LP1 ,"LP1 contention" ); +DSI_PORT_BIT (INT_ERR_CONT_LP1 ),"LP1 contention" );dsi_handle_error (dsi, &ret, stat, -DSI1_INT_HSTX_TO ,"HSTX timeout" ); +DSI_PORT_BIT (INT_HSTX_TO ),"HSTX timeout" );dsi_handle_error (dsi, &ret, stat, -DSI1_INT_LPRX_TO ,"LPRX timeout" ); +DSI_PORT_BIT (INT_LPRX_TO ),"LPRX timeout" );dsi_handle_error (dsi, &ret, stat, -DSI1_INT_TA_TO ,"turnaround timeout" ); +DSI_PORT_BIT (INT_TA_TO ),"turnaround timeout" );dsi_handle_error (dsi, &ret, stat, -DSI1_INT_PR_TO ,"peripheral reset timeout" ); +DSI_PORT_BIT (INT_PR_TO ),"peripheral reset timeout" ); -if (stat & (DSI1_INT_TXPKT1_DONE |DSI1_INT_PHY_DIR_RTF )) { +if (stat & ((dsi->variant->port ?DSI1_INT_TXPKT1_DONE : +DSI0_INT_CMDC_DONE_MASK ) | +DSI_PORT_BIT (INT_PHY_DIR_RTF ))) {complete (&dsi->xfer_completion); ret =IRQ_HANDLED ; - }else if (stat &DSI1_INT_HSTX_TO ) { + }else if (stat &DSI_PORT_BIT (INT_HSTX_TO )) {complete (&dsi->xfer_completion); dsi->xfer_result = -ETIMEDOUT ; ret =IRQ_HANDLED ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 391/1095 drm/vc4: dsi: Add correct stop condition to vc4_dsi_encoder_disable iteration
In reply to Greg Kroah-HartmanFrom: Dave Stevenson <[email protected]>
[ Upstream commit 7bcb9c8d0bc9f3cab8ac2634b056c2e6b63945ca ]
vc4_dsi_encoder_disable is partially an open coded version of drm_bridge_chain_disable, but it missed a termination condition in the loop for ->disable which meant that no post_disable calls were made.
Add in the termination clause.
--- drivers/gpu/drm/vc4/vc4_dsi.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/vc4/vc4_dsi.c +3 -0
@@ -803,6 +803,9 @@ static void vc4_dsi_encoder_disable(struct drm_encoder *encoder)list_for_each_entry_reverse (iter, &dsi->bridge_chain, chain_node) {if (iter->funcs->disable) iter->funcs->disable (iter); + +if (iter == dsi->bridge) +break ; }vc4_dsi_ulps (dsi, true);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 392/1095 drm/vc4: hdmi: Add all the vc5 HDMI registers into the debugfs dumps
In reply to Greg Kroah-HartmanFrom: Dave Stevenson <[email protected]>
[ Upstream commit 25eb441d55d479581a65bcc9de88bc1d86bf76c1 ]
The vc5 HDMI registers hadn't been added into the debugfs register sets, therefore weren't dumped on request. Add them in.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 39 ++++++++++++++++++++++++++++++++++ drivers/gpu/drm/vc4/vc4_hdmi.h | 8 +++++++ 2 files changed, 47 insertions(+)
drivers/gpu/drm/vc4/vc4_hdmi.c +39 -0
@@ -122,6 +122,12 @@ static int vc4_hdmi_debugfs_regs(struct seq_file *m, void *unused)drm_print_regset32 (&p, &vc4_hdmi->hdmi_regset);drm_print_regset32 (&p, &vc4_hdmi->hd_regset); +drm_print_regset32 (&p, &vc4_hdmi->cec_regset); +drm_print_regset32 (&p, &vc4_hdmi->csc_regset); +drm_print_regset32 (&p, &vc4_hdmi->dvp_regset); +drm_print_regset32 (&p, &vc4_hdmi->phy_regset); +drm_print_regset32 (&p, &vc4_hdmi->ram_regset); +drm_print_regset32 (&p, &vc4_hdmi->rm_regset);return 0 ; }
@@ -2374,6 +2380,7 @@ static int vc5_hdmi_init_resources(struct vc4_hdmi *vc4_hdmi)struct platform_device *pdev = vc4_hdmi->pdev;struct device *dev = &pdev->dev;struct resource *res; +int ret; res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"hdmi" );if (!res)
@@ -2470,6 +2477,38 @@ static int vc5_hdmi_init_resources(struct vc4_hdmi *vc4_hdmi)return PTR_ERR (vc4_hdmi->reset); } + ret =vc4_hdmi_build_regset (vc4_hdmi, &vc4_hdmi->hdmi_regset,VC4_HDMI ); +if (ret) +return ret; + + ret =vc4_hdmi_build_regset (vc4_hdmi, &vc4_hdmi->hd_regset,VC4_HD ); +if (ret) +return ret; + + ret =vc4_hdmi_build_regset (vc4_hdmi, &vc4_hdmi->cec_regset,VC5_CEC ); +if (ret) +return ret; + + ret =vc4_hdmi_build_regset (vc4_hdmi, &vc4_hdmi->csc_regset,VC5_CSC ); +if (ret) +return ret; + + ret =vc4_hdmi_build_regset (vc4_hdmi, &vc4_hdmi->dvp_regset,VC5_DVP ); +if (ret) +return ret; + + ret =vc4_hdmi_build_regset (vc4_hdmi, &vc4_hdmi->phy_regset,VC5_PHY ); +if (ret) +return ret; + + ret =vc4_hdmi_build_regset (vc4_hdmi, &vc4_hdmi->ram_regset,VC5_RAM ); +if (ret) +return ret; + + ret =vc4_hdmi_build_regset (vc4_hdmi, &vc4_hdmi->rm_regset,VC5_RM ); +if (ret) +return ret; +return 0 ; }
drivers/gpu/drm/vc4/vc4_hdmi.h +8 -0
@@ -184,6 +184,14 @@ struct vc4_hdmi {struct debugfs_regset32 hdmi_regset;struct debugfs_regset32 hd_regset; +/* VC5 only */ +struct debugfs_regset32 cec_regset; +struct debugfs_regset32 csc_regset; +struct debugfs_regset32 dvp_regset; +struct debugfs_regset32 phy_regset; +struct debugfs_regset32 ram_regset; +struct debugfs_regset32 rm_regset; +/** * @hw_lock: Spinlock protecting device register access. */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 393/1095 drm/vc4: hdmi: Clear unused infoframe packet RAM registers
In reply to Greg Kroah-HartmanFrom: Dom Cobley <[email protected]>
[ Upstream commit b6079d1578dc4b4b8050d613a5449a63def7d1dd ]
Using a hdmi analyser the bytes in packet ram registers beyond the length were visible in the infoframes and it flagged the checksum as invalid.
Zeroing unused words of packet RAM avoids this
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +10 -1
@@ -439,9 +439,11 @@ static void vc4_hdmi_write_infoframe(struct drm_encoder *encoder,const struct vc4_hdmi_register *ram_packet_start = &vc4_hdmi->variant->registers[HDMI_RAM_PACKET_START ];u32 packet_reg = ram_packet_start->offset +VC4_HDMI_PACKET_STRIDE * packet_id; +u32 packet_reg_next = ram_packet_start->offset + +VC4_HDMI_PACKET_STRIDE * (packet_id +1 );void __iomem *base =__vc4_hdmi_get_field_base (vc4_hdmi, ram_packet_start->reg); -uint8_t buffer[VC4_HDMI_PACKET_STRIDE ]; +uint8_t buffer[VC4_HDMI_PACKET_STRIDE ] = {};unsigned long flags;ssize_t len, i;int ret;
@@ -477,6 +479,13 @@ static void vc4_hdmi_write_infoframe(struct drm_encoder *encoder, packet_reg +=4 ; } +/* +* clear remainder of packet ram as it's included in the +* infoframe and triggers a checksum error on hdmi analyser +*/ +for (; packet_reg < packet_reg_next; packet_reg +=4 ) +writel (0 , base + packet_reg); +HDMI_WRITE (HDMI_RAM_PACKET_CONFIG ,HDMI_READ (HDMI_RAM_PACKET_CONFIG ) |BIT (packet_id));
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 394/1095 drm/vc4: hdmi: Avoid full hdmi audio fifo writes
In reply to Greg Kroah-HartmanFrom: Dom Cobley <[email protected]>
[ Upstream commit 1c594eeccf92368177c2e22f1d3ee4933dfb8567 ]
We are getting occasional VC4_HD_MAI_CTL_ERRORF in HDMI_MAI_CTL which seem to correspond with audio dropouts.
Reduce the threshold where we deassert DREQ to avoid the fifo overfilling
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +4 -4
@@ -1626,10 +1626,10 @@ static int vc4_hdmi_audio_prepare(struct device *dev, void *data,/* Set the MAI threshold */ HDMI_WRITE (HDMI_MAI_THR , -VC4_SET_FIELD (0x10 ,VC4_HD_MAI_THR_PANICHIGH ) | -VC4_SET_FIELD (0x10 ,VC4_HD_MAI_THR_PANICLOW ) | -VC4_SET_FIELD (0x10 ,VC4_HD_MAI_THR_DREQHIGH ) | -VC4_SET_FIELD (0x10 ,VC4_HD_MAI_THR_DREQLOW )); +VC4_SET_FIELD (0x08 ,VC4_HD_MAI_THR_PANICHIGH ) | +VC4_SET_FIELD (0x08 ,VC4_HD_MAI_THR_PANICLOW ) | +VC4_SET_FIELD (0x06 ,VC4_HD_MAI_THR_DREQHIGH ) | +VC4_SET_FIELD (0x08 ,VC4_HD_MAI_THR_DREQLOW )); HDMI_WRITE(HDMI_MAI_CONFIG, VC4_HDMI_MAI_CONFIG_BIT_REVERSE |
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 395/1095 drm/vc4: hdmi: Reset HDMI MISC_CONTROL register
In reply to Greg Kroah-HartmanFrom: Dave Stevenson <[email protected]>
[ Upstream commit 35dc00c12a72700a9c4592afee7d136ecb280cbd ]
The HDMI block can repeat pixels for double clocked modes, and the firmware is now configuring the block to do this as the PV is doing it incorrectly when at 2pixels/clock. If the kernel doesn't reset it then we end up with strange modes.
Reset MISC_CONTROL.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 8 ++++++++ drivers/gpu/drm/vc4/vc4_hdmi_regs.h | 3 +++ 2 files changed, 11 insertions(+)
drivers/gpu/drm/vc4/vc4_hdmi.c +8 -0
@@ -79,6 +79,9 @@#define VC5_HDMI_VERTB_VSPO_SHIFT 16#define VC5_HDMI_VERTB_VSPO_MASK VC4_MASK(29, 16) +#define VC5_HDMI_MISC_CONTROL_PIXEL_REP_SHIFT 0 +#define VC5_HDMI_MISC_CONTROL_PIXEL_REP_MASK VC4_MASK(3, 0) +#define VC5_HDMI_SCRAMBLER_CTL_ENABLE BIT(0)#define VC5_HDMI_DEEP_COLOR_CONFIG_1_INIT_PACK_PHASE_SHIFT 8
@@ -988,6 +991,11 @@ static void vc5_hdmi_set_timings(struct vc4_hdmi *vc4_hdmi, reg |= gcp_en ?VC5_HDMI_GCP_CONFIG_GCP_ENABLE :0 ;HDMI_WRITE (HDMI_GCP_CONFIG , reg); + reg =HDMI_READ (HDMI_MISC_CONTROL ); + reg &= ~VC5_HDMI_MISC_CONTROL_PIXEL_REP_MASK ; + reg |=VC4_SET_FIELD (0 ,VC5_HDMI_MISC_CONTROL_PIXEL_REP ); +HDMI_WRITE (HDMI_MISC_CONTROL , reg); +HDMI_WRITE (HDMI_CLOCK_STOP ,0 );spin_unlock_irqrestore (&vc4_hdmi->hw_lock, flags);
drivers/gpu/drm/vc4/vc4_hdmi_regs.h +3 -0
@@ -125,6 +125,7 @@ enum vc4_hdmi_field {HDMI_VERTB0 ,HDMI_VERTB1 ,HDMI_VID_CTL , + HDMI_MISC_CONTROL, }; struct vc4_hdmi_register {
@@ -235,6 +236,7 @@ static const struct vc4_hdmi_register __maybe_unused vc5_hdmi_hdmi0_fields[] = {VC4_HDMI_REG (HDMI_VERTB0 ,0x0f0 ),VC4_HDMI_REG (HDMI_VERTA1 ,0x0f4 ),VC4_HDMI_REG (HDMI_VERTB1 ,0x0f8 ), +VC4_HDMI_REG (HDMI_MISC_CONTROL ,0x100 ),VC4_HDMI_REG (HDMI_MAI_CHANNEL_MAP ,0x09c ),VC4_HDMI_REG (HDMI_MAI_CONFIG ,0x0a0 ), VC4_HDMI_REG(HDMI_DEEP_COLOR_CONFIG_1, 0x170),
@@ -315,6 +317,7 @@ static const struct vc4_hdmi_register __maybe_unused vc5_hdmi_hdmi1_fields[] = {VC4_HDMI_REG (HDMI_VERTB0 ,0x0f0 ),VC4_HDMI_REG (HDMI_VERTA1 ,0x0f4 ),VC4_HDMI_REG (HDMI_VERTB1 ,0x0f8 ), +VC4_HDMI_REG (HDMI_MISC_CONTROL ,0x100 ),VC4_HDMI_REG (HDMI_MAI_CHANNEL_MAP ,0x09c ),VC4_HDMI_REG (HDMI_MAI_CONFIG ,0x0a0 ), VC4_HDMI_REG(HDMI_DEEP_COLOR_CONFIG_1, 0x170),
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 396/1095 drm/vc4: hdmi: Switch to pm_runtime_status_suspended
In reply to Greg Kroah-HartmanFrom: Dave Stevenson <[email protected]>
[ Upstream commit fcef97e70094a33ded73b3eb9bef06698c6e9c12 ]
If the controller isn't clocked or its domain powered up, the register accesses will either stall the CPU or return garbage, respectively.
Thus, we had a warning in our register access function to complain when that kind of risky accesses were performed.
In order to check the runtime_pm power state, we were using pm_runtime_active(), but it turns out that it will become active only once the runtime_resume hook has been executed.
This prevents us from doing any WARN-free register access in our runtime_resume() implementation, while this is valid.
Let's switch to pm_runtime_status_suspended() instead.
--- drivers/gpu/drm/vc4/vc4_hdmi_regs.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/vc4/vc4_hdmi_regs.h +2 -2
@@ -417,7 +417,7 @@ static inline u32 vc4_hdmi_read(struct vc4_hdmi *hdmi,const struct vc4_hdmi_variant *variant = hdmi->variant;void __iomem *base; -WARN_ON (!pm_runtime_active (&hdmi->pdev->dev)); +WARN_ON (pm_runtime_status_suspended (&hdmi->pdev->dev));if (reg >= variant->num_registers) { dev_warn(&hdmi->pdev->dev,
@@ -447,7 +447,7 @@ static inline void vc4_hdmi_write(struct vc4_hdmi *hdmi,lockdep_assert_held (&hdmi->hw_lock); -WARN_ON (!pm_runtime_active (&hdmi->pdev->dev)); +WARN_ON (pm_runtime_status_suspended (&hdmi->pdev->dev));if (reg >= variant->num_registers) { dev_warn(&hdmi->pdev->dev,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 397/1095 drm/vc4: hdmi: Move HDMI reset to pm_resume
In reply to Greg Kroah-HartmanFrom: Dave Stevenson <[email protected]>
[ Upstream commit 467e30171b5b483922b1c24c573fa50787207cb6 ]
The BCM2835-37 found in the RaspberryPi 0 to 3 have a power domain attached to the HDMI block, handled in Linux through runtime_pm.
That power domain is shared with the VEC block, so even if we put our runtime_pm reference in the HDMI driver it would keep being on. If the VEC is disabled though, the power domain would be disabled and we would lose any initialization done in our bind implementation.
That initialization involves calling the reset function and initializing the CEC registers.
Let's move the initialization to our runtime_resume implementation so that we initialize everything properly if we ever need to.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 41 ++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 19 deletions(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +22 -19
@@ -2214,8 +2214,6 @@ static int vc4_hdmi_cec_init(struct vc4_hdmi *vc4_hdmi)struct cec_connector_info conn_info;struct platform_device *pdev = vc4_hdmi->pdev;struct device *dev = &pdev->dev; -unsigned long flags; -u32 value;int ret;if (!of_find_property (dev->of_node,"interrupts" ,NULL )) {
@@ -2234,15 +2232,6 @@ static int vc4_hdmi_cec_init(struct vc4_hdmi *vc4_hdmi)cec_fill_conn_info_from_drm (&conn_info, &vc4_hdmi->connector);cec_s_conn_info (vc4_hdmi->cec_adap, &conn_info); -spin_lock_irqsave (&vc4_hdmi->hw_lock, flags); - value =HDMI_READ (HDMI_CEC_CNTRL_1 ); -/* Set the logical address to Unregistered */ - value |=VC4_HDMI_CEC_ADDR_MASK ; -HDMI_WRITE (HDMI_CEC_CNTRL_1 , value); -spin_unlock_irqrestore (&vc4_hdmi->hw_lock, flags); - -vc4_hdmi_cec_update_clk_div (vc4_hdmi); -if (vc4_hdmi->variant->external_irq_controller) { ret = request_threaded_irq(platform_get_irq_byname(pdev, "cec-rx"), vc4_cec_irq_handler_rx_bare,
@@ -2258,10 +2247,6 @@ static int vc4_hdmi_cec_init(struct vc4_hdmi *vc4_hdmi)if (ret) goto err_remove_cec_rx_handler; }else { -spin_lock_irqsave (&vc4_hdmi->hw_lock, flags); -HDMI_WRITE (HDMI_CEC_CPU_MASK_SET ,0xffffffff ); -spin_unlock_irqrestore (&vc4_hdmi->hw_lock, flags); - ret = request_threaded_irq(platform_get_irq(pdev, 0), vc4_cec_irq_handler, vc4_cec_irq_handler_thread, 0,
@@ -2312,7 +2297,6 @@ static int vc4_hdmi_cec_init(struct vc4_hdmi *vc4_hdmi) }static void vc4_hdmi_cec_exit (struct vc4_hdmi *vc4_hdmi) {}; -#endif static int vc4_hdmi_build_regset(struct vc4_hdmi *vc4_hdmi,
@@ -2541,12 +2525,34 @@ static int __maybe_unused vc4_hdmi_runtime_suspend(struct device *dev)static int vc4_hdmi_runtime_resume (struct device *dev) {struct vc4_hdmi *vc4_hdmi =dev_get_drvdata (dev); +unsigned long __maybe_unused flags; +u32 __maybe_unused value;int ret; ret =clk_prepare_enable (vc4_hdmi->hsm_clock);if (ret)return ret; +if (vc4_hdmi->variant->reset) + vc4_hdmi->variant->reset (vc4_hdmi); + +#ifdef CONFIG_DRM_VC4_HDMI_CEC +spin_lock_irqsave (&vc4_hdmi->hw_lock, flags); + value =HDMI_READ (HDMI_CEC_CNTRL_1 ); +/* Set the logical address to Unregistered */ + value |=VC4_HDMI_CEC_ADDR_MASK ; +HDMI_WRITE (HDMI_CEC_CNTRL_1 , value); +spin_unlock_irqrestore (&vc4_hdmi->hw_lock, flags); + +vc4_hdmi_cec_update_clk_div (vc4_hdmi); + +if (!vc4_hdmi->variant->external_irq_controller) { +spin_lock_irqsave (&vc4_hdmi->hw_lock, flags); +HDMI_WRITE (HDMI_CEC_CPU_MASK_SET ,0xffffffff ); +spin_unlock_irqrestore (&vc4_hdmi->hw_lock, flags); + } +#endif +return 0 ; }
@@ -2649,9 +2655,6 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)pm_runtime_set_active (dev);pm_runtime_enable (dev); -if (vc4_hdmi->variant->reset) - vc4_hdmi->variant->reset (vc4_hdmi); -if ((of_device_is_compatible (dev->of_node,"brcm,bcm2711-hdmi0" ) ||of_device_is_compatible (dev->of_node,"brcm,bcm2711-hdmi1" )) &&HDMI_READ (HDMI_VID_CTL ) &VC4_HD_VID_CTL_ENABLE ) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 398/1095 drm/vc4: hdmi: Fix timings for interlaced modes
In reply to Greg Kroah-HartmanFrom: Mateusz Kwiatkowski <[email protected]>
[ Upstream commit 0ee5a40152b15f200ed3a0d51e8aa782ea979c6a ]
Increase the number of post-sync blanking lines on odd fields instead of decreasing it on even fields. This makes the total number of lines properly match the modelines.
Additionally fix the value of PV_VCONTROL_ODD_DELAY, which did not take pixels_per_clock into account, causing some displays to invert the fields when driven by bcm2711.
--- drivers/gpu/drm/vc4/vc4_crtc.c | 7 ++++--- drivers/gpu/drm/vc4/vc4_hdmi.c | 12 ++++++------ 2 files changed, 10 insertions(+), 9 deletions(-)
drivers/gpu/drm/vc4/vc4_crtc.c +4 -3
@@ -344,7 +344,8 @@ static void vc4_crtc_config_pv(struct drm_crtc *crtc, struct drm_encoder *encode PV_HORZB_HACTIVE));CRTC_WRITE (PV_VERTA , -VC4_SET_FIELD (mode->crtc_vtotal - mode->crtc_vsync_end, +VC4_SET_FIELD (mode->crtc_vtotal - mode->crtc_vsync_end + + interlace,PV_VERTA_VBP ) |VC4_SET_FIELD (mode->crtc_vsync_end - mode->crtc_vsync_start,PV_VERTA_VSYNC ));
@@ -356,7 +357,7 @@ static void vc4_crtc_config_pv(struct drm_crtc *crtc, struct drm_encoder *encode if (interlace) { CRTC_WRITE(PV_VERTA_EVEN, VC4_SET_FIELD(mode->crtc_vtotal - - mode->crtc_vsync_end - 1, + mode->crtc_vsync_end, PV_VERTA_VBP) | VC4_SET_FIELD(mode->crtc_vsync_end - mode->crtc_vsync_start,
@@ -376,7 +377,7 @@ static void vc4_crtc_config_pv(struct drm_crtc *crtc, struct drm_encoder *encodePV_VCONTROL_CONTINUOUS | (is_dsi ?PV_VCONTROL_DSI :0 ) |PV_VCONTROL_INTERLACE | -VC4_SET_FIELD (mode->htotal * pixel_rep /2 , +VC4_SET_FIELD (mode->htotal * pixel_rep / (2 * ppc), PV_VCONTROL_ODD_DELAY));CRTC_WRITE (PV_VSYNCD_EVEN ,0 ); }else {
drivers/gpu/drm/vc4/vc4_hdmi.c +6 -6
@@ -870,12 +870,12 @@ static void vc4_hdmi_set_timings(struct vc4_hdmi *vc4_hdmi, VC4_HDMI_VERTA_VFP) | VC4_SET_FIELD(mode->crtc_vdisplay, VC4_HDMI_VERTA_VAL));u32 vertb = (VC4_SET_FIELD (0 ,VC4_HDMI_VERTB_VSPO ) | -VC4_SET_FIELD (mode->crtc_vtotal - mode->crtc_vsync_end, +VC4_SET_FIELD (mode->crtc_vtotal - mode->crtc_vsync_end + + interlaced,VC4_HDMI_VERTB_VBP ));u32 vertb_even = (VC4_SET_FIELD (0 ,VC4_HDMI_VERTB_VSPO ) |VC4_SET_FIELD (mode->crtc_vtotal - - mode->crtc_vsync_end - - interlaced, + mode->crtc_vsync_end,VC4_HDMI_VERTB_VBP ));unsigned long flags;
@@ -921,12 +921,12 @@ static void vc5_hdmi_set_timings(struct vc4_hdmi *vc4_hdmi, VC5_HDMI_VERTA_VFP) | VC4_SET_FIELD(mode->crtc_vdisplay, VC5_HDMI_VERTA_VAL));u32 vertb = (VC4_SET_FIELD (0 ,VC5_HDMI_VERTB_VSPO ) | -VC4_SET_FIELD (mode->crtc_vtotal - mode->crtc_vsync_end, +VC4_SET_FIELD (mode->crtc_vtotal - mode->crtc_vsync_end + + interlaced,VC4_HDMI_VERTB_VBP ));u32 vertb_even = (VC4_SET_FIELD (0 ,VC5_HDMI_VERTB_VSPO ) |VC4_SET_FIELD (mode->crtc_vtotal - - mode->crtc_vsync_end - - interlaced, + mode->crtc_vsync_end,VC4_HDMI_VERTB_VBP ));unsigned long flags;unsigned char gcp;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 399/1095 drm/vc4: hdmi: Correct HDMI timing registers for interlaced modes
In reply to Greg Kroah-HartmanFrom: Dave Stevenson <[email protected]>
[ Upstream commit fb10dc451c0f15e3c19798a2f41d357f3f7576f5 ]
For interlaced modes the timings were not being correctly programmed into the HDMI block, so correct them.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +4 -4
@@ -920,13 +920,13 @@ static void vc5_hdmi_set_timings(struct vc4_hdmi *vc4_hdmi,VC4_SET_FIELD (mode->crtc_vsync_start - mode->crtc_vdisplay,VC5_HDMI_VERTA_VFP ) | VC4_SET_FIELD(mode->crtc_vdisplay, VC5_HDMI_VERTA_VAL)); -u32 vertb = (VC4_SET_FIELD (0 ,VC5_HDMI_VERTB_VSPO ) | -VC4_SET_FIELD (mode->crtc_vtotal - mode->crtc_vsync_end + - interlaced, +u32 vertb = (VC4_SET_FIELD (mode->htotal >> (2 - pixel_rep), +VC5_HDMI_VERTB_VSPO ) | +VC4_SET_FIELD (mode->crtc_vtotal - mode->crtc_vsync_end,VC4_HDMI_VERTB_VBP ));u32 vertb_even = (VC4_SET_FIELD (0 ,VC5_HDMI_VERTB_VSPO ) |VC4_SET_FIELD (mode->crtc_vtotal - - mode->crtc_vsync_end, + mode->crtc_vsync_end - interlaced,VC4_HDMI_VERTB_VBP ));unsigned long flags;unsigned char gcp;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 400/1095 drm/vc4: hdmi: Move pixel doubling from Pixelvalve to HDMI block
In reply to Greg Kroah-HartmanFrom: Dave Stevenson <[email protected]>
[ Upstream commit 3650062e4281ab28a6f8c9d59606d0a6266be736 ]
With the change to 2 pixels/clock, the pixel doubling in the PV results in doubling each pair of pixels, ie ABABCDCD instead of AABBCCDD.
Move the pixel doubling to the HDMI block, however this means that DBLCLK modes now fall foul of requiring even values for all the horizontal timing parameters.
As both 480i and 576i fail this, attempt to fix up DBLCLK modes that have odd timings values.
--- drivers/gpu/drm/vc4/vc4_crtc.c | 4 +++- drivers/gpu/drm/vc4/vc4_hdmi.c | 34 ++++++++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 7 deletions(-)
drivers/gpu/drm/vc4/vc4_crtc.c +3 -1
@@ -314,7 +314,9 @@ static void vc4_crtc_config_pv(struct drm_crtc *crtc, struct drm_encoder *encodestruct drm_crtc_state *crtc_state = crtc->state;struct drm_display_mode *mode = &crtc_state->adjusted_mode;bool interlace = mode->flags &DRM_MODE_FLAG_INTERLACE ; -u32 pixel_rep = (mode->flags &DRM_MODE_FLAG_DBLCLK ) ?2 :1 ; +bool is_hdmi = vc4_encoder->type ==VC4_ENCODER_TYPE_HDMI0 || + vc4_encoder->type ==VC4_ENCODER_TYPE_HDMI1 ; +u32 pixel_rep = ((mode->flags &DRM_MODE_FLAG_DBLCLK ) && !is_hdmi) ?2 :1 ;bool is_dsi = (vc4_encoder->type ==VC4_ENCODER_TYPE_DSI0 || vc4_encoder->type ==VC4_ENCODER_TYPE_DSI1 );bool is_dsi1 = vc4_encoder->type ==VC4_ENCODER_TYPE_DSI1 ;
drivers/gpu/drm/vc4/vc4_hdmi.c +28 -6
@@ -79,6 +79,8 @@#define VC5_HDMI_VERTB_VSPO_SHIFT 16#define VC5_HDMI_VERTB_VSPO_MASK VC4_MASK(29, 16) +#define VC4_HDMI_MISC_CONTROL_PIXEL_REP_SHIFT 0 +#define VC4_HDMI_MISC_CONTROL_PIXEL_REP_MASK VC4_MASK(3, 0)#define VC5_HDMI_MISC_CONTROL_PIXEL_REP_SHIFT 0#define VC5_HDMI_MISC_CONTROL_PIXEL_REP_MASK VC4_MASK(3, 0)
@@ -878,6 +880,7 @@ static void vc4_hdmi_set_timings(struct vc4_hdmi *vc4_hdmi, mode->crtc_vsync_end, VC4_HDMI_VERTB_VBP));unsigned long flags; +u32 reg;spin_lock_irqsave (&vc4_hdmi->hw_lock, flags);
@@ -904,6 +907,11 @@ static void vc4_hdmi_set_timings(struct vc4_hdmi *vc4_hdmi,HDMI_WRITE (HDMI_VERTB0 , vertb_even);HDMI_WRITE (HDMI_VERTB1 , vertb); + reg =HDMI_READ (HDMI_MISC_CONTROL ); + reg &= ~VC4_HDMI_MISC_CONTROL_PIXEL_REP_MASK ; + reg |=VC4_SET_FIELD (pixel_rep -1 ,VC4_HDMI_MISC_CONTROL_PIXEL_REP ); +HDMI_WRITE (HDMI_MISC_CONTROL , reg); +spin_unlock_irqrestore (&vc4_hdmi->hw_lock, flags); }
@@ -993,7 +1001,7 @@ static void vc5_hdmi_set_timings(struct vc4_hdmi *vc4_hdmi, reg =HDMI_READ (HDMI_MISC_CONTROL ); reg &= ~VC5_HDMI_MISC_CONTROL_PIXEL_REP_MASK ; - reg |=VC4_SET_FIELD (0 ,VC5_HDMI_MISC_CONTROL_PIXEL_REP ); + reg |=VC4_SET_FIELD (pixel_rep -1 ,VC5_HDMI_MISC_CONTROL_PIXEL_REP );HDMI_WRITE (HDMI_MISC_CONTROL , reg);HDMI_WRITE (HDMI_CLOCK_STOP ,0 );
@@ -1276,11 +1284,25 @@ static int vc4_hdmi_encoder_atomic_check(struct drm_encoder *encoder,unsigned long long pixel_rate = mode->clock *1000 ;unsigned long long tmds_rate; -if (vc4_hdmi->variant->unsupported_odd_h_timings && - !(mode->flags &DRM_MODE_FLAG_DBLCLK ) && - ((mode->hdisplay %2 ) || (mode->hsync_start %2 ) || - (mode->hsync_end %2 ) || (mode->htotal %2 ))) -return -EINVAL ; +if (vc4_hdmi->variant->unsupported_odd_h_timings) { +if (mode->flags &DRM_MODE_FLAG_DBLCLK ) { +/* Only try to fixup DBLCLK modes to get 480i and 576i +* working. +* A generic solution for all modes with odd horizontal +* timing values seems impossible based on trying to +* solve it for 1366x768 monitors. +*/ +if ((mode->hsync_start - mode->hdisplay) &1 ) + mode->hsync_start--; +if ((mode->hsync_end - mode->hsync_start) &1 ) + mode->hsync_end--; + } + +/* Now check whether we still have odd values remaining */ +if ((mode->hdisplay %2 ) || (mode->hsync_start %2 ) || + (mode->hsync_end %2 ) || (mode->htotal %2 )) +return -EINVAL ; + }/* * The 1440p@60 pixel rate is in the same range than the first
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 401/1095 mm: Account dirty folios properly during splits
In reply to Greg Kroah-HartmanFrom: Matthew Wilcox (Oracle) <[email protected]>
[ Upstream commit fb5c2029f8221e904e604938171c4a8ef169aadb ]
If the last folio in a file is split as a result of truncation, we simply clear the dirty bits for the pages we're discarding. That causes NR_FILE_DIRTY (among other counters) to be thrown off and eventually Linux will hang in balance_dirty_pages_ratelimited()
--- mm/huge_memory.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
mm/huge_memory.c +8 -3
@@ -18,6 +18,7 @@#include <linux/shrinker.h> #include <linux/mm_inline.h> #include <linux/swapops.h> +#include <linux/backing-dev.h> #include <linux/dax.h> #include <linux/khugepaged.h> #include <linux/freezer.h>
@@ -2389,11 +2390,15 @@ static void __split_huge_page(struct page *page, struct list_head *list,__split_huge_page_tail (head, i, lruvec, list);/* Some pages can be beyond EOF: drop them from page cache */ if (head[i].index >= end) { -ClearPageDirty (head + i); -__delete_from_page_cache (head + i,NULL ); +struct folio *tail =page_folio (head + i); +if (shmem_mapping (head->mapping))shmem_uncharge (head->mapping->host,1 ); -put_page (head + i); +else if (folio_test_clear_dirty (tail)) +folio_account_cleaned (tail, +inode_to_wb (folio->mapping->host)); +__filemap_remove_folio (tail,NULL ); +folio_put (tail); }else if (!PageAnon (page)) {__xa_store (&head->mapping->i_pages, head[i].index, head + i,0 );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 402/1095 crypto: arm64/gcm - Select AEAD for GHASH_ARM64_CE
In reply to Greg Kroah-HartmanFrom: Qian Cai <[email protected]>
[ Upstream commit fac76f2260893dde5aa05bb693b4c13e8ed0454b ]
Otherwise, we could fail to compile.
ld: arch/arm64/crypto/ghash-ce-glue.o: in function 'ghash_ce_mod_exit':
ghash-ce-glue.c:(.exit.text+0x24): undefined reference to 'crypto_unregister_aead'
ld: arch/arm64/crypto/ghash-ce-glue.o: in function 'ghash_ce_mod_init':
ghash-ce-glue.c:(.init.text+0x34): undefined reference to 'crypto_register_aead'
--- arch/arm64/crypto/Kconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm64/crypto/Kconfig +1 -0
@@ -59,6 +59,7 @@ config CRYPTO_GHASH_ARM64_CE select CRYPTO_HASH select CRYPTO_GF128MUL select CRYPTO_LIB_AES + select CRYPTO_AEAD config CRYPTO_CRCT10DIF_ARM64_CE tristate "CRCT10DIF digest algorithm using PMULL instructions"
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 403/1095 selftests/xsk: Destroy BPF resources only when ctx refcount drops to 0
In reply to Greg Kroah-HartmanFrom: Maciej Fijalkowski <[email protected]>
[ Upstream commit 39e940d4abfabb08b6937a315546b24d10be67e3 ]
Currently, xsk_socket__delete frees BPF resources regardless of ctx refcount. Xdpxceiver has a test to verify whether underlying BPF resources would not be wiped out after closing XSK socket that was bound to interface with other active sockets. From library's xsk part perspective it also means that the internal xsk context is shared and its refcount is bumped accordingly.
After a switch to loading XDP prog based on previously opened XSK socket, mentioned xdpxceiver test fails with:
not ok 16 [xdpxceiver.c:swap_xsk_resources:1334]: ERROR: 9/"Bad file descriptor
which means that in swap_xsk_resources(), xsk_socket__delete() released xskmap which in turn caused a failure of xsk_socket__update_xskmap().
To fix this, when deleting socket, decrement ctx refcount before releasing BPF resources and do so only when refcount dropped to 0 which means there are no more active sockets for this ctx so BPF resources can be freed safely.
--- tools/lib/bpf/xsk.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
tools/lib/bpf/xsk.c +4 -5
@@ -1147,8 +1147,6 @@ int xsk_socket__create_shared(struct xsk_socket **xsk_ptr, goto out_mmap_tx; } - ctx->prog_fd =-1 ; -if (!(xsk->config.libbpf_flags &XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD )) { err =__xsk_setup_xdp_prog (xsk,NULL );if (err)
@@ -1229,7 +1227,10 @@ void xsk_socket__delete(struct xsk_socket *xsk) ctx = xsk->ctx; umem = ctx->umem; -if (ctx->prog_fd !=-1 ) { + +xsk_put_ctx (ctx, true); + +if (!ctx->refcount) {xsk_delete_bpf_maps (xsk);close (ctx->prog_fd);if (ctx->has_bpf_link)
@@ -1248,8 +1249,6 @@ void xsk_socket__delete(struct xsk_socket *xsk) } } -xsk_put_ctx (ctx, true); - umem->refcount--;/* Do not close an fd that also has an associated umem connected * to it.
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 404/1095 net: mscc: ocelot: delete ocelot_port :: xmit_template
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit 15f6d01e4829cd2a2dc4f02a00c51d7cec1c736d ]
This is no longer used since commit 7c4bb540e917 ("net: dsa: tag_ocelot:
create separate tagger for Seville").
--- include/soc/mscc/ocelot.h | 1 - 1 file changed, 1 deletion(-)
include/soc/mscc/ocelot.h +0 -1
@@ -663,7 +663,6 @@ struct ocelot_port {phy_interface_t phy_mode; -u8 *xmit_template;bool is_dsa_8021q_cpu;bool learn_ena;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 405/1095 net: mscc: ocelot: minimize holes in struct ocelot_port
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit 6d0be600477089026c76fe529bd96fad4cf69c3b ]
Reorder members of struct ocelot_port to eliminate holes and reduce structure size. Pahole says:
Before:
struct ocelot_port {
struct ocelot * ocelot; /* 0 8 */
struct regmap * target; /* 8 8 */
bool vlan_aware; /* 16 1 *//* XXX 7 bytes hole, try to pack */
const struct ocelot_bridge_vlan * pvid_vlan; /* 24 8 */
unsigned int ptp_skbs_in_flight; /* 32 4 */
u8 ptp_cmd; /* 36 1 */
/* XXX 3 bytes hole, try to pack */
struct sk_buff_head tx_skbs; /* 40 96 */
/* --- cacheline 2 boundary (128 bytes) was 8 bytes ago --- */
u8 ts_id; /* 136 1 */
/* XXX 3 bytes hole, try to pack */
phy_interface_t phy_mode; /* 140 4 */
bool is_dsa_8021q_cpu; /* 144 1 */
bool learn_ena; /* 145 1 */
/* XXX 6 bytes hole, try to pack */
struct net_device * bond; /* 152 8 */
bool lag_tx_active; /* 160 1 */
/* XXX 1 byte hole, try to pack */
u16 mrp_ring_id; /* 162 2 */
/* XXX 4 bytes hole, try to pack */
struct net_device * bridge; /* 168 8 */
int bridge_num; /* 176 4 */
u8 stp_state; /* 180 1 */
/* XXX 3 bytes hole, try to pack */
int speed; /* 184 4 */
/* size: 192, cachelines: 3, members: 18 */ /* sum members: 161, holes: 7, sum holes: 27 */ /* padding: 4 */
};
After:
struct ocelot_port {
struct ocelot * ocelot; /* 0 8 */
struct regmap * target; /* 8 8 */
struct net_device * bond; /* 16 8 */
struct net_device * bridge; /* 24 8 */
const struct ocelot_bridge_vlan * pvid_vlan; /* 32 8 */
phy_interface_t phy_mode; /* 40 4 */
unsigned int ptp_skbs_in_flight; /* 44 4 */
struct sk_buff_head tx_skbs; /* 48 96 */ /* --- cacheline 2 boundary (128 bytes) was 16 bytes ago --- */
u16 mrp_ring_id; /* 144 2 */
u8 ptp_cmd; /* 146 1 */
u8 ts_id; /* 147 1 */
u8 stp_state; /* 148 1 */
bool vlan_aware; /* 149 1 */
bool is_dsa_8021q_cpu; /* 150 1 */
bool learn_ena; /* 151 1 */
bool lag_tx_active; /* 152 1 */
/* XXX 3 bytes hole, try to pack */
int bridge_num; /* 156 4 */
int speed; /* 160 4 */
/* size: 168, cachelines: 3, members: 18 */ /* sum members: 161, holes: 1, sum holes: 3 */ /* padding: 4 */
/* last cacheline: 40 bytes */
};
--- include/soc/mscc/ocelot.h | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
include/soc/mscc/ocelot.h +11 -9
@@ -652,28 +652,30 @@ struct ocelot_port {struct regmap *target; -bool vlan_aware; +struct net_device *bond; +struct net_device *bridge; +/* VLAN that untagged frames are classified to, on ingress */ const struct ocelot_bridge_vlan *pvid_vlan; +phy_interface_t phy_mode; +unsigned int ptp_skbs_in_flight; -u8 ptp_cmd;struct sk_buff_head tx_skbs; -u8 ts_id; -phy_interface_t phy_mode; +u16 mrp_ring_id; +u8 ptp_cmd; +u8 ts_id; + +u8 stp_state; +bool vlan_aware;bool is_dsa_8021q_cpu;bool learn_ena; -struct net_device *bond;bool lag_tx_active; -u16 mrp_ring_id; - -struct net_device *bridge;int bridge_num; -u8 stp_state;int speed; };
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 406/1095 net: dsa: felix: update base time of time-aware shaper when adjusting PTP time
In reply to Greg Kroah-HartmanFrom: Xiaoliang Yang <[email protected]>
[ Upstream commit 8670dc33f48bab4d7bb4b8d0232f17f4dae419ec ]
When adjusting the PTP clock, the base time of the TAS configuration will become unreliable. We need reset the TAS configuration by using a new base time.
For example, if the driver gets a base time 0 of Qbv configuration from user, and current time is 20000. The driver will set the TAS base time to be 20000. After the PTP clock adjustment, the current time becomes 10000. If the TAS base time is still 20000, it will be a future time, and TAS entry list will stop running. Another example, if the current time becomes to be 10000000 after PTP clock adjust, a large time offset can cause the hardware to hang.
This patch introduces a tas_clock_adjust() function to reset the TAS module by using a new base time after the PTP clock adjustment. This can avoid issues above.
Due to PTP clock adjustment can occur at any time, it may conflict with the TAS configuration. We introduce a new TAS lock to serialize the access to the TAS registers.
--- drivers/net/dsa/ocelot/felix_vsc9959.c | 83 ++++++++++++++++++++++++-- drivers/net/ethernet/mscc/ocelot.c | 1 + drivers/net/ethernet/mscc/ocelot_ptp.c | 8 +++ include/soc/mscc/ocelot.h | 7 +++ 4 files changed, 93 insertions(+), 6 deletions(-)
drivers/net/dsa/ocelot/felix_vsc9959.c +77 -6
@@ -1193,10 +1193,13 @@ static void vsc9959_tas_gcl_set(struct ocelot *ocelot, const u32 gcl_ix,static int vsc9959_qos_port_tas_set (struct ocelot *ocelot,int port,struct tc_taprio_qopt_offload *taprio) { +struct ocelot_port *ocelot_port = ocelot->ports[port];struct timespec64 base_ts;int ret, i;u32 val; +mutex_lock (&ocelot->tas_lock); +if (!taprio->enable) { ocelot_rmw_rix(ocelot, QSYS_TAG_CONFIG_INIT_GATE_STATE(0xFF),
@@ -1204,15 +1207,20 @@ static int vsc9959_qos_port_tas_set(struct ocelot *ocelot, int port,QSYS_TAG_CONFIG_INIT_GATE_STATE_M , QSYS_TAG_CONFIG, port); +mutex_unlock (&ocelot->tas_lock);return 0 ; }if (taprio->cycle_time >NSEC_PER_SEC || - taprio->cycle_time_extension >=NSEC_PER_SEC ) -return -EINVAL ; + taprio->cycle_time_extension >=NSEC_PER_SEC ) { + ret = -EINVAL ; + goto err; + } -if (taprio->num_entries >VSC9959_TAS_GCL_ENTRY_MAX ) -return -ERANGE ; +if (taprio->num_entries >VSC9959_TAS_GCL_ENTRY_MAX ) { + ret = -ERANGE ; + goto err; + }/* Enable guard band. The switch will schedule frames without taking * their length into account. Thus we'll always need to enable the
@@ -1233,8 +1241,10 @@ static int vsc9959_qos_port_tas_set(struct ocelot *ocelot, int port,* config is pending, need reset the TAS module */ val =ocelot_read (ocelot,QSYS_PARAM_STATUS_REG_8 ); -if (val &QSYS_PARAM_STATUS_REG_8_CONFIG_PENDING ) -return -EBUSY ; +if (val &QSYS_PARAM_STATUS_REG_8_CONFIG_PENDING ) { + ret = -EBUSY ; + goto err; + } ocelot_rmw_rix(ocelot, QSYS_TAG_CONFIG_ENABLE |
@@ -1245,6 +1255,8 @@ static int vsc9959_qos_port_tas_set(struct ocelot *ocelot, int port,QSYS_TAG_CONFIG_SCH_TRAFFIC_QUEUES_M , QSYS_TAG_CONFIG, port); + ocelot_port->base_time = taprio->base_time; +vsc9959_new_base_time (ocelot, taprio->base_time, taprio->cycle_time, &base_ts);ocelot_write (ocelot, base_ts.tv_nsec,QSYS_PARAM_CFG_REG_1 );
@@ -1268,9 +1280,67 @@ static int vsc9959_qos_port_tas_set(struct ocelot *ocelot, int port, !(val &QSYS_TAS_PARAM_CFG_CTRL_CONFIG_CHANGE ), 10, 100000); +err: +mutex_unlock (&ocelot->tas_lock); +return ret; } +static void vsc9959_tas_clock_adjust (struct ocelot *ocelot) +{ +struct ocelot_port *ocelot_port; +struct timespec64 base_ts; +u64 cycletime; +int port; +u32 val; + +mutex_lock (&ocelot->tas_lock); + +for (port =0 ; port < ocelot->num_phys_ports; port++) { + val =ocelot_read_rix (ocelot,QSYS_TAG_CONFIG , port); +if (!(val &QSYS_TAG_CONFIG_ENABLE )) +continue ; + +ocelot_rmw (ocelot, +QSYS_TAS_PARAM_CFG_CTRL_PORT_NUM (port), +QSYS_TAS_PARAM_CFG_CTRL_PORT_NUM_M , +QSYS_TAS_PARAM_CFG_CTRL ); + +ocelot_rmw_rix (ocelot, +QSYS_TAG_CONFIG_INIT_GATE_STATE (0xFF ), +QSYS_TAG_CONFIG_ENABLE | +QSYS_TAG_CONFIG_INIT_GATE_STATE_M , +QSYS_TAG_CONFIG , port); + + cycletime =ocelot_read (ocelot,QSYS_PARAM_CFG_REG_4 ); + ocelot_port = ocelot->ports[port]; + +vsc9959_new_base_time (ocelot, ocelot_port->base_time, + cycletime, &base_ts); + +ocelot_write (ocelot, base_ts.tv_nsec,QSYS_PARAM_CFG_REG_1 ); +ocelot_write (ocelot,lower_32_bits (base_ts.tv_sec), +QSYS_PARAM_CFG_REG_2 ); + val =upper_32_bits (base_ts.tv_sec); +ocelot_rmw (ocelot, +QSYS_PARAM_CFG_REG_3_BASE_TIME_SEC_MSB (val), +QSYS_PARAM_CFG_REG_3_BASE_TIME_SEC_MSB_M , +QSYS_PARAM_CFG_REG_3 ); + +ocelot_rmw (ocelot,QSYS_TAS_PARAM_CFG_CTRL_CONFIG_CHANGE , +QSYS_TAS_PARAM_CFG_CTRL_CONFIG_CHANGE , +QSYS_TAS_PARAM_CFG_CTRL ); + +ocelot_rmw_rix (ocelot, +QSYS_TAG_CONFIG_INIT_GATE_STATE (0xFF ) | +QSYS_TAG_CONFIG_ENABLE , +QSYS_TAG_CONFIG_ENABLE | +QSYS_TAG_CONFIG_INIT_GATE_STATE_M , +QSYS_TAG_CONFIG , port); + } +mutex_unlock (&ocelot->tas_lock); +} +static int vsc9959_qos_port_cbs_set (struct dsa_switch *ds,int port,struct tc_cbs_qopt_offload *cbs_qopt) {
@@ -2210,6 +2280,7 @@ static const struct ocelot_ops vsc9959_ops = { .psfp_filter_del = vsc9959_psfp_filter_del, .psfp_stats_get = vsc9959_psfp_stats_get, .cut_through_fwd = vsc9959_cut_through_fwd, + .tas_clock_adjust = vsc9959_tas_clock_adjust, };static const struct felix_info felix_info_vsc9959 = {
drivers/net/ethernet/mscc/ocelot.c +1 -0
@@ -3245,6 +3245,7 @@ int ocelot_init(struct ocelot *ocelot)mutex_init (&ocelot->ptp_lock);mutex_init (&ocelot->mact_lock);mutex_init (&ocelot->fwd_domain_lock); +mutex_init (&ocelot->tas_lock);spin_lock_init (&ocelot->ptp_clock_lock);spin_lock_init (&ocelot->ts_id_lock); snprintf(queue_name, sizeof(queue_name), "%s-stats",
drivers/net/ethernet/mscc/ocelot_ptp.c +8 -0
@@ -72,6 +72,10 @@ int ocelot_ptp_settime64(struct ptp_clock_info *ptp,ocelot_write_rix (ocelot, val,PTP_PIN_CFG ,TOD_ACC_PIN );spin_unlock_irqrestore (&ocelot->ptp_clock_lock, flags); + +if (ocelot->ops->tas_clock_adjust) + ocelot->ops->tas_clock_adjust (ocelot); +return 0 ; }EXPORT_SYMBOL (ocelot_ptp_settime64);
@@ -105,6 +109,9 @@ int ocelot_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)ocelot_write_rix (ocelot, val,PTP_PIN_CFG ,TOD_ACC_PIN );spin_unlock_irqrestore (&ocelot->ptp_clock_lock, flags); + +if (ocelot->ops->tas_clock_adjust) + ocelot->ops->tas_clock_adjust (ocelot); }else {/* Fall back using ocelot_ptp_settime64 which is not exact. */ struct timespec64 ts;
@@ -117,6 +124,7 @@ int ocelot_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)ocelot_ptp_settime64 (ptp, &ts); } +return 0 ; }EXPORT_SYMBOL (ocelot_ptp_adjtime);
include/soc/mscc/ocelot.h +7 -0
@@ -568,6 +568,7 @@ struct ocelot_ops {int (*psfp_stats_get)(struct ocelot *ocelot,struct flow_cls_offload *f,struct flow_stats *stats);void (*cut_through_fwd)(struct ocelot *ocelot); +void (*tas_clock_adjust)(struct ocelot *ocelot); };struct ocelot_vcap_policer {
@@ -678,6 +679,9 @@ struct ocelot_port {int bridge_num;int speed; + +/* Store the AdminBaseTime of EST fetched from userspace. */ +s64 base_time; };struct ocelot {
@@ -744,6 +748,9 @@ struct ocelot {/* Lock for serializing forwarding domain changes */ struct mutex fwd_domain_lock; +/* Lock for serializing Time-Aware Shaper changes */ +struct mutex tas_lock; +struct workqueue_struct *owq; u8 ptp:1;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 407/1095 net: dsa: felix: keep reference on entire tc-taprio config
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit 1c9017e44af2eee94b1001af18c401ae440ad77c ]
In a future change we will need to remember the entire tc-taprio config on all ports rather than just the base time, so use the taprio_offload_get() helper function to replace ocelot_port->base_time with ocelot_port->taprio.
--- drivers/net/dsa/ocelot/felix_vsc9959.c | 23 +++++++++++++---------- include/soc/mscc/ocelot.h | 5 ++--- 2 files changed, 15 insertions(+), 13 deletions(-)
drivers/net/dsa/ocelot/felix_vsc9959.c +13 -10
@@ -1207,6 +1207,9 @@ static int vsc9959_qos_port_tas_set(struct ocelot *ocelot, int port,QSYS_TAG_CONFIG_INIT_GATE_STATE_M , QSYS_TAG_CONFIG, port); +taprio_offload_free (ocelot_port->taprio); + ocelot_port->taprio =NULL ; +mutex_unlock (&ocelot->tas_lock);return 0 ; }
@@ -1255,8 +1258,6 @@ static int vsc9959_qos_port_tas_set(struct ocelot *ocelot, int port,QSYS_TAG_CONFIG_SCH_TRAFFIC_QUEUES_M , QSYS_TAG_CONFIG, port); - ocelot_port->base_time = taprio->base_time; -vsc9959_new_base_time (ocelot, taprio->base_time, taprio->cycle_time, &base_ts);ocelot_write (ocelot, base_ts.tv_nsec,QSYS_PARAM_CFG_REG_1 );
@@ -1279,6 +1280,10 @@ static int vsc9959_qos_port_tas_set(struct ocelot *ocelot, int port, ret =readx_poll_timeout (vsc9959_tas_read_cfg_status, ocelot, val, !(val &QSYS_TAS_PARAM_CFG_CTRL_CONFIG_CHANGE ),10 ,100000 ); +if (ret) + goto err; + + ocelot_port->taprio =taprio_offload_get (taprio); err:mutex_unlock (&ocelot->tas_lock);
@@ -1288,17 +1293,18 @@ static int vsc9959_qos_port_tas_set(struct ocelot *ocelot, int port,static void vsc9959_tas_clock_adjust (struct ocelot *ocelot) { +struct tc_taprio_qopt_offload *taprio;struct ocelot_port *ocelot_port;struct timespec64 base_ts; -u64 cycletime;int port;u32 val;mutex_lock (&ocelot->tas_lock);for (port =0 ; port < ocelot->num_phys_ports; port++) { - val =ocelot_read_rix (ocelot,QSYS_TAG_CONFIG , port); -if (!(val &QSYS_TAG_CONFIG_ENABLE )) + ocelot_port = ocelot->ports[port]; + taprio = ocelot_port->taprio; +if (!taprio)continue ; ocelot_rmw(ocelot,
@@ -1312,11 +1318,8 @@ static void vsc9959_tas_clock_adjust(struct ocelot *ocelot)QSYS_TAG_CONFIG_INIT_GATE_STATE_M , QSYS_TAG_CONFIG, port); - cycletime =ocelot_read (ocelot,QSYS_PARAM_CFG_REG_4 ); - ocelot_port = ocelot->ports[port]; - -vsc9959_new_base_time (ocelot, ocelot_port->base_time, - cycletime, &base_ts); +vsc9959_new_base_time (ocelot, taprio->base_time, + taprio->cycle_time, &base_ts);ocelot_write (ocelot, base_ts.tv_nsec,QSYS_PARAM_CFG_REG_1 ); ocelot_write(ocelot, lower_32_bits(base_ts.tv_sec),
include/soc/mscc/ocelot.h +2 -3
@@ -659,6 +659,8 @@ struct ocelot_port {/* VLAN that untagged frames are classified to, on ingress */ const struct ocelot_bridge_vlan *pvid_vlan; +struct tc_taprio_qopt_offload *taprio; +phy_interface_t phy_mode;unsigned int ptp_skbs_in_flight;
@@ -679,9 +681,6 @@ struct ocelot_port {int bridge_num;int speed; - -/* Store the AdminBaseTime of EST fetched from userspace. */ -s64 base_time; };struct ocelot {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 408/1095 net: dsa: felix: drop oversized frames with tc-taprio instead of hanging the port
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit 55a515b1f5a97df5704a1788fe97a4a740be2b9e ]
Currently, sending a packet into a time gate too small for it (or always closed) causes the queue system to hold the frame forever. Even worse, this frame isn't subject to aging either, because for that to happen, it needs to be scheduled for transmission in the first place. But the frame will consume buffer memory and frame references while it is forever held in the queue system.
Before commit a4ae997adcbd ("net: mscc: ocelot: initialize watermarks to sane defaults"), this behavior was somewhat subtle, as the switch had a more intricately tuned default watermark configuration out of reset, which did not allow any single port and tc to consume the entire switch buffer space. Nonetheless, the held frames are still there, and they reduce the total backplane capacity of the switch.
However, after the aforementioned commit, the behavior can be very clearly seen, since we deliberately allow each {port, tc} to consume the entire shared buffer of the switch minus the reservations (and we disable all reservations by default). That is to say, we allow a permanently closed tc-taprio gate to hang the entire switch.
A careful inspection of the documentation shows that the QSYS:Q_MAX_SDU per-port-tc registers serve 2 purposes: one is for guard band calculation (when zero, this falls back to QSYS:PORT_MAX_SDU), and the other is to enable oversized frame dropping (when non-zero).
Currently the QSYS:Q_MAX_SDU registers are all zero, so oversized frame dropping is disabled. The goal of the change is to enable it seamlessly. For that, we need to hook into the MTU change, tc-taprio change, and port link speed change procedures, since we depend on these variables.
Frames are not dropped on egress due to a queue system oversize condition, instead that egress port is simply excluded from the mask of valid destination ports for the packet. If there are no destination ports at all, the ingress counter that increments is the generic "drop_tail" in ethtool -S.
The issue exists in various forms since the tc-taprio offload was introduced.
--- drivers/net/dsa/ocelot/felix.c | 9 ++ drivers/net/dsa/ocelot/felix.h | 1 + drivers/net/dsa/ocelot/felix_vsc9959.c | 201 +++++++++++++++++++++++++ 3 files changed, 211 insertions(+)
drivers/net/dsa/ocelot/felix.c +9 -0
@@ -1613,9 +1613,18 @@ static void felix_txtstamp(struct dsa_switch *ds, int port,static int felix_change_mtu (struct dsa_switch *ds,int port,int new_mtu) {struct ocelot *ocelot = ds->priv; +struct ocelot_port *ocelot_port = ocelot->ports[port]; +struct felix *felix =ocelot_to_felix (ocelot);ocelot_port_set_maxlen (ocelot, port, new_mtu); +mutex_lock (&ocelot->tas_lock); + +if (ocelot_port->taprio && felix->info->tas_guard_bands_update) + felix->info->tas_guard_bands_update (ocelot, port); + +mutex_unlock (&ocelot->tas_lock); +return 0 ; }
drivers/net/dsa/ocelot/felix.h +1 -0
@@ -53,6 +53,7 @@ struct felix_info { struct phylink_link_state *state);int (*port_setup_tc)(struct dsa_switch *ds,int port,enum tc_setup_type type,void *type_data); +void (*tas_guard_bands_update)(struct ocelot *ocelot,int port);void (*port_sched_speed_set)(struct ocelot *ocelot,int port,u32 speed); struct regmap *(*init_regmap)(struct ocelot *ocelot,
drivers/net/dsa/ocelot/felix_vsc9959.c +201 -0
234 lines not on this page · raw message
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 409/1095 drm/rockchip: vop: Dont crash for invalid duplicate_state()
In reply to Greg Kroah-HartmanFrom: Brian Norris <[email protected]>
[ Upstream commit 1449110b0dade8b638d2c17ab7c5b0ff696bfccb ]
It's possible for users to try to duplicate the CRTC state even when the state doesn't exist. drm_atomic_helper_crtc_duplicate_state() (and other users of __drm_atomic_helper_crtc_duplicate_state()) already guard this with a WARN_ON() instead of crashing, so let's do that here too.
--- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +3 -0
@@ -1552,6 +1552,9 @@ static struct drm_crtc_state *vop_crtc_duplicate_state(struct drm_crtc *crtc) {struct rockchip_crtc_state *rockchip_state; +if (WARN_ON (!crtc->state)) +return NULL ; + rockchip_state =kzalloc (sizeof (*rockchip_state),GFP_KERNEL );if (!rockchip_state)return NULL ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 410/1095 drm/rockchip: Fix an error handling path rockchip_dp_probe()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 5074376822fe99fa4ce344b851c5016d00c0444f ]
Should component_add() fail, we should call analogix_dp_remove() in the error handling path, as already done in the remove function.
--- drivers/gpu/drm/rockchip/analogix_dp-rockchip.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/rockchip/analogix_dp-rockchip.c +9 -1
@@ -398,7 +398,15 @@ static int rockchip_dp_probe(struct platform_device *pdev)if (IS_ERR (dp->adp))return PTR_ERR (dp->adp); -return component_add (dev, &rockchip_dp_component_ops); + ret =component_add (dev, &rockchip_dp_component_ops); +if (ret) + goto err_dp_remove; + +return 0 ; + +err_dp_remove: +analogix_dp_remove (dp->adp); +return ret; }static int rockchip_dp_remove (struct platform_device *pdev)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 411/1095 drm/mediatek: dpi: Remove output format of YUV
In reply to Greg Kroah-HartmanFrom: Bo-Chen Chen <[email protected]>
[ Upstream commit c9ed0713b3c35fc45677707ba47f432cad95da56 ]
DPI is not support output format as YUV, but there is the setting of configuring output YUV. Therefore, remove them in this patch.
--- drivers/gpu/drm/mediatek/mtk_dpi.c | 31 ++++++------------------------ 1 file changed, 6 insertions(+), 25 deletions(-)
drivers/gpu/drm/mediatek/mtk_dpi.c +6 -25
@@ -54,13 +54,7 @@ enum mtk_dpi_out_channel_swap { };enum mtk_dpi_out_color_format { -MTK_DPI_COLOR_FORMAT_RGB , -MTK_DPI_COLOR_FORMAT_RGB_FULL , -MTK_DPI_COLOR_FORMAT_YCBCR_444 , -MTK_DPI_COLOR_FORMAT_YCBCR_422 , -MTK_DPI_COLOR_FORMAT_XV_YCC , -MTK_DPI_COLOR_FORMAT_YCBCR_444_FULL , -MTK_DPI_COLOR_FORMAT_YCBCR_422_FULL +MTK_DPI_COLOR_FORMAT_RGB };struct mtk_dpi {
@@ -364,24 +358,11 @@ static void mtk_dpi_config_disable_edge(struct mtk_dpi *dpi)static void mtk_dpi_config_color_format (struct mtk_dpi *dpi,enum mtk_dpi_out_color_format format) { -if ((format ==MTK_DPI_COLOR_FORMAT_YCBCR_444 ) || - (format ==MTK_DPI_COLOR_FORMAT_YCBCR_444_FULL )) { -mtk_dpi_config_yuv422_enable (dpi, false); -mtk_dpi_config_csc_enable (dpi, true); -mtk_dpi_config_swap_input (dpi, false); -mtk_dpi_config_channel_swap (dpi,MTK_DPI_OUT_CHANNEL_SWAP_BGR ); - }else if ((format ==MTK_DPI_COLOR_FORMAT_YCBCR_422 ) || - (format ==MTK_DPI_COLOR_FORMAT_YCBCR_422_FULL )) { -mtk_dpi_config_yuv422_enable (dpi, true); -mtk_dpi_config_csc_enable (dpi, true); -mtk_dpi_config_swap_input (dpi, true); -mtk_dpi_config_channel_swap (dpi,MTK_DPI_OUT_CHANNEL_SWAP_RGB ); - }else { -mtk_dpi_config_yuv422_enable (dpi, false); -mtk_dpi_config_csc_enable (dpi, false); -mtk_dpi_config_swap_input (dpi, false); -mtk_dpi_config_channel_swap (dpi,MTK_DPI_OUT_CHANNEL_SWAP_RGB ); - } +/* only support RGB888 */ +mtk_dpi_config_yuv422_enable (dpi, false); +mtk_dpi_config_csc_enable (dpi, false); +mtk_dpi_config_swap_input (dpi, false); +mtk_dpi_config_channel_swap (dpi,MTK_DPI_OUT_CHANNEL_SWAP_RGB ); }static void mtk_dpi_dual_edge (struct mtk_dpi *dpi)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 412/1095 drm/mediatek: dpi: Only enable dpi after the bridge is enabled
In reply to Greg Kroah-HartmanFrom: Guillaume Ranquet <[email protected]>
[ Upstream commit aed61ef6beb911cc043af0f2f291167663995065 ]
Enabling the dpi too early causes glitches on screen.
Move the call to mtk_dpi_enable() at the end of the bridge_enable callback to ensure everything is setup properly before enabling dpi.
--- drivers/gpu/drm/mediatek/mtk_dpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/mediatek/mtk_dpi.c +1 -1
@@ -417,7 +417,6 @@ static int mtk_dpi_power_on(struct mtk_dpi *dpi)if (dpi->pinctrl && dpi->pins_dpi)pinctrl_select_state (dpi->pinctrl, dpi->pins_dpi); -mtk_dpi_enable (dpi);return 0 ; err_pixel:
@@ -639,6 +638,7 @@ static void mtk_dpi_bridge_enable(struct drm_bridge *bridge)mtk_dpi_power_on (dpi);mtk_dpi_set_display_mode (dpi, &dpi->mode); +mtk_dpi_enable (dpi); } static enum drm_mode_status
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 413/1095 drm/msm/hdmi: fill the pwr_regs bulk regulators
In reply to Greg Kroah-HartmanFrom: Dmitry Baryshkov <[email protected]>
[ Upstream commit a18a44e9262d5c7f7fbccbc9458df64d69185d41 ]
Conversion to use bulk regulator API omitted filling the pwr_regs with proper regulator IDs. This was left unnoticed, since none of my testing platforms has used the pwr_regs. Fix this by propagating regulator ids properly.
Patchwork: https://patchwork.freedesktop.org/patch/488847/
--- drivers/gpu/drm/msm/hdmi/hdmi.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/msm/hdmi/hdmi.c +3 -0
@@ -180,6 +180,9 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev) goto fail; } +for (i =0 ; i < config->pwr_reg_cnt; i++) + hdmi->pwr_regs[i].supply = config->pwr_reg_names[i]; + ret =devm_regulator_bulk_get (&pdev->dev, config->pwr_reg_cnt, hdmi->pwr_regs);if (ret) {DRM_DEV_ERROR (&pdev->dev,"failed to get pwr regulator: %d\n" , ret);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 414/1095 drm: bridge: sii8620: fix possible off-by-one
In reply to Greg Kroah-HartmanFrom: Hangyu Hua <[email protected]>
[ Upstream commit 21779cc21c732c5eff8ea1624be6590450baa30f ]
The next call to sii8620_burst_get_tx_buf will result in off-by-one When ctx->burst.tx_count + size == ARRAY_SIZE(ctx->burst.tx_buf). The same thing happens in sii8620_burst_get_rx_buf.
This patch also change tx_count and tx_buf to rx_count and rx_buf in sii8620_burst_get_rx_buf. It is unreasonable to check tx_buf's size and use rx_buf.
--- drivers/gpu/drm/bridge/sil-sii8620.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/sil-sii8620.c +2 -2
@@ -605,7 +605,7 @@ static void *sii8620_burst_get_tx_buf(struct sii8620 *ctx, int len)u8 *buf = &ctx->burst.tx_buf[ctx->burst.tx_count];int size = len +2 ; -if (ctx->burst.tx_count + size >ARRAY_SIZE (ctx->burst.tx_buf)) { +if (ctx->burst.tx_count + size >=ARRAY_SIZE (ctx->burst.tx_buf)) {dev_err (ctx->dev,"TX-BLK buffer exhausted\n" ); ctx->error = -EINVAL ;return NULL ;
@@ -622,7 +622,7 @@ static u8 *sii8620_burst_get_rx_buf(struct sii8620 *ctx, int len)u8 *buf = &ctx->burst.rx_buf[ctx->burst.rx_count];int size = len +1 ; -if (ctx->burst.tx_count + size >ARRAY_SIZE (ctx->burst.tx_buf)) { +if (ctx->burst.rx_count + size >=ARRAY_SIZE (ctx->burst.rx_buf)) {dev_err (ctx->dev,"RX-BLK buffer exhausted\n" ); ctx->error = -EINVAL ;return NULL ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 415/1095 net: sched: provide shim definitions for taprio_offload_{get,free}
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit d7be266adbfd3aca6965ea6a0c36b2c3d8fc9fc8 ]
All callers of taprio_offload_get() and taprio_offload_free() prior to the blamed commit are conditionally compiled based on CONFIG_NET_SCH_TAPRIO.
felix_vsc9959.c is different; it provides vsc9959_qos_port_tas_set() even when taprio is compiled out.
Provide shim definitions for the functions exported by taprio so that felix_vsc9959.c is able to compile. vsc9959_qos_port_tas_set() in that case is dead code anyway, and ocelot_port->taprio remains NULL, which is fine for the rest of the logic.
--- include/net/pkt_sched.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
include/net/pkt_sched.h +17 -0
@@ -173,11 +173,28 @@ struct tc_taprio_qopt_offload {struct tc_taprio_sched_entry entries[]; }; +#if IS_ENABLED (CONFIG_NET_SCH_TAPRIO ) +/* Reference counting */ struct tc_taprio_qopt_offload *taprio_offload_get (struct tc_taprio_qopt_offload *offload);void taprio_offload_free (struct tc_taprio_qopt_offload *offload); +#else + +/* Reference counting */ +static inline struct tc_taprio_qopt_offload * +taprio_offload_get (struct tc_taprio_qopt_offload *offload) +{ +return NULL ; +} + +static inline void taprio_offload_free (struct tc_taprio_qopt_offload *offload) +{ +} + +#endif +/* Ensure skb_mstamp_ns, which might have been populated with the txtime, is * not mistaken for a software timestamp, because this will otherwise prevent * the dispatch of hardware timestamps to the socket.
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 416/1095 net: dsa: felix: build as module when tc-taprio is module
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit 10ed11ab6399813eb652137db9c378433c28a95c ]
felix_vsc9959.c calls taprio_offload_get() and taprio_offload_free(), symbols exported by net/sched/sch_taprio.c. As such, we must disallow building the Felix driver as built-in when the symbol exported by tc-taprio isn't present in the kernel image.
--- drivers/net/dsa/ocelot/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/net/dsa/ocelot/Kconfig +1 -0
@@ -6,6 +6,7 @@ config NET_DSA_MSCC_FELIX depends on NET_VENDOR_FREESCALE depends on HAS_IOMEM depends on PTP_1588_CLOCK_OPTIONAL + depends on NET_SCH_TAPRIO || NET_SCH_TAPRIO=n select MSCC_OCELOT_SWITCH_LIB select NET_DSA_TAG_OCELOT_8021Q select NET_DSA_TAG_OCELOT
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 417/1095 hinic: Use the bitmap API when applicable
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 7c2c57263af41cfd8b5022274e6801542831bb69 ]
'vlan_bitmap' is a bitmap and is used as such. So allocate it with devm_bitmap_zalloc() and its explicit bit size (i.e. VLAN_N_VID).
This avoids the need of the VLAN_BITMAP_SIZE macro which:
- needlessly has a 'nic_dev' parameter
- should be "long" (and not byte) aligned, so that the bitmap semantic is respected
This is in fact not an issue because VLAN_N_VID is 4096 at the time being, but devm_bitmap_zalloc() is less verbose and easier to understand.
--- drivers/net/ethernet/huawei/hinic/hinic_main.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/net/ethernet/huawei/hinic/hinic_main.c +2 -5
@@ -62,8 +62,6 @@ MODULE_PARM_DESC(rx_weight, "Number Rx packets for NAPI budget (default=64)");#define HINIC_LRO_RX_TIMER_DEFAULT 16 -#define VLAN_BITMAP_SIZE (nic_dev) (ALIGN(VLAN_N_VID, 8) / 8) -#define work_to_rx_mode_work (work) \ container_of(work, struct hinic_rx_mode_work, work)
@@ -1242,9 +1240,8 @@ static int nic_dev_init(struct pci_dev *pdev)u64_stats_init (&tx_stats->syncp);u64_stats_init (&rx_stats->syncp); - nic_dev->vlan_bitmap =devm_kzalloc (&pdev->dev, -VLAN_BITMAP_SIZE (nic_dev), -GFP_KERNEL ); + nic_dev->vlan_bitmap =devm_bitmap_zalloc (&pdev->dev,VLAN_N_VID , +GFP_KERNEL );if (!nic_dev->vlan_bitmap) { err = -ENOMEM ; goto err_vlan_bitmap;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 418/1095 net: hinic: fix bug that ethtool get wrong stats
In reply to Greg Kroah-HartmanFrom: Qiao Ma <[email protected]>
[ Upstream commit 67dffd3db98570af8ff54c934f7d14664c0d182a ]
Function hinic_get_stats64() will do two operations:
1. reads stats from every hinic_rxq/txq and accumulates them
2. calls hinic_rxq/txq_clean_stats() to clean every rxq/txq's stats
For hinic_get_stats64(), it could get right data, because it sums all data to nic_dev->rx_stats/tx_stats.
But it is wrong for get_drv_queue_stats(), this function will read hinic_rxq's stats, which have been cleared to zero by hinic_get_stats64().
I have observed hinic's cleanup operation by using such command:
Quoted 1 line
watch -n 1 "cat ethtool -S eth4 | tail -40"
Result before:
...
rxq7_pkts: 1
rxq7_bytes: 90
rxq7_errors: 0
rxq7_csum_errors: 0
rxq7_other_errors: 0
...
rxq9_pkts: 11
rxq9_bytes: 726
rxq9_errors: 0
rxq9_csum_errors: 0
rxq9_other_errors: 0
...
rxq11_pkts: 0
rxq11_bytes: 0
rxq11_errors: 0
rxq11_csum_errors: 0
rxq11_other_errors: 0Result after a few seconds:
...
rxq7_pkts: 0
rxq7_bytes: 0
rxq7_errors: 0
rxq7_csum_errors: 0
rxq7_other_errors: 0
...
rxq9_pkts: 2
rxq9_bytes: 132
rxq9_errors: 0
rxq9_csum_errors: 0
rxq9_other_errors: 0
...
rxq11_pkts: 1
rxq11_bytes: 170
rxq11_errors: 0
rxq11_csum_errors: 0
rxq11_other_errors: 0To solve this problem, we just keep every queue's total stats in their own queue (aka hinic_{rxq|txq}), and simply sum all per-queue stats every time calling hinic_get_stats64().
With that solution, there is no need to clean per-queue stats now, and there is no need to maintain global hinic_dev.{tx|rx}_stats, too.
--- drivers/net/ethernet/huawei/hinic/hinic_dev.h | 3 - .../net/ethernet/huawei/hinic/hinic_main.c | 57 ++++++------------- drivers/net/ethernet/huawei/hinic/hinic_rx.c | 2 - drivers/net/ethernet/huawei/hinic/hinic_tx.c | 2 - 4 files changed, 16 insertions(+), 48 deletions(-)
drivers/net/ethernet/huawei/hinic/hinic_dev.h +0 -3
@@ -95,9 +95,6 @@ struct hinic_dev {u16 sq_depth;u16 rq_depth; -struct hinic_txq_stats tx_stats; -struct hinic_rxq_stats rx_stats; -u8 rss_tmpl_idx;u8 rss_hash_engine;u16 num_rss;
drivers/net/ethernet/huawei/hinic/hinic_main.c +16 -41
126 lines not on this page · raw message
drivers/net/ethernet/huawei/hinic/hinic_rx.c +0 -2
@@ -73,7 +73,6 @@ void hinic_rxq_get_stats(struct hinic_rxq *rxq, struct hinic_rxq_stats *stats)struct hinic_rxq_stats *rxq_stats = &rxq->rxq_stats;unsigned int start; -u64_stats_update_begin (&stats->syncp); do { start = u64_stats_fetch_begin(&rxq_stats->syncp); stats->pkts = rxq_stats->pkts;
@@ -83,7 +82,6 @@ void hinic_rxq_get_stats(struct hinic_rxq *rxq, struct hinic_rxq_stats *stats) stats->csum_errors = rxq_stats->csum_errors; stats->other_errors = rxq_stats->other_errors; }while (u64_stats_fetch_retry (&rxq_stats->syncp, start)); -u64_stats_update_end (&stats->syncp); }/**
drivers/net/ethernet/huawei/hinic/hinic_tx.c +0 -2
@@ -98,7 +98,6 @@ void hinic_txq_get_stats(struct hinic_txq *txq, struct hinic_txq_stats *stats)struct hinic_txq_stats *txq_stats = &txq->txq_stats;unsigned int start; -u64_stats_update_begin (&stats->syncp); do { start = u64_stats_fetch_begin(&txq_stats->syncp); stats->pkts = txq_stats->pkts;
@@ -108,7 +107,6 @@ void hinic_txq_get_stats(struct hinic_txq *txq, struct hinic_txq_stats *stats) stats->tx_dropped = txq_stats->tx_dropped; stats->big_frags_pkts = txq_stats->big_frags_pkts; }while (u64_stats_fetch_retry (&txq_stats->syncp, start)); -u64_stats_update_end (&stats->syncp); }/**
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 419/1095 net: hinic: avoid kernel hung in hinic_get_stats64()
In reply to Greg Kroah-HartmanFrom: Qiao Ma <[email protected]>
[ Upstream commit 98f9fcdee35add80505b6c73f72de5f750d5c03c ]
When using hinic device as a bond slave device, and reading device stats of master bond device, the kernel may hung.
The kernel panic calltrace as follows:
Kernel panic - not syncing: softlockup: hung tasks Call trace: native_queued_spin_lock_slowpath+0x1ec/0x31c dev_get_stats+0x60/0xcc dev_seq_printf_stats+0x40/0x120 dev_seq_show+0x1c/0x40 seq_read_iter+0x3c8/0x4dc seq_read+0xe0/0x130 proc_reg_read+0xa8/0xe0 vfs_read+0xb0/0x1d4 ksys_read+0x70/0xfc __arm64_sys_read+0x20/0x30 el0_svc_common+0x88/0x234 do_el0_svc+0x2c/0x90 el0_svc+0x1c/0x30 el0_sync_handler+0xa8/0xb0 el0_sync+0x148/0x180
And the calltrace of task that actually caused kernel hungs as follows:
__switch_to+124
__schedule+548
schedule+72
schedule_timeout+348
__down_common+188
__down+24
down+104
hinic_get_stats64+44 [hinic]
dev_get_stats+92
bond_get_stats+172 [bonding]
dev_get_stats+92
dev_seq_printf_stats+60
dev_seq_show+24
seq_read_iter+964
seq_read+220
proc_reg_read+164
vfs_read+172
ksys_read+108
__arm64_sys_read+28
el0_svc_common+132
do_el0_svc+40
el0_svc+24
el0_sync_handler+164
el0_sync+324
When getting device stats from bond, kernel will call bond_get_stats(). It first holds the spinlock bond->stats_lock, and then call hinic_get_stats64() to collect hinic device's stats. However, hinic_get_stats64() calls down(&nic_dev->mgmt_lock) to protect its critical section, which may schedule current task out. And if system is under high pressure, the task cannot be woken up immediately, which eventually triggers kernel hung panic.
Since previous patch has replaced hinic_dev.tx_stats/rx_stats with local variable in hinic_get_stats64(), there is nothing need to be protected by lock, so just removing down()/up() is ok.
--- drivers/net/ethernet/huawei/hinic/hinic_main.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/net/ethernet/huawei/hinic/hinic_main.c +0 -4
@@ -842,13 +842,9 @@ static void hinic_get_stats64(struct net_device *netdev,struct hinic_rxq_stats nic_rx_stats = {};struct hinic_txq_stats nic_tx_stats = {}; -down (&nic_dev->mgmt_lock); -if (nic_dev->flags &HINIC_INTF_UP )gather_nic_stats (nic_dev, &nic_rx_stats, &nic_tx_stats); -up (&nic_dev->mgmt_lock); - stats->rx_bytes = nic_rx_stats.bytes; stats->rx_packets = nic_rx_stats.pkts; stats->rx_errors = nic_rx_stats.errors;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 420/1095 drm/bridge: anx7625: Fix NULL pointer crash when using edp-panel
In reply to Greg Kroah-HartmanFrom: Hsin-Yi Wang <[email protected]>
[ Upstream commit dfb02eb6bdf84697dbadd69a7df12db612ce4ed0 ]
Move devm_of_dp_aux_populate_ep_devices() after pm runtime and i2c setup to avoid NULL pointer crash.
edp-panel probe (generic_edp_panel_probe) calls pm_runtime_get_sync() to read EDID. At this time, bridge should have pm runtime enabled and i2c clients ready.
--- drivers/gpu/drm/bridge/analogix/anx7625.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/gpu/drm/bridge/analogix/anx7625.c +9 -8
@@ -2651,14 +2651,6 @@ static int anx7625_i2c_probe(struct i2c_client *client, platform->aux.dev = dev; platform->aux.transfer = anx7625_aux_transfer;drm_dp_aux_init (&platform->aux); -devm_of_dp_aux_populate_ep_devices (&platform->aux); - - ret =anx7625_parse_dt (dev, pdata); -if (ret) { -if (ret != -EPROBE_DEFER ) -DRM_DEV_ERROR (dev,"fail to parse DT : %d\n" , ret); - goto free_wq; - }if (anx7625_register_i2c_dummy_clients (platform, client) !=0 ) { ret = -ENOMEM ;
@@ -2674,6 +2666,15 @@ static int anx7625_i2c_probe(struct i2c_client *client,if (ret) goto free_wq; +devm_of_dp_aux_populate_ep_devices (&platform->aux); + + ret =anx7625_parse_dt (dev, pdata); +if (ret) { +if (ret != -EPROBE_DEFER ) +DRM_DEV_ERROR (dev,"fail to parse DT : %d\n" , ret); + goto free_wq; + } +if (!platform->pdata.low_power_mode) {anx7625_disable_pd_protocol (platform);pm_runtime_get_sync (dev);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 421/1095 drm/msm: Avoid unclocked GMU register access in 6xx gpu_busy
In reply to Greg Kroah-HartmanFrom: Douglas Anderson <[email protected]>
[ Upstream commit 6694482a70e9536efbf2ac233cbf0c302d6e2dae ]
Quoted 1 line
From testing on sc7180-trogdor devices, reading the GMU registers
needs the GMU clocks to be enabled. Those clocks get turned on in a6xx_gmu_resume(). Confusingly enough, that function is called as a result of the runtime_pm of the GPU "struct device", not the GMU "struct device". Unfortunately the current a6xx_gpu_busy() grabs a reference to the GMU's "struct device".
The fact that we were grabbing the wrong reference was easily seen to cause crashes that happen if we change the GPU's pm_runtime usage to not use autosuspend. It's also believed to cause some long tail GPU crashes even with autosuspend.
We could look at changing it so that we do pm_runtime_get_if_in_use() on the GPU's "struct device", but then we run into a different problem. pm_runtime_get_if_in_use() will return 0 for the GPU's "struct device" the whole time when we're in the "autosuspend delay". That is, when we drop the last reference to the GPU but we're waiting a period before actually suspending then we'll think the GPU is off. One reason that's bad is that if the GPU didn't actually turn off then the cycle counter doesn't lose state and that throws off all of our calculations.
Let's change the code to keep track of the suspend state of devfreq. msm_devfreq_suspend() is always called before we actually suspend the GPU and msm_devfreq_resume() after we resume it. This means we can use the suspended state to know if we're powered or not.
NOTE: one might wonder when exactly our status function is called when devfreq is supposed to be disabled. The stack crawl I captured was:
msm_devfreq_get_dev_status
devfreq_simple_ondemand_func
devfreq_update_target
qos_notifier_call
qos_max_notifier_call
blocking_notifier_call_chain
pm_qos_update_target
freq_qos_apply
apply_constraint
__dev_pm_qos_update_request
dev_pm_qos_update_request
msm_devfreq_idle_work
Patchwork: https://patchwork.freedesktop.org/patch/489124/
--- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 8 ------ drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 13 ++++----- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 12 +++------ drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 3 ++- drivers/gpu/drm/msm/msm_gpu.h | 11 +++++++- drivers/gpu/drm/msm/msm_gpu_devfreq.c | 39 +++++++++++++++++++++------ 6 files changed, 53 insertions(+), 33 deletions(-)
drivers/gpu/drm/msm/adreno/a5xx_gpu.c +0 -8
@@ -1666,18 +1666,10 @@ static u64 a5xx_gpu_busy(struct msm_gpu *gpu, unsigned long *out_sample_rate) {u64 busy_cycles; -/* Only read the gpu busy if the hardware is already active */ -if (pm_runtime_get_if_in_use (&gpu->pdev->dev) ==0 ) { - *out_sample_rate =1 ; -return 0 ; - } - busy_cycles =gpu_read64 (gpu,REG_A5XX_RBBM_PERFCTR_RBBM_0_LO ,REG_A5XX_RBBM_PERFCTR_RBBM_0_HI ); *out_sample_rate =clk_get_rate (gpu->core_clk); -pm_runtime_put (&gpu->pdev->dev); -return busy_cycles; }
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +7 -6
@@ -102,7 +102,8 @@ bool a6xx_gmu_gx_is_on(struct a6xx_gmu *gmu) A6XX_GMU_SPTPRAC_PWR_CLK_STATUS_GX_HM_CLK_OFF)); } -void a6xx_gmu_set_freq (struct msm_gpu *gpu,struct dev_pm_opp *opp) +void a6xx_gmu_set_freq (struct msm_gpu *gpu,struct dev_pm_opp *opp, +bool suspended) {struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu);struct a6xx_gpu *a6xx_gpu =to_a6xx_gpu (adreno_gpu);
@@ -127,15 +128,16 @@ void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp)/* * This can get called from devfreq while the hardware is idle. Don't -* bring up the power if it isn't already active +* bring up the power if it isn't already active. All we're doing here +* is updating the frequency so that when we come back online we're at +* the right rate. */ -if (pm_runtime_get_if_in_use (gmu->dev) ==0 ) +if (suspended)return ;if (!gmu->legacy) {a6xx_hfi_set_freq (gmu, perf_index);dev_pm_opp_set_opp (&gpu->pdev->dev, opp); -pm_runtime_put (gmu->dev);return ; }
@@ -159,7 +161,6 @@ void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp)dev_err (gmu->dev,"GMU set GPU frequency error: %d\n" , ret);dev_pm_opp_set_opp (&gpu->pdev->dev, opp); -pm_runtime_put (gmu->dev); }unsigned long a6xx_gmu_get_freq (struct msm_gpu *gpu)
@@ -895,7 +896,7 @@ static void a6xx_gmu_set_initial_freq(struct msm_gpu *gpu, struct a6xx_gmu *gmu)return ; gmu->freq =0 ;/* so a6xx_gmu_set_freq() doesn't exit early */ -a6xx_gmu_set_freq (gpu, gpu_opp); +a6xx_gmu_set_freq (gpu, gpu_opp, false);dev_pm_opp_put (gpu_opp); }
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +3 -9
@@ -1658,27 +1658,21 @@ static u64 a6xx_gpu_busy(struct msm_gpu *gpu, unsigned long *out_sample_rate)/* 19.2MHz */ *out_sample_rate =19200000 ; -/* Only read the gpu busy if the hardware is already active */ -if (pm_runtime_get_if_in_use (a6xx_gpu->gmu.dev) ==0 ) -return 0 ; - busy_cycles =gmu_read64 (&a6xx_gpu->gmu,REG_A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_0_L ,REG_A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_0_H ); - -pm_runtime_put (a6xx_gpu->gmu.dev); -return busy_cycles; } -static void a6xx_gpu_set_freq (struct msm_gpu *gpu,struct dev_pm_opp *opp) +static void a6xx_gpu_set_freq (struct msm_gpu *gpu,struct dev_pm_opp *opp, +bool suspended) {struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu);struct a6xx_gpu *a6xx_gpu =to_a6xx_gpu (adreno_gpu);mutex_lock (&a6xx_gpu->gmu.lock); -a6xx_gmu_set_freq (gpu, opp); +a6xx_gmu_set_freq (gpu, opp, suspended);mutex_unlock (&a6xx_gpu->gmu.lock); }
drivers/gpu/drm/msm/adreno/a6xx_gpu.h +2 -1
@@ -77,7 +77,8 @@ void a6xx_gmu_clear_oob(struct a6xx_gmu *gmu, enum a6xx_gmu_oob_state state);int a6xx_gmu_init (struct a6xx_gpu *a6xx_gpu,struct device_node *node);void a6xx_gmu_remove (struct a6xx_gpu *a6xx_gpu); -void a6xx_gmu_set_freq (struct msm_gpu *gpu,struct dev_pm_opp *opp); +void a6xx_gmu_set_freq (struct msm_gpu *gpu,struct dev_pm_opp *opp, +bool suspended);unsigned long a6xx_gmu_get_freq (struct msm_gpu *gpu); void a6xx_show(struct msm_gpu *gpu, struct msm_gpu_state *state,
drivers/gpu/drm/msm/msm_gpu.h +10 -1
@@ -63,11 +63,14 @@ struct msm_gpu_funcs {/* for generation specific debugfs: */ void (*debugfs_init)(struct msm_gpu *gpu,struct drm_minor *minor);#endif +/* note: gpu_busy() can assume that we have been pm_resumed */ u64 (*gpu_busy)(struct msm_gpu *gpu,unsigned long *out_sample_rate);struct msm_gpu_state *(*gpu_state_get)(struct msm_gpu *gpu);int (*gpu_state_put)(struct msm_gpu_state *state);unsigned long (*gpu_get_freq)(struct msm_gpu *gpu); -void (*gpu_set_freq)(struct msm_gpu *gpu,struct dev_pm_opp *opp); +/* note: gpu_set_freq() can assume that we have been pm_resumed */ +void (*gpu_set_freq)(struct msm_gpu *gpu,struct dev_pm_opp *opp, +bool suspended);struct msm_gem_address_space *(*create_address_space) (struct msm_gpu *gpu,struct platform_device *pdev);struct msm_gem_address_space *(*create_private_address_space)
@@ -91,6 +94,9 @@ struct msm_gpu_devfreq {/** devfreq: devfreq instance */ struct devfreq *devfreq; +/** lock: lock for "suspended", "busy_cycles", and "time" */ +struct mutex lock; +/** * idle_constraint: *
@@ -134,6 +140,9 @@ struct msm_gpu_devfreq {* elapsed */ struct msm_hrtimer_work boost_work; + +/** suspended: tracks if we're suspended */ +bool suspended; };struct msm_gpu {
drivers/gpu/drm/msm/msm_gpu_devfreq.c +31 -8
@@ -20,6 +20,7 @@ static int msm_devfreq_target(struct device *dev, unsigned long *freq, u32 flags) {struct msm_gpu *gpu =dev_to_gpu (dev); +struct msm_gpu_devfreq *df = &gpu->devfreq;struct dev_pm_opp *opp;/*
@@ -32,10 +33,13 @@ static int msm_devfreq_target(struct device *dev, unsigned long *freq,trace_msm_gpu_freq_change (dev_pm_opp_get_freq (opp)); -if (gpu->funcs->gpu_set_freq) - gpu->funcs->gpu_set_freq (gpu, opp); -else +if (gpu->funcs->gpu_set_freq) { +mutex_lock (&df->lock); + gpu->funcs->gpu_set_freq (gpu, opp, df->suspended); +mutex_unlock (&df->lock); + }else {clk_set_rate (gpu->core_clk, *freq); + }dev_pm_opp_put (opp);
@@ -58,15 +62,24 @@ static void get_raw_dev_status(struct msm_gpu *gpu,unsigned long sample_rate;ktime_t time; +mutex_lock (&df->lock); + status->current_frequency =get_freq (gpu); - busy_cycles = gpu->funcs->gpu_busy (gpu, &sample_rate); time =ktime_get (); - - busy_time = busy_cycles - df->busy_cycles; status->total_time =ktime_us_delta (time, df->time); + df->time = time; +if (df->suspended) { +mutex_unlock (&df->lock); + status->busy_time =0 ; +return ; + } + + busy_cycles = gpu->funcs->gpu_busy (gpu, &sample_rate); + busy_time = busy_cycles - df->busy_cycles; df->busy_cycles = busy_cycles; - df->time = time; + +mutex_unlock (&df->lock); busy_time *=USEC_PER_SEC ;do_div (busy_time, sample_rate);
@@ -175,6 +188,8 @@ void msm_devfreq_init(struct msm_gpu *gpu)if (!gpu->funcs->gpu_busy)return ; +mutex_init (&df->lock); +dev_pm_qos_add_request (&gpu->pdev->dev, &df->idle_freq,DEV_PM_QOS_MAX_FREQUENCY ,PM_QOS_MAX_FREQUENCY_DEFAULT_VALUE );
@@ -244,12 +259,16 @@ void msm_devfreq_cleanup(struct msm_gpu *gpu)void msm_devfreq_resume (struct msm_gpu *gpu) {struct msm_gpu_devfreq *df = &gpu->devfreq; +unsigned long sample_rate;if (!has_devfreq (gpu))return ; - df->busy_cycles =0 ; +mutex_lock (&df->lock); + df->busy_cycles = gpu->funcs->gpu_busy (gpu, &sample_rate); df->time =ktime_get (); + df->suspended = false; +mutex_unlock (&df->lock);devfreq_resume_device (df->devfreq); }
@@ -261,6 +280,10 @@ void msm_devfreq_suspend(struct msm_gpu *gpu)if (!has_devfreq (gpu))return ; +mutex_lock (&df->lock); + df->suspended = true; +mutex_unlock (&df->lock); +devfreq_suspend_device (df->devfreq);cancel_idle_work (df);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 422/1095 libbpf, riscv: Use a0 for RC register
In reply to Greg Kroah-HartmanFrom: Yixun Lan <[email protected]>
[ Upstream commit 935dc35c75318fa213d26808ad8bb130fb0b486e ]
According to the RISC-V calling convention register usage here [0], a0 is used as return value register, so rename it to make it consistent with the spec.
[0] section 18.2, table 18.2
https://riscv.org/wp-content/uploads/2015/01/riscv-calling.pdf
--- tools/lib/bpf/bpf_tracing.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/bpf/bpf_tracing.h +1 -1
@@ -227,7 +227,7 @@ struct pt_regs___arm64 {#define __PT_PARM5_REG a4#define __PT_RET_REG ra#define __PT_FP_REG s0 -#define __PT_RC_REG a5 +#define __PT_RC_REG a0#define __PT_SP_REG sp#define __PT_IP_REG pc/* riscv does not select ARCH_HAS_SYSCALL_WRAPPER. */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 423/1095 drm/msm/mdp5: Fix global state lock backoff
In reply to Greg Kroah-HartmanFrom: Rob Clark <[email protected]>
[ Upstream commit 92ef86ab513593c6329d04146e61f9a670e72fc5 ]
We need to grab the lock after the early return for !hwpipe case. Otherwise, we could have hit contention yet still returned 0.
Fixes an issue that the new CONFIG_DRM_DEBUG_MODESET_LOCK stuff flagged in CI:
WARNING: CPU: 0 PID: 282 at drivers/gpu/drm/drm_modeset_lock.c:296 drm_modeset_lock+0xf8/0x154
Modules linked in:
CPU: 0 PID: 282 Comm: kms_cursor_lega Tainted: G W 5.19.0-rc2-15930-g875cc8bc536a #1
Hardware name: Qualcomm Technologies, Inc. DB820c (DT)
pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : drm_modeset_lock+0xf8/0x154
lr : drm_atomic_get_private_obj_state+0x84/0x170
sp : ffff80000cfab6a0
x29: ffff80000cfab6a0 x28: 0000000000000000 x27: ffff000083bc4d00
x26: 0000000000000038 x25: 0000000000000000 x24: ffff80000957ca58
x23: 0000000000000000 x22: ffff000081ace080 x21: 0000000000000001
x20: ffff000081acec18 x19: ffff80000cfabb80 x18: 0000000000000038
x17: 0000000000000000 x16: 0000000000000000 x15: fffffffffffea0d0
x14: 0000000000000000 x13: 284e4f5f4e524157 x12: 5f534b434f4c5f47
x11: ffff80000a386aa8 x10: 0000000000000029 x9 : ffff80000cfab610
x8 : 0000000000000029 x7 : 0000000000000014 x6 : 0000000000000000
x5 : 0000000000000001 x4 : ffff8000081ad904 x3 : 0000000000000029
x2 : ffff0000801db4c0 x1 : ffff80000cfabb80 x0 : ffff000081aceb58
Call trace:
drm_modeset_lock+0xf8/0x154
drm_atomic_get_private_obj_state+0x84/0x170
mdp5_get_global_state+0x54/0x6c
mdp5_pipe_release+0x2c/0xd4
mdp5_plane_atomic_check+0x2ec/0x414
drm_atomic_helper_check_planes+0xd8/0x210
drm_atomic_helper_check+0x54/0xb0
...
---[ end trace 0000000000000000 ]---
drm_modeset_lock attempting to lock a contended lock without backoff:
drm_modeset_lock+0x148/0x154
mdp5_get_global_state+0x30/0x6c
mdp5_pipe_release+0x2c/0xd4
mdp5_plane_atomic_check+0x290/0x414
drm_atomic_helper_check_planes+0xd8/0x210
drm_atomic_helper_check+0x54/0xb0
drm_atomic_check_only+0x4b0/0x8f4
drm_atomic_commit+0x68/0xe0Patchwork: https://patchwork.freedesktop.org/patch/492701/
--- drivers/gpu/drm/msm/disp/mdp5/mdp5_pipe.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/disp/mdp5/mdp5_pipe.c +2 -1
@@ -123,12 +123,13 @@ int mdp5_pipe_release(struct drm_atomic_state *s, struct mdp5_hw_pipe *hwpipe) {struct msm_drm_private *priv = s->dev->dev_private;struct mdp5_kms *mdp5_kms =to_mdp5_kms (to_mdp_kms (priv->kms)); -struct mdp5_global_state *state =mdp5_get_global_state (s); +struct mdp5_global_state *state;struct mdp5_hw_pipe_state *new_state;if (!hwpipe)return 0 ; + state =mdp5_get_global_state (s);if (IS_ERR (state))return PTR_ERR (state);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 424/1095 drm/radeon: avoid bogus "vram limit (0) must be a power of 2" warning
In reply to Greg Kroah-HartmanFrom: Mateusz Jończyk <[email protected]>
[ Upstream commit 9da2902609f7519c48eda84f953f72fee53f2b71 ]
I was getting the following message on boot on Linux 5.19-rc5:
radeon 0000:01:05.0: vram limit (0) must be a power of 2
(I didn't use any radeon.vramlimit commandline parameter).
This is caused by
commit 8c2d34eb53b9 ("drm/radeon: use kernel is_power_of_2 rather than local version") which removed radeon_check_pot_argument() and converted its users to is_power_of_2(). The two functions differ in its handling of 0, which is the default value of radeon_vram_limit: radeon_check_pot_argument() "incorrectly" considered it a power of 2, while is_power_of_2() does not.
An appropriate conditional silences the warning message.
It is not necessary to add a similar test to other callers of is_power_of_2() in radeon_device.c. The matching commit in amdgpu:
commit 761175078466 ("drm/amdgpu: use kernel is_power_of_2 rather than local version") is unaffected by this bug.
Tested on Radeon HD 3200.
Not ccing stable, this is not serious enough.
--- drivers/gpu/drm/radeon/radeon_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/radeon/radeon_device.c +1 -1
@@ -1113,7 +1113,7 @@ static int radeon_gart_size_auto(enum radeon_family family)static void radeon_check_arguments (struct radeon_device *rdev) {/* vramlimit must be a power of two */ -if (!is_power_of_2 (radeon_vram_limit)) { +if (radeon_vram_limit !=0 && !is_power_of_2 (radeon_vram_limit)) {dev_warn (rdev->dev,"vram limit (%d) must be a power of 2\n" , radeon_vram_limit); radeon_vram_limit =0 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 425/1095 crypto: hisilicon/sec - dont sleep when in softirq
In reply to Greg Kroah-HartmanFrom: Zhengchao Shao <[email protected]>
[ Upstream commit 02884a4f12de11f54d4ca67a07dd1f111d96fdbd ]
When kunpeng920 encryption driver is used to deencrypt and decrypt packets during the softirq, it is not allowed to use mutex lock. The kernel will report the following error:
BUG: scheduling while atomic: swapper/57/0/0x00000300 Call trace: dump_backtrace+0x0/0x1e4 show_stack+0x20/0x2c dump_stack+0xd8/0x140 __schedule_bug+0x68/0x80 __schedule+0x728/0x840 schedule+0x50/0xe0 schedule_preempt_disabled+0x18/0x24 __mutex_lock.constprop.0+0x594/0x5dc __mutex_lock_slowpath+0x1c/0x30 mutex_lock+0x50/0x60 sec_request_init+0x8c/0x1a0 [hisi_sec2] sec_process+0x28/0x1ac [hisi_sec2] sec_skcipher_crypto+0xf4/0x1d4 [hisi_sec2] sec_skcipher_encrypt+0x1c/0x30 [hisi_sec2] crypto_skcipher_encrypt+0x2c/0x40 crypto_authenc_encrypt+0xc8/0xfc [authenc] crypto_aead_encrypt+0x2c/0x40 echainiv_encrypt+0x144/0x1a0 [echainiv] crypto_aead_encrypt+0x2c/0x40 esp_output_tail+0x348/0x5c0 [esp4] esp_output+0x120/0x19c [esp4] xfrm_output_one+0x25c/0x4d4 xfrm_output_resume+0x6c/0x1fc xfrm_output+0xac/0x3c0 xfrm4_output+0x64/0x130 ip_build_and_send_pkt+0x158/0x20c tcp_v4_send_synack+0xdc/0x1f0 tcp_conn_request+0x7d0/0x994 tcp_v4_conn_request+0x58/0x6c tcp_v6_conn_request+0xf0/0x100 tcp_rcv_state_process+0x1cc/0xd60 tcp_v4_do_rcv+0x10c/0x250 tcp_v4_rcv+0xfc4/0x10a4 ip_protocol_deliver_rcu+0xf4/0x200 ip_local_deliver_finish+0x58/0x70 ip_local_deliver+0x68/0x120 ip_sublist_rcv_finish+0x70/0x94 ip_list_rcv_finish.constprop.0+0x17c/0x1d0 ip_sublist_rcv+0x40/0xb0 ip_list_rcv+0x140/0x1dc __netif_receive_skb_list_core+0x154/0x28c __netif_receive_skb_list+0x120/0x1a0 netif_receive_skb_list_internal+0xe4/0x1f0 napi_complete_done+0x70/0x1f0 gro_cell_poll+0x9c/0xb0 napi_poll+0xcc/0x264 net_rx_action+0xd4/0x21c __do_softirq+0x130/0x358 irq_exit+0x11c/0x13c __handle_domain_irq+0x88/0xf0 gic_handle_irq+0x78/0x2c0 el1_irq+0xb8/0x140 arch_cpu_idle+0x18/0x40 default_idle_call+0x5c/0x1c0 cpuidle_idle_call+0x174/0x1b0 do_idle+0xc8/0x160 cpu_startup_entry+0x30/0x11c secondary_start_kernel+0x158/0x1e4
softirq: huh, entered softirq 3 NET_RX 0000000093774ee4 with preempt_count 00000100, exited with fffffe00?
--- drivers/crypto/hisilicon/sec2/sec.h | 2 +- drivers/crypto/hisilicon/sec2/sec_crypto.c | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-)
drivers/crypto/hisilicon/sec2/sec.h +1 -1
@@ -119,7 +119,7 @@ struct sec_qp_ctx {struct idr req_idr;struct sec_alg_res res[QM_Q_DEPTH ];struct sec_ctx *ctx; -struct mutex req_lock; +spinlock_t req_lock;struct list_head backlog;struct hisi_acc_sgl_pool *c_in_pool;struct hisi_acc_sgl_pool *c_out_pool;
drivers/crypto/hisilicon/sec2/sec_crypto.c +10 -10
@@ -127,11 +127,11 @@ static int sec_alloc_req_id(struct sec_req *req, struct sec_qp_ctx *qp_ctx) {int req_id; -mutex_lock (&qp_ctx->req_lock); +spin_lock_bh (&qp_ctx->req_lock); req_id =idr_alloc_cyclic (&qp_ctx->req_idr,NULL ,0 ,QM_Q_DEPTH ,GFP_ATOMIC ); -mutex_unlock (&qp_ctx->req_lock); +spin_unlock_bh (&qp_ctx->req_lock);if (unlikely (req_id <0 )) {dev_err (req->ctx->dev,"alloc req id fail!\n" );return req_id;
@@ -156,9 +156,9 @@ static void sec_free_req_id(struct sec_req *req) qp_ctx->req_list[req_id] =NULL ; req->qp_ctx =NULL ; -mutex_lock (&qp_ctx->req_lock); +spin_lock_bh (&qp_ctx->req_lock);idr_remove (&qp_ctx->req_idr, req_id); -mutex_unlock (&qp_ctx->req_lock); +spin_unlock_bh (&qp_ctx->req_lock); }static u8 pre_parse_finished_bd (struct bd_status *status,void *resp)
@@ -273,7 +273,7 @@ static int sec_bd_send(struct sec_ctx *ctx, struct sec_req *req) !(req->flag & CRYPTO_TFM_REQ_MAY_BACKLOG))return -EBUSY ; -mutex_lock (&qp_ctx->req_lock); +spin_lock_bh (&qp_ctx->req_lock); ret =hisi_qp_send (qp_ctx->qp, &req->sec_sqe); if (ctx->fake_req_limit <=
@@ -281,10 +281,10 @@ static int sec_bd_send(struct sec_ctx *ctx, struct sec_req *req)list_add_tail (&req->backlog_head, &qp_ctx->backlog);atomic64_inc (&ctx->sec->debug.dfx.send_cnt);atomic64_inc (&ctx->sec->debug.dfx.send_busy_cnt); -mutex_unlock (&qp_ctx->req_lock); +spin_unlock_bh (&qp_ctx->req_lock);return -EBUSY ; } -mutex_unlock (&qp_ctx->req_lock); +spin_unlock_bh (&qp_ctx->req_lock);if (unlikely (ret == -EBUSY ))return -ENOBUFS ;
@@ -487,7 +487,7 @@ static int sec_create_qp_ctx(struct hisi_qm *qm, struct sec_ctx *ctx, qp->req_cb = sec_req_cb; -mutex_init (&qp_ctx->req_lock); +spin_lock_init (&qp_ctx->req_lock);idr_init (&qp_ctx->req_idr);INIT_LIST_HEAD (&qp_ctx->backlog);
@@ -1382,7 +1382,7 @@ static struct sec_req *sec_back_req_clear(struct sec_ctx *ctx, {struct sec_req *backlog_req =NULL ; -mutex_lock (&qp_ctx->req_lock); +spin_lock_bh (&qp_ctx->req_lock);if (ctx->fake_req_limit >=atomic_read (&qp_ctx->qp->qp_status.used) && !list_empty (&qp_ctx->backlog)) {
@@ -1390,7 +1390,7 @@ static struct sec_req *sec_back_req_clear(struct sec_ctx *ctx, typeof(*backlog_req), backlog_head);list_del (&backlog_req->backlog_head); } -mutex_unlock (&qp_ctx->req_lock); +spin_unlock_bh (&qp_ctx->req_lock);return backlog_req; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 426/1095 crypto: hisilicon - Kunpeng916 crypto driver dont sleep when in softirq
In reply to Greg Kroah-HartmanFrom: Zhengchao Shao <[email protected]>
[ Upstream commit 68740ab505431f268dc1ee26a54b871e75f0ddaa ]
When kunpeng916 encryption driver is used to deencrypt and decrypt packets during the softirq, it is not allowed to use mutex lock.
--- drivers/crypto/hisilicon/sec/sec_algs.c | 14 +++++++------- drivers/crypto/hisilicon/sec/sec_drv.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/crypto/hisilicon/sec/sec_algs.c +7 -7
@@ -449,7 +449,7 @@ static void sec_skcipher_alg_callback(struct sec_bd_info *sec_resp,*/ } -mutex_lock (&ctx->queue->queuelock); +spin_lock_bh (&ctx->queue->queuelock);/* Put the IV in place for chained cases */ switch (ctx->cipher_alg) {case SEC_C_AES_CBC_128 :
@@ -509,7 +509,7 @@ static void sec_skcipher_alg_callback(struct sec_bd_info *sec_resp,list_del (&backlog_req->backlog_head); } } -mutex_unlock (&ctx->queue->queuelock); +spin_unlock_bh (&ctx->queue->queuelock);mutex_lock (&sec_req->lock);list_del (&sec_req_el->head);
@@ -798,7 +798,7 @@ static int sec_alg_skcipher_crypto(struct skcipher_request *skreq,*/ /* Grab a big lock for a long time to avoid concurrency issues */ -mutex_lock (&queue->queuelock); +spin_lock_bh (&queue->queuelock);/* * Can go on to queue if we have space in either:
@@ -814,15 +814,15 @@ static int sec_alg_skcipher_crypto(struct skcipher_request *skreq, ret = -EBUSY ;if ((skreq->base.flags &CRYPTO_TFM_REQ_MAY_BACKLOG )) {list_add_tail (&sec_req->backlog_head, &ctx->backlog); -mutex_unlock (&queue->queuelock); +spin_unlock_bh (&queue->queuelock); goto out; } -mutex_unlock (&queue->queuelock); +spin_unlock_bh (&queue->queuelock); goto err_free_elements; } ret =sec_send_request (sec_req, queue); -mutex_unlock (&queue->queuelock); +spin_unlock_bh (&queue->queuelock);if (ret) goto err_free_elements;
@@ -881,7 +881,7 @@ static int sec_alg_skcipher_init(struct crypto_skcipher *tfm)if (IS_ERR (ctx->queue))return PTR_ERR (ctx->queue); -mutex_init (&ctx->queue->queuelock); +spin_lock_init (&ctx->queue->queuelock); ctx->queue->havesoftqueue = false;return 0 ;
drivers/crypto/hisilicon/sec/sec_drv.h +1 -1
@@ -347,7 +347,7 @@ struct sec_queue {DECLARE_BITMAP (unprocessed,SEC_QUEUE_LEN ); DECLARE_KFIFO_PTR(softqueue, typeof(struct sec_request_el *));bool havesoftqueue; -struct mutex queuelock; +spinlock_t queuelock;void *shadow[SEC_QUEUE_LEN ]; };
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 427/1095 media: platform: mtk-mdp: Fix mdp_ipi_comm structure alignment
In reply to Greg Kroah-HartmanFrom: AngeloGioacchino Del Regno <[email protected]>
[ Upstream commit ab14c99c035da7156a3b66fa171171295bc4b89a ]
The mdp_ipi_comm structure defines a command that is either PROCESS (start processing) or DEINIT (destroy instance); we are using this one to send PROCESS or DEINIT commands from Linux to an MDP instance through a VPU write but, while the first wants us to stay 4-bytes aligned, the VPU instead requires an 8-bytes data alignment.
Keeping in mind that these commands are executed immediately after sending them (hence not chained with others before the VPU/MDP "actually" start executing), it is fine to simply add a padding of 4 bytes to this structure: this keeps the same performance as before, as we're still stack-allocating it, while avoiding hackery inside of mtk-vpu to ensure alignment bringing a definitely bigger performance impact.
--- drivers/media/platform/mediatek/mdp/mtk_mdp_ipi.h | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/platform/mediatek/mdp/mtk_mdp_ipi.h +2 -0
@@ -40,12 +40,14 @@ struct mdp_ipi_init {* @ipi_id : IPI_MDP * @ap_inst : AP mtk_mdp_vpu address * @vpu_inst_addr : VPU MDP instance address +* @padding : Alignment padding */ struct mdp_ipi_comm {uint32_t msg_id;uint32_t ipi_id;uint64_t ap_inst;uint32_t vpu_inst_addr; +uint32_t padding; };/**
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 428/1095 media: amphion: release core lock before reset vpu core
In reply to Greg Kroah-HartmanFrom: Ming Qian <[email protected]>
[ Upstream commit a621cc4bed97e49f5a8019f5215dec7e208a7c4d ]
In reset vpu core, driver will wait for a response event, but if there are still some events unhandled,
they will be handled first, driver may acquire core lock for that. So if we do reset in core lock, it may led to reset timeout.
--- drivers/media/platform/amphion/vpu_core.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/media/platform/amphion/vpu_core.c +6 -1
@@ -455,8 +455,13 @@ int vpu_inst_unregister(struct vpu_inst *inst) }vpu_core_check_hang (core);if (core->state ==VPU_CORE_HANG && !core->instance_mask) { +int err; +dev_info (core->dev,"reset hang core\n" ); -if (!vpu_core_sw_reset (core)) { +mutex_unlock (&core->lock); + err =vpu_core_sw_reset (core); +mutex_lock (&core->lock); +if (!err) { core->state =VPU_CORE_ACTIVE ; core->hang_mask =0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 429/1095 drm/msm/dpu: Fix for non-visible planes
In reply to Greg Kroah-HartmanFrom: Rob Clark <[email protected]>
[ Upstream commit cb77085b1f0a86ef9dfba86b5f3ed6c3340c2ea3 ]
Fixes kms_cursor_crc --run-subtest cursor-offscreen.. when the cursor moves offscreen the plane becomes non-visible, so we need to skip over it in crtc atomic test and mixer setup.
Patchwork: https://patchwork.freedesktop.org/patch/492819/
--- drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c +6 -0
@@ -361,6 +361,9 @@ static void _dpu_crtc_blend_setup_mixer(struct drm_crtc *crtc,if (!state)continue ; +if (!state->visible) +continue ; + pstate =to_dpu_plane_state (state); fb = state->fb;
@@ -1125,6 +1128,9 @@ static int dpu_crtc_atomic_check(struct drm_crtc *crtc,if (cnt >=DPU_STAGE_MAX *4 )continue ; +if (!pstate->visible) +continue ; + pstates[cnt].dpu_pstate = dpu_pstate; pstates[cnt].drm_pstate = pstate; pstates[cnt].stage = pstate->normalized_zpos;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 430/1095 media: mediatek: vcodec: Initialize decoder parameters for each instance
In reply to Greg Kroah-HartmanFrom: Chen-Yu Tsai <[email protected]>
[ Upstream commit fe3d651627d61210c6905339e5281d3b9db75033 ]
The decoder parameters are stored in each instance's context data. This needs to be initialized per-instance, but a previous fix incorrectly changed it to only be initialized for the first opened instance. This resulted in subsequent instances not correctly signaling the requirement for the Requests API.
Fix this by calling the initializing function outside of the v4l2_fh_is_singular() conditional block.
--- drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c +2 -1
@@ -211,11 +211,12 @@ static int fops_vcodec_open(struct file *file) dev->dec_capability =mtk_vcodec_fw_get_vdec_capa (dev->fw_handler); - ctx->dev->vdec_pdata->init_vdec_params (ctx);mtk_v4l2_debug (0 ,"decoder capability %x" , dev->dec_capability); } + ctx->dev->vdec_pdata->init_vdec_params (ctx); +list_add (&ctx->list, &dev->ctx_list);mutex_unlock (&dev->dev_mutex);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 431/1095 media: amphion: defer setting last_buffer_dequeued until resolution changes are processed
In reply to Greg Kroah-HartmanFrom: Ming Qian <[email protected]>
[ Upstream commit afba6e20801ad9a2f863c52c21e609e021269d83 ]
Don't set last_buffer_dequeued during dynamic resolution change, otherwise it may be cleared in handling resolution change, as streamoff may be called in dynamic resolution change.
Normally, this does not happen.
But we encounter a special testcase,
User issue V4L2_DEC_CMD_STOP after enqueue one buffer that only contains codec config header, but not any frame data. So VPU report the parsed resolution, then report the eos event.
So driver should notify user to handle resolution change first, after it's handled, set the last_buffer_dequeued. then the user can exit decoding normally.
Otherwise the user may be stalled.
--- drivers/media/platform/amphion/vdec.c | 36 ++++++++++++++--------- drivers/media/platform/amphion/vpu_v4l2.c | 2 +- 2 files changed, 23 insertions(+), 15 deletions(-)
drivers/media/platform/amphion/vdec.c +22 -14
@@ -174,16 +174,6 @@ static int vdec_ctrl_init(struct vpu_inst *inst)return 0 ; } -static void vdec_set_last_buffer_dequeued (struct vpu_inst *inst) -{ -struct vdec_t *vdec = inst->priv; - -if (vdec->eos_received) { -if (!vpu_set_last_buffer_dequeued (inst)) - vdec->eos_received--; - } -} -static void vdec_handle_resolution_change (struct vpu_inst *inst) {struct vdec_t *vdec = inst->priv;
@@ -230,6 +220,21 @@ static int vdec_update_state(struct vpu_inst *inst, enum vpu_codec_state state,return 0 ; } +static void vdec_set_last_buffer_dequeued (struct vpu_inst *inst) +{ +struct vdec_t *vdec = inst->priv; + +if (inst->state ==VPU_CODEC_STATE_DYAMIC_RESOLUTION_CHANGE ) +return ; + +if (vdec->eos_received) { +if (!vpu_set_last_buffer_dequeued (inst)) { + vdec->eos_received--; +vdec_update_state (inst,VPU_CODEC_STATE_DRAIN ,0 ); + } + } +} +static int vdec_querycap (struct file *file,void *fh,struct v4l2_capability *cap) {strscpy (cap->driver,"amphion-vpu" ,sizeof (cap->driver));
@@ -489,6 +494,8 @@ static int vdec_drain(struct vpu_inst *inst)static int vdec_cmd_start (struct vpu_inst *inst) { +struct vdec_t *vdec = inst->priv; +switch (inst->state) {case VPU_CODEC_STATE_STARTED :case VPU_CODEC_STATE_DRAIN :
@@ -499,6 +506,8 @@ static int vdec_cmd_start(struct vpu_inst *inst)break ; }vpu_process_capture_buffer (inst); +if (vdec->eos_received) +vdec_set_last_buffer_dequeued (inst);return 0 ; }
@@ -1188,7 +1197,6 @@ static void vdec_event_eos(struct vpu_inst *inst) vdec->eos_received++; vdec->fixed_fmt = false; inst->min_buffer_cap =VDEC_MIN_BUFFER_CAP ; -vdec_update_state (inst,VPU_CODEC_STATE_DRAIN ,0 );vdec_set_last_buffer_dequeued (inst);vpu_inst_unlock (inst); }
@@ -1470,10 +1478,10 @@ static int vdec_stop_session(struct vpu_inst *inst, u32 type)vdec_update_state (inst,VPU_CODEC_STATE_SEEK ,0 ); vdec->drain =0 ; }else { -if (inst->state !=VPU_CODEC_STATE_DYAMIC_RESOLUTION_CHANGE ) +if (inst->state !=VPU_CODEC_STATE_DYAMIC_RESOLUTION_CHANGE ) {vdec_abort (inst); - - vdec->eos_received =0 ; + vdec->eos_received =0 ; + }vdec_clear_slots (inst); }
drivers/media/platform/amphion/vpu_v4l2.c +1 -1
@@ -440,8 +440,8 @@ static int vpu_vb2_start_streaming(struct vb2_queue *q, unsigned int count) fmt->sizeimage[1 ], fmt->bytesperline[1 ], fmt->sizeimage[2 ], fmt->bytesperline[2 ], q->num_buffers); - ret =call_vop (inst, start, q->type);vb2_clear_last_buffer_dequeued (q); + ret =call_vop (inst, start, q->type);if (ret)vpu_vb2_buffers_return (inst, q->type,VB2_BUF_STATE_QUEUED );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 432/1095 media: hantro: Add support for Hantro G1 on RK356x
In reply to Greg Kroah-HartmanFrom: Piotr Oniszczuk <[email protected]>
[ Upstream commit 5f6bfab6da6531238e899fdf29efd6d0185adc3e ]
RK356x has Hantro G1 video decoder capable to decode MPEG2/H.264/VP8 video formats.
This patch adds support for RK356x family in existing Hantro video decoder kernel driver.
Tested on [1] with FFmpeg v4l2_request code taken from [2] with MPEG2, H.642 and VP8 samples with results [3].
[1] https://github.com/warpme/minimyth2
[2] https://github.com/LibreELEC/LibreELEC.tv/blob/master/packages/multimedia/ffmpeg/patches/v4l2-request/ffmpeg-001-v4l2-request.patch
[3] https://github.com/warpme/minimyth2/blob/master/video-test-summary.txt
--- drivers/staging/media/hantro/hantro_drv.c | 1 + drivers/staging/media/hantro/hantro_hw.h | 1 + drivers/staging/media/hantro/rockchip_vpu_hw.c | 14 ++++++++++++++ 3 files changed, 16 insertions(+)
drivers/staging/media/hantro/hantro_drv.c +1 -0
@@ -638,6 +638,7 @@ static const struct of_device_id of_hantro_match[] = { { .compatible = "rockchip,rk3288-vpu", .data = &rk3288_vpu_variant, }, { .compatible = "rockchip,rk3328-vpu", .data = &rk3328_vpu_variant, }, { .compatible = "rockchip,rk3399-vpu", .data = &rk3399_vpu_variant, }, + { .compatible = "rockchip,rk3568-vpu", .data = &rk3568_vpu_variant, }, #endif #ifdef CONFIG_VIDEO_HANTRO_IMX8M { .compatible = "nxp,imx8mm-vpu-g1", .data = &imx8mm_vpu_g1_variant, },
drivers/staging/media/hantro/hantro_hw.h +1 -0
@@ -300,6 +300,7 @@ extern const struct hantro_variant rk3066_vpu_variant;extern const struct hantro_variant rk3288_vpu_variant;extern const struct hantro_variant rk3328_vpu_variant;extern const struct hantro_variant rk3399_vpu_variant; +extern const struct hantro_variant rk3568_vpu_variant;extern const struct hantro_variant sama5d4_vdec_variant;extern const struct hantro_variant sunxi_vpu_variant;
drivers/staging/media/hantro/rockchip_vpu_hw.c +14 -0
@@ -545,6 +545,20 @@ const struct hantro_variant rk3399_vpu_variant = { .num_clocks = ARRAY_SIZE(rockchip_vpu_clk_names) }; +const struct hantro_variant rk3568_vpu_variant = { + .dec_offset =0x400 , + .dec_fmts = rk3399_vpu_dec_fmts, + .num_dec_fmts =ARRAY_SIZE (rk3399_vpu_dec_fmts), + .codec =HANTRO_MPEG2_DECODER | +HANTRO_VP8_DECODER |HANTRO_H264_DECODER , + .codec_ops = rk3399_vpu_codec_ops, + .irqs = rockchip_vdpu2_irqs, + .num_irqs =ARRAY_SIZE (rockchip_vdpu2_irqs), + .init = rockchip_vpu_hw_init, + .clk_names = rockchip_vpu_clk_names, + .num_clocks =ARRAY_SIZE (rockchip_vpu_clk_names) +}; +const struct hantro_variant px30_vpu_variant = { .enc_offset =0x0 , .enc_fmts = rockchip_vpu_enc_fmts,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 433/1095 media: staging: media: hantro: Fix typos
In reply to Greg Kroah-HartmanFrom: Sebastian Fricke <[email protected]>
[ Upstream commit d8f6f1c56d5469e22eeb7cc1f3580b29e2f0fef5 ]
Fix typos in comments within the Hantro driver.
--- drivers/staging/media/hantro/hantro_g2_hevc_dec.c | 2 +- drivers/staging/media/hantro/hantro_hevc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/media/hantro/hantro_g2_hevc_dec.c +1 -1
@@ -401,7 +401,7 @@ static int set_ref(struct hantro_ctx *ctx)set_ref_pic_list (ctx); -/* We will only keep the references picture that are still used */ +/* We will only keep the reference pictures that are still used */ ctx->hevc_dec.ref_bufs_used =0 ;/* Set up addresses of DPB buffers */
drivers/staging/media/hantro/hantro_hevc.c +1 -1
@@ -59,7 +59,7 @@ dma_addr_t hantro_hevc_get_ref_buf(struct hantro_ctx *ctx,struct hantro_hevc_dec_hw_ctx *hevc_dec = &ctx->hevc_dec;int i; -/* Find the reference buffer in already know ones */ +/* Find the reference buffer in already known ones */ for (i =0 ; i <NUM_REF_PICTURES ; i++) {if (hevc_dec->ref_bufs_poc[i] == poc) { hevc_dec->ref_bufs_used |=1 << i;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 434/1095 media: hantro: HEVC: Fix output frame chroma offset
In reply to Greg Kroah-HartmanFrom: Benjamin Gaignard <[email protected]>
[ Upstream commit 579846ec52593e6ca123c30379103377cd25728a ]
Hantro decoder doesn't take care of the requested and aligned size of the capture buffer.
Stop using the bitstream width/height and use capture frame size stored in the context to get the correct values.
hantro_hevc_chroma_offset() and hantro_hevc_motion_vectors_offset() are only used in hantro_g2_hevc_dec.c so take the opportunity to move them here.
fluster HEVC score goes up from 77 to 85 successful tests (over 147) with this patch.
--- .../staging/media/hantro/hantro_g2_hevc_dec.c | 19 ++++++++++++++++--- drivers/staging/media/hantro/hantro_hevc.c | 17 ----------------- drivers/staging/media/hantro/hantro_hw.h | 2 -- 3 files changed, 16 insertions(+), 22 deletions(-)
drivers/staging/media/hantro/hantro_g2_hevc_dec.c +16 -3
@@ -8,6 +8,20 @@#include "hantro_hw.h" #include "hantro_g2_regs.h" +#define G2_ALIGN 16 + +static size_t hantro_hevc_chroma_offset (struct hantro_ctx *ctx) +{ +return ctx->dst_fmt.width * ctx->dst_fmt.height; +} + +static size_t hantro_hevc_motion_vectors_offset (struct hantro_ctx *ctx) +{ +size_t cr_offset =hantro_hevc_chroma_offset (ctx); + +return ALIGN ((cr_offset *3 ) /2 ,G2_ALIGN ); +} +static void prepare_tile_info_buffer (struct hantro_ctx *ctx) {struct hantro_dev *vpu = ctx->dev;
@@ -330,7 +344,6 @@ static void set_ref_pic_list(struct hantro_ctx *ctx)static int set_ref (struct hantro_ctx *ctx) {const struct hantro_hevc_dec_ctrls *ctrls = &ctx->hevc_dec.ctrls; -const struct v4l2_ctrl_hevc_sps *sps = ctrls->sps;const struct v4l2_ctrl_hevc_pps *pps = ctrls->pps;const struct v4l2_ctrl_hevc_decode_params *decode_params = ctrls->decode_params;const struct v4l2_hevc_dpb_entry *dpb = decode_params->dpb;
@@ -338,8 +351,8 @@ static int set_ref(struct hantro_ctx *ctx)struct hantro_dev *vpu = ctx->dev;struct vb2_v4l2_buffer *vb2_dst;struct hantro_decoded_buffer *dst; -size_t cr_offset =hantro_hevc_chroma_offset (sps); -size_t mv_offset =hantro_hevc_motion_vectors_offset (sps); +size_t cr_offset =hantro_hevc_chroma_offset (ctx); +size_t mv_offset =hantro_hevc_motion_vectors_offset (ctx);u32 max_ref_frames;u16 dpb_longterm_e;static const struct hantro_reg cur_poc[] = {
drivers/staging/media/hantro/hantro_hevc.c +0 -17
@@ -27,23 +27,6 @@#define UNUSED_REF -1 -#define G2_ALIGN 16 - -size_t hantro_hevc_chroma_offset (const struct v4l2_ctrl_hevc_sps *sps) -{ -int bytes_per_pixel = sps->bit_depth_luma_minus8 ==0 ?1 :2 ; - -return sps->pic_width_in_luma_samples * - sps->pic_height_in_luma_samples * bytes_per_pixel; -} - -size_t hantro_hevc_motion_vectors_offset (const struct v4l2_ctrl_hevc_sps *sps) -{ -size_t cr_offset =hantro_hevc_chroma_offset (sps); - -return ALIGN ((cr_offset *3 ) /2 ,G2_ALIGN ); -} -static void hantro_hevc_ref_init (struct hantro_ctx *ctx) {struct hantro_hevc_dec_hw_ctx *hevc_dec = &ctx->hevc_dec;
drivers/staging/media/hantro/hantro_hw.h +0 -2
@@ -341,8 +341,6 @@ int hantro_hevc_dec_prepare_run(struct hantro_ctx *ctx);dma_addr_t hantro_hevc_get_ref_buf (struct hantro_ctx *ctx,int poc);int hantro_hevc_add_ref_buf (struct hantro_ctx *ctx,int poc,dma_addr_t addr);void hantro_hevc_ref_remove_unused (struct hantro_ctx *ctx); -size_t hantro_hevc_chroma_offset (const struct v4l2_ctrl_hevc_sps *sps); -size_t hantro_hevc_motion_vectors_offset (const struct v4l2_ctrl_hevc_sps *sps);static inline unsigned short hantro_vp9_num_sbs (unsigned short dimension) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 435/1095 media: hantro: HEVC: Fix reference frames management
In reply to Greg Kroah-HartmanFrom: Benjamin Gaignard <[email protected]>
[ Upstream commit 387d1176956883635c63a7d1c91b1f45e19c1777 ]
PoC shall be int the range of -2^31 to 2^31 -1
(HEVC spec section 8.3.1 Decoding process for picture order count). The current way to know if an entry in reference picture array is free is to test if PoC = UNUSED_REF. Since UNUSED_REF is defined as '-1' that could lead to decode issue if one PoC also equal '-1'.
PoC with value = '-1' exists in conformance test SLIST_B_Sony_9.
Change the way unused entries are managed in reference pictures array to avoid using PoC to detect then.
This patch doesn't change fluster HEVC score.
--- .../staging/media/hantro/hantro_g2_hevc_dec.c | 4 +-- drivers/staging/media/hantro/hantro_hevc.c | 27 +++---------------- drivers/staging/media/hantro/hantro_hw.h | 2 +- 3 files changed, 5 insertions(+), 28 deletions(-)
drivers/staging/media/hantro/hantro_g2_hevc_dec.c +1 -3
@@ -415,7 +415,7 @@ static int set_ref(struct hantro_ctx *ctx)set_ref_pic_list (ctx);/* We will only keep the reference pictures that are still used */ - ctx->hevc_dec.ref_bufs_used =0 ; +hantro_hevc_ref_init (ctx);/* Set up addresses of DPB buffers */ dpb_longterm_e =0 ;
@@ -456,8 +456,6 @@ static int set_ref(struct hantro_ctx *ctx)hantro_write_addr (vpu,G2_OUT_CHROMA_ADDR , chroma_addr);hantro_write_addr (vpu,G2_OUT_MV_ADDR , mv_addr); -hantro_hevc_ref_remove_unused (ctx); -for (; i <V4L2_HEVC_DPB_ENTRIES_NUM_MAX ; i++) {hantro_write_addr (vpu,G2_REF_LUMA_ADDR (i),0 );hantro_write_addr (vpu,G2_REF_CHROMA_ADDR (i),0 );
drivers/staging/media/hantro/hantro_hevc.c +3 -24
@@ -25,15 +25,11 @@#define MAX_TILE_COLS 20#define MAX_TILE_ROWS 22 -#define UNUSED_REF -1 - -static void hantro_hevc_ref_init (struct hantro_ctx *ctx) +void hantro_hevc_ref_init (struct hantro_ctx *ctx) {struct hantro_hevc_dec_hw_ctx *hevc_dec = &ctx->hevc_dec; -int i; -for (i =0 ; i <NUM_REF_PICTURES ; i++) - hevc_dec->ref_bufs_poc[i] =UNUSED_REF ; + hevc_dec->ref_bufs_used =0 ; } dma_addr_t hantro_hevc_get_ref_buf(struct hantro_ctx *ctx,
@@ -60,7 +56,7 @@ int hantro_hevc_add_ref_buf(struct hantro_ctx *ctx, int poc, dma_addr_t addr)/* Add a new reference buffer */ for (i =0 ; i <NUM_REF_PICTURES ; i++) { -if (hevc_dec->ref_bufs_poc[i] ==UNUSED_REF ) { +if (!(hevc_dec->ref_bufs_used &1 << i)) { hevc_dec->ref_bufs_used |=1 << i; hevc_dec->ref_bufs_poc[i] = poc; hevc_dec->ref_bufs[i].dma = addr;
@@ -71,23 +67,6 @@ int hantro_hevc_add_ref_buf(struct hantro_ctx *ctx, int poc, dma_addr_t addr)return -EINVAL ; } -void hantro_hevc_ref_remove_unused (struct hantro_ctx *ctx) -{ -struct hantro_hevc_dec_hw_ctx *hevc_dec = &ctx->hevc_dec; -int i; - -/* Just tag buffer as unused, do not free them */ -for (i =0 ; i <NUM_REF_PICTURES ; i++) { -if (hevc_dec->ref_bufs_poc[i] ==UNUSED_REF ) -continue ; - -if (hevc_dec->ref_bufs_used & (1 << i)) -continue ; - - hevc_dec->ref_bufs_poc[i] =UNUSED_REF ; - } -} -static int tile_buffer_reallocate (struct hantro_ctx *ctx) {struct hantro_dev *vpu = ctx->dev;
drivers/staging/media/hantro/hantro_hw.h +1 -1
@@ -338,9 +338,9 @@ int hantro_hevc_dec_init(struct hantro_ctx *ctx);void hantro_hevc_dec_exit (struct hantro_ctx *ctx);int hantro_g2_hevc_dec_run (struct hantro_ctx *ctx);int hantro_hevc_dec_prepare_run (struct hantro_ctx *ctx); +void hantro_hevc_ref_init (struct hantro_ctx *ctx);dma_addr_t hantro_hevc_get_ref_buf (struct hantro_ctx *ctx,int poc);int hantro_hevc_add_ref_buf (struct hantro_ctx *ctx,int poc,dma_addr_t addr); -void hantro_hevc_ref_remove_unused (struct hantro_ctx *ctx);static inline unsigned short hantro_vp9_num_sbs (unsigned short dimension) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 436/1095 media: hantro: Be more accurate on pixel formats step_width constraints
In reply to Greg Kroah-HartmanFrom: Benjamin Gaignard <[email protected]>
[ Upstream commit 135ad96cb4d6bd6dace030846fe5c7ea890411ab ]
On Hantro G2 decoder on IMX8MQ strides requirements aren't the same for NV12_4L4 and NV12 pixel formats. The first one use a 4 bytes padding while the last one needs 16 bytes.
To be sure to provide the correct stride in all cases we need:
- to relax the constraints on codec formats so set step_width to 4
- use capture queue format and not the output queue format when applying the pixel format constraints.
- put the correct step_width constraints on each pixel format.
Move HEVC SPS validation in hantro_hevc.c to be able to perform it when setting sps control and when starting to decode the bitstream. Add a new test in HEVC SPS validation function to check if resolution is still matching the hardware constraints.
With this SAODBLK_A_MainConcept_4 and SAODBLK_B_MainConcept_4 conformance tests files are correctly decoded with both NV12 and NV12_4L4 pixel formats. These two files have a resolution of 1016x760.
Add defines for the various used resolutions.
For other variants than Hantro G2 on IMX8M keep the same step_width to avoid regressions.
Fluster HEVC test score is now 128/147 vs 126/147 with the both pixel formats as decoder output.
Fluster VP9 test score stay at 147/303.
[hverkuil: fix trivial checkpatch warnings]
--- drivers/staging/media/hantro/hantro_drv.c | 12 +- drivers/staging/media/hantro/hantro_hevc.c | 30 +++++ drivers/staging/media/hantro/hantro_hw.h | 14 +++ drivers/staging/media/hantro/hantro_v4l2.c | 2 +- drivers/staging/media/hantro/imx8m_vpu_hw.c | 80 ++++++++++---- .../staging/media/hantro/rockchip_vpu_hw.c | 104 ++++++++++++------ .../staging/media/hantro/sama5d4_vdec_hw.c | 40 +++++-- drivers/staging/media/hantro/sunxi_vpu_hw.c | 24 +++- 8 files changed, 223 insertions(+), 83 deletions(-)
drivers/staging/media/hantro/hantro_drv.c +6 -6
@@ -253,6 +253,11 @@ queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_queue *dst_vq)static int hantro_try_ctrl (struct v4l2_ctrl *ctrl) { +struct hantro_ctx *ctx; + + ctx =container_of (ctrl->handler, + struct hantro_ctx, ctrl_handler); +if (ctrl->id ==V4L2_CID_STATELESS_H264_SPS ) {const struct v4l2_ctrl_h264_sps *sps = ctrl->p_new.p_h264_sps;
@@ -268,12 +273,7 @@ static int hantro_try_ctrl(struct v4l2_ctrl *ctrl) }else if (ctrl->id ==V4L2_CID_MPEG_VIDEO_HEVC_SPS ) {const struct v4l2_ctrl_hevc_sps *sps = ctrl->p_new.p_hevc_sps; -if (sps->bit_depth_luma_minus8 != sps->bit_depth_chroma_minus8) -/* Luma and chroma bit depth mismatch */ -return -EINVAL ; -if (sps->bit_depth_luma_minus8 !=0 ) -/* Only 8-bit is supported */ -return -EINVAL ; +return hantro_hevc_validate_sps (ctx, sps); }else if (ctrl->id ==V4L2_CID_STATELESS_VP9_FRAME ) {const struct v4l2_ctrl_vp9_frame *dec_params = ctrl->p_new.p_vp9_frame;
drivers/staging/media/hantro/hantro_hevc.c +30 -0
@@ -154,6 +154,32 @@ static int tile_buffer_reallocate(struct hantro_ctx *ctx)return -ENOMEM ; } +int hantro_hevc_validate_sps (struct hantro_ctx *ctx,const struct v4l2_ctrl_hevc_sps *sps) +{ +if (sps->bit_depth_luma_minus8 != sps->bit_depth_chroma_minus8) +/* Luma and chroma bit depth mismatch */ +return -EINVAL ; +if (sps->bit_depth_luma_minus8 !=0 ) +/* Only 8-bit is supported */ +return -EINVAL ; + +/* +* for tile pixel format check if the width and height match +* hardware constraints +*/ +if (ctx->vpu_dst_fmt->fourcc ==V4L2_PIX_FMT_NV12_4L4 ) { +if (ctx->dst_fmt.width != +ALIGN (sps->pic_width_in_luma_samples, ctx->vpu_dst_fmt->frmsize.step_width)) +return -EINVAL ; + +if (ctx->dst_fmt.height != +ALIGN (sps->pic_height_in_luma_samples, ctx->vpu_dst_fmt->frmsize.step_height)) +return -EINVAL ; + } + +return 0 ; +} +int hantro_hevc_dec_prepare_run (struct hantro_ctx *ctx) {struct hantro_hevc_dec_hw_ctx *hevc_ctx = &ctx->hevc_dec;
@@ -177,6 +203,10 @@ int hantro_hevc_dec_prepare_run(struct hantro_ctx *ctx)if (WARN_ON (!ctrls->sps))return -EINVAL ; + ret =hantro_hevc_validate_sps (ctx, ctrls->sps); +if (ret) +return ret; + ctrls->pps =hantro_get_ctrl (ctx,V4L2_CID_MPEG_VIDEO_HEVC_PPS );if (WARN_ON (!ctrls->pps))
drivers/staging/media/hantro/hantro_hw.h +14 -0
@@ -18,9 +18,21 @@#define DEC_8190_ALIGN_MASK 0x07U#define MB_DIM 16 +#define TILE_MB_DIM 4#define MB_WIDTH (w) DIV_ROUND_UP(w, MB_DIM)#define MB_HEIGHT (h) DIV_ROUND_UP(h, MB_DIM) +#define FMT_MIN_WIDTH 48 +#define FMT_MIN_HEIGHT 48 +#define FMT_HD_WIDTH 1280 +#define FMT_HD_HEIGHT 720 +#define FMT_FHD_WIDTH 1920 +#define FMT_FHD_HEIGHT 1088 +#define FMT_UHD_WIDTH 3840 +#define FMT_UHD_HEIGHT 2160 +#define FMT_4K_WIDTH 4096 +#define FMT_4K_HEIGHT 2304 +#define NUM_REF_PICTURES (V4L2_HEVC_DPB_ENTRIES_NUM_MAX + 1)struct hantro_dev ;
@@ -341,6 +353,8 @@ int hantro_hevc_dec_prepare_run(struct hantro_ctx *ctx);void hantro_hevc_ref_init (struct hantro_ctx *ctx);dma_addr_t hantro_hevc_get_ref_buf (struct hantro_ctx *ctx,int poc);int hantro_hevc_add_ref_buf (struct hantro_ctx *ctx,int poc,dma_addr_t addr); +int hantro_hevc_validate_sps (struct hantro_ctx *ctx,const struct v4l2_ctrl_hevc_sps *sps); +static inline unsigned short hantro_vp9_num_sbs (unsigned short dimension) {
drivers/staging/media/hantro/hantro_v4l2.c +1 -1
@@ -260,7 +260,7 @@ static int hantro_try_fmt(const struct hantro_ctx *ctx, }else if (ctx->is_encoder) { vpu_fmt = ctx->vpu_dst_fmt; }else { - vpu_fmt = ctx->vpu_src_fmt; + vpu_fmt = fmt;/* * Width/height on the CAPTURE end of a decoder are ignored and * replaced by the OUTPUT ones.
drivers/staging/media/hantro/imx8m_vpu_hw.c +56 -24
137 lines not on this page · raw message
drivers/staging/media/hantro/rockchip_vpu_hw.c +68 -36
191 lines not on this page · raw message
drivers/staging/media/hantro/sama5d4_vdec_hw.c +28 -12
@@ -16,6 +16,14 @@ static const struct hantro_fmt sama5d4_vdec_postproc_fmts[] = { .fourcc = V4L2_PIX_FMT_YUYV, .codec_mode = HANTRO_MODE_NONE, .postprocessed = true, + .frmsize = { + .min_width = FMT_MIN_WIDTH, + .max_width = FMT_HD_WIDTH, + .step_width = MB_DIM, + .min_height = FMT_MIN_HEIGHT, + .max_height = FMT_HD_HEIGHT, + .step_height = MB_DIM, + }, }, };
@@ -23,17 +31,25 @@ static const struct hantro_fmt sama5d4_vdec_fmts[] = { { .fourcc = V4L2_PIX_FMT_NV12, .codec_mode = HANTRO_MODE_NONE, + .frmsize = { + .min_width = FMT_MIN_WIDTH, + .max_width = FMT_HD_WIDTH, + .step_width = MB_DIM, + .min_height = FMT_MIN_HEIGHT, + .max_height = FMT_HD_HEIGHT, + .step_height = MB_DIM, + }, }, { .fourcc = V4L2_PIX_FMT_MPEG2_SLICE, .codec_mode = HANTRO_MODE_MPEG2_DEC, .max_depth = 2, .frmsize = { - .min_width = 48, - .max_width = 1280, + .min_width = FMT_MIN_WIDTH, + .max_width = FMT_HD_WIDTH, .step_width = MB_DIM, - .min_height = 48, - .max_height = 720, + .min_height = FMT_MIN_HEIGHT, + .max_height = FMT_HD_HEIGHT, .step_height = MB_DIM, }, },
@@ -42,11 +58,11 @@ static const struct hantro_fmt sama5d4_vdec_fmts[] = { .codec_mode = HANTRO_MODE_VP8_DEC, .max_depth = 2, .frmsize = { - .min_width = 48, - .max_width = 1280, + .min_width = FMT_MIN_WIDTH, + .max_width = FMT_HD_WIDTH, .step_width = MB_DIM, - .min_height = 48, - .max_height = 720, + .min_height = FMT_MIN_HEIGHT, + .max_height = FMT_HD_HEIGHT, .step_height = MB_DIM, }, },
@@ -55,11 +71,11 @@ static const struct hantro_fmt sama5d4_vdec_fmts[] = { .codec_mode = HANTRO_MODE_H264_DEC, .max_depth = 2, .frmsize = { - .min_width = 48, - .max_width = 1280, + .min_width = FMT_MIN_WIDTH, + .max_width = FMT_HD_WIDTH, .step_width = MB_DIM, - .min_height = 48, - .max_height = 720, + .min_height = FMT_MIN_HEIGHT, + .max_height = FMT_HD_HEIGHT, .step_height = MB_DIM, }, },
drivers/staging/media/hantro/sunxi_vpu_hw.c +20 -4
@@ -14,6 +14,14 @@ static const struct hantro_fmt sunxi_vpu_postproc_fmts[] = { .fourcc = V4L2_PIX_FMT_NV12, .codec_mode = HANTRO_MODE_NONE, .postprocessed = true, + .frmsize = { + .min_width = FMT_MIN_WIDTH, + .max_width = FMT_UHD_WIDTH, + .step_width = 32, + .min_height = FMT_MIN_HEIGHT, + .max_height = FMT_UHD_HEIGHT, + .step_height = 32, + }, }, };
@@ -21,17 +29,25 @@ static const struct hantro_fmt sunxi_vpu_dec_fmts[] = { { .fourcc = V4L2_PIX_FMT_NV12_4L4, .codec_mode = HANTRO_MODE_NONE, + .frmsize = { + .min_width = FMT_MIN_WIDTH, + .max_width = FMT_UHD_WIDTH, + .step_width = 32, + .min_height = FMT_MIN_HEIGHT, + .max_height = FMT_UHD_HEIGHT, + .step_height = 32, + }, }, { .fourcc = V4L2_PIX_FMT_VP9_FRAME, .codec_mode = HANTRO_MODE_VP9_DEC, .max_depth = 2, .frmsize = { - .min_width = 48, - .max_width = 3840, + .min_width = FMT_MIN_WIDTH, + .max_width = FMT_UHD_WIDTH, .step_width = 32, - .min_height = 48, - .max_height = 2160, + .min_height = FMT_MIN_HEIGHT, + .max_height = FMT_UHD_HEIGHT, .step_height = 32, }, },
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 437/1095 media: hantro: Fix RK3399 H.264 format advertising
In reply to Greg Kroah-HartmanFrom: Ezequiel Garcia <[email protected]>
[ Upstream commit 177d841fa19542eb35aa5ec9579c4abb989c9255 ]
Commit 1f82f2df523cb ("media: hantro: Enable H.264 on Rockchip VDPU2") enabled H.264 on some SoCs with VDPU2 cores. This had the side-effect of exposing H.264 coded format as supported on RK3399.
Fix this and clarify how the codec is explicitly disabled on RK3399 on this driver.
--- .../staging/media/hantro/rockchip_vpu_hw.c | 60 ++++++++++++++++--- 1 file changed, 53 insertions(+), 7 deletions(-)
drivers/staging/media/hantro/rockchip_vpu_hw.c +53 -7
@@ -182,7 +182,7 @@ static const struct hantro_fmt rk3288_vpu_dec_fmts[] = { }, }; -static const struct hantro_fmt rk3399_vpu_dec_fmts[] = { +static const struct hantro_fmt rockchip_vdpu2_dec_fmts[] = { { .fourcc =V4L2_PIX_FMT_NV12 , .codec_mode =HANTRO_MODE_NONE ,
@@ -236,6 +236,47 @@ static const struct hantro_fmt rk3399_vpu_dec_fmts[] = { }, }; +static const struct hantro_fmt rk3399_vpu_dec_fmts[] = { + { + .fourcc =V4L2_PIX_FMT_NV12 , + .codec_mode =HANTRO_MODE_NONE , + .frmsize = { + .min_width =FMT_MIN_WIDTH , + .max_width =FMT_FHD_WIDTH , + .step_width =MB_DIM , + .min_height =FMT_MIN_HEIGHT , + .max_height =FMT_FHD_HEIGHT , + .step_height =MB_DIM , + }, + }, + { + .fourcc =V4L2_PIX_FMT_MPEG2_SLICE , + .codec_mode =HANTRO_MODE_MPEG2_DEC , + .max_depth =2 , + .frmsize = { + .min_width =FMT_MIN_WIDTH , + .max_width =FMT_FHD_WIDTH , + .step_width =MB_DIM , + .min_height =FMT_MIN_HEIGHT , + .max_height =FMT_FHD_HEIGHT , + .step_height =MB_DIM , + }, + }, + { + .fourcc =V4L2_PIX_FMT_VP8_FRAME , + .codec_mode =HANTRO_MODE_VP8_DEC , + .max_depth =2 , + .frmsize = { + .min_width =FMT_MIN_WIDTH , + .max_width =FMT_UHD_WIDTH , + .step_width =MB_DIM , + .min_height =FMT_MIN_HEIGHT , + .max_height =FMT_UHD_HEIGHT , + .step_height =MB_DIM , + }, + }, +}; +static irqreturn_t rockchip_vpu1_vepu_irq (int irq,void *dev_id) {struct hantro_dev *vpu = dev_id;
@@ -548,8 +589,8 @@ const struct hantro_variant rk3288_vpu_variant = {const struct hantro_variant rk3328_vpu_variant = { .dec_offset =0x400 , - .dec_fmts = rk3399_vpu_dec_fmts, - .num_dec_fmts =ARRAY_SIZE (rk3399_vpu_dec_fmts), + .dec_fmts = rockchip_vdpu2_dec_fmts, + .num_dec_fmts =ARRAY_SIZE (rockchip_vdpu2_dec_fmts), .codec =HANTRO_MPEG2_DECODER |HANTRO_VP8_DECODER |HANTRO_H264_DECODER , .codec_ops = rk3399_vpu_codec_ops,
@@ -560,6 +601,11 @@ const struct hantro_variant rk3328_vpu_variant = { .num_clocks = ARRAY_SIZE(rockchip_vpu_clk_names), }; +/* +* H.264 decoding explicitly disabled in RK3399. +* This ensures userspace applications use the Rockchip VDEC core, +* which has better performance. +*/ const struct hantro_variant rk3399_vpu_variant = { .enc_offset =0x0 , .enc_fmts = rockchip_vpu_enc_fmts,
@@ -579,8 +625,8 @@ const struct hantro_variant rk3399_vpu_variant = {const struct hantro_variant rk3568_vpu_variant = { .dec_offset =0x400 , - .dec_fmts = rk3399_vpu_dec_fmts, - .num_dec_fmts =ARRAY_SIZE (rk3399_vpu_dec_fmts), + .dec_fmts = rockchip_vdpu2_dec_fmts, + .num_dec_fmts =ARRAY_SIZE (rockchip_vdpu2_dec_fmts), .codec =HANTRO_MPEG2_DECODER |HANTRO_VP8_DECODER |HANTRO_H264_DECODER , .codec_ops = rk3399_vpu_codec_ops,
@@ -596,8 +642,8 @@ const struct hantro_variant px30_vpu_variant = { .enc_fmts = rockchip_vpu_enc_fmts, .num_enc_fmts = ARRAY_SIZE(rockchip_vpu_enc_fmts), .dec_offset = 0x400, - .dec_fmts = rk3399_vpu_dec_fmts, - .num_dec_fmts = ARRAY_SIZE(rk3399_vpu_dec_fmts), + .dec_fmts = rockchip_vdpu2_dec_fmts, + .num_dec_fmts = ARRAY_SIZE(rockchip_vdpu2_dec_fmts), .codec =HANTRO_JPEG_ENCODER |HANTRO_MPEG2_DECODER | HANTRO_VP8_DECODER | HANTRO_H264_DECODER, .codec_ops = rk3399_vpu_codec_ops,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 438/1095 media: amphion: decoder copy timestamp from output to capture
In reply to Greg Kroah-HartmanFrom: Ming Qian <[email protected]>
[ Upstream commit a4dca209f23470f20b61b40cca417a5bf6ea8533 ]
copy the timestamp using the helper functionV4L2_BUF_FLAG_TIMESTAMP_COPY
To implement this, driver will keep the output buffer until it's decoded, in previous, driver will return the output buffer immediately after copying data to stream buffer.
After that, there is no need to make a workaround for poll function. driver can use v4l2_m2m_fop_poll directly.
Also, driver don't need to keep a input threshold
as the buffer count is up to only 32.
--- drivers/media/platform/amphion/vdec.c | 76 ++++++++------------- drivers/media/platform/amphion/vpu_malone.c | 2 +- drivers/media/platform/amphion/vpu_v4l2.c | 56 +++++++++++++++ drivers/media/platform/amphion/vpu_v4l2.h | 3 + 4 files changed, 87 insertions(+), 50 deletions(-)
drivers/media/platform/amphion/vdec.c +27 -49
@@ -26,8 +26,8 @@#include "vpu_cmds.h" #include "vpu_rpc.h" -#define VDEC_FRAME_DEPTH 256#define VDEC_MIN_BUFFER_CAP 8 +#define VDEC_MIN_BUFFER_OUT 8struct vdec_fs_info {char name[8 ];
@@ -63,8 +63,6 @@ struct vdec_t {bool is_source_changed;u32 source_change;u32 drain; -u32 ts_pre_count; -u32 frame_depth; };static const struct vpu_format vdec_formats[] = {
@@ -475,7 +473,7 @@ static int vdec_drain(struct vpu_inst *inst)if (!vdec->drain)return 0 ; -if (v4l2_m2m_num_src_bufs_ready (inst->fh.m2m_ctx)) +if (!vpu_is_source_empty (inst))return 0 ;if (!vdec->params.frame_count) {
@@ -598,11 +596,8 @@ static bool vdec_check_ready(struct vpu_inst *inst, unsigned int type) {struct vdec_t *vdec = inst->priv; -if (V4L2_TYPE_IS_OUTPUT (type)) { -if (vdec->ts_pre_count >= vdec->frame_depth) -return false; +if (V4L2_TYPE_IS_OUTPUT (type))return true; - }if (vdec->req_frame_count)return true;
@@ -610,12 +605,21 @@ static bool vdec_check_ready(struct vpu_inst *inst, unsigned int type)return false; } +static struct vb2_v4l2_buffer *vdec_get_src_buffer (struct vpu_inst *inst,u32 count) +{ +if (count >1 ) +vpu_skip_frame (inst, count -1 ); + +return vpu_next_src_buf (inst); +} +static int vdec_frame_decoded (struct vpu_inst *inst,void *arg) {struct vdec_t *vdec = inst->priv;struct vpu_dec_pic_info *info = arg;struct vpu_vb2_buffer *vpu_buf;struct vb2_v4l2_buffer *vbuf; +struct vb2_v4l2_buffer *src_buf;int ret =0 ;if (!info || info->id >=ARRAY_SIZE (vdec->slots))
@@ -629,14 +633,21 @@ static int vdec_frame_decoded(struct vpu_inst *inst, void *arg) goto exit; } vbuf = &vpu_buf->m2m_buf.vb; + src_buf =vdec_get_src_buffer (inst, info->consumed_count); +if (src_buf) { +v4l2_m2m_buf_copy_metadata (src_buf, vbuf, true); +if (info->consumed_count) { +v4l2_m2m_src_buf_remove (inst->fh.m2m_ctx); +vpu_set_buffer_state (src_buf,VPU_BUF_STATE_IDLE ); +v4l2_m2m_buf_done (src_buf,VB2_BUF_STATE_DONE ); + }else { +vpu_set_buffer_state (src_buf,VPU_BUF_STATE_DECODED ); + } + }if (vpu_get_buffer_state (vbuf) ==VPU_BUF_STATE_DECODED )dev_info (inst->dev,"[%d] buf[%d] has been decoded\n" , inst->id, info->id);vpu_set_buffer_state (vbuf,VPU_BUF_STATE_DECODED ); vdec->decoded_frame_count++; -if (vdec->ts_pre_count >= info->consumed_count) - vdec->ts_pre_count -= info->consumed_count; -else - vdec->ts_pre_count =0 ; exit:vpu_inst_unlock (inst);
@@ -692,10 +703,9 @@ static void vdec_buf_done(struct vpu_inst *inst, struct vpu_frame_info *frame)vpu_set_buffer_state (vbuf,VPU_BUF_STATE_READY );vb2_set_plane_payload (&vbuf->vb2_buf,0 , inst->cap_format.sizeimage[0 ]);vb2_set_plane_payload (&vbuf->vb2_buf,1 , inst->cap_format.sizeimage[1 ]); - vbuf->vb2_buf.timestamp = frame->timestamp; vbuf->field = inst->cap_format.field; vbuf->sequence = sequence; -dev_dbg (inst->dev,"[%d][OUTPUT TS]%32lld\n" , inst->id, frame->timestamp); +dev_dbg (inst->dev,"[%d][OUTPUT TS]%32lld\n" , inst->id, vbuf->vb2_buf.timestamp);v4l2_m2m_buf_done (vbuf,VB2_BUF_STATE_DONE );vpu_inst_lock (inst);
@@ -717,7 +727,6 @@ static void vdec_stop_done(struct vpu_inst *inst) vdec->fixed_fmt = false; vdec->params.end_flag =0 ; vdec->drain =0 ; - vdec->ts_pre_count =0 ; vdec->params.frame_count =0 ; vdec->decoded_frame_count =0 ; vdec->display_frame_count =0 ;
@@ -1252,18 +1261,14 @@ static int vdec_process_output(struct vpu_inst *inst, struct vb2_buffer *vb)if (free_space <vb2_get_plane_payload (vb,0 ) +0x40000 )return -ENOMEM ; +vpu_set_buffer_state (vbuf,VPU_BUF_STATE_INUSE ); ret =vpu_iface_input_frame (inst, vb);if (ret <0 )return -ENOMEM ;dev_dbg (inst->dev,"[%d][INPUT TS]%32lld\n" , inst->id, vb->timestamp); - vdec->ts_pre_count++; vdec->params.frame_count++; -v4l2_m2m_src_buf_remove_by_buf (inst->fh.m2m_ctx, vbuf); -vpu_set_buffer_state (vbuf,VPU_BUF_STATE_IDLE ); -v4l2_m2m_buf_done (vbuf,VB2_BUF_STATE_DONE ); -if (vdec->drain)vdec_drain (inst);
@@ -1326,7 +1331,6 @@ static void vdec_abort(struct vpu_inst *inst) vdec->sequence); vdec->params.end_flag =0 ; vdec->drain =0 ; - vdec->ts_pre_count =0 ; vdec->params.frame_count =0 ; vdec->decoded_frame_count =0 ; vdec->display_frame_count =0 ;
@@ -1533,10 +1537,6 @@ static int vdec_get_debug_info(struct vpu_inst *inst, char *str, u32 size, u32 i vdec->drain, vdec->eos_received, vdec->source_change);break ;case 8 : - num =scnprintf (str, size,"ts_pre_count = %d, frame_depth = %d\n" , - vdec->ts_pre_count, vdec->frame_depth); -break ; -case 9 : num =scnprintf (str, size,"fps = %d/%d\n" , vdec->codec_info.frame_rate.numerator, vdec->codec_info.frame_rate.denominator);
@@ -1570,12 +1570,8 @@ static struct vpu_inst_ops vdec_inst_ops = {static void vdec_init (struct file *file) {struct vpu_inst *inst =to_inst (file); -struct vdec_t *vdec;struct v4l2_format f; - vdec = inst->priv; - vdec->frame_depth =VDEC_FRAME_DEPTH ; -memset (&f,0 ,sizeof (f)); f.type =V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ; f.fmt.pix_mp.pixelformat =V4L2_PIX_FMT_H264 ;
@@ -1620,36 +1616,18 @@ static int vdec_open(struct file *file) vdec->fixed_fmt = false; inst->min_buffer_cap =VDEC_MIN_BUFFER_CAP ; + inst->min_buffer_out =VDEC_MIN_BUFFER_OUT ;vdec_init (file);return 0 ; } -static __poll_t vdec_poll (struct file *file,poll_table *wait) -{ -struct vpu_inst *inst =to_inst (file); -struct vb2_queue *src_q, *dst_q; -__poll_t ret; - - ret =v4l2_m2m_fop_poll (file, wait); - src_q =v4l2_m2m_get_src_vq (inst->fh.m2m_ctx); - dst_q =v4l2_m2m_get_dst_vq (inst->fh.m2m_ctx); -if (vb2_is_streaming (src_q) && !vb2_is_streaming (dst_q)) - ret &= (~EPOLLERR ); -if (!src_q->error && !dst_q->error && - (vb2_is_streaming (src_q) &&list_empty (&src_q->queued_list)) && - (vb2_is_streaming (dst_q) &&list_empty (&dst_q->queued_list))) - ret &= (~EPOLLERR ); - -return ret; -} -static const struct v4l2_file_operations vdec_fops = { .owner =THIS_MODULE , .open = vdec_open, .release = vpu_v4l2_close, .unlocked_ioctl = video_ioctl2, - .poll = vdec_poll, + .poll = v4l2_m2m_fop_poll, .mmap = v4l2_m2m_fop_mmap, };
drivers/media/platform/amphion/vpu_malone.c +1 -1
@@ -1558,7 +1558,7 @@ int vpu_malone_input_frame(struct vpu_shared_addr *shared,* merge the data to next frame */ vbuf =to_vb2_v4l2_buffer (vb); -if (vpu_vb_is_codecconfig (vbuf) && (s64 )vb->timestamp <0 ) { +if (vpu_vb_is_codecconfig (vbuf)) { inst->extra_size += size;return 0 ; }
drivers/media/platform/amphion/vpu_v4l2.c +56 -0
68 lines not on this page · raw message
drivers/media/platform/amphion/vpu_v4l2.h +3 -0
@@ -19,6 +19,8 @@ int vpu_v4l2_close(struct file *file);const struct vpu_format *vpu_try_fmt_common (struct vpu_inst *inst,struct v4l2_format *f);int vpu_process_output_buffer (struct vpu_inst *inst);int vpu_process_capture_buffer (struct vpu_inst *inst); +struct vb2_v4l2_buffer *vpu_next_src_buf (struct vpu_inst *inst); +void vpu_skip_frame (struct vpu_inst *inst,int count);struct vb2_v4l2_buffer *vpu_find_buf_by_sequence (struct vpu_inst *inst,u32 type,u32 sequence);struct vb2_v4l2_buffer *vpu_find_buf_by_idx (struct vpu_inst *inst,u32 type,u32 idx);void vpu_v4l2_set_error (struct vpu_inst *inst);
@@ -27,6 +29,7 @@ int vpu_notify_source_change(struct vpu_inst *inst);int vpu_set_last_buffer_dequeued (struct vpu_inst *inst);void vpu_vb2_buffers_return (struct vpu_inst *inst,unsigned int type,enum vb2_buffer_state state);int vpu_get_num_buffers (struct vpu_inst *inst,u32 type); +bool vpu_is_source_empty (struct vpu_inst *inst);dma_addr_t vpu_get_vb_phy_addr (struct vb2_buffer *vb,u32 plane_no);unsigned int vpu_get_vb_length (struct vb2_buffer *vb,u32 plane_no);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 439/1095 media: amphion: sync buffer status with firmware during abort
In reply to Greg Kroah-HartmanFrom: Ming Qian <[email protected]>
[ Upstream commit d8f1eb105eab7aab36323c6b488dda479d5bd2da ]
1. prevent to allocate buffer to firmware during abort
2. release buffer when clear the slots
--- drivers/media/platform/amphion/vdec.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/media/platform/amphion/vdec.c +9 -0
@@ -63,6 +63,7 @@ struct vdec_t {bool is_source_changed;u32 source_change;u32 drain; +bool aborting; };static const struct vpu_format vdec_formats[] = {
@@ -942,6 +943,9 @@ static int vdec_response_frame(struct vpu_inst *inst, struct vb2_v4l2_buffer *vbif (inst->state !=VPU_CODEC_STATE_ACTIVE )return -EINVAL ; +if (vdec->aborting) +return -EINVAL ; +if (!vdec->req_frame_count)return -EINVAL ;
@@ -1051,6 +1055,8 @@ static void vdec_clear_slots(struct vpu_inst *inst) vpu_buf = vdec->slots[i]; vbuf = &vpu_buf->m2m_buf.vb; +vpu_trace (inst->dev,"clear slot %d\n" , i); +vdec_response_fs_release (inst, i, vpu_buf->tag);vdec_recycle_buffer (inst, vbuf); vdec->slots[i]->state =VPU_BUF_STATE_IDLE ; vdec->slots[i] =NULL ;
@@ -1312,6 +1318,8 @@ static void vdec_abort(struct vpu_inst *inst)int ret;vpu_trace (inst->dev,"[%d] state = %d\n" , inst->id, inst->state); + + vdec->aborting = true;vpu_iface_add_scode (inst,SCODE_PADDING_ABORT ); vdec->params.end_flag =1 ;vpu_iface_set_decode_params (inst, &vdec->params,1 );
@@ -1335,6 +1343,7 @@ static void vdec_abort(struct vpu_inst *inst) vdec->decoded_frame_count =0 ; vdec->display_frame_count =0 ; vdec->sequence =0 ; + vdec->aborting = false; }static void vdec_stop (struct vpu_inst *inst,bool free)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 440/1095 media: amphion: only insert the first sequence startcode for vc1l format
In reply to Greg Kroah-HartmanFrom: Ming Qian <[email protected]>
[ Upstream commit e670f5d672ef3d00b0b8c69eff09a019e6dd4ef9 ]
For format V4L2_PIX_FMT_VC1_ANNEX_L,
the amphion vpu requires driver to help insert some custom startcode before sequence and frame.
but only the first sequence startcode is needed,
the extra startcode will cause decoding error.
So after seek, we don't need to insert the sequence startcode.
In other words, for V4L2_PIX_FMT_VC1_ANNEX_L, the vpu doesn't support dynamic resolution change.
--- drivers/media/platform/amphion/vdec.c | 2 +- drivers/media/platform/amphion/vpu.h | 1 + drivers/media/platform/amphion/vpu_malone.c | 2 ++ drivers/media/platform/amphion/vpu_rpc.h | 7 ++++++- 4 files changed, 10 insertions(+), 2 deletions(-)
drivers/media/platform/amphion/vdec.c +1 -1
@@ -105,7 +105,6 @@ static const struct vpu_format vdec_formats[] = { .pixfmt = V4L2_PIX_FMT_VC1_ANNEX_L, .num_planes = 1, .type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, - .flags =V4L2_FMT_FLAG_DYN_RESOLUTION }, { .pixfmt = V4L2_PIX_FMT_MPEG2,
@@ -735,6 +734,7 @@ static void vdec_stop_done(struct vpu_inst *inst) vdec->eos_received =0 ; vdec->is_source_changed = false; vdec->source_change =0 ; + inst->total_input_count =0 ;vpu_inst_unlock (inst); }
drivers/media/platform/amphion/vpu.h +1 -0
@@ -258,6 +258,7 @@ struct vpu_inst {struct vpu_format cap_format;u32 min_buffer_cap;u32 min_buffer_out; +u32 total_input_count;struct v4l2_rect crop;u32 colorspace;
drivers/media/platform/amphion/vpu_malone.c +2 -0
@@ -1296,6 +1296,8 @@ static int vpu_malone_insert_scode_vc1_l_seq(struct malone_scode_t *scode)int size =0 ;u8 rcv_seqhdr[MALONE_VC1_RCV_SEQ_HEADER_LEN ]; +if (scode->inst->total_input_count) +return 0 ; scode->need_data =0 ; ret =vpu_malone_insert_scode_seq (scode,MALONE_CODEC_ID_VC1_SIMPLE ,sizeof (rcv_seqhdr));
drivers/media/platform/amphion/vpu_rpc.h +6 -1
@@ -312,11 +312,16 @@ static inline int vpu_iface_input_frame(struct vpu_inst *inst, struct vb2_buffer *vb) {struct vpu_iface_ops *ops =vpu_core_get_iface (inst->core); +int ret;if (!ops || !ops->input_frame)return -EINVAL ; -return ops->input_frame (inst->core->iface, inst, vb); + ret = ops->input_frame (inst->core->iface, inst, vb); +if (ret <0 ) +return ret; + inst->total_input_count++; +return ret; } static inline int vpu_iface_config_memory_resource(struct vpu_inst *inst,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 441/1095 mt76: mt76x02u: fix possible memory leak in __mt76x02u_mcu_send_msg
In reply to Greg Kroah-HartmanFrom: Lorenzo Bianconi <[email protected]>
[ Upstream commit cffd93411575afd987788e2ec3cb8eaff70f0215 ]
Free the skb if mt76u_bulk_msg fails in __mt76x02u_mcu_send_msg routine.
--- drivers/net/wireless/mediatek/mt76/mt76x02_usb_mcu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt76x02_usb_mcu.c +1 -1
@@ -108,7 +108,7 @@ __mt76x02u_mcu_send_msg(struct mt76_dev *dev, struct sk_buff *skb, ret =mt76u_bulk_msg (dev, skb->data, skb->len,NULL ,500 ,MT_EP_OUT_INBAND_CMD );if (ret) -return ret; + goto out;if (wait_resp) ret =mt76x02u_mcu_wait_resp (dev, seq);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 442/1095 mt76: mt7921s: fix firmware download random fail
In reply to Greg Kroah-HartmanFrom: YN Chen <[email protected]>
[ Upstream commit a55a0c701c129f8e448f0ec1eb811dba728ace64 ]
To avoid racing problems in chip, mt7921s should reacquire drv-own after firmware semaphore is released.
--- drivers/net/wireless/mediatek/mt76/mt7921/mcu.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +8 -7
@@ -538,13 +538,6 @@ static int mt7921_load_patch(struct mt7921_dev *dev)if (ret)dev_err (dev->mt76.dev,"Failed to start patch\n" ); -if (mt76_is_sdio (&dev->mt76)) { -/* activate again */ - ret =__mt7921_mcu_fw_pmctrl (dev); -if (!ret) - ret =__mt7921_mcu_drv_pmctrl (dev); - } - out: sem =mt76_connac_mcu_patch_sem_ctrl (&dev->mt76, false);switch (sem) {
@@ -555,6 +548,14 @@ static int mt7921_load_patch(struct mt7921_dev *dev)dev_err (dev->mt76.dev,"Failed to release patch semaphore\n" );break ; } + +if (!ret &&mt76_is_sdio (&dev->mt76)) { +/* activate again */ + ret =__mt7921_mcu_fw_pmctrl (dev); +if (!ret) + ret =__mt7921_mcu_drv_pmctrl (dev); + } +release_firmware (fw);return ret;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 443/1095 mt76: mt7615: do not update pm stats in case of error
In reply to Greg Kroah-HartmanFrom: Lorenzo Bianconi <[email protected]>
[ Upstream commit 79717c4eeeae9dec894794fbe8af72f08f03ebdd ]
Do not update pm stats if mt7615_mcu_fw_pmctrl returns an error.
--- drivers/net/wireless/mediatek/mt76/mt7615/mcu.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +5 -4
@@ -350,10 +350,11 @@ static int mt7615_mcu_fw_pmctrl(struct mt7615_dev *dev) }mt7622_trigger_hif_int (dev, false); - - pm->stats.last_doze_event = jiffies; - pm->stats.awake_time += pm->stats.last_doze_event - - pm->stats.last_wake_event; +if (!err) { + pm->stats.last_doze_event = jiffies; + pm->stats.awake_time += pm->stats.last_doze_event - + pm->stats.last_wake_event; + } out:mutex_unlock (&pm->mutex);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 444/1095 mt76: mt7921: do not update pm states in case of error
In reply to Greg Kroah-HartmanFrom: Lorenzo Bianconi <[email protected]>
[ Upstream commit f4a92547fb9818ff272e1e2f0c79cd6b0bc99ce8 ]
Do not update pm stats if mt7921e_mcu_fw_pmctrl routine returns an error.
--- drivers/net/wireless/mediatek/mt76/mt7921/pci_mcu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/pci_mcu.c +3 -3
@@ -102,7 +102,7 @@ int mt7921e_mcu_fw_pmctrl(struct mt7921_dev *dev) {struct mt76_phy *mphy = &dev->mt76.phy;struct mt76_connac_pm *pm = &dev->pm; -int i, err =0 ; +int i;for (i =0 ; i <MT7921_DRV_OWN_RETRY_COUNT ; i++) {mt76_wr (dev,MT_CONN_ON_LPCTL ,PCIE_LPCR_HOST_SET_OWN );
@@ -114,12 +114,12 @@ int mt7921e_mcu_fw_pmctrl(struct mt7921_dev *dev)if (i ==MT7921_DRV_OWN_RETRY_COUNT ) {dev_err (dev->mt76.dev,"firmware own failed\n" );clear_bit (MT76_STATE_PM , &mphy->state); - err = -EIO ; +return -EIO ; } pm->stats.last_doze_event = jiffies; pm->stats.awake_time += pm->stats.last_doze_event - pm->stats.last_wake_event; -return err; +return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 445/1095 mt76: mt7921s: fix possible sdio deadlock in command fail
In reply to Greg Kroah-HartmanFrom: Deren Wu <[email protected]>
[ Upstream commit 364718c94ac2ea4e51958ac0aa15c9092c785a3a ]
Move sdio_release_host() to final resource handing
--- drivers/net/wireless/mediatek/mt76/mt7921/sdio_mcu.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/sdio_mcu.c +5 -5
@@ -136,8 +136,8 @@ int mt7921s_mcu_fw_pmctrl(struct mt7921_dev *dev)struct sdio_func *func = dev->mt76.sdio.func;struct mt76_phy *mphy = &dev->mt76.phy;struct mt76_connac_pm *pm = &dev->pm; -int err =0 ;u32 status; +int err;sdio_claim_host (func);
@@ -148,7 +148,7 @@ int mt7921s_mcu_fw_pmctrl(struct mt7921_dev *dev) 2000, 1000000);if (err <0 ) {dev_err (dev->mt76.dev,"mailbox ACK not cleared\n" ); - goto err; + goto out; } }
@@ -156,18 +156,18 @@ int mt7921s_mcu_fw_pmctrl(struct mt7921_dev *dev) err =readx_poll_timeout (mt76s_read_pcr, &dev->mt76, status, !(status &WHLPCR_IS_DRIVER_OWN ),2000 ,1000000 ); +out:sdio_release_host (func); -err:if (err <0 ) {dev_err (dev->mt76.dev,"firmware own failed\n" );clear_bit (MT76_STATE_PM , &mphy->state); - err = -EIO ; +return -EIO ; } pm->stats.last_doze_event = jiffies; pm->stats.awake_time += pm->stats.last_doze_event - pm->stats.last_wake_event; -return err; +return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 446/1095 mt76: mt7921: fix aggregation subframes setting to HE max
In reply to Greg Kroah-HartmanFrom: Deren Wu <[email protected]>
[ Upstream commit d5a50e6bd1972c481f82befa846dce0b9866f025 ]
mt7921/mt7922 support HE max aggregation subframes 256 for both tx/rx. Get better throughput then before.
--- drivers/net/wireless/mediatek/mt76/mt7921/init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/init.c +2 -2
@@ -49,8 +49,8 @@ mt7921_init_wiphy(struct ieee80211_hw *hw)struct wiphy *wiphy = hw->wiphy; hw->queues =4 ; - hw->max_rx_aggregation_subframes =64 ; - hw->max_tx_aggregation_subframes =128 ; + hw->max_rx_aggregation_subframes =IEEE80211_MAX_AMPDU_BUF_HE ; + hw->max_tx_aggregation_subframes =IEEE80211_MAX_AMPDU_BUF_HE ; hw->netdev_features =NETIF_F_RXCSUM ; hw->radiotap_timestamp.units_pos =
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 447/1095 mt76: mt7921: enlarge maximum VHT MPDU length to 11454
In reply to Greg Kroah-HartmanFrom: Deren Wu <[email protected]>
[ Upstream commit 31f3248a75932b111bc90c66b1f6c7d89eedca8e ]
Enlarge maximum MPDU length to 11454 that both mt7921/mt7922 can support. After this fixing, we can get better performance.
--- drivers/net/wireless/mediatek/mt76/mt7921/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7921/init.c +1 -1
@@ -291,7 +291,7 @@ int mt7921_register_device(struct mt7921_dev *dev)IEEE80211_HT_CAP_LDPC_CODING |IEEE80211_HT_CAP_MAX_AMSDU ; dev->mphy.sband_5g.sband.vht_cap.cap |= -IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991 | +IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454 |IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK |IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE | IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE |
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 448/1095 mt76: mt7615: fix throughput regression on DFS channels
In reply to Greg Kroah-HartmanFrom: Felix Fietkau <[email protected]>
[ Upstream commit aac86cebb4a09e3fa2c07589f79f7d0e07e8c9a4 ]
For some reason, mt7615 reacts badly to repeatedly enabling/disabling the radar detector without also switching the channel.
This results in very bad throughput on DFS channels, because hw->conf.radar_enabled can get toggled a few times after CAC ends. Fix this by always leaving the DFS detector enabled on DFS channels and instead suppress unwanted detection events.
--- .../net/wireless/mediatek/mt76/mt7615/mac.c | 7 ++++--- .../net/wireless/mediatek/mt76/mt7615/main.c | 21 ------------------- .../net/wireless/mediatek/mt76/mt7615/mcu.c | 3 +++ .../wireless/mediatek/mt76/mt7615/mt7615.h | 1 - 4 files changed, 7 insertions(+), 25 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/mac.c +4 -3
@@ -2282,6 +2282,7 @@ mt7615_dfs_init_radar_specs(struct mt7615_phy *phy)int mt7615_dfs_init_radar_detector (struct mt7615_phy *phy) { +struct cfg80211_chan_def *chandef = &phy->mt76->chandef;struct mt7615_dev *dev = phy->dev;bool ext_phy = phy != &dev->phy;enum mt76_dfs_state dfs_state, prev_state;
@@ -2292,13 +2293,13 @@ int mt7615_dfs_init_radar_detector(struct mt7615_phy *phy) prev_state = phy->mt76->dfs_state; dfs_state =mt76_phy_dfs_state (phy->mt76); +if ((chandef->chan->flags &IEEE80211_CHAN_RADAR ) && + dfs_state <MT_DFS_STATE_CAC ) + dfs_state =MT_DFS_STATE_ACTIVE ;if (prev_state == dfs_state)return 0 ; -if (prev_state ==MT_DFS_STATE_UNKNOWN ) -mt7615_dfs_stop_radar_detector (phy); -if (dfs_state ==MT_DFS_STATE_DISABLED ) goto stop;
drivers/net/wireless/mediatek/mt76/mt7615/main.c +0 -21
@@ -282,26 +282,6 @@ static void mt7615_remove_interface(struct ieee80211_hw *hw,mt76_packet_id_flush (&dev->mt76, &mvif->sta.wcid); } -static void mt7615_init_dfs_state (struct mt7615_phy *phy) -{ -struct mt76_phy *mphy = phy->mt76; -struct ieee80211_hw *hw = mphy->hw; -struct cfg80211_chan_def *chandef = &hw->conf.chandef; - -if (hw->conf.flags &IEEE80211_CONF_OFFCHANNEL ) -return ; - -if (!(chandef->chan->flags &IEEE80211_CHAN_RADAR ) && - !(mphy->chandef.chan->flags &IEEE80211_CHAN_RADAR )) -return ; - -if (mphy->chandef.chan->center_freq == chandef->chan->center_freq && - mphy->chandef.width == chandef->width) -return ; - - phy->dfs_state =-1 ; -} -int mt7615_set_channel (struct mt7615_phy *phy) {struct mt7615_dev *dev = phy->dev;
@@ -314,7 +294,6 @@ int mt7615_set_channel(struct mt7615_phy *phy)set_bit (MT76_RESET , &phy->mt76->state); -mt7615_init_dfs_state (phy);mt76_set_channel (phy->mt76);if (is_mt7615 (&dev->mt76) && dev->flash_eeprom) {
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +3 -0
@@ -403,6 +403,9 @@ mt7615_mcu_rx_radar_detected(struct mt7615_dev *dev, struct sk_buff *skb)if (r->band_idx && dev->mt76.phy2) mphy = dev->mt76.phy2; +if (mt76_phy_dfs_state (mphy) <MT_DFS_STATE_CAC ) +return ; +ieee80211_radar_detected (mphy->hw); dev->hw_pattern++; }
drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h +0 -1
@@ -177,7 +177,6 @@ struct mt7615_phy {u8 chfreq;u8 rdd_state; -int dfs_state;u32 rx_ampdu_ts;u32 ampdu_ref;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 449/1095 mediatek: mt76: mac80211: Fix missing of_node_put() in mt76_led_init()
In reply to Greg Kroah-HartmanFrom: Liang He <[email protected]>
[ Upstream commit 0a14c1d0113f121151edf34333cdf212dd209190 ]
We should use of_node_put() for the reference 'np' returned by of_get_child_by_name() which will increase the refcount.
--- drivers/net/wireless/mediatek/mt76/mac80211.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/mediatek/mt76/mac80211.c +1 -0
@@ -210,6 +210,7 @@ static int mt76_led_init(struct mt76_dev *dev)if (!of_property_read_u32 (np,"led-sources" , &led_pin)) dev->led_pin = led_pin; dev->led_al =of_property_read_bool (np,"led-active-low" ); +of_node_put (np); }return led_classdev_register (dev->dev, &dev->led_cdev);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 450/1095 mediatek: mt76: eeprom: fix missing of_node_put() in mt76_find_power_limits_node()
In reply to Greg Kroah-HartmanFrom: Liang He <[email protected]>
[ Upstream commit 3bd53ea02d77917c2314ec7be9e2d05be22f87d3 ]
We should use of_node_put() for the reference 'np' returned by of_get_child_by_name() which will increase the refcount.
--- drivers/net/wireless/mediatek/mt76/eeprom.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/eeprom.c +4 -1
@@ -162,10 +162,13 @@ mt76_find_power_limits_node(struct mt76_dev *dev) }if (mt76_string_prop_find (country, dev->alpha2) || -mt76_string_prop_find (regd, region_name)) +mt76_string_prop_find (regd, region_name)) { +of_node_put (np);return cur; + } } +of_node_put (np);return fallback; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 451/1095 skmsg: Fix invalid last sg check in sk_msg_recvmsg()
In reply to Greg Kroah-HartmanFrom: Liu Jian <[email protected]>
[ Upstream commit 9974d37ea75f01b47d16072b5dad305bd8d23fcc ]
In sk_psock_skb_ingress_enqueue function, if the linear area + nr_frags + frag_list of the SKB has NR_MSG_FRAG_IDS blocks in total, skb_to_sgvec will return NR_MSG_FRAG_IDS, then msg->sg.end will be set to NR_MSG_FRAG_IDS, and in addition, (NR_MSG_FRAG_IDS - 1) is set to the last SG of msg. Recv the msg in sk_msg_recvmsg, when i is (NR_MSG_FRAG_IDS - 1), the sk_msg_iter_var_next(i) will change i to 0 (not NR_MSG_FRAG_IDS), the judgment condition "msg_rx->sg.start==msg_rx->sg.end" and
"i != msg_rx->sg.end" can not work.
As a result, the processed msg cannot be deleted from ingress_msg list. But the length of all the sge of the msg has changed to 0. Then the next recvmsg syscall will process the msg repeatedly, because the length of sge is 0, the -EFAULT error is always returned.
--- net/core/skmsg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/core/skmsg.c +2 -2
@@ -462,7 +462,7 @@ int sk_msg_recvmsg(struct sock *sk, struct sk_psock *psock, struct msghdr *msg,if (copied == len)break ; - }while (i != msg_rx->sg.end); + }while (!sg_is_last (sge));if (unlikely (peek)) { msg_rx =sk_psock_next_msg (psock, msg_rx);
@@ -472,7 +472,7 @@ int sk_msg_recvmsg(struct sock *sk, struct sk_psock *psock, struct msghdr *msg, } msg_rx->sg.start = i; -if (!sge->length && msg_rx->sg.start == msg_rx->sg.end) { +if (!sge->length &&sg_is_last (sge)) { msg_rx =sk_psock_dequeue_msg (psock);kfree_sk_msg (msg_rx); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 452/1095 drm/exynos/exynos7_drm_decon: free resources when clk_set_parent() failed.
In reply to Greg Kroah-HartmanFrom: Jian Zhang <[email protected]>
[ Upstream commit 48b927770f8ad3f8cf4a024a552abf272af9f592 ]
In exynos7_decon_resume, When it fails, we must use clk_disable_unprepare() to free resource that have been used.
message")
--- drivers/gpu/drm/exynos/exynos7_drm_decon.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
drivers/gpu/drm/exynos/exynos7_drm_decon.c +13 -4
@@ -800,31 +800,40 @@ static int exynos7_decon_resume(struct device *dev)if (ret <0 ) {DRM_DEV_ERROR (dev,"Failed to prepare_enable the pclk [%d]\n" , ret); -return ret; + goto err_pclk_enable; } ret =clk_prepare_enable (ctx->aclk);if (ret <0 ) {DRM_DEV_ERROR (dev,"Failed to prepare_enable the aclk [%d]\n" , ret); -return ret; + goto err_aclk_enable; } ret =clk_prepare_enable (ctx->eclk);if (ret <0 ) {DRM_DEV_ERROR (dev,"Failed to prepare_enable the eclk [%d]\n" , ret); -return ret; + goto err_eclk_enable; } ret =clk_prepare_enable (ctx->vclk);if (ret <0 ) {DRM_DEV_ERROR (dev,"Failed to prepare_enable the vclk [%d]\n" , ret); -return ret; + goto err_vclk_enable; }return 0 ; + +err_vclk_enable: +clk_disable_unprepare (ctx->eclk); +err_eclk_enable: +clk_disable_unprepare (ctx->aclk); +err_aclk_enable: +clk_disable_unprepare (ctx->pclk); +err_pclk_enable: + return ret; }#endif
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 453/1095 bpftool: Add missing link types
In reply to Greg Kroah-HartmanFrom: Milan Landaverde <[email protected]>
[ Upstream commit fff3dfab17866f6ac5c5666839f6132b6c52f306 ]
Will display the link type names in bpftool link show output
--- tools/bpf/bpftool/link.c | 3 +++ 1 file changed, 3 insertions(+)
tools/bpf/bpftool/link.c +3 -0
@@ -20,6 +20,9 @@ static const char * const link_type_name[] = { [BPF_LINK_TYPE_CGROUP] = "cgroup", [BPF_LINK_TYPE_ITER] = "iter", [BPF_LINK_TYPE_NETNS] = "netns", + [BPF_LINK_TYPE_XDP] = "xdp", + [BPF_LINK_TYPE_PERF_EVENT] = "perf_event", + [BPF_LINK_TYPE_KPROBE_MULTI] = "kprobe_multi", };static struct hashmap *link_table;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 454/1095 bpf, x86: Generate trampolines from bpf_tramp_links
In reply to Greg Kroah-HartmanFrom: Kui-Feng Lee <[email protected]>
[ Upstream commit f7e0beaf39d3868dc700d4954b26cf8443c5d423 ]
Replace struct bpf_tramp_progs with struct bpf_tramp_links to collect struct bpf_tramp_link(s) for a trampoline. struct bpf_tramp_link extends bpf_link to act as a linked list node.
arch_prepare_bpf_trampoline() accepts a struct bpf_tramp_links to collects all bpf_tramp_link(s) that a trampoline should call.
Change BPF trampoline and bpf_struct_ops to pass bpf_tramp_links instead of bpf_tramp_progs.
--- arch/x86/net/bpf_jit_comp.c | 36 +++++++++-------- include/linux/bpf.h | 36 +++++++++++------ include/linux/bpf_types.h | 1 + include/uapi/linux/bpf.h | 1 + kernel/bpf/bpf_struct_ops.c | 71 +++++++++++++++++++++++---------- kernel/bpf/syscall.c | 23 ++++------- kernel/bpf/trampoline.c | 73 +++++++++++++++++++--------------- net/bpf/bpf_dummy_struct_ops.c | 24 ++++++++--- tools/bpf/bpftool/link.c | 1 + tools/include/uapi/linux/bpf.h | 1 + 10 files changed, 164 insertions(+), 103 deletions(-)
arch/x86/net/bpf_jit_comp.c +19 -17
@@ -1777,10 +1777,12 @@ static void restore_regs(const struct btf_func_model *m, u8 **prog, int nr_args, }static int invoke_bpf_prog (const struct btf_func_model *m,u8 **pprog, -struct bpf_prog *p,int stack_size,bool save_ret) +struct bpf_tramp_link *l,int stack_size, +bool save_ret) {u8 *prog = *pprog;u8 *jmp_insn; +struct bpf_prog *p = l->link.prog;/* arg1: mov rdi, progs[i] */ emit_mov_imm64 (&prog,BPF_REG_1 , (long ) p >>32 , (u32 ) (long ) p);
@@ -1865,14 +1867,14 @@ static int emit_cond_near_jump(u8 **pprog, void *func, void *ip, u8 jmp_cond) }static int invoke_bpf (const struct btf_func_model *m,u8 **pprog, -struct bpf_tramp_progs *tp,int stack_size, +struct bpf_tramp_links *tl,int stack_size,bool save_ret) {int i;u8 *prog = *pprog; -for (i =0 ; i < tp->nr_progs; i++) { -if (invoke_bpf_prog (m, &prog, tp->progs[i], stack_size, +for (i =0 ; i < tl->nr_links; i++) { +if (invoke_bpf_prog (m, &prog, tl->links[i], stack_size, save_ret))return -EINVAL ; }
@@ -1881,7 +1883,7 @@ static int invoke_bpf(const struct btf_func_model *m, u8 **pprog, }static int invoke_bpf_mod_ret (const struct btf_func_model *m,u8 **pprog, -struct bpf_tramp_progs *tp,int stack_size, +struct bpf_tramp_links *tl,int stack_size,u8 **branches) {u8 *prog = *pprog;
@@ -1892,8 +1894,8 @@ static int invoke_bpf_mod_ret(const struct btf_func_model *m, u8 **pprog,*/ emit_mov_imm32 (&prog, false,BPF_REG_0 ,0 );emit_stx (&prog,BPF_DW ,BPF_REG_FP ,BPF_REG_0 ,-8 ); -for (i =0 ; i < tp->nr_progs; i++) { -if (invoke_bpf_prog (m, &prog, tp->progs[i], stack_size, true)) +for (i =0 ; i < tl->nr_links; i++) { +if (invoke_bpf_prog (m, &prog, tl->links[i], stack_size, true))return -EINVAL ;/* mod_ret prog stored return value into [rbp - 8]. Emit:
@@ -1995,14 +1997,14 @@ static bool is_valid_bpf_tramp_flags(unsigned int flags)*/ int arch_prepare_bpf_trampoline (struct bpf_tramp_image *im,void *image,void *image_end,const struct btf_func_model *m,u32 flags, -struct bpf_tramp_progs *tprogs, +struct bpf_tramp_links *tlinks,void *orig_call) {int ret, i, nr_args = m->nr_args;int regs_off, ip_off, args_off, stack_size = nr_args *8 ; -struct bpf_tramp_progs *fentry = &tprogs[BPF_TRAMP_FENTRY ]; -struct bpf_tramp_progs *fexit = &tprogs[BPF_TRAMP_FEXIT ]; -struct bpf_tramp_progs *fmod_ret = &tprogs[BPF_TRAMP_MODIFY_RETURN ]; +struct bpf_tramp_links *fentry = &tlinks[BPF_TRAMP_FENTRY ]; +struct bpf_tramp_links *fexit = &tlinks[BPF_TRAMP_FEXIT ]; +struct bpf_tramp_links *fmod_ret = &tlinks[BPF_TRAMP_MODIFY_RETURN ];u8 **branches =NULL ;u8 *prog;bool save_ret;
@@ -2093,13 +2095,13 @@ int arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *image, void *i } } -if (fentry->nr_progs) +if (fentry->nr_links)if (invoke_bpf (m, &prog, fentry, regs_off, flags &BPF_TRAMP_F_RET_FENTRY_RET ))return -EINVAL ; -if (fmod_ret->nr_progs) { - branches =kcalloc (fmod_ret->nr_progs,sizeof (u8 *), +if (fmod_ret->nr_links) { + branches =kcalloc (fmod_ret->nr_links,sizeof (u8 *),GFP_KERNEL );if (!branches)return -ENOMEM ;
@@ -2126,7 +2128,7 @@ int arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *image, void *i prog +=X86_PATCH_SIZE ; } -if (fmod_ret->nr_progs) { +if (fmod_ret->nr_links) {/* From Intel 64 and IA-32 Architectures Optimization * Reference Manual, 3.4.1.4 Code Alignment, Assembly/Compiler * Coding Rule 11: All branch targets should be 16-byte
@@ -2136,12 +2138,12 @@ int arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *image, void *i/* Update the branches saved in invoke_bpf_mod_ret with the * aligned address of do_fexit. */ -for (i =0 ; i < fmod_ret->nr_progs; i++) +for (i =0 ; i < fmod_ret->nr_links; i++)emit_cond_near_jump (&branches[i], prog, branches[i],X86_JNE ); } -if (fexit->nr_progs) +if (fexit->nr_links)if (invoke_bpf (m, &prog, fexit, regs_off, false)) { ret = -EINVAL ; goto cleanup;
include/linux/bpf.h +24 -12
@@ -674,11 +674,11 @@ struct btf_func_model {/* Each call __bpf_prog_enter + call bpf_func + call __bpf_prog_exit is ~50 * bytes on x86. */ -#define BPF_MAX_TRAMP_PROGS 38 +#define BPF_MAX_TRAMP_LINKS 38 -struct bpf_tramp_progs { -struct bpf_prog *progs[BPF_MAX_TRAMP_PROGS ]; -int nr_progs; +struct bpf_tramp_links { +struct bpf_tramp_link *links[BPF_MAX_TRAMP_LINKS ]; +int nr_links; };/* Different use cases for BPF trampoline:
@@ -704,7 +704,7 @@ struct bpf_tramp_progs {struct bpf_tramp_image ;int arch_prepare_bpf_trampoline (struct bpf_tramp_image *tr,void *image,void *image_end,const struct btf_func_model *m,u32 flags, -struct bpf_tramp_progs *tprogs, +struct bpf_tramp_links *tlinks,void *orig_call);/* these two functions are called from generated trampoline */ u64 notrace __bpf_prog_enter(struct bpf_prog *prog);
@@ -803,9 +803,10 @@ static __always_inline __nocfi unsigned int bpf_dispatcher_nop_func( {return bpf_func (ctx, insnsi); } +#ifdef CONFIG_BPF_JIT -int bpf_trampoline_link_prog (struct bpf_prog *prog,struct bpf_trampoline *tr); -int bpf_trampoline_unlink_prog (struct bpf_prog *prog,struct bpf_trampoline *tr); +int bpf_trampoline_link_prog (struct bpf_tramp_link *link,struct bpf_trampoline *tr); +int bpf_trampoline_unlink_prog (struct bpf_tramp_link *link,struct bpf_trampoline *tr);struct bpf_trampoline *bpf_trampoline_get (u64 key,struct bpf_attach_target_info *tgt_info);void bpf_trampoline_put (struct bpf_trampoline *tr);
@@ -856,12 +857,12 @@ int bpf_jit_charge_modmem(u32 size);void bpf_jit_uncharge_modmem (u32 size);bool bpf_prog_has_trampoline (const struct bpf_prog *prog);#else -static inline int bpf_trampoline_link_prog (struct bpf_prog *prog, +static inline int bpf_trampoline_link_prog (struct bpf_tramp_link *link,struct bpf_trampoline *tr) {return -ENOTSUPP ; } -static inline int bpf_trampoline_unlink_prog (struct bpf_prog *prog, +static inline int bpf_trampoline_unlink_prog (struct bpf_tramp_link *link,struct bpf_trampoline *tr) {return -ENOTSUPP ;
@@ -960,7 +961,6 @@ struct bpf_prog_aux {bool tail_call_reachable;bool xdp_has_frags;bool use_bpf_prog_pack; -struct hlist_node tramp_hlist;/* BTF_KIND_FUNC_PROTO for valid attach_btf_id */ const struct btf_type *attach_func_proto;/* function name for valid attach_btf_id */
@@ -1047,6 +1047,18 @@ struct bpf_link_ops { struct bpf_link_info *info); }; +struct bpf_tramp_link { +struct bpf_link link; +struct hlist_node tramp_hlist; +}; + +struct bpf_tracing_link { +struct bpf_tramp_link link; +enum bpf_attach_type attach_type; +struct bpf_trampoline *trampoline; +struct bpf_prog *tgt_prog; +}; +struct bpf_link_primer {struct bpf_link *link;struct file *file;
@@ -1084,8 +1096,8 @@ bool bpf_struct_ops_get(const void *kdata);void bpf_struct_ops_put (const void *kdata);int bpf_struct_ops_map_sys_lookup_elem (struct bpf_map *map,void *key,void *value); -int bpf_struct_ops_prepare_trampoline (struct bpf_tramp_progs *tprogs, -struct bpf_prog *prog, +int bpf_struct_ops_prepare_trampoline (struct bpf_tramp_links *tlinks, +struct bpf_tramp_link *link,const struct btf_func_model *model,void *image,void *image_end);static inline bool bpf_try_module_get (const void *data,struct module *owner)
include/linux/bpf_types.h +1 -0
@@ -141,3 +141,4 @@ BPF_LINK_TYPE(BPF_LINK_TYPE_XDP, xdp) BPF_LINK_TYPE(BPF_LINK_TYPE_PERF_EVENT, perf)#endif BPF_LINK_TYPE(BPF_LINK_TYPE_KPROBE_MULTI, kprobe_multi) +BPF_LINK_TYPE (BPF_LINK_TYPE_STRUCT_OPS , struct_ops)
include/uapi/linux/bpf.h +1 -0
@@ -1013,6 +1013,7 @@ enum bpf_link_type {BPF_LINK_TYPE_XDP =6 ,BPF_LINK_TYPE_PERF_EVENT =7 ,BPF_LINK_TYPE_KPROBE_MULTI =8 , +BPF_LINK_TYPE_STRUCT_OPS =9 , MAX_BPF_LINK_TYPE, };
kernel/bpf/bpf_struct_ops.c +49 -22
155 lines not on this page · raw message
kernel/bpf/syscall.c +8 -15
@@ -2640,19 +2640,12 @@ struct bpf_link *bpf_link_get_from_fd(u32 ufd) }EXPORT_SYMBOL (bpf_link_get_from_fd); -struct bpf_tracing_link { -struct bpf_link link; -enum bpf_attach_type attach_type; -struct bpf_trampoline *trampoline; -struct bpf_prog *tgt_prog; -}; -static void bpf_tracing_link_release (struct bpf_link *link) {struct bpf_tracing_link *tr_link = - container_of(link, struct bpf_tracing_link, link); + container_of(link, struct bpf_tracing_link, link.link); -WARN_ON_ONCE (bpf_trampoline_unlink_prog (link->prog, +WARN_ON_ONCE (bpf_trampoline_unlink_prog (&tr_link->link, tr_link->trampoline));bpf_trampoline_put (tr_link->trampoline);
@@ -2665,7 +2658,7 @@ static void bpf_tracing_link_release(struct bpf_link *link)static void bpf_tracing_link_dealloc (struct bpf_link *link) {struct bpf_tracing_link *tr_link = - container_of(link, struct bpf_tracing_link, link); + container_of(link, struct bpf_tracing_link, link.link);kfree (tr_link); }
@@ -2674,7 +2667,7 @@ static void bpf_tracing_link_show_fdinfo(const struct bpf_link *link, struct seq_file *seq) {struct bpf_tracing_link *tr_link = - container_of(link, struct bpf_tracing_link, link); + container_of(link, struct bpf_tracing_link, link.link); seq_printf(seq, "attach_type:\t%d\n",
@@ -2685,7 +2678,7 @@ static int bpf_tracing_link_fill_link_info(const struct bpf_link *link, struct bpf_link_info *info) {struct bpf_tracing_link *tr_link = - container_of(link, struct bpf_tracing_link, link); + container_of(link, struct bpf_tracing_link, link.link); info->tracing.attach_type = tr_link->attach_type; bpf_trampoline_unpack_key(tr_link->trampoline->key,
@@ -2766,7 +2759,7 @@ static int bpf_tracing_prog_attach(struct bpf_prog *prog, err = -ENOMEM ; goto out_put_prog; } -bpf_link_init (&link->link,BPF_LINK_TYPE_TRACING , +bpf_link_init (&link->link.link,BPF_LINK_TYPE_TRACING , &bpf_tracing_link_lops, prog); link->attach_type = prog->expected_attach_type;
@@ -2836,11 +2829,11 @@ static int bpf_tracing_prog_attach(struct bpf_prog *prog, tgt_prog = prog->aux->dst_prog; } - err =bpf_link_prime (&link->link, &link_primer); + err =bpf_link_prime (&link->link.link, &link_primer);if (err) goto out_unlock; - err =bpf_trampoline_link_prog (prog, tr); + err =bpf_trampoline_link_prog (&link->link, tr);if (err) {bpf_link_cleanup (&link_primer); link =NULL ;
kernel/bpf/trampoline.c +41 -32
171 lines not on this page · raw message
net/bpf/bpf_dummy_struct_ops.c +19 -5
@@ -72,13 +72,16 @@ static int dummy_ops_call_op(void *image, struct bpf_dummy_ops_test_args *args) args->args[3], args->args[4]); } +extern const struct bpf_link_ops bpf_struct_ops_link_lops; +int bpf_struct_ops_test_run (struct bpf_prog *prog,const union bpf_attr *kattr,union bpf_attr __user *uattr) {const struct bpf_struct_ops *st_ops = &bpf_bpf_dummy_ops;const struct btf_type *func_proto;struct bpf_dummy_ops_test_args *args; -struct bpf_tramp_progs *tprogs; +struct bpf_tramp_links *tlinks; +struct bpf_tramp_link *link =NULL ;void *image =NULL ;unsigned int op_idx;int prog_ret;
@@ -92,8 +95,8 @@ int bpf_struct_ops_test_run(struct bpf_prog *prog, const union bpf_attr *kattr,if (IS_ERR (args))return PTR_ERR (args); - tprogs =kcalloc (BPF_TRAMP_MAX ,sizeof (*tprogs),GFP_KERNEL ); -if (!tprogs) { + tlinks =kcalloc (BPF_TRAMP_MAX ,sizeof (*tlinks),GFP_KERNEL ); +if (!tlinks) { err = -ENOMEM ; goto out; }
@@ -105,8 +108,17 @@ int bpf_struct_ops_test_run(struct bpf_prog *prog, const union bpf_attr *kattr, }set_vm_flush_reset_perms (image); + link =kzalloc (sizeof (*link),GFP_USER ); +if (!link) { + err = -ENOMEM ; + goto out; + } +/* prog doesn't take the ownership of the reference from caller */ +bpf_prog_inc (prog); +bpf_link_init (&link->link,BPF_LINK_TYPE_STRUCT_OPS , &bpf_struct_ops_link_lops, prog); + op_idx = prog->expected_attach_type; - err =bpf_struct_ops_prepare_trampoline (tprogs, prog, + err =bpf_struct_ops_prepare_trampoline (tlinks, link, &st_ops->func_models[op_idx], image, image +PAGE_SIZE );if (err <0 )
@@ -124,7 +136,9 @@ int bpf_struct_ops_test_run(struct bpf_prog *prog, const union bpf_attr *kattr, out:kfree (args);bpf_jit_free_exec (image); -kfree (tprogs); +if (link) +bpf_link_put (&link->link); +kfree (tlinks);return err; }
tools/bpf/bpftool/link.c +1 -0
@@ -23,6 +23,7 @@ static const char * const link_type_name[] = { [BPF_LINK_TYPE_XDP] = "xdp", [BPF_LINK_TYPE_PERF_EVENT] = "perf_event", [BPF_LINK_TYPE_KPROBE_MULTI] = "kprobe_multi", + [BPF_LINK_TYPE_STRUCT_OPS] = "struct_ops", };static struct hashmap *link_table;
tools/include/uapi/linux/bpf.h +1 -0
@@ -1013,6 +1013,7 @@ enum bpf_link_type {BPF_LINK_TYPE_XDP =6 ,BPF_LINK_TYPE_PERF_EVENT =7 ,BPF_LINK_TYPE_KPROBE_MULTI =8 , +BPF_LINK_TYPE_STRUCT_OPS =9 , MAX_BPF_LINK_TYPE, };
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 455/1095 bpf, x64: Add predicate for bpf2bpf with tailcalls support in JIT
In reply to Greg Kroah-HartmanFrom: Tony Ambardar <[email protected]>
[ Upstream commit 95acd8817e66d031d2e6ee7def3f1e1874819317 ]
The BPF core/verifier is hard-coded to permit mixing bpf2bpf and tail calls for only x86-64. Change the logic to instead rely on a new weak function 'bool bpf_jit_supports_subprog_tailcalls(void)', which a capable JIT backend can override.
Update the x86-64 eBPF JIT to reflect this.
--- arch/x86/net/bpf_jit_comp.c | 6 ++++++ include/linux/filter.h | 1 + kernel/bpf/core.c | 6 ++++++ kernel/bpf/verifier.c | 3 ++- 4 files changed, 15 insertions(+), 1 deletion(-)
arch/x86/net/bpf_jit_comp.c +6 -0
@@ -2477,3 +2477,9 @@ void *bpf_arch_text_copy(void *dst, void *src, size_t len)return ERR_PTR (-EINVAL );return dst; } + +/* Indicate the JIT backend supports mixing bpf2bpf and tailcalls. */ +bool bpf_jit_supports_subprog_tailcalls (void ) +{ +return true; +}
include/linux/filter.h +1 -0
@@ -948,6 +948,7 @@ u64 __bpf_call_base(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5);struct bpf_prog *bpf_int_jit_compile (struct bpf_prog *prog);void bpf_jit_compile (struct bpf_prog *prog);bool bpf_jit_needs_zext (void ); +bool bpf_jit_supports_subprog_tailcalls (void );bool bpf_jit_supports_kfunc_call (void );bool bpf_helper_changes_pkt_data (void *func);
kernel/bpf/core.c +6 -0
@@ -2712,6 +2712,12 @@ bool __weak bpf_jit_needs_zext(void)return false; } +/* Return TRUE if the JIT backend supports mixing bpf2bpf and tailcalls. */ +bool __weak bpf_jit_supports_subprog_tailcalls (void ) +{ +return false; +} +bool __weak bpf_jit_supports_kfunc_call (void ) {return false;
kernel/bpf/verifier.c +2 -1
@@ -5696,7 +5696,8 @@ static bool may_update_sockmap(struct bpf_verifier_env *env, int func_id)static bool allow_tail_call_in_subprogs (struct bpf_verifier_env *env) { -return env->prog->jit_requested &&IS_ENABLED (CONFIG_X86_64 ); +return env->prog->jit_requested && +bpf_jit_supports_subprog_tailcalls (); } static int check_map_func_compatibility(struct bpf_verifier_env *env,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 456/1095 bpf, x86: fix freeing of not-finalized bpf_prog_pack
In reply to Greg Kroah-HartmanFrom: Song Liu <[email protected]>
[ Upstream commit 1d5f82d9dd477d5c66e0214a68c3e4f308eadd6d ]
syzbot reported a few issues with bpf_prog_pack [1], [2]. This only happens with multiple subprogs. In jit_subprogs(), we first call bpf_int_jit_compile() on each sub program. And then, we call it on each sub program again. jit_data is not freed in the first call of bpf_int_jit_compile(). Similarly we don't call bpf_jit_binary_pack_finalize() in the first call of bpf_int_jit_compile().
If bpf_int_jit_compile() failed for one sub program, we will call bpf_jit_binary_pack_finalize() for this sub program. However, we don't have a chance to call it for other sub programs. Then we will hit "goto out_free" in jit_subprogs(), and call bpf_jit_free on some subprograms that haven't got bpf_jit_binary_pack_finalize() yet.
At this point, bpf_jit_binary_pack_free() is called and the whole 2MB page is freed erroneously.
Fix this with a custom bpf_jit_free() for x86_64, which calls bpf_jit_binary_pack_finalize() if necessary. Also, with custom bpf_jit_free(), bpf_prog_aux->use_bpf_prog_pack is not needed any more, remove it.
[1] https://syzkaller.appspot.com/bug?extid=2f649ec6d2eea1495a8f
[2] https://syzkaller.appspot.com/bug?extid=87f65c75f4a72db05445
--- arch/x86/net/bpf_jit_comp.c | 25 +++++++++++++++++++++++++ include/linux/bpf.h | 1 - include/linux/filter.h | 8 ++++++++ kernel/bpf/core.c | 29 ++++++++++++----------------- 4 files changed, 45 insertions(+), 18 deletions(-)
arch/x86/net/bpf_jit_comp.c +25 -0
@@ -2483,3 +2483,28 @@ bool bpf_jit_supports_subprog_tailcalls(void) {return true; } + +void bpf_jit_free (struct bpf_prog *prog) +{ +if (prog->jited) { +struct x64_jit_data *jit_data = prog->aux->jit_data; +struct bpf_binary_header *hdr; + +/* +* If we fail the final pass of JIT (from jit_subprogs), +* the program may not be finalized yet. Call finalize here +* before freeing it. +*/ +if (jit_data) { +bpf_jit_binary_pack_finalize (prog, jit_data->header, + jit_data->rw_header); +kvfree (jit_data->addrs); +kfree (jit_data); + } + hdr =bpf_jit_binary_pack_hdr (prog); +bpf_jit_binary_pack_free (hdr,NULL ); +WARN_ON_ONCE (!bpf_prog_kallsyms_verify_off (prog)); + } + +bpf_prog_unlock_free (prog); +}
include/linux/bpf.h +0 -1
@@ -960,7 +960,6 @@ struct bpf_prog_aux {bool sleepable;bool tail_call_reachable;bool xdp_has_frags; -bool use_bpf_prog_pack;/* BTF_KIND_FUNC_PROTO for valid attach_btf_id */ const struct btf_type *attach_func_proto;/* function name for valid attach_btf_id */
include/linux/filter.h +8 -0
@@ -1061,6 +1061,14 @@ u64 bpf_jit_alloc_exec_limit(void);void *bpf_jit_alloc_exec (unsigned long size);void bpf_jit_free_exec (void *addr);void bpf_jit_free (struct bpf_prog *fp); +struct bpf_binary_header * +bpf_jit_binary_pack_hdr (const struct bpf_prog *fp); + +static inline bool bpf_prog_kallsyms_verify_off (const struct bpf_prog *fp) +{ +return list_empty (&fp->aux->ksym.lnode) || + fp->aux->ksym.lnode.prev ==LIST_POISON2 ; +}struct bpf_binary_header * bpf_jit_binary_pack_alloc(unsigned int proglen, u8 **ro_image,
kernel/bpf/core.c +12 -17
@@ -649,12 +649,6 @@ static bool bpf_prog_kallsyms_candidate(const struct bpf_prog *fp)return fp->jited && !bpf_prog_was_classic (fp); } -static bool bpf_prog_kallsyms_verify_off (const struct bpf_prog *fp) -{ -return list_empty (&fp->aux->ksym.lnode) || - fp->aux->ksym.lnode.prev ==LIST_POISON2 ; -} -void bpf_prog_kallsyms_add (struct bpf_prog *fp) { if (!bpf_prog_kallsyms_candidate(fp) ||
@@ -1149,7 +1143,6 @@ int bpf_jit_binary_pack_finalize(struct bpf_prog *prog,bpf_prog_pack_free (ro_header);return PTR_ERR (ptr); } - prog->aux->use_bpf_prog_pack = true;return 0 ; }
@@ -1173,17 +1166,23 @@ void bpf_jit_binary_pack_free(struct bpf_binary_header *ro_header,bpf_jit_uncharge_modmem (size); } +struct bpf_binary_header * +bpf_jit_binary_pack_hdr (const struct bpf_prog *fp) +{ +unsigned long real_start = (unsigned long )fp->bpf_func; +unsigned long addr; + + addr = real_start &BPF_PROG_CHUNK_MASK ; +return (void *)addr; +} +static inline struct bpf_binary_header *bpf_jit_binary_hdr (const struct bpf_prog *fp) {unsigned long real_start = (unsigned long )fp->bpf_func;unsigned long addr; -if (fp->aux->use_bpf_prog_pack) - addr = real_start &BPF_PROG_CHUNK_MASK ; -else - addr = real_start &PAGE_MASK ; - + addr = real_start &PAGE_MASK ;return (void *)addr; }
@@ -1196,11 +1195,7 @@ void __weak bpf_jit_free(struct bpf_prog *fp)if (fp->jited) {struct bpf_binary_header *hdr =bpf_jit_binary_hdr (fp); -if (fp->aux->use_bpf_prog_pack) -bpf_jit_binary_pack_free (hdr,NULL /* rw_buffer */ ); -else -bpf_jit_binary_free (hdr); - +bpf_jit_binary_free (hdr);WARN_ON_ONCE (!bpf_prog_kallsyms_verify_off (fp)); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 457/1095 tcp: make retransmitted SKB fit into the send window
In reply to Greg Kroah-HartmanFrom: Yonglong Li <[email protected]>
[ Upstream commit 536a6c8e05f95e3d1118c40ae8b3022ee2d05d52 ]
current code of __tcp_retransmit_skb only check TCP_SKB_CB(skb)->seq in send window, and TCP_SKB_CB(skb)->seq_end maybe out of send window. If receiver has shrunk his window, and skb is out of new window, it should retransmit a smaller portion of the payload.
test packetdrill script:
0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
+0 fcntl(3, F_GETFL) = 0x2 (flags O_RDWR)
+0 fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
+0 connect(3, ..., ...) = -1 EINPROGRESS (Operation now in progress) +0 > S 0:0(0) win 65535 <mss 1460,sackOK,TS val 100 ecr 0,nop,wscale 8>
+.05 < S. 0:0(0) ack 1 win 6000 <mss 1000,nop,nop,sackOK>
+0 > . 1:1(0) ack 1
+0 write(3, ..., 10000) = 10000
+0 > . 1:2001(2000) ack 1 win 65535
+0 > . 2001:4001(2000) ack 1 win 65535
+0 > . 4001:6001(2000) ack 1 win 65535
+.05 < . 1:1(0) ack 4001 win 1001
and tcpdump show:
192.168.226.67.55 > 192.0.2.1.8080: Flags [.], seq 1:2001, ack 1, win 65535, length 2000 192.168.226.67.55 > 192.0.2.1.8080: Flags [.], seq 2001:4001, ack 1, win 65535, length 2000 192.168.226.67.55 > 192.0.2.1.8080: Flags [P.], seq 4001:5001, ack 1, win 65535, length 1000 192.168.226.67.55 > 192.0.2.1.8080: Flags [.], seq 5001:6001, ack 1, win 65535, length 1000 192.0.2.1.8080 > 192.168.226.67.55: Flags [.], ack 4001, win 1001, length 0 192.168.226.67.55 > 192.0.2.1.8080: Flags [.], seq 5001:6001, ack 1, win 65535, length 1000 192.168.226.67.55 > 192.0.2.1.8080: Flags [P.], seq 4001:5001, ack 1, win 65535, length 1000
when cient retract window to 1001, send window is [4001,5002], but TLP send 5001-6001 packet which is out of send window.
--- net/ipv4/tcp_output.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)
net/ipv4/tcp_output.c +16 -7
@@ -3140,7 +3140,7 @@ int __tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb, int segs)struct tcp_sock *tp =tcp_sk (sk);unsigned int cur_mss;int diff, len, err; - +int avail_wnd;/* Inconclusive MTU probe */ if (icsk->icsk_mtup.probe_size)
@@ -3162,17 +3162,25 @@ int __tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb, int segs)return -EHOSTUNREACH ;/* Routing failure or similar. */ cur_mss =tcp_current_mss (sk); + avail_wnd =tcp_wnd_end (tp) -TCP_SKB_CB (skb)->seq;/* If receiver has shrunk his window, and skb is out of * new window, do not retransmit it. The exception is the * case, when window is shrunk to zero. In this case -* our retransmit serves as a zero window probe. +* our retransmit of one segment serves as a zero window probe. */ -if (!before (TCP_SKB_CB (skb)->seq,tcp_wnd_end (tp)) && -TCP_SKB_CB (skb)->seq != tp->snd_una) -return -EAGAIN ; +if (avail_wnd <=0 ) { +if (TCP_SKB_CB (skb)->seq != tp->snd_una) +return -EAGAIN ; + avail_wnd = cur_mss; + } len = cur_mss * segs; +if (len > avail_wnd) { + len =rounddown (avail_wnd, cur_mss); +if (!len) + len = avail_wnd; + }if (skb->len > len) {if (tcp_fragment (sk,TCP_FRAG_IN_RTX_QUEUE , skb, len, cur_mss,GFP_ATOMIC ))
@@ -3186,8 +3194,9 @@ int __tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb, int segs) diff -=tcp_skb_pcount (skb);if (diff)tcp_adjust_pcount (sk, skb, diff); -if (skb->len < cur_mss) -tcp_retrans_try_collapse (sk, skb, cur_mss); + avail_wnd =min_t (int, avail_wnd, cur_mss); +if (skb->len < avail_wnd) +tcp_retrans_try_collapse (sk, skb, avail_wnd); }/* RFC3168, section 6.1.1.1. ECN fallback */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 458/1095 libbpf: Fix the name of a reused map
In reply to Greg Kroah-HartmanFrom: Anquan Wu <[email protected]>
[ Upstream commit bf3f00378524adae16628cbadbd11ba7211863bb ]
BPF map name is limited to BPF_OBJ_NAME_LEN.
A map name is defined as being longer than BPF_OBJ_NAME_LEN, it will be truncated to BPF_OBJ_NAME_LEN when a userspace program calls libbpf to create the map. A pinned map also generates a path in the /sys. If the previous program wanted to reuse the map, it can not get bpf_map by name, because the name of the map is only partially the same as the name which get from pinned path.
The syscall information below show that map name "process_pinned_map" is truncated to "process_pinned_".
bpf(BPF_OBJ_GET, {pathname="/sys/fs/bpf/process_pinned_map",
bpf_fd=0, file_flags=0}, 144) = -1 ENOENT (No such file or directory)
bpf(BPF_MAP_CREATE, {map_type=BPF_MAP_TYPE_HASH, key_size=4,
value_size=4,max_entries=1024, map_flags=0, inner_map_fd=0,
map_name="process_pinned_",map_ifindex=0, btf_fd=3, btf_key_type_id=6,
btf_value_type_id=10,btf_vmlinux_value_type_id=0}, 72) = 4This patch check that if the name of pinned map are the same as the actual name for the first (BPF_OBJ_NAME_LEN - 1),
bpf map still uses the name which is included in bpf object.
--- tools/lib/bpf/libbpf.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
tools/lib/bpf/libbpf.c +7 -2
@@ -4271,7 +4271,7 @@ static int bpf_get_map_info_from_fdinfo(int fd, struct bpf_map_info *info)int bpf_map__reuse_fd (struct bpf_map *map,int fd) {struct bpf_map_info info = {}; -__u32 len =sizeof (info); +__u32 len =sizeof (info), name_len;int new_fd, err;char *new_name;
@@ -4281,7 +4281,12 @@ int bpf_map__reuse_fd(struct bpf_map *map, int fd)if (err)return libbpf_err (err); - new_name =strdup (info.name); + name_len =strlen (info.name); +if (name_len ==BPF_OBJ_NAME_LEN -1 &&strncmp (map->name, info.name, name_len) ==0 ) + new_name =strdup (map->name); +else + new_name =strdup (info.name); +if (!new_name)return libbpf_err (-errno);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 459/1095 kunit: executor: Fix a memory leak on failure in kunit_filter_tests
In reply to Greg Kroah-HartmanFrom: David Gow <[email protected]>
[ Upstream commit 94681e289bf5d10c9db9db143d1a22d8717205c5 ]
It's possible that memory allocation for 'filtered' will fail, but for the copy of the suite to succeed. In this case, the copy could be leaked.
Properly free 'copy' in the error case for the allocation of 'filtered' failing.
Note that there may also have been a similar issue in kunit_filter_subsuites, before it was removed in "kunit: flatten kunit_suite*** to kunit_suite** in .kunit_test_suites".
This was reported by clang-analyzer via the kernel test robot, here:
https://lore.kernel.org/all/[email protected]/
And by smatch via Dan Carpenter and the kernel test robot:
https://lore.kernel.org/all/[email protected]/
--- lib/kunit/executor.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
lib/kunit/executor.c +3 -1
@@ -76,8 +76,10 @@ kunit_filter_tests(struct kunit_suite *const suite, const char *test_glob)memcpy (copy, suite,sizeof (*copy)); filtered =kcalloc (n +1 ,sizeof (*filtered),GFP_KERNEL ); -if (!filtered) +if (!filtered) { +kfree (copy);return ERR_PTR (-ENOMEM ); + } n =0 ;kunit_suite_for_each_test_case (suite, test_case) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 460/1095 selftests: timers: valid-adjtimex: build fix for newer toolchains
In reply to Greg Kroah-HartmanFrom: Wolfram Sang <[email protected]>
[ Upstream commit 9a162977d20436be5678a8e21a8e58eb4616d86a ]
Toolchains with an include file 'sys/timex.h' based on 3.18 will have a 'clock_adjtime' definition added, so it can't be static in the code:
valid-adjtimex.c:43:12: error: static declaration of ‘clock_adjtime’ follows non-static declaration
--- tools/testing/selftests/timers/valid-adjtimex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/timers/valid-adjtimex.c +1 -1
@@ -40,7 +40,7 @@#define ADJ_SETOFFSET 0x0100#include <sys/syscall.h> -static int clock_adjtime (clockid_t id,struct timex *tx) +int clock_adjtime (clockid_t id,struct timex *tx) {return syscall (__NR_clock_adjtime, id, tx); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 461/1095 selftests: timers: clocksource-switch: fix passing errors from child
In reply to Greg Kroah-HartmanFrom: Wolfram Sang <[email protected]>
[ Upstream commit 4d8f52ac5fa9eede7b7aa2f2d67c841d9eeb655f ]
The return value from system() is a waitpid-style integer. Do not return it directly because with the implicit masking in exit() it will always return 0. Access it with appropriate macros to really pass on errors.
--- tools/testing/selftests/timers/clocksource-switch.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/timers/clocksource-switch.c +3 -3
@@ -110,10 +110,10 @@ int run_tests(int secs)sprintf (buf,"./inconsistency-check -t %i" , secs); ret =system (buf); -if (ret) -return ret; +if (WIFEXITED (ret) &&WEXITSTATUS (ret)) +return WEXITSTATUS (ret); ret =system ("./nanosleep" ); -return ret; +return WIFEXITED (ret) ?WEXITSTATUS (ret) :0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 462/1095 bpf: Fix subprog names in stack traces.
In reply to Greg Kroah-HartmanFrom: Alexei Starovoitov <[email protected]>
[ Upstream commit 9c7c48d6a1e2eb5192ad5294c1c4dbd42a88e88b ]
The commit 7337224fc150 ("bpf: Improve the info.func_info and info.func_info_rec_size behavior") accidently made bpf_prog_ksym_set_name() conservative for bpf subprograms.
Fixed it so instead of "bpf_prog_tag_F" the stack traces print "bpf_prog_tag_full_subprog_name".
--- kernel/bpf/verifier.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
kernel/bpf/verifier.c +1 -3
@@ -13016,6 +13016,7 @@ static int jit_subprogs(struct bpf_verifier_env *env)/* Below members will be freed only at prog->aux */ func[i]->aux->btf = prog->aux->btf; func[i]->aux->func_info = prog->aux->func_info; + func[i]->aux->func_info_cnt = prog->aux->func_info_cnt; func[i]->aux->poke_tab = prog->aux->poke_tab; func[i]->aux->size_poke_tab = prog->aux->size_poke_tab;
@@ -13028,9 +13029,6 @@ static int jit_subprogs(struct bpf_verifier_env *env) poke->aux = func[i]->aux; } -/* Use bpf_prog_F_tag to indicate functions in stack traces. -* Long term would need debug info to populate names -*/ func[i]->aux->name[0 ] ='F' ; func[i]->aux->stack_depth = env->subprog_info[i].stack_depth; func[i]->jit_requested =1 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 463/1095 fs: check FMODE_LSEEK to control internal pipe splicing
In reply to Greg Kroah-HartmanFrom: Jason A. Donenfeld <[email protected]>
[ Upstream commit 97ef77c52b789ec1411d360ed99dca1efe4b2c81 ]
The original direct splicing mechanism from Jens required the input to be a regular file because it was avoiding the special socket case. It also recognized blkdevs as being close enough to a regular file. But it forgot about chardevs, which behave the same way and work fine here.
This is an okayish heuristic, but it doesn't totally work. For example, a few chardevs should be spliceable here. And a few regular files shouldn't. This patch fixes this by instead checking whether FMODE_LSEEK is set, which represents decently enough what we need rewinding for when splicing to internal pipes.
--- fs/splice.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
fs/splice.c +4 -6
@@ -814,17 +814,15 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd, {struct pipe_inode_info *pipe;long ret, bytes; -umode_t i_mode;size_t len;int i, flags, more;/* -* We require the input being a regular file, as we don't want to -* randomly drop data for eg socket -> socket splicing. Use the -* piped splicing for that! +* We require the input to be seekable, as we don't want to randomly +* drop data for eg socket -> socket splicing. Use the piped splicing +* for that! */ - i_mode =file_inode (in)->i_mode; -if (unlikely (!S_ISREG (i_mode) && !S_ISBLK (i_mode))) +if (unlikely (!(in->f_mode &FMODE_LSEEK )))return -EINVAL ;/*
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 464/1095 media: cedrus: h265: Fix flag name
In reply to Greg Kroah-HartmanFrom: Jernej Skrabec <[email protected]>
[ Upstream commit 104a70e1d0bcef28db13c4192b8729086089651c ]
Bit 21 in register 0x24 (slice header info 1) actually represents negated version of low delay flag. This can be seen in vendor Cedar library source code. While this flag is not part of the standard, it can be found in reference HEVC implementation.
Fix macro name and change it to flag.
--- drivers/staging/media/sunxi/cedrus/cedrus_h265.c | 4 +++- drivers/staging/media/sunxi/cedrus/cedrus_regs.h | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/staging/media/sunxi/cedrus/cedrus_h265.c +3 -1
@@ -559,7 +559,6 @@ static void cedrus_h265_setup(struct cedrus_ctx *ctx, reg =VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_TC_OFFSET_DIV2 (slice_params->slice_tc_offset_div2) |VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_BETA_OFFSET_DIV2 (slice_params->slice_beta_offset_div2) | -VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_POC_BIGEST_IN_RPS_ST (decode_params->num_poc_st_curr_after ==0 ) |VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_CR_QP_OFFSET (slice_params->slice_cr_qp_offset) |VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_CB_QP_OFFSET (slice_params->slice_cb_qp_offset) |VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_QP_DELTA (slice_params->slice_qp_delta);
@@ -572,6 +571,9 @@ static void cedrus_h265_setup(struct cedrus_ctx *ctx,V4L2_HEVC_SLICE_PARAMS_FLAG_SLICE_LOOP_FILTER_ACROSS_SLICES_ENABLED , slice_params->flags); +if (decode_params->num_poc_st_curr_after ==0 ) + reg |=VE_DEC_H265_DEC_SLICE_HDR_INFO1_FLAG_SLICE_NOT_LOW_DELAY ; +cedrus_write (dev,VE_DEC_H265_DEC_SLICE_HDR_INFO1 , reg); chroma_log2_weight_denom = pred_weight_table->luma_log2_weight_denom +
drivers/staging/media/sunxi/cedrus/cedrus_regs.h +1 -2
@@ -377,13 +377,12 @@#define VE_DEC_H265_DEC_SLICE_HDR_INFO1_FLAG_SLICE_DEBLOCKING_FILTER_DISABLED BIT(23)#define VE_DEC_H265_DEC_SLICE_HDR_INFO1_FLAG_SLICE_LOOP_FILTER_ACROSS_SLICES_ENABLED BIT(22) +#define VE_DEC_H265_DEC_SLICE_HDR_INFO1_FLAG_SLICE_NOT_LOW_DELAY BIT(21)#define VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_TC_OFFSET_DIV2 (v) \ SHIFT_AND_MASK_BITS(v, 31, 28)#define VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_BETA_OFFSET_DIV2 (v) \ SHIFT_AND_MASK_BITS(v, 27, 24) -#define VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_POC_BIGEST_IN_RPS_ST (v) \ - ((v) ? BIT(21) : 0)#define VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_CR_QP_OFFSET (v) \ SHIFT_AND_MASK_BITS(v, 20, 16)#define VE_DEC_H265_DEC_SLICE_HDR_INFO1_SLICE_CB_QP_OFFSET (v) \
Signature · 1 line
2.35.1