Received: by 2002:a25:d783:0:0:0:0:0 with SMTP id o125csp784114ybg; Thu, 19 Mar 2020 08:42:03 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvmdUFhBXIEePbyYmsIMfT5wg33bJT92lX8kjfG1Fo/1aR0SQdszPD3XL8mCtfuPqqzaxfz X-Received: by 2002:aca:7512:: with SMTP id q18mr2848558oic.71.1584632523083; Thu, 19 Mar 2020 08:42:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584632523; cv=none; d=google.com; s=arc-20160816; b=HtpirRAEzPOFI4REhU4/+QqI8Q6Ri+RLG5BFyit+ewb5yv5L5ThZY6spiSv2aLAdnE df2zzFTBzl4MVrnKIIu0YinZruOCbyPMk0Sg2qE/W1E8nsVt7yvh8+ds6lvn+EunEbB+ vN/nxdwY7WUgsqxRkYMpoLjo4JGUoA0aNOvQNEBRrGoKHAIDmLNP+ci09t5CMtfFTdaW T8zXvB25F9+SzSw/gAFITDQfbvA5004AEiFDRqMXA/yTWXAAhhFBGtIzgF6L7ODQZE1j N0xFKXEIuw0tAYrd2R4ehMgxEK9dvUcN+eg0HhkflZOdciVkLkqynT6uueLxi5foj8PN q2UA== 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=VPMgh2JtrQm1/6g8pY64WOyAeCXD06lKmoeplbB0tww=; b=L0Sdeu1Xd86+CqEL/K64okcxujBSC0E7hgThgZkbJs0ByJxlKpquxyXEYOfvs2fZHa eDuF8qJafZPktCjDK+19zrDF8liQHQOa5QclmTjwU0obhqXZeyLz5Ve8m2dcrb+aJRdI dpEzlLaLeAJL5fFMRgUw5gqisd8WY7Lk8EOJEWMCkkB9motlJs0wmpiLZ59OChMQ2qsw 0nRg33AsyM4+dBD6Q40DXE4iTa1jOj+Y8iqo/+zLwWp8gaQdehhmqbiwwWx/ny8m2rGO +HjnkL5Gqk3YxIc2CSkyx4FAEKIebkGSbo8WvpDY2QpiWYq9YC9EunTiDS+NYUPz7D7K TILw== 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 s199si1162395oih.169.2020.03.19.08.41.50; Thu, 19 Mar 2020 08:42:03 -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 S1728202AbgCSPlR (ORCPT + 99 others); Thu, 19 Mar 2020 11:41:17 -0400 Received: from inva021.nxp.com ([92.121.34.21]:51880 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728157AbgCSPlP (ORCPT ); Thu, 19 Mar 2020 11:41:15 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 8F8F02000E0; 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 8278D2000C2; 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 3503A205C2; Thu, 19 Mar 2020 16:41:12 +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 08/10] bus/fsl-mc: Export a cleanup function for DPRC Date: Thu, 19 Mar 2020 17:40:49 +0200 Message-Id: <20200319154051.30609-9-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 Create and export a cleanup function for DPRC. The function is used by the DPRC driver, but it will be used by the VFIO driver as well. Signed-off-by: Diana Craciun --- drivers/bus/fsl-mc/dprc-driver.c | 52 ++++++++++++++++++++++++-------- include/linux/fsl/mc.h | 2 ++ 2 files changed, 41 insertions(+), 13 deletions(-) diff --git a/drivers/bus/fsl-mc/dprc-driver.c b/drivers/bus/fsl-mc/dprc-driver.c index 789220f0372a..a655e3fee291 100644 --- a/drivers/bus/fsl-mc/dprc-driver.c +++ b/drivers/bus/fsl-mc/dprc-driver.c @@ -725,33 +725,25 @@ static void dprc_teardown_irq(struct fsl_mc_device *mc_dev) } /** - * dprc_remove - callback invoked when a DPRC is being unbound from this driver + * dprc_cleanup - function that cleanups a DPRC * * @mc_dev: Pointer to fsl-mc device representing the DPRC * - * It removes the DPRC's child objects from Linux (not from the MC) and - * closes the DPRC device in the MC. - * It tears down the interrupts that were configured for the DPRC device. + * It closes the DPRC device in the MC. * It destroys the interrupt pool associated with this MC bus. */ -static int dprc_remove(struct fsl_mc_device *mc_dev) + +int dprc_cleanup(struct fsl_mc_device *mc_dev) { int error; struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev); if (!is_fsl_mc_bus_dprc(mc_dev)) return -EINVAL; - if (!mc_dev->mc_io) - return -EINVAL; - if (!mc_bus->irq_resources) + if (!mc_dev->mc_io) return -EINVAL; - if (dev_get_msi_domain(&mc_dev->dev)) - dprc_teardown_irq(mc_dev); - - device_for_each_child(&mc_dev->dev, NULL, __fsl_mc_device_remove); - if (dev_get_msi_domain(&mc_dev->dev)) { fsl_mc_cleanup_irq_pool(mc_bus); dev_set_msi_domain(&mc_dev->dev, NULL); @@ -768,6 +760,40 @@ static int dprc_remove(struct fsl_mc_device *mc_dev) mc_dev->mc_io = NULL; } + return 0; +} +EXPORT_SYMBOL_GPL(dprc_cleanup); + +/** + * dprc_remove - callback invoked when a DPRC is being unbound from this driver + * + * @mc_dev: Pointer to fsl-mc device representing the DPRC + * + * It removes the DPRC's child objects from Linux (not from the MC) and + * closes the DPRC device in the MC. + * It tears down the interrupts that were configured for the DPRC device. + * It destroys the interrupt pool associated with this MC bus. + */ +static int dprc_remove(struct fsl_mc_device *mc_dev) +{ + int error; + struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev); + + if (!is_fsl_mc_bus_dprc(mc_dev)) + return -EINVAL; + + if (!mc_bus->irq_resources) + return -EINVAL; + + if (dev_get_msi_domain(&mc_dev->dev)) + dprc_teardown_irq(mc_dev); + + device_for_each_child(&mc_dev->dev, NULL, __fsl_mc_device_remove); + + error = dprc_cleanup(mc_dev); + if (error < 0) + dev_err(&mc_dev->dev, "dprc_close() failed: %d\n", error); + dev_info(&mc_dev->dev, "DPRC device unbound from driver"); return 0; } diff --git a/include/linux/fsl/mc.h b/include/linux/fsl/mc.h index 2bdd96a482fb..e3ba273a1122 100644 --- a/include/linux/fsl/mc.h +++ b/include/linux/fsl/mc.h @@ -480,6 +480,8 @@ int dprc_scan_container(struct fsl_mc_device *mc_bus_dev, const char *driver_override, bool alloc_interrupts); +int dprc_cleanup(struct fsl_mc_device *mc_dev); + /* * Data Path Buffer Pool (DPBP) API * Contains initialization APIs and runtime control APIs for DPBP -- 2.17.1