Skip to content

Commit 50978df

Browse files
committed
Merge tag 'media/v5.5-3' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
Pull media fixes from Mauro Carvalho Chehab: - some fixes at CEC core to comply with HDMI 2.0 specs and fix some border cases - a fix at the transmission logic of the pulse8-cec driver - one alignment fix on a data struct at ipu3 when built with 32 bits * tag 'media/v5.5-3' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: media: intel-ipu3: Align struct ipu3_uapi_awb_fr_config_s to 32 bytes media: pulse8-cec: fix lost cec_transmit_attempt_done() call media: cec: check 'transmit_in_progress', not 'transmitting' media: cec: avoid decrementing transmit_queue_sz if it is 0 media: cec: CEC 2.0-only bcast messages were ignored
2 parents 3a562ae + ce644cf commit 50978df

File tree

3 files changed

+41
-18
lines changed

3 files changed

+41
-18
lines changed

drivers/media/cec/cec-adap.c

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,8 @@ static void cec_data_cancel(struct cec_data *data, u8 tx_status)
380380
} else {
381381
list_del_init(&data->list);
382382
if (!(data->msg.tx_status & CEC_TX_STATUS_OK))
383-
data->adap->transmit_queue_sz--;
383+
if (!WARN_ON(!data->adap->transmit_queue_sz))
384+
data->adap->transmit_queue_sz--;
384385
}
385386

386387
if (data->msg.tx_status & CEC_TX_STATUS_OK) {
@@ -432,6 +433,14 @@ static void cec_flush(struct cec_adapter *adap)
432433
* need to do anything special in that case.
433434
*/
434435
}
436+
/*
437+
* If something went wrong and this counter isn't what it should
438+
* be, then this will reset it back to 0. Warn if it is not 0,
439+
* since it indicates a bug, either in this framework or in a
440+
* CEC driver.
441+
*/
442+
if (WARN_ON(adap->transmit_queue_sz))
443+
adap->transmit_queue_sz = 0;
435444
}
436445

437446
/*
@@ -456,7 +465,7 @@ int cec_thread_func(void *_adap)
456465
bool timeout = false;
457466
u8 attempts;
458467

459-
if (adap->transmitting) {
468+
if (adap->transmit_in_progress) {
460469
int err;
461470

462471
/*
@@ -491,7 +500,7 @@ int cec_thread_func(void *_adap)
491500
goto unlock;
492501
}
493502

494-
if (adap->transmitting && timeout) {
503+
if (adap->transmit_in_progress && timeout) {
495504
/*
496505
* If we timeout, then log that. Normally this does
497506
* not happen and it is an indication of a faulty CEC
@@ -500,14 +509,18 @@ int cec_thread_func(void *_adap)
500509
* so much traffic on the bus that the adapter was
501510
* unable to transmit for CEC_XFER_TIMEOUT_MS (2.1s).
502511
*/
503-
pr_warn("cec-%s: message %*ph timed out\n", adap->name,
504-
adap->transmitting->msg.len,
505-
adap->transmitting->msg.msg);
512+
if (adap->transmitting) {
513+
pr_warn("cec-%s: message %*ph timed out\n", adap->name,
514+
adap->transmitting->msg.len,
515+
adap->transmitting->msg.msg);
516+
/* Just give up on this. */
517+
cec_data_cancel(adap->transmitting,
518+
CEC_TX_STATUS_TIMEOUT);
519+
} else {
520+
pr_warn("cec-%s: transmit timed out\n", adap->name);
521+
}
506522
adap->transmit_in_progress = false;
507523
adap->tx_timeouts++;
508-
/* Just give up on this. */
509-
cec_data_cancel(adap->transmitting,
510-
CEC_TX_STATUS_TIMEOUT);
511524
goto unlock;
512525
}
513526

@@ -522,7 +535,8 @@ int cec_thread_func(void *_adap)
522535
data = list_first_entry(&adap->transmit_queue,
523536
struct cec_data, list);
524537
list_del_init(&data->list);
525-
adap->transmit_queue_sz--;
538+
if (!WARN_ON(!data->adap->transmit_queue_sz))
539+
adap->transmit_queue_sz--;
526540

527541
/* Make this the current transmitting message */
528542
adap->transmitting = data;
@@ -1085,11 +1099,11 @@ void cec_received_msg_ts(struct cec_adapter *adap,
10851099
valid_la = false;
10861100
else if (!cec_msg_is_broadcast(msg) && !(dir_fl & DIRECTED))
10871101
valid_la = false;
1088-
else if (cec_msg_is_broadcast(msg) && !(dir_fl & BCAST1_4))
1102+
else if (cec_msg_is_broadcast(msg) && !(dir_fl & BCAST))
10891103
valid_la = false;
10901104
else if (cec_msg_is_broadcast(msg) &&
1091-
adap->log_addrs.cec_version >= CEC_OP_CEC_VERSION_2_0 &&
1092-
!(dir_fl & BCAST2_0))
1105+
adap->log_addrs.cec_version < CEC_OP_CEC_VERSION_2_0 &&
1106+
!(dir_fl & BCAST1_4))
10931107
valid_la = false;
10941108
}
10951109
if (valid_la && min_len) {

drivers/media/usb/pulse8-cec/pulse8-cec.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ struct pulse8 {
116116
unsigned int vers;
117117
struct completion cmd_done;
118118
struct work_struct work;
119+
u8 work_result;
119120
struct delayed_work ping_eeprom_work;
120121
struct cec_msg rx_msg;
121122
u8 data[DATA_SIZE];
@@ -137,8 +138,10 @@ static void pulse8_irq_work_handler(struct work_struct *work)
137138
{
138139
struct pulse8 *pulse8 =
139140
container_of(work, struct pulse8, work);
141+
u8 result = pulse8->work_result;
140142

141-
switch (pulse8->data[0] & 0x3f) {
143+
pulse8->work_result = 0;
144+
switch (result & 0x3f) {
142145
case MSGCODE_FRAME_DATA:
143146
cec_received_msg(pulse8->adap, &pulse8->rx_msg);
144147
break;
@@ -172,12 +175,12 @@ static irqreturn_t pulse8_interrupt(struct serio *serio, unsigned char data,
172175
pulse8->escape = false;
173176
} else if (data == MSGEND) {
174177
struct cec_msg *msg = &pulse8->rx_msg;
178+
u8 msgcode = pulse8->buf[0];
175179

176180
if (debug)
177181
dev_info(pulse8->dev, "received: %*ph\n",
178182
pulse8->idx, pulse8->buf);
179-
pulse8->data[0] = pulse8->buf[0];
180-
switch (pulse8->buf[0] & 0x3f) {
183+
switch (msgcode & 0x3f) {
181184
case MSGCODE_FRAME_START:
182185
msg->len = 1;
183186
msg->msg[0] = pulse8->buf[1];
@@ -186,14 +189,20 @@ static irqreturn_t pulse8_interrupt(struct serio *serio, unsigned char data,
186189
if (msg->len == CEC_MAX_MSG_SIZE)
187190
break;
188191
msg->msg[msg->len++] = pulse8->buf[1];
189-
if (pulse8->buf[0] & MSGCODE_FRAME_EOM)
192+
if (msgcode & MSGCODE_FRAME_EOM) {
193+
WARN_ON(pulse8->work_result);
194+
pulse8->work_result = msgcode;
190195
schedule_work(&pulse8->work);
196+
break;
197+
}
191198
break;
192199
case MSGCODE_TRANSMIT_SUCCEEDED:
193200
case MSGCODE_TRANSMIT_FAILED_LINE:
194201
case MSGCODE_TRANSMIT_FAILED_ACK:
195202
case MSGCODE_TRANSMIT_FAILED_TIMEOUT_DATA:
196203
case MSGCODE_TRANSMIT_FAILED_TIMEOUT_LINE:
204+
WARN_ON(pulse8->work_result);
205+
pulse8->work_result = msgcode;
197206
schedule_work(&pulse8->work);
198207
break;
199208
case MSGCODE_HIGH_ERROR:

drivers/staging/media/ipu3/include/intel-ipu3.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ struct ipu3_uapi_awb_fr_config_s {
449449
__u16 reserved1;
450450
__u32 bayer_sign;
451451
__u8 bayer_nf;
452-
__u8 reserved2[3];
452+
__u8 reserved2[7];
453453
} __attribute__((aligned(32))) __packed;
454454

455455
/**

0 commit comments

Comments
 (0)