From patchwork Tue Jul 30 20:16:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 170112 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp3060392ile; Tue, 30 Jul 2019 13:16:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqxDJmLQogOkYCKSkHqS84SNFO8EeN1beIwgealvSNy5Zhw0OJO4FJCixxYK6lB/aTBq7t7h X-Received: by 2002:a62:174a:: with SMTP id 71mr44950196pfx.140.1564517805809; Tue, 30 Jul 2019 13:16:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564517805; cv=none; d=google.com; s=arc-20160816; b=GEmtX6nT2v7t3UM8uMmPFV0ZAVQhXxiBdVj3disqrw045/TbmIIgb538tXya+aNL3a jlSoh9CPUvEXP6Iv/IJWS6x5adXdDeQB8teGPC/1WqEy1e+epf8dIj17J2WQOdbJgalN 059dE4N8pePc9YhqT4oQcGYD0k/S/Bb/OCAAXM+IljDA9GrvAimtT5sJVswm88rYlpkf mR+gWxw86ApCS1r+k2bEubtPmUJPH1oJajCQxMo5Q5EN7DWMnTUV5d1M2YreANgKod6j 0POTNGzhswmOTJeHTCPAU9ZM+9/Efh5pHh1mS16Z7LmqQgjm+TMY/mz+CqKpcMcBd+OB IUbw== 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; bh=9hc+sJms2hXMGQNWN7WU1PS1ixx5relE2nk3BJfrfy4=; b=G1w31D2lrG1zXZTDn2IogFtSRMrDaONaFOfsYkkUdsFuyzZXHWqcJdffuehuXLU2zZ +CVX/a2YJY+cfHIOrGWpdHKSx4nxG/uaouGiA/R7aMSS5zHmESFwbJUzk8ZuZFOxVunn QmqiXeH/SS3Qmu7S1jtV7tQBwm7QOKnf7fTmDWjZaGuIB1AR1+3ra4tmUdQejZsd8J24 5leQZ8lZd7bBpjPa1tM6jiXCf8JE9YyqjpZKT1WS90HqoLxB76Xqw4Mi2guwM9lGEhWI PzhVLJ1wDfdpe75uz/3AtADE4rfyCPVlVhHayz8/44yLUgoq6VZ9irR6LsUzbteXs640 AymQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oFyOwQYt; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (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 v31si27788462pjb.22.2019.07.30.13.16.45; Tue, 30 Jul 2019 13:16:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oFyOwQYt; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728129AbfG3UQo (ORCPT + 14 others); Tue, 30 Jul 2019 16:16:44 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:41385 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725947AbfG3UQo (ORCPT ); Tue, 30 Jul 2019 16:16:44 -0400 Received: by mail-pf1-f194.google.com with SMTP id m30so30423229pff.8 for ; Tue, 30 Jul 2019 13:16:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=9hc+sJms2hXMGQNWN7WU1PS1ixx5relE2nk3BJfrfy4=; b=oFyOwQYtTR4ybI4vMkuOqL5ixzuVUrMh4y1OvgP/C0QjRpRdQNHKtR1iP0ITwY99HT 6HKap4jWMO+upU6ossYk8DQwUJc1BhpTpuDr5ym6WYmAFQUtYaCt6kN2eptv+J2dBPiy TZj4rggMnSgldDmqz0rzxOi6Nv3EyjfEdnSp0PUwqIqAN2GeAneMIgLkmJjnrSd7vWaP Uc874um1a3w87fmAD8lnWiayZ0ue3FIV4P/SdhyddJYv4v5gF7pv289YDK8uXphnG95w nnlxNLVfnAqJJdqMX5BispgRlKCtRUV5gmlVP9c6rL8O2NvcyD8nc55QnHCNvOXNnZW1 Ierw== 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=9hc+sJms2hXMGQNWN7WU1PS1ixx5relE2nk3BJfrfy4=; b=dih/FQyIEGifwmXY0WwHwsY1KlaQ8OeszwCWjB38+lWTEi4aqBtygIGoOmvfKaml6R WHEn1cgn4T8V3BODdDGjW3l+NedISeUWoJNy/508QoftYTPtU+gxMigDcBmwxGIl3vcp AxomVI0daF2yKwD6dIDguhw62jwksEeq0P0jOwp8mBub65jzSS9XxRiu/tv9uE174rfr qI3k9d574faLJ3ZCf618GmL2TIiPLQG+mcNZzgNE2wyquS/IBRDZADwAe9k4cAAzTRjN ouYHJ3GKot7m6l7qELpft3bkBu1jzus8Aubq5d0lDrndldh1OV6Y2TGlewh0/byL8I35 fzBA== X-Gm-Message-State: APjAAAWas50RmLRL3jbkh6eiK8VVKQUfGYQ2h1uw5ycLKkNvaL688RRV cewHkHtPC8dx4aDqlajxapdfQQ== X-Received: by 2002:a62:1750:: with SMTP id 77mr44045939pfx.172.1564517803827; Tue, 30 Jul 2019 13:16:43 -0700 (PDT) Received: from localhost.localdomain ([49.207.49.136]) by smtp.gmail.com with ESMTPSA id 135sm67603659pfb.137.2019.07.30.13.16.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 30 Jul 2019 13:16:42 -0700 (PDT) From: Amit Pundir To: Greg KH Cc: Stable , Minas Harutyunyan , Minas Harutyunyan , Felipe Balbi Subject: [PATCH for-4.19.y 1/3] usb: dwc2: Disable all EP's on disconnect Date: Wed, 31 Jul 2019 01:46:37 +0530 Message-Id: <1564517799-16880-1-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Minas Harutyunyan commit dccf1bad4be7eaa096c1f3697bd37883f9a08ecb upstream. Disabling all EP's allow to reset EP's to initial state. On disconnect disable all EP's instead of just killing all requests. Because of some platform didn't catch disconnect event, same stuff added to dwc2_hsotg_core_init_disconnected() function when USB reset detected on the bus. Changed from version 1: Changed lock acquire flow in dwc2_hsotg_ep_disable() function. Signed-off-by: Minas Harutyunyan Signed-off-by: Felipe Balbi Signed-off-by: Amit Pundir --- Cherry-picked from lede/openwrt tree https://git.lede-project.org/?p=source.git. Build tested for ARCH=arm64 + defconfig drivers/usb/dwc2/gadget.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) -- 2.7.4 diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 03614ef64ca4..ed79bdf6f56c 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -3107,6 +3107,8 @@ static void kill_all_requests(struct dwc2_hsotg *hsotg, dwc2_hsotg_txfifo_flush(hsotg, ep->fifo_index); } +static int dwc2_hsotg_ep_disable(struct usb_ep *ep); + /** * dwc2_hsotg_disconnect - disconnect service * @hsotg: The device state. @@ -3125,13 +3127,12 @@ void dwc2_hsotg_disconnect(struct dwc2_hsotg *hsotg) hsotg->connected = 0; hsotg->test_mode = 0; + /* all endpoints should be shutdown */ for (ep = 0; ep < hsotg->num_of_eps; ep++) { if (hsotg->eps_in[ep]) - kill_all_requests(hsotg, hsotg->eps_in[ep], - -ESHUTDOWN); + dwc2_hsotg_ep_disable(&hsotg->eps_in[ep]->ep); if (hsotg->eps_out[ep]) - kill_all_requests(hsotg, hsotg->eps_out[ep], - -ESHUTDOWN); + dwc2_hsotg_ep_disable(&hsotg->eps_out[ep]->ep); } call_gadget(hsotg, disconnect); @@ -3189,13 +3190,23 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg, u32 val; u32 usbcfg; u32 dcfg = 0; + int ep; /* Kill any ep0 requests as controller will be reinitialized */ kill_all_requests(hsotg, hsotg->eps_out[0], -ECONNRESET); - if (!is_usb_reset) + if (!is_usb_reset) { if (dwc2_core_reset(hsotg, true)) return; + } else { + /* all endpoints should be shutdown */ + for (ep = 1; ep < hsotg->num_of_eps; ep++) { + if (hsotg->eps_in[ep]) + dwc2_hsotg_ep_disable(&hsotg->eps_in[ep]->ep); + if (hsotg->eps_out[ep]) + dwc2_hsotg_ep_disable(&hsotg->eps_out[ep]->ep); + } + } /* * we must now enable ep0 ready for host detection and then @@ -3996,6 +4007,7 @@ static int dwc2_hsotg_ep_disable(struct usb_ep *ep) unsigned long flags; u32 epctrl_reg; u32 ctrl; + int locked; dev_dbg(hsotg->dev, "%s(ep %p)\n", __func__, ep); @@ -4011,7 +4023,9 @@ static int dwc2_hsotg_ep_disable(struct usb_ep *ep) epctrl_reg = dir_in ? DIEPCTL(index) : DOEPCTL(index); - spin_lock_irqsave(&hsotg->lock, flags); + locked = spin_is_locked(&hsotg->lock); + if (!locked) + spin_lock_irqsave(&hsotg->lock, flags); ctrl = dwc2_readl(hsotg, epctrl_reg); @@ -4035,7 +4049,9 @@ static int dwc2_hsotg_ep_disable(struct usb_ep *ep) hs_ep->fifo_index = 0; hs_ep->fifo_size = 0; - spin_unlock_irqrestore(&hsotg->lock, flags); + if (!locked) + spin_unlock_irqrestore(&hsotg->lock, flags); + return 0; } From patchwork Tue Jul 30 20:16:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 170113 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp3060427ile; Tue, 30 Jul 2019 13:16:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqyKDTjoamqsPlrBWiB9LUOPRcglVwOALkQjPfP52YBjMVsyp4bUTf77oG7DEm8RG4QezKUh X-Received: by 2002:a17:90a:cb01:: with SMTP id z1mr3835171pjt.93.1564517808241; Tue, 30 Jul 2019 13:16:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564517808; cv=none; d=google.com; s=arc-20160816; b=DOH05woQqYky5UGL0hRgCSiPIHuwK1w6CuxcPI7T5nbcYaSteQjQufm4Rd5oRVZpqZ fZDaLzD6wM3WKJJU3H1c6zVu3RCXeeBVrBWzhL8nim0FgliiIxZiy2wh68/3IaS5aFSx HZnj96fspUlTbwKLZM5p2mePnwqYWRPCsjobTlUW0nQiOVaEXhyQI8F+CmsM2UDY96P4 zby9XXZiWeMMh6LMyGUMODHKaPaOKKbH3i12Mc0F0PW/IUR77jx4VCtYXSjgO9dWSvV9 J49BWwA8d4ynaeRmu12IpmCQ/sOHdnQW/Sl5tQaTnT04tx1nArfdB9cmq2RRVxVE1bZb cSWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BeA/svtAIFW8HDV9tUYz5pgLvX8TrGYNMj5kwb+rqcE=; b=0b3neMh4JwBYWgqwWytbGbfM7+I6HE1kGdjTfMRj/hzu3MHOOdlbJNlMy5av2jKDpU BThUj3ti/4ZITeu6wBkAB+ogOMnD7aMe/uDhOlbB4cGsnJage3uP0vE1k00xuu3ONpwZ OuS9UO1GCYAcqFL5ajPuKBlUyAXDcFrvc2rBeRdh1vpeww98lm8Q2t/oTA4iVot7krRJ wCtkvSIgcdbWtWgazYwtwL3C45y97nsV6UT7nzdgcEtPMgpYcL86UKLupZDbTfwDKF3m ph2aCYdybrBRXWC1DFoFWIvRpg1d8b8Zu4nX3OM7KloYnptnnEkOoBGb8V0iRgfmsHqX AdMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="k/5uDoU+"; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (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 v31si27788462pjb.22.2019.07.30.13.16.48; Tue, 30 Jul 2019 13:16:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="k/5uDoU+"; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728140AbfG3UQr (ORCPT + 14 others); Tue, 30 Jul 2019 16:16:47 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:37178 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725947AbfG3UQr (ORCPT ); Tue, 30 Jul 2019 16:16:47 -0400 Received: by mail-pg1-f194.google.com with SMTP id i70so19888790pgd.4 for ; Tue, 30 Jul 2019 13:16:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BeA/svtAIFW8HDV9tUYz5pgLvX8TrGYNMj5kwb+rqcE=; b=k/5uDoU+a06aMoVqDSCbVpbcEi6eGjeSTKQ39j7yNqiQXZaBK2cZmzIyhyn4cdQy3O sPrc8MIasvPdgbP3sf4gie614PaC8WVhyTBZo0w8ZxXeSZMIl+CKLTiJO6/RBIycRJaC tb82SWrI980qCnHmIPpKHKuIhs3M2P2ZpjSDHDtpElOs3twZbVDMzDxn8UMClj1tstD6 7S1C9ZCRcC9bSLXcmW8oFepKXgJVXgMs2quS4VQ4cBG6XRhW2A2DWKOSdlJ/9ztOJ4KQ c5tlrlsGZrSz6l/v+CWX4BEGtiC78kESi+tZ1PBAm2cmBpSWBOf+lZT/GfU8oNBpUfAo JHaA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=BeA/svtAIFW8HDV9tUYz5pgLvX8TrGYNMj5kwb+rqcE=; b=pzoNdWBOBHNadS3tI9aalOP5Pf8UjnkxVCRzR5M5LX/UTHLakQI3cSqBfOOZPY/oEQ c/FXnX+Je4/54ljh6YjYmvXrDKIR7gTCJWCc4Ecbge6MU3Kc6c/ZVPT25UzgQ4t+8n0K IzlwKOKHQMqh8T88n9rhqNhrzDgfdDMlxP+vKL9Qrg9MXUFrt2uN8dqtkVgLL1PvAt+7 b0JF4UZmfO3+VqMfBW468l2axQyKS7oPB6/fG1BORUeuXTI0EplWEOeilG0z2kbsRzV9 NigT8JW6/t6f+qf/7yUH2sgufpUHtpCn7kdLCNIH6pFj1KXBc1RlXEfkHJf50wGSnkAG Cv1Q== X-Gm-Message-State: APjAAAWV27qN0krvca2EafovicpXJwa+zcg3s3k9YaIl8uUDUru5u/zO FTeSnUVH94EDEyhp4gik8QMmuq3y35E= X-Received: by 2002:a63:61c6:: with SMTP id v189mr103070806pgb.36.1564517806498; Tue, 30 Jul 2019 13:16:46 -0700 (PDT) Received: from localhost.localdomain ([49.207.49.136]) by smtp.gmail.com with ESMTPSA id 135sm67603659pfb.137.2019.07.30.13.16.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 30 Jul 2019 13:16:45 -0700 (PDT) From: Amit Pundir To: Greg KH Cc: Stable , Minas Harutyunyan , Minas Harutyunyan , Felipe Balbi Subject: [PATCH for-4.19.y 2/3] usb: dwc2: Fix disable all EP's on disconnect Date: Wed, 31 Jul 2019 01:46:38 +0530 Message-Id: <1564517799-16880-2-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1564517799-16880-1-git-send-email-amit.pundir@linaro.org> References: <1564517799-16880-1-git-send-email-amit.pundir@linaro.org> MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Minas Harutyunyan commit 4fe4f9fecc36956fd53c8edf96dd0c691ef98ff9 upstream. Disabling all EP's allow to reset EP's to initial state. Introduced new function dwc2_hsotg_ep_disable_lock() which before calling dwc2_hsotg_ep_disable() function acquire hsotg->lock and release on exiting. >From dwc2_hsotg_ep_disable() function removed acquiring hsotg->lock. In dwc2_hsotg_core_init_disconnected() function when USB reset interrupt asserted disabling all ep’s by dwc2_hsotg_ep_disable() function. This updates eliminating sparse imbalance warnings. Reverted changes in dwc2_hostg_disconnect() function. Introduced new function dwc2_hsotg_ep_disable_lock(). Changed dwc2_hsotg_ep_ops. Now disable point to dwc2_hsotg_ep_disable_lock() function. In functions dwc2_hsotg_udc_stop() and dwc2_hsotg_suspend() dwc2_hsotg_ep_disable() function replaced by dwc2_hsotg_ep_disable_lock() function. In dwc2_hsotg_ep_disable() function removed acquiring of hsotg->lock. Fixes: dccf1bad4be7 ("usb: dwc2: Disable all EP's on disconnect") Signed-off-by: Minas Harutyunyan Signed-off-by: Felipe Balbi Signed-off-by: Amit Pundir --- Cherry-picked from lede/openwrt tree https://git.lede-project.org/?p=source.git. Build tested for ARCH=arm64 + defconfig drivers/usb/dwc2/gadget.c | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) -- 2.7.4 diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index ed79bdf6f56c..3f68edde0f03 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -3107,8 +3107,6 @@ static void kill_all_requests(struct dwc2_hsotg *hsotg, dwc2_hsotg_txfifo_flush(hsotg, ep->fifo_index); } -static int dwc2_hsotg_ep_disable(struct usb_ep *ep); - /** * dwc2_hsotg_disconnect - disconnect service * @hsotg: The device state. @@ -3130,9 +3128,11 @@ void dwc2_hsotg_disconnect(struct dwc2_hsotg *hsotg) /* all endpoints should be shutdown */ for (ep = 0; ep < hsotg->num_of_eps; ep++) { if (hsotg->eps_in[ep]) - dwc2_hsotg_ep_disable(&hsotg->eps_in[ep]->ep); + kill_all_requests(hsotg, hsotg->eps_in[ep], + -ESHUTDOWN); if (hsotg->eps_out[ep]) - dwc2_hsotg_ep_disable(&hsotg->eps_out[ep]->ep); + kill_all_requests(hsotg, hsotg->eps_out[ep], + -ESHUTDOWN); } call_gadget(hsotg, disconnect); @@ -3176,6 +3176,7 @@ static void dwc2_hsotg_irq_fifoempty(struct dwc2_hsotg *hsotg, bool periodic) GINTSTS_PTXFEMP | \ GINTSTS_RXFLVL) +static int dwc2_hsotg_ep_disable(struct usb_ep *ep); /** * dwc2_hsotg_core_init - issue softreset to the core * @hsotg: The device state @@ -4004,10 +4005,8 @@ static int dwc2_hsotg_ep_disable(struct usb_ep *ep) struct dwc2_hsotg *hsotg = hs_ep->parent; int dir_in = hs_ep->dir_in; int index = hs_ep->index; - unsigned long flags; u32 epctrl_reg; u32 ctrl; - int locked; dev_dbg(hsotg->dev, "%s(ep %p)\n", __func__, ep); @@ -4023,10 +4022,6 @@ static int dwc2_hsotg_ep_disable(struct usb_ep *ep) epctrl_reg = dir_in ? DIEPCTL(index) : DOEPCTL(index); - locked = spin_is_locked(&hsotg->lock); - if (!locked) - spin_lock_irqsave(&hsotg->lock, flags); - ctrl = dwc2_readl(hsotg, epctrl_reg); if (ctrl & DXEPCTL_EPENA) @@ -4049,12 +4044,22 @@ static int dwc2_hsotg_ep_disable(struct usb_ep *ep) hs_ep->fifo_index = 0; hs_ep->fifo_size = 0; - if (!locked) - spin_unlock_irqrestore(&hsotg->lock, flags); - return 0; } +static int dwc2_hsotg_ep_disable_lock(struct usb_ep *ep) +{ + struct dwc2_hsotg_ep *hs_ep = our_ep(ep); + struct dwc2_hsotg *hsotg = hs_ep->parent; + unsigned long flags; + int ret; + + spin_lock_irqsave(&hsotg->lock, flags); + ret = dwc2_hsotg_ep_disable(ep); + spin_unlock_irqrestore(&hsotg->lock, flags); + return ret; +} + /** * on_list - check request is on the given endpoint * @ep: The endpoint to check. @@ -4202,7 +4207,7 @@ static int dwc2_hsotg_ep_sethalt_lock(struct usb_ep *ep, int value) static const struct usb_ep_ops dwc2_hsotg_ep_ops = { .enable = dwc2_hsotg_ep_enable, - .disable = dwc2_hsotg_ep_disable, + .disable = dwc2_hsotg_ep_disable_lock, .alloc_request = dwc2_hsotg_ep_alloc_request, .free_request = dwc2_hsotg_ep_free_request, .queue = dwc2_hsotg_ep_queue_lock, @@ -4342,9 +4347,9 @@ static int dwc2_hsotg_udc_stop(struct usb_gadget *gadget) /* all endpoints should be shutdown */ for (ep = 1; ep < hsotg->num_of_eps; ep++) { if (hsotg->eps_in[ep]) - dwc2_hsotg_ep_disable(&hsotg->eps_in[ep]->ep); + dwc2_hsotg_ep_disable_lock(&hsotg->eps_in[ep]->ep); if (hsotg->eps_out[ep]) - dwc2_hsotg_ep_disable(&hsotg->eps_out[ep]->ep); + dwc2_hsotg_ep_disable_lock(&hsotg->eps_out[ep]->ep); } spin_lock_irqsave(&hsotg->lock, flags); @@ -4792,9 +4797,9 @@ int dwc2_hsotg_suspend(struct dwc2_hsotg *hsotg) for (ep = 0; ep < hsotg->num_of_eps; ep++) { if (hsotg->eps_in[ep]) - dwc2_hsotg_ep_disable(&hsotg->eps_in[ep]->ep); + dwc2_hsotg_ep_disable_lock(&hsotg->eps_in[ep]->ep); if (hsotg->eps_out[ep]) - dwc2_hsotg_ep_disable(&hsotg->eps_out[ep]->ep); + dwc2_hsotg_ep_disable_lock(&hsotg->eps_out[ep]->ep); } } From patchwork Tue Jul 30 20:16:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 170114 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp3060465ile; Tue, 30 Jul 2019 13:16:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqzMjLQsAOUOg14E9SzDYZKxMYY7ZRkWbCzcqr98zqatXxa6kIXvuc/U+UesLuE7G0F3ewA9 X-Received: by 2002:a63:8dc9:: with SMTP id z192mr55635532pgd.151.1564517810515; Tue, 30 Jul 2019 13:16:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564517810; cv=none; d=google.com; s=arc-20160816; b=nVsAhHC8lK8Ws9lAHKcvtf4QD5Xqt7oJHgBPuqWE14P8aYngaZjaFzzbUk9gfxmYls asGN1c/Ybzk5bEEmPZGNUpIuTq4OJswvZuTeg6aOpZ5b/36JkKVPab4cp2Tt3WG7JyJd aqIV75WzikHBzvzgrFJAN83wU8S+vulkSPk/HECFhCpIglAHa73T5AmLn068zSsaDM1Z SnqiZAR8akrdFZYEE3nOR4mDF0OmvmXBKVTSRjX9KYxIgbTIxVbXMZ90oeEUWpPtu63m imEe5rwWE5sZjWNhGNTk1tvvIYcvoMPCCMhr6hRfvHqU//AutB5OpPj+eqEaqzFg0ckA Fj8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=MunFz2lTShwR26VZ4w2FwMukvVD2WiHHyR9u5VL0/FM=; b=utOU+VMItBJRN+wF1otlKqPMlJXhT2XsAiYemHCiB4Aj4V6cd6M3ydIKk8QolkB+A8 lDbGof2QEdSi7tL+YtjTAnpcbfCyaj5e+IRg38eJtgaUp250XHiLQ/N98b4UIoxPLWEg 2BBWofrVsKHX6aojkgP0klcKJ6OgeLrMgAukCYULN3BvS4jzcuADX92Pi2cb2SNQMiw+ btfyHVtMtJIaPxknUlL4fgzeqrc3D1GQPHAYTZSNhIRwt9P4UMHLaGwnWCIhMWB4aO7o KBhmi/ZILu102FrI6pjq5SSf2sHwi39JyLlBF9GA7hng3UnKoILwz7AIRuAQc7ttlD9c eO8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O0sgUBMm; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (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 v31si27788462pjb.22.2019.07.30.13.16.50; Tue, 30 Jul 2019 13:16:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O0sgUBMm; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725947AbfG3UQu (ORCPT + 14 others); Tue, 30 Jul 2019 16:16:50 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:45761 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387406AbfG3UQt (ORCPT ); Tue, 30 Jul 2019 16:16:49 -0400 Received: by mail-pf1-f195.google.com with SMTP id r1so30405583pfq.12 for ; Tue, 30 Jul 2019 13:16:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MunFz2lTShwR26VZ4w2FwMukvVD2WiHHyR9u5VL0/FM=; b=O0sgUBMmEVpuYzSdIhpoJHYNdPFG1Wy1qJ37KN+PwiFAJmdOsuuYvjImrBg5oRDGzg v1fRzWZc7wQSkFwkmQ04Wmmm3cTUnZFJMS0YAzSShidmCBhlBth2BEYbVq2r03h4g2of EPQkmhkEpqq5AB4lycKJmHq8JtWO/NmRnMBBVKDFYRJr7ezH/yBqYidFXwHiC631ArCG OkGHhQnum43cky9PAUD5NS7e4Rtt8JIqP0qSO7U/PZ2xqGNjCGXqzesoK5LfhSVBhxJd tAnm4ETsjj7Es9dfA9vHolHfhwQ+0kyNqD4xm6yrwMcjJDKmMMjMU+XCm6iRYV58JqTi Eelw== 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:in-reply-to :references; bh=MunFz2lTShwR26VZ4w2FwMukvVD2WiHHyR9u5VL0/FM=; b=AnGg82aLQOTDlDLzCcBE51RWZaBodoPfB2CQM2Uo5Xx0al0wtB1wivOVi/VZ0rl8g/ 8+eE7HPjK5aeNXF0YjBKkNGnAn9psoP22CRamHpOycbCsV60n8BkifVMZIy2zY+xcHtj EcbeaZ3iutNsSrHMiU8UQQxh17hLX1ESyUZzgROyiNdB8ZE3Qqt/SbPAEy/sG5iQnHZx Ka80Un5Noc8Lij2d3FU57bZW00RBw1kSM9+VgOlZtHGZDmxsGMJXpbQGGF3bvpEqUCs9 qQNZWZjWIXD64XgS3LZanIGFOtH1bi6JnKKHBGvmeK1flqz9sejFIkqJdHZ9stMP45+i mG5Q== X-Gm-Message-State: APjAAAUFTBq71RaCnCYQUijafs5yApMmJdoPLfOn7j8h/eERwxs6x1DB I0LwGbnVra+nXZLPrM/kRFW71g== X-Received: by 2002:a63:f807:: with SMTP id n7mr114040472pgh.119.1564517808943; Tue, 30 Jul 2019 13:16:48 -0700 (PDT) Received: from localhost.localdomain ([49.207.49.136]) by smtp.gmail.com with ESMTPSA id 135sm67603659pfb.137.2019.07.30.13.16.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 30 Jul 2019 13:16:48 -0700 (PDT) From: Amit Pundir To: Greg KH Cc: Stable , Christian Lamparter , Michael Ellerman Subject: [PATCH for-4.19.y 3/3] powerpc/4xx/uic: clear pending interrupt after irq type/pol change Date: Wed, 31 Jul 2019 01:46:39 +0530 Message-Id: <1564517799-16880-3-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1564517799-16880-1-git-send-email-amit.pundir@linaro.org> References: <1564517799-16880-1-git-send-email-amit.pundir@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Christian Lamparter commit 3ab3a0689e74e6aa5b41360bc18861040ddef5b1 upstream. When testing out gpio-keys with a button, a spurious interrupt (and therefore a key press or release event) gets triggered as soon as the driver enables the irq line for the first time. This patch clears any potential bogus generated interrupt that was caused by the switching of the associated irq's type and polarity. Signed-off-by: Christian Lamparter Signed-off-by: Michael Ellerman Signed-off-by: Amit Pundir --- Cherry-picked from lede/openwrt tree https://git.lede-project.org/?p=source.git. To be picked up for 4.14.y as well. arch/powerpc/platforms/4xx/uic.c | 1 + 1 file changed, 1 insertion(+) -- 2.7.4 diff --git a/arch/powerpc/platforms/4xx/uic.c b/arch/powerpc/platforms/4xx/uic.c index 8b4dd0da0839..9e27cfe27026 100644 --- a/arch/powerpc/platforms/4xx/uic.c +++ b/arch/powerpc/platforms/4xx/uic.c @@ -158,6 +158,7 @@ static int uic_set_irq_type(struct irq_data *d, unsigned int flow_type) mtdcr(uic->dcrbase + UIC_PR, pr); mtdcr(uic->dcrbase + UIC_TR, tr); + mtdcr(uic->dcrbase + UIC_SR, ~mask); raw_spin_unlock_irqrestore(&uic->lock, flags);