Received: by 2002:a25:d783:0:0:0:0:0 with SMTP id o125csp784384ybg; Thu, 19 Mar 2020 08:42:18 -0700 (PDT) X-Google-Smtp-Source: ADFU+vv4ZGy+ffIcL4S3hGmi0igs0+Ick/0k/2BTtfeVW3KKWLkzCahGccIYgva6+upkNT1io8Kc X-Received: by 2002:a05:6830:1190:: with SMTP id u16mr2700950otq.298.1584632537977; Thu, 19 Mar 2020 08:42:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584632537; cv=none; d=google.com; s=arc-20160816; b=h6NhGDdb2f5WlWzDJvASTwgQPWT34qadimRYt6uf+5U3W3hu5g51Ap69XlvQskMKTs 2VMpd7SN4PGJFE/45EWBwcea2IIIIh6B9rmvIK/6iqqdGpj9DCJxOYiIy833JMrCCIYr p/mvJuNWQWCDgutZ2btoytdJbbYGetyPrQr2aTIUOwDcCsvKuUmtqWTh8vhqBhXhX809 MEui7qkSwG51tkxx/bcJ8wmEApkcIW2Nji+Xh29uIjRkDtMjEV9j2715vSDE+IUvXi3m TSOeCJvvX4NurZF5qulGrmORhjjB2w4vIcrxj5aKfeUK2CPv8bs6YPlFqQeIjW8BfV6S 6Zaw== 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=gpIcpW+tfDk1fyw/mgyXyqu1jmvpIzZvdT1hCcq9Jxc=; b=N15po9xk7GbN4dF3upPU/JKlYD2wMhX/o9mMYR8VgHzmKYcjwzburnxdxoQUB8EggH g+vuFUCJ8MELLKV2xvZ+X4bLaHncRR+XcDDogDzt3HVCiNs+3izqfurTybjcaSuYR+27 THpgrkz0osrKCBZwx/r+oX9zTVZstdWjlZH92B5V2k6EsD59Ul29A+IQqQwyeMhSFuzb wxWu2kq+UBoZUvZg0w6gkH5pWKB9tuX7F+UIewEb6ubs2RsRuu6EdNPLQI3ERtCJuBYr Q82jiJLaxxiI9TMdrEPzMRAewpBiLmUkIYu0PoC59lxMGEt2Jgl9cVmYf6ZY/GtP4+df YrHA== 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 c133si1258840oif.272.2020.03.19.08.42.05; Thu, 19 Mar 2020 08:42:17 -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 S1728055AbgCSPlY (ORCPT + 99 others); Thu, 19 Mar 2020 11:41:24 -0400 Received: from inva021.nxp.com ([92.121.34.21]:51848 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728120AbgCSPlO (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 D610C2000C4; Thu, 19 Mar 2020 16:41:11 +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 BE3712000C2; Thu, 19 Mar 2020 16:41:11 +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 68504205C2; 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: Bharat Bhushan , Diana Craciun Subject: [PATCH 06/10] bus/fsl-mc: Add dprc-reset-container support Date: Thu, 19 Mar 2020 17:40:47 +0200 Message-Id: <20200319154051.30609-7-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 From: Bharat Bhushan DPRC reset is required by VFIO-mc in order to stop a device to further generate DMA transactions. Signed-off-by: Bharat Bhushan Signed-off-by: Laurentiu Tudor Signed-off-by: Diana Craciun --- drivers/bus/fsl-mc/dprc.c | 41 +++++++++++++++++++++++++++++ drivers/bus/fsl-mc/fsl-mc-private.h | 5 ++++ include/linux/fsl/mc.h | 5 ++++ 3 files changed, 51 insertions(+) diff --git a/drivers/bus/fsl-mc/dprc.c b/drivers/bus/fsl-mc/dprc.c index 602f030d84eb..5ae17fd957ba 100644 --- a/drivers/bus/fsl-mc/dprc.c +++ b/drivers/bus/fsl-mc/dprc.c @@ -72,6 +72,47 @@ int dprc_close(struct fsl_mc_io *mc_io, } EXPORT_SYMBOL_GPL(dprc_close); +/** + * dprc_reset_container - Reset child container. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPRC object + * @child_container_id: ID of the container to reset + * + * In case a software context crashes or becomes non-responsive, the parent + * may wish to reset its resources container before the software context is + * restarted. + * + * This routine informs all objects assigned to the child container that the + * container is being reset, so they may perform any cleanup operations that are + * needed. All objects handles that were owned by the child container shall be + * closed. + * + * Note that such request may be submitted even if the child software context + * has not crashed, but the resulting object cleanup operations will not be + * aware of that. + * + * Return: '0' on Success; Error code otherwise. + */ +int dprc_reset_container(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 token, + int child_container_id) +{ + struct fsl_mc_command cmd = { 0 }; + struct dprc_cmd_reset_container *cmd_params; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPRC_CMDID_RESET_CONT, + cmd_flags, token); + cmd_params = (struct dprc_cmd_reset_container *)cmd.params; + cmd_params->child_container_id = cpu_to_le32(child_container_id); + + /* send command to mc*/ + return mc_send_command(mc_io, &cmd); +} +EXPORT_SYMBOL_GPL(dprc_reset_container); + /** * dprc_set_irq() - Set IRQ information for the DPRC to trigger an interrupt. * @mc_io: Pointer to MC portal's I/O object diff --git a/drivers/bus/fsl-mc/fsl-mc-private.h b/drivers/bus/fsl-mc/fsl-mc-private.h index 81b9a9b16698..66ccf7fb34af 100644 --- a/drivers/bus/fsl-mc/fsl-mc-private.h +++ b/drivers/bus/fsl-mc/fsl-mc-private.h @@ -92,6 +92,7 @@ int dpmcp_reset(struct fsl_mc_io *mc_io, #define DPRC_CMDID_GET_API_VERSION DPRC_CMD(0xa05) #define DPRC_CMDID_GET_ATTR DPRC_CMD(0x004) +#define DPRC_CMDID_RESET_CONT DPRC_CMD(0x005) #define DPRC_CMDID_SET_IRQ DPRC_CMD(0x010) #define DPRC_CMDID_SET_IRQ_ENABLE DPRC_CMD(0x012) @@ -112,6 +113,10 @@ struct dprc_cmd_open { __le32 container_id; }; +struct dprc_cmd_reset_container { + __le32 child_container_id; +}; + struct dprc_cmd_set_irq { /* cmd word 0 */ __le32 irq_val; diff --git a/include/linux/fsl/mc.h b/include/linux/fsl/mc.h index f997f8091408..b9d5e5955adb 100644 --- a/include/linux/fsl/mc.h +++ b/include/linux/fsl/mc.h @@ -471,6 +471,11 @@ static inline bool is_fsl_mc_bus_dpseci(const struct fsl_mc_device *mc_dev) return mc_dev->dev.type == &fsl_mc_bus_dpseci_type; } +int dprc_reset_container(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 token, + int child_container_id); + /* * Data Path Buffer Pool (DPBP) API * Contains initialization APIs and runtime control APIs for DPBP -- 2.17.1