Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3515662pxa; Wed, 26 Aug 2020 02:29:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz66Fw16mMJWNA70cURvXiOgR/9RfsFLphLzn2UiQDBxkIGxxFKybQ8BShpgye6tgbiw8km X-Received: by 2002:a17:906:fb01:: with SMTP id lz1mr11134131ejb.447.1598434156263; Wed, 26 Aug 2020 02:29:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598434156; cv=none; d=google.com; s=arc-20160816; b=qoeEkMKyvIAZdmeAVMiSqgbFRp9kyhhUfFDy0UG6Ln8y3N6T2veDYkeSdGtE5Zl+BX Ged2QgcKotz85rk6MVWUA6xTvzQLbrNdjJXFDsdSAjEaRYTnR9+ZhL0HHwBJXA0zd2FN I+Dv25qKaVQwDALDFCb9ayakkRQwp1iLtFx3pXI27oY3MEkXlInX9/LEcFdoFClTkoVw WkNFx8VnQSIpAcZfPTxHMwxjoW1PfM/GnHAguIsEBpjGJ8dYKtxs0Z/4OIkqdI3T7GOW H4MpFUaGpZI7a1MkUODdtffY8KmToFeQxLJw6mL3lOS5Y1H29ZnatVzOTDNoO6pnZefM q99A== 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=cNeSp1g1O8RPT5qnVKg9RVnsNfrwAlhctfLOe5CIgJ4=; b=CFr+m/yQ7cIPXklwK1Tn6/A7eq8HGbM2AJR3GQbm7GO6wbVJtKDbgoGVWeVKndtO+u apoLi//6zaBpvxKWuQ6GKeLiJLZH2B/Evqf0jnXSb7MmP4I3gglzW+chQq4ug8vDE+iy GOKPFu+DdkF9NNAorWFOw0FmmjIBNh7SgBI+dDmaI9Z/L7ArAsz3ThRIlMekw3wUF9lY mGe9XeHzFL4rWtV4Qo5HcBoulOPLDosJ0aKUegP1cyzFE7U9/XxOfpfUND6xSAsbHsBv mqu3KW7HIKYWMDMcEbC2PT5/2gVyAPV6hXCGNW+zhoecZjj+RjWXgdL26yVRs6bT51ka uCEA== 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 q12si1047590edw.294.2020.08.26.02.28.53; Wed, 26 Aug 2020 02:29:16 -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 S1728183AbgHZJ1T (ORCPT + 99 others); Wed, 26 Aug 2020 05:27:19 -0400 Received: from inva020.nxp.com ([92.121.34.13]:56472 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728004AbgHZJ0J (ORCPT ); Wed, 26 Aug 2020 05:26:09 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id EDB281A16BA; Wed, 26 Aug 2020 11:26:05 +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 E0A091A1559; Wed, 26 Aug 2020 11:26:05 +0200 (CEST) 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 8A5A7202CA; Wed, 26 Aug 2020 11:26:05 +0200 (CEST) From: Diana Craciun To: linux-kernel@vger.kernel.org, laurentiu.tudor@nxp.com Cc: stuyoder@gmail.com, leoyang.li@nxp.com, gregkh@linuxfoundation.org, linux-arm-kernel@lists.infradead.org, bharatb.linux@gmail.com, Diana Craciun Subject: [PATCH v4 09/13] bus/fsl-mc: Add a container setup function Date: Wed, 26 Aug 2020 12:25:23 +0300 Message-Id: <20200826092527.4992-10-diana.craciun@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200826092527.4992-1-diana.craciun@oss.nxp.com> References: <20200826092527.4992-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 Both DPRC driver and VFIO driver use the same initialization code for the DPRC. Introduced a new function which groups this initialization code. The function is exported and may be used by VFIO as well. Signed-off-by: Diana Craciun --- drivers/bus/fsl-mc/dprc-driver.c | 65 ++++++++++++++++++++++---------- include/linux/fsl/mc.h | 2 + 2 files changed, 48 insertions(+), 19 deletions(-) diff --git a/drivers/bus/fsl-mc/dprc-driver.c b/drivers/bus/fsl-mc/dprc-driver.c index 6d7b9412fb77..471386e9b46c 100644 --- a/drivers/bus/fsl-mc/dprc-driver.c +++ b/drivers/bus/fsl-mc/dprc-driver.c @@ -588,16 +588,15 @@ static int dprc_setup_irq(struct fsl_mc_device *mc_dev) } /** - * dprc_probe - callback invoked when a DPRC is being bound to this driver + * dprc_setup - opens and creates a mc_io for DPRC * * @mc_dev: Pointer to fsl-mc device representing a DPRC * * It opens the physical DPRC in the MC. - * It scans the DPRC to discover the MC objects contained in it. - * It creates the interrupt pool for the MC bus associated with the DPRC. - * It configures the interrupts for the DPRC device itself. + * It configures the DPRC portal used to communicate with MC */ -static int dprc_probe(struct fsl_mc_device *mc_dev) + +int dprc_setup(struct fsl_mc_device *mc_dev) { int error; size_t region_size; @@ -681,35 +680,63 @@ static int dprc_probe(struct fsl_mc_device *mc_dev) goto error_cleanup_open; } + return 0; + +error_cleanup_open: + (void)dprc_close(mc_dev->mc_io, 0, mc_dev->mc_handle); + +error_cleanup_msi_domain: + if (msi_domain_set) + dev_set_msi_domain(&mc_dev->dev, NULL); + + if (mc_io_created) { + fsl_destroy_mc_io(mc_dev->mc_io); + mc_dev->mc_io = NULL; + } + + return error; +} +EXPORT_SYMBOL_GPL(dprc_setup); + +/** + * dprc_probe - callback invoked when a DPRC is being bound to this driver + * + * @mc_dev: Pointer to fsl-mc device representing a DPRC + * + * It opens the physical DPRC in the MC. + * It scans the DPRC to discover the MC objects contained in it. + * It creates the interrupt pool for the MC bus associated with the DPRC. + * It configures the interrupts for the DPRC device itself. + */ +static int dprc_probe(struct fsl_mc_device *mc_dev) +{ + int error; + + error = dprc_setup(mc_dev); + if (error < 0) + return error; + /* * Discover MC objects in DPRC object: */ error = dprc_scan_container(mc_dev, true); if (error < 0) - goto error_cleanup_open; + goto dprc_cleanup; /* * Configure interrupt for the DPRC object associated with this MC bus: */ error = dprc_setup_irq(mc_dev); if (error < 0) - goto error_cleanup_open; + goto scan_cleanup; dev_info(&mc_dev->dev, "DPRC device bound to driver"); return 0; -error_cleanup_open: - (void)dprc_close(mc_dev->mc_io, 0, mc_dev->mc_handle); - -error_cleanup_msi_domain: - if (msi_domain_set) - dev_set_msi_domain(&mc_dev->dev, NULL); - - if (mc_io_created) { - fsl_destroy_mc_io(mc_dev->mc_io); - mc_dev->mc_io = NULL; - } - +scan_cleanup: + device_for_each_child(&mc_dev->dev, NULL, __fsl_mc_device_remove); +dprc_cleanup: + dprc_cleanup(mc_dev); return error; } diff --git a/include/linux/fsl/mc.h b/include/linux/fsl/mc.h index 5519a510b8c9..e99d181ee4cd 100644 --- a/include/linux/fsl/mc.h +++ b/include/linux/fsl/mc.h @@ -540,6 +540,8 @@ void dprc_remove_devices(struct fsl_mc_device *mc_bus_dev, int dprc_cleanup(struct fsl_mc_device *mc_dev); +int dprc_setup(struct fsl_mc_device *mc_dev); + /* * Data Path Buffer Pool (DPBP) API * Contains initialization APIs and runtime control APIs for DPBP -- 2.17.1