Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1081874imm; Wed, 26 Sep 2018 11:18:27 -0700 (PDT) X-Google-Smtp-Source: ACcGV636t3F47ENxmPSU6ZxHjY8BuHeVs+jgzTs8zFxFbCHRlmfXoCR+bvBHvGvL4DbK8ytT7DwP X-Received: by 2002:a63:1342:: with SMTP id 2-v6mr6741650pgt.19.1537985907578; Wed, 26 Sep 2018 11:18:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537985907; cv=none; d=google.com; s=arc-20160816; b=rucY6Rj3zoi/ssnVdzViwRkvttK/DxRxqBE5zrywNzhRM78q6zlDaVTQq7D6sNm/0b VWJs2HzgU0lsZ385l9/t+NwVBAFWD593CxI4QGFNvnYmcxMLuPabCGu1+RdaEZ7HWtuJ Wf78Am0iONnWKTum8HiiMLIOgmG20mXpdK7mqy4z+W3wFfqBp615JLAWwOenncLcp/ku rEkZ970TdOuKVA9rL8v7xzK1uIWLrs+ngiIATvqpT7CdvtXH4FDpMSlj0z40fhkwnsMj RpcqhDJFTT8sxSPS612lrJUrIpRBtkcRKBBKVrJfJD1zYlKxksc8Acc/9JogqqaddXCT /9qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=2iwWX6YeCx01aT6+yPJ837Z+CZods0Ydje0ucuCRe6U=; b=qt2xB6ImwVPTy02xzt1VXC12KMlPePAdDpRWZ26uvyKVK/Nw4xrhvxDSBmAlomwOX7 5eTpYNxfwJ5HP2ueeL8sdbORtboMrZ/lZLW8Tnh8qwC+JdhoZKwzezcHRDhxw/Y0HAq/ parcVBCb1PGKl1j4ZI8IkdoqIDsQrlHD3H3Ix6B6M1s/pJBxF6bGt3IpgDdyJaCmsPUW VxP86Em3GR4vhV3i9axyFd85Joq9CRGdOji8doRUMdrGQQjkfpaHhnIoz+gm816fSAEH 9iUmL0DoEQxjBIZVSbQ2LqpHdhcMEExdaY+Loi2D7gKV2JtG5NbCHIwGfDD0chExTgy7 I8ew== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l70-v6si5891719pga.498.2018.09.26.11.18.06; Wed, 26 Sep 2018 11:18:27 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728229AbeI0Ab7 (ORCPT + 99 others); Wed, 26 Sep 2018 20:31:59 -0400 Received: from mail-ot1-f65.google.com ([209.85.210.65]:42540 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725987AbeI0Ab7 (ORCPT ); Wed, 26 Sep 2018 20:31:59 -0400 Received: by mail-ot1-f65.google.com with SMTP id h26-v6so29095480otl.9 for ; Wed, 26 Sep 2018 11:17:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2iwWX6YeCx01aT6+yPJ837Z+CZods0Ydje0ucuCRe6U=; b=Rt3GQGlO2DDe2dxmaru+ggqOAflBQDUV0YAkavKPZ8lwfqcNdOzFQJgk5m8O4IMaiw 41ZthvClYP+6zysVIxtjzhlOZgYdayW8mmOHS/Kz2ziY+FIA9gja/OYkErWqWEyoE4Lz sQLcAEIgSH0eF7S6KkJoWkf8FZFUMefzjUBU1nQohtJBWFS95PUT3nTS0+MQ6tMbNcmv uXzQJ51UC3l8S5Wn+Bg++XHQCCXnQpFANRS+9crlGTnvpmul1bTMtRYC0tD4lWJ1V8Bs FfLMjtjsZqhbKWgWPsTm8xMT+AJWR5750vQYYbxAGvGBNvngG9u7a9cidiHwU2UmDcek ULaA== X-Gm-Message-State: ABuFfog7V5EUs8N83WVTUaHnFv0wv+4hM/j8+mH8V6hAJgpWjiZDhO7m KqtbdyS3uaRGe9h8WI/YGvPnlqz6 X-Received: by 2002:a9d:654a:: with SMTP id q10-v6mr4812164otl.256.1537985866199; Wed, 26 Sep 2018 11:17:46 -0700 (PDT) Received: from mail-ot1-f42.google.com (mail-ot1-f42.google.com. [209.85.210.42]) by smtp.gmail.com with ESMTPSA id g26-v6sm1951460otj.8.2018.09.26.11.17.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Sep 2018 11:17:45 -0700 (PDT) Received: by mail-ot1-f42.google.com with SMTP id e21-v6so16411330otk.10 for ; Wed, 26 Sep 2018 11:17:45 -0700 (PDT) X-Received: by 2002:a9d:614b:: with SMTP id c11-v6mr5255190otk.178.1537985864946; Wed, 26 Sep 2018 11:17:44 -0700 (PDT) MIME-Version: 1.0 References: <20180823213600.23426-1-alexandre.belloni@bootlin.com> <20180926092706.GA16644@piout.net> In-Reply-To: <20180926092706.GA16644@piout.net> From: Li Yang Date: Wed, 26 Sep 2018 13:15:15 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/2] soc: fsl: qbman: qman_portal: defer probing when qman is not available To: alexandre.belloni@bootlin.com Cc: Olof Johansson , Roy Pledge , linuxppc-dev , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" , lkml Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 26, 2018 at 4:28 AM Alexandre Belloni wrote: > > On 25/09/2018 21:45:56+0200, Olof Johansson wrote: > > Hi, > > > > > > On Thu, Aug 23, 2018 at 11:36 PM Alexandre Belloni > > wrote: > > > > > > If the qman driver (qman_ccsr) doesn't probe or fail to probe before > > > qman_portal, qm_ccsr_start will be either NULL or a stale pointer to an > > > unmapped page. > > > > > > This leads to a crash when probing qman_portal as the init_pcfg function > > > calls qman_liodn_fixup that tries to read qman registers. > > > > > > Assume that qman didn't probe when the pool mask is 0. > > > > > > Signed-off-by: Alexandre Belloni > > > --- > > > drivers/soc/fsl/qbman/qman_portal.c | 2 ++ > > > 1 file changed, 2 insertions(+) > > > > > > diff --git a/drivers/soc/fsl/qbman/qman_portal.c b/drivers/soc/fsl/qbman/qman_portal.c > > > index a120002b630e..4fc80d2c8feb 100644 > > > --- a/drivers/soc/fsl/qbman/qman_portal.c > > > +++ b/drivers/soc/fsl/qbman/qman_portal.c > > > @@ -277,6 +277,8 @@ static int qman_portal_probe(struct platform_device *pdev) > > > } > > > > > > pcfg->pools = qm_get_pools_sdqcr(); > > > + if (pcfg->pools == 0) > > > + return -EPROBE_DEFER; > > > > This is quite late in the probe, after a bunch of resources have been claimed. > > > > Note that the ioremaps above this are doing unwinds, and you'll end up > > doing duplicate ioremaps if you come in and probe again. > > > > You should probably unwind those allocations, or move them to devm_* > > or do this check earlier in the function. > > > > The actual chance of having that happen is quite small (this was coming > from a non working DT) and I mainly wanted to avoid a crash so the > platform could still boot. I would think moving to devm_ would be the > right thing to do. Even if it is not failing with the upstreamed device trees, it is still good to harden the driver for possible issues. Moving to devm_ is definitely a right thing to do. But I also think checking if the qman is already probed should be the first thing to do before starting to allocate resources and etc and rolling back later. Probably we can move the qm_get_pools_sdqcr() to the begining of the probe to determine if qman is probed as it doesn't seem to depend on any of the setups done right now. Regards, Leo