diff mbox

[REVIEW,1/2] img-ir/hw: Avoid clearing filter for no-op protocol change

Message ID 1417438510-18977-2-git-send-email-james.hogan@imgtec.com (mailing list archive)
State New, archived
Headers show

Commit Message

James Hogan Dec. 1, 2014, 12:55 p.m. UTC
When the img-ir driver is asked to change protocol, if the chosen
decoder is already loaded then don't call img_ir_set_decoder(), so as
not to clear the current filter.

This is important because store_protocol() does not refresh the scancode
filter with the new protocol if the set of enabled protocols hasn't
actually changed, but it will still call the change_protocol() callback,
resulting in the filter being disabled in the hardware.

The problem can be reproduced by setting a filter, and then setting the
protocol to the same protocol that is already set:
$ echo nec > protocols
$ echo 0xffff > filter_mask
$ echo nec > protocols

After this, messages which don't match the filter still get received.

Reported-by: Sifan Naeem <sifan.naeem@imgtec.com>
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Mauro Carvalho Chehab <m.chehab@samsung.com>
Cc: <stable@vger.kernel.org> # v3.15+
Cc: linux-media@vger.kernel.org
---
 drivers/media/rc/img-ir/img-ir-hw.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Mauro Carvalho Chehab Dec. 4, 2014, 5:38 p.m. UTC | #1
Em Mon, 1 Dec 2014 12:55:09 +0000
James Hogan <james.hogan@imgtec.com> escreveu:

> When the img-ir driver is asked to change protocol, if the chosen
> decoder is already loaded then don't call img_ir_set_decoder(), so as
> not to clear the current filter.
> 
> This is important because store_protocol() does not refresh the scancode
> filter with the new protocol if the set of enabled protocols hasn't
> actually changed, but it will still call the change_protocol() callback,
> resulting in the filter being disabled in the hardware.
> 
> The problem can be reproduced by setting a filter, and then setting the
> protocol to the same protocol that is already set:
> $ echo nec > protocols
> $ echo 0xffff > filter_mask
> $ echo nec > protocols
> 
> After this, messages which don't match the filter still get received.

This should be fixed at the RC core, as this is not driver-specific.

Regards,
Mauro

> 
> Reported-by: Sifan Naeem <sifan.naeem@imgtec.com>
> Signed-off-by: James Hogan <james.hogan@imgtec.com>
> Cc: Mauro Carvalho Chehab <m.chehab@samsung.com>
> Cc: <stable@vger.kernel.org> # v3.15+
> Cc: linux-media@vger.kernel.org
> ---
>  drivers/media/rc/img-ir/img-ir-hw.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/media/rc/img-ir/img-ir-hw.c b/drivers/media/rc/img-ir/img-ir-hw.c
> index 9db065344b41..1566337c1059 100644
> --- a/drivers/media/rc/img-ir/img-ir-hw.c
> +++ b/drivers/media/rc/img-ir/img-ir-hw.c
> @@ -643,6 +643,12 @@ static int img_ir_change_protocol(struct rc_dev *dev, u64 *ir_type)
>  			continue;
>  		if (*ir_type & dec->type) {
>  			*ir_type &= dec->type;
> +			/*
> +			 * We don't want to clear the filter if nothing is
> +			 * changing as it won't get set again.
> +			 */
> +			if (dec == hw->decoder)
> +				return 0;
>  			img_ir_set_decoder(priv, dec, *ir_type);
>  			goto success;
>  		}
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
James Hogan Dec. 8, 2014, 4:13 p.m. UTC | #2
Hi Mauro,

On 04/12/14 17:38, Mauro Carvalho Chehab wrote:
> Em Mon, 1 Dec 2014 12:55:09 +0000
> James Hogan <james.hogan@imgtec.com> escreveu:
> 
>> When the img-ir driver is asked to change protocol, if the chosen
>> decoder is already loaded then don't call img_ir_set_decoder(), so as
>> not to clear the current filter.
>>
>> This is important because store_protocol() does not refresh the scancode
>> filter with the new protocol if the set of enabled protocols hasn't
>> actually changed, but it will still call the change_protocol() callback,
>> resulting in the filter being disabled in the hardware.
>>
>> The problem can be reproduced by setting a filter, and then setting the
>> protocol to the same protocol that is already set:
>> $ echo nec > protocols
>> $ echo 0xffff > filter_mask
>> $ echo nec > protocols
>>
>> After this, messages which don't match the filter still get received.
> 
> This should be fixed at the RC core, as this is not driver-specific.

Yes, you're right. I've fixed there and attempted backporting, and the
problem appears to have actually been introduced in commit da6e162d6a46
("[media] rc-core: simplify sysfs code") which went into v3.17.

I'll send a v2.

Thanks
James

> 
> Regards,
> Mauro
diff mbox

Patch

diff --git a/drivers/media/rc/img-ir/img-ir-hw.c b/drivers/media/rc/img-ir/img-ir-hw.c
index 9db065344b41..1566337c1059 100644
--- a/drivers/media/rc/img-ir/img-ir-hw.c
+++ b/drivers/media/rc/img-ir/img-ir-hw.c
@@ -643,6 +643,12 @@  static int img_ir_change_protocol(struct rc_dev *dev, u64 *ir_type)
 			continue;
 		if (*ir_type & dec->type) {
 			*ir_type &= dec->type;
+			/*
+			 * We don't want to clear the filter if nothing is
+			 * changing as it won't get set again.
+			 */
+			if (dec == hw->decoder)
+				return 0;
 			img_ir_set_decoder(priv, dec, *ir_type);
 			goto success;
 		}