From patchwork Tue Jan 9 07:00:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 123806 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3673995qgn; Mon, 8 Jan 2018 23:01:03 -0800 (PST) X-Google-Smtp-Source: ACJfBosulcNdR/eWk3wSETyyU7xxoCJBAZ7kYWTQRbkaAS3gmoW87hyn9Qty8RbXJ5vb/0ooTr4H X-Received: by 10.84.131.40 with SMTP id 37mr14617646pld.58.1515481263598; Mon, 08 Jan 2018 23:01:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515481263; cv=none; d=google.com; s=arc-20160816; b=ad/ixhPlJswxsGay8sJR01Nb8gn4ccmjxP890nE9/3gdQ8UsJteLBv3Aqlh9ahuiEk qt2IAiEFqyahHJ/aJeYVB6HuI+L0GRbg/18NUfvj6ivI0FLVn8ygQmzxSqx/9dLsfKBu 6m0zEFHC5TfFqKzCXF8oNbR314vDRjKEGBT6/elaS42bh0TNLbAA/zfWrfSc2D/dy/kR wLbrCCTiq0QoCeKuzA3EAk+RS0Xu6TiJ0FXV1h0wuqjSie5tYQ22HKE8uHPrhzboqM30 ipyl/+q2uPcs2rLHv+2IQVuKpOLl8vIcAeWDurr0w1+OwiURvTCMgA2u2mRw4q5bJsdl GGnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=ZOQ78Ucj0uCrwo5DrED2ApGocpuTOhFIqUqPb2UXXBs=; b=an6AChI7VBxjZL+TsTTedQc9hLhSJDv0kAGwIGjZNNDMCynzshXrITKvsXDc2rtmaW u09CVHz3PQmeV/lnojpEoaIRqbchVPfY8X3w4KszKZ2j+BKffXoH2TtyYm7fSUfOkKtu 7o2cGn2fBmxz2z40C5zr8Du1i2OBc3wmc9J0QKH1U1kpTbCAeszRFnMfRDrZCja7BYHR NgbrAhi/jlhFxazbcVe67yAdqb5+0h9PFl1uq3iP2tQMHhpLRUcmk0Ab20CIYLAj66oX QRVK2MA0SGVvmDy1H/HPKVOhrDUqql8NvHID6FRTp1jsEZXd+IjTj+fqPBE8S54M010S x84A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Tb67IbOY; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d3si10135995pln.700.2018.01.08.23.01.03; Mon, 08 Jan 2018 23:01:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Tb67IbOY; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753919AbeAIHBB (ORCPT + 3 others); Tue, 9 Jan 2018 02:01:01 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:44883 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751811AbeAIHBA (ORCPT ); Tue, 9 Jan 2018 02:01:00 -0500 Received: by mail-pf0-f193.google.com with SMTP id m26so7922734pfj.11 for ; Mon, 08 Jan 2018 23:00:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=K7CFHI3GMMfF2/MIzl2GmGVINnjIZDFlLJXJT5T7s54=; b=Tb67IbOYqPQxSnIxj4O5UsvcdnuKMUz3b+g+B201tj1zHwJxs/uUd3AhRS1Yc8RXdI L6dA9jXPugoYdx9hsUZWxWACodh/fQSYovfb9Zr2vTtJ0K0RZimMRy1QjVoSbpqwBlld EBu0cvsh/AiIioPuenYsb3v6qr1xwAJBUhA/c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=K7CFHI3GMMfF2/MIzl2GmGVINnjIZDFlLJXJT5T7s54=; b=AbFQUWXzCVjeefLcx4RuMSZW7LYU5wSfDMLMj5m2DJlHdKT3ahdfhLR4wPIQBoMgWS vXelAHMKpuxFaQTqaPj8X3rAaSzz3SiTKlrg3uN20rnZR3WcO/SILwY3e4lQ8fYmbEpg Tbnz/gkeWZp6b/4a4I03hKZHhUItHz3mDD6yg2C7X6HDJ33FwjEhnzt7/cOLHzK13Eha 1v7vMdLZBAEqmYAzFuKAGDIOnX+XKmKEt1gKz/1oP9gwxSUgehsDZbM9wsf9iQhAXsdR +CLKa/ETxgeOL1hi/5WVRol1HMOXtN7bT3pNDjHXGIYMSDUh/4F2chv+YSWN/oNgiwSq /q9Q== X-Gm-Message-State: AKGB3mLF5ANSogtDkmIbFooi0TQMDLdg5SXFQWWkfj0qTp4DxqY1qLFP gnuJ9dleM5TaZcE31Lg+e1ULHg== X-Received: by 10.99.165.80 with SMTP id r16mr10780542pgu.73.1515481259382; Mon, 08 Jan 2018 23:00:59 -0800 (PST) Received: from localhost.localdomain ([106.51.16.9]) by smtp.gmail.com with ESMTPSA id q69sm30644104pfa.161.2018.01.08.23.00.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 08 Jan 2018 23:00:58 -0800 (PST) From: Amit Pundir To: lkml , linux-usb@vger.kernel.org Cc: Hemant Kumar , Felipe Balbi , Greg KH , Michal Nazarewicz , John Stultz , Dmitry Shmidt , Badhri , Android Kernel Team , stable@vger.kernel.org Subject: [PATCH] usb: f_fs: Prevent gadget unbind if it is already unbound Date: Tue, 9 Jan 2018 12:30:53 +0530 Message-Id: <1515481253-10415-1-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Hemant Kumar 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 Cc: stable@vger.kernel.org Signed-off-by: Hemant Kumar [AmitP: Cherry-picked it from android-4.14 and updated the commit log] Signed-off-by: Amit Pundir --- drivers/usb/gadget/function/f_fs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index b6cf5ab5a0a1..f9bd351637cd 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -3700,7 +3700,8 @@ static void ffs_closed(struct ffs_data *ffs) ci = 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();