Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2274148imm; Thu, 7 Jun 2018 08:03:19 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLXXF7tg5WtTcMER81Sys60bk1Wk0rpvuEvi4NqR6HUbSJbwZX7RT0ZzcJZWcZbun7QL8ot X-Received: by 2002:a63:6501:: with SMTP id z1-v6mr1886753pgb.452.1528383799444; Thu, 07 Jun 2018 08:03:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528383799; cv=none; d=google.com; s=arc-20160816; b=dHgjTamKbPWRQxTY2G1oSHa7fMaCAbFv33ndUX+YoS08Qop85dOV8d49KO44xmgGdG P7Cz7kMJprK6iHVBwuaOBwHbUZp+OPqB8pYi4acOgwIaS+QIVJkrmGhxV6lHlu4Hgwox 8mCHbQDxPuxhpza33QLz5Z4vEsC/L/WzRL3hflN0ugZMqLiwk4wTuh8hLxbvwCtkS5O2 q2KraJnbahGWVGnb/kcn5ZggjdOK6yetg37P/X4BxYizhpVt5+7aKjJMgsnsXehYXazj o2d0k/Jzga4+eL86icaGGeyVTn+h+TZfk4bAE0cxKFQO7E6ngForaSLXPGGVNwI3ACPx s1rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=9ptiPqNfVE88bb09eQy7DDxrMbiIBkpYwFoDRHV3Qus=; b=HrHXkezdwXIxbIiNl16FF1HzkY8oLGuSe5YF9jA/95gPjL7bF8PlBbmY53aYS8DyGO s+f0LpRhMyfVLqZ+WUIpNJkGNPVUNtj57coxYcwRjHNQmkYTnZ4S/uIELMYtk020tg8q WAn+kb4Cg4aJQ6fIddwGVub7w5569QHnBKi80p+G/qkAAh+zYCQJ3cJsYiBZKLXJ0Elf QeWUX1MfdWCANLxVk/dAI5tiWNqn3pfjaVaEu+6P/qtGi9R7kiMZB/RrrvEkZonfQKDX J89aPLf7fcSOhUlc7/baCfgRRAPn5RKK7PHHiRh1xqnsGDkQxm03Qhb1fAO9bjxV/Emi qA3w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t17-v6si28014444pgb.465.2018.06.07.08.03.04; Thu, 07 Jun 2018 08:03:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935805AbeFGPAl (ORCPT + 99 others); Thu, 7 Jun 2018 11:00:41 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:41349 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932536AbeFGPAh (ORCPT ); Thu, 7 Jun 2018 11:00:37 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvbs-0005hK-Ml; Thu, 07 Jun 2018 15:09:52 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvb1-0002pW-G0; Thu, 07 Jun 2018 15:08:59 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "John Stultz" , "Felipe Balbi" , "Android Kernel Team" , "Michal Nazarewicz" , "Badhri" , "Greg KH" , "Dmitry Shmidt" , "Amit Pundir" , "Hemant Kumar" , "Greg Kroah-Hartman" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 103/410] usb: f_fs: Prevent gadget unbind if it is already unbound In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Hemant Kumar commit ce5bf9a50daf2d9078b505aca1cea22e88ecb94a upstream. Upon usb composition switch there is possibility of ep0 file release happening after gadget driver bind. In case of composition switch from adb to a non-adb composition gadget will never gets bound again resulting into failure of usb device enumeration. Fix this issue by checking FFS_FL_BOUND flag and avoid extra gadget driver unbind if it is already done as part of composition switch. This fixes adb reconnection error reported on Android running v4.4 and above kernel versions. Verified on Hikey running vanilla v4.15-rc7 + few out of tree Mali patches. Reviewed-at: https://android-review.googlesource.com/#/c/582632/ Cc: Felipe Balbi Cc: Greg KH Cc: Michal Nazarewicz Cc: John Stultz Cc: Dmitry Shmidt Cc: Badhri Cc: Android Kernel Team Signed-off-by: Hemant Kumar [AmitP: Cherry-picked it from android-4.14 and updated the commit log] Signed-off-by: Amit Pundir Signed-off-by: Greg Kroah-Hartman Signed-off-by: Ben Hutchings --- drivers/usb/gadget/f_fs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/usb/gadget/f_fs.c +++ b/drivers/usb/gadget/f_fs.c @@ -3019,7 +3019,8 @@ static void ffs_closed(struct ffs_data * ci = ffs_obj->opts->func_inst.group.cg_item.ci_parent->ci_parent; ffs_dev_unlock(); - unregister_gadget_item(ci); + if (test_bit(FFS_FL_BOUND, &ffs->flags)) + unregister_gadget_item(ci); return; done: ffs_dev_unlock();