From patchwork Wed Apr 26 11:50:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 9701267 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9FD50603F4 for ; Wed, 26 Apr 2017 11:52:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8DEAC2793A for ; Wed, 26 Apr 2017 11:52:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 82AC628468; Wed, 26 Apr 2017 11:52:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED9B3284D2 for ; Wed, 26 Apr 2017 11:52:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1949847AbdDZLwh (ORCPT ); Wed, 26 Apr 2017 07:52:37 -0400 Received: from relmlor1.renesas.com ([210.160.252.171]:39490 "EHLO relmlie4.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1949402AbdDZLwf (ORCPT ); Wed, 26 Apr 2017 07:52:35 -0400 Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie4.idc.renesas.com with ESMTP; 26 Apr 2017 20:52:33 +0900 Received: from relmlii1.idc.renesas.com (relmlii1.idc.renesas.com [10.200.68.65]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id 4FDD26E8A7; Wed, 26 Apr 2017 20:52:33 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.37,254,1488812400"; d="scan'208";a="240959728" Received: from mail-hk2apc01lp0210.outbound.protection.outlook.com (HELO APC01-HK2-obe.outbound.protection.outlook.com) ([65.55.88.210]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA256; 26 Apr 2017 20:52:32 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesasgroup.onmicrosoft.com; s=selector1-renesas-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=3YEMRK/nEojtahzmXPRXKxlFyet4WhWH7VJlpfWgiuk=; b=WEeRdFJsU7fIKonxWRyVmMfUOJY62lE7jPeSA5P5/X5XzfGh5s3XCpf7U4uxBL7O5U4oHrzdzMEwY6H3yk68azN7kXWe97nBo70ztgat01bYpzN+i1rxKzPeEhMti6NNkWU9DoC2Z3Sj1bdDJk02UDSoav0SI5sBgPYy6zQ3EM4= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=renesas.com; Received: from localhost.localdomain (211.11.155.144) by HK2PR06MB1683.apcprd06.prod.outlook.com (10.167.73.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1061.12; Wed, 26 Apr 2017 11:52:31 +0000 From: Yoshihiro Shimoda To: CC: , , , Yoshihiro Shimoda Subject: [PATCH 1/5] usb: gadget: udc: renesas_usb3: fix pm_runtime functions calling Date: Wed, 26 Apr 2017 20:50:07 +0900 Message-ID: <1493207411-24416-2-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1493207411-24416-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> References: <1493207411-24416-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> MIME-Version: 1.0 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: OS2PR01CA0039.jpnprd01.prod.outlook.com (10.164.161.149) To HK2PR06MB1683.apcprd06.prod.outlook.com (10.167.73.9) X-MS-Office365-Filtering-Correlation-Id: 68b70bd9-176c-4598-076d-08d48c9ab8b2 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(201703131423075)(201703031133081); SRVR:HK2PR06MB1683; X-Microsoft-Exchange-Diagnostics: 1; HK2PR06MB1683; 3:mZjTQfWFZnwlklHdtys1/dlZX9jNnDYD88wi77QJSNHf0+xzbkmEGBuxBrmugEuuywIwUx1FoGPu6blVJgTgHCjfs4W6YmTRuW5nvd7QElnEbmeBb6ZlDb14W99c7q2HJNbTXOrmqmBWnKW2uqvVv3JCLNxZX02U4Ah+LkEEtMZy0ksR4obmuPm4RdQrcpADyEP9FULmrwg3mDrKlkbQjpoQBBsoTR8Su9WjXiUeoYJEV2PMoPTnFO70/YKK+aJdKsgpd107u8BVRCi5gdr5AZkSJQGxYVelbSyNlshvbUCOHYnk8Aez680OKBM+am+KsrK6LUS5eKV7pxU3vDI6SoGM5Wo165/O3Gx7wDfdMIk=; 25:2JfT+4E3o7sjzg0cbiC3r585KUFOS5MtrP1oEeg6bBnNi4I387HerTAwjIo/HDi7ivmOfrcjZlMK6rpPC08xpKel6DwJEBKDLjdg5rgCG1ztajpSSvNxitopR0NbWcdz1c7Bhl1GLj5WUttZO09Ckv/9V3KTfMlGFDH1fNG8rul7Hm2eLZbwmjbV/LAC8zd4ygDtKlYEK9aFBsoCKaYsQqjeFpDbcZjwtaU0eXH+PSxOlVJ9+lL++Pq//qTdPPwtzdjG/H1Ttj+etRTFtNMTxepvrgawnbY+Nu8/9hFFY8G13G2GwPoLi9Hmn4jKGU107maO7GShQKYI4IYCNmYHD35CzPOMn8SDdaOroWlCejsX+vvSF5cl/uyDeQBjgkPjWlry/F8iqmEONRbzIw+tFtPLHJ0mXoXWolQ1Uxl9ZRV56rp/xy/qO671TXHxLbgP/uGy6TiaMEODgPsy5AlA/A== X-Microsoft-Exchange-Diagnostics: 1; HK2PR06MB1683; 31:05ezQtOoB3eGMqMYy30LMEQa4qSSYEZ4Yq74Q1ogCK7AFksLyMtfV33xA6tiAjm+x+GNCz2zPAUGdPzT28gYAcxf+JJUlB1iMnUteSvoQG4CybOLdxqHAn2eZj92PmldaMR/IfvEJ8nobAlZFqBScQwKWyaoaC4H3IJveYVBTKRodadkDhfFKaTlyxH9sGljMKK4gFwPwF+zo7Mgr5nEv5W3kyvMyuz/Oozaj4hL7fuhS4ujDwPoCTXnpBBAY2py; 20:chJWmq0VDIcON+D9scOkATRawlguJgagucwRT5uAPYltsMisEPHZK01Om1dwPykQLkLl5q63pSohH1JP3Y0yt++/TsjUOopUn0waLCvUeo9bf5Fa+1aTu8WiVXR2VVZjavyy83G1e3hqolCNqM7tmQug1BMI0cFWKN8pDXLA2Nu6R1ArSYvrSEY3MBtASK3XG2Hk/ZaknvqI43C2PyOO6Y+sHoNhc451DAZjS8FIR2PdMnyPTqltYomw/SAUGlKQu+UW5Y4hxuY/l4+6jwuX5ZZUk4cs/b2Y5cZMQQmtvp0thU6mp4EAwQoZo5yYlUnOCDJmb9J1l0ImgFXNRdM1Odj8eVtbjx4GdS1ZBV4gFY15AbhWBVmgRVmY07qAz5QNRysOGo28Ynn5kwtMj14P1ZfgtdrkReqrqGGweHkw3R2PGwcLAtQUsSEuNI2FoEksqFXjmvlopHx0bjk1tIhJ1bMxspvrfE3AuZNFm6k1GD+uy8e1AV46+tIw4V6D5E0a X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(6055026)(6041248)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061750153)(20161123558100)(20161123562025)(20161123564025)(20161123555025)(6072148); SRVR:HK2PR06MB1683; BCL:0; PCL:0; RULEID:; SRVR:HK2PR06MB1683; X-Microsoft-Exchange-Diagnostics: 1; HK2PR06MB1683; 4:JOwhZiJoP5yf4Sm6V8qynKKC1NRShEQyc/lchs5iRynrpDqUlA7Paaevh0g4WW/XPP96ModIeZZ6KPtVveVcg+Jdb6BKv+vVt75bS7a+lKICcbJP59Xklxjljr08VLruZhQCts247IjQqqtywWDdf9bdKegKSIQPClFglWjTxKi3IZ4chUQtfDnhjw2d4qq0ccNbGYNc05HZiaCIl9Rv+zJX1ujU3i1b41ufzEC5PP2VZ7x6+Ngv3sy1s0JAdqyznJtqVhPFrip9BGwrNhoBunxJ6a9d+HbR5ONl7kEE6rv3xqxX5VILoMeKrDTn1LF3aqytevllyqR43Jif2/niN4dDHMzTUYwFt3+LJp0tfB9cVO2KTuMflwDmoDwwo80Aaaa8p72t1ARWaZeBncM/3MaCMUoQNQOFXBfGyATPUtZZMVbn7BE0a0xUvZNGRhPapi1vZgCA4uZPogGnlRWF1JaoW5K2UtUGrDznOJfQy3kXuioSOv2mPMhb1MjQeVbCy3WnWJC84ZReX1ncuWTw/JeR9qWBEtnVBc8rt+uT1LV3SVIDW5sHBcRdfa7EB1Tq35KLjq9GVbmn045NJYeSTUsHAGukY11g52UJ2lRyQLMGsfQdWv5vBggBLBQarr/rGd5J0TcyNEPZdv4oTNr8VAAE9re3hiIqYAm5sZRvGagnhN7A1co8h9tYblt9j+8ejumAmIto9gq65UFCqq+foVzB3+5lWKhxCGWlto+1iwYvZkjBFik2My998Ltksby1Pmq6H03T0KxADiLYiw23umTlMEyz3nKfJkqod1mlZqA= X-Forefront-PRVS: 0289B6431E X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(6069001)(39850400002)(39450400003)(39860400002)(39410400002)(39400400002)(39840400002)(54906002)(6512007)(53936002)(189998001)(42186005)(2351001)(2906002)(38730400002)(50986999)(76176999)(33646002)(66066001)(6506006)(6486002)(6666003)(107886003)(2950100002)(6916009)(42882006)(110136004)(4326008)(47776003)(25786009)(36756003)(78352004)(5003940100001)(5660300001)(305945005)(7736002)(3846002)(6116002)(50466002)(8676002)(81166006)(50226002)(48376002); DIR:OUT; SFP:1102; SCL:1; SRVR:HK2PR06MB1683; H:localhost.localdomain; FPR:; SPF:None; MLV:ovrnspm; PTR:InfoNoRecords; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HK2PR06MB1683; 23:56LlTI+2xgZ3c6GPm27JpOkFDaYlw0fkh10oB2zy5?= =?us-ascii?Q?KGlqKrupVPCjqYIp1lmAINki32ISepfL3IQhiwYmThOxFy7fxjaBzp7q5NDy?= =?us-ascii?Q?Z+RvmNtp7uaV27lCjQXxJTHSSVdJQMy5wwTawmOiV1MRdN6a2DvkhVvIDQ+4?= =?us-ascii?Q?pHd0O9Ig9JgSEXkk6u48yHxvDAb8Tyx1NiBPZjtWCQItZdCgyRsmy3vqIALM?= =?us-ascii?Q?4lhqoT065yzpCiwl9gQh27c0whcDgrTjoUlEQbk8qfZjmQYoHKHM0v1X5BSI?= =?us-ascii?Q?bjwn9nJaySG8NUfmCb/+Z62EpmqvFM3wWS5ZGxjIQBnms5NBPciWCq//O8GA?= =?us-ascii?Q?E3F/r+akm89BZJe1HQ5pu3F5sqwVODHdP35nD68h1hYEyBOGC2GfrNuqKTHi?= =?us-ascii?Q?ZPLYj0z0EDfUGBaKAYaXAJnV66wJzOYFWSL+HH2zXs1Fd1Fy1BtYvwpBFlTv?= =?us-ascii?Q?cw7MU8zB6cXI5g6YdDezEW0Dg3UAHxOGXCnJWOPmdKyID/bdAINRt7dONb9+?= =?us-ascii?Q?n3bpOZFJPP7Cdn/614DoESo94agA16Hvsm8nLoI2d+2gSJTTzo1tbp6npwFZ?= =?us-ascii?Q?4CLb74Eoa1F+hD68blLJF54uIM7NKF3zLxOhTU73h1EAdcECrwBS0uT85nJ7?= =?us-ascii?Q?BqnZUum3pIXEZu0Z91+dEiKIgli7JbFbdAcqmM1xz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33IXvz6WK5MdfAUd9xhjWjmOIT3Ujax+ZGewDs2C54D4hZlVNTQdBrSN9CSWVGx9B+O441Duj3MRPsR8r3VTGM9tBQJB5TlOG1CMljtRzOqIu7NrFCntlztwsWPSlMkw==; 5:XQkjuPls6Ub01rGQQ8ap90oyBnN3ny1+uAJBOB2vjXLmB8at0RWnPZF+K8S7a277t+TKLD6/zEt3yQJJxxa2xi31holl7m/xbkMx55Nr95hq+gnVVCaDwin8YQa/pZ5zaaVmtpArIJIoLkxDFNpiyg==; 24:RoIOdaIhitxL02Uo9kL05Nxhu663YcYE6AQhjemYMWRF8x50v13rYn30bCJM/BGTx3iozG8z5Ke8rZ+1Bq/9A7QlIaR20r+T6wvBu0m5/Ts= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HK2PR06MB1683; 7:3Dtrv8UaPQJCdqeksbMWSJDCGWFIg/WE7kanuIFnnnZtxW3nT3Oli/WUF3qQ+1cAA4GBdnEDI159fKODnumKqcQ2LFeNncbF7wtBmvEqfSnrWP6hfiKtbmxwWzHydcjw0qm45jfT1pV6xsp/reQ8/SsT0t4kzJVCelgKSlvCTCEmnBhpg9oNym5jx6r8J/inEqOLAWqOWIDWl5nzMj0ePkh3x23fDe1NzOPFqGcCHZB3MlIvuRm9/O3CUCBcJ39Gje6HIsE0ikAaBrDsA5jIK21q1KoK9A0KLn0bfjfyCKABxFTFcbBBnmWonirZfzhCX8/ilhAyBdjTWg9zHkmTfw==; 20:bO8EMQDNfUZpTr7orWpdvWeZIpaM9B9/TP/kGzckwD8VoG+DO4tdIOiZme5RgpbZ2vJnL7pTBW/6X0fMubZF7KA3/1bl745Pozo4fbpOFWs0AP+nZWKCndNZf0UJWFDS4ATaBwyh8bCgKvfx12MZtE+K7nCCMkj5vOMWUy7UKwo= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2017 11:52:31.2297 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HK2PR06MB1683 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch fixes an issue that this driver is possible to access the registers before pm_runtime_get_sync() if a gadget driver is installed first. After that, oops happens on R-Car Gen3 environment. To avoid it, this patch changes the pm_runtime call timing from probe/remove to udc_start/udc_stop. Fixes: 746bfe63bba3 ("usb: gadget: renesas_usb3: add support for Renesas USB3.0 peripheral controller") Signed-off-by: Yoshihiro Shimoda --- drivers/usb/gadget/udc/renesas_usb3.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c index 5a2d845..10585da 100644 --- a/drivers/usb/gadget/udc/renesas_usb3.c +++ b/drivers/usb/gadget/udc/renesas_usb3.c @@ -1799,6 +1799,9 @@ static int renesas_usb3_start(struct usb_gadget *gadget, /* hook up the driver */ usb3->driver = driver; + pm_runtime_enable(usb3_to_dev(usb3)); + pm_runtime_get_sync(usb3_to_dev(usb3)); + renesas_usb3_init_controller(usb3); return 0; @@ -1816,6 +1819,9 @@ static int renesas_usb3_stop(struct usb_gadget *gadget) renesas_usb3_stop_controller(usb3); spin_unlock_irqrestore(&usb3->lock, flags); + pm_runtime_put(usb3_to_dev(usb3)); + pm_runtime_disable(usb3_to_dev(usb3)); + return 0; } @@ -1891,9 +1897,6 @@ static int renesas_usb3_remove(struct platform_device *pdev) device_remove_file(&pdev->dev, &dev_attr_role); - pm_runtime_put(&pdev->dev); - pm_runtime_disable(&pdev->dev); - usb_del_gadget_udc(&usb3->gadget); __renesas_usb3_ep_free_request(usb3->ep0_req); @@ -2099,9 +2102,6 @@ static int renesas_usb3_probe(struct platform_device *pdev) usb3->workaround_for_vbus = priv->workaround_for_vbus; - pm_runtime_enable(&pdev->dev); - pm_runtime_get_sync(&pdev->dev); - dev_info(&pdev->dev, "probed\n"); return 0;