From patchwork Thu Apr 28 13:34:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Neukum X-Patchwork-Id: 12830712 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B2ACC433F5 for ; Thu, 28 Apr 2022 13:35:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347308AbiD1NiX (ORCPT ); Thu, 28 Apr 2022 09:38:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347288AbiD1NiR (ORCPT ); Thu, 28 Apr 2022 09:38:17 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD827CD5 for ; Thu, 28 Apr 2022 06:35:01 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7A4D721870; Thu, 28 Apr 2022 13:35:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651152900; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=rGry2or8ZnSvGQwINbJylSjvHJHz+Cs/k6Wvfz4ZDK4=; b=o6WgskfmOeQPR62kBvu6pwIvzxIkN8rJ53QmFY+3LLLhGl3CnOnS964qM+D7BZoCBciMyD JweWlpcZ3xtuUslcvI3JP19kyaEyif2hSmUw5MPiQX8H49BN1KMSEZ93bzB45DAutcLgFQ YKadUuuDYRjOSHV1NkcK/nJvRflMHPk= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 4A5EB13491; Thu, 28 Apr 2022 13:35:00 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id d1N6EASYamKuTAAAMHmgww (envelope-from ); Thu, 28 Apr 2022 13:35:00 +0000 From: Oliver Neukum To: sean@mess.org, mchehab@kernel.org, linux-media@vger.kernel.org Cc: Oliver Neukum Subject: [PATCH 1/3] USB: imon: avoid needless atomic allocations in resume Date: Thu, 28 Apr 2022 15:34:53 +0200 Message-Id: <20220428133455.3200-1-oneukum@suse.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org GFP_NOIO is fine here. Signed-off-by: Oliver Neukum --- drivers/media/rc/imon.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c index 54da6f60079b..761b7fa57378 100644 --- a/drivers/media/rc/imon.c +++ b/drivers/media/rc/imon.c @@ -2578,7 +2578,7 @@ static int imon_resume(struct usb_interface *intf) usb_rx_callback_intf0, ictx, ictx->rx_endpoint_intf0->bInterval); - rc = usb_submit_urb(ictx->rx_urb_intf0, GFP_ATOMIC); + rc = usb_submit_urb(ictx->rx_urb_intf0, GFP_NOIO); } else { usb_fill_int_urb(ictx->rx_urb_intf1, ictx->usbdev_intf1, @@ -2588,7 +2588,7 @@ static int imon_resume(struct usb_interface *intf) usb_rx_callback_intf1, ictx, ictx->rx_endpoint_intf1->bInterval); - rc = usb_submit_urb(ictx->rx_urb_intf1, GFP_ATOMIC); + rc = usb_submit_urb(ictx->rx_urb_intf1, GFP_NOIO); } return rc; From patchwork Thu Apr 28 13:34:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Neukum X-Patchwork-Id: 12830713 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18719C433EF for ; Thu, 28 Apr 2022 13:35:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347316AbiD1NiY (ORCPT ); Thu, 28 Apr 2022 09:38:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347309AbiD1NiR (ORCPT ); Thu, 28 Apr 2022 09:38:17 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08701FCF for ; Thu, 28 Apr 2022 06:35:02 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id B3C3B21872; Thu, 28 Apr 2022 13:35:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651152900; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VYZ+UDp1nONzQN/HqiPcka54V8skLwOqfQ0S9hYLkgE=; b=pAFm/9X+J2/r2DMBTQ590etCAfRhPtQrQnjs+Tvtc2b3FvMoDQzwhYdU91TwBfNH9nrcHG i+6TmPKnRqJiZrjIFc9jilHhFSL9QHPgxZlFp7FeuvEskQkGoLj2kFYiMPsqPDRbtswWaB /qfhBXMAXnNprLw3qMulYdgL31fSqGA= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8479313491; Thu, 28 Apr 2022 13:35:00 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id uPdyHgSYamKuTAAAMHmgww (envelope-from ); Thu, 28 Apr 2022 13:35:00 +0000 From: Oliver Neukum To: sean@mess.org, mchehab@kernel.org, linux-media@vger.kernel.org Cc: Oliver Neukum Subject: [PATCH 2/3] USB: imon: fix timer racing disconnect Date: Thu, 28 Apr 2022 15:34:54 +0200 Message-Id: <20220428133455.3200-2-oneukum@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220428133455.3200-1-oneukum@suse.com> References: <20220428133455.3200-1-oneukum@suse.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The timer will report events for an input device. Reporting events for an unregistered device is bad. Hence the timer must be killed first. Signed-off-by: Oliver Neukum --- drivers/media/rc/imon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c index 761b7fa57378..8dbeab48ed3c 100644 --- a/drivers/media/rc/imon.c +++ b/drivers/media/rc/imon.c @@ -2537,8 +2537,8 @@ static void imon_disconnect(struct usb_interface *interface) usb_kill_urb(ictx->rx_urb_intf1); usb_put_dev(ictx->usbdev_intf1); if (ictx->display_type == IMON_DISPLAY_TYPE_VGA) { - input_unregister_device(ictx->touch); del_timer_sync(&ictx->ttimer); + input_unregister_device(ictx->touch); } } From patchwork Thu Apr 28 13:34:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Neukum X-Patchwork-Id: 12830714 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 026A3C433F5 for ; Thu, 28 Apr 2022 13:35:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347309AbiD1NiZ (ORCPT ); Thu, 28 Apr 2022 09:38:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347310AbiD1NiR (ORCPT ); Thu, 28 Apr 2022 09:38:17 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D870115A for ; Thu, 28 Apr 2022 06:35:02 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id EA56F1F745; Thu, 28 Apr 2022 13:35:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651152900; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qanz/XQuIdO1OmNd+DubCNDUnpeUsq3UV9DMjixmjRk=; b=t0b3GptzJ2jpP4maCG5S3BC96QWT79PMNfc+K1E3q1kwl8yu2hc5SpJzCT++quHuA4AbtS veiiBwg6SQ4SzzraFHYRL8KJzUmCu1H4/BY50F2AEztvqJjB36WwvTAdsHi8xLz0Q+5rbq 2CNi8gOegGFYiEw8RMAGuVmpRMqqYdU= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id BD36813491; Thu, 28 Apr 2022 13:35:00 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id YJx8LASYamKuTAAAMHmgww (envelope-from ); Thu, 28 Apr 2022 13:35:00 +0000 From: Oliver Neukum To: sean@mess.org, mchehab@kernel.org, linux-media@vger.kernel.org Cc: Oliver Neukum Subject: [PATCH 3/3] USB: imon: drop references only after device is no longer used Date: Thu, 28 Apr 2022 15:34:55 +0200 Message-Id: <20220428133455.3200-3-oneukum@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220428133455.3200-1-oneukum@suse.com> References: <20220428133455.3200-1-oneukum@suse.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The point of using get/put_device() is to keep references for as long as the device may be in use. That means dropping them must be the penultimate action right before freeing the memory. Signed-off-by: Oliver Neukum --- drivers/media/rc/imon.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c index 8dbeab48ed3c..ad8bca8a8abd 100644 --- a/drivers/media/rc/imon.c +++ b/drivers/media/rc/imon.c @@ -2523,7 +2523,6 @@ static void imon_disconnect(struct usb_interface *interface) if (ifnum == 0) { ictx->dev_present_intf0 = false; usb_kill_urb(ictx->rx_urb_intf0); - usb_put_dev(ictx->usbdev_intf0); input_unregister_device(ictx->idev); rc_unregister_device(ictx->rdev); if (ictx->display_supported) { @@ -2532,14 +2531,15 @@ static void imon_disconnect(struct usb_interface *interface) else if (ictx->display_type == IMON_DISPLAY_TYPE_VFD) usb_deregister_dev(interface, &imon_vfd_class); } + usb_put_dev(ictx->usbdev_intf0); } else { ictx->dev_present_intf1 = false; usb_kill_urb(ictx->rx_urb_intf1); - usb_put_dev(ictx->usbdev_intf1); if (ictx->display_type == IMON_DISPLAY_TYPE_VGA) { del_timer_sync(&ictx->ttimer); input_unregister_device(ictx->touch); } + usb_put_dev(ictx->usbdev_intf1); } if (!ictx->dev_present_intf0 && !ictx->dev_present_intf1)