5.19.2-rc1 review
Subsystems (12)
Greg Kroah-Hartman
maintainerPATCH 369/1157 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
@@ -1919,6 +1919,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>
@@ -1073,6 +1074,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 370/1157 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 371/1157 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
@@ -591,11 +591,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 372/1157 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 373/1157 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 374/1157 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
@@ -610,6 +610,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
@@ -500,10 +500,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 375/1157 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 376/1157 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 377/1157 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
@@ -520,6 +520,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:
@@ -755,7 +756,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 378/1157 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,18 +1161,30 @@ 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) {if (*nplanes != q_data->fmt->colplanes)return -EINVAL ;for (i =0 ; i < *nplanes; i++) { -if (sizes[i] < q_data->sizeimage[i]) +if (sizes[i] < tmp_q.sizeimage[i])return -EINVAL ; }return 0 ;
@@ -1181,7 +1193,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 ; }
@@ -1381,11 +1393,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",
@@ -1691,22 +1698,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;
@@ -1832,35 +1834,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 379/1157 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 ; }
@@ -1204,6 +1210,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);
@@ -1235,11 +1243,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,
@@ -1438,6 +1450,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;
@@ -1486,24 +1512,11 @@ static int mxc_jpeg_buf_prepare(struct vb2_buffer *vb)return -EINVAL ; } } -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 = {
@@ -1512,7 +1525,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,
@@ -1956,27 +1968,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,
@@ -2000,7 +1991,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 380/1157 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
@@ -1261,7 +1261,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 381/1157 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 382/1157 wifi: mac80211: set STA deflink addresses
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit 630c7e4621763220d23789fbb036e0cf227e0b22 ]
We should set the STA deflink addresses in case no link is really added.
--- net/mac80211/sta_info.c | 2 ++ 1 file changed, 2 insertions(+)
net/mac80211/sta_info.c +2 -0
@@ -373,6 +373,8 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,memcpy (sta->addr, addr,ETH_ALEN );memcpy (sta->sta.addr, addr,ETH_ALEN ); +memcpy (sta->deflink.addr, addr,ETH_ALEN ); +memcpy (sta->sta.deflink.addr, addr,ETH_ALEN ); sta->sta.max_rx_aggregation_subframes = local->hw.max_rx_aggregation_subframes;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 383/1157 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 384/1157 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 385/1157 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 386/1157 drm/amd: Dont show warning on reading vbios values for SMU13 3.1
In reply to Greg Kroah-HartmanFrom: Mario Limonciello <[email protected]>
[ Upstream commit 1320d6c7b0deb7219701a55397e93e6c73d00366 ]
Some APUs with SMU13 are showing the following message:amdgpu 0000:63:00.0: amdgpu: Unexpected and unhandled version: 3.1
This warning isn't relevant for smu info 3.1, as no bootup information is present in the table.
--- drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +2 -0
@@ -714,6 +714,8 @@ int smu_v13_0_get_vbios_bootup_values(struct smu_context *smu) smu->smu_table.boot_values.vclk = smu_info_v3_6->bootup_vclk_10khz; smu->smu_table.boot_values.dclk = smu_info_v3_6->bootup_dclk_10khz; smu->smu_table.boot_values.fclk = smu_info_v3_6->bootup_fclk_10khz; + }else if ((frev ==3 ) && (crev ==1 )) { +return 0 ; }else if ((frev ==4 ) && (crev ==0 )) { smu_info_v4_0 = (struct atom_smu_info_v4_0 *)header;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 387/1157 drm/amdkfd: correct sdma queue number of sdma 6.0.1
In reply to Greg Kroah-HartmanFrom: Yifan Zhang <[email protected]>
[ Upstream commit efb4fd107cfd9748f777a4e9015d803d3c9db68b ]
sdma 6.0.1 has 8 queues instead of 2.
--- drivers/gpu/drm/amd/amdkfd/kfd_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_device.c +1 -1
@@ -75,7 +75,6 @@ static void kfd_device_info_set_sdma_info(struct kfd_dev *kfd)case IP_VERSION (5 ,2 ,3 ):/* YELLOW_CARP */ case IP_VERSION (5 ,2 ,6 ):/* GC 10.3.6 */ case IP_VERSION (5 ,2 ,7 ):/* GC 10.3.7 */ -case IP_VERSION (6 ,0 ,1 ): kfd->device_info.num_sdma_queues_per_engine =2 ;break ;case IP_VERSION (4 ,2 ,0 ):/* VEGA20 */
@@ -90,6 +89,7 @@ static void kfd_device_info_set_sdma_info(struct kfd_dev *kfd)case IP_VERSION (5 ,2 ,4 ):/* DIMGREY_CAVEFISH */ case IP_VERSION (5 ,2 ,5 ):/* BEIGE_GOBY */ case IP_VERSION (6 ,0 ,0 ): +case IP_VERSION (6 ,0 ,1 ):case IP_VERSION (6 ,0 ,2 ): kfd->device_info.num_sdma_queues_per_engine =8 ;break ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 388/1157 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 389/1157 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
@@ -2075,6 +2075,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 ();
@@ -3329,21 +3342,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 390/1157 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
@@ -14733,9 +14733,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 391/1157 drm/display: Fix build error without CONFIG_OF
In reply to Greg Kroah-HartmanFrom: YueHaibing <[email protected]>
[ Upstream commit 876271118aa41097d035c84f99648746b4a125f3 ]
While CONFIG_OF is n but COMPILE_TEST is y, we got this:
WARNING: unmet direct dependencies detected for DRM_DP_AUX_BUS
Depends on [n]: HAS_IOMEM [=y] && DRM [=y] && OF [=n]
Selected by [y]:
- DRM_MSM [=y] && HAS_IOMEM [=y] && DRM [=y] && (ARCH_QCOM || SOC_IMX5 || COMPILE_TEST [=y]) && COMMON_CLK [=y] && IOMMU_SUPPORT [=y] && (QCOM_OCMEM [=n] || QCOM_OCMEM [=n]=n) && (QCOM_LLCC [=y] || QCOM_LLCC [=y]=n) && (QCOM_COMMAND_DB [=n] || QCOM_COMMAND_DB [=n]=n)
Make DRM_DP_AUX_BUS depends on OF || COMPILE_TEST to fix this warning.
--- drivers/gpu/drm/display/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/display/Kconfig +1 -1
@@ -3,7 +3,7 @@ config DRM_DP_AUX_BUS tristate depends on DRM - depends on OF + depends on OF || COMPILE_TEST config DRM_DISPLAY_HELPER tristate
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 392/1157 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 393/1157 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 394/1157 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
@@ -1393,10 +1393,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 395/1157 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 396/1157 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 397/1157 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 398/1157 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 399/1157 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
@@ -925,7 +925,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 400/1157 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 401/1157 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
@@ -208,6 +208,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 402/1157 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
@@ -196,6 +196,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 403/1157 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
@@ -2145,12 +2145,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 404/1157 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
@@ -1280,8 +1280,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 405/1157 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
@@ -388,6 +388,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 406/1157 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
@@ -950,7 +950,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 407/1157 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 408/1157 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 409/1157 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 410/1157 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 411/1157 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
@@ -319,7 +319,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 412/1157 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 413/1157 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 414/1157 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 415/1157 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
@@ -145,6 +145,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 ; }
@@ -2704,6 +2710,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)
@@ -2800,6 +2807,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
@@ -179,6 +179,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 416/1157 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
@@ -461,9 +461,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;
@@ -499,6 +501,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 417/1157 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
@@ -1956,10 +1956,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 418/1157 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
@@ -1117,6 +1120,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
@@ -127,6 +127,7 @@ enum vc4_hdmi_field {HDMI_VERTB0 ,HDMI_VERTB1 ,HDMI_VID_CTL , + HDMI_MISC_CONTROL, }; struct vc4_hdmi_register {
@@ -237,6 +238,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),
@@ -319,6 +321,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 419/1157 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
@@ -423,7 +423,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,
@@ -453,7 +453,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 420/1157 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
@@ -2544,8 +2544,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 )) {
@@ -2564,15 +2562,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,
@@ -2588,10 +2577,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,
@@ -2642,7 +2627,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,
@@ -2871,12 +2855,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 ; }
@@ -2966,9 +2972,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 421/1157 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
@@ -346,7 +346,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 ));
@@ -358,7 +359,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,
@@ -378,7 +379,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
@@ -988,12 +988,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;
@@ -1041,12 +1041,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 422/1157 drm/vc4: hdmi: Force modeset when bpc or format changes
In reply to Greg Kroah-HartmanFrom: Dom Cobley <[email protected]>
[ Upstream commit c94cd0620a922156c9ff9af9c3301b174b287677 ]
Whenever the maximum BPC is changed, vc4_hdmi_encoder_compute_config() might pick up a different BPC or format depending on the display capabilities.
That change will have a number of side effects, including the clock rates and whether the scrambling is enabled.
However, only drm_crtc_state.connectors_changed will be set to true, since that properly only affects the connector.
This means that while drm_atomic_crtc_needs_modeset() will return true, and thus drm_atomic_helper_commit_modeset_enables() will call our encoder atomic_enable() hook, mode_changed will be false.
So crtc_set_mode() will not call our encoder .atomic_mode_set() hook. We use this hook in vc4 to set the vc4_hdmi_connector_state.output_bpc (and output_format), and will then reuse the value in .atomic_enable() to select whether or not scrambling should be enabled.
However, since our clock rate is pre-computed during .atomic_check(), we end up with the clocks properly configured, but the scrambling disabled, leading to a blank screen.
Let's set mode_changed to true in our HDMI driver to force the update of output_bpc, and thus prevent the issue entirely.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +11 -1
@@ -1620,9 +1620,14 @@ static int vc4_hdmi_encoder_atomic_check(struct drm_encoder *encoder,struct drm_crtc_state *crtc_state, struct drm_connector_state *conn_state) { + struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); +struct drm_connector *connector = &vc4_hdmi->connector; +struct drm_connector_state *old_conn_state = +drm_atomic_get_old_connector_state (conn_state->state, connector); +struct vc4_hdmi_connector_state *old_vc4_state = +conn_state_to_vc4_hdmi_conn_state (old_conn_state);struct vc4_hdmi_connector_state *vc4_state =conn_state_to_vc4_hdmi_conn_state (conn_state);struct drm_display_mode *mode = &crtc_state->adjusted_mode; -struct vc4_hdmi *vc4_hdmi =encoder_to_vc4_hdmi (encoder);unsigned long long tmds_char_rate = mode->clock *1000 ;unsigned long long tmds_bit_rate;int ret;
@@ -1651,6 +1656,11 @@ static int vc4_hdmi_encoder_atomic_check(struct drm_encoder *encoder,if (ret)return ret; +/* vc4_hdmi_encoder_compute_config may have changed output_bpc and/or output_format */ +if (vc4_state->output_bpc != old_vc4_state->output_bpc || + vc4_state->output_format != old_vc4_state->output_format) + crtc_state->mode_changed = true; +return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 423/1157 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
@@ -1040,13 +1040,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 424/1157 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
@@ -316,7 +316,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)
@@ -996,6 +998,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);
@@ -1022,6 +1025,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); }
@@ -1122,7 +1130,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 );
@@ -1632,11 +1640,25 @@ static int vc4_hdmi_encoder_atomic_check(struct drm_encoder *encoder,unsigned long long tmds_bit_rate;int ret; -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 425/1157 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>
@@ -2440,11 +2441,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 426/1157 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
@@ -71,6 +71,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 427/1157 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 428/1157 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
@@ -1196,10 +1196,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),
@@ -1207,15 +1210,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
@@ -1236,8 +1244,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 |
@@ -1248,6 +1258,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 );
@@ -1271,9 +1283,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) {
@@ -2214,6 +2284,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
@@ -3367,6 +3367,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
@@ -575,6 +575,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 {
@@ -691,6 +692,9 @@ struct ocelot_port {int bridge_num;int speed; + +/* Store the AdminBaseTime of EST fetched from userspace. */ +s64 base_time; };struct ocelot {
@@ -757,6 +761,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 429/1157 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
@@ -1210,6 +1210,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 ; }
@@ -1258,8 +1261,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 );
@@ -1282,6 +1283,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);
@@ -1291,17 +1296,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,
@@ -1315,11 +1321,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
@@ -670,6 +670,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;
@@ -692,9 +694,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 430/1157 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
@@ -1553,9 +1553,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 431/1157 selftests: net: fib_rule_tests: fix support for running individual tests
In reply to Greg Kroah-HartmanFrom: Alaa Mohamed <[email protected]>
[ Upstream commit 9c154ab47f5e5ff632d2b7af6342c027d7e04b92 ]
parsing and usage of -t got missed in the previous patch. this patch fixes it
--- tools/testing/selftests/net/fib_rule_tests.sh | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+)
tools/testing/selftests/net/fib_rule_tests.sh +23 -0
@@ -303,6 +303,29 @@ run_fibrule_tests() log_section "IPv6 fib rule" fib_rule6_test } +################################################################################ +# usage + +usage() +{ + cat <<EOF +usage: ${0##*/} OPTS + + -t <test> Test(s) to run (default: all) + (options: $TESTS) +EOF +} + +################################################################################ +# main + +while getopts ":t:h" opt; do + case $opt in + t) TESTS=$OPTARG;; + h) usage; exit 0;; + *) usage; exit 1;; + esac +done if [ "$(id -u)" -ne 0 ];then echo "SKIP: Need root privileges"
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 432/1157 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
@@ -1570,6 +1570,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 433/1157 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
@@ -408,7 +408,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 434/1157 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 435/1157 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 436/1157 drm/msm/dpu: move intf and wb assignment to dpu_encoder_setup_display()
In reply to Greg Kroah-HartmanFrom: Abhinav Kumar <[email protected]>
[ Upstream commit b4a624acabe99f2ea912e895529b8b37d1fa909d ]
intf and wb resources are not dependent on the rm global state so need not be allocated during dpu_encoder_virt_atomic_mode_set().
Move the allocation of intf and wb resources to dpu_encoder_setup_display() so that we can utilize the hw caps even during atomic_check() phase.
Since dpu_encoder_setup_display() already has protection against setting invalid intf_idx and wb_idx, these checks can now be dropped as well.
changes in v2:
- add phys->hw_intf and phys->hw_wb checks back
changes in v3:
- correct the Fixes tag
Patchwork: https://patchwork.freedesktop.org/patch/489885/
--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 36 ++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +18 -18
@@ -1048,24 +1048,6 @@ static void dpu_encoder_virt_atomic_mode_set(struct drm_encoder *drm_enc, phys->hw_pp = dpu_enc->hw_pp[i]; phys->hw_ctl =to_dpu_hw_ctl (hw_ctl[i]); -if (phys->intf_idx >=INTF_0 && phys->intf_idx <INTF_MAX ) - phys->hw_intf =dpu_rm_get_intf (&dpu_kms->rm, phys->intf_idx); - -if (phys->wb_idx >=WB_0 && phys->wb_idx <WB_MAX ) - phys->hw_wb =dpu_rm_get_wb (&dpu_kms->rm, phys->wb_idx); - -if (!phys->hw_intf && !phys->hw_wb) { -DPU_ERROR_ENC (dpu_enc, -"no intf or wb block assigned at idx: %d\n" , i); -return ; - } - -if (phys->hw_intf && phys->hw_wb) { -DPU_ERROR_ENC (dpu_enc, -"invalid phys both intf and wb block at idx: %d\n" , i); -return ; - } - phys->cached_mode = crtc_state->adjusted_mode;if (phys->ops.atomic_mode_set) phys->ops.atomic_mode_set (phys, crtc_state, conn_state);
@@ -2294,7 +2276,25 @@ static int dpu_encoder_setup_display(struct dpu_encoder_virt *dpu_enc,struct dpu_encoder_phys *phys = dpu_enc->phys_encs[i];atomic_set (&phys->vsync_cnt,0 );atomic_set (&phys->underrun_cnt,0 ); + +if (phys->intf_idx >=INTF_0 && phys->intf_idx <INTF_MAX ) + phys->hw_intf =dpu_rm_get_intf (&dpu_kms->rm, phys->intf_idx); + +if (phys->wb_idx >=WB_0 && phys->wb_idx <WB_MAX ) + phys->hw_wb =dpu_rm_get_wb (&dpu_kms->rm, phys->wb_idx); + +if (!phys->hw_intf && !phys->hw_wb) { +DPU_ERROR_ENC (dpu_enc,"no intf or wb block assigned at idx: %d\n" , i); + ret = -EINVAL ; + } + +if (phys->hw_intf && phys->hw_wb) { +DPU_ERROR_ENC (dpu_enc, +"invalid phys both intf and wb block at idx: %d\n" , i); + ret = -EINVAL ; + } } +mutex_unlock (&dpu_enc->enc_lock);return ret;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 437/1157 drm/msm/dpu: fix maxlinewidth for writeback block
In reply to Greg Kroah-HartmanFrom: Abhinav Kumar <[email protected]>
[ Upstream commit a370cc392e075de5a4b7f3fb27cdeec0d70b5893 ]
Writeback block for sm8250 was using the default maxlinewidth of 2048. But this is not right as it supports upto 4096.
This should have no effect on most resolutions as we are still limiting upto maxlinewidth of SSPP for adding the modes.
Fix the maxlinewidth for writeback block on sm8250.
changes in v3:
- correct the Fixes tag
Patchwork: https://patchwork.freedesktop.org/patch/489887/
--- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c +3 -3
@@ -1285,7 +1285,7 @@ static const struct dpu_intf_cfg qcm2290_intf[] = {* Writeback blocks config *************************************************************/ #define WB_BLK (_name, _id, _base, _features, _clk_ctrl, \ - __xin_id, vbif_id, _reg, _wb_done_bit) \ + __xin_id, vbif_id, _reg, _max_linewidth, _wb_done_bit) \ { \ .name = _name, .id = _id, \ .base = _base, .len = 0x2c8, \
@@ -1295,13 +1295,13 @@ static const struct dpu_intf_cfg qcm2290_intf[] = { .clk_ctrl = _clk_ctrl, \ .xin_id = __xin_id, \ .vbif_idx = vbif_id, \ - .maxlinewidth = DEFAULT_DPU_LINE_WIDTH, \ + .maxlinewidth = _max_linewidth, \ .intr_wb_done = DPU_IRQ_IDX(_reg, _wb_done_bit) \ }static const struct dpu_wb_cfg sm8250_wb[] = {WB_BLK ("wb_2" ,WB_2 ,0x65000 ,WB_SM8250_MASK ,DPU_CLK_CTRL_WB2 ,6 , -VBIF_RT ,MDP_SSPP_TOP0_INTR ,4 ), +VBIF_RT ,MDP_SSPP_TOP0_INTR ,4096 ,4 ), };/*************************************************************
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 438/1157 drm/msm/dpu: remove hard-coded linewidth limit for writeback
In reply to Greg Kroah-HartmanFrom: Abhinav Kumar <[email protected]>
[ Upstream commit 4edea8d305873336a626c5f4ce17cb8751059054 ]
Remove the hard-coded limit for writeback and lets start using the one from catalog instead.
changes in v3:
- correct the Fixes tag
Patchwork: https://patchwork.freedesktop.org/patch/489888/
--- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c +2 -4
@@ -20,8 +20,6 @@#include "dpu_crtc.h" #include "disp/msm_disp_snapshot.h" -#define DEFAULT_MAX_WRITEBACK_WIDTH 2048 -#define to_dpu_encoder_phys_wb (x) \ container_of(x, struct dpu_encoder_phys_wb, base)
@@ -278,9 +276,9 @@ static int dpu_encoder_phys_wb_atomic_check(DPU_ERROR ("invalid fb h=%d, mode h=%d\n" , fb->height, mode->vdisplay);return -EINVAL ; - }else if (fb->width >DEFAULT_MAX_WRITEBACK_WIDTH ) { + }else if (fb->width > phys_enc->hw_wb->caps->maxlinewidth) {DPU_ERROR ("invalid fb w=%d, maxlinewidth=%u\n" , - fb->width,DEFAULT_MAX_WRITEBACK_WIDTH ); + fb->width, phys_enc->hw_wb->caps->maxlinewidth);return -EINVAL ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 439/1157 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 440/1157 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 441/1157 drm/msm: Fix fence rollover issue
In reply to Greg Kroah-HartmanFrom: Rob Clark <[email protected]>
[ Upstream commit 2311720a0182756f175fbf4afc1fb76ac487b587 ]
And while we are at it, let's start the fence counter close to the rollover point so that if issues slip in, they are more obvious.
Patchwork: https://patchwork.freedesktop.org/patch/489619/
--- drivers/gpu/drm/msm/msm_fence.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/msm_fence.c +10 -1
@@ -28,6 +28,14 @@ msm_fence_context_alloc(struct drm_device *dev, volatile uint32_t *fenceptr, fctx->fenceptr = fenceptr;spin_lock_init (&fctx->spinlock); +/* +* Start out close to the 32b fence rollover point, so we can +* catch bugs with fence comparisons. +*/ + fctx->last_fence =0xffffff00 ; + fctx->completed_fence = fctx->last_fence; + *fctx->fenceptr = fctx->last_fence; +return fctx; }
@@ -52,7 +60,8 @@ void msm_update_fence(struct msm_fence_context *fctx, uint32_t fence)unsigned long flags;spin_lock_irqsave (&fctx->spinlock, flags); - fctx->completed_fence =max (fence, fctx->completed_fence); +if (fence_after (fence, fctx->completed_fence)) + fctx->completed_fence = fence;spin_unlock_irqrestore (&fctx->spinlock, flags); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 442/1157 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 443/1157 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 444/1157 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 445/1157 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 446/1157 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 447/1157 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
@@ -2656,14 +2656,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 ;
@@ -2679,6 +2671,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 448/1157 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
@@ -64,11 +64,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)
@@ -92,6 +95,9 @@ struct msm_gpu_devfreq {/** devfreq: devfreq instance */ struct devfreq *devfreq; +/** lock: lock for "suspended", "busy_cycles", and "time" */ +struct mutex lock; +/** * idle_constraint: *
@@ -135,6 +141,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 449/1157 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
@@ -233,7 +233,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 450/1157 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 451/1157 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 452/1157 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 453/1157 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 454/1157 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 455/1157 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 456/1157 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;
@@ -1134,6 +1137,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 457/1157 media: atomisp: revert "dont pass a pointer to a local variable"
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit a3b36a8ce3d0c277fe243fa1be6bd3f606ed130f ]
The gcc is warning about returning a pointer to a local variable is a false positive.
The type of handle is "struct ia_css_rmgr_vbuf_handle **" and "h.vptr" is left to NULL, so the "if ((*handle)->vptr == 0x0)" check always succeeds when the "*handle = &h;" statement which gcc warns about executes. Leading to this statement being executed:
rmgr_pop_handle(pool, handle);
If that succeeds, then *handle has been set to point to one of the pre-allocated array of handles, so it no longer points to h.
If that fails the following statement will be executed:
/* Note that handle will change to an internally maintained one */ ia_css_rmgr_refcount_retain_vbuf(handle);
Which allocated a new handle from the array of pre-allocated handles and then makes *handle point to this. So the address of h is actually never returned.
The fix for the false-postive compiler warning actually breaks the code, the new:
**handle = h;
is part of a "if (pool->copy_on_write) { ... }" which means that the handle where *handle points to should be treated read-only, IOW **handle must never be set, instead *handle must be set to point to a new handle (with a copy of the contents of the old handle).
The old code correctly did this and the new fixed code gets this wrong.
Note there is another patch in this series, which fixes the warning in another way.
--- .../staging/media/atomisp/pci/runtime/rmgr/src/rmgr_vbuf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/media/atomisp/pci/runtime/rmgr/src/rmgr_vbuf.c +2 -2
@@ -254,7 +254,7 @@ void rmgr_pop_handle(struct ia_css_rmgr_vbuf_pool *pool,void ia_css_rmgr_acq_vbuf (struct ia_css_rmgr_vbuf_pool *pool,struct ia_css_rmgr_vbuf_handle **handle) { -struct ia_css_rmgr_vbuf_handle h = {0 }; +struct ia_css_rmgr_vbuf_handle h;if ((!pool) || (!handle) || (!*handle)) {IA_CSS_LOG ("Invalid inputs" );
@@ -272,7 +272,7 @@ void ia_css_rmgr_acq_vbuf(struct ia_css_rmgr_vbuf_pool *pool, h.size = (*handle)->size;/* release ref to current buffer */ ia_css_rmgr_refcount_release_vbuf (handle); - **handle = h; + *handle = &h; }/* get new buffer for needed size */ if ((*handle)->vptr ==0x0 ) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 458/1157 media: mediatek: vcodec: decoder: Fix 4K frame size enumeration
In reply to Greg Kroah-HartmanFrom: Chen-Yu Tsai <[email protected]>
[ Upstream commit f1748f8f8174a65a885a8e6c0dc11658a6705ac2 ]
This partially reverts commit b018be06f3c7 ("media: mediatek: vcodec:
Read max resolution from dec_capability"). In this commit, the maximum resolution ended up being a function of both the firmware capability and the current set format.
However, frame size enumeration for output (coded) formats should not depend on the format set, but should return supported resolutions for the format requested by userspace.
Fix this so that the driver returns the supported resolutions correctly, even if the instance only has default settings, or if the output format is currently set to VP8F, which does not support 4K.
This adds an copy of special casing for !VP8 and 4K support. The other existing copy will be removed when .max_{width,height} are removed from |struct mtk_vcodec_ctx| in a subsequent patch.
--- drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c | 2 -- .../platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c | 7 +++++++ 2 files changed, 7 insertions(+), 2 deletions(-)
drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c +0 -2
@@ -536,8 +536,6 @@ static int vidioc_enum_framesizes(struct file *file, void *priv, fsize->type =V4L2_FRMSIZE_TYPE_STEPWISE ; fsize->stepwise = dec_pdata->vdec_framesizes[i].stepwise; - fsize->stepwise.max_width = ctx->max_width; - fsize->stepwise.max_height = ctx->max_height; mtk_v4l2_debug(1, "%x, %d %d %d %d %d %d", ctx->dev->dec_capability, fsize->stepwise.min_width,
drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c +7 -0
@@ -360,6 +360,13 @@ static void mtk_vcodec_add_formats(unsigned int fourcc, mtk_vdec_framesizes[count_framesizes].fourcc = fourcc; mtk_vdec_framesizes[count_framesizes].stepwise = stepwise_fhd; +if (!(ctx->dev->dec_capability &VCODEC_CAPABILITY_4K_DISABLED ) && + fourcc !=V4L2_PIX_FMT_VP8_FRAME ) { + mtk_vdec_framesizes[count_framesizes].stepwise.max_width = +VCODEC_DEC_4K_CODED_WIDTH ; + mtk_vdec_framesizes[count_framesizes].stepwise.max_height = +VCODEC_DEC_4K_CODED_HEIGHT ; + } num_framesizes++;break ;case V4L2_PIX_FMT_MM21 :
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 459/1157 media: mediatek: vcodec: decoder: Fix resolution clamping in TRY_FMT
In reply to Greg Kroah-HartmanFrom: Chen-Yu Tsai <[email protected]>
[ Upstream commit d7abd054201377aa441411ca081bd903fba82ce0 ]
In commit b018be06f3c7 ("media: mediatek: vcodec: Read max resolution from dec_capability"), TRY_FMT clamps the resolution to the maximum that was previously set either by default 1080p or the limit set by a previous S_FMT call. This does not make sense when doing TRY_FMT for the output side, which may have different capabilities.
Instead, for the output side, find the maximum resolution based on the pixel format requested. For the capture side, find the maximum resolution based on the currently set output format.
The maximum resolution is found from the list of per-format frame sizes, so the patch "media: mediatek: vcodec: dec: Fix 4K frame size enumeration" is needed.
--- .../platform/mediatek/vcodec/mtk_vcodec_dec.c | 48 ++++++++++++++----- 1 file changed, 36 insertions(+), 12 deletions(-)
drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c +36 -12
@@ -211,17 +211,44 @@ static int vidioc_vdec_subscribe_evt(struct v4l2_fh *fh, } } +static const struct v4l2_frmsize_stepwise *mtk_vdec_get_frmsize (struct mtk_vcodec_ctx *ctx, +u32 pixfmt) +{ +const struct mtk_vcodec_dec_pdata *dec_pdata = ctx->dev->vdec_pdata; +int i; + +for (i =0 ; i < *dec_pdata->num_framesizes; ++i) +if (pixfmt == dec_pdata->vdec_framesizes[i].fourcc) +return &dec_pdata->vdec_framesizes[i].stepwise; + +/* +* This should never happen since vidioc_try_fmt_vid_out_mplane() +* always passes through a valid format for the output side, and +* for the capture side, a valid output format should already have +* been set. +*/ +WARN_ONCE (1 ,"Unsupported format requested.\n" ); +return &dec_pdata->vdec_framesizes[0 ].stepwise; +} +static int vidioc_try_fmt (struct mtk_vcodec_ctx *ctx,struct v4l2_format *f,const struct mtk_video_fmt *fmt) {struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp; +const struct v4l2_frmsize_stepwise *frmsize; +u32 fourcc; pix_fmt_mp->field =V4L2_FIELD_NONE ; - pix_fmt_mp->width = -clamp (pix_fmt_mp->width,MTK_VDEC_MIN_W , ctx->max_width); - pix_fmt_mp->height = -clamp (pix_fmt_mp->height,MTK_VDEC_MIN_H , ctx->max_height); +/* Always apply frame size constraints from the coded side */ +if (V4L2_TYPE_IS_OUTPUT (f->type)) + fourcc = f->fmt.pix_mp.pixelformat; +else + fourcc = ctx->q_data[MTK_Q_DATA_SRC ].fmt->fourcc; + + frmsize =mtk_vdec_get_frmsize (ctx, fourcc); + pix_fmt_mp->width =clamp (pix_fmt_mp->width,MTK_VDEC_MIN_W , frmsize->max_width); + pix_fmt_mp->height =clamp (pix_fmt_mp->height,MTK_VDEC_MIN_H , frmsize->max_height);if (f->type ==V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ) { pix_fmt_mp->num_planes =1 ;
@@ -237,18 +264,15 @@ static int vidioc_try_fmt(struct mtk_vcodec_ctx *ctx, struct v4l2_format *f,*/ tmp_w = pix_fmt_mp->width; tmp_h = pix_fmt_mp->height; -v4l_bound_align_image (&pix_fmt_mp->width, -MTK_VDEC_MIN_W , - ctx->max_width,6 , - &pix_fmt_mp->height, -MTK_VDEC_MIN_H , - ctx->max_height,6 ,9 ); +v4l_bound_align_image (&pix_fmt_mp->width,MTK_VDEC_MIN_W , frmsize->max_width,6 , + &pix_fmt_mp->height,MTK_VDEC_MIN_H , frmsize->max_height,6 , +9 );if (pix_fmt_mp->width < tmp_w && - (pix_fmt_mp->width +64 ) <= ctx->max_width) + (pix_fmt_mp->width +64 ) <= frmsize->max_width) pix_fmt_mp->width +=64 ;if (pix_fmt_mp->height < tmp_h && - (pix_fmt_mp->height +64 ) <= ctx->max_height) + (pix_fmt_mp->height +64 ) <= frmsize->max_height) pix_fmt_mp->height +=64 ; mtk_v4l2_debug(0,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 460/1157 media: mediatek: vcodec: decoder: Skip alignment for default resolution
In reply to Greg Kroah-HartmanFrom: Chen-Yu Tsai <[email protected]>
[ Upstream commit 3b6a81a31370539f1fd0e9bdd315503aa154285e ]
The default resolution of 64x64 is already aligned, according to the call to v4l_bound_align_image() in mtk_vcodec_dec_set_default_params().
Drop the redundant v4l_bound_align_image() call. This also removes one usage of ctx->max_{width,height}.
--- drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c +0 -7
@@ -142,13 +142,6 @@ void mtk_vcodec_dec_set_default_params(struct mtk_vcodec_ctx *ctx) ctx->max_width =MTK_VDEC_MAX_W ; ctx->max_height =MTK_VDEC_MAX_H ; -v4l_bound_align_image (&q_data->coded_width, -MTK_VDEC_MIN_W , - ctx->max_width,4 , - &q_data->coded_height, -MTK_VDEC_MIN_H , - ctx->max_height,5 ,6 ); - q_data->sizeimage[0 ] = q_data->coded_width * q_data->coded_height; q_data->bytesperline[0 ] = q_data->coded_width; q_data->sizeimage[1 ] = q_data->sizeimage[0 ] /2 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 461/1157 media: mediatek: vcodec: decoder: Drop max_{width,height} from mtk_vcodec_ctx
In reply to Greg Kroah-HartmanFrom: Chen-Yu Tsai <[email protected]>
[ Upstream commit e8d266d533b171387945f8a0bad1944a5609f63b ]
This partially reverts commit b018be06f3c7 ("media: mediatek: vcodec:
Read max resolution from dec_capability").
After the previous patches:
- media: mediatek: vcodec: decoder: Fix 4K frame size enumeration
- media: mediatek: vcodec: decoder: Skip alignment for default resolution
- media: mediatek: vcodec: decoder: Fix resolution clamping in TRY_FMT
the max_{width,height} fields in |struct mtk_vcodec_ctx| no longer have any real users. Remove them.
--- drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c | 9 --------- drivers/media/platform/mediatek/vcodec/mtk_vcodec_drv.h | 4 ---- 2 files changed, 13 deletions(-)
drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c +0 -9
@@ -139,8 +139,6 @@ void mtk_vcodec_dec_set_default_params(struct mtk_vcodec_ctx *ctx) q_data->coded_height =DFT_CFG_HEIGHT ; q_data->fmt = ctx->dev->vdec_pdata->default_cap_fmt; q_data->field =V4L2_FIELD_NONE ; - ctx->max_width =MTK_VDEC_MAX_W ; - ctx->max_height =MTK_VDEC_MAX_H ; q_data->sizeimage[0 ] = q_data->coded_width * q_data->coded_height; q_data->bytesperline[0 ] = q_data->coded_width;
@@ -455,13 +453,6 @@ static int vidioc_vdec_s_fmt(struct file *file, void *priv,if (fmt ==NULL )return -EINVAL ; -if (!(ctx->dev->dec_capability &VCODEC_CAPABILITY_4K_DISABLED ) && - fmt->fourcc !=V4L2_PIX_FMT_VP8_FRAME ) { -mtk_v4l2_debug (3 ,"4K is enabled" ); - ctx->max_width =VCODEC_DEC_4K_CODED_WIDTH ; - ctx->max_height =VCODEC_DEC_4K_CODED_HEIGHT ; - } - q_data->fmt = fmt;vidioc_try_fmt (ctx, f, q_data->fmt);if (f->type ==V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE ) {
drivers/media/platform/mediatek/vcodec/mtk_vcodec_drv.h +0 -4
@@ -285,8 +285,6 @@ struct vdec_pic_info {* mtk_video_dec_buf. * @hw_id: hardware index used to identify different hardware. * -* @max_width: hardware supported max width -* @max_height: hardware supported max height * @msg_queue: msg queue used to store lat buffer information. */ struct mtk_vcodec_ctx {
@@ -333,8 +331,6 @@ struct mtk_vcodec_ctx {struct mutex lock;int hw_id; -unsigned int max_width; -unsigned int max_height;struct vdec_msg_queue msg_queue; };
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 462/1157 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
@@ -208,11 +208,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 463/1157 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
@@ -178,16 +178,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;
@@ -234,6 +224,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));
@@ -493,6 +498,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 :
@@ -503,6 +510,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 ; }
@@ -1203,7 +1212,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); }
@@ -1480,10 +1488,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
@@ -500,8 +500,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 464/1157 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 ;
@@ -347,6 +359,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
@@ -259,7 +259,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 465/1157 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 466/1157 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[] = {
@@ -948,6 +949,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 ;
@@ -1057,6 +1061,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 ;
@@ -1318,6 +1324,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 );
@@ -1341,6 +1349,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 467/1157 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,
@@ -741,6 +740,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
@@ -1298,6 +1298,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 468/1157 mt76: mt7915: fix endianness in mt7915_rf_regval_get
In reply to Greg Kroah-HartmanFrom: Lorenzo Bianconi <[email protected]>
[ Upstream commit 63907290faa916ffab1c8455141c79ca8e3a79bb ]
Fix the following sparse warning in mt7915_rf_regval_get routine:drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c:979:16: warning: cast to restricted __le32
--- drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c +1 -1
@@ -976,7 +976,7 @@ mt7915_rf_regval_get(void *data, u64 *val)if (ret)return ret; - *val =le32_to_cpu (regval); + *val = regval;return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 469/1157 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 470/1157 mt76: mt7915: fix endian bug in mt7915_rf_regval_set()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit f572dc969a59a80baa22bf2f7c9af0064402652f ]
This code is supposed to set a u32 value, but casting will not work on big endian systems.
--- drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c +2 -1
@@ -985,8 +985,9 @@ static int mt7915_rf_regval_set(void *data, u64 val) {struct mt7915_dev *dev = data; +u32 val32 = val; -return mt7915_mcu_rf_regval (dev, dev->mt76.debugfs_reg, (u32 *)&val, true); +return mt7915_mcu_rf_regval (dev, dev->mt76.debugfs_reg, &val32, true); } DEFINE_DEBUGFS_ATTRIBUTE(fops_rf_regval, mt7915_rf_regval_get,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 471/1157 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
@@ -582,13 +582,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) {
@@ -599,6 +592,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 472/1157 mt76: mt7921: not support beacon offload disable command
In reply to Greg Kroah-HartmanFrom: Deren Wu <[email protected]>
[ Upstream commit c149d3a9058616ff942a6e44b6e968e18a84dd5a ]
Beacon disable flow would be handled in bss stop handler automatically. Force return -EOPNOTSUPP in disable case.
--- drivers/net/wireless/mediatek/mt76/mt7921/mcu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +4 -2
@@ -1256,8 +1256,11 @@ mt7921_mcu_uni_add_beacon_offload(struct mt7921_dev *dev, };struct sk_buff *skb; +/* support enable/update process only +* disable flow would be handled in bss stop handler automatically +*/ if (!enable) - goto out; +return -EOPNOTSUPP ; skb =ieee80211_beacon_get_template (mt76_hw (dev), vif, &offs);if (!skb)
@@ -1283,7 +1286,6 @@ mt7921_mcu_uni_add_beacon_offload(struct mt7921_dev *dev, }dev_kfree_skb (skb); -out:return mt76_mcu_send_msg (&dev->mt76,MCU_UNI_CMD (BSS_INFO_UPDATE ), &req,sizeof (req), true); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 473/1157 wifi: mac80211: reject WEP or pairwise keys with key ID > 3
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit 92ea8df110b8ca92f9664ec7bd76dea109115348 ]
We don't really care too much right now since our data structures are set up to not have a problem with this, but clearly it's wrong to accept WEP and pairwise keys with key ID > 3.
However, with MLD we need to split into per-link (GTK, IGTK, BIGTK) and per interface/MLD (including WEP) keys so make sure this is not a problem.
--- net/mac80211/key.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
net/mac80211/key.c +13 -5
@@ -433,13 +433,25 @@ static int ieee80211_key_replace(struct ieee80211_sub_if_data *sdata,int idx;int ret =0 ;bool defunikey, defmultikey, defmgmtkey, defbeaconkey; +bool is_wep;/* caller must provide at least one old/new */ if (WARN_ON (!new && !old))return 0 ; -if (new) +if (new) { + idx = new->conf.keyidx;list_add_tail_rcu (&new->list, &sdata->key_list); + is_wep = new->conf.cipher ==WLAN_CIPHER_SUITE_WEP40 || + new->conf.cipher ==WLAN_CIPHER_SUITE_WEP104 ; + }else { + idx = old->conf.keyidx; + is_wep = old->conf.cipher ==WLAN_CIPHER_SUITE_WEP40 || + old->conf.cipher ==WLAN_CIPHER_SUITE_WEP104 ; + } + +if ((is_wep || pairwise) && idx >=NUM_DEFAULT_KEYS ) +return -EINVAL ;WARN_ON (new && old && new->conf.keyidx != old->conf.keyidx);
@@ -451,8 +463,6 @@ static int ieee80211_key_replace(struct ieee80211_sub_if_data *sdata, }if (old) { - idx = old->conf.keyidx; -if (old->flags &KEY_FLAG_UPLOADED_TO_HARDWARE ) {ieee80211_key_disable_hw_accel (old);
@@ -460,8 +470,6 @@ static int ieee80211_key_replace(struct ieee80211_sub_if_data *sdata, ret =ieee80211_key_enable_hw_accel (new); } }else { -/* new must be provided in case old is not */ - idx = new->conf.keyidx;if (!new->local->wowlan) ret =ieee80211_key_enable_hw_accel (new); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 474/1157 wifi: cfg80211: do some rework towards MLO link APIs
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit 7b0a0e3c3a88260b6fcb017e49f198463aa62ed1 ]
In order to support multi-link operation with multiple links, start adding some APIs. The notable addition here is to have the link ID in a new nl80211 attribute, that will be used to differentiate the links in many nl80211 operations.
So far, this patch adds the netlink NL80211_ATTR_MLO_LINK_ID attribute (as well as the NL80211_ATTR_MLO_LINKS attribute) and plugs it through the system in some places, checking the validity etc. along with other infrastructure needed for it.
For now, I've decided to include only the over-the-air link ID in the API. I know we discussed that we eventually need to have to have other ways of identifying a link, but for local AP mode and auth/assoc commands as well as set_key etc. we'll use the OTA ID.
Also included in this patch is some refactoring of the data structures in struct wireless_dev, splitting for the first time the data into type dependent pieces, to make reasoning about these things easier.
--- drivers/net/wireless/ath/ath6kl/cfg80211.c | 6 +- drivers/net/wireless/ath/wil6210/cfg80211.c | 9 +- .../broadcom/brcm80211/brcmfmac/cfg80211.c | 4 +- drivers/net/wireless/marvell/libertas/mesh.c | 10 +- drivers/net/wireless/marvell/mwifiex/11h.c | 2 +- .../net/wireless/marvell/mwifiex/cfg80211.c | 18 +- .../wireless/microchip/wilc1000/cfg80211.c | 3 +- .../net/wireless/quantenna/qtnfmac/cfg80211.c | 14 +- .../net/wireless/quantenna/qtnfmac/commands.c | 2 +- .../net/wireless/quantenna/qtnfmac/event.c | 15 +- .../staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 4 +- include/linux/ieee80211.h | 3 + include/net/cfg80211.h | 99 ++- include/uapi/linux/nl80211.h | 28 + net/mac80211/cfg.c | 8 +- net/mac80211/mlme.c | 2 +- net/wireless/ap.c | 46 +- net/wireless/chan.c | 196 ++++-- net/wireless/core.c | 28 +- net/wireless/core.h | 13 +- net/wireless/ibss.c | 57 +- net/wireless/mesh.c | 31 +- net/wireless/mlme.c | 74 ++- net/wireless/nl80211.c | 623 +++++++++++++----- net/wireless/ocb.c | 5 +- net/wireless/rdev-ops.h | 32 +- net/wireless/reg.c | 139 ++-- net/wireless/scan.c | 8 +- net/wireless/sme.c | 102 +-- net/wireless/trace.h | 86 ++- net/wireless/util.c | 44 +- net/wireless/wext-compat.c | 48 +- net/wireless/wext-sme.c | 29 +- 33 files changed, 1255 insertions(+), 533 deletions(-)
drivers/net/wireless/ath/ath6kl/cfg80211.c +4 -2
@@ -1119,7 +1119,7 @@ void ath6kl_cfg80211_ch_switch_notify(struct ath6kl_vif *vif, int freq, NL80211_CHAN_HT20 : NL80211_CHAN_NO_HT);mutex_lock (&vif->wdev.mtx); -cfg80211_ch_switch_notify (vif->ndev, &chandef); +cfg80211_ch_switch_notify (vif->ndev, &chandef,0 );mutex_unlock (&vif->wdev.mtx); }
@@ -2967,7 +2967,8 @@ static int ath6kl_change_beacon(struct wiphy *wiphy, struct net_device *dev,return ath6kl_set_ies (vif, beacon); } -static int ath6kl_stop_ap (struct wiphy *wiphy,struct net_device *dev) +static int ath6kl_stop_ap (struct wiphy *wiphy,struct net_device *dev, +unsigned int link_id) {struct ath6kl *ar =ath6kl_priv (dev);struct ath6kl_vif *vif =netdev_priv (dev);
@@ -3368,6 +3369,7 @@ static int ath6kl_cfg80211_sscan_stop(struct wiphy *wiphy,static int ath6kl_cfg80211_set_bitrate (struct wiphy *wiphy,struct net_device *dev, +unsigned int link_id,const u8 *addr,const struct cfg80211_bitrate_mask *mask) {
drivers/net/wireless/ath/wil6210/cfg80211.c +5 -4
@@ -2098,8 +2098,8 @@ static int wil_cfg80211_change_beacon(struct wiphy *wiphy, bcon->tail_len)) privacy =1 ; -memcpy (vif->ssid, wdev->ssid, wdev->ssid_len); - vif->ssid_len = wdev->ssid_len; +memcpy (vif->ssid, wdev->u.ap.ssid, wdev->u.ap.ssid_len); + vif->ssid_len = wdev->u.ap.ssid_len;/* in case privacy has changed, need to restart the AP */ if (vif->privacy != privacy) {
@@ -2108,7 +2108,7 @@ static int wil_cfg80211_change_beacon(struct wiphy *wiphy, rc = _wil_cfg80211_start_ap(wiphy, ndev, vif->ssid, vif->ssid_len, privacy, - wdev->beacon_interval, + wdev->links[0].ap.beacon_interval, vif->channel, vif->wmi_edmg_channel, bcon, vif->hidden_ssid,
@@ -2186,7 +2186,8 @@ static int wil_cfg80211_start_ap(struct wiphy *wiphy, }static int wil_cfg80211_stop_ap (struct wiphy *wiphy, -struct net_device *ndev) +struct net_device *ndev, +unsigned int link_id) {struct wil6210_priv *wil =wiphy_to_wil (wiphy);struct wil6210_vif *vif =ndev_to_vif (ndev);
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +3 -1
@@ -4965,7 +4965,8 @@ brcmf_cfg80211_start_ap(struct wiphy *wiphy, struct net_device *ndev,return err; } -static int brcmf_cfg80211_stop_ap (struct wiphy *wiphy,struct net_device *ndev) +static int brcmf_cfg80211_stop_ap (struct wiphy *wiphy,struct net_device *ndev, +unsigned int link_id) {struct brcmf_cfg80211_info *cfg =wiphy_to_cfg (wiphy);struct brcmf_if *ifp =netdev_priv (ndev);
@@ -5302,6 +5303,7 @@ brcmf_cfg80211_cancel_remain_on_channel(struct wiphy *wiphy,static int brcmf_cfg80211_get_channel (struct wiphy *wiphy,struct wireless_dev *wdev, +unsigned int link_id,struct cfg80211_chan_def *chandef) {struct brcmf_cfg80211_info *cfg =wiphy_to_cfg (wiphy);
drivers/net/wireless/marvell/libertas/mesh.c +5 -5
@@ -109,9 +109,9 @@ static int lbs_mesh_config(struct lbs_private *priv, uint16_t action,if (priv->mesh_dev) { mesh_wdev = priv->mesh_dev->ieee80211_ptr; - ie->val.mesh_id_len = mesh_wdev->mesh_id_up_len; -memcpy (ie->val.mesh_id, mesh_wdev->ssid, - mesh_wdev->mesh_id_up_len); + ie->val.mesh_id_len = mesh_wdev->u.mesh.id_up_len; +memcpy (ie->val.mesh_id, mesh_wdev->u.mesh.id, + mesh_wdev->u.mesh.id_up_len); } ie->len = sizeof(struct mrvl_meshie_val) -
@@ -986,8 +986,8 @@ static int lbs_add_mesh(struct lbs_private *priv) mesh_wdev->wiphy = priv->wdev->wiphy;if (priv->mesh_tlv) { -sprintf (mesh_wdev->ssid,"mesh" ); - mesh_wdev->mesh_id_up_len =4 ; +sprintf (mesh_wdev->u.mesh.id,"mesh" ); + mesh_wdev->u.mesh.id_up_len =4 ; } mesh_wdev->netdev = mesh_dev;
drivers/net/wireless/marvell/mwifiex/11h.c +1 -1
@@ -304,6 +304,6 @@ void mwifiex_dfs_chan_sw_work_queue(struct work_struct *work)mwifiex_dbg (priv->adapter,MSG ,"indicating channel switch completion to kernel\n" );mutex_lock (&priv->wdev.mtx); -cfg80211_ch_switch_notify (priv->netdev, &priv->dfs_chandef); +cfg80211_ch_switch_notify (priv->netdev, &priv->dfs_chandef,0 );mutex_unlock (&priv->wdev.mtx); }
drivers/net/wireless/marvell/mwifiex/cfg80211.c +11 -7
@@ -1753,10 +1753,12 @@ mwifiex_mgmt_stypes[NUM_NL80211_IFTYPES] = {* Function configures data rates to firmware using bitrate mask * provided by cfg80211. */ -static int mwifiex_cfg80211_set_bitrate_mask (struct wiphy *wiphy, -struct net_device *dev, -const u8 *peer, -const struct cfg80211_bitrate_mask *mask) +static int +mwifiex_cfg80211_set_bitrate_mask (struct wiphy *wiphy, +struct net_device *dev, +unsigned int link_id, +const u8 *peer, +const struct cfg80211_bitrate_mask *mask) {struct mwifiex_private *priv =mwifiex_netdev_get_priv (dev);u16 bitmap_rates[MAX_BITMAP_RATES_SIZE ];
@@ -1998,7 +2000,8 @@ mwifiex_cfg80211_get_antenna(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant)/* cfg80211 operation handler for stop ap. * Function stops BSS running at uAP interface. */ -static int mwifiex_cfg80211_stop_ap (struct wiphy *wiphy,struct net_device *dev) +static int mwifiex_cfg80211_stop_ap (struct wiphy *wiphy,struct net_device *dev, +unsigned int link_id) {struct mwifiex_private *priv =mwifiex_netdev_get_priv (dev);
@@ -2421,7 +2424,7 @@ mwifiex_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,return -EINVAL ; } -if (priv->wdev.current_bss) { +if (priv->wdev.connected) {mwifiex_dbg (adapter,ERROR ,"%s: already connected\n" , dev->name);return -EALREADY ;
@@ -2649,7 +2652,7 @@ mwifiex_cfg80211_scan(struct wiphy *wiphy,return -EBUSY ; } -if (!priv->wdev.current_bss && priv->scan_block) +if (!priv->wdev.connected && priv->scan_block) priv->scan_block = false;if (!mwifiex_stop_bg_scan (priv))
@@ -4025,6 +4028,7 @@ mwifiex_cfg80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,static int mwifiex_cfg80211_get_channel (struct wiphy *wiphy,struct wireless_dev *wdev, +unsigned int link_id,struct cfg80211_chan_def *chandef) {struct mwifiex_private *priv =mwifiex_netdev_get_priv (wdev->netdev);
drivers/net/wireless/microchip/wilc1000/cfg80211.c +2 -1
@@ -1378,7 +1378,8 @@ static int change_beacon(struct wiphy *wiphy, struct net_device *dev,return wilc_add_beacon (vif,0 ,0 , beacon); } -static int stop_ap (struct wiphy *wiphy,struct net_device *dev) +static int stop_ap (struct wiphy *wiphy,struct net_device *dev, +unsigned int link_id) {int ret;struct wilc_vif *vif =netdev_priv (dev);
drivers/net/wireless/quantenna/qtnfmac/cfg80211.c +8 -6
@@ -352,7 +352,8 @@ static int qtnf_start_ap(struct wiphy *wiphy, struct net_device *dev,return ret; } -static int qtnf_stop_ap (struct wiphy *wiphy,struct net_device *dev) +static int qtnf_stop_ap (struct wiphy *wiphy,struct net_device *dev, +unsigned int link_id) {struct qtnf_vif *vif =qtnf_netdev_get_priv (dev);int ret;
@@ -500,7 +501,7 @@ qtnf_dump_station(struct wiphy *wiphy, struct net_device *dev,switch (vif->wdev.iftype) {case NL80211_IFTYPE_STATION : -if (idx !=0 || !vif->wdev.current_bss) +if (idx !=0 || !vif->wdev.connected)return -ENOENT ;ether_addr_copy (mac, vif->bssid);
@@ -729,7 +730,7 @@ qtnf_disconnect(struct wiphy *wiphy, struct net_device *dev,pr_err ("VIF%u.%u: failed to disconnect\n" , mac->macid, vif->vifid); -if (vif->wdev.current_bss) { +if (vif->wdev.connected) {netif_carrier_off (vif->netdev);cfg80211_disconnected (vif->netdev, reason_code,NULL ,0 , true,GFP_KERNEL );
@@ -745,10 +746,11 @@ qtnf_dump_survey(struct wiphy *wiphy, struct net_device *dev,struct qtnf_wmac *mac =wiphy_priv (wiphy);struct wireless_dev *wdev = dev->ieee80211_ptr;struct ieee80211_supported_band *sband; -const struct cfg80211_chan_def *chandef = &wdev->chandef; +const struct cfg80211_chan_def *chandef =wdev_chandef (wdev,0 );struct ieee80211_channel *chan;int ret; + sband = wiphy->bands[NL80211_BAND_2GHZ ];if (sband && idx >= sband->n_channels) { idx -= sband->n_channels;
@@ -765,7 +767,7 @@ qtnf_dump_survey(struct wiphy *wiphy, struct net_device *dev, survey->channel = chan; survey->filled =0x0 ; -if (chan == chandef->chan) +if (chandef && chan == chandef->chan) survey->filled =SURVEY_INFO_IN_USE ; ret =qtnf_cmd_get_chan_stats (mac, chan->center_freq, survey);
@@ -778,7 +780,7 @@ qtnf_dump_survey(struct wiphy *wiphy, struct net_device *dev,static int qtnf_get_channel (struct wiphy *wiphy,struct wireless_dev *wdev, -struct cfg80211_chan_def *chandef) +unsigned int link_id,struct cfg80211_chan_def *chandef) {struct net_device *ndev = wdev->netdev;struct qtnf_vif *vif;
drivers/net/wireless/quantenna/qtnfmac/commands.c +1 -1
@@ -2005,7 +2005,7 @@ int qtnf_cmd_send_scan(struct qtnf_wmac *mac) dwell_active = scan_req->duration; dwell_passive = scan_req->duration; }else if (wdev->iftype ==NL80211_IFTYPE_STATION && - wdev->current_bss) { + wdev->connected) {/* let device select dwell based on traffic conditions */ dwell_active =QTNF_SCAN_TIME_AUTO ; dwell_passive =QTNF_SCAN_TIME_AUTO ;
drivers/net/wireless/quantenna/qtnfmac/event.c +8 -7
@@ -189,7 +189,7 @@ qtnf_event_handle_bss_join(struct qtnf_vif *vif, vif->mac->macid, vif->vifid, join_info->bssid, chandef.chan->hw_value); -if (!vif->wdev.ssid_len) { +if (!vif->wdev.u.client.ssid_len) {pr_warn ("VIF%u.%u: SSID unknown for BSS:%pM\n" , vif->mac->macid, vif->vifid, join_info->bssid);
@@ -197,7 +197,7 @@ qtnf_event_handle_bss_join(struct qtnf_vif *vif, goto done; } - ie =kzalloc (2 + vif->wdev.ssid_len,GFP_KERNEL ); + ie =kzalloc (2 + vif->wdev.u.client.ssid_len,GFP_KERNEL );if (!ie) { pr_warn("VIF%u.%u: IE alloc failed for BSS:%pM\n", vif->mac->macid, vif->vifid,
@@ -207,14 +207,15 @@ qtnf_event_handle_bss_join(struct qtnf_vif *vif, } ie[0 ] =WLAN_EID_SSID ; - ie[1 ] = vif->wdev.ssid_len; -memcpy (ie +2 , vif->wdev.ssid, vif->wdev.ssid_len); + ie[1 ] = vif->wdev.u.client.ssid_len; +memcpy (ie +2 , vif->wdev.u.client.ssid, + vif->wdev.u.client.ssid_len); bss =cfg80211_inform_bss (wiphy, chandef.chan,CFG80211_BSS_FTYPE_UNKNOWN , join_info->bssid,0 ,WLAN_CAPABILITY_ESS ,100 , - ie,2 + vif->wdev.ssid_len, + ie,2 + vif->wdev.u.client.ssid_len,0 ,GFP_KERNEL );if (!bss) { pr_warn("VIF%u.%u: can't connect to unknown BSS: %pM\n",
@@ -470,14 +471,14 @@ qtnf_event_handle_freq_change(struct qtnf_wmac *mac,continue ;if (vif->wdev.iftype ==NL80211_IFTYPE_STATION && - !vif->wdev.current_bss) + !vif->wdev.connected)continue ;if (!vif->netdev)continue ;mutex_lock (&vif->wdev.mtx); -cfg80211_ch_switch_notify (vif->netdev, &chandef); +cfg80211_ch_switch_notify (vif->netdev, &chandef,0 );mutex_unlock (&vif->wdev.mtx); }
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +3 -1
@@ -2086,6 +2086,7 @@ static u8 rtw_get_chan_type(struct adapter *adapter) }static int cfg80211_rtw_get_channel (struct wiphy *wiphy,struct wireless_dev *wdev, +unsigned int link_id,struct cfg80211_chan_def *chandef) {struct adapter *adapter =wiphy_to_adapter (wiphy);
@@ -2446,7 +2447,8 @@ static int cfg80211_rtw_change_beacon(struct wiphy *wiphy, struct net_device *ndreturn rtw_add_beacon (adapter, info->head, info->head_len, info->tail, info->tail_len); } -static int cfg80211_rtw_stop_ap (struct wiphy *wiphy,struct net_device *ndev) +static int cfg80211_rtw_stop_ap (struct wiphy *wiphy,struct net_device *ndev, +unsigned int link_id) {return 0 ; }
include/linux/ieee80211.h +3 -0
@@ -4345,4 +4345,7 @@ enum ieee80211_range_params_max_total_ltf { IEEE80211_RANGE_PARAMS_MAX_TOTAL_LTF_UNSPECIFIED, }; +/* multi-link device */ +#define IEEE80211_MLD_MAX_NUM_LINKS 15 +#endif /* LINUX_IEEE80211_H */
include/net/cfg80211.h +89 -10
194 lines not on this page · raw message
include/uapi/linux/nl80211.h +28 -0
@@ -323,6 +323,17 @@* Once the association is done, the driver cleans the FILS AAD data. */ +/** +* DOC: Multi-Link Operation +* +* In Multi-Link Operation, a connection between to MLDs utilizes multiple +* links. To use this in nl80211, various commands and responses now need +* to or will include the new %NL80211_ATTR_MLO_LINKS attribute. +* Additionally, various commands that need to operate on a specific link +* now need to be given the %NL80211_ATTR_MLO_LINK_ID attribute, e.g. to +* use %NL80211_CMD_START_AP or similar functions. +*/ +/** * enum nl80211_commands - supported nl80211 commands *
@@ -1237,6 +1248,12 @@* to describe the BSSID address of the AP and %NL80211_ATTR_TIMEOUT to * specify the timeout value. * +* @NL80211_CMD_ADD_LINK: Add a new link to an interface. The +* %NL80211_ATTR_MLO_LINK_ID attribute is used for the new link. +* @NL80211_CMD_REMOVE_LINK: Remove a link from an interface. This may come +* without %NL80211_ATTR_MLO_LINK_ID as an easy way to remove all links +* in preparation for e.g. roaming to a regular (non-MLO) AP. +* * @NL80211_CMD_MAX: highest used command number * @__NL80211_CMD_AFTER_LAST: internal use */
@@ -1481,6 +1498,9 @@ enum nl80211_commands {NL80211_CMD_ASSOC_COMEBACK , +NL80211_CMD_ADD_LINK , + NL80211_CMD_REMOVE_LINK, +/* add new commands above here */ /* used to define NL80211_CMD_MAX below */
@@ -2663,6 +2683,11 @@ enum nl80211_commands {* association request when used with NL80211_CMD_NEW_STATION). Can be set * only if %NL80211_STA_FLAG_WME is set. * +* @NL80211_ATTR_MLO_LINK_ID: A (u8) link ID for use with MLO, to be used with +* various commands that need a link ID to operate. +* @NL80211_ATTR_MLO_LINKS: A nested array of links, each containing some +* per-link information and a link ID. +* * @NUM_NL80211_ATTR: total number of nl80211_attrs available * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -3177,6 +3202,9 @@ enum nl80211_attrs {NL80211_ATTR_DISABLE_EHT , +NL80211_ATTR_MLO_LINKS , +NL80211_ATTR_MLO_LINK_ID , +/* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST,
net/mac80211/cfg.c +6 -2
@@ -1358,7 +1358,8 @@ static void ieee80211_free_next_beacon(struct ieee80211_sub_if_data *sdata) sdata->u.ap.next_beacon =NULL ; } -static int ieee80211_stop_ap (struct wiphy *wiphy,struct net_device *dev) +static int ieee80211_stop_ap (struct wiphy *wiphy,struct net_device *dev, +unsigned int link_id) {struct ieee80211_sub_if_data *sdata =IEEE80211_DEV_TO_SUB_IF (dev);struct ieee80211_sub_if_data *vlan;
@@ -3065,6 +3066,7 @@ static int ieee80211_set_cqm_rssi_range_config(struct wiphy *wiphy,static int ieee80211_set_bitrate_mask (struct wiphy *wiphy,struct net_device *dev, +unsigned int link_id,const u8 *addr,const struct cfg80211_bitrate_mask *mask) {
@@ -3406,7 +3408,7 @@ static int __ieee80211_csa_finalize(struct ieee80211_sub_if_data *sdata)if (err)return err; -cfg80211_ch_switch_notify (sdata->dev, &sdata->csa_chandef); +cfg80211_ch_switch_notify (sdata->dev, &sdata->csa_chandef,0 );return 0 ; }
@@ -3914,6 +3916,7 @@ static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev,static int ieee80211_cfg_get_channel (struct wiphy *wiphy,struct wireless_dev *wdev, +unsigned int link_id,struct cfg80211_chan_def *chandef) {struct ieee80211_sub_if_data *sdata =IEEE80211_WDEV_TO_SUB_IF (wdev);
@@ -3974,6 +3977,7 @@ static int ieee80211_set_qos_map(struct wiphy *wiphy,static int ieee80211_set_ap_chanwidth (struct wiphy *wiphy,struct net_device *dev, +unsigned int link_id,struct cfg80211_chan_def *chandef) {struct ieee80211_sub_if_data *sdata =IEEE80211_DEV_TO_SUB_IF (dev);
net/mac80211/mlme.c +1 -1
@@ -1314,7 +1314,7 @@ static void ieee80211_chswitch_post_beacon(struct ieee80211_sub_if_data *sdata)return ; } -cfg80211_ch_switch_notify (sdata->dev, &sdata->reserved_chandef); +cfg80211_ch_switch_notify (sdata->dev, &sdata->reserved_chandef,0 ); }void ieee80211_chswitch_done (struct ieee80211_vif *vif,bool success)
net/wireless/ap.c +37 -9
78 lines not on this page · raw message
net/wireless/chan.c +136 -60
262 lines not on this page · raw message
net/wireless/core.c +20 -8
@@ -1118,6 +1118,7 @@ static void _cfg80211_unregister_wdev(struct wireless_dev *wdev, bool unregister_netdev) {struct cfg80211_registered_device *rdev =wiphy_to_rdev (wdev->wiphy); +unsigned int link_id;ASSERT_RTNL ();lockdep_assert_held (&rdev->wiphy.mtx);
@@ -1167,11 +1168,22 @@ static void _cfg80211_unregister_wdev(struct wireless_dev *wdev,*/ cfg80211_process_wdev_events (wdev); -if (WARN_ON (wdev->current_bss)) { -cfg80211_unhold_bss (wdev->current_bss); -cfg80211_put_bss (wdev->wiphy, &wdev->current_bss->pub); - wdev->current_bss =NULL ; +if (wdev->iftype ==NL80211_IFTYPE_STATION || + wdev->iftype ==NL80211_IFTYPE_P2P_CLIENT ) { +for (link_id =0 ; link_id <ARRAY_SIZE (wdev->links); link_id++) { +struct cfg80211_internal_bss *curbss; + + curbss = wdev->links[link_id].client.current_bss; + +if (WARN_ON (curbss)) { +cfg80211_unhold_bss (curbss); +cfg80211_put_bss (wdev->wiphy, &curbss->pub); + wdev->links[link_id].client.current_bss =NULL ; + } + } } + + wdev->connected = false; }void cfg80211_unregister_wdev (struct wireless_dev *wdev)
@@ -1233,7 +1245,7 @@ void __cfg80211_leave(struct cfg80211_registered_device *rdev,break ;case NL80211_IFTYPE_AP :case NL80211_IFTYPE_P2P_GO : -__cfg80211_stop_ap (rdev, dev, true); +__cfg80211_stop_ap (rdev, dev,-1 , true);break ;case NL80211_IFTYPE_OCB :__cfg80211_leave_ocb (rdev, dev);
@@ -1463,9 +1475,9 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb,memcpy (&setup, &default_mesh_setup,sizeof (setup));/* back compat only needed for mesh_id */ - setup.mesh_id = wdev->ssid; - setup.mesh_id_len = wdev->mesh_id_up_len; -if (wdev->mesh_id_up_len) + setup.mesh_id = wdev->u.mesh.id; + setup.mesh_id_len = wdev->u.mesh.id_up_len; +if (wdev->u.mesh.id_up_len)__cfg80211_join_mesh (rdev, dev, &setup, &default_mesh_config);
net/wireless/core.h +10 -3
@@ -307,6 +307,7 @@ void cfg80211_bss_expire(struct cfg80211_registered_device *rdev);void cfg80211_bss_age (struct cfg80211_registered_device *rdev,unsigned long age_secs);void cfg80211_update_assoc_bss_entry (struct wireless_dev *wdev, +unsigned int link,struct ieee80211_channel *channel);/* IBSS */
@@ -353,9 +354,11 @@ int cfg80211_leave_ocb(struct cfg80211_registered_device *rdev,/* AP */ int __cfg80211_stop_ap (struct cfg80211_registered_device *rdev, -struct net_device *dev,bool notify); +struct net_device *dev,int link, +bool notify);int cfg80211_stop_ap (struct cfg80211_registered_device *rdev, -struct net_device *dev,bool notify); +struct net_device *dev,int link, +bool notify);/* MLME */ int cfg80211_mlme_auth(struct cfg80211_registered_device *rdev,
@@ -507,7 +510,11 @@ bool cfg80211_any_wiphy_oper_chan(struct wiphy *wiphy,bool cfg80211_beaconing_iface_active (struct wireless_dev *wdev);bool cfg80211_is_sub_chan (struct cfg80211_chan_def *chandef, -struct ieee80211_channel *chan); +struct ieee80211_channel *chan, +bool primary_only); +bool cfg80211_wdev_on_sub_chan (struct wireless_dev *wdev, +struct ieee80211_channel *chan, +bool primary_only);static inline unsigned int elapsed_jiffies_msecs (unsigned long start) {
net/wireless/ibss.c +29 -28
147 lines not on this page · raw message
net/wireless/mesh.c +18 -13
@@ -1,4 +1,8 @@// SPDX-License-Identifier: GPL-2.0 +/* +* Portions +* Copyright (C) 2022 Intel Corporation +*/ #include <linux/ieee80211.h> #include <linux/export.h> #include <net/cfg80211.h>
@@ -114,7 +118,7 @@ int __cfg80211_join_mesh(struct cfg80211_registered_device *rdev, setup->is_secure)return -EOPNOTSUPP ; -if (wdev->mesh_id_len) +if (wdev->u.mesh.id_len)return -EALREADY ;if (!setup->mesh_id_len)
@@ -125,7 +129,7 @@ int __cfg80211_join_mesh(struct cfg80211_registered_device *rdev,if (!setup->chandef.chan) {/* if no channel explicitly given, use preset channel */ - setup->chandef = wdev->preset_chandef; + setup->chandef = wdev->u.mesh.preset_chandef; }if (!setup->chandef.chan) {
@@ -209,10 +213,10 @@ int __cfg80211_join_mesh(struct cfg80211_registered_device *rdev, err =rdev_join_mesh (rdev, dev, conf, setup);if (!err) { -memcpy (wdev->ssid, setup->mesh_id, setup->mesh_id_len); - wdev->mesh_id_len = setup->mesh_id_len; - wdev->chandef = setup->chandef; - wdev->beacon_interval = setup->beacon_interval; +memcpy (wdev->u.mesh.id, setup->mesh_id, setup->mesh_id_len); + wdev->u.mesh.id_len = setup->mesh_id_len; + wdev->u.mesh.chandef = setup->chandef; + wdev->u.mesh.beacon_interval = setup->beacon_interval; }return err;
@@ -241,15 +245,15 @@ int cfg80211_set_mesh_channel(struct cfg80211_registered_device *rdev, err =rdev_libertas_set_mesh_channel (rdev, wdev->netdev, chandef->chan);if (!err) - wdev->chandef = *chandef; + wdev->u.mesh.chandef = *chandef;return err; } -if (wdev->mesh_id_len) +if (wdev->u.mesh.id_len)return -EBUSY ; - wdev->preset_chandef = *chandef; + wdev->u.mesh.preset_chandef = *chandef;return 0 ; }
@@ -267,15 +271,16 @@ int __cfg80211_leave_mesh(struct cfg80211_registered_device *rdev,if (!rdev->ops->leave_mesh)return -EOPNOTSUPP ; -if (!wdev->mesh_id_len) +if (!wdev->u.mesh.id_len)return -ENOTCONN ; err =rdev_leave_mesh (rdev, dev);if (!err) { wdev->conn_owner_nlportid =0 ; - wdev->mesh_id_len =0 ; - wdev->beacon_interval =0 ; -memset (&wdev->chandef,0 ,sizeof (wdev->chandef)); + wdev->u.mesh.id_len =0 ; + wdev->u.mesh.beacon_interval =0 ; +memset (&wdev->u.mesh.chandef,0 , +sizeof (wdev->u.mesh.chandef));rdev_set_qos_map (rdev, dev,NULL );cfg80211_sched_dfs_chan_update (rdev); }
net/wireless/mlme.c +42 -32
168 lines not on this page · raw message
net/wireless/nl80211.c +459 -164
1,239 lines not on this page · raw message
net/wireless/ocb.c +3 -2
@@ -4,6 +4,7 @@* * Copyright: (c) 2014 Czech Technical University in Prague * (c) 2014 Volkswagen Group Research +* Copyright (C) 2022 Intel Corporation * Author: Rostislav Lisovy <[email protected]> * Funded by: Volkswagen Group Research */
@@ -34,7 +35,7 @@ int __cfg80211_join_ocb(struct cfg80211_registered_device *rdev, err =rdev_join_ocb (rdev, dev, setup);if (!err) - wdev->chandef = setup->chandef; + wdev->u.ocb.chandef = setup->chandef;return err; }
@@ -69,7 +70,7 @@ int __cfg80211_leave_ocb(struct cfg80211_registered_device *rdev, err =rdev_leave_ocb (rdev, dev);if (!err) -memset (&wdev->chandef,0 ,sizeof (wdev->chandef)); +memset (&wdev->u.ocb.chandef,0 ,sizeof (wdev->u.ocb.chandef));return err; }
net/wireless/rdev-ops.h +21 -11
@@ -1,4 +1,9 @@/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Portions of this file +* Copyright(c) 2016-2017 Intel Deutschland GmbH +* Copyright (C) 2018, 2021-2022 Intel Corporation +*/ #ifndef __CFG80211_RDEV_OPS#define __CFG80211_RDEV_OPS
@@ -172,11 +177,11 @@ static inline int rdev_change_beacon(struct cfg80211_registered_device *rdev, }static inline int rdev_stop_ap (struct cfg80211_registered_device *rdev, -struct net_device *dev) +struct net_device *dev,unsigned int link_id) {int ret; -trace_rdev_stop_ap (&rdev->wiphy, dev); - ret = rdev->ops->stop_ap (&rdev->wiphy, dev); +trace_rdev_stop_ap (&rdev->wiphy, dev, link_id); + ret = rdev->ops->stop_ap (&rdev->wiphy, dev, link_id);trace_rdev_return_int (&rdev->wiphy, ret);return ret; }
@@ -651,12 +656,14 @@ static inline int rdev_testmode_dump(struct cfg80211_registered_device *rdev,static inline int rdev_set_bitrate_mask (struct cfg80211_registered_device *rdev, -struct net_device *dev,const u8 *peer, +struct net_device *dev,unsigned int link_id, +const u8 *peer,const struct cfg80211_bitrate_mask *mask) {int ret; -trace_rdev_set_bitrate_mask (&rdev->wiphy, dev, peer, mask); - ret = rdev->ops->set_bitrate_mask (&rdev->wiphy, dev, peer, mask); +trace_rdev_set_bitrate_mask (&rdev->wiphy, dev, link_id, peer, mask); + ret = rdev->ops->set_bitrate_mask (&rdev->wiphy, dev, link_id, + peer, mask);trace_rdev_return_int (&rdev->wiphy, ret);return ret; }
@@ -944,12 +951,13 @@ static inline int rdev_set_noack_map(struct cfg80211_registered_device *rdev,static inline int rdev_get_channel (struct cfg80211_registered_device *rdev,struct wireless_dev *wdev, +unsigned int link_id,struct cfg80211_chan_def *chandef) {int ret; -trace_rdev_get_channel (&rdev->wiphy, wdev); - ret = rdev->ops->get_channel (&rdev->wiphy, wdev, chandef); +trace_rdev_get_channel (&rdev->wiphy, wdev, link_id); + ret = rdev->ops->get_channel (&rdev->wiphy, wdev, link_id, chandef);trace_rdev_return_chandef (&rdev->wiphy, ret, chandef);return ret;
@@ -1107,12 +1115,14 @@ static inline int rdev_set_qos_map(struct cfg80211_registered_device *rdev,static inline int rdev_set_ap_chanwidth (struct cfg80211_registered_device *rdev, -struct net_device *dev,struct cfg80211_chan_def *chandef) +struct net_device *dev, +unsigned int link_id, +struct cfg80211_chan_def *chandef) {int ret; -trace_rdev_set_ap_chanwidth (&rdev->wiphy, dev, chandef); - ret = rdev->ops->set_ap_chanwidth (&rdev->wiphy, dev, chandef); +trace_rdev_set_ap_chanwidth (&rdev->wiphy, dev, link_id, chandef); + ret = rdev->ops->set_ap_chanwidth (&rdev->wiphy, dev, link_id, chandef);trace_rdev_return_int (&rdev->wiphy, ret);return ret;
net/wireless/reg.c +85 -54
168 lines not on this page · raw message
net/wireless/scan.c +5 -3
@@ -5,7 +5,7 @@* Copyright 2008 Johannes Berg <[email protected]> * Copyright 2013-2014 Intel Mobile Communications GmbH * Copyright 2016 Intel Deutschland GmbH -* Copyright (C) 2018-2021 Intel Corporation +* Copyright (C) 2018-2022 Intel Corporation */ #include <linux/kernel.h> #include <linux/slab.h>
@@ -2617,7 +2617,8 @@ void cfg80211_bss_iter(struct wiphy *wiphy,spin_lock_bh (&rdev->bss_lock);list_for_each_entry (bss, &rdev->bss_list, list) { -if (!chandef ||cfg80211_is_sub_chan (chandef, bss->pub.channel)) +if (!chandef ||cfg80211_is_sub_chan (chandef, bss->pub.channel, + false))iter (wiphy, &bss->pub, iter_data); }
@@ -2626,11 +2627,12 @@ void cfg80211_bss_iter(struct wiphy *wiphy,EXPORT_SYMBOL (cfg80211_bss_iter);void cfg80211_update_assoc_bss_entry (struct wireless_dev *wdev, +unsigned int link_id,struct ieee80211_channel *chan) {struct wiphy *wiphy = wdev->wiphy;struct cfg80211_registered_device *rdev =wiphy_to_rdev (wiphy); -struct cfg80211_internal_bss *cbss = wdev->current_bss; +struct cfg80211_internal_bss *cbss = wdev->links[link_id].client.current_bss;struct cfg80211_internal_bss *new =NULL ;struct cfg80211_internal_bss *bss;struct cfg80211_bss *nontrans_bss;
net/wireless/sme.c +54 -48
67 lines not on this page · raw message
net/wireless/trace.h +65 -21
86 lines not on this page · raw message
net/wireless/util.c +37 -7
44 lines not on this page · raw message
net/wireless/wext-compat.c +35 -13
48 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.35.1
Part of the diff is not shown here. View the raw message.