From patchwork Mon Oct 20 10:45:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 39038 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8F9A820C2D for ; Mon, 20 Oct 2014 10:46:06 +0000 (UTC) Received: by mail-wg0-f71.google.com with SMTP id y10sf2329820wgg.10 for ; Mon, 20 Oct 2014 03:46:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=hJSCk5+Sk760I5QobhAFYLMoMJakOVwC2xYvS+xP7EA=; b=UYhKwLTMjc6uNZmn/rqoTfQ/KLX70iwnC6Qy5jTefEE5HvO1kyXSXiVSHD5gDgAede rcfpbxeUF2pLmH9wK0uKJdjEX7FJWDCJ97kWy0K0aTIUJfmKKS6eIKyu8RLW+i+JRQZ/ jaXPgUwxfJFGYWuZVuFdp7N1Lhv7nUjTZUHhPHdJh9R+Dp+eTtw97Qwi41kUCVSTQqzT C0WUKKJNckNonXys3muGFHysPxtkBXj345zOGS7wbQucZZMEiOTRyIGgJYvh6KobW4Z5 wFwnJt35yst4KW3gsGwI9pBDJgr4KJ9RIymkFao5IGXxeOoZRVQ0vRnsGlc1+p1xOBx5 R72Q== X-Gm-Message-State: ALoCoQm7WR8AabUg9w83MUw7Q1vt1AQgjM1DhXRm+JQXSR8febFb0t9PMDPGV+8wN8zypj6k83v9 X-Received: by 10.180.36.176 with SMTP id r16mr2321825wij.7.1413801965734; Mon, 20 Oct 2014 03:46:05 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.21.193 with SMTP id x1ls459698lae.53.gmail; Mon, 20 Oct 2014 03:46:05 -0700 (PDT) X-Received: by 10.112.172.231 with SMTP id bf7mr1952204lbc.100.1413801965568; Mon, 20 Oct 2014 03:46:05 -0700 (PDT) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id qh5si13662779lbb.111.2014.10.20.03.46.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 20 Oct 2014 03:46:05 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by mail-la0-f46.google.com with SMTP id gi9so3631780lab.5 for ; Mon, 20 Oct 2014 03:46:05 -0700 (PDT) X-Received: by 10.112.189.10 with SMTP id ge10mr26216180lbc.23.1413801965413; Mon, 20 Oct 2014 03:46:05 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp278561lbz; Mon, 20 Oct 2014 03:46:04 -0700 (PDT) X-Received: by 10.70.38.232 with SMTP id j8mr26856174pdk.44.1413801963307; Mon, 20 Oct 2014 03:46:03 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id yk7si7470081pab.135.2014.10.20.03.46.02 for ; Mon, 20 Oct 2014 03:46:03 -0700 (PDT) Received-SPF: none (google.com: linux-usb-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753588AbaJTKqA (ORCPT + 3 others); Mon, 20 Oct 2014 06:46:00 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:54314 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753523AbaJTKp5 (ORCPT ); Mon, 20 Oct 2014 06:45:57 -0400 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NDQ00KWHOPAHP10@mailout1.w1.samsung.com>; Mon, 20 Oct 2014 11:48:46 +0100 (BST) X-AuditID: cbfec7f4-b7f6c6d00000120b-66-5444e7e096b9 Received: from eusync4.samsung.com ( [203.254.199.214]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 72.64.04619.0E7E4445; Mon, 20 Oct 2014 11:45:52 +0100 (BST) Received: from amdc1339.digital.local ([106.116.147.30]) by eusync4.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NDQ009U7OK7MS20@eusync4.samsung.com>; Mon, 20 Oct 2014 11:45:52 +0100 (BST) From: Marek Szyprowski To: linux-usb@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , Felipe Balbi , Kyungmin Park , Robert Baldyga , Paul Zimmerman , Krzysztof Kozlowski Subject: [PATCH v2 09/10] usb: dwc2/gadget: fix calls to phy control functions in suspend/resume code Date: Mon, 20 Oct 2014 12:45:39 +0200 Message-id: <1413801940-31086-10-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.2 In-reply-to: <1413801940-31086-1-git-send-email-m.szyprowski@samsung.com> References: <1413801940-31086-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrCJMWRmVeSWpSXmKPExsVy+t/xa7oPnruEGOyYJmhx8H69xesXhhZn m96wW8w4v4/JYtGyVmaLtUfusltsnzKdyeLB4Z3sDhwefVtWMXps2f+Z0eP4je1MHp83yQWw RHHZpKTmZJalFunbJXBlvNy1halgD0/F1f032RoYD3N1MXJySAiYSBzd/YsVwhaTuHBvPVsX IxeHkMBSRomV8++yQjh9TBJtz2Ywg1SxCRhKdL3tYgOxRQQcJJYsvQNmMwv8ZJSYPNUGxBYW SJfY8nQnE4jNIqAq0fZ6NiOIzSvgKfFpznsmiG1yEv9frgCzOYHib15MA6sREvCQ2LT8JcsE Rt4FjAyrGEVTS5MLipPScw31ihNzi0vz0vWS83M3MUJC6ssOxsXHrA4xCnAwKvHwCli6hAix JpYVV+YeYpTgYFYS4e2+DRTiTUmsrEotyo8vKs1JLT7EyMTBKdXAWDxl67FunYLohH1La1j3 RbXej3tz7arQvn6FhKSXMVr31+gddKu9Vrj2+UQupjDeUx6zfj8xf7D+yV+eFZqrt9gd6+T5 XMTXOddD4VvzGZ/tjD7V79j37nmrPVnCcMa8iQuniCtxT3+wqDGkPMdT9fPyU4wyIevyZL+y bXLNEX3KtG6hTpvmXiWW4oxEQy3mouJEAG+p7G0HAgAA Sender: linux-usb-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: m.szyprowski@samsung.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This patch moves calls to phy enable/disable out of spinlock protected blocks in device suspend/resume to fix incorrect caller context. Phy related functions must not be called from atomic context. To protect device internal state from a race during suspend, a call to s3c_hsotg_core_disconnect() is added under a spinlock, what prevents any further activity on the usb bus. Signed-off-by: Marek Szyprowski Acked-by: Paul Zimmerman --- drivers/usb/dwc2/gadget.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index e8ffc080e6c7..0d34cfc71bfb 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -3653,11 +3653,13 @@ static int s3c_hsotg_suspend(struct platform_device *pdev, pm_message_t state) hsotg->driver->driver.name); spin_lock_irqsave(&hsotg->lock, flags); + s3c_hsotg_core_disconnect(hsotg); s3c_hsotg_disconnect(hsotg); - s3c_hsotg_phy_disable(hsotg); hsotg->gadget.speed = USB_SPEED_UNKNOWN; spin_unlock_irqrestore(&hsotg->lock, flags); + s3c_hsotg_phy_disable(hsotg); + if (hsotg->driver) { int ep; for (ep = 0; ep < hsotg->num_of_eps; ep++) @@ -3686,8 +3688,9 @@ static int s3c_hsotg_resume(struct platform_device *pdev) hsotg->supplies); } - spin_lock_irqsave(&hsotg->lock, flags); s3c_hsotg_phy_enable(hsotg); + + spin_lock_irqsave(&hsotg->lock, flags); s3c_hsotg_core_init_disconnected(hsotg); s3c_hsotg_core_connect(hsotg); spin_unlock_irqrestore(&hsotg->lock, flags);