Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2530687imm; Wed, 3 Oct 2018 05:28:04 -0700 (PDT) X-Google-Smtp-Source: ACcGV63t0a7NI/Cx/9Rh9a5wGg4fXqOF7D4arzyVIjoyz6jEXzLXAaiIqPf/xttMstC4ZxBhdTXw X-Received: by 2002:a62:670a:: with SMTP id b10-v6mr1346676pfc.243.1538569684136; Wed, 03 Oct 2018 05:28:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538569684; cv=none; d=google.com; s=arc-20160816; b=pYk4U5biScGpmQGf/l1xb04lxSH8LdIJqvLSi/eRObN4zh8Rv/tuQnyTRClKNIdHUc VHWUj0NsYRGZZHdjlo1jWGuKAd7+cgyyRzKOyE+o8eOQAunlWVQQInUUCPJFhSCt5r6r cy/ckGCequ8hZFNHXUdNgoFO4s8h/LC0ixhOODZVAxE4IlVLa8hOCyviVBeOW5H+zJJZ 3OYrTkEpJbS4KJUyg60Tb1LLAcrLIrqIuIiVI1o9GNUOWl7pRhpwplGFRpKAp36B5yXR d7OlOmGPKUPFNbyhH5H64tccD5gHCzCFqAMpRi74mhgBCLshZdMZl0qAZVibJJvBRRh3 52JQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=DPgQEg4rdfNZKIoR6fim2SgRNYHreWU8GEFnwmciBeM=; b=MZ/jv647tsi1ZEdEQKxBZv2pmgZ6v2NUn1J7ZtlOgtRcI0K1AjeQ02MSJ48oBvIddL qWIh9lLN3H+UP3xlHdP9+cxvoqO4DDMQhKgzq52FrZfqIdqS9Vt8VMxRCH/Vt964P3A6 7H5BbX3J4QBtcPikJzplH7Evr16X2tzvzDnBGkP9slRBGcMIia8Bto4IGRsEpUfUwOo6 H6ZK7Lm+rhrelqZOZh3a+Fw50LTunR6UfK3OTPu5dOJIpFfx6g81bQ4LlfvdLZmup/eb 6ATQ19hADiqL/PmzbNNhT+d6WjkHZV33WPO3me6rdH1j/nEPeF3dmdIKRQYHCH0lY9wZ 2v5Q== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d14-v6si1073333pgl.258.2018.10.03.05.27.48; Wed, 03 Oct 2018 05:28:04 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727120AbeJCTPt (ORCPT + 99 others); Wed, 3 Oct 2018 15:15:49 -0400 Received: from foss.arm.com ([217.140.101.70]:50622 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726619AbeJCTPs (ORCPT ); Wed, 3 Oct 2018 15:15:48 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E1C5A18A; Wed, 3 Oct 2018 05:27:36 -0700 (PDT) Received: from [10.1.31.205] (desktop-vlo843j.cambridge.arm.com [10.1.31.205]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B1B663F5B7; Wed, 3 Oct 2018 05:27:34 -0700 (PDT) Subject: Re: [PATCH v2 08/22] soc/fsl/qbman_portals: add APIs to retrieve the probing status To: Laurentiu Tudor , Leo Li Cc: "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Netdev , lkml , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" , Roy Pledge , Madalin-cristian Bucur , David Miller , Shawn Guo , Bharat Bhushan References: <20180926132247.10971-1-laurentiu.tudor@nxp.com> <20180926132247.10971-9-laurentiu.tudor@nxp.com> From: Robin Murphy Message-ID: <37ad85d7-6540-60de-6d47-66f57fa3473a@arm.com> Date: Wed, 3 Oct 2018 13:27:34 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-10-03 11:50 AM, Laurentiu Tudor wrote: > Hi Leo, > > On 27.09.2018 23:03, Li Yang wrote: >> On Wed, Sep 26, 2018 at 8:26 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 >>> 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 | 10 ++++++++++ >>> drivers/soc/fsl/qbman/qman_portal.c | 10 ++++++++++ >>> include/soc/fsl/bman.h | 8 ++++++++ >>> include/soc/fsl/qman.h | 9 +++++++++ >>> 4 files changed, 37 insertions(+) >>> >>> diff --git a/drivers/soc/fsl/qbman/bman_portal.c b/drivers/soc/fsl/qbman/bman_portal.c >>> index f9edd28894fd..8048d35de8a2 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); >>> >>> @@ -85,6 +86,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; >>> @@ -148,6 +155,7 @@ static int bman_portal_probe(struct platform_device *pdev) >>> spin_lock(&bman_lock); >>> cpu = cpumask_next_zero(-1, &portal_cpus); >>> if (cpu >= nr_cpu_ids) { >>> + __bman_portals_probed = 1; >> >> What if the last CPU is not used for portals? Is there a hard >> requirement that all CPUs need to be used for portal? > > As far as I know, in the current driver design a portal is required for > each CPU. > >> What happens if the last CPU is offline? > > Can this happen at probe time? As I understand things, yes - if you boot with "maxcpus=1", only the boot CPU will be onlined by the kernel, but the others can still be brought up manually by userspace later. Robin. > Anyway, I'm not sure that the driver is even aware of cpu hotplug but > I'll let Roy comment on this one. > >> >>> /* unassigned portal, skip init */ >>> spin_unlock(&bman_lock); >>> return 0; >>> @@ -173,6 +181,8 @@ static int bman_portal_probe(struct platform_device *pdev) >>> err_ioremap2: >>> memunmap(pcfg->addr_virt_ce); >>> err_ioremap1: >>> + __bman_portals_probed = 1; >>> + >> >> There are other error paths that not covered. > > Right, thanks for pointing. On top of that, the assigned value here > should be -1 to signal error (instead of 1 which signals success). > > --- > Best Regards, Laurentiu >