Received: by 2002:a25:d783:0:0:0:0:0 with SMTP id o125csp784192ybg; Thu, 19 Mar 2020 08:42:07 -0700 (PDT) X-Google-Smtp-Source: ADFU+vupP+KRFJirBpGVnwXpd1jlEPIuErSv0Rg0FoEtEE8adhzGkgmkYe27LzMrNEmaRy4SNIQS X-Received: by 2002:a05:6830:1e96:: with SMTP id n22mr2745494otr.189.1584632527566; Thu, 19 Mar 2020 08:42:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584632527; cv=none; d=google.com; s=arc-20160816; b=XtE07jgrWFafS4YhxX/7mR698VID/Ff4sgoaQxh/F1roeso0RJifLfV2nvuWGOtNjp yGE+APBe0+CaXBQd9QISFPyJCDfnZUItzgaYEConn6xm5H2mcv7ozI1EaUZdHDr1DxbD 8xJgfF6CycJIjEX5MdNdaI4On9BZT2kNu8QNIwC7iDqHom37U64MvC9HW+aKHMf2IkFi 4ZtQHE3jmBMYvOaOUlW0xG+DOQqmJJ6wGLlZ4CY2OiRW9fH+xqPVVwB/7iobtFydAqnU NSAmMfTCDenrLguj+ApeNcv2epHFE5/LEUyXKN11mt1j7I0aCwRKGnAslOC9HiUxDOX0 Ehhg== 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=tt+sl3q5p1RZA8DbI0tFmtsm8Dgr7B9veA+1ne5L7No=; b=NQTyWsULz/xc+WCdRDPLEfnszp7Mk6jl2p5ONOnUYumYR8p+MddgzyUjMoZYiIdroY VzrxQXKw71+KzxkSs6vThy8yPKSaMTyjTZ33vLx1EGIf0kMcfW8If/tX6vTvveurI5rv dX477SeQYfQ7cBM95NmQXPS2rkE7UFJPwQYcWYMFKCHDCpW7lamX7uTwvLEMj81YX9nf 72CNe+REZEv7v7ezAV03Wi/uL0I9aVldhcmgOw2Rl2g7ZIwDevY0ZnhSvf/dKjpfF94k bsym8oDw6AEPoMV9Fb6qKFtXPZsAM9g3jZHB7h3a9ZuHbUByCZdp1QAuSSzZV4v7Q983 xm/Q== 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 p3si1593310otk.212.2020.03.19.08.41.55; Thu, 19 Mar 2020 08:42:07 -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 S1728224AbgCSPlS (ORCPT + 99 others); Thu, 19 Mar 2020 11:41:18 -0400 Received: from inva021.nxp.com ([92.121.34.21]:51868 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728133AbgCSPlO (ORCPT ); Thu, 19 Mar 2020 11:41:14 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 336842000DB; Thu, 19 Mar 2020 16:41:12 +0100 (CET) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 2666D2000C2; Thu, 19 Mar 2020 16:41:12 +0100 (CET) Received: from fsr-ub1864-111.ea.freescale.net (fsr-ub1864-111.ea.freescale.net [10.171.82.141]) by inva024.eu-rdc02.nxp.com (Postfix) with ESMTP id CCF60205C2; Thu, 19 Mar 2020 16:41:11 +0100 (CET) From: Diana Craciun To: linux-kernel@vger.kernel.org, laurentiu.tudor@nxp.com, stuyoder@gmail.com, leoyang.li@nxp.com, linux-arm-kernel@lists.infradead.org, bharatb.yadav@gmail.com Cc: Diana Craciun Subject: [PATCH 07/10] bus/fsl-mc: Export a dprc scan function to be used by multiple entities Date: Thu, 19 Mar 2020 17:40:48 +0200 Message-Id: <20200319154051.30609-8-diana.craciun@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200319154051.30609-1-diana.craciun@oss.nxp.com> References: <20200319154051.30609-1-diana.craciun@oss.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 Currently the DPRC scan function is used only by the bus driver. But the same functionality will be needed by the VFIO driver. To support this, the dprc scan function was exported and a little bit adjusted to fit both scenarios. Signed-off-by: Diana Craciun --- drivers/bus/fsl-mc/dprc-driver.c | 15 ++++++--------- drivers/bus/fsl-mc/fsl-mc-bus.c | 2 ++ include/linux/fsl/mc.h | 4 ++++ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/bus/fsl-mc/dprc-driver.c b/drivers/bus/fsl-mc/dprc-driver.c index 7eaf78900dfc..789220f0372a 100644 --- a/drivers/bus/fsl-mc/dprc-driver.c +++ b/drivers/bus/fsl-mc/dprc-driver.c @@ -335,7 +335,9 @@ static int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev, * bus driver with the actual state of the MC by adding and removing * devices as appropriate. */ -static int dprc_scan_container(struct fsl_mc_device *mc_bus_dev) +int dprc_scan_container(struct fsl_mc_device *mc_bus_dev, + const char *driver_override, + bool alloc_interrupts) { int error; struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_bus_dev); @@ -346,15 +348,12 @@ static int dprc_scan_container(struct fsl_mc_device *mc_bus_dev) * Discover objects in the DPRC: */ mutex_lock(&mc_bus->scan_mutex); - error = dprc_scan_objects(mc_bus_dev, NULL, true); + error = dprc_scan_objects(mc_bus_dev, driver_override, alloc_interrupts); mutex_unlock(&mc_bus->scan_mutex); - if (error < 0) { - fsl_mc_cleanup_all_resource_pools(mc_bus_dev); - return error; - } return 0; } +EXPORT_SYMBOL_GPL(dprc_scan_container); /** * dprc_irq0_handler - Regular ISR for DPRC interrupt 0 @@ -679,12 +678,10 @@ static int dprc_probe(struct fsl_mc_device *mc_dev) goto error_cleanup_open; } - mutex_init(&mc_bus->scan_mutex); - /* * Discover MC objects in DPRC object: */ - error = dprc_scan_container(mc_dev); + error = dprc_scan_container(mc_dev, NULL, true); if (error < 0) goto error_cleanup_open; diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c b/drivers/bus/fsl-mc/fsl-mc-bus.c index a99a0edef252..1865221bb12d 100644 --- a/drivers/bus/fsl-mc/fsl-mc-bus.c +++ b/drivers/bus/fsl-mc/fsl-mc-bus.c @@ -635,7 +635,9 @@ int fsl_mc_device_add(struct fsl_mc_obj_desc *obj_desc, if (!mc_bus) return -ENOMEM; + mutex_init(&mc_bus->scan_mutex); mc_dev = &mc_bus->mc_dev; + } else { /* * Allocate a regular fsl_mc_device object: diff --git a/include/linux/fsl/mc.h b/include/linux/fsl/mc.h index b9d5e5955adb..2bdd96a482fb 100644 --- a/include/linux/fsl/mc.h +++ b/include/linux/fsl/mc.h @@ -476,6 +476,10 @@ int dprc_reset_container(struct fsl_mc_io *mc_io, u16 token, int child_container_id); +int dprc_scan_container(struct fsl_mc_device *mc_bus_dev, + const char *driver_override, + bool alloc_interrupts); + /* * Data Path Buffer Pool (DPBP) API * Contains initialization APIs and runtime control APIs for DPBP -- 2.17.1