From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4EF47C43381 for ; Mon, 1 Apr 2019 22:12:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 14A5B206C0 for ; Mon, 1 Apr 2019 22:12:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728552AbfDAWMV (ORCPT ); Mon, 1 Apr 2019 18:12:21 -0400 Received: from mail-oi1-f196.google.com ([209.85.167.196]:35882 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725897AbfDAWMV (ORCPT ); Mon, 1 Apr 2019 18:12:21 -0400 Received: by mail-oi1-f196.google.com with SMTP id l203so8080514oia.3; Mon, 01 Apr 2019 15:12:20 -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=MuVGX2jjm0nWqvcUdPFL6/Kf5uXYGMPModplisJCpd0=; b=m4rvNkOVD6sfGZQIsgoS0bcHwDHP2T3fVpkBH2CSDDRkfUldM3EnzUYrOahMCFkd+o tbVTTK4T16667aDXQjvMdSUCvNxanvLv7L/GetHGj3ltNhKdMi0uJnDW71lrO7MKzcdW +aqy/Bkgm2R2wNpYbBm0HMQYEdh1QIXom+OzBQ7O/6z3AwLUH4CyzF6P2FWjEAzzdywC AcDziSOdBIzjv+7ExhjuyLgSNWX93t9ve/WNxjOMeYDbMwEqg22SfQS4XLUHFbS1zMfp 5WN6wjfkER+z/rDwWX28nAZkATKFbmV5MwyTtuXhi9JVTjOzoLEk50ITyY5FcfUVwymY XegA== X-Gm-Message-State: APjAAAWkBLM+klFYa7DvBvAt2np5iO1iLoRP4OFLnPJLWnJoZnNe6kFY y6YfFA+VbwHn8ldH/HCAL2RjE1aAivo= X-Google-Smtp-Source: APXvYqzZFnttYZ8BrE0jQsvu/ZshoIUjO6W3EEDGgOkRcKXcseh8nciFJ9rYN/3s0GYv5CUojYjVbw== X-Received: by 2002:aca:f44a:: with SMTP id s71mr8093104oih.151.1554156740182; Mon, 01 Apr 2019 15:12:20 -0700 (PDT) Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com. [209.85.167.178]) by smtp.gmail.com with ESMTPSA id h26sm3865958oih.22.2019.04.01.15.12.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Apr 2019 15:12:19 -0700 (PDT) Received: by mail-oi1-f178.google.com with SMTP id y84so8708151oia.12; Mon, 01 Apr 2019 15:12:19 -0700 (PDT) X-Received: by 2002:aca:48d0:: with SMTP id v199mr4315301oia.51.1554156739290; Mon, 01 Apr 2019 15:12:19 -0700 (PDT) MIME-Version: 1.0 References: <20190329140014.8126-1-laurentiu.tudor@nxp.com> <20190329140014.8126-7-laurentiu.tudor@nxp.com> In-Reply-To: <20190329140014.8126-7-laurentiu.tudor@nxp.com> From: Li Yang Date: Mon, 1 Apr 2019 17:12:07 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 06/13] soc/fsl/qbman_portals: add APIs to retrieve the probing status To: Laurentiu Tudor Cc: Netdev , madalin.bucur@nxp.com, Roy Pledge , camelia.groza@nxp.com, David Miller , Linux IOMMU , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" , linuxppc-dev , 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 Fri, Mar 29, 2019 at 9:03 AM wrote: > > From: Laurentiu Tudor > > Add a couple of new APIs to check the probing status of the required > cpu bound qman and bman portals: > 'int bman_portals_probed()' and 'int qman_portals_probed()'. > They return the following values. > * 1 if qman/bman portals were all probed correctly > * 0 if qman/bman portals were not yet probed > * -1 if probing of qman/bman portals failed > Portals are considered successful probed if no error occurred during > the probing of any of the portals and if enough portals were probed > to have one available for each cpu. > The error handling paths were slightly rearranged in order to fit this > new functionality without being too intrusive. > Drivers that use qman/bman portal driver services are required to use > these APIs before calling any functions exported by these drivers or > otherwise they will crash the kernel. > First user will be the dpaa1 ethernet driver, coming in a subsequent > patch. > > Signed-off-by: Laurentiu Tudor > --- > drivers/soc/fsl/qbman/bman_portal.c | 22 ++++++++++++++++++---- > drivers/soc/fsl/qbman/qman_portal.c | 23 +++++++++++++++++++---- > include/soc/fsl/bman.h | 8 ++++++++ > include/soc/fsl/qman.h | 9 +++++++++ > 4 files changed, 54 insertions(+), 8 deletions(-) > > diff --git a/drivers/soc/fsl/qbman/bman_portal.c b/drivers/soc/fsl/qbman/bman_portal.c > index 2c95cf59f3e7..7819bc29936d 100644 > --- a/drivers/soc/fsl/qbman/bman_portal.c > +++ b/drivers/soc/fsl/qbman/bman_portal.c > @@ -32,6 +32,7 @@ > > static struct bman_portal *affine_bportals[NR_CPUS]; > static struct cpumask portal_cpus; > +static int __bman_portals_probed; > /* protect bman global registers and global data shared among portals */ > static DEFINE_SPINLOCK(bman_lock); > > @@ -87,6 +88,12 @@ static int bman_online_cpu(unsigned int cpu) > return 0; > } > > +int bman_portals_probed(void) > +{ > + return __bman_portals_probed; > +} > +EXPORT_SYMBOL_GPL(bman_portals_probed); > + > static int bman_portal_probe(struct platform_device *pdev) > { > struct device *dev = &pdev->dev; > @@ -104,8 +111,10 @@ static int bman_portal_probe(struct platform_device *pdev) > } > > pcfg = devm_kmalloc(dev, sizeof(*pcfg), GFP_KERNEL); > - if (!pcfg) > + if (!pcfg) { > + __bman_portals_probed = -1; > return -ENOMEM; > + } > > pcfg->dev = dev; > > @@ -113,14 +122,14 @@ static int bman_portal_probe(struct platform_device *pdev) > DPAA_PORTAL_CE); > if (!addr_phys[0]) { > dev_err(dev, "Can't get %pOF property 'reg::CE'\n", node); > - return -ENXIO; > + goto err_ioremap1; > } > > addr_phys[1] = platform_get_resource(pdev, IORESOURCE_MEM, > DPAA_PORTAL_CI); > if (!addr_phys[1]) { > dev_err(dev, "Can't get %pOF property 'reg::CI'\n", node); > - return -ENXIO; > + goto err_ioremap1; > } > > pcfg->cpu = -1; > @@ -128,7 +137,7 @@ static int bman_portal_probe(struct platform_device *pdev) > irq = platform_get_irq(pdev, 0); > if (irq <= 0) { > dev_err(dev, "Can't get %pOF IRQ'\n", node); > - return -ENXIO; > + goto err_ioremap1; > } > pcfg->irq = irq; > > @@ -156,6 +165,9 @@ static int bman_portal_probe(struct platform_device *pdev) > } > > cpumask_set_cpu(cpu, &portal_cpus); > + if (!__bman_portals_probed && > + cpumask_weight(&portal_cpus) == num_online_cpus()) > + __bman_portals_probed = 1; Given the fact that the portal_cpus bit will get set even for offline cpus, this is not correct either. Probably the previous code for checking cpu >= nr_cpu_ids is actually the right way to do it. > spin_unlock(&bman_lock); > pcfg->cpu = cpu; > > @@ -175,6 +187,8 @@ static int bman_portal_probe(struct platform_device *pdev) > err_ioremap2: > memunmap(pcfg->addr_virt_ce); > err_ioremap1: > + __bman_portals_probed = -1; > + > return -ENXIO; > } > > diff --git a/drivers/soc/fsl/qbman/qman_portal.c b/drivers/soc/fsl/qbman/qman_portal.c > index bce56da2b01f..11ba6c77c0d6 100644 > --- a/drivers/soc/fsl/qbman/qman_portal.c > +++ b/drivers/soc/fsl/qbman/qman_portal.c > @@ -39,6 +39,7 @@ EXPORT_SYMBOL(qman_dma_portal); > #define CONFIG_FSL_DPA_PIRQ_FAST 1 > > static struct cpumask portal_cpus; > +static int __qman_portals_probed; > /* protect qman global registers and global data shared among portals */ > static DEFINE_SPINLOCK(qman_lock); > > @@ -221,6 +222,12 @@ static int qman_online_cpu(unsigned int cpu) > return 0; > } > > +int qman_portals_probed(void) > +{ > + return __qman_portals_probed; > +} > +EXPORT_SYMBOL_GPL(qman_portals_probed); > + > static int qman_portal_probe(struct platform_device *pdev) > { > struct device *dev = &pdev->dev; > @@ -240,8 +247,10 @@ static int qman_portal_probe(struct platform_device *pdev) > } > > pcfg = devm_kmalloc(dev, sizeof(*pcfg), GFP_KERNEL); > - if (!pcfg) > + if (!pcfg) { > + __qman_portals_probed = -1; > return -ENOMEM; > + } > > pcfg->dev = dev; > > @@ -249,19 +258,20 @@ static int qman_portal_probe(struct platform_device *pdev) > DPAA_PORTAL_CE); > if (!addr_phys[0]) { > dev_err(dev, "Can't get %pOF property 'reg::CE'\n", node); > - return -ENXIO; > + goto err_ioremap1; > } > > addr_phys[1] = platform_get_resource(pdev, IORESOURCE_MEM, > DPAA_PORTAL_CI); > if (!addr_phys[1]) { > dev_err(dev, "Can't get %pOF property 'reg::CI'\n", node); > - return -ENXIO; > + goto err_ioremap1; > } > > err = of_property_read_u32(node, "cell-index", &val); > if (err) { > dev_err(dev, "Can't get %pOF property 'cell-index'\n", node); > + __qman_portals_probed = -1; > return err; > } > pcfg->channel = val; > @@ -269,7 +279,7 @@ static int qman_portal_probe(struct platform_device *pdev) > irq = platform_get_irq(pdev, 0); > if (irq <= 0) { > dev_err(dev, "Can't get %pOF IRQ\n", node); > - return -ENXIO; > + goto err_ioremap1; > } > pcfg->irq = irq; > > @@ -314,6 +324,9 @@ static int qman_portal_probe(struct platform_device *pdev) > } > > cpumask_set_cpu(cpu, &portal_cpus); > + if (!__qman_portals_probed && > + cpumask_weight(&portal_cpus) == num_online_cpus()) > + __qman_portals_probed = 1; > spin_unlock(&qman_lock); > pcfg->cpu = cpu; > > @@ -338,6 +351,8 @@ static int qman_portal_probe(struct platform_device *pdev) > err_ioremap2: > memunmap(pcfg->addr_virt_ce); > err_ioremap1: > + __qman_portals_probed = -1; > + > return -ENXIO; > } > > diff --git a/include/soc/fsl/bman.h b/include/soc/fsl/bman.h > index 5b99cb2ea5ef..173e4049d963 100644 > --- a/include/soc/fsl/bman.h > +++ b/include/soc/fsl/bman.h > @@ -133,5 +133,13 @@ int bman_acquire(struct bman_pool *pool, struct bm_buffer *bufs, u8 num); > * failed to probe or 0 if the bman driver did not probed yet. > */ > int bman_is_probed(void); > +/** > + * bman_portals_probed - Check if all cpu bound bman portals are probed > + * > + * Returns 1 if all the required cpu bound bman portals successfully probed, > + * -1 if probe errors appeared or 0 if the bman portals did not yet finished > + * probing. > + */ > +int bman_portals_probed(void); > > #endif /* __FSL_BMAN_H */ > diff --git a/include/soc/fsl/qman.h b/include/soc/fsl/qman.h > index 5cc7af06c1ba..aa31c05a103a 100644 > --- a/include/soc/fsl/qman.h > +++ b/include/soc/fsl/qman.h > @@ -1194,6 +1194,15 @@ int qman_release_cgrid(u32 id); > */ > int qman_is_probed(void); > > +/** > + * qman_portals_probed - Check if all cpu bound qman portals are probed > + * > + * Returns 1 if all the required cpu bound qman portals successfully probed, > + * -1 if probe errors appeared or 0 if the qman portals did not yet finished > + * probing. > + */ > +int qman_portals_probed(void); > + > /** > * qman_dqrr_get_ithresh - Get coalesce interrupt threshold > * @portal: portal to get the value for > -- > 2.17.1 > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36657C43381 for ; Mon, 1 Apr 2019 22:14:00 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7A897206C0 for ; Mon, 1 Apr 2019 22:13:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7A897206C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 44Y67S5GmnzDqLT for ; Tue, 2 Apr 2019 09:13:56 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=209.85.210.65; helo=mail-ot1-f65.google.com; envelope-from=pku.leo@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=fail (p=none dis=none) header.from=nxp.com Received: from mail-ot1-f65.google.com (mail-ot1-f65.google.com [209.85.210.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 44Y65g3qj3zDqBX for ; Tue, 2 Apr 2019 09:12:23 +1100 (AEDT) Received: by mail-ot1-f65.google.com with SMTP id 103so10106799otd.9 for ; Mon, 01 Apr 2019 15:12:23 -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=MuVGX2jjm0nWqvcUdPFL6/Kf5uXYGMPModplisJCpd0=; b=j1bUbgsbIXlshlajapbVwmXIRGwDXyenRBDOBS9AdNxEjY9IfSKDW/IpzTCy4gRWQf lGhmzLnquWcTbG5vdCAFIK3LI4XJQOVXY5qUsYMWIFE1nBKV+S+preJqTugocR/UH7EV MY57UnWvkKwQhzsjSrSJTYwd5Xas++lpe7eG4RH+5X8sldhYFdHzRh/wZ3x9jkO/uuFA GNrB8pt+vRPOyFDsuN/f7L/PNGviOEDz4q0ILWx2e/eDeF0dS8OZTFg+RhGaa6yy/LVP fZLfQ5k0vqt48sOfngj+TPG4zUp7P1ScCqZnkUmn0sefeIzNxV+GcgvWAT9m+TQKyynz HR6g== X-Gm-Message-State: APjAAAVifdxK4BBJtJshbC+ySjobteCH9ZX4B89JmpruRPJeI2+QfFaR 0MSIk2DY4Seu3cD1Mh4A7QhrOiuCq3Q= X-Google-Smtp-Source: APXvYqx4R76QBV4T/+BJNaxAIyG1ITdnVP5N+qaJjqb976XpSlpgBBqvJUjdv+FunDZkn1fkheunpw== X-Received: by 2002:a9d:6ace:: with SMTP id m14mr20374973otq.296.1554156740288; Mon, 01 Apr 2019 15:12:20 -0700 (PDT) Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com. [209.85.167.178]) by smtp.gmail.com with ESMTPSA id q82sm3728656oif.28.2019.04.01.15.12.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Apr 2019 15:12:19 -0700 (PDT) Received: by mail-oi1-f178.google.com with SMTP id a6so5351706oie.5 for ; Mon, 01 Apr 2019 15:12:19 -0700 (PDT) X-Received: by 2002:aca:48d0:: with SMTP id v199mr4315301oia.51.1554156739290; Mon, 01 Apr 2019 15:12:19 -0700 (PDT) MIME-Version: 1.0 References: <20190329140014.8126-1-laurentiu.tudor@nxp.com> <20190329140014.8126-7-laurentiu.tudor@nxp.com> In-Reply-To: <20190329140014.8126-7-laurentiu.tudor@nxp.com> From: Li Yang Date: Mon, 1 Apr 2019 17:12:07 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 06/13] soc/fsl/qbman_portals: add APIs to retrieve the probing status To: Laurentiu Tudor Content-Type: text/plain; charset="UTF-8" X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: madalin.bucur@nxp.com, Netdev , Roy Pledge , lkml , Linux IOMMU , camelia.groza@nxp.com, linuxppc-dev , David Miller , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Fri, Mar 29, 2019 at 9:03 AM wrote: > > From: Laurentiu Tudor > > Add a couple of new APIs to check the probing status of the required > cpu bound qman and bman portals: > 'int bman_portals_probed()' and 'int qman_portals_probed()'. > They return the following values. > * 1 if qman/bman portals were all probed correctly > * 0 if qman/bman portals were not yet probed > * -1 if probing of qman/bman portals failed > Portals are considered successful probed if no error occurred during > the probing of any of the portals and if enough portals were probed > to have one available for each cpu. > The error handling paths were slightly rearranged in order to fit this > new functionality without being too intrusive. > Drivers that use qman/bman portal driver services are required to use > these APIs before calling any functions exported by these drivers or > otherwise they will crash the kernel. > First user will be the dpaa1 ethernet driver, coming in a subsequent > patch. > > Signed-off-by: Laurentiu Tudor > --- > drivers/soc/fsl/qbman/bman_portal.c | 22 ++++++++++++++++++---- > drivers/soc/fsl/qbman/qman_portal.c | 23 +++++++++++++++++++---- > include/soc/fsl/bman.h | 8 ++++++++ > include/soc/fsl/qman.h | 9 +++++++++ > 4 files changed, 54 insertions(+), 8 deletions(-) > > diff --git a/drivers/soc/fsl/qbman/bman_portal.c b/drivers/soc/fsl/qbman/bman_portal.c > index 2c95cf59f3e7..7819bc29936d 100644 > --- a/drivers/soc/fsl/qbman/bman_portal.c > +++ b/drivers/soc/fsl/qbman/bman_portal.c > @@ -32,6 +32,7 @@ > > static struct bman_portal *affine_bportals[NR_CPUS]; > static struct cpumask portal_cpus; > +static int __bman_portals_probed; > /* protect bman global registers and global data shared among portals */ > static DEFINE_SPINLOCK(bman_lock); > > @@ -87,6 +88,12 @@ static int bman_online_cpu(unsigned int cpu) > return 0; > } > > +int bman_portals_probed(void) > +{ > + return __bman_portals_probed; > +} > +EXPORT_SYMBOL_GPL(bman_portals_probed); > + > static int bman_portal_probe(struct platform_device *pdev) > { > struct device *dev = &pdev->dev; > @@ -104,8 +111,10 @@ static int bman_portal_probe(struct platform_device *pdev) > } > > pcfg = devm_kmalloc(dev, sizeof(*pcfg), GFP_KERNEL); > - if (!pcfg) > + if (!pcfg) { > + __bman_portals_probed = -1; > return -ENOMEM; > + } > > pcfg->dev = dev; > > @@ -113,14 +122,14 @@ static int bman_portal_probe(struct platform_device *pdev) > DPAA_PORTAL_CE); > if (!addr_phys[0]) { > dev_err(dev, "Can't get %pOF property 'reg::CE'\n", node); > - return -ENXIO; > + goto err_ioremap1; > } > > addr_phys[1] = platform_get_resource(pdev, IORESOURCE_MEM, > DPAA_PORTAL_CI); > if (!addr_phys[1]) { > dev_err(dev, "Can't get %pOF property 'reg::CI'\n", node); > - return -ENXIO; > + goto err_ioremap1; > } > > pcfg->cpu = -1; > @@ -128,7 +137,7 @@ static int bman_portal_probe(struct platform_device *pdev) > irq = platform_get_irq(pdev, 0); > if (irq <= 0) { > dev_err(dev, "Can't get %pOF IRQ'\n", node); > - return -ENXIO; > + goto err_ioremap1; > } > pcfg->irq = irq; > > @@ -156,6 +165,9 @@ static int bman_portal_probe(struct platform_device *pdev) > } > > cpumask_set_cpu(cpu, &portal_cpus); > + if (!__bman_portals_probed && > + cpumask_weight(&portal_cpus) == num_online_cpus()) > + __bman_portals_probed = 1; Given the fact that the portal_cpus bit will get set even for offline cpus, this is not correct either. Probably the previous code for checking cpu >= nr_cpu_ids is actually the right way to do it. > spin_unlock(&bman_lock); > pcfg->cpu = cpu; > > @@ -175,6 +187,8 @@ static int bman_portal_probe(struct platform_device *pdev) > err_ioremap2: > memunmap(pcfg->addr_virt_ce); > err_ioremap1: > + __bman_portals_probed = -1; > + > return -ENXIO; > } > > diff --git a/drivers/soc/fsl/qbman/qman_portal.c b/drivers/soc/fsl/qbman/qman_portal.c > index bce56da2b01f..11ba6c77c0d6 100644 > --- a/drivers/soc/fsl/qbman/qman_portal.c > +++ b/drivers/soc/fsl/qbman/qman_portal.c > @@ -39,6 +39,7 @@ EXPORT_SYMBOL(qman_dma_portal); > #define CONFIG_FSL_DPA_PIRQ_FAST 1 > > static struct cpumask portal_cpus; > +static int __qman_portals_probed; > /* protect qman global registers and global data shared among portals */ > static DEFINE_SPINLOCK(qman_lock); > > @@ -221,6 +222,12 @@ static int qman_online_cpu(unsigned int cpu) > return 0; > } > > +int qman_portals_probed(void) > +{ > + return __qman_portals_probed; > +} > +EXPORT_SYMBOL_GPL(qman_portals_probed); > + > static int qman_portal_probe(struct platform_device *pdev) > { > struct device *dev = &pdev->dev; > @@ -240,8 +247,10 @@ static int qman_portal_probe(struct platform_device *pdev) > } > > pcfg = devm_kmalloc(dev, sizeof(*pcfg), GFP_KERNEL); > - if (!pcfg) > + if (!pcfg) { > + __qman_portals_probed = -1; > return -ENOMEM; > + } > > pcfg->dev = dev; > > @@ -249,19 +258,20 @@ static int qman_portal_probe(struct platform_device *pdev) > DPAA_PORTAL_CE); > if (!addr_phys[0]) { > dev_err(dev, "Can't get %pOF property 'reg::CE'\n", node); > - return -ENXIO; > + goto err_ioremap1; > } > > addr_phys[1] = platform_get_resource(pdev, IORESOURCE_MEM, > DPAA_PORTAL_CI); > if (!addr_phys[1]) { > dev_err(dev, "Can't get %pOF property 'reg::CI'\n", node); > - return -ENXIO; > + goto err_ioremap1; > } > > err = of_property_read_u32(node, "cell-index", &val); > if (err) { > dev_err(dev, "Can't get %pOF property 'cell-index'\n", node); > + __qman_portals_probed = -1; > return err; > } > pcfg->channel = val; > @@ -269,7 +279,7 @@ static int qman_portal_probe(struct platform_device *pdev) > irq = platform_get_irq(pdev, 0); > if (irq <= 0) { > dev_err(dev, "Can't get %pOF IRQ\n", node); > - return -ENXIO; > + goto err_ioremap1; > } > pcfg->irq = irq; > > @@ -314,6 +324,9 @@ static int qman_portal_probe(struct platform_device *pdev) > } > > cpumask_set_cpu(cpu, &portal_cpus); > + if (!__qman_portals_probed && > + cpumask_weight(&portal_cpus) == num_online_cpus()) > + __qman_portals_probed = 1; > spin_unlock(&qman_lock); > pcfg->cpu = cpu; > > @@ -338,6 +351,8 @@ static int qman_portal_probe(struct platform_device *pdev) > err_ioremap2: > memunmap(pcfg->addr_virt_ce); > err_ioremap1: > + __qman_portals_probed = -1; > + > return -ENXIO; > } > > diff --git a/include/soc/fsl/bman.h b/include/soc/fsl/bman.h > index 5b99cb2ea5ef..173e4049d963 100644 > --- a/include/soc/fsl/bman.h > +++ b/include/soc/fsl/bman.h > @@ -133,5 +133,13 @@ int bman_acquire(struct bman_pool *pool, struct bm_buffer *bufs, u8 num); > * failed to probe or 0 if the bman driver did not probed yet. > */ > int bman_is_probed(void); > +/** > + * bman_portals_probed - Check if all cpu bound bman portals are probed > + * > + * Returns 1 if all the required cpu bound bman portals successfully probed, > + * -1 if probe errors appeared or 0 if the bman portals did not yet finished > + * probing. > + */ > +int bman_portals_probed(void); > > #endif /* __FSL_BMAN_H */ > diff --git a/include/soc/fsl/qman.h b/include/soc/fsl/qman.h > index 5cc7af06c1ba..aa31c05a103a 100644 > --- a/include/soc/fsl/qman.h > +++ b/include/soc/fsl/qman.h > @@ -1194,6 +1194,15 @@ int qman_release_cgrid(u32 id); > */ > int qman_is_probed(void); > > +/** > + * qman_portals_probed - Check if all cpu bound qman portals are probed > + * > + * Returns 1 if all the required cpu bound qman portals successfully probed, > + * -1 if probe errors appeared or 0 if the qman portals did not yet finished > + * probing. > + */ > +int qman_portals_probed(void); > + > /** > * qman_dqrr_get_ithresh - Get coalesce interrupt threshold > * @portal: portal to get the value for > -- > 2.17.1 > From mboxrd@z Thu Jan 1 00:00:00 1970 From: Li Yang Subject: Re: [PATCH 06/13] soc/fsl/qbman_portals: add APIs to retrieve the probing status Date: Mon, 1 Apr 2019 17:12:07 -0500 Message-ID: References: <20190329140014.8126-1-laurentiu.tudor@nxp.com> <20190329140014.8126-7-laurentiu.tudor@nxp.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: In-Reply-To: <20190329140014.8126-7-laurentiu.tudor@nxp.com> Sender: linux-kernel-owner@vger.kernel.org To: Laurentiu Tudor Cc: Netdev , madalin.bucur@nxp.com, Roy Pledge , camelia.groza@nxp.com, David Miller , Linux IOMMU , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" , linuxppc-dev , lkml List-Id: iommu@lists.linux-foundation.org On Fri, Mar 29, 2019 at 9:03 AM wrote: > > From: Laurentiu Tudor > > Add a couple of new APIs to check the probing status of the required > cpu bound qman and bman portals: > 'int bman_portals_probed()' and 'int qman_portals_probed()'. > They return the following values. > * 1 if qman/bman portals were all probed correctly > * 0 if qman/bman portals were not yet probed > * -1 if probing of qman/bman portals failed > Portals are considered successful probed if no error occurred during > the probing of any of the portals and if enough portals were probed > to have one available for each cpu. > The error handling paths were slightly rearranged in order to fit this > new functionality without being too intrusive. > Drivers that use qman/bman portal driver services are required to use > these APIs before calling any functions exported by these drivers or > otherwise they will crash the kernel. > First user will be the dpaa1 ethernet driver, coming in a subsequent > patch. > > Signed-off-by: Laurentiu Tudor > --- > drivers/soc/fsl/qbman/bman_portal.c | 22 ++++++++++++++++++---- > drivers/soc/fsl/qbman/qman_portal.c | 23 +++++++++++++++++++---- > include/soc/fsl/bman.h | 8 ++++++++ > include/soc/fsl/qman.h | 9 +++++++++ > 4 files changed, 54 insertions(+), 8 deletions(-) > > diff --git a/drivers/soc/fsl/qbman/bman_portal.c b/drivers/soc/fsl/qbman/bman_portal.c > index 2c95cf59f3e7..7819bc29936d 100644 > --- a/drivers/soc/fsl/qbman/bman_portal.c > +++ b/drivers/soc/fsl/qbman/bman_portal.c > @@ -32,6 +32,7 @@ > > static struct bman_portal *affine_bportals[NR_CPUS]; > static struct cpumask portal_cpus; > +static int __bman_portals_probed; > /* protect bman global registers and global data shared among portals */ > static DEFINE_SPINLOCK(bman_lock); > > @@ -87,6 +88,12 @@ static int bman_online_cpu(unsigned int cpu) > return 0; > } > > +int bman_portals_probed(void) > +{ > + return __bman_portals_probed; > +} > +EXPORT_SYMBOL_GPL(bman_portals_probed); > + > static int bman_portal_probe(struct platform_device *pdev) > { > struct device *dev = &pdev->dev; > @@ -104,8 +111,10 @@ static int bman_portal_probe(struct platform_device *pdev) > } > > pcfg = devm_kmalloc(dev, sizeof(*pcfg), GFP_KERNEL); > - if (!pcfg) > + if (!pcfg) { > + __bman_portals_probed = -1; > return -ENOMEM; > + } > > pcfg->dev = dev; > > @@ -113,14 +122,14 @@ static int bman_portal_probe(struct platform_device *pdev) > DPAA_PORTAL_CE); > if (!addr_phys[0]) { > dev_err(dev, "Can't get %pOF property 'reg::CE'\n", node); > - return -ENXIO; > + goto err_ioremap1; > } > > addr_phys[1] = platform_get_resource(pdev, IORESOURCE_MEM, > DPAA_PORTAL_CI); > if (!addr_phys[1]) { > dev_err(dev, "Can't get %pOF property 'reg::CI'\n", node); > - return -ENXIO; > + goto err_ioremap1; > } > > pcfg->cpu = -1; > @@ -128,7 +137,7 @@ static int bman_portal_probe(struct platform_device *pdev) > irq = platform_get_irq(pdev, 0); > if (irq <= 0) { > dev_err(dev, "Can't get %pOF IRQ'\n", node); > - return -ENXIO; > + goto err_ioremap1; > } > pcfg->irq = irq; > > @@ -156,6 +165,9 @@ static int bman_portal_probe(struct platform_device *pdev) > } > > cpumask_set_cpu(cpu, &portal_cpus); > + if (!__bman_portals_probed && > + cpumask_weight(&portal_cpus) == num_online_cpus()) > + __bman_portals_probed = 1; Given the fact that the portal_cpus bit will get set even for offline cpus, this is not correct either. Probably the previous code for checking cpu >= nr_cpu_ids is actually the right way to do it. > spin_unlock(&bman_lock); > pcfg->cpu = cpu; > > @@ -175,6 +187,8 @@ static int bman_portal_probe(struct platform_device *pdev) > err_ioremap2: > memunmap(pcfg->addr_virt_ce); > err_ioremap1: > + __bman_portals_probed = -1; > + > return -ENXIO; > } > > diff --git a/drivers/soc/fsl/qbman/qman_portal.c b/drivers/soc/fsl/qbman/qman_portal.c > index bce56da2b01f..11ba6c77c0d6 100644 > --- a/drivers/soc/fsl/qbman/qman_portal.c > +++ b/drivers/soc/fsl/qbman/qman_portal.c > @@ -39,6 +39,7 @@ EXPORT_SYMBOL(qman_dma_portal); > #define CONFIG_FSL_DPA_PIRQ_FAST 1 > > static struct cpumask portal_cpus; > +static int __qman_portals_probed; > /* protect qman global registers and global data shared among portals */ > static DEFINE_SPINLOCK(qman_lock); > > @@ -221,6 +222,12 @@ static int qman_online_cpu(unsigned int cpu) > return 0; > } > > +int qman_portals_probed(void) > +{ > + return __qman_portals_probed; > +} > +EXPORT_SYMBOL_GPL(qman_portals_probed); > + > static int qman_portal_probe(struct platform_device *pdev) > { > struct device *dev = &pdev->dev; > @@ -240,8 +247,10 @@ static int qman_portal_probe(struct platform_device *pdev) > } > > pcfg = devm_kmalloc(dev, sizeof(*pcfg), GFP_KERNEL); > - if (!pcfg) > + if (!pcfg) { > + __qman_portals_probed = -1; > return -ENOMEM; > + } > > pcfg->dev = dev; > > @@ -249,19 +258,20 @@ static int qman_portal_probe(struct platform_device *pdev) > DPAA_PORTAL_CE); > if (!addr_phys[0]) { > dev_err(dev, "Can't get %pOF property 'reg::CE'\n", node); > - return -ENXIO; > + goto err_ioremap1; > } > > addr_phys[1] = platform_get_resource(pdev, IORESOURCE_MEM, > DPAA_PORTAL_CI); > if (!addr_phys[1]) { > dev_err(dev, "Can't get %pOF property 'reg::CI'\n", node); > - return -ENXIO; > + goto err_ioremap1; > } > > err = of_property_read_u32(node, "cell-index", &val); > if (err) { > dev_err(dev, "Can't get %pOF property 'cell-index'\n", node); > + __qman_portals_probed = -1; > return err; > } > pcfg->channel = val; > @@ -269,7 +279,7 @@ static int qman_portal_probe(struct platform_device *pdev) > irq = platform_get_irq(pdev, 0); > if (irq <= 0) { > dev_err(dev, "Can't get %pOF IRQ\n", node); > - return -ENXIO; > + goto err_ioremap1; > } > pcfg->irq = irq; > > @@ -314,6 +324,9 @@ static int qman_portal_probe(struct platform_device *pdev) > } > > cpumask_set_cpu(cpu, &portal_cpus); > + if (!__qman_portals_probed && > + cpumask_weight(&portal_cpus) == num_online_cpus()) > + __qman_portals_probed = 1; > spin_unlock(&qman_lock); > pcfg->cpu = cpu; > > @@ -338,6 +351,8 @@ static int qman_portal_probe(struct platform_device *pdev) > err_ioremap2: > memunmap(pcfg->addr_virt_ce); > err_ioremap1: > + __qman_portals_probed = -1; > + > return -ENXIO; > } > > diff --git a/include/soc/fsl/bman.h b/include/soc/fsl/bman.h > index 5b99cb2ea5ef..173e4049d963 100644 > --- a/include/soc/fsl/bman.h > +++ b/include/soc/fsl/bman.h > @@ -133,5 +133,13 @@ int bman_acquire(struct bman_pool *pool, struct bm_buffer *bufs, u8 num); > * failed to probe or 0 if the bman driver did not probed yet. > */ > int bman_is_probed(void); > +/** > + * bman_portals_probed - Check if all cpu bound bman portals are probed > + * > + * Returns 1 if all the required cpu bound bman portals successfully probed, > + * -1 if probe errors appeared or 0 if the bman portals did not yet finished > + * probing. > + */ > +int bman_portals_probed(void); > > #endif /* __FSL_BMAN_H */ > diff --git a/include/soc/fsl/qman.h b/include/soc/fsl/qman.h > index 5cc7af06c1ba..aa31c05a103a 100644 > --- a/include/soc/fsl/qman.h > +++ b/include/soc/fsl/qman.h > @@ -1194,6 +1194,15 @@ int qman_release_cgrid(u32 id); > */ > int qman_is_probed(void); > > +/** > + * qman_portals_probed - Check if all cpu bound qman portals are probed > + * > + * Returns 1 if all the required cpu bound qman portals successfully probed, > + * -1 if probe errors appeared or 0 if the qman portals did not yet finished > + * probing. > + */ > +int qman_portals_probed(void); > + > /** > * qman_dqrr_get_ithresh - Get coalesce interrupt threshold > * @portal: portal to get the value for > -- > 2.17.1 > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 185B2C43381 for ; Mon, 1 Apr 2019 22:12:29 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DDCB1206C0 for ; Mon, 1 Apr 2019 22:12:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Iu560eoL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DDCB1206C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/RyU99VOFskKtOivyqKbKpVV8/6CfaHRLibeZUgHOhw=; b=Iu560eoL5axM9j UTwRISjcU40UjSJBqWffgHcyCXORBS2zVQSiRXh8vInlwcPd4T8kKQfqw4YMAihYeo4AyOUclfG5X WWgkH5WUA9HyFKHwxcjV/nJnTAymepP+uEJ6SHvTEiQdUiTYgJj0814jFFpsp8xQHZnyKBiDHXEDY Yg8tbsEY6M6ITlzksyRNJfOi+LaAFnm6X8DoGILI9dtAizGq+Tg1T1OVjIVz8obNXKQhVsbwMZwv2 l5+4yvahRLeoQEE+iuUJhC87t6U6LmnkHJgdphrHF8Xi/Pu8tKjmjhlGMIPPEjBRM7fib1mE38Za/ jT6y11tHDg0uj3fi0NjA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hB5AH-0006l7-25; Mon, 01 Apr 2019 22:12:25 +0000 Received: from mail-ot1-f66.google.com ([209.85.210.66]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hB5AD-0006kf-U9 for linux-arm-kernel@lists.infradead.org; Mon, 01 Apr 2019 22:12:23 +0000 Received: by mail-ot1-f66.google.com with SMTP id o74so10240030ota.3 for ; Mon, 01 Apr 2019 15:12:21 -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=MuVGX2jjm0nWqvcUdPFL6/Kf5uXYGMPModplisJCpd0=; b=peyuVuS7wVCXg+MEnpKha99W/0uDsbf4FVgq7FaqzWA8OIVTAwrhSYjD1mFmUzAUt7 QyTJT4a88ZqvVquQe0TysyTs1A/kyraxNcz8VQTr9FDDu/EyGZ2a6qKlupew8z0p5oz/ q6JgZEPe3x9/TRzmXHULgpktvCDqVRVPhxviq6JH1RkWNM0CoeMorVw0Uryk0u672Je8 At8JRfqbrI56dmIGoVZIwpX+Y+mePl9ExwujRCNgFX0yiEEj3n7vlZTCD5gBuVZf4h7V 7g6bR9pCFvfhIbNwjD+PvBgJA4JmLC8/zvXSt1BLnlgTyQsqQe6Oc+xR41f2zEUV06oh 3hGg== X-Gm-Message-State: APjAAAXdFcuxwHmzkrVuWIgdXjnmrmUvAtVQoBoNV48KpAfBsjAgb86J kwa+BlEc/pKjd2Rs1LBs/If+17gmlFo= X-Google-Smtp-Source: APXvYqyrX7TRuSvrQFZiZpyZme8v7mSwzitgjpcTmvPuU40TMZFxY0EBHZNChgEFHZaBFXvIKUnl8Q== X-Received: by 2002:a9d:6850:: with SMTP id c16mr43464430oto.226.1554156740229; Mon, 01 Apr 2019 15:12:20 -0700 (PDT) Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com. [209.85.167.178]) by smtp.gmail.com with ESMTPSA id c90sm4704132otb.71.2019.04.01.15.12.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Apr 2019 15:12:19 -0700 (PDT) Received: by mail-oi1-f178.google.com with SMTP id x188so8707349oia.13 for ; Mon, 01 Apr 2019 15:12:19 -0700 (PDT) X-Received: by 2002:aca:48d0:: with SMTP id v199mr4315301oia.51.1554156739290; Mon, 01 Apr 2019 15:12:19 -0700 (PDT) MIME-Version: 1.0 References: <20190329140014.8126-1-laurentiu.tudor@nxp.com> <20190329140014.8126-7-laurentiu.tudor@nxp.com> In-Reply-To: <20190329140014.8126-7-laurentiu.tudor@nxp.com> From: Li Yang Date: Mon, 1 Apr 2019 17:12:07 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 06/13] soc/fsl/qbman_portals: add APIs to retrieve the probing status To: Laurentiu Tudor X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190401_151221_973796_2DA275BE X-CRM114-Status: GOOD ( 26.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: madalin.bucur@nxp.com, Netdev , Roy Pledge , lkml , Linux IOMMU , camelia.groza@nxp.com, linuxppc-dev , David Miller , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Mar 29, 2019 at 9:03 AM wrote: > > From: Laurentiu Tudor > > Add a couple of new APIs to check the probing status of the required > cpu bound qman and bman portals: > 'int bman_portals_probed()' and 'int qman_portals_probed()'. > They return the following values. > * 1 if qman/bman portals were all probed correctly > * 0 if qman/bman portals were not yet probed > * -1 if probing of qman/bman portals failed > Portals are considered successful probed if no error occurred during > the probing of any of the portals and if enough portals were probed > to have one available for each cpu. > The error handling paths were slightly rearranged in order to fit this > new functionality without being too intrusive. > Drivers that use qman/bman portal driver services are required to use > these APIs before calling any functions exported by these drivers or > otherwise they will crash the kernel. > First user will be the dpaa1 ethernet driver, coming in a subsequent > patch. > > Signed-off-by: Laurentiu Tudor > --- > drivers/soc/fsl/qbman/bman_portal.c | 22 ++++++++++++++++++---- > drivers/soc/fsl/qbman/qman_portal.c | 23 +++++++++++++++++++---- > include/soc/fsl/bman.h | 8 ++++++++ > include/soc/fsl/qman.h | 9 +++++++++ > 4 files changed, 54 insertions(+), 8 deletions(-) > > diff --git a/drivers/soc/fsl/qbman/bman_portal.c b/drivers/soc/fsl/qbman/bman_portal.c > index 2c95cf59f3e7..7819bc29936d 100644 > --- a/drivers/soc/fsl/qbman/bman_portal.c > +++ b/drivers/soc/fsl/qbman/bman_portal.c > @@ -32,6 +32,7 @@ > > static struct bman_portal *affine_bportals[NR_CPUS]; > static struct cpumask portal_cpus; > +static int __bman_portals_probed; > /* protect bman global registers and global data shared among portals */ > static DEFINE_SPINLOCK(bman_lock); > > @@ -87,6 +88,12 @@ static int bman_online_cpu(unsigned int cpu) > return 0; > } > > +int bman_portals_probed(void) > +{ > + return __bman_portals_probed; > +} > +EXPORT_SYMBOL_GPL(bman_portals_probed); > + > static int bman_portal_probe(struct platform_device *pdev) > { > struct device *dev = &pdev->dev; > @@ -104,8 +111,10 @@ static int bman_portal_probe(struct platform_device *pdev) > } > > pcfg = devm_kmalloc(dev, sizeof(*pcfg), GFP_KERNEL); > - if (!pcfg) > + if (!pcfg) { > + __bman_portals_probed = -1; > return -ENOMEM; > + } > > pcfg->dev = dev; > > @@ -113,14 +122,14 @@ static int bman_portal_probe(struct platform_device *pdev) > DPAA_PORTAL_CE); > if (!addr_phys[0]) { > dev_err(dev, "Can't get %pOF property 'reg::CE'\n", node); > - return -ENXIO; > + goto err_ioremap1; > } > > addr_phys[1] = platform_get_resource(pdev, IORESOURCE_MEM, > DPAA_PORTAL_CI); > if (!addr_phys[1]) { > dev_err(dev, "Can't get %pOF property 'reg::CI'\n", node); > - return -ENXIO; > + goto err_ioremap1; > } > > pcfg->cpu = -1; > @@ -128,7 +137,7 @@ static int bman_portal_probe(struct platform_device *pdev) > irq = platform_get_irq(pdev, 0); > if (irq <= 0) { > dev_err(dev, "Can't get %pOF IRQ'\n", node); > - return -ENXIO; > + goto err_ioremap1; > } > pcfg->irq = irq; > > @@ -156,6 +165,9 @@ static int bman_portal_probe(struct platform_device *pdev) > } > > cpumask_set_cpu(cpu, &portal_cpus); > + if (!__bman_portals_probed && > + cpumask_weight(&portal_cpus) == num_online_cpus()) > + __bman_portals_probed = 1; Given the fact that the portal_cpus bit will get set even for offline cpus, this is not correct either. Probably the previous code for checking cpu >= nr_cpu_ids is actually the right way to do it. > spin_unlock(&bman_lock); > pcfg->cpu = cpu; > > @@ -175,6 +187,8 @@ static int bman_portal_probe(struct platform_device *pdev) > err_ioremap2: > memunmap(pcfg->addr_virt_ce); > err_ioremap1: > + __bman_portals_probed = -1; > + > return -ENXIO; > } > > diff --git a/drivers/soc/fsl/qbman/qman_portal.c b/drivers/soc/fsl/qbman/qman_portal.c > index bce56da2b01f..11ba6c77c0d6 100644 > --- a/drivers/soc/fsl/qbman/qman_portal.c > +++ b/drivers/soc/fsl/qbman/qman_portal.c > @@ -39,6 +39,7 @@ EXPORT_SYMBOL(qman_dma_portal); > #define CONFIG_FSL_DPA_PIRQ_FAST 1 > > static struct cpumask portal_cpus; > +static int __qman_portals_probed; > /* protect qman global registers and global data shared among portals */ > static DEFINE_SPINLOCK(qman_lock); > > @@ -221,6 +222,12 @@ static int qman_online_cpu(unsigned int cpu) > return 0; > } > > +int qman_portals_probed(void) > +{ > + return __qman_portals_probed; > +} > +EXPORT_SYMBOL_GPL(qman_portals_probed); > + > static int qman_portal_probe(struct platform_device *pdev) > { > struct device *dev = &pdev->dev; > @@ -240,8 +247,10 @@ static int qman_portal_probe(struct platform_device *pdev) > } > > pcfg = devm_kmalloc(dev, sizeof(*pcfg), GFP_KERNEL); > - if (!pcfg) > + if (!pcfg) { > + __qman_portals_probed = -1; > return -ENOMEM; > + } > > pcfg->dev = dev; > > @@ -249,19 +258,20 @@ static int qman_portal_probe(struct platform_device *pdev) > DPAA_PORTAL_CE); > if (!addr_phys[0]) { > dev_err(dev, "Can't get %pOF property 'reg::CE'\n", node); > - return -ENXIO; > + goto err_ioremap1; > } > > addr_phys[1] = platform_get_resource(pdev, IORESOURCE_MEM, > DPAA_PORTAL_CI); > if (!addr_phys[1]) { > dev_err(dev, "Can't get %pOF property 'reg::CI'\n", node); > - return -ENXIO; > + goto err_ioremap1; > } > > err = of_property_read_u32(node, "cell-index", &val); > if (err) { > dev_err(dev, "Can't get %pOF property 'cell-index'\n", node); > + __qman_portals_probed = -1; > return err; > } > pcfg->channel = val; > @@ -269,7 +279,7 @@ static int qman_portal_probe(struct platform_device *pdev) > irq = platform_get_irq(pdev, 0); > if (irq <= 0) { > dev_err(dev, "Can't get %pOF IRQ\n", node); > - return -ENXIO; > + goto err_ioremap1; > } > pcfg->irq = irq; > > @@ -314,6 +324,9 @@ static int qman_portal_probe(struct platform_device *pdev) > } > > cpumask_set_cpu(cpu, &portal_cpus); > + if (!__qman_portals_probed && > + cpumask_weight(&portal_cpus) == num_online_cpus()) > + __qman_portals_probed = 1; > spin_unlock(&qman_lock); > pcfg->cpu = cpu; > > @@ -338,6 +351,8 @@ static int qman_portal_probe(struct platform_device *pdev) > err_ioremap2: > memunmap(pcfg->addr_virt_ce); > err_ioremap1: > + __qman_portals_probed = -1; > + > return -ENXIO; > } > > diff --git a/include/soc/fsl/bman.h b/include/soc/fsl/bman.h > index 5b99cb2ea5ef..173e4049d963 100644 > --- a/include/soc/fsl/bman.h > +++ b/include/soc/fsl/bman.h > @@ -133,5 +133,13 @@ int bman_acquire(struct bman_pool *pool, struct bm_buffer *bufs, u8 num); > * failed to probe or 0 if the bman driver did not probed yet. > */ > int bman_is_probed(void); > +/** > + * bman_portals_probed - Check if all cpu bound bman portals are probed > + * > + * Returns 1 if all the required cpu bound bman portals successfully probed, > + * -1 if probe errors appeared or 0 if the bman portals did not yet finished > + * probing. > + */ > +int bman_portals_probed(void); > > #endif /* __FSL_BMAN_H */ > diff --git a/include/soc/fsl/qman.h b/include/soc/fsl/qman.h > index 5cc7af06c1ba..aa31c05a103a 100644 > --- a/include/soc/fsl/qman.h > +++ b/include/soc/fsl/qman.h > @@ -1194,6 +1194,15 @@ int qman_release_cgrid(u32 id); > */ > int qman_is_probed(void); > > +/** > + * qman_portals_probed - Check if all cpu bound qman portals are probed > + * > + * Returns 1 if all the required cpu bound qman portals successfully probed, > + * -1 if probe errors appeared or 0 if the qman portals did not yet finished > + * probing. > + */ > +int qman_portals_probed(void); > + > /** > * qman_dqrr_get_ithresh - Get coalesce interrupt threshold > * @portal: portal to get the value for > -- > 2.17.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel