Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp616911pxb; Thu, 15 Apr 2021 02:27:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxj0DhUiNbPkZpLgTA+OqEIgNaFsLtoHIcKrr2WwMVssYj9aXjaob8A9GHevZpSZckbVwuO X-Received: by 2002:a17:907:1b06:: with SMTP id mp6mr2494136ejc.292.1618478876128; Thu, 15 Apr 2021 02:27:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618478876; cv=none; d=google.com; s=arc-20160816; b=YweyJZX4BzkFZsYB9V6oaFXSs605q+BkrGBZDPWyUojzLAC4QsO/z3Z5APg7yUTIRb 3vu1c0lETAGXIXlS6h5XbPOPFXwJjRgAg4cgB8E6a5AHG0W1a0hjbq/KSS4TdgES/p2O dZoSO9Gkjg6lBV/TcCVLcU3Eq/Opg+4vY/p/E2zZK2i18eMWshyDoAFCK/hmtcnmdfPU GaRTrAaxPEvM6q8CR4Kg5CvrWxr2knYyz3PZUdOzPhEn3lfSaCkdulDe9IyE+vmwVYkY zf1CZjejzWasi1v+TuQYYct+SFqycMWL1OquaglCdBnSjqXCuAyt+8nP/Uks/9RhffBj /XQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject:dkim-signature; bh=F1DJ0GzmXw8sKDsrZ52paH//XCluIfnFmXR68ddtBX0=; b=Z8dVU9S3Ayg650BR0e/Zy23EMKxJa5g//dkZu8XNCBbMnOelUJKoQPfCbEV6Oc/xXs QhfgH16tG9RTj5NoWksjuLRIN67rQTImXaYwq4L+ExGSK6khF9yjqRtDhyPvzisuvZ3h +NBaOXhJP42cK/GF8znJ+jCxL1c4xIx1AuBfhaGQpptZxlSo18ckPTW7+EJUA3HQzHX/ f0jgYMHY1TakrpXP23NAo/N79IN/AkqqikUNYYZpgYfj960q5x2G5Pfd7SnCW7GWAQjN LUr7oiQAagkAZgqhQmNOBeI5OeSOFVxmUswZbMmT0pWPmnjkoc59gly3jFQEreCZ02nk /qrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vDoOc5lS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j22si1865741eds.145.2021.04.15.02.27.32; Thu, 15 Apr 2021 02:27:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vDoOc5lS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230474AbhDOJYz (ORCPT + 99 others); Thu, 15 Apr 2021 05:24:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229820AbhDOJYy (ORCPT ); Thu, 15 Apr 2021 05:24:54 -0400 Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79A81C061574; Thu, 15 Apr 2021 02:24:29 -0700 (PDT) Received: by mail-lj1-x232.google.com with SMTP id o16so26332053ljp.3; Thu, 15 Apr 2021 02:24:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:organization:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=F1DJ0GzmXw8sKDsrZ52paH//XCluIfnFmXR68ddtBX0=; b=vDoOc5lSA9j5NNrK/w7l0gAncecdDu6kyst7n8cezjygFmOw3ppcWTe6fFeSvLIhHx Hq37KSYwg01SjWERH8E9gRuVGgmHE5uWFm8WX4PxCdEYOV1KJP4RVT6NE/WoEiw+Vmk0 dVRWiTAojRv5aLptzU0J5UkPwdwzt2oI1AjPNu1PENyV6nrcvoDttDiRNqaBGH7fZNF7 n5q4yQiRgwVrx2TD77FGuakRcWDNVMQoLgwbcynK5LdUXiQTvatbrEHp1wWjP4yqszcs mwwM8W6BPmZVhPbZFtiAb54wq+aE/HpK1u5eDYBDtsDuZ0Gdl47G85scyaR2n/p1ZkLU uPeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=F1DJ0GzmXw8sKDsrZ52paH//XCluIfnFmXR68ddtBX0=; b=mcKG6UyLvwx4G5vWzO1eZi+dhuMeGGuegPYQ23zJPEZLkSaJG2Y9wbVkbj2+L0IDnL CBf9IMVCpYrLmmt7O1+zFk+kCnwvnehDJ2Y+GZWnqhwzchqAroXW4tS49abQGdNGgF4O kWSRymnMEEJLJSRyclDbFRX8ULDGBRpTWl3Sw3QV/bks6TXn3BEUnbf5EcSsGL/ZwZ81 jzW/DvlUpUbB89YrKEh0Glgi4vo8rqxNxjn59EVeKT/JQCRTf6BH0587A2Z1JizjejQT jWvdymRbbNXxVjD95Z8414sl7Gg7SiqHFtnAbjOeIbtR4c/+guCn7u/Eb/NOotKJzoVw +9/g== X-Gm-Message-State: AOAM531v1QnjqjmYc97oF4PleU4A5zy0sYYSNn5Eyl5zady210KccCMV 10C9oxdB1MabIta+vl3AuWSWXFpDwTQ= X-Received: by 2002:a05:651c:1306:: with SMTP id u6mr1275592lja.197.1618478667878; Thu, 15 Apr 2021 02:24:27 -0700 (PDT) Received: from [192.168.1.100] ([31.173.84.170]) by smtp.gmail.com with ESMTPSA id q19sm584577lfu.258.2021.04.15.02.24.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Apr 2021 02:24:27 -0700 (PDT) Subject: Re: [PATCH 13/15] usb: dwc2: Add exit hibernation mode before removing drive To: Artur Petrosyan , Felipe Balbi , Greg Kroah-Hartman , Minas Harutyunyan , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: John Youn References: From: Sergei Shtylyov Organization: Brain-dead Software Message-ID: <6e51ca4c-b479-5ccb-59bd-a767db7118ec@gmail.com> Date: Thu, 15 Apr 2021 12:24:19 +0300 User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 15.04.2021 8:41, Artur Petrosyan wrote: > When dwc2 core is in hibernation mode loading > driver again causes driver fail. Because in > that mode registers are not accessible. > > In order to exit from hibernation checking > dwc2 core power saving state in "dwc2_driver_remove()" > function. If core is in hibernation, then checking the > operational mode of the driver. To check whether dwc2 core > is operating in host mode or device mode there is one way > which is retrieving the backup value of "gotgctl" and compare > the "CurMod" value. If previously core entered hibernation > in host mode then the exit is performed for host if not then > exit is performed for device mode. The introduced checking > is because in hibernation state all registers are not > accessible. > > Signed-off-by: Artur Petrosyan > --- > drivers/usb/dwc2/platform.c | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c > index f8b819cfa80e..2ae4748ed5ec 100644 > --- a/drivers/usb/dwc2/platform.c > +++ b/drivers/usb/dwc2/platform.c > @@ -316,8 +316,24 @@ static int dwc2_lowlevel_hw_init(struct dwc2_hsotg *hsotg) > static int dwc2_driver_remove(struct platform_device *dev) > { > struct dwc2_hsotg *hsotg = platform_get_drvdata(dev); > + struct dwc2_gregs_backup *gr; > int ret = 0; > > + /* Exit Hibernation when driver is removed. */ > + if (hsotg->hibernated) { > + if (gr->gotgctl & GOTGCTL_CURMODE_HOST) { > + ret = dwc2_exit_hibernation(hsotg, 0, 0, 1); > + if (ret) > + dev_err(hsotg->dev, > + "exit hibernation failed.\n"); > + } else { > + ret = dwc2_exit_hibernation(hsotg, 0, 0, 0); > + if (ret) > + dev_err(hsotg->dev, > + "exit hibernation failed.\n"); Again, why duplicate the innermost *if*? > + } > + } > + > /* Exit Partial Power Down when driver is removed. */ > if (hsotg->in_ppd) { > ret = dwc2_exit_partial_power_down(hsotg, 0, true); MBR, Sergei