Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp700362imm; Wed, 19 Sep 2018 05:39:44 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbkCyD6GbdzYiJLU8zWonJmgZk3wEG1uH8B/q+rQVuEdPy/b98yBrNKZYIseXxh9yGqlmxH X-Received: by 2002:a62:642:: with SMTP id 63-v6mr36276837pfg.42.1537360784735; Wed, 19 Sep 2018 05:39:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537360784; cv=none; d=google.com; s=arc-20160816; b=ZyXpwILq0WjVVhNUy3PXNZ44uwf2LGKnPYJ4fCFYhlkcgJNukqHuNvHgSpL1rfY+Xq wT6oBG7dY19leyqXtWjG93tRNxm2bcPOx9J23+Lio3Gc8vyIq3JyaFIm6JemOZtOBROR ipodyp2J/ECACoPlo7ADf3CGvk3VJOlKoAaUKGbgal6SMDWCXYuZ9jsHPherwX/A40F/ YE9JWvSdINuJPjVrN8gaQbJ5Z+ofSzCHP6yNRhVWSnwvdxTBlNR9iAliDctjsv1YQ+g2 hHFYlpnkXE1qHQ4MfAmBa3HqXJTdABFFF4fX19LfIHvrpjGxY8T3lPZN0N1NNzlcMXei IfZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=JzB0hRbRaS4RNDbI2dSXLt4zO5UpNj4I+nKZLzB+9eU=; b=AAatnXum/vcQR7FdYL8adVw7Tvd1z7mob/A8GDh1aP7fQog2ujslCpbhaSB1TnUO5M nW29OrA28Hf64gMNzO8xt7E7AEqaEWhiTISqaD4of6bgNm6nvXaDpW2QUj/K5XBTLZzm 1EIOxPjlZguhKoTztDFR165RE9Lmmb1ekSb+G8oNfI0VWf8oH4wjXoKQkJf5YoSSpXPf iBxbGbjksEV+BDWlcMlrbGZwHEzRzHGGWWFpXe7m4irhtpI/fZPJp6gb4+LOJu1JcJtH LQXl1o+ymNxQCdarWZn2dVdLC0K9dwUvcs3apWXhhfhN0ilbcj920IBu/YR9+jnRGW2r 6qOA== 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 w133-v6si20892276pfd.313.2018.09.19.05.39.29; Wed, 19 Sep 2018 05:39:44 -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 S1731794AbeISSOP (ORCPT + 99 others); Wed, 19 Sep 2018 14:14:15 -0400 Received: from inva020.nxp.com ([92.121.34.13]:49856 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731507AbeISSOP (ORCPT ); Wed, 19 Sep 2018 14:14:15 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 4BFFA1A01FB; Wed, 19 Sep 2018 14:36:28 +0200 (CEST) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 3F0781A0009; Wed, 19 Sep 2018 14:36:28 +0200 (CEST) Received: from fsr-ub1864-101.ea.freescale.net (fsr-ub1864-101.ea.freescale.net [10.171.82.97]) by inva024.eu-rdc02.nxp.com (Postfix) with ESMTP id F2D6E20618; Wed, 19 Sep 2018 14:36:26 +0200 (CEST) From: laurentiu.tudor@nxp.com To: devicetree@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: roy.pledge@nxp.com, madalin.bucur@nxp.com, davem@davemloft.net, shawnguo@kernel.org, leoyang.li@nxp.com, Laurentiu Tudor Subject: [PATCH 05/21] soc/fsl/qbman: add APIs to retrieve the probing status Date: Wed, 19 Sep 2018 15:35:57 +0300 Message-Id: <20180919123613.15092-6-laurentiu.tudor@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180919123613.15092-1-laurentiu.tudor@nxp.com> References: <20180919123613.15092-1-laurentiu.tudor@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Laurentiu Tudor Add a couple of new APIs to check the probing status of qman and bman: 'int bman_is_probed()' and 'int qman_is_probed()'. They return the following values. * 1 if qman/bman were probed correctly * 0 if qman/bman were not yet probed * -1 if probing of qman/bman failed Drivers that use qman/bman driver services are required to use these APIs before calling any functions exported by qman or bman drivers or otherwise they will crash the kernel. The APIs will be used in the following couple of qbman portal patches and later in the series in the dpaa1 ethernet driver. Signed-off-by: Laurentiu Tudor --- drivers/soc/fsl/qbman/bman_ccsr.c | 11 +++++++++++ drivers/soc/fsl/qbman/qman_ccsr.c | 11 +++++++++++ include/soc/fsl/bman.h | 8 ++++++++ include/soc/fsl/qman.h | 8 ++++++++ 4 files changed, 38 insertions(+) diff --git a/drivers/soc/fsl/qbman/bman_ccsr.c b/drivers/soc/fsl/qbman/bman_ccsr.c index 680f67f04fb4..2c11883d42a5 100644 --- a/drivers/soc/fsl/qbman/bman_ccsr.c +++ b/drivers/soc/fsl/qbman/bman_ccsr.c @@ -121,6 +121,7 @@ static void bm_set_memory(u64 ba, u32 size) */ static dma_addr_t fbpr_a; static size_t fbpr_sz; +static int __bman_probed; static int bman_fbpr(struct reserved_mem *rmem) { @@ -167,6 +168,12 @@ static irqreturn_t bman_isr(int irq, void *ptr) return IRQ_HANDLED; } +int bman_is_probed(void) +{ + return __bman_probed; +} +EXPORT_SYMBOL_GPL(bman_is_probed); + static int fsl_bman_probe(struct platform_device *pdev) { int ret, err_irq; @@ -177,6 +184,8 @@ static int fsl_bman_probe(struct platform_device *pdev) u16 id, bm_pool_cnt; u8 major, minor; + __bman_probed = -1; + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(dev, "Can't get %pOF property 'IORESOURCE_MEM'\n", @@ -267,6 +276,8 @@ static int fsl_bman_probe(struct platform_device *pdev) return ret; } + __bman_probed = 1; + return 0; }; diff --git a/drivers/soc/fsl/qbman/qman_ccsr.c b/drivers/soc/fsl/qbman/qman_ccsr.c index 7163f7511ce1..0bfbe24b479a 100644 --- a/drivers/soc/fsl/qbman/qman_ccsr.c +++ b/drivers/soc/fsl/qbman/qman_ccsr.c @@ -274,6 +274,7 @@ static const struct qman_error_info_mdata error_mdata[] = { static u32 __iomem *qm_ccsr_start; /* A SDQCR mask comprising all the available/visible pool channels */ static u32 qm_pools_sdqcr; +static int __qman_probed; static inline u32 qm_ccsr_in(u32 offset) { @@ -689,6 +690,12 @@ static int qman_resource_init(struct device *dev) return 0; } +int qman_is_probed(void) +{ + return __qman_probed; +} +EXPORT_SYMBOL_GPL(qman_is_probed); + static int fsl_qman_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -699,6 +706,8 @@ static int fsl_qman_probe(struct platform_device *pdev) u16 id; u8 major, minor; + __qman_probed = -1; + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(dev, "Can't get %pOF property 'IORESOURCE_MEM'\n", @@ -847,6 +856,8 @@ static int fsl_qman_probe(struct platform_device *pdev) if (ret) return ret; + __qman_probed = 1; + return 0; } diff --git a/include/soc/fsl/bman.h b/include/soc/fsl/bman.h index eaaf56df4086..5b99cb2ea5ef 100644 --- a/include/soc/fsl/bman.h +++ b/include/soc/fsl/bman.h @@ -126,4 +126,12 @@ int bman_release(struct bman_pool *pool, const struct bm_buffer *bufs, u8 num); */ int bman_acquire(struct bman_pool *pool, struct bm_buffer *bufs, u8 num); +/** + * bman_is_probed - Check if bman is probed + * + * Returns 1 if the bman driver successfully probed, -1 if the bman driver + * failed to probe or 0 if the bman driver did not probed yet. + */ +int bman_is_probed(void); + #endif /* __FSL_BMAN_H */ diff --git a/include/soc/fsl/qman.h b/include/soc/fsl/qman.h index d4dfefdee6c1..597783b8a3a0 100644 --- a/include/soc/fsl/qman.h +++ b/include/soc/fsl/qman.h @@ -1186,4 +1186,12 @@ int qman_alloc_cgrid_range(u32 *result, u32 count); */ int qman_release_cgrid(u32 id); +/** + * qman_is_probed - Check if qman is probed + * + * Returns 1 if the qman driver successfully probed, -1 if the qman driver + * failed to probe or 0 if the qman driver did not probed yet. + */ +int qman_is_probed(void); + #endif /* __FSL_QMAN_H */ -- 2.17.1