From patchwork Tue Sep 14 15:18:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Young X-Patchwork-Id: 12493931 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 166B2C433F5 for ; Tue, 14 Sep 2021 15:18:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F35766115C for ; Tue, 14 Sep 2021 15:18:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234793AbhINPTc (ORCPT ); Tue, 14 Sep 2021 11:19:32 -0400 Received: from gofer.mess.org ([88.97.38.141]:35469 "EHLO gofer.mess.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234879AbhINPT2 (ORCPT ); Tue, 14 Sep 2021 11:19:28 -0400 Received: by gofer.mess.org (Postfix, from userid 1000) id 460B8C6398; Tue, 14 Sep 2021 16:18:09 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mess.org; s=2020; t=1631632689; bh=qeS/5imX9GLmIFY4E6hwoHSSrOLKVUvULn/KMQN2Ozc=; h=From:To:Cc:Subject:Date:From; b=lLw/CbK3FIjjpwYsHvj/nTa8oprwHd/CwV4VN5BC66grJeL3LwwIaxztH5e92UA1r 0oOG6L/z25YALUHbCt8+qj8uvgShy3QRiqlXRZgw+nturEQFDZouaOxFYPX2eD7BoL jTPSD/y2RVZVI7k1CHPBmSzw+0DsveHJl0lT7akflobBXASog08xvx0046x6OH2gkt BPVWQzuHlOP/wmXLLZOWOpTbH6D+rBaGLxzQkZUKG4f7cMZlTgcTzjt6LSnzoNIyb6 VVUFbwbdBKYtgn7il2y8tZcapIVwMDOWDCUyRkfQ9fZB8wlBUdhC9Lg3lWV7BWXdeX QPOD9A7C0VUXQ== From: Sean Young To: linux-media@vger.kernel.org Cc: Georgi Bakalski Subject: [PATCH 1/4] media: ir_toy: print firmwware version in correct format Date: Tue, 14 Sep 2021 16:18:06 +0100 Message-Id: <22eeae667aac9d5eaaae2f21904f238ebef0c05b.1631632442.git.sean@mess.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org A value of 25 means firmware version 2.5. Signed-off-by: Sean Young --- drivers/media/rc/ir_toy.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/rc/ir_toy.c b/drivers/media/rc/ir_toy.c index b0dc19d36ac9..45d39b6e49c0 100644 --- a/drivers/media/rc/ir_toy.c +++ b/drivers/media/rc/ir_toy.c @@ -440,8 +440,9 @@ static int irtoy_probe(struct usb_interface *intf, if (err) goto free_rcdev; - dev_info(irtoy->dev, "version: hardware %u, firmware %u, protocol %u", - irtoy->hw_version, irtoy->sw_version, irtoy->proto_version); + dev_info(irtoy->dev, "version: hardware %u, firmware %u.%u, protocol %u", + irtoy->hw_version, irtoy->sw_version / 10, + irtoy->sw_version % 10, irtoy->proto_version); if (irtoy->sw_version < MIN_FW_VERSION) { dev_err(irtoy->dev, "need firmware V%02u or higher", From patchwork Tue Sep 14 15:18:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Young X-Patchwork-Id: 12493935 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D1E3C433FE for ; Tue, 14 Sep 2021 15:18:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E94B161151 for ; Tue, 14 Sep 2021 15:18:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234771AbhINPTd (ORCPT ); Tue, 14 Sep 2021 11:19:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234273AbhINPTb (ORCPT ); Tue, 14 Sep 2021 11:19:31 -0400 Received: from gofer.mess.org (gofer.mess.org [IPv6:2a02:8011:d000:212::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 685FBC0613CF; Tue, 14 Sep 2021 08:18:12 -0700 (PDT) Received: by gofer.mess.org (Postfix, from userid 1000) id 654D4C6355; Tue, 14 Sep 2021 16:18:09 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mess.org; s=2020; t=1631632689; bh=/IhPmIr9/LHDBv8I1A2poHCsQ9nOxmqZ/x5osrJSJAM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JDiLzAMPXiYDuvfH6vtr9I65enS3LtscCNuUkisqFNv2FXKReQgFn+Eh+yZCGONT9 E8yg2mv83s23k45nzOEXJwxWjALbUXl7iyh98c8S8lGEfRWakfHS3Dbfzd+0u5TZzH rBORpK2YG1MSh2kVGjtWhtKj6BXRndQK1kSd0FVzg3t6GuZ4r6XZLFz7NR+sEMIqMs Xt0bp01VbBFxlpvXpOCKXSLRP1HlkY09Pnhn6OmAEBXBRjKvjMShz7gQpIqinrSXBB LSJrwJyKywsncjGl0OtLNVf+tmdNwmTJBhnEPLUrFKmd+7YZd/GvZZsNzaRKldv2yD ktuXrGtBQpn6Q== From: Sean Young To: linux-media@vger.kernel.org Cc: Georgi Bakalski , stable@vger.kernel.org Subject: [PATCH 2/4] media: ir_toy: deal with residual irdata before expected response Date: Tue, 14 Sep 2021 16:18:07 +0100 Message-Id: <2b28f45034d54371fe420f3a54c7eb93034024e1.1631632442.git.sean@mess.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <22eeae667aac9d5eaaae2f21904f238ebef0c05b.1631632442.git.sean@mess.org> References: <22eeae667aac9d5eaaae2f21904f238ebef0c05b.1631632442.git.sean@mess.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org After sending the start transmit command, the device is supposed to respond with the length of the buffer which can be sent. There might be some residual ir data there. Cc: stable@vger.kernel.org Signed-off-by: Sean Young --- drivers/media/rc/ir_toy.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/media/rc/ir_toy.c b/drivers/media/rc/ir_toy.c index 45d39b6e49c0..2b7c8bba4d6a 100644 --- a/drivers/media/rc/ir_toy.c +++ b/drivers/media/rc/ir_toy.c @@ -122,6 +122,7 @@ static void irtoy_response(struct irtoy *irtoy, u32 len) len, irtoy->in); } break; + case STATE_COMMAND_NO_RESP: case STATE_IRDATA: { struct ir_raw_event rawir = { .pulse = irtoy->pulse }; __be16 *in = (__be16 *)irtoy->in; @@ -167,10 +168,8 @@ static void irtoy_response(struct irtoy *irtoy, u32 len) int err; if (len != 1 || space > MAX_PACKET || space == 0) { - dev_err(irtoy->dev, "packet length expected: %*phN\n", + dev_dbg(irtoy->dev, "packet length expected: %*phN\n", len, irtoy->in); - irtoy->state = STATE_IRDATA; - complete(&irtoy->command_done); break; } @@ -194,9 +193,6 @@ static void irtoy_response(struct irtoy *irtoy, u32 len) irtoy->tx_len -= buf_len; } break; - case STATE_COMMAND_NO_RESP: - dev_err(irtoy->dev, "unexpected response to reset: %*phN\n", - len, irtoy->in); } } From patchwork Tue Sep 14 15:18:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Young X-Patchwork-Id: 12493933 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76A64C433EF for ; Tue, 14 Sep 2021 15:18:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6486E61151 for ; Tue, 14 Sep 2021 15:18:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234803AbhINPTc (ORCPT ); Tue, 14 Sep 2021 11:19:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234350AbhINPTb (ORCPT ); Tue, 14 Sep 2021 11:19:31 -0400 Received: from gofer.mess.org (gofer.mess.org [IPv6:2a02:8011:d000:212::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6809FC061768 for ; Tue, 14 Sep 2021 08:18:12 -0700 (PDT) Received: by gofer.mess.org (Postfix, from userid 1000) id 7A9BBC64DB; Tue, 14 Sep 2021 16:18:09 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mess.org; s=2020; t=1631632689; bh=X5FVP3NY/rkYiydH64k/xGz1BQQi5i1hZr4CRXtGGRE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ax9Jr0jNhYiI91jz98p9hVBchlDmQnzMXKv56tBwfekLU8DW13elwzaBOSR++m1be dXsqYzuUwq8MpKzDz2OYdwYR1FibwEPUssYJ/tdwH5htgoy9qFFot5gzpdfK6mbO44 hNyZfdKsT0arC4EuPJkGIwMD1hg871zrJCH7XLqNzwKp49dR3cxl8FkGPJK5wYzhzL hga1yZJR4Xjk61uUSsSH/z/oYkyUlwiVNYpNqdyR4lbWvxCzI9mTAXk/fM2DkS/IEZ VeJZXkvwc66+BnczlQNZ1CL5JlmIRHKuU3WuOI71wMwFbygTO8p1OV9xEbXZCBdgm4 tXhK9qv6uG4aQ== From: Sean Young To: linux-media@vger.kernel.org Cc: Georgi Bakalski Subject: [PATCH 3/4] media: ir_toy: do not resubmit broken urb Date: Tue, 14 Sep 2021 16:18:08 +0100 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: <22eeae667aac9d5eaaae2f21904f238ebef0c05b.1631632442.git.sean@mess.org> References: <22eeae667aac9d5eaaae2f21904f238ebef0c05b.1631632442.git.sean@mess.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org This causes the same urb to resubmitted continuously, hogging up a cpu. Signed-off-by: Sean Young --- drivers/media/rc/ir_toy.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/media/rc/ir_toy.c b/drivers/media/rc/ir_toy.c index 2b7c8bba4d6a..d2d9346eb8f5 100644 --- a/drivers/media/rc/ir_toy.c +++ b/drivers/media/rc/ir_toy.c @@ -213,10 +213,20 @@ static void irtoy_in_callback(struct urb *urb) struct irtoy *irtoy = urb->context; int ret; - if (urb->status == 0) + switch (urb->status) { + case 0: irtoy_response(irtoy, urb->actual_length); - else + break; + case -ECONNRESET: + case -ENOENT: + case -ESHUTDOWN: + case -EPROTO: + case -EPIPE: + usb_unlink_urb(urb); + return; + default: dev_dbg(irtoy->dev, "in urb status: %d\n", urb->status); + } ret = usb_submit_urb(urb, GFP_ATOMIC); if (ret && ret != -ENODEV) From patchwork Tue Sep 14 15:18:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Young X-Patchwork-Id: 12493937 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-21.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 708D3C43219 for ; Tue, 14 Sep 2021 15:18:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5D14961151 for ; Tue, 14 Sep 2021 15:18:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234826AbhINPTe (ORCPT ); Tue, 14 Sep 2021 11:19:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234779AbhINPTb (ORCPT ); Tue, 14 Sep 2021 11:19:31 -0400 Received: from gofer.mess.org (gofer.mess.org [IPv6:2a02:8011:d000:212::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6857BC0613C1; Tue, 14 Sep 2021 08:18:12 -0700 (PDT) Received: by gofer.mess.org (Postfix, from userid 1000) id 90BDEC65BA; Tue, 14 Sep 2021 16:18:09 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mess.org; s=2020; t=1631632689; bh=WksOAXceADQojSv7D9XcocopFCjz8Htoqezgrn7HtWc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M5H+5QxlrjRGQv24cWyMdIBqxOCO7NaO8FYzva+CkR/axoNrE5Lr4uZWg8I3n8lpY oC54a1MlTaKcQOI5uPX5Fu4GnrTV/ZOxSu0UbnticgsaNCWJDSUU12HT5lErQn5JaW lkmTgwRV7bhqGFK7qqvd73/dOCSdrhfh50wQD+Xy5HCF2OUt6OVlFio+kl42YSXeFl LL+QPnkiEvOysBeaNg9kLdSrOLLJakR4k34ZT2sr1Xu5uhoS+d98nOmNptgJP1+QnO BqH0EhwgQ/oSU5PxLDV7gLe2BdqyfrAEYZCBnMjLtQAsxvmX1HgUCm17AZY8B8kGJU GA12pd5h85Plw== From: Sean Young To: linux-media@vger.kernel.org Cc: Georgi Bakalski , stable@vger.kernel.org Subject: [PATCH 4/4] media: ir_toy: prevent device from hanging during transmit Date: Tue, 14 Sep 2021 16:18:09 +0100 Message-Id: <4ed68b6848f09f191e0709702c3d1d7838a3a717.1631632442.git.sean@mess.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <22eeae667aac9d5eaaae2f21904f238ebef0c05b.1631632442.git.sean@mess.org> References: <22eeae667aac9d5eaaae2f21904f238ebef0c05b.1631632442.git.sean@mess.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org If the IR Toy is receiving IR while a transmit is done, it may end up hanging. We can prevent this from happening by re-entering sample mode just before issuing the transmit command. Link: https://github.com/bengtmartensson/HarcHardware/discussions/25 Cc: stable@vger.kernel.org Signed-off-by: Sean Young --- drivers/media/rc/ir_toy.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/media/rc/ir_toy.c b/drivers/media/rc/ir_toy.c index d2d9346eb8f5..71aced52248f 100644 --- a/drivers/media/rc/ir_toy.c +++ b/drivers/media/rc/ir_toy.c @@ -26,6 +26,7 @@ static const u8 COMMAND_VERSION[] = { 'v' }; // End transmit and repeat reset command so we exit sump mode static const u8 COMMAND_RESET[] = { 0xff, 0xff, 0, 0, 0, 0, 0 }; static const u8 COMMAND_SMODE_ENTER[] = { 's' }; +static const u8 COMMAND_SMODE_EXIT[] = { 0 }; static const u8 COMMAND_TXSTART[] = { 0x26, 0x24, 0x25, 0x03 }; #define REPLY_XMITCOUNT 't' @@ -317,12 +318,30 @@ static int irtoy_tx(struct rc_dev *rc, uint *txbuf, uint count) buf[i] = cpu_to_be16(v); } - buf[count] = cpu_to_be16(0xffff); + buf[count] = 0xffff; irtoy->tx_buf = buf; irtoy->tx_len = size; irtoy->emitted = 0; + // There is an issue where if the unit is receiving IR while the + // first TXSTART command is sent, the device might end up hanging + // with its led on. It does not respond to any command when this + // happens. To work around this, re-enter sample mode. + err = irtoy_command(irtoy, COMMAND_SMODE_EXIT, + sizeof(COMMAND_SMODE_EXIT), STATE_COMMAND_NO_RESP); + if (err) { + dev_err(irtoy->dev, "exit sample mode: %d\n", err); + return err; + } + + err = irtoy_command(irtoy, COMMAND_SMODE_ENTER, + sizeof(COMMAND_SMODE_ENTER), STATE_COMMAND); + if (err) { + dev_err(irtoy->dev, "enter sample mode: %d\n", err); + return err; + } + err = irtoy_command(irtoy, COMMAND_TXSTART, sizeof(COMMAND_TXSTART), STATE_TX); kfree(buf);