Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5933617ybi; Wed, 12 Jun 2019 10:57:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqzYTBrG1AKtSURyQ2ck+OGH/6jKsoORsVtFQQiWcZ5762eF4Vax3BSs9F6SfxT0KF+eZue1 X-Received: by 2002:a63:d70b:: with SMTP id d11mr26286748pgg.178.1560362278332; Wed, 12 Jun 2019 10:57:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560362278; cv=none; d=google.com; s=arc-20160816; b=rvdJECOVm8/prksco08PuMICwKoF4BKb6lsWEQjRaOyh7vI5nZaTYUkuvtmqsr16n7 P9xkswN6S+osdCe3dhAjvMid8wAdkZHCxT7O51G+HKMY7C9Lc1bg2xrLISsxaqtN+eyc edCCTAToesH3rCl2kew7dhoBvjpmeScQJAEpUag3UYoW6mD6ciFP6O9YeLV8/4isyUXx 5HHybzy2cQje4Bogiedp0P0YZMQJRVgPQq4FmfK0ZKN0NtYgzD3LMHtZqqH7KQhHarrS EfAgiiDBiOYREvcJZvicZuGCTcbfz3LCUclI1+8fw+VYW1lBtBc2TkhpSnmX4bK4pDF3 cOhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=olVtNqgfDAV8QzwsEHcbF4HS6DldAiMSK2i/PaExH8Y=; b=HXWs2Wgy3L+lGTWQz1z2avpE4bRFzg6fEDla8x/sNIm2aBmXyq1zp3v5u1rjkgSRhW eXXPM5stw3hGbFBUSaAJccmMguvzsjwTglMkaNGILPRCj8jYr5wSqqQAQW4L8q/dCr3y h493qYRKJUhsFumzLOGeC9DrLMkg9mXu8iO6fgMlIQGvFZxQKyhxzBdBSzKhz/rt1uvV a62DQWvRzF1G6+XZGGDlS4ZMmh2NKuKxntQKWFlETcJu8HujrXng76mS2XoPJQIrskP1 PA6eI562BJdbT31ddhFMXEwKwfYr+C9DQvqKRUQ6BHpd2s0O0m3RxukvOz5iY0YbYGTd zZWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Y3n3CJL6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 e127si414115pgc.214.2019.06.12.10.57.43; Wed, 12 Jun 2019 10:57:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=Y3n3CJL6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S2439392AbfFLNRm (ORCPT + 99 others); Wed, 12 Jun 2019 09:17:42 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:35888 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437410AbfFLNRl (ORCPT ); Wed, 12 Jun 2019 09:17:41 -0400 Received: by mail-lf1-f65.google.com with SMTP id q26so12089846lfc.3 for ; Wed, 12 Jun 2019 06:17:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=olVtNqgfDAV8QzwsEHcbF4HS6DldAiMSK2i/PaExH8Y=; b=Y3n3CJL6MQLaNLnpDPpIi04zq3C2rje6Y6b45S5VnDSla+tLtHIRJAXsv0oZ2AtQ/Q BEm+F2oMOOrT6C/ZsnEa52CZe1QHqSvUizwJIHmVv1NEsjAtMa6AB95v4X+xezzzEPzP BjXdBQZ1P6DBtIhwqEhxusym6OlTFnQg9bAtkw0D/sNAdcqbN5fh9aCPPr5i+aT4Yl1G EEhFFQ3f55iASjxeRSjdkDZ341YuSJTOjlMjlsznsjpZEb1DBvCsej3Zmv3WawKyuc8f Bwo/W9fyuhNRkj5JpOEKVK9O/+HfaR1QxxvK6bM9YpxHIEvFe+U7tchgjGDxltoJkvK2 R/Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=olVtNqgfDAV8QzwsEHcbF4HS6DldAiMSK2i/PaExH8Y=; b=kMTMdilPxUV7QkGi9QYmqDpBKl/dI7ggmhe0gmYrXePxblxB/MzuB9XRso5DFObo6F VDcHEjF5VQ3BIczJWWZ4pQG8jBrfiZtqMLVgncGAtYpHSZcvgikvy/h4FNa2GqIRO0OR ugPu0PUVBSFH81YwJnNKXbDbjDvQupymWxngB+l+bFft/DHxSmTDsoIgjJAkodBarmus aYtmKtDU8E+/7m/umtr7ca9f4N+dQluUUMvotgSE25Xr7vPGWro3HlcfaWu3DsxEuwuI B3yhL35zLxPDe6PlnllccI5BcNCTt1Ja1j+M2eoUzQAlyMKU4jZ4yffcd8lxYNOZ/Az+ hZww== X-Gm-Message-State: APjAAAV3LFFNp3LthOKkpNOPznJZixKRYRfPgv8s2YY06/i94zAsLJ4b ou3NK7+rswG09OC9pnepbfKjmw== X-Received: by 2002:ac2:4c84:: with SMTP id d4mr40519535lfl.1.1560345458799; Wed, 12 Jun 2019 06:17:38 -0700 (PDT) Received: from centauri (m83-185-80-163.cust.tele2.se. [83.185.80.163]) by smtp.gmail.com with ESMTPSA id l25sm159693lja.76.2019.06.12.06.17.37 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 12 Jun 2019 06:17:37 -0700 (PDT) Date: Wed, 12 Jun 2019 15:17:35 +0200 From: Niklas Cassel To: Paolo Pisati , Vivek Gautam Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: msm8996: qcom-qmp: apq8096-db820c fails to boot, reset back to fastboot and locks up Message-ID: <20190612131735.GB11167@centauri> References: <20190610134401.GA12964@harukaze> <20190611171225.GA21992@centauri.ideon.se> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190611171225.GA21992@centauri.ideon.se> User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 11, 2019 at 07:12:25PM +0200, Niklas Cassel wrote: > On Mon, Jun 10, 2019 at 03:44:01PM +0200, Paolo Pisati wrote: > > From time to time, my apq8096-db820c fails to boot to userspace, reset back to > > fastboot and locks up: to easily reproduce the issue, i'm boot looping using a > > cron job with a 1 min reboot entry on the board while leaving a "while 1; do > > fastboot boot boot.img; done" on the host pc. > > > > The issue is present in mainline up to 5.2-rc4, using defconfig and: > > > > CONFIG_SCSI_UFS_QCOM=y > > CONFIG_PHY_QCOM_QMP=y > > CONFIG_PHY_QCOM_UFS=y > > > > but was present in previous releases too (e.g. 4.14., 4.19, etc qcom-lt or > > mainline), where it's even easier to reproduce (e.g. takes way less reboots to > > trigger it). > > Hello Paolo, > > I have a guess of what is going on. > db820c has 3 PCIe controllers, > that shares a singe QMP block (that has clocks, regulators, and resets). > The QMP block has 3 PCIe PHYs, that have their own clocks and resets. > > > > > These are the last lines printed out: > > ... > > [ 7.407209] qcom-qmp-phy 34000.phy: Registered Qcom-QMP phy > > [ 7.448058] qcom-qmp-phy 7410000.phy: Registered Qcom-QMP phy > > [ 7.461859] ufs_qcom_phy_qmp_14nm 627000.phy: invalid resource > > [ 7.535434] qcom-qmp-phy 34000.phy: phy common block init timed-out > > ^^ here the phy_init() called from pcie-qcom.c > which ends up to a call to qcom_qmp_phy_enable() > > which has this code: > > ret = qcom_qmp_phy_com_init(qphy); > if (ret) > return ret; > > qcom_qmp_phy_com_init() has this code: > > if (qmp->init_count++) { > mutex_unlock(&qmp->phy_mutex); > return 0; > } > > qcom_qmp_phy_com_init() later fails, > since the common block init time out, so the qmp driver > disables clocks, asserts reset, and disables regulators > > > > [ 7.538596] phy phy-34000.phy.0: phy init failed --> -110 > > [ 7.550891] qcom-pcie: probe of 600000.pcie failed with error -110 > > ^^ here the first PCIe controller instance fails to probe > > > [ 7.619008] qcom-pcie 608000.pcie: 608000.pcie supply vddpe-3v3 not found, > > using dummy regulator > > ^^ here the second PCIe controller is probed. > > it will call phy_init() > > which will again call qcom_qmp_phy_enable() which will call > qcom_qmp_phy_com_init() > > where this code: > > if (qmp->init_count++) { > mutex_unlock(&qmp->phy_mutex); > return 0; > } > > now will return 0, > > so clocks will never be enabled, resets never deasserted, regulators > never enabled. > > since qcom_qmp_phy_com_init() returns success in this case, > qcom_qmp_phy_enable() will try to continue with the init, > and writes to disabled hardware is usually not a good idea. > > I think the proper fix for this is: > > diff --git a/drivers/phy/qualcomm/phy-qcom-qmp.c b/drivers/phy/qualcomm/phy-qcom-qmp.c > index cd91b4179b10..22352e3b0ec5 100644 > --- a/drivers/phy/qualcomm/phy-qcom-qmp.c > +++ b/drivers/phy/qualcomm/phy-qcom-qmp.c > @@ -1490,7 +1490,7 @@ static int qcom_qmp_phy_enable(struct phy *phy) > > ret = qcom_qmp_phy_com_init(qphy); > if (ret) > - return ret; > + goto err_lane_rst; > > if (cfg->has_lane_rst) { > ret = reset_control_deassert(qphy->lane_rst); > > > > Kind regards, > Niklas > > > > > Log Type: B - Since Boot(Power On Reset), D - Delta, S - Statistic > > S - QC_IMAGE_VERSION_STRING=BOOT.XF.1.0-00301 > > S - IMAGE_VARIANT_STRING=M8996LAB > > S - OEM_IMAGE_VERSION_STRING=crm-ubuntu68 > > S - Boot Interface: UFS > > S - Secure Boot: Off > > ... > > > > Full boot here: https://pastebin.ubuntu.com/p/rtjVrD3yzk/ > > > > Any idea what is going on? Am i doing something wrong? > > -- > > bye, > > p. Adding Vivek.