Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp6548790pxu; Thu, 24 Dec 2020 05:31:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJxslfYd1O7VK4bHFzL65q21ex2zYcmA2tD+GBsxgvgztsbbsI5qP5oSgLzAXbSkYK1Tnokb X-Received: by 2002:a50:b905:: with SMTP id m5mr28078086ede.292.1608816682653; Thu, 24 Dec 2020 05:31:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608816682; cv=none; d=google.com; s=arc-20160816; b=zVGiGswhIOLSWNa/UW7f17nWzQdnraUNCp+RPI0LYw6fEby9t8VaFUzmujvlJvA1S5 OlDZwB3EdQflSAlxM6qTsCLIyjjjH54hl6cNETttiB9U209jTLltW+TFTyeNJXThQcik Fr8rSkzPkP6Db9QGm3mdISyjjw9f0nAQH9nMChOLFHQNTX6jkNnklBbd1RZcHDoT7og1 Dw8L7BEnCjObHKC+YhJ1YMM/BVY5qsdcD+Q9J1nAthB6mx6wwr3Er6tRVe+hkHWwklF7 /SjKuSIUQ12vtAzhvD/YFRP823RrDex5LdSHE6EdyiUwnaohhIFuHSWNlYOGNVJ2Np5y OZ6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=6NqQsoACU5cAy52+51rrJzNq5c9MDqVth5ZM0mIu/sA=; b=yILyjdPdqqARhaMvqLORwiq844G7ldf/L4yuK7nH2lWPPJztkk9rBXhhhW72XBqTCF KyrUISy6zoKCc5wgoJWJpGLWkrMr2DZb0ybI/YejP7AWmu+Y8BPuXEjgAqaVH993tMYm G+F1Zh0IJ4gi0DFfU1mLzwpCEwshO4DxEJ65r+X8sRERQNrKI/RiN7MAu2z0JI2hxT+w BV3+CXl8Shidd5Mo2Z4mEUfSFRKRky6GZhgunfrKTm5VVt4nqCtJmZjHk424IEuMQjhG 4ObmE0EeXU/bK7d7m3k61wXV7Zq17+gaFndYOv1PpXLPuPWgcuRzTUSHP3U7LQgoolHA UXPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CLNAfzVP; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y7si1006163edt.257.2020.12.24.05.31.00; Thu, 24 Dec 2020 05:31:22 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=CLNAfzVP; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728563AbgLXNa2 (ORCPT + 99 others); Thu, 24 Dec 2020 08:30:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:48724 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728266AbgLXNa1 (ORCPT ); Thu, 24 Dec 2020 08:30:27 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8E99C22210; Thu, 24 Dec 2020 13:29:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1608816586; bh=b+MKS0YXpwXIZAtxx6PxhWkrhKXzG0lI7tMEuHK6RXc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=CLNAfzVPcNm9yylAyq7f2p4xuiuWNOLmQl1aWMwbTXOwx8USG4Ezziv4dmh+g2QBr oukyHxwGfj7QGsA31s1RZC3iBN++1Du5Qj7tOyW66OWPaAhRqQ4k1ypNiUVxtbjyuO nF3ryeGnDe2WGp97bY1Iv7KBiLGawgyFy5fbGTHK8b72Wv0tqVPKqhg6FGNKiGUci+ Ihi2VSKrIJe0xcHWKRC1Y8J0RDmYgvzYwKSHIuAk0CBw06JhdJZ1dnpHMbOyv3iFCE KFuOJi/gtcn/CPCk66g7LOC164FFYAR7dVgCFx/R7OstkyUyISYy/c4xfCkTI0Vbqy gH9rGmkoUvD0Q== Received: by pali.im (Postfix) id 66F2C829; Thu, 24 Dec 2020 14:29:44 +0100 (CET) Date: Thu, 24 Dec 2020 14:29:44 +0100 From: Pali =?utf-8?B?Um9ow6Fy?= To: Peter Chen Cc: Mathias Nyman , Greg Kroah-Hartman , Gregory CLEMENT , Miquel Raynal , Tomasz Maciej Nowak , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] usb: host: xhci: mvebu: make USB 3.0 PHY optional for Armada 3720 Message-ID: <20201224132944.5odphwxtnzhvkeg7@pali> References: <20201223162403.10897-1-pali@kernel.org> <20201224055425.GA27629@b29397-desktop> <20201224125347.z2ka7itpxuvboghq@pali> <20201224132401.7inh5ae7aaqvooxe@pali> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20201224132401.7inh5ae7aaqvooxe@pali> User-Agent: NeoMutt/20180716 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thursday 24 December 2020 14:24:01 Pali Rohár wrote: > On Thursday 24 December 2020 13:15:21 Peter Chen wrote: > > > > > > > + /* Old bindings miss the PHY handle */ > > > > > + phy = of_phy_get(dev->of_node, "usb3-phy"); > > > > > + if (IS_ERR(phy) && PTR_ERR(phy) == -EPROBE_DEFER) > > > > > + return -EPROBE_DEFER; > > > > > > > > Doesn't need to judge IS_ERR(phy). > > > > > > Ok, I can remove it. I used same condition which is already in SATA and PCIe > > > phy code. > > > > > > > > + else if (IS_ERR(phy)) > > > > > + goto phy_out; > > > > > + > > > > > + ret = phy_init(phy); > > > > > + if (ret) > > > > > + goto phy_put; > > > > > + > > > > > + ret = phy_set_mode(phy, PHY_MODE_USB_HOST_SS); > > > > > + if (ret) > > > > > + goto phy_exit; > > > > > + > > > > > + ret = phy_power_on(phy); > > > > > + if (ret == -EOPNOTSUPP) { > > > > > + /* Skip initializatin of XHCI PHY when it is unsupported by > > > firmware */ > > > > > + dev_warn(dev, "PHY unsupported by firmware\n"); > > > > > + xhci->quirks |= XHCI_SKIP_PHY_INIT; > > > > > + } > > > > > + if (ret) > > > > > + goto phy_exit; > > > > > + > > > > > + phy_power_off(phy); > > > > > +phy_exit: > > > > > + phy_exit(phy); > > > > > +phy_put: > > > > > + of_phy_put(phy); > > > > > +phy_out: > > > > > + > > > > > > > > You do power on and off again only want to know if PHY has already > > > > powered at ATF, right? > > > > > > I need to know if power on/off procedure is supported by ATF. And if not > > > (indicated by -EOPNOTSUPP) then I need to ensure that usb hdc code would not > > > try to call phy_power_on() as it would cause failure as described in the commit > > > message. You can look at those other two commits for PCIe and SATA. Same > > > thing is needed for USB. > > > > If not supported by ATF, then where to power on and off PHY since no other place calls PHY APIs? Is it always on? > > Yes, in this case (when -EOPNOTSUPP is returned) SMC API is not > supported by ATF, and PHY is always on. To make it clear, core/hcd.c function usb_add_hcd() when hcd->skip_phy_initialization is false is calling usb_phy_roothub_power_on() which calls phy_power_on(). If this call fails then error is propagated back to the usb_add_hcd() and this function fails too. But on boards with older ATF (which do not support PHY power on SMC API) is phy_power_on() returning error -EOPNOTSUPP and therefore whole USB 3.0 initialization fails. This patch is adding init hook to detect if ATF supports PHY power on/off functions and in case it does not support it, code sets XHCI_SKIP_PHY_INIT flag to instruct xhci-plat code to set hcd->skip_phy_initialization flag to instruct core/hcd.c to skip calling usb_phy_roothub_power_on() function as it is know that it would fail.