Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp2080315ybh; Fri, 17 Jul 2020 08:49:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6kdeE7O6nw+65Wl+D2J845q1XCBrXYBCA7hm2j/sbVNwFg2ufcTC37bhWUn93wrYBtcP/ X-Received: by 2002:a05:6402:1ac4:: with SMTP id ba4mr9500724edb.60.1595000955970; Fri, 17 Jul 2020 08:49:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595000955; cv=none; d=google.com; s=arc-20160816; b=ZqKYDScYOyJo0Uxaz+6YFxQszMtF9jEHPh3pDLCfc97vSsoNnRtg6yT0FuuxSGvM/r KsH5NhO8YtLPP8mW06JrcxwUQyuUXG2cTTiub40eRG1zEiJMlCV+V0B9IYF/6wiBLUA5 LcJhNopLU5Yu6328zl/JpGIyqnfKaKwe3Q0N856iE/DmMcAb8CW3N2ypTbkpdpG2ztTW dJR2IjbwSlTjlfWesHw31AFm6+KUgLu/zqavLFh/IaU1o2PbzsvigT4VlQ/0j6tzJECg BgM4SNiiJjon2rlnN1WGd19M8KOVmsEE6Z8XdehDaZhbelBw7vMknKu4AagNPAHJG0Zu P1zA== 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=iUPnOOaH65ycD+gmZnKy6uZq60Mhr2tKGy8wM+PrVvo=; b=AUqmV5Yb3wlhOwmAA/TW3Msh+4YR93O4/+77FdixPQjzNMjMiJbZTVCO3U+RAa6epW LeV/nWWyJKMnh201qDa1y8k1RfOULHBE4mRQ+OJC2K2MOWKLHSLnulZOWwU/+LFAsR1v 8bBdJmRt3dKNhFsSAM1kOEmyh01BgnTY3bChRzV2blKNoyCFSYW9giMbv+HbTZr3o6Ym KGz1skNafqDMITiYjr7OaaRJdgpmIzVSQueVULs0ss1ur63Y9z1uZFrIsQSRBQb3PdU4 CbCiC4szPd0vF4G1yr0TuXNE9YYNE6vjhe3J1oh1yCMe9j269PW3K+QOwlb3HtJ3XdbQ wMUg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id v13si3298047ejb.285.2020.07.17.08.48.52; Fri, 17 Jul 2020 08:49:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726763AbgGQPsK (ORCPT + 99 others); Fri, 17 Jul 2020 11:48:10 -0400 Received: from inva020.nxp.com ([92.121.34.13]:40588 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726424AbgGQPsJ (ORCPT ); Fri, 17 Jul 2020 11:48:09 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 41EC41A0906; Fri, 17 Jul 2020 17:48:08 +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 3521A1A026D; Fri, 17 Jul 2020 17:48:08 +0200 (CEST) Received: from fsr-ub1864-126.ea.freescale.net (fsr-ub1864-126.ea.freescale.net [10.171.82.212]) by inva024.eu-rdc02.nxp.com (Postfix) with ESMTP id E581020466; Fri, 17 Jul 2020 17:48:07 +0200 (CEST) From: Ioana Ciornei To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org Cc: laurentiu.tudor@nxp.com, Grigore Popescu , Ioana Ciornei Subject: [PATCH 3/3] bus: fsl-mc: probe the allocatable objects first Date: Fri, 17 Jul 2020 18:48:00 +0300 Message-Id: <20200717154800.17169-4-ioana.ciornei@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200717154800.17169-1-ioana.ciornei@nxp.com> References: <20200717154800.17169-1-ioana.ciornei@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: Grigore Popescu Because the DPNIs are probed before DPMCPs and other objects that need to be allocated, messages like "No more resources of type X left" are printed by the fsl-mc bus driver. This patch resolves the issue by probing the allocatable objects first and then any other object that may use them. Signed-off-by: Grigore Popescu Signed-off-by: Ioana Ciornei --- drivers/bus/fsl-mc/dprc-driver.c | 57 ++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 17 deletions(-) diff --git a/drivers/bus/fsl-mc/dprc-driver.c b/drivers/bus/fsl-mc/dprc-driver.c index c8b1c3842c1a..3512d1b95821 100644 --- a/drivers/bus/fsl-mc/dprc-driver.c +++ b/drivers/bus/fsl-mc/dprc-driver.c @@ -27,7 +27,16 @@ static bool fsl_mc_device_match(struct fsl_mc_device *mc_dev, { return mc_dev->obj_desc.id == obj_desc->id && strcmp(mc_dev->obj_desc.type, obj_desc->type) == 0; +} +static bool fsl_mc_obj_desc_is_allocatable(struct fsl_mc_obj_desc *obj) +{ + if (strcmp(obj->type, "dpmcp") == 0 || + strcmp(obj->type, "dpcon") == 0 || + strcmp(obj->type, "dpbp") == 0) + return true; + else + return false; } static int __fsl_mc_device_remove_if_not_in_mc(struct device *dev, void *data) @@ -150,6 +159,27 @@ static void check_plugged_state_change(struct fsl_mc_device *mc_dev, } } +static void fsl_mc_obj_device_add(struct fsl_mc_device *mc_bus_dev, + struct fsl_mc_obj_desc *obj_desc) +{ + int error; + struct fsl_mc_device *child_dev; + + /* + * Check if device is already known to Linux: + */ + child_dev = fsl_mc_device_lookup(obj_desc, mc_bus_dev); + if (child_dev) { + check_plugged_state_change(child_dev, obj_desc); + put_device(&child_dev->dev); + } else { + error = fsl_mc_device_add(obj_desc, NULL, &mc_bus_dev->dev, + &child_dev); + if (error < 0) + return; + } +} + /** * dprc_add_new_devices - Adds devices to the logical bus for a DPRC * @@ -166,30 +196,23 @@ static void dprc_add_new_devices(struct fsl_mc_device *mc_bus_dev, struct fsl_mc_obj_desc *obj_desc_array, int num_child_objects_in_mc) { - int error; int i; + /* probe the allocable objects first */ for (i = 0; i < num_child_objects_in_mc; i++) { - struct fsl_mc_device *child_dev; struct fsl_mc_obj_desc *obj_desc = &obj_desc_array[i]; - if (strlen(obj_desc->type) == 0) - continue; + if (strlen(obj_desc->type) > 0 && + fsl_mc_obj_desc_is_allocatable(obj_desc)) + fsl_mc_obj_device_add(mc_bus_dev, obj_desc); + } - /* - * Check if device is already known to Linux: - */ - child_dev = fsl_mc_device_lookup(obj_desc, mc_bus_dev); - if (child_dev) { - check_plugged_state_change(child_dev, obj_desc); - put_device(&child_dev->dev); - continue; - } + for (i = 0; i < num_child_objects_in_mc; i++) { + struct fsl_mc_obj_desc *obj_desc = &obj_desc_array[i]; - error = fsl_mc_device_add(obj_desc, NULL, &mc_bus_dev->dev, - &child_dev); - if (error < 0) - continue; + if (strlen(obj_desc->type) > 0 && + !fsl_mc_obj_desc_is_allocatable(obj_desc)) + fsl_mc_obj_device_add(mc_bus_dev, obj_desc); } } -- 2.25.1