From patchwork Fri Jan 3 10:12:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beleswar Prasad Padhi X-Patchwork-Id: 13925455 Received: from lelvem-ot02.ext.ti.com (lelvem-ot02.ext.ti.com [198.47.23.235]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75B451B0F15; Fri, 3 Jan 2025 10:12:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.235 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899172; cv=none; b=jTZmkVop5te6Ua8yQMnm0s9nshrD2lfvHC3KzZRrMHo/+Vi4Zbgyb0X89zqH/fQOgV3g7DsJE9qBmW0s/RSl2ipsu8dS8TqqpP0dkvMpkGA1urtCGpUQNocv4fwl/SYxi1iDLi9dwIKxr1VJuDrWKLhMqZQ7vAcRB2E9XGEWoDM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899172; c=relaxed/simple; bh=/29MSFbPgQUCCFm0c37xVaMkx8k9/eU3gI33n/h0gt4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OqjmGPT/ZG71OjHZM8CjSZk9CgKOKAdznYpkyEi9y6ppyk20+hHO6+Yb9YJVufpTh9g9CaspXgEel9dGjsFPSFiE7Kb810aBU3UfFfq72lV2po2wwHim7gRzDlTNa/T94rz1htH36F6o74/dNxWo5+zqlxU8J0yaHiBeb3asCbo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=TNpyyh82; arc=none smtp.client-ip=198.47.23.235 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="TNpyyh82" Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelvem-ot02.ext.ti.com (8.15.2/8.15.2) with ESMTPS id 503ACewc2382517 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 3 Jan 2025 04:12:40 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1735899160; bh=SPoqV2eDb292uZt8eTSHqRtT4vsMfk16uFTNAa5m4co=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=TNpyyh82fBMrKT8wBJcHqYqFaSciimkdDZt5ZehgX0HCwUC6q2iPgz48YATSzqs0a wZOZ92VmaBT56Uw5pi1tqvfr1W3IWLfy9BqCOpg2wWwLqlVJJIgguAeyO/s7i/Tx7C c/ONIhbU5kbqLuGpgD/FtQAtf/y5SjA1lCYxAJIg= Received: from DLEE103.ent.ti.com (dlee103.ent.ti.com [157.170.170.33]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 503ACe0d112225 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 3 Jan 2025 04:12:40 -0600 Received: from DLEE105.ent.ti.com (157.170.170.35) by DLEE103.ent.ti.com (157.170.170.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 3 Jan 2025 04:12:39 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Fri, 3 Jan 2025 04:12:39 -0600 Received: from uda0510294.dhcp.ti.com (uda0510294.dhcp.ti.com [172.24.227.151]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 503ACVSJ126047; Fri, 3 Jan 2025 04:12:36 -0600 From: Beleswar Padhi To: , CC: , , , , , , , , , , Subject: [PATCH v8 01/20] remoteproc: k3-m4: Prevent Mailbox level IPC with detached core Date: Fri, 3 Jan 2025 15:42:12 +0530 Message-ID: <20250103101231.1508151-2-b-padhi@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103101231.1508151-1-b-padhi@ti.com> References: <20250103101231.1508151-1-b-padhi@ti.com> Precedence: bulk X-Mailing-List: linux-remoteproc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea Inter-Processor Communication is facilitated through mailbox payloads, which typically contains the index of the triggered virtqueue having the actual data to be consumed, but the payload can also be used for trivial communication, like sending an echo message or notifying a crash etc. When the core is detached, the virtqueues are freed, and thus the Virtio level IPC is not functional. However, Mailbox IPC is still possible with trivial payloads. Therefore, introduce checks in k3_m4_rproc_kick() and k3_m4_rproc_mbox_callback() functions to return early without parsing the payload when core is detached, and is not undergoing an attach operation in IPC-only mode. Signed-off-by: Beleswar Padhi --- drivers/remoteproc/ti_k3_m4_remoteproc.c | 41 ++++++++++++++++++++---- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/drivers/remoteproc/ti_k3_m4_remoteproc.c b/drivers/remoteproc/ti_k3_m4_remoteproc.c index a16fb165fced..3201c3684a86 100644 --- a/drivers/remoteproc/ti_k3_m4_remoteproc.c +++ b/drivers/remoteproc/ti_k3_m4_remoteproc.c @@ -50,6 +50,7 @@ struct k3_m4_rproc_mem_data { /** * struct k3_m4_rproc - k3 remote processor driver structure * @dev: cached device pointer + * @rproc: remoteproc device handle * @mem: internal memory regions data * @num_mems: number of internal memory regions * @rmem: reserved memory regions data @@ -60,9 +61,11 @@ struct k3_m4_rproc_mem_data { * @ti_sci_id: TI-SCI device identifier * @mbox: mailbox channel handle * @client: mailbox client to request the mailbox channel + * @is_attach_ongoing: flag to indicate if IPC-only "attach()" is in progress */ struct k3_m4_rproc { struct device *dev; + struct rproc *rproc; struct k3_m4_rproc_mem *mem; int num_mems; struct k3_m4_rproc_mem *rmem; @@ -73,6 +76,7 @@ struct k3_m4_rproc { u32 ti_sci_id; struct mbox_chan *mbox; struct mbox_client client; + bool is_attach_ongoing; }; /** @@ -93,8 +97,16 @@ static void k3_m4_rproc_mbox_callback(struct mbox_client *client, void *data) { struct device *dev = client->dev; struct rproc *rproc = dev_get_drvdata(dev); + struct k3_m4_rproc *kproc = rproc->priv; u32 msg = (u32)(uintptr_t)(data); + /* + * Do not forward messages from a detached core, except when the core + * is in the process of being attached in IPC-only mode. + */ + if (!kproc->is_attach_ongoing && kproc->rproc->state == RPROC_DETACHED) + return; + dev_dbg(dev, "mbox msg: 0x%x\n", msg); switch (msg) { @@ -135,6 +147,12 @@ static void k3_m4_rproc_kick(struct rproc *rproc, int vqid) u32 msg = (u32)vqid; int ret; + /* + * Do not forward messages to a detached core, except when the core + * is in the process of being attached in IPC-only mode. + */ + if (!kproc->is_attach_ongoing && kproc->rproc->state == RPROC_DETACHED) + return; /* * Send the index of the triggered virtqueue in the mailbox payload. * NOTE: msg is cast to uintptr_t to prevent compiler warnings when @@ -515,15 +533,19 @@ static int k3_m4_rproc_stop(struct rproc *rproc) /* * Attach to a running M4 remote processor (IPC-only mode) * - * The remote processor is already booted, so there is no need to issue any - * TI-SCI commands to boot the M4 core. This callback is used only in IPC-only - * mode. + * This rproc attach callback only needs to set the "is_attach_ongoing" flag to + * notify k3_m4_rproc_{kick/mbox_callback} functions that the core is in the + * process of getting attached in IPC-only mode. The remote processor is already + * booted, so there is no need to issue any TI-SCI commands to boot the M4 core. + * This callback is used only in IPC-only mode. */ static int k3_m4_rproc_attach(struct rproc *rproc) { struct k3_m4_rproc *kproc = rproc->priv; int ret; + kproc->is_attach_ongoing = true; + ret = k3_m4_rproc_ping_mbox(kproc); if (ret) return ret; @@ -534,12 +556,18 @@ static int k3_m4_rproc_attach(struct rproc *rproc) /* * Detach from a running M4 remote processor (IPC-only mode) * - * This rproc detach callback performs the opposite operation to attach - * callback, the M4 core is not stopped and will be left to continue to - * run its booted firmware. This callback is invoked only in IPC-only mode. + * This rproc detach callback performs the opposite operation to attach callback + * and only needs to clear the "is_attach_ongoing" flag to ensure no mailbox + * messages are sent to or received from a detached core. The M4 core is not + * stopped and will be left to continue to run its booted firmware. This + * callback is invoked only in IPC-only mode. */ static int k3_m4_rproc_detach(struct rproc *rproc) { + struct k3_m4_rproc *kproc = rproc->priv; + + kproc->is_attach_ongoing = false; + return 0; } @@ -577,6 +605,7 @@ static int k3_m4_rproc_probe(struct platform_device *pdev) rproc->has_iommu = false; rproc->recovery_disabled = true; kproc = rproc->priv; + kproc->rproc = rproc; kproc->dev = dev; platform_set_drvdata(pdev, rproc); From patchwork Fri Jan 3 10:12:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beleswar Prasad Padhi X-Patchwork-Id: 13925456 Received: from fllvem-ot03.ext.ti.com (fllvem-ot03.ext.ti.com [198.47.19.245]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D00CA1AA1C4; Fri, 3 Jan 2025 10:12:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.245 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899179; cv=none; b=EMaND/TyZSDAl3vX1lEeRosmVJUMueTDG6AEnY8EvKo8Cn3XsmrVl477PP0BgBri9kmAys2ioB7gAaZ9IqjloZnU7pmZg1GTwF4RoeatW/v0r1gHTYyTPHlT5HR5eO5qxRBrD9kqd/W8sf8r8TEkRsiRN8gULnKSzeMbNKLKdj8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899179; c=relaxed/simple; bh=1xrsul6mWUfeY7v3QeDuawa4NM8rB5KbDK5aNG+L0Kc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YhxLedcwHRxCltcMQFVCBCrWN/Vfm7Ioe1jI8iApt7XfE5kcDsZPE4BNjd3vyso1IhCLm7f3ByA95tD5yFH0J2y0K/Z8xOnk8ahUg3bT26OOS5BdwAl1roWsdZXYepWQpjmS5gR4NEoik1XZzLd/dmCRUtsjjHePIYULcNPdvKc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=f9VPxqD8; arc=none smtp.client-ip=198.47.19.245 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="f9VPxqD8" Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllvem-ot03.ext.ti.com (8.15.2/8.15.2) with ESMTPS id 503ACh7E2019393 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 3 Jan 2025 04:12:43 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1735899163; bh=SBV1OsWQ7+r/n2HtEto3x74O2ImMh4Yh7VsMQ0rS9ak=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=f9VPxqD8TZAgnfuWyD/ECZb3Oowx1wiS5+ybNz7W3FGXzyd2HMstkbLZgvuBND2ra LEfETea51jdid0oy8oExckLgvfAuc9dzxnWteFohEAtOCHxJicnzzOPXeuheggl7GF 1f3j6zM9LN+lM5t3//QDtESmALWrOynCPiyvXz4o= Received: from DFLE111.ent.ti.com (dfle111.ent.ti.com [10.64.6.32]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTP id 503AChCF041836; Fri, 3 Jan 2025 04:12:43 -0600 Received: from DFLE110.ent.ti.com (10.64.6.31) by DFLE111.ent.ti.com (10.64.6.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 3 Jan 2025 04:12:43 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE110.ent.ti.com (10.64.6.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Fri, 3 Jan 2025 04:12:43 -0600 Received: from uda0510294.dhcp.ti.com (uda0510294.dhcp.ti.com [172.24.227.151]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 503ACVSK126047; Fri, 3 Jan 2025 04:12:40 -0600 From: Beleswar Padhi To: , CC: , , , , , , , , , , Subject: [PATCH v8 02/20] remoteproc: k3: Refactor shared data structures Date: Fri, 3 Jan 2025 15:42:13 +0530 Message-ID: <20250103101231.1508151-3-b-padhi@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103101231.1508151-1-b-padhi@ti.com> References: <20250103101231.1508151-1-b-padhi@ti.com> Precedence: bulk X-Mailing-List: linux-remoteproc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea The ti_k3_dsp_remoteproc.c and ti_k3_m4_remoteproc.c drivers share the same data structure definitions. Refactor the shared data structures into a new common header file, 'ti_k3_common.h', and update both drivers to use the unified data structures. Signed-off-by: Beleswar Padhi --- drivers/remoteproc/ti_k3_common.h | 91 ++++++++++++++++ drivers/remoteproc/ti_k3_dsp_remoteproc.c | 124 +++++----------------- drivers/remoteproc/ti_k3_m4_remoteproc.c | 85 +++------------ 3 files changed, 132 insertions(+), 168 deletions(-) create mode 100644 drivers/remoteproc/ti_k3_common.h diff --git a/drivers/remoteproc/ti_k3_common.h b/drivers/remoteproc/ti_k3_common.h new file mode 100644 index 000000000000..9d7ce70bcbf5 --- /dev/null +++ b/drivers/remoteproc/ti_k3_common.h @@ -0,0 +1,91 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * TI K3 Remote Processor(s) driver common code + * + * Refactored out of ti_k3_dsp_remoteproc.c and ti_k3_m4_remoteproc.c. + * + * ti_k3_dsp_remoteproc.c: + * Copyright (C) 2018-2022 Texas Instruments Incorporated - https://www.ti.com/ + * Suman Anna + * + * ti_k3_m4_remoteproc.c: + * Copyright (C) 2021-2024 Texas Instruments Incorporated - https://www.ti.com/ + * Hari Nagalla + */ + +#ifndef REMOTEPROC_TI_K3_COMMON_H +#define REMOTEPROC_TI_K3_COMMON_H + +/** + * struct k3_rproc_mem - internal memory structure + * @cpu_addr: MPU virtual address of the memory region + * @bus_addr: Bus address used to access the memory region + * @dev_addr: Device address of the memory region from remote processor view + * @size: Size of the memory region + */ +struct k3_rproc_mem { + void __iomem *cpu_addr; + phys_addr_t bus_addr; + u32 dev_addr; + size_t size; +}; + +/** + * struct k3_rproc_mem_data - memory definitions for a remote processor + * @name: name for this memory entry + * @dev_addr: device address for the memory entry + */ +struct k3_rproc_mem_data { + const char *name; + const u32 dev_addr; +}; + +/** + * struct k3_rproc_dev_data - device data structure for a remote processor + * @mems: pointer to memory definitions for a remote processor + * @num_mems: number of memory regions in @mems + * @boot_align_addr: boot vector address alignment granularity + * @uses_lreset: flag to denote the need for local reset management + */ +struct k3_rproc_dev_data { + const struct k3_rproc_mem_data *mems; + u32 num_mems; + u32 boot_align_addr; + bool uses_lreset; +}; + +/** + * struct k3_rproc - k3 remote processor driver structure + * @dev: cached device pointer + * @rproc: remoteproc device handle + * @mem: internal memory regions data + * @num_mems: number of internal memory regions + * @rmem: reserved memory regions data + * @num_rmems: number of reserved memory regions + * @reset: reset control handle + * @data: pointer to DSP-specific device data + * @tsp: TI-SCI processor control handle + * @ti_sci: TI-SCI handle + * @ti_sci_id: TI-SCI device identifier + * @mbox: mailbox channel handle + * @client: mailbox client to request the mailbox channel + * @is_attach_ongoing: flag to indicate if IPC-only "attach()" is in progress + */ +struct k3_rproc { + struct device *dev; + struct rproc *rproc; + struct k3_rproc_mem *mem; + int num_mems; + struct k3_rproc_mem *rmem; + int num_rmems; + struct reset_control *reset; + const struct k3_rproc_dev_data *data; + struct ti_sci_proc *tsp; + const struct ti_sci_handle *ti_sci; + u32 ti_sci_id; + struct mbox_chan *mbox; + struct mbox_client client; + bool is_attach_ongoing; +}; + +#endif /* REMOTEPROC_TI_K3_COMMON_H */ diff --git a/drivers/remoteproc/ti_k3_dsp_remoteproc.c b/drivers/remoteproc/ti_k3_dsp_remoteproc.c index f20fc2db077b..41b32af15260 100644 --- a/drivers/remoteproc/ti_k3_dsp_remoteproc.c +++ b/drivers/remoteproc/ti_k3_dsp_remoteproc.c @@ -20,81 +20,10 @@ #include "omap_remoteproc.h" #include "remoteproc_internal.h" #include "ti_sci_proc.h" +#include "ti_k3_common.h" #define KEYSTONE_RPROC_LOCAL_ADDRESS_MASK (SZ_16M - 1) -/** - * struct k3_dsp_mem - internal memory structure - * @cpu_addr: MPU virtual address of the memory region - * @bus_addr: Bus address used to access the memory region - * @dev_addr: Device address of the memory region from DSP view - * @size: Size of the memory region - */ -struct k3_dsp_mem { - void __iomem *cpu_addr; - phys_addr_t bus_addr; - u32 dev_addr; - size_t size; -}; - -/** - * struct k3_dsp_mem_data - memory definitions for a DSP - * @name: name for this memory entry - * @dev_addr: device address for the memory entry - */ -struct k3_dsp_mem_data { - const char *name; - const u32 dev_addr; -}; - -/** - * struct k3_dsp_dev_data - device data structure for a DSP - * @mems: pointer to memory definitions for a DSP - * @num_mems: number of memory regions in @mems - * @boot_align_addr: boot vector address alignment granularity - * @uses_lreset: flag to denote the need for local reset management - */ -struct k3_dsp_dev_data { - const struct k3_dsp_mem_data *mems; - u32 num_mems; - u32 boot_align_addr; - bool uses_lreset; -}; - -/** - * struct k3_dsp_rproc - k3 DSP remote processor driver structure - * @dev: cached device pointer - * @rproc: remoteproc device handle - * @mem: internal memory regions data - * @num_mems: number of internal memory regions - * @rmem: reserved memory regions data - * @num_rmems: number of reserved memory regions - * @reset: reset control handle - * @data: pointer to DSP-specific device data - * @tsp: TI-SCI processor control handle - * @ti_sci: TI-SCI handle - * @ti_sci_id: TI-SCI device identifier - * @mbox: mailbox channel handle - * @client: mailbox client to request the mailbox channel - * @is_attach_ongoing: flag to indicate if IPC-only "attach()" is in progress - */ -struct k3_dsp_rproc { - struct device *dev; - struct rproc *rproc; - struct k3_dsp_mem *mem; - int num_mems; - struct k3_dsp_mem *rmem; - int num_rmems; - struct reset_control *reset; - const struct k3_dsp_dev_data *data; - struct ti_sci_proc *tsp; - const struct ti_sci_handle *ti_sci; - u32 ti_sci_id; - struct mbox_chan *mbox; - struct mbox_client client; - bool is_attach_ongoing; -}; - /** * k3_dsp_rproc_mbox_callback() - inbound mailbox message handler * @client: mailbox client pointer used for requesting the mailbox channel @@ -111,8 +40,7 @@ struct k3_dsp_rproc { */ static void k3_dsp_rproc_mbox_callback(struct mbox_client *client, void *data) { - struct k3_dsp_rproc *kproc = container_of(client, struct k3_dsp_rproc, - client); + struct k3_rproc *kproc = container_of(client, struct k3_rproc, client); struct device *dev = kproc->rproc->dev.parent; const char *name = kproc->rproc->name; u32 msg = omap_mbox_message(data); @@ -159,7 +87,7 @@ static void k3_dsp_rproc_mbox_callback(struct mbox_client *client, void *data) */ static void k3_dsp_rproc_kick(struct rproc *rproc, int vqid) { - struct k3_dsp_rproc *kproc = rproc->priv; + struct k3_rproc *kproc = rproc->priv; struct device *dev = rproc->dev.parent; mbox_msg_t msg = (mbox_msg_t)vqid; int ret; @@ -179,7 +107,7 @@ static void k3_dsp_rproc_kick(struct rproc *rproc, int vqid) } /* Put the DSP processor into reset */ -static int k3_dsp_rproc_reset(struct k3_dsp_rproc *kproc) +static int k3_dsp_rproc_reset(struct k3_rproc *kproc) { struct device *dev = kproc->dev; int ret; @@ -205,7 +133,7 @@ static int k3_dsp_rproc_reset(struct k3_dsp_rproc *kproc) } /* Release the DSP processor from reset */ -static int k3_dsp_rproc_release(struct k3_dsp_rproc *kproc) +static int k3_dsp_rproc_release(struct k3_rproc *kproc) { struct device *dev = kproc->dev; int ret; @@ -234,7 +162,7 @@ static int k3_dsp_rproc_release(struct k3_dsp_rproc *kproc) static int k3_dsp_rproc_request_mbox(struct rproc *rproc) { - struct k3_dsp_rproc *kproc = rproc->priv; + struct k3_rproc *kproc = rproc->priv; struct mbox_client *client = &kproc->client; struct device *dev = kproc->dev; int ret; @@ -278,7 +206,7 @@ static int k3_dsp_rproc_request_mbox(struct rproc *rproc) */ static int k3_dsp_rproc_prepare(struct rproc *rproc) { - struct k3_dsp_rproc *kproc = rproc->priv; + struct k3_rproc *kproc = rproc->priv; struct device *dev = kproc->dev; int ret; @@ -302,7 +230,7 @@ static int k3_dsp_rproc_prepare(struct rproc *rproc) */ static int k3_dsp_rproc_unprepare(struct rproc *rproc) { - struct k3_dsp_rproc *kproc = rproc->priv; + struct k3_rproc *kproc = rproc->priv; struct device *dev = kproc->dev; int ret; @@ -323,7 +251,7 @@ static int k3_dsp_rproc_unprepare(struct rproc *rproc) */ static int k3_dsp_rproc_start(struct rproc *rproc) { - struct k3_dsp_rproc *kproc = rproc->priv; + struct k3_rproc *kproc = rproc->priv; struct device *dev = kproc->dev; u32 boot_addr; int ret; @@ -355,7 +283,7 @@ static int k3_dsp_rproc_start(struct rproc *rproc) */ static int k3_dsp_rproc_stop(struct rproc *rproc) { - struct k3_dsp_rproc *kproc = rproc->priv; + struct k3_rproc *kproc = rproc->priv; k3_dsp_rproc_reset(kproc); @@ -374,7 +302,7 @@ static int k3_dsp_rproc_stop(struct rproc *rproc) */ static int k3_dsp_rproc_attach(struct rproc *rproc) { - struct k3_dsp_rproc *kproc = rproc->priv; + struct k3_rproc *kproc = rproc->priv; kproc->is_attach_ongoing = true; @@ -392,7 +320,7 @@ static int k3_dsp_rproc_attach(struct rproc *rproc) */ static int k3_dsp_rproc_detach(struct rproc *rproc) { - struct k3_dsp_rproc *kproc = rproc->priv; + struct k3_rproc *kproc = rproc->priv; kproc->is_attach_ongoing = false; @@ -412,7 +340,7 @@ static int k3_dsp_rproc_detach(struct rproc *rproc) static struct resource_table *k3_dsp_get_loaded_rsc_table(struct rproc *rproc, size_t *rsc_table_sz) { - struct k3_dsp_rproc *kproc = rproc->priv; + struct k3_rproc *kproc = rproc->priv; struct device *dev = kproc->dev; if (!kproc->rmem[0].cpu_addr) { @@ -441,7 +369,7 @@ static struct resource_table *k3_dsp_get_loaded_rsc_table(struct rproc *rproc, */ static void *k3_dsp_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *is_iomem) { - struct k3_dsp_rproc *kproc = rproc->priv; + struct k3_rproc *kproc = rproc->priv; void __iomem *va = NULL; phys_addr_t bus_addr; u32 dev_addr, offset; @@ -498,9 +426,9 @@ static const struct rproc_ops k3_dsp_rproc_ops = { }; static int k3_dsp_rproc_of_get_memories(struct platform_device *pdev, - struct k3_dsp_rproc *kproc) + struct k3_rproc *kproc) { - const struct k3_dsp_dev_data *data = kproc->data; + const struct k3_rproc_dev_data *data = kproc->data; struct device *dev = &pdev->dev; struct resource *res; int num_mems = 0; @@ -556,7 +484,7 @@ static void k3_dsp_mem_release(void *data) of_reserved_mem_device_release(dev); } -static int k3_dsp_reserved_mem_init(struct k3_dsp_rproc *kproc) +static int k3_dsp_reserved_mem_init(struct k3_rproc *kproc) { struct device *dev = kproc->dev; struct device_node *np = dev->of_node; @@ -637,8 +565,8 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct device_node *np = dev->of_node; - const struct k3_dsp_dev_data *data; - struct k3_dsp_rproc *kproc; + const struct k3_rproc_dev_data *data; + struct k3_rproc *kproc; struct rproc *rproc; const char *fw_name; bool p_state = false; @@ -754,7 +682,7 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) static void k3_dsp_rproc_remove(struct platform_device *pdev) { - struct k3_dsp_rproc *kproc = platform_get_drvdata(pdev); + struct k3_rproc *kproc = platform_get_drvdata(pdev); struct rproc *rproc = kproc->rproc; struct device *dev = &pdev->dev; int ret; @@ -768,37 +696,37 @@ static void k3_dsp_rproc_remove(struct platform_device *pdev) mbox_free_channel(kproc->mbox); } -static const struct k3_dsp_mem_data c66_mems[] = { +static const struct k3_rproc_mem_data c66_mems[] = { { .name = "l2sram", .dev_addr = 0x800000 }, { .name = "l1pram", .dev_addr = 0xe00000 }, { .name = "l1dram", .dev_addr = 0xf00000 }, }; /* C71x cores only have a L1P Cache, there are no L1P SRAMs */ -static const struct k3_dsp_mem_data c71_mems[] = { +static const struct k3_rproc_mem_data c71_mems[] = { { .name = "l2sram", .dev_addr = 0x800000 }, { .name = "l1dram", .dev_addr = 0xe00000 }, }; -static const struct k3_dsp_mem_data c7xv_mems[] = { +static const struct k3_rproc_mem_data c7xv_mems[] = { { .name = "l2sram", .dev_addr = 0x800000 }, }; -static const struct k3_dsp_dev_data c66_data = { +static const struct k3_rproc_dev_data c66_data = { .mems = c66_mems, .num_mems = ARRAY_SIZE(c66_mems), .boot_align_addr = SZ_1K, .uses_lreset = true, }; -static const struct k3_dsp_dev_data c71_data = { +static const struct k3_rproc_dev_data c71_data = { .mems = c71_mems, .num_mems = ARRAY_SIZE(c71_mems), .boot_align_addr = SZ_2M, .uses_lreset = false, }; -static const struct k3_dsp_dev_data c7xv_data = { +static const struct k3_rproc_dev_data c7xv_data = { .mems = c7xv_mems, .num_mems = ARRAY_SIZE(c7xv_mems), .boot_align_addr = SZ_2M, diff --git a/drivers/remoteproc/ti_k3_m4_remoteproc.c b/drivers/remoteproc/ti_k3_m4_remoteproc.c index 3201c3684a86..feca53978c62 100644 --- a/drivers/remoteproc/ti_k3_m4_remoteproc.c +++ b/drivers/remoteproc/ti_k3_m4_remoteproc.c @@ -19,66 +19,11 @@ #include "omap_remoteproc.h" #include "remoteproc_internal.h" #include "ti_sci_proc.h" +#include "ti_k3_common.h" #define K3_M4_IRAM_DEV_ADDR 0x00000 #define K3_M4_DRAM_DEV_ADDR 0x30000 -/** - * struct k3_m4_rproc_mem - internal memory structure - * @cpu_addr: MPU virtual address of the memory region - * @bus_addr: Bus address used to access the memory region - * @dev_addr: Device address of the memory region from remote processor view - * @size: Size of the memory region - */ -struct k3_m4_rproc_mem { - void __iomem *cpu_addr; - phys_addr_t bus_addr; - u32 dev_addr; - size_t size; -}; - -/** - * struct k3_m4_rproc_mem_data - memory definitions for a remote processor - * @name: name for this memory entry - * @dev_addr: device address for the memory entry - */ -struct k3_m4_rproc_mem_data { - const char *name; - const u32 dev_addr; -}; - -/** - * struct k3_m4_rproc - k3 remote processor driver structure - * @dev: cached device pointer - * @rproc: remoteproc device handle - * @mem: internal memory regions data - * @num_mems: number of internal memory regions - * @rmem: reserved memory regions data - * @num_rmems: number of reserved memory regions - * @reset: reset control handle - * @tsp: TI-SCI processor control handle - * @ti_sci: TI-SCI handle - * @ti_sci_id: TI-SCI device identifier - * @mbox: mailbox channel handle - * @client: mailbox client to request the mailbox channel - * @is_attach_ongoing: flag to indicate if IPC-only "attach()" is in progress - */ -struct k3_m4_rproc { - struct device *dev; - struct rproc *rproc; - struct k3_m4_rproc_mem *mem; - int num_mems; - struct k3_m4_rproc_mem *rmem; - int num_rmems; - struct reset_control *reset; - struct ti_sci_proc *tsp; - const struct ti_sci_handle *ti_sci; - u32 ti_sci_id; - struct mbox_chan *mbox; - struct mbox_client client; - bool is_attach_ongoing; -}; - /** * k3_m4_rproc_mbox_callback() - inbound mailbox message handler * @client: mailbox client pointer used for requesting the mailbox channel @@ -97,7 +42,7 @@ static void k3_m4_rproc_mbox_callback(struct mbox_client *client, void *data) { struct device *dev = client->dev; struct rproc *rproc = dev_get_drvdata(dev); - struct k3_m4_rproc *kproc = rproc->priv; + struct k3_rproc *kproc = rproc->priv; u32 msg = (u32)(uintptr_t)(data); /* @@ -142,7 +87,7 @@ static void k3_m4_rproc_mbox_callback(struct mbox_client *client, void *data) */ static void k3_m4_rproc_kick(struct rproc *rproc, int vqid) { - struct k3_m4_rproc *kproc = rproc->priv; + struct k3_rproc *kproc = rproc->priv; struct device *dev = kproc->dev; u32 msg = (u32)vqid; int ret; @@ -164,7 +109,7 @@ static void k3_m4_rproc_kick(struct rproc *rproc, int vqid) ret); } -static int k3_m4_rproc_ping_mbox(struct k3_m4_rproc *kproc) +static int k3_m4_rproc_ping_mbox(struct k3_rproc *kproc) { struct device *dev = kproc->dev; int ret; @@ -196,7 +141,7 @@ static int k3_m4_rproc_ping_mbox(struct k3_m4_rproc *kproc) */ static int k3_m4_rproc_prepare(struct rproc *rproc) { - struct k3_m4_rproc *kproc = rproc->priv; + struct k3_rproc *kproc = rproc->priv; struct device *dev = kproc->dev; int ret; @@ -241,7 +186,7 @@ static int k3_m4_rproc_prepare(struct rproc *rproc) */ static int k3_m4_rproc_unprepare(struct rproc *rproc) { - struct k3_m4_rproc *kproc = rproc->priv; + struct k3_rproc *kproc = rproc->priv; struct device *dev = kproc->dev; int ret; @@ -272,7 +217,7 @@ static int k3_m4_rproc_unprepare(struct rproc *rproc) static struct resource_table *k3_m4_get_loaded_rsc_table(struct rproc *rproc, size_t *rsc_table_sz) { - struct k3_m4_rproc *kproc = rproc->priv; + struct k3_rproc *kproc = rproc->priv; struct device *dev = kproc->dev; if (!kproc->rmem[0].cpu_addr) { @@ -302,7 +247,7 @@ static struct resource_table *k3_m4_get_loaded_rsc_table(struct rproc *rproc, */ static void *k3_m4_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *is_iomem) { - struct k3_m4_rproc *kproc = rproc->priv; + struct k3_rproc *kproc = rproc->priv; void __iomem *va = NULL; phys_addr_t bus_addr; u32 dev_addr, offset; @@ -348,7 +293,7 @@ static void *k3_m4_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool } static int k3_m4_rproc_of_get_memories(struct platform_device *pdev, - struct k3_m4_rproc *kproc) + struct k3_rproc *kproc) { static const char * const mem_names[] = { "iram", "dram" }; static const u32 mem_addrs[] = { K3_M4_IRAM_DEV_ADDR, K3_M4_DRAM_DEV_ADDR }; @@ -407,7 +352,7 @@ static void k3_m4_rproc_dev_mem_release(void *data) of_reserved_mem_device_release(dev); } -static int k3_m4_reserved_mem_init(struct k3_m4_rproc *kproc) +static int k3_m4_reserved_mem_init(struct k3_rproc *kproc) { struct device *dev = kproc->dev; struct device_node *np = dev->of_node; @@ -492,7 +437,7 @@ static void k3_m4_release_tsp(void *data) */ static int k3_m4_rproc_start(struct rproc *rproc) { - struct k3_m4_rproc *kproc = rproc->priv; + struct k3_rproc *kproc = rproc->priv; struct device *dev = kproc->dev; int ret; @@ -517,7 +462,7 @@ static int k3_m4_rproc_start(struct rproc *rproc) */ static int k3_m4_rproc_stop(struct rproc *rproc) { - struct k3_m4_rproc *kproc = rproc->priv; + struct k3_rproc *kproc = rproc->priv; struct device *dev = kproc->dev; int ret; @@ -541,7 +486,7 @@ static int k3_m4_rproc_stop(struct rproc *rproc) */ static int k3_m4_rproc_attach(struct rproc *rproc) { - struct k3_m4_rproc *kproc = rproc->priv; + struct k3_rproc *kproc = rproc->priv; int ret; kproc->is_attach_ongoing = true; @@ -564,7 +509,7 @@ static int k3_m4_rproc_attach(struct rproc *rproc) */ static int k3_m4_rproc_detach(struct rproc *rproc) { - struct k3_m4_rproc *kproc = rproc->priv; + struct k3_rproc *kproc = rproc->priv; kproc->is_attach_ongoing = false; @@ -586,7 +531,7 @@ static const struct rproc_ops k3_m4_rproc_ops = { static int k3_m4_rproc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct k3_m4_rproc *kproc; + struct k3_rproc *kproc; struct rproc *rproc; const char *fw_name; bool r_state = false; From patchwork Fri Jan 3 10:12:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beleswar Prasad Padhi X-Patchwork-Id: 13925457 Received: from fllvem-ot04.ext.ti.com (fllvem-ot04.ext.ti.com [198.47.19.246]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 538371C07EB; Fri, 3 Jan 2025 10:12:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.246 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899180; cv=none; b=YJZL7aKOFET0VeUnyhMTjqin/DjHoNJoz86IuVwOtZ1ag1/8mQ9oX3ToY0hLNM+xU39NWauBzYUzV7OTZ3SnqeZJP4WRRePXE0c70J1BdbMINc6fVwletJnIEVfjQMhKznHg1pjSJt3gAgaVoDu0ktp5IP/cYjs8RmS8rcjK7V4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899180; c=relaxed/simple; bh=h0IZfkwt3CP+0irdT+XGSKWNfdf9m8kCy232vwu7+Js=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TqD5cddv36CEB/yZGgI3i6si9oY5LLzyy9FRL4Huy+GFNLqSZMBD/3gQDLLcH3FePCv9kxtlWZOUYfrfofWInMjPH76OQDPN4IsRYSjkrN8wR78fzTxQeeh3QDnafFWiAdcIR/LM6tiAyKLhi9jbnZVjIoYW5n/lkYZgzJBcwfs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=mhmBCH40; arc=none smtp.client-ip=198.47.19.246 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="mhmBCH40" Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllvem-ot04.ext.ti.com (8.15.2/8.15.2) with ESMTPS id 503ACl9a2306828 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 3 Jan 2025 04:12:47 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1735899167; bh=UmjVTBIrOf59QKmEPntyA/SbJbqGAhb+9jWSxGG1ZDs=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=mhmBCH406moYyahTjVpzXM+uladlgC2ZEUFUce1Zc2vqi1zOvQG/N8NPzp8tI6li2 z3W/gZPE+/94ozvt916BqxmAwYkbD5mU6Pb5n+ddZYOEQWgvDUsIiKB5Sg6znxOAA6 W5LC4NVj9BXIqrh1ZV3qEj1m/8Dn9fgxn1fzWr24= Received: from DLEE100.ent.ti.com (dlee100.ent.ti.com [157.170.170.30]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 503AClgT012190 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 3 Jan 2025 04:12:47 -0600 Received: from DLEE110.ent.ti.com (157.170.170.21) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 3 Jan 2025 04:12:46 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE110.ent.ti.com (157.170.170.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Fri, 3 Jan 2025 04:12:46 -0600 Received: from uda0510294.dhcp.ti.com (uda0510294.dhcp.ti.com [172.24.227.151]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 503ACVSL126047; Fri, 3 Jan 2025 04:12:43 -0600 From: Beleswar Padhi To: , CC: , , , , , , , , , , Subject: [PATCH v8 03/20] remoteproc: k3: Refactor mailbox rx_callback functions into common driver Date: Fri, 3 Jan 2025 15:42:14 +0530 Message-ID: <20250103101231.1508151-4-b-padhi@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103101231.1508151-1-b-padhi@ti.com> References: <20250103101231.1508151-1-b-padhi@ti.com> Precedence: bulk X-Mailing-List: linux-remoteproc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea The mailbox .rx_callback implementations in ti_k3_dsp_remoteproc.c and ti_k3_m4_remoteproc.c drivers handle inbound mailbox messages in the same way. Introduce a common driver 'ti_k3_common.c' and refactor the implementations into a common function 'k3_rproc_mbox_callback'() in it. Signed-off-by: Beleswar Padhi --- drivers/remoteproc/Makefile | 4 +- drivers/remoteproc/ti_k3_common.c | 90 +++++++++++++++++++++++ drivers/remoteproc/ti_k3_common.h | 1 + drivers/remoteproc/ti_k3_dsp_remoteproc.c | 57 +------------- drivers/remoteproc/ti_k3_m4_remoteproc.c | 57 +------------- 5 files changed, 95 insertions(+), 114 deletions(-) create mode 100644 drivers/remoteproc/ti_k3_common.c diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile index 5ff4e2fee4ab..e30908ca4bfc 100644 --- a/drivers/remoteproc/Makefile +++ b/drivers/remoteproc/Makefile @@ -36,7 +36,7 @@ obj-$(CONFIG_RCAR_REMOTEPROC) += rcar_rproc.o obj-$(CONFIG_ST_REMOTEPROC) += st_remoteproc.o obj-$(CONFIG_ST_SLIM_REMOTEPROC) += st_slim_rproc.o obj-$(CONFIG_STM32_RPROC) += stm32_rproc.o -obj-$(CONFIG_TI_K3_DSP_REMOTEPROC) += ti_k3_dsp_remoteproc.o -obj-$(CONFIG_TI_K3_M4_REMOTEPROC) += ti_k3_m4_remoteproc.o +obj-$(CONFIG_TI_K3_DSP_REMOTEPROC) += ti_k3_dsp_remoteproc.o ti_k3_common.o +obj-$(CONFIG_TI_K3_M4_REMOTEPROC) += ti_k3_m4_remoteproc.o ti_k3_common.o obj-$(CONFIG_TI_K3_R5_REMOTEPROC) += ti_k3_r5_remoteproc.o obj-$(CONFIG_XLNX_R5_REMOTEPROC) += xlnx_r5_remoteproc.o diff --git a/drivers/remoteproc/ti_k3_common.c b/drivers/remoteproc/ti_k3_common.c new file mode 100644 index 000000000000..a87a06744f71 --- /dev/null +++ b/drivers/remoteproc/ti_k3_common.c @@ -0,0 +1,90 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * TI K3 Remote Processor(s) driver common code + * + * Refactored out of ti_k3_dsp_remoteproc.c and ti_k3_m4_remoteproc.c. + * + * ti_k3_dsp_remoteproc.c: + * Copyright (C) 2018-2022 Texas Instruments Incorporated - https://www.ti.com/ + * Suman Anna + * + * ti_k3_m4_remoteproc.c: + * Copyright (C) 2021-2024 Texas Instruments Incorporated - https://www.ti.com/ + * Hari Nagalla + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "omap_remoteproc.h" +#include "remoteproc_internal.h" +#include "ti_sci_proc.h" +#include "ti_k3_common.h" + +/** + * k3_rproc_mbox_callback() - inbound mailbox message handler + * @client: mailbox client pointer used for requesting the mailbox channel + * @data: mailbox payload + * + * This handler is invoked by the K3 mailbox driver whenever a mailbox + * message is received. Usually, the mailbox payload simply contains + * the index of the virtqueue that is kicked by the remote processor, + * and we let remoteproc core handle it. + * + * In addition to virtqueue indices, we also have some out-of-band values + * that indicate different events. Those values are deliberately very + * large so they don't coincide with virtqueue indices. + */ +void k3_rproc_mbox_callback(struct mbox_client *client, void *data) +{ + struct k3_rproc *kproc = container_of(client, struct k3_rproc, client); + struct device *dev = kproc->rproc->dev.parent; + struct rproc *rproc = kproc->rproc; + u32 msg = (u32)(uintptr_t)(data); + + /* + * Do not forward messages from a detached core, except when the core + * is in the process of being attached in IPC-only mode. + */ + if (!kproc->is_attach_ongoing && kproc->rproc->state == RPROC_DETACHED) + return; + + dev_dbg(dev, "mbox msg: 0x%x\n", msg); + + switch (msg) { + case RP_MBOX_CRASH: + /* + * remoteproc detected an exception, but error recovery is not + * supported. So, just log this for now + */ + dev_err(dev, "K3 rproc %s crashed\n", rproc->name); + break; + case RP_MBOX_ECHO_REPLY: + dev_info(dev, "received echo reply from %s\n", rproc->name); + break; + default: + /* silently handle all other valid messages */ + if (msg >= RP_MBOX_READY && msg < RP_MBOX_END_MSG) + return; + if (msg > rproc->max_notifyid) { + dev_dbg(dev, "dropping unknown message 0x%x", msg); + return; + } + /* msg contains the index of the triggered vring */ + if (rproc_vq_interrupt(rproc, msg) == IRQ_NONE) + dev_dbg(dev, "no message was found in vqid %d\n", msg); + } +} +EXPORT_SYMBOL_GPL(k3_rproc_mbox_callback); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("TI K3 common Remoteproc code"); diff --git a/drivers/remoteproc/ti_k3_common.h b/drivers/remoteproc/ti_k3_common.h index 9d7ce70bcbf5..251ecc2df1dd 100644 --- a/drivers/remoteproc/ti_k3_common.h +++ b/drivers/remoteproc/ti_k3_common.h @@ -88,4 +88,5 @@ struct k3_rproc { bool is_attach_ongoing; }; +void k3_rproc_mbox_callback(struct mbox_client *client, void *data); #endif /* REMOTEPROC_TI_K3_COMMON_H */ diff --git a/drivers/remoteproc/ti_k3_dsp_remoteproc.c b/drivers/remoteproc/ti_k3_dsp_remoteproc.c index 41b32af15260..70fbceccbac2 100644 --- a/drivers/remoteproc/ti_k3_dsp_remoteproc.c +++ b/drivers/remoteproc/ti_k3_dsp_remoteproc.c @@ -24,61 +24,6 @@ #define KEYSTONE_RPROC_LOCAL_ADDRESS_MASK (SZ_16M - 1) -/** - * k3_dsp_rproc_mbox_callback() - inbound mailbox message handler - * @client: mailbox client pointer used for requesting the mailbox channel - * @data: mailbox payload - * - * This handler is invoked by the OMAP mailbox driver whenever a mailbox - * message is received. Usually, the mailbox payload simply contains - * the index of the virtqueue that is kicked by the remote processor, - * and we let remoteproc core handle it. - * - * In addition to virtqueue indices, we also have some out-of-band values - * that indicate different events. Those values are deliberately very - * large so they don't coincide with virtqueue indices. - */ -static void k3_dsp_rproc_mbox_callback(struct mbox_client *client, void *data) -{ - struct k3_rproc *kproc = container_of(client, struct k3_rproc, client); - struct device *dev = kproc->rproc->dev.parent; - const char *name = kproc->rproc->name; - u32 msg = omap_mbox_message(data); - - /* - * Do not forward messages from a detached core, except when the core - * is in the process of being attached in IPC-only mode. - */ - if (!kproc->is_attach_ongoing && kproc->rproc->state == RPROC_DETACHED) - return; - - dev_dbg(dev, "mbox msg: 0x%x\n", msg); - - switch (msg) { - case RP_MBOX_CRASH: - /* - * remoteproc detected an exception, but error recovery is not - * supported. So, just log this for now - */ - dev_err(dev, "K3 DSP rproc %s crashed\n", name); - break; - case RP_MBOX_ECHO_REPLY: - dev_info(dev, "received echo reply from %s\n", name); - break; - default: - /* silently handle all other valid messages */ - if (msg >= RP_MBOX_READY && msg < RP_MBOX_END_MSG) - return; - if (msg > kproc->rproc->max_notifyid) { - dev_dbg(dev, "dropping unknown message 0x%x", msg); - return; - } - /* msg contains the index of the triggered vring */ - if (rproc_vq_interrupt(kproc->rproc, msg) == IRQ_NONE) - dev_dbg(dev, "no message was found in vqid %d\n", msg); - } -} - /* * Kick the remote processor to notify about pending unprocessed messages. * The vqid usage is not used and is inconsequential, as the kick is performed @@ -169,7 +114,7 @@ static int k3_dsp_rproc_request_mbox(struct rproc *rproc) client->dev = dev; client->tx_done = NULL; - client->rx_callback = k3_dsp_rproc_mbox_callback; + client->rx_callback = k3_rproc_mbox_callback; client->tx_block = false; client->knows_txdone = false; diff --git a/drivers/remoteproc/ti_k3_m4_remoteproc.c b/drivers/remoteproc/ti_k3_m4_remoteproc.c index feca53978c62..f1fe7d462d2a 100644 --- a/drivers/remoteproc/ti_k3_m4_remoteproc.c +++ b/drivers/remoteproc/ti_k3_m4_remoteproc.c @@ -24,61 +24,6 @@ #define K3_M4_IRAM_DEV_ADDR 0x00000 #define K3_M4_DRAM_DEV_ADDR 0x30000 -/** - * k3_m4_rproc_mbox_callback() - inbound mailbox message handler - * @client: mailbox client pointer used for requesting the mailbox channel - * @data: mailbox payload - * - * This handler is invoked by the K3 mailbox driver whenever a mailbox - * message is received. Usually, the mailbox payload simply contains - * the index of the virtqueue that is kicked by the remote processor, - * and we let remoteproc core handle it. - * - * In addition to virtqueue indices, we also have some out-of-band values - * that indicate different events. Those values are deliberately very - * large so they don't coincide with virtqueue indices. - */ -static void k3_m4_rproc_mbox_callback(struct mbox_client *client, void *data) -{ - struct device *dev = client->dev; - struct rproc *rproc = dev_get_drvdata(dev); - struct k3_rproc *kproc = rproc->priv; - u32 msg = (u32)(uintptr_t)(data); - - /* - * Do not forward messages from a detached core, except when the core - * is in the process of being attached in IPC-only mode. - */ - if (!kproc->is_attach_ongoing && kproc->rproc->state == RPROC_DETACHED) - return; - - dev_dbg(dev, "mbox msg: 0x%x\n", msg); - - switch (msg) { - case RP_MBOX_CRASH: - /* - * remoteproc detected an exception, but error recovery is not - * supported. So, just log this for now - */ - dev_err(dev, "K3 rproc %s crashed\n", rproc->name); - break; - case RP_MBOX_ECHO_REPLY: - dev_info(dev, "received echo reply from %s\n", rproc->name); - break; - default: - /* silently handle all other valid messages */ - if (msg >= RP_MBOX_READY && msg < RP_MBOX_END_MSG) - return; - if (msg > rproc->max_notifyid) { - dev_dbg(dev, "dropping unknown message 0x%x", msg); - return; - } - /* msg contains the index of the triggered vring */ - if (rproc_vq_interrupt(rproc, msg) == IRQ_NONE) - dev_dbg(dev, "no message was found in vqid %d\n", msg); - } -} - /* * Kick the remote processor to notify about pending unprocessed messages. * The vqid usage is not used and is inconsequential, as the kick is performed @@ -603,7 +548,7 @@ static int k3_m4_rproc_probe(struct platform_device *pdev) kproc->client.dev = dev; kproc->client.tx_done = NULL; - kproc->client.rx_callback = k3_m4_rproc_mbox_callback; + kproc->client.rx_callback = k3_rproc_mbox_callback; kproc->client.tx_block = false; kproc->client.knows_txdone = false; kproc->mbox = mbox_request_channel(&kproc->client, 0); From patchwork Fri Jan 3 10:12:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beleswar Prasad Padhi X-Patchwork-Id: 13925458 Received: from fllvem-ot03.ext.ti.com (fllvem-ot03.ext.ti.com [198.47.19.245]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 347A41F9AB6; Fri, 3 Jan 2025 10:13:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.245 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899184; cv=none; b=IYnKdKCn/YhcYIkqVOFjs7NwzeyQbW0ZMmix9G4H0xH2RrdDaBhO7UD2n5cPIcmlPbOuGishCizaOcA+O+sgi1iX6596vNgWaVd2ytAY3Bx13rl4Ke5hYgMMoK+Iv7XAYw/nF/lqDHaHreu1Uj029Xkwa8EGlnGyOx9Jr8WDZqY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899184; c=relaxed/simple; bh=YbMs7JlqVUHC8NgrQl9CQBdLtGYXH6D2DqArDUwl7Mk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bXd8DrlI7dQnxxylE+gjuDOdNJ4dlprgL5z7PvtNBWlLV2U2AbtDMiQnFuT6Fw/i0RNGUjSryg05qOiMaI/E2uAAEb2SWflQ8X99qHtGs06gT2BQjZwVwOOWD2I2UoBr0F1ieGhw9BEmSCPEAcrNeXprzrzFW7hQ1FoTQawckpA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=D2EtF9+G; arc=none smtp.client-ip=198.47.19.245 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="D2EtF9+G" Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllvem-ot03.ext.ti.com (8.15.2/8.15.2) with ESMTPS id 503ACpgC2019398 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 3 Jan 2025 04:12:51 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1735899171; bh=DgyVEw7oOl3tnOK8cHQEwe00QwCEYwZiiFEcw9txbtE=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=D2EtF9+G3bkr/uC0PGMHWDj+SB3iKnZpklY4nG6l+OmDvFN+R2ttyI/ckUT2rarA7 A1ittsx8YT2CV6kkfXohPbi4OnhkXQTZA5ulQpu32BVo6G7A3Zj4LoocgVFPWNPOeV qksE6/x8uWGKrSSAf/GcXA7B/+nkQ83N/RraLu+8= Received: from DLEE107.ent.ti.com (dlee107.ent.ti.com [157.170.170.37]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTP id 503ACpNR041856; Fri, 3 Jan 2025 04:12:51 -0600 Received: from DLEE107.ent.ti.com (157.170.170.37) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 3 Jan 2025 04:12:50 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Fri, 3 Jan 2025 04:12:50 -0600 Received: from uda0510294.dhcp.ti.com (uda0510294.dhcp.ti.com [172.24.227.151]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 503ACVSM126047; Fri, 3 Jan 2025 04:12:47 -0600 From: Beleswar Padhi To: , CC: , , , , , , , , , , Subject: [PATCH v8 04/20] remoteproc: k3: Refactor .kick rproc ops into common driver Date: Fri, 3 Jan 2025 15:42:15 +0530 Message-ID: <20250103101231.1508151-5-b-padhi@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103101231.1508151-1-b-padhi@ti.com> References: <20250103101231.1508151-1-b-padhi@ti.com> Precedence: bulk X-Mailing-List: linux-remoteproc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea The .kick rproc ops implementations in ti_k3_dsp_remoteproc.c and ti_k3_m4_remoteproc.c drivers sends a mailbox message to the remote processor in the same way. Refactor the implementations into a common function 'k3_rproc_kick()' in the ti_k3_common.c driver. Signed-off-by: Beleswar Padhi --- drivers/remoteproc/ti_k3_common.c | 31 +++++++++++++++++++++ drivers/remoteproc/ti_k3_common.h | 1 + drivers/remoteproc/ti_k3_dsp_remoteproc.c | 31 ++------------------- drivers/remoteproc/ti_k3_m4_remoteproc.c | 34 ++--------------------- 4 files changed, 36 insertions(+), 61 deletions(-) diff --git a/drivers/remoteproc/ti_k3_common.c b/drivers/remoteproc/ti_k3_common.c index a87a06744f71..bd6353283078 100644 --- a/drivers/remoteproc/ti_k3_common.c +++ b/drivers/remoteproc/ti_k3_common.c @@ -86,5 +86,36 @@ void k3_rproc_mbox_callback(struct mbox_client *client, void *data) } EXPORT_SYMBOL_GPL(k3_rproc_mbox_callback); +/* + * Kick the remote processor to notify about pending unprocessed messages. + * The vqid usage is not used and is inconsequential, as the kick is performed + * through a simulated GPIO (a bit in an IPC interrupt-triggering register), + * the remote processor is expected to process both its Tx and Rx virtqueues. + */ +void k3_rproc_kick(struct rproc *rproc, int vqid) +{ + struct k3_rproc *kproc = rproc->priv; + struct device *dev = kproc->dev; + u32 msg = (u32)vqid; + int ret; + + /* + * Do not forward messages to a detached core, except when the core + * is in the process of being attached in IPC-only mode. + */ + if (!kproc->is_attach_ongoing && kproc->rproc->state == RPROC_DETACHED) + return; + /* + * Send the index of the triggered virtqueue in the mailbox payload. + * NOTE: msg is cast to uintptr_t to prevent compiler warnings when + * void* is 64bit. It is safely cast back to u32 in the mailbox driver. + */ + ret = mbox_send_message(kproc->mbox, (void *)(uintptr_t)msg); + if (ret < 0) + dev_err(dev, "failed to send mailbox message, status = %d\n", + ret); +} +EXPORT_SYMBOL_GPL(k3_rproc_kick); + MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("TI K3 common Remoteproc code"); diff --git a/drivers/remoteproc/ti_k3_common.h b/drivers/remoteproc/ti_k3_common.h index 251ecc2df1dd..57792d68b7ef 100644 --- a/drivers/remoteproc/ti_k3_common.h +++ b/drivers/remoteproc/ti_k3_common.h @@ -89,4 +89,5 @@ struct k3_rproc { }; void k3_rproc_mbox_callback(struct mbox_client *client, void *data); +void k3_rproc_kick(struct rproc *rproc, int vqid); #endif /* REMOTEPROC_TI_K3_COMMON_H */ diff --git a/drivers/remoteproc/ti_k3_dsp_remoteproc.c b/drivers/remoteproc/ti_k3_dsp_remoteproc.c index 70fbceccbac2..b2551b5171a9 100644 --- a/drivers/remoteproc/ti_k3_dsp_remoteproc.c +++ b/drivers/remoteproc/ti_k3_dsp_remoteproc.c @@ -24,33 +24,6 @@ #define KEYSTONE_RPROC_LOCAL_ADDRESS_MASK (SZ_16M - 1) -/* - * Kick the remote processor to notify about pending unprocessed messages. - * The vqid usage is not used and is inconsequential, as the kick is performed - * through a simulated GPIO (a bit in an IPC interrupt-triggering register), - * the remote processor is expected to process both its Tx and Rx virtqueues. - */ -static void k3_dsp_rproc_kick(struct rproc *rproc, int vqid) -{ - struct k3_rproc *kproc = rproc->priv; - struct device *dev = rproc->dev.parent; - mbox_msg_t msg = (mbox_msg_t)vqid; - int ret; - - /* - * Do not forward messages to a detached core, except when the core is - * in the process of being attached in IPC-only mode. - */ - if (!kproc->is_attach_ongoing && kproc->rproc->state == RPROC_DETACHED) - return; - - /* send the index of the triggered virtqueue in the mailbox payload */ - ret = mbox_send_message(kproc->mbox, (void *)msg); - if (ret < 0) - dev_err(dev, "failed to send mailbox message (%pe)\n", - ERR_PTR(ret)); -} - /* Put the DSP processor into reset */ static int k3_dsp_rproc_reset(struct k3_rproc *kproc) { @@ -239,7 +212,7 @@ static int k3_dsp_rproc_stop(struct rproc *rproc) * Attach to a running DSP remote processor (IPC-only mode) * * This rproc attach callback only needs to set the "is_attach_ongoing" flag to - * notify k3_dsp_rproc_{kick/mbox_callback} functions that the core is in the + * notify k3_rproc_{kick/mbox_callback} functions that the core is in the * process of getting attached in IPC-only mode. The remote processor is already * booted, and all required resources have been acquired during probe routine, * so there is no need to issue any TI-SCI commands to boot the DSP core. This @@ -366,7 +339,7 @@ static void *k3_dsp_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool static const struct rproc_ops k3_dsp_rproc_ops = { .start = k3_dsp_rproc_start, .stop = k3_dsp_rproc_stop, - .kick = k3_dsp_rproc_kick, + .kick = k3_rproc_kick, .da_to_va = k3_dsp_rproc_da_to_va, }; diff --git a/drivers/remoteproc/ti_k3_m4_remoteproc.c b/drivers/remoteproc/ti_k3_m4_remoteproc.c index f1fe7d462d2a..953c3999019f 100644 --- a/drivers/remoteproc/ti_k3_m4_remoteproc.c +++ b/drivers/remoteproc/ti_k3_m4_remoteproc.c @@ -24,36 +24,6 @@ #define K3_M4_IRAM_DEV_ADDR 0x00000 #define K3_M4_DRAM_DEV_ADDR 0x30000 -/* - * Kick the remote processor to notify about pending unprocessed messages. - * The vqid usage is not used and is inconsequential, as the kick is performed - * through a simulated GPIO (a bit in an IPC interrupt-triggering register), - * the remote processor is expected to process both its Tx and Rx virtqueues. - */ -static void k3_m4_rproc_kick(struct rproc *rproc, int vqid) -{ - struct k3_rproc *kproc = rproc->priv; - struct device *dev = kproc->dev; - u32 msg = (u32)vqid; - int ret; - - /* - * Do not forward messages to a detached core, except when the core - * is in the process of being attached in IPC-only mode. - */ - if (!kproc->is_attach_ongoing && kproc->rproc->state == RPROC_DETACHED) - return; - /* - * Send the index of the triggered virtqueue in the mailbox payload. - * NOTE: msg is cast to uintptr_t to prevent compiler warnings when - * void* is 64bit. It is safely cast back to u32 in the mailbox driver. - */ - ret = mbox_send_message(kproc->mbox, (void *)(uintptr_t)msg); - if (ret < 0) - dev_err(dev, "failed to send mailbox message, status = %d\n", - ret); -} - static int k3_m4_rproc_ping_mbox(struct k3_rproc *kproc) { struct device *dev = kproc->dev; @@ -424,7 +394,7 @@ static int k3_m4_rproc_stop(struct rproc *rproc) * Attach to a running M4 remote processor (IPC-only mode) * * This rproc attach callback only needs to set the "is_attach_ongoing" flag to - * notify k3_m4_rproc_{kick/mbox_callback} functions that the core is in the + * notify k3_rproc_{kick/mbox_callback} functions that the core is in the * process of getting attached in IPC-only mode. The remote processor is already * booted, so there is no need to issue any TI-SCI commands to boot the M4 core. * This callback is used only in IPC-only mode. @@ -468,7 +438,7 @@ static const struct rproc_ops k3_m4_rproc_ops = { .stop = k3_m4_rproc_stop, .attach = k3_m4_rproc_attach, .detach = k3_m4_rproc_detach, - .kick = k3_m4_rproc_kick, + .kick = k3_rproc_kick, .da_to_va = k3_m4_rproc_da_to_va, .get_loaded_rsc_table = k3_m4_get_loaded_rsc_table, }; From patchwork Fri Jan 3 10:12:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beleswar Prasad Padhi X-Patchwork-Id: 13925460 Received: from lelvem-ot01.ext.ti.com (lelvem-ot01.ext.ti.com [198.47.23.234]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AFABC1F941F; Fri, 3 Jan 2025 10:13:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.234 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899189; cv=none; b=LCp9iLhjD8rxtdsegFdEANAzIOLDh14l8uFF3aNGB+WeppZ3E1+nGKHJE9lbWZlFGmvzQ0MQXc/RpJKpLG7EnH7ycxu8H4fS3saw9sMKWXhsigzUIrAJE1zIpWWa2xGYjVykmUHp59i488wSPCDWSBWTi9UDCGdvLeXzAAQAbKM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899189; c=relaxed/simple; bh=Fm5OkSK3KIib1TPPxadSQXRiQkaYbKKsLNDV1NvqS2o=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hcPsnsVtzdbNUyjz/TR+/HG523hci/2wVxLJ/jJZt19zp10MB+NsXGvmrJPonFCmpx2mf78zgtReoiMWnqKisSM//MFUrcszG38jJvLFZeP68nY0oIcyB7CcR9ZgGTUbyg2QLo5/SmfWV7TAy5CPN8oM9Kj2bpPmyeaddkJoXnE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=aJBherqi; arc=none smtp.client-ip=198.47.23.234 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="aJBherqi" Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelvem-ot01.ext.ti.com (8.15.2/8.15.2) with ESMTPS id 503ACs7Y2076372 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 3 Jan 2025 04:12:54 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1735899174; bh=fq5TNC9QrfaSZDncZPI6A87HfJTjjUWbjcK9fTzKL9U=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=aJBherqippPaVVYGjiSr6zc1zeg688GQunhIfZzQy6bsEd+ZwuJvlJKW+dvsnyutq +LIh9Jq8LeGU9WdEoPfaZzO18uWbgBy2A3TqHsPdAc83S8KQpATsX4pQfpDwtd+mpR hsBTQAKcR8pSx+uDvRY+rlcK95t/V4E9z9GcKzMI= Received: from DFLE114.ent.ti.com (dfle114.ent.ti.com [10.64.6.35]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTP id 503ACsJY041864; Fri, 3 Jan 2025 04:12:54 -0600 Received: from DFLE111.ent.ti.com (10.64.6.32) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 3 Jan 2025 04:12:54 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE111.ent.ti.com (10.64.6.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Fri, 3 Jan 2025 04:12:54 -0600 Received: from uda0510294.dhcp.ti.com (uda0510294.dhcp.ti.com [172.24.227.151]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 503ACVSN126047; Fri, 3 Jan 2025 04:12:51 -0600 From: Beleswar Padhi To: , CC: , , , , , , , , , , Subject: [PATCH v8 05/20] remoteproc: k3-m4: Use k3_rproc_mem_data structure for memory info Date: Fri, 3 Jan 2025 15:42:16 +0530 Message-ID: <20250103101231.1508151-6-b-padhi@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103101231.1508151-1-b-padhi@ti.com> References: <20250103101231.1508151-1-b-padhi@ti.com> Precedence: bulk X-Mailing-List: linux-remoteproc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea The ti_k3_m4_remoteproc.c driver previously hardcoded device memory region addresses and names. Change this to use the k3_rproc_mem_data structure to store memory information. This aligns with ti_k3_dsp_remoteproc.c driver, and can be refactored out later. Signed-off-by: Beleswar Padhi --- drivers/remoteproc/ti_k3_m4_remoteproc.c | 40 ++++++++++++++++-------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/drivers/remoteproc/ti_k3_m4_remoteproc.c b/drivers/remoteproc/ti_k3_m4_remoteproc.c index 953c3999019f..fc688b124a54 100644 --- a/drivers/remoteproc/ti_k3_m4_remoteproc.c +++ b/drivers/remoteproc/ti_k3_m4_remoteproc.c @@ -21,9 +21,6 @@ #include "ti_sci_proc.h" #include "ti_k3_common.h" -#define K3_M4_IRAM_DEV_ADDR 0x00000 -#define K3_M4_DRAM_DEV_ADDR 0x30000 - static int k3_m4_rproc_ping_mbox(struct k3_rproc *kproc) { struct device *dev = kproc->dev; @@ -210,14 +207,13 @@ static void *k3_m4_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool static int k3_m4_rproc_of_get_memories(struct platform_device *pdev, struct k3_rproc *kproc) { - static const char * const mem_names[] = { "iram", "dram" }; - static const u32 mem_addrs[] = { K3_M4_IRAM_DEV_ADDR, K3_M4_DRAM_DEV_ADDR }; + const struct k3_rproc_dev_data *data = kproc->data; struct device *dev = &pdev->dev; struct resource *res; int num_mems; int i; - num_mems = ARRAY_SIZE(mem_names); + num_mems = kproc->data->num_mems; kproc->mem = devm_kcalloc(kproc->dev, num_mems, sizeof(*kproc->mem), GFP_KERNEL); if (!kproc->mem) @@ -225,17 +221,17 @@ static int k3_m4_rproc_of_get_memories(struct platform_device *pdev, for (i = 0; i < num_mems; i++) { res = platform_get_resource_byname(pdev, IORESOURCE_MEM, - mem_names[i]); + data->mems[i].name); if (!res) { dev_err(dev, "found no memory resource for %s\n", - mem_names[i]); + data->mems[i].name); return -EINVAL; } if (!devm_request_mem_region(dev, res->start, resource_size(res), dev_name(dev))) { dev_err(dev, "could not request %s region for resource\n", - mem_names[i]); + data->mems[i].name); return -EBUSY; } @@ -243,15 +239,15 @@ static int k3_m4_rproc_of_get_memories(struct platform_device *pdev, resource_size(res)); if (!kproc->mem[i].cpu_addr) { dev_err(dev, "failed to map %s memory\n", - mem_names[i]); + data->mems[i].name); return -ENOMEM; } kproc->mem[i].bus_addr = res->start; - kproc->mem[i].dev_addr = mem_addrs[i]; + kproc->mem[i].dev_addr = data->mems[i].dev_addr; kproc->mem[i].size = resource_size(res); dev_dbg(dev, "memory %8s: bus addr %pa size 0x%zx va %pK da 0x%x\n", - mem_names[i], &kproc->mem[i].bus_addr, + data->mems[i].name, &kproc->mem[i].bus_addr, kproc->mem[i].size, kproc->mem[i].cpu_addr, kproc->mem[i].dev_addr); } @@ -446,6 +442,7 @@ static const struct rproc_ops k3_m4_rproc_ops = { static int k3_m4_rproc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; + const struct k3_rproc_dev_data *data; struct k3_rproc *kproc; struct rproc *rproc; const char *fw_name; @@ -453,6 +450,10 @@ static int k3_m4_rproc_probe(struct platform_device *pdev) bool p_state = false; int ret; + data = of_device_get_match_data(dev); + if (!data) + return -ENODEV; + ret = rproc_of_parse_firmware(dev, 0, &fw_name); if (ret) return dev_err_probe(dev, ret, "failed to parse firmware-name property\n"); @@ -467,6 +468,7 @@ static int k3_m4_rproc_probe(struct platform_device *pdev) kproc = rproc->priv; kproc->rproc = rproc; kproc->dev = dev; + kproc->data = data; platform_set_drvdata(pdev, rproc); kproc->ti_sci = devm_ti_sci_get_by_phandle(dev, "ti,sci"); @@ -534,8 +536,20 @@ static int k3_m4_rproc_probe(struct platform_device *pdev) return 0; } +static const struct k3_rproc_mem_data am64_m4_mems[] = { + { .name = "iram", .dev_addr = 0x0 }, + { .name = "dram", .dev_addr = 0x30000 }, +}; + +static const struct k3_rproc_dev_data am64_m4_data = { + .mems = am64_m4_mems, + .num_mems = ARRAY_SIZE(am64_m4_mems), + .boot_align_addr = SZ_1K, + .uses_lreset = true, +}; + static const struct of_device_id k3_m4_of_match[] = { - { .compatible = "ti,am64-m4fss", }, + { .compatible = "ti,am64-m4fss", .data = &am64_m4_data, }, { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, k3_m4_of_match); From patchwork Fri Jan 3 10:12:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beleswar Prasad Padhi X-Patchwork-Id: 13925459 Received: from lelvem-ot01.ext.ti.com (lelvem-ot01.ext.ti.com [198.47.23.234]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD4591F9F48; Fri, 3 Jan 2025 10:13:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.234 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899189; cv=none; b=koaoDUXgId6m1Vhd+d7lU7Fcy27CUID9Il0auq460CyoFI0+D+OI5995iBKITENQgRSLyl/FQDCnhF/ah6/oZ0sDY9t1fWazB4zfbwrOn00y/IxBAWKguCd1Po+2T6Mi0GMirLgr3gMTJ62SSKjWWaR++k0BOpEMWlzicaFDh2I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899189; c=relaxed/simple; bh=dv8Rdx922O7xN0WyGdN3/oUDuk5E4qQbW+XT7rPM7dg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cTbYO0UmV3W8MVZy0fILhesuOfu8lZcYwouFCLzS4VRhHy0zBOP601QtC86EP7chlvpzZnsngGEDYzLo0dlx1ouwRVOSBKSS4isu1RA6iyB8MMPJNW52WRIUpCV7YoldmPu5x6wsO0hL/wt2+ojhpJHNIS9xlsVFg8sqcVgzguc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=tLEeMvQd; arc=none smtp.client-ip=198.47.23.234 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="tLEeMvQd" Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelvem-ot01.ext.ti.com (8.15.2/8.15.2) with ESMTPS id 503ACwqR2076377 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 3 Jan 2025 04:12:58 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1735899178; bh=tcHAMj3B1jP+H8++Z/xR9g/S7xj6x47Z+JTtbYMT5j4=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=tLEeMvQdLORSI6eRrT1p6KX+342FSoQACVAEx0vcrMdSsZfitwex2Fqhb+xKvgrB6 3Fd2ngT+WnTuYk9FhQMNdmzWVPJTZP+Y8iYq+1bvG3R9JBWBCctsRrsVidzxupj1AZ KqIUD+Bq+/6vJuux5ziZPsBS4bZ/QOPs8pI7a26s= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 503ACwhM112379 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 3 Jan 2025 04:12:58 -0600 Received: from DFLE112.ent.ti.com (10.64.6.33) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 3 Jan 2025 04:12:58 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Fri, 3 Jan 2025 04:12:58 -0600 Received: from uda0510294.dhcp.ti.com (uda0510294.dhcp.ti.com [172.24.227.151]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 503ACVSO126047; Fri, 3 Jan 2025 04:12:54 -0600 From: Beleswar Padhi To: , CC: , , , , , , , , , , Subject: [PATCH v8 06/20] remoteproc: k3: Refactor rproc_reset() implementation into common driver Date: Fri, 3 Jan 2025 15:42:17 +0530 Message-ID: <20250103101231.1508151-7-b-padhi@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103101231.1508151-1-b-padhi@ti.com> References: <20250103101231.1508151-1-b-padhi@ti.com> Precedence: bulk X-Mailing-List: linux-remoteproc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea The k3_dsp_rproc_reset() function erroneously asserts the local reset even for devices which do not support it. Even though it results in a no-operation, Update the logic to explicitly assert the local reset for devices that support it and only the global reset for those that do not. Further, refactor the above function into the ti_k3_common.c driver as k3_rproc_reset() and use it throughout DSP and M4 drivers for resetting the remote processor. Signed-off-by: Beleswar Padhi --- drivers/remoteproc/ti_k3_common.c | 25 +++++++++++++++++++ drivers/remoteproc/ti_k3_common.h | 1 + drivers/remoteproc/ti_k3_dsp_remoteproc.c | 30 ++--------------------- drivers/remoteproc/ti_k3_m4_remoteproc.c | 16 +++--------- 4 files changed, 31 insertions(+), 41 deletions(-) diff --git a/drivers/remoteproc/ti_k3_common.c b/drivers/remoteproc/ti_k3_common.c index bd6353283078..8f4cc52c1332 100644 --- a/drivers/remoteproc/ti_k3_common.c +++ b/drivers/remoteproc/ti_k3_common.c @@ -117,5 +117,30 @@ void k3_rproc_kick(struct rproc *rproc, int vqid) } EXPORT_SYMBOL_GPL(k3_rproc_kick); +/* Put the remote processor into reset */ +int k3_rproc_reset(struct k3_rproc *kproc) +{ + struct device *dev = kproc->dev; + int ret; + + if (kproc->data->uses_lreset) { + ret = reset_control_assert(kproc->reset); + if (ret) + dev_err(dev, "local-reset assert failed (%pe)\n", ERR_PTR(ret)); + return ret; + } + + ret = kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci, + kproc->ti_sci_id); + if (ret) { + dev_err(dev, "module-reset assert failed (%pe)\n", ERR_PTR(ret)); + if (reset_control_deassert(kproc->reset)) + dev_warn(dev, "local-reset deassert back failed\n"); + } + + return ret; +} +EXPORT_SYMBOL_GPL(k3_rproc_reset); + MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("TI K3 common Remoteproc code"); diff --git a/drivers/remoteproc/ti_k3_common.h b/drivers/remoteproc/ti_k3_common.h index 57792d68b7ef..52f784ada496 100644 --- a/drivers/remoteproc/ti_k3_common.h +++ b/drivers/remoteproc/ti_k3_common.h @@ -90,4 +90,5 @@ struct k3_rproc { void k3_rproc_mbox_callback(struct mbox_client *client, void *data); void k3_rproc_kick(struct rproc *rproc, int vqid); +int k3_rproc_reset(struct k3_rproc *kproc); #endif /* REMOTEPROC_TI_K3_COMMON_H */ diff --git a/drivers/remoteproc/ti_k3_dsp_remoteproc.c b/drivers/remoteproc/ti_k3_dsp_remoteproc.c index b2551b5171a9..045b1e81d06c 100644 --- a/drivers/remoteproc/ti_k3_dsp_remoteproc.c +++ b/drivers/remoteproc/ti_k3_dsp_remoteproc.c @@ -24,32 +24,6 @@ #define KEYSTONE_RPROC_LOCAL_ADDRESS_MASK (SZ_16M - 1) -/* Put the DSP processor into reset */ -static int k3_dsp_rproc_reset(struct k3_rproc *kproc) -{ - struct device *dev = kproc->dev; - int ret; - - ret = reset_control_assert(kproc->reset); - if (ret) { - dev_err(dev, "local-reset assert failed (%pe)\n", ERR_PTR(ret)); - return ret; - } - - if (kproc->data->uses_lreset) - return ret; - - ret = kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci, - kproc->ti_sci_id); - if (ret) { - dev_err(dev, "module-reset assert failed (%pe)\n", ERR_PTR(ret)); - if (reset_control_deassert(kproc->reset)) - dev_warn(dev, "local-reset deassert back failed\n"); - } - - return ret; -} - /* Release the DSP processor from reset */ static int k3_dsp_rproc_release(struct k3_rproc *kproc) { @@ -203,7 +177,7 @@ static int k3_dsp_rproc_stop(struct rproc *rproc) { struct k3_rproc *kproc = rproc->priv; - k3_dsp_rproc_reset(kproc); + k3_rproc_reset(kproc); return 0; } @@ -584,7 +558,7 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) return dev_err_probe(dev, ret, "failed to get reset status\n"); } else if (ret == 0) { dev_warn(dev, "local reset is deasserted for device\n"); - k3_dsp_rproc_reset(kproc); + k3_rproc_reset(kproc); } } } diff --git a/drivers/remoteproc/ti_k3_m4_remoteproc.c b/drivers/remoteproc/ti_k3_m4_remoteproc.c index fc688b124a54..d31cf9babf1d 100644 --- a/drivers/remoteproc/ti_k3_m4_remoteproc.c +++ b/drivers/remoteproc/ti_k3_m4_remoteproc.c @@ -65,11 +65,9 @@ static int k3_m4_rproc_prepare(struct rproc *rproc) * Ensure the local reset is asserted so the core doesn't * execute bogus code when the module reset is released. */ - ret = reset_control_assert(kproc->reset); - if (ret) { - dev_err(dev, "could not assert local reset\n"); + ret = k3_rproc_reset(kproc); + if (ret) return ret; - } ret = reset_control_status(kproc->reset); if (ret <= 0) { @@ -374,16 +372,8 @@ static int k3_m4_rproc_start(struct rproc *rproc) static int k3_m4_rproc_stop(struct rproc *rproc) { struct k3_rproc *kproc = rproc->priv; - struct device *dev = kproc->dev; - int ret; - ret = reset_control_assert(kproc->reset); - if (ret) { - dev_err(dev, "local-reset assert failed, ret = %d\n", ret); - return ret; - } - - return 0; + return k3_rproc_reset(kproc); } /* From patchwork Fri Jan 3 10:12:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beleswar Prasad Padhi X-Patchwork-Id: 13925461 Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E45C11F9F75; Fri, 3 Jan 2025 10:13:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899194; cv=none; b=gpCg53txTL3QhQ/bUCaDsmjEC2BOuWrN6tMnR+CWnsLTSZTgKUtEZmFQ4T7pxBuIK4oc3a5DHVcH4L9qtUQRJsUteY/t88Dx0L0NapXYYVz3Tc++N/zZenfUkbYZkT8gFWsWqfwoqFgJop8V+FBSt/1Y9ShItKwfMu53YaNuens= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899194; c=relaxed/simple; bh=r2wIasGEClrDJxcFyrPt6OS2ds0xiD7/1YtYeEinklw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IX5iYJz/3o91FhgVljtONip5a8GhFkDP38aNYSiK2LYTTJeOt1V+f3r/HEjXaozgvIkP1tIgEWoRS3ZYUDIYeJ6cJgwuldz7Wfm3VIh+9WrYQT39o5UmhVqyJxOkn7APEaxZRzffGqYVFpxxbNNULWtSUS2YoyZjTUx7O14/iJY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=fRyVG3J2; arc=none smtp.client-ip=198.47.19.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="fRyVG3J2" Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 503AD2s0033585; Fri, 3 Jan 2025 04:13:02 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1735899182; bh=3OaDFkprKgvZiVPCfSGh/Lb6TcLawnwA3Tz8FOz6CK4=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=fRyVG3J2fB71PQUcYAyXzWu84wL8GJ7VrpyPrrHsBXiY9/jYgwsDlOc0E3B4f9+Wk e8mlmx5we9nra6kwtGQ1UewxzmToSofvxxF4r3qIKvSRK4z5T3+nLm25ICbsyGKFkt /FtrgSgq0kRi+uO4bo9FO8/LuW9i9ep8zoOcZcGY= Received: from DFLE102.ent.ti.com (dfle102.ent.ti.com [10.64.6.23]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 503AD2Rx125968 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 3 Jan 2025 04:13:02 -0600 Received: from DFLE102.ent.ti.com (10.64.6.23) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 3 Jan 2025 04:13:01 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Fri, 3 Jan 2025 04:13:01 -0600 Received: from uda0510294.dhcp.ti.com (uda0510294.dhcp.ti.com [172.24.227.151]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 503ACVSP126047; Fri, 3 Jan 2025 04:12:58 -0600 From: Beleswar Padhi To: , CC: , , , , , , , , , , Subject: [PATCH v8 07/20] remoteproc: k3: Refactor rproc_release() implementation into common driver Date: Fri, 3 Jan 2025 15:42:18 +0530 Message-ID: <20250103101231.1508151-8-b-padhi@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103101231.1508151-1-b-padhi@ti.com> References: <20250103101231.1508151-1-b-padhi@ti.com> Precedence: bulk X-Mailing-List: linux-remoteproc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea The k3_dsp_rproc_release() function erroneously deasserts the local reset even for devices which do not support it. Even though it results in a no-operation, Update the logic to explicitly deassert the local reset for devices that support it and only the global reset for those that do not. Further, refactor the above function into the ti_k3_common.c driver as k3_rproc_release() and use it throughout DSP and M4 drivers for releasing the reset from the remote processor. Signed-off-by: Beleswar Padhi --- drivers/remoteproc/ti_k3_common.c | 27 ++++++++++++++++++++ drivers/remoteproc/ti_k3_common.h | 1 + drivers/remoteproc/ti_k3_dsp_remoteproc.c | 30 +---------------------- drivers/remoteproc/ti_k3_m4_remoteproc.c | 8 +++--- 4 files changed, 32 insertions(+), 34 deletions(-) diff --git a/drivers/remoteproc/ti_k3_common.c b/drivers/remoteproc/ti_k3_common.c index 8f4cc52c1332..cec664819a1d 100644 --- a/drivers/remoteproc/ti_k3_common.c +++ b/drivers/remoteproc/ti_k3_common.c @@ -142,5 +142,32 @@ int k3_rproc_reset(struct k3_rproc *kproc) } EXPORT_SYMBOL_GPL(k3_rproc_reset); +/* Release the remote processor from reset */ +int k3_rproc_release(struct k3_rproc *kproc) +{ + struct device *dev = kproc->dev; + int ret; + + if (kproc->data->uses_lreset) { + ret = reset_control_deassert(kproc->reset); + if (ret) { + dev_err(dev, "local-reset deassert failed, (%pe)\n", ERR_PTR(ret)); + if (kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci, + kproc->ti_sci_id)) + dev_warn(dev, "module-reset assert back failed\n"); + } + + return ret; + } + + ret = kproc->ti_sci->ops.dev_ops.get_device(kproc->ti_sci, + kproc->ti_sci_id); + if (ret) + dev_err(dev, "module-reset deassert failed (%pe)\n", ERR_PTR(ret)); + + return ret; +} +EXPORT_SYMBOL_GPL(k3_rproc_release); + MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("TI K3 common Remoteproc code"); diff --git a/drivers/remoteproc/ti_k3_common.h b/drivers/remoteproc/ti_k3_common.h index 52f784ada496..37516765e505 100644 --- a/drivers/remoteproc/ti_k3_common.h +++ b/drivers/remoteproc/ti_k3_common.h @@ -91,4 +91,5 @@ struct k3_rproc { void k3_rproc_mbox_callback(struct mbox_client *client, void *data); void k3_rproc_kick(struct rproc *rproc, int vqid); int k3_rproc_reset(struct k3_rproc *kproc); +int k3_rproc_release(struct k3_rproc *kproc); #endif /* REMOTEPROC_TI_K3_COMMON_H */ diff --git a/drivers/remoteproc/ti_k3_dsp_remoteproc.c b/drivers/remoteproc/ti_k3_dsp_remoteproc.c index 045b1e81d06c..64affbe0ba29 100644 --- a/drivers/remoteproc/ti_k3_dsp_remoteproc.c +++ b/drivers/remoteproc/ti_k3_dsp_remoteproc.c @@ -24,34 +24,6 @@ #define KEYSTONE_RPROC_LOCAL_ADDRESS_MASK (SZ_16M - 1) -/* Release the DSP processor from reset */ -static int k3_dsp_rproc_release(struct k3_rproc *kproc) -{ - struct device *dev = kproc->dev; - int ret; - - if (kproc->data->uses_lreset) - goto lreset; - - ret = kproc->ti_sci->ops.dev_ops.get_device(kproc->ti_sci, - kproc->ti_sci_id); - if (ret) { - dev_err(dev, "module-reset deassert failed (%pe)\n", ERR_PTR(ret)); - return ret; - } - -lreset: - ret = reset_control_deassert(kproc->reset); - if (ret) { - dev_err(dev, "local-reset deassert failed, (%pe)\n", ERR_PTR(ret)); - if (kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci, - kproc->ti_sci_id)) - dev_warn(dev, "module-reset assert back failed\n"); - } - - return ret; -} - static int k3_dsp_rproc_request_mbox(struct rproc *rproc) { struct k3_rproc *kproc = rproc->priv; @@ -160,7 +132,7 @@ static int k3_dsp_rproc_start(struct rproc *rproc) if (ret) return ret; - ret = k3_dsp_rproc_release(kproc); + ret = k3_rproc_release(kproc); if (ret) return ret; diff --git a/drivers/remoteproc/ti_k3_m4_remoteproc.c b/drivers/remoteproc/ti_k3_m4_remoteproc.c index d31cf9babf1d..c24085411e1c 100644 --- a/drivers/remoteproc/ti_k3_m4_remoteproc.c +++ b/drivers/remoteproc/ti_k3_m4_remoteproc.c @@ -354,13 +354,11 @@ static int k3_m4_rproc_start(struct rproc *rproc) if (ret) return ret; - ret = reset_control_deassert(kproc->reset); - if (ret) { + ret = k3_rproc_release(kproc); + if (ret) dev_err(dev, "local-reset deassert failed, ret = %d\n", ret); - return ret; - } - return 0; + return ret; } /* From patchwork Fri Jan 3 10:12:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beleswar Prasad Padhi X-Patchwork-Id: 13925462 Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9594A1F943F; Fri, 3 Jan 2025 10:13:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899199; cv=none; b=XIFtdVblYyS21u4ooLdFIqWICmS/TBVfTcbF112b6E0vHDjHByYSPfoZ9BQ0qMuBZDfbP79/ml7y5ZbcDvO9VRTH3kh7VxRM4p3KLt4Je13mla0RNBKUsc+2bQCDv0EVVQ4hWr4PeZPngE/EPotqs1UqR8mkLmGmZ8KgHX/znF4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899199; c=relaxed/simple; bh=0NQkNgYmoCoPTHF3IqcIRO+FUsrsnggW6J/3BVgMcng=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pl0D/QarordNtsWrACAjVzcSKEuWe1jH38khzuC+VBvgecMvCgSy+dH2G1hapcJ9dYZEfK13m1qpwv7ZqsKvSiMqfsEDGiHezJUD3KyymnvBaZK7qXO5A7xtZCVPxZMTJ+81dprd3vytcL/r75VZixHt7VqZ+ENhdaU1QgxvBt0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=A0hd0gtz; arc=none smtp.client-ip=198.47.19.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="A0hd0gtz" Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 503AD5iW033596; Fri, 3 Jan 2025 04:13:05 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1735899185; bh=ZcbFZqP8Z4NUAMCntYlwy0RskYls8rWZ0AY3/2eX4Aw=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=A0hd0gtzUTV5MNCa8NXZ5r8X15jVqkMDDhpnBNKUC25aEQep8ONbyJXrC+o+8f12O evS3ollqq6uLquhc/H3TWoOBXP6tV6ZpVpD2uAj5kkl5v2BoRsXBXeRsN07Saf2Sm4 q3e7rCTVdwNzUoeirRxX+Ku/8a5Ov2nuzRDbj3G8= Received: from DFLE109.ent.ti.com (dfle109.ent.ti.com [10.64.6.30]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 503AD5fp112707 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 3 Jan 2025 04:13:05 -0600 Received: from DFLE107.ent.ti.com (10.64.6.28) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 3 Jan 2025 04:13:05 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE107.ent.ti.com (10.64.6.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Fri, 3 Jan 2025 04:13:05 -0600 Received: from uda0510294.dhcp.ti.com (uda0510294.dhcp.ti.com [172.24.227.151]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 503ACVSQ126047; Fri, 3 Jan 2025 04:13:02 -0600 From: Beleswar Padhi To: , CC: , , , , , , , , , , Subject: [PATCH v8 08/20] remoteproc: k3: Refactor rproc_request_mbox() implementations into common driver Date: Fri, 3 Jan 2025 15:42:19 +0530 Message-ID: <20250103101231.1508151-9-b-padhi@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103101231.1508151-1-b-padhi@ti.com> References: <20250103101231.1508151-1-b-padhi@ti.com> Precedence: bulk X-Mailing-List: linux-remoteproc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea The k3_dsp_rproc_request_mbox() function acquires the mailbox channel and sends a message through the acquired channel. The ti_k3_m4_remoteproc.c driver acquires the mailbox channel in probe and sends the message later in .attach()/.start() callbacks. Refactor the k3_dsp_rproc_request_mbox() function into ti_k3_common.c as k3_rproc_request_mbox() and align DSP and M4 drivers to use this common function during probe routine. Signed-off-by: Beleswar Padhi --- drivers/remoteproc/ti_k3_common.c | 36 +++++++++++++++++++ drivers/remoteproc/ti_k3_common.h | 1 + drivers/remoteproc/ti_k3_dsp_remoteproc.c | 36 +------------------ drivers/remoteproc/ti_k3_m4_remoteproc.c | 42 ++--------------------- 4 files changed, 41 insertions(+), 74 deletions(-) diff --git a/drivers/remoteproc/ti_k3_common.c b/drivers/remoteproc/ti_k3_common.c index cec664819a1d..a78abecf2756 100644 --- a/drivers/remoteproc/ti_k3_common.c +++ b/drivers/remoteproc/ti_k3_common.c @@ -169,5 +169,41 @@ int k3_rproc_release(struct k3_rproc *kproc) } EXPORT_SYMBOL_GPL(k3_rproc_release); +int k3_rproc_request_mbox(struct rproc *rproc) +{ + struct k3_rproc *kproc = rproc->priv; + struct mbox_client *client = &kproc->client; + struct device *dev = kproc->dev; + int ret; + + client->dev = dev; + client->tx_done = NULL; + client->rx_callback = k3_rproc_mbox_callback; + client->tx_block = false; + client->knows_txdone = false; + + kproc->mbox = mbox_request_channel(client, 0); + if (IS_ERR(kproc->mbox)) + return dev_err_probe(dev, PTR_ERR(kproc->mbox), + "mbox_request_channel failed\n"); + + /* + * Ping the remote processor, this is only for sanity-sake for now; + * there is no functional effect whatsoever. + * + * Note that the reply will _not_ arrive immediately: this message + * will wait in the mailbox fifo until the remote processor is booted. + */ + ret = mbox_send_message(kproc->mbox, (void *)RP_MBOX_ECHO_REQUEST); + if (ret < 0) { + dev_err(dev, "mbox_send_message failed (%pe)\n", ERR_PTR(ret)); + mbox_free_channel(kproc->mbox); + return ret; + } + + return 0; +} +EXPORT_SYMBOL_GPL(k3_rproc_request_mbox); + MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("TI K3 common Remoteproc code"); diff --git a/drivers/remoteproc/ti_k3_common.h b/drivers/remoteproc/ti_k3_common.h index 37516765e505..8e44c0455c39 100644 --- a/drivers/remoteproc/ti_k3_common.h +++ b/drivers/remoteproc/ti_k3_common.h @@ -92,4 +92,5 @@ void k3_rproc_mbox_callback(struct mbox_client *client, void *data); void k3_rproc_kick(struct rproc *rproc, int vqid); int k3_rproc_reset(struct k3_rproc *kproc); int k3_rproc_release(struct k3_rproc *kproc); +int k3_rproc_request_mbox(struct rproc *rproc); #endif /* REMOTEPROC_TI_K3_COMMON_H */ diff --git a/drivers/remoteproc/ti_k3_dsp_remoteproc.c b/drivers/remoteproc/ti_k3_dsp_remoteproc.c index 64affbe0ba29..c8bab63a4f4d 100644 --- a/drivers/remoteproc/ti_k3_dsp_remoteproc.c +++ b/drivers/remoteproc/ti_k3_dsp_remoteproc.c @@ -24,40 +24,6 @@ #define KEYSTONE_RPROC_LOCAL_ADDRESS_MASK (SZ_16M - 1) -static int k3_dsp_rproc_request_mbox(struct rproc *rproc) -{ - struct k3_rproc *kproc = rproc->priv; - struct mbox_client *client = &kproc->client; - struct device *dev = kproc->dev; - int ret; - - client->dev = dev; - client->tx_done = NULL; - client->rx_callback = k3_rproc_mbox_callback; - client->tx_block = false; - client->knows_txdone = false; - - kproc->mbox = mbox_request_channel(client, 0); - if (IS_ERR(kproc->mbox)) - return dev_err_probe(dev, PTR_ERR(kproc->mbox), - "mbox_request_channel failed\n"); - - /* - * Ping the remote processor, this is only for sanity-sake for now; - * there is no functional effect whatsoever. - * - * Note that the reply will _not_ arrive immediately: this message - * will wait in the mailbox fifo until the remote processor is booted. - */ - ret = mbox_send_message(kproc->mbox, (void *)RP_MBOX_ECHO_REQUEST); - if (ret < 0) { - dev_err(dev, "mbox_send_message failed (%pe)\n", ERR_PTR(ret)); - mbox_free_channel(kproc->mbox); - return ret; - } - - return 0; -} /* * The C66x DSP cores have a local reset that affects only the CPU, and a * generic module reset that powers on the device and allows the DSP internal @@ -460,7 +426,7 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) kproc->dev = dev; kproc->data = data; - ret = k3_dsp_rproc_request_mbox(rproc); + ret = k3_rproc_request_mbox(rproc); if (ret) return ret; diff --git a/drivers/remoteproc/ti_k3_m4_remoteproc.c b/drivers/remoteproc/ti_k3_m4_remoteproc.c index c24085411e1c..6dd93c8d0553 100644 --- a/drivers/remoteproc/ti_k3_m4_remoteproc.c +++ b/drivers/remoteproc/ti_k3_m4_remoteproc.c @@ -21,27 +21,6 @@ #include "ti_sci_proc.h" #include "ti_k3_common.h" -static int k3_m4_rproc_ping_mbox(struct k3_rproc *kproc) -{ - struct device *dev = kproc->dev; - int ret; - - /* - * Ping the remote processor, this is only for sanity-sake for now; - * there is no functional effect whatsoever. - * - * Note that the reply will _not_ arrive immediately: this message - * will wait in the mailbox fifo until the remote processor is booted. - */ - ret = mbox_send_message(kproc->mbox, (void *)RP_MBOX_ECHO_REQUEST); - if (ret < 0) { - dev_err(dev, "mbox_send_message failed: %d\n", ret); - return ret; - } - - return 0; -} - /* * The M4 cores have a local reset that affects only the CPU, and a * generic module reset that powers on the device and allows the internal @@ -350,10 +329,6 @@ static int k3_m4_rproc_start(struct rproc *rproc) struct device *dev = kproc->dev; int ret; - ret = k3_m4_rproc_ping_mbox(kproc); - if (ret) - return ret; - ret = k3_rproc_release(kproc); if (ret) dev_err(dev, "local-reset deassert failed, ret = %d\n", ret); @@ -386,14 +361,9 @@ static int k3_m4_rproc_stop(struct rproc *rproc) static int k3_m4_rproc_attach(struct rproc *rproc) { struct k3_rproc *kproc = rproc->priv; - int ret; kproc->is_attach_ongoing = true; - ret = k3_m4_rproc_ping_mbox(kproc); - if (ret) - return ret; - return 0; } @@ -506,15 +476,9 @@ static int k3_m4_rproc_probe(struct platform_device *pdev) dev_info(dev, "configured M4F for remoteproc mode\n"); } - kproc->client.dev = dev; - kproc->client.tx_done = NULL; - kproc->client.rx_callback = k3_rproc_mbox_callback; - kproc->client.tx_block = false; - kproc->client.knows_txdone = false; - kproc->mbox = mbox_request_channel(&kproc->client, 0); - if (IS_ERR(kproc->mbox)) - return dev_err_probe(dev, PTR_ERR(kproc->mbox), - "mbox_request_channel failed\n"); + ret = k3_rproc_request_mbox(rproc); + if (ret) + return ret; ret = devm_rproc_add(dev, rproc); if (ret) From patchwork Fri Jan 3 10:12:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beleswar Prasad Padhi X-Patchwork-Id: 13925463 Received: from lelvem-ot01.ext.ti.com (lelvem-ot01.ext.ti.com [198.47.23.234]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0790D1F8EF9; Fri, 3 Jan 2025 10:13:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.234 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899203; cv=none; b=Pn/mcJckXqyVcEy9k2FwWRlr3Qy3ZrUIMWuaQS0JXtObcUkbNxhyXo8uob3X8RUl5UwFU1p8gjbk5gpF7ZgvmO03lGvaHPY2JrmcfzvRonz8gsaUmOW0kOUrIU1znn7q3swHDBFJF4ncVqZrEoE6OO8p2Tn5YGMVvkK8H18wGC8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899203; c=relaxed/simple; bh=Lltou93Tx6+7HaAaR5g+83Va7G64bRdecPX8m2vRsr0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QNYYA1kcgudsJAIkUJhjb+/liRjp/FNVcbDYBpjnSy/AVviW3ISdeTxzDouQmJOktOGLNBnJgAWz6FY7RFnz+QoqxuICWZZzLeuS+pZHmuIsIF3VjMCLT5JBKwaW96M+lgyx4V3fDwML3+DgcQnpUGt8ZjDvSQZ1FIPgZsMweZY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=YreilqoC; arc=none smtp.client-ip=198.47.23.234 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="YreilqoC" Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelvem-ot01.ext.ti.com (8.15.2/8.15.2) with ESMTPS id 503AD9QG2076419 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 3 Jan 2025 04:13:09 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1735899189; bh=JM5GiY79Te21OH84xe04G9U6i4kFv5LmBItYTCoTcdw=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=YreilqoCEYbw1IOK1NokDMF+VrxlLjXr+HnjZDj4z9mj90Z0F1ZVtOKIprs4gSHCl LkEfXPNCUQKcRQAkpU9B9LQyncxqVHwO272EHHYjN1PajlLzVqK9pL6MVvAGyMwkOB HK3wLVN4hNHze+m5hxzuCqxpXu6Hygd0nT/hV3Uo= Received: from DFLE104.ent.ti.com (dfle104.ent.ti.com [10.64.6.25]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTP id 503AD9Iq042032; Fri, 3 Jan 2025 04:13:09 -0600 Received: from DFLE105.ent.ti.com (10.64.6.26) by DFLE104.ent.ti.com (10.64.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 3 Jan 2025 04:13:09 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Fri, 3 Jan 2025 04:13:09 -0600 Received: from uda0510294.dhcp.ti.com (uda0510294.dhcp.ti.com [172.24.227.151]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 503ACVSR126047; Fri, 3 Jan 2025 04:13:05 -0600 From: Beleswar Padhi To: , CC: , , , , , , , , , , Subject: [PATCH v8 09/20] remoteproc: k3: Refactor .prepare rproc ops into common driver Date: Fri, 3 Jan 2025 15:42:20 +0530 Message-ID: <20250103101231.1508151-10-b-padhi@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103101231.1508151-1-b-padhi@ti.com> References: <20250103101231.1508151-1-b-padhi@ti.com> Precedence: bulk X-Mailing-List: linux-remoteproc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea The ti_k3_dsp_remoteproc.c driver asserts the local reset in probe and releases the global reset in .prepare callback. Whereas, the ti_k3_m4_remoteproc.c driver does both operations in .prepare callback, which is more suitable as it ensures lreset is asserted for subsequent core start operations from sysfs. Refactor the k3_m4_rproc_prepare() function into the ti_k3_common.c driver as k3_rproc_prepare() and align DSP and M4 drivers to register this common function as .prepare ops. Signed-off-by: Beleswar Padhi --- drivers/remoteproc/ti_k3_common.c | 46 +++++++++++++++++++++++ drivers/remoteproc/ti_k3_common.h | 1 + drivers/remoteproc/ti_k3_dsp_remoteproc.c | 42 +-------------------- drivers/remoteproc/ti_k3_m4_remoteproc.c | 45 +--------------------- 4 files changed, 49 insertions(+), 85 deletions(-) diff --git a/drivers/remoteproc/ti_k3_common.c b/drivers/remoteproc/ti_k3_common.c index a78abecf2756..699528e4a369 100644 --- a/drivers/remoteproc/ti_k3_common.c +++ b/drivers/remoteproc/ti_k3_common.c @@ -205,5 +205,51 @@ int k3_rproc_request_mbox(struct rproc *rproc) } EXPORT_SYMBOL_GPL(k3_rproc_request_mbox); +/* + * The K3 DSP and M4 cores have a local reset that affects only the CPU, and a + * generic module reset that powers on the device and allows the internal + * memories to be accessed while the local reset is asserted. This function is + * used to release the global reset on remote cores to allow loading into the + * internal RAMs. The .prepare() ops is invoked by remoteproc core before any + * firmware loading, and is followed by the .start() ops after loading to + * actually let the remote cores to run. + */ +int k3_rproc_prepare(struct rproc *rproc) +{ + struct k3_rproc *kproc = rproc->priv; + struct device *dev = kproc->dev; + int ret; + + /* If the core is running already no need to deassert the module reset */ + if (rproc->state == RPROC_DETACHED) + return 0; + + /* + * Ensure the local reset is asserted so the core doesn't + * execute bogus code when the module reset is released. + */ + if (kproc->data->uses_lreset) { + ret = k3_rproc_reset(kproc); + if (ret) + return ret; + + ret = reset_control_status(kproc->reset); + if (ret <= 0) { + dev_err(dev, "local reset still not asserted\n"); + return ret; + } + } + + ret = kproc->ti_sci->ops.dev_ops.get_device(kproc->ti_sci, + kproc->ti_sci_id); + if (ret) { + dev_err(dev, "could not deassert module-reset for internal RAM loading\n"); + return ret; + } + + return 0; +} +EXPORT_SYMBOL_GPL(k3_rproc_prepare); + MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("TI K3 common Remoteproc code"); diff --git a/drivers/remoteproc/ti_k3_common.h b/drivers/remoteproc/ti_k3_common.h index 8e44c0455c39..22dd6e13f47a 100644 --- a/drivers/remoteproc/ti_k3_common.h +++ b/drivers/remoteproc/ti_k3_common.h @@ -93,4 +93,5 @@ void k3_rproc_kick(struct rproc *rproc, int vqid); int k3_rproc_reset(struct k3_rproc *kproc); int k3_rproc_release(struct k3_rproc *kproc); int k3_rproc_request_mbox(struct rproc *rproc); +int k3_rproc_prepare(struct rproc *rproc); #endif /* REMOTEPROC_TI_K3_COMMON_H */ diff --git a/drivers/remoteproc/ti_k3_dsp_remoteproc.c b/drivers/remoteproc/ti_k3_dsp_remoteproc.c index c8bab63a4f4d..078bfb9aa233 100644 --- a/drivers/remoteproc/ti_k3_dsp_remoteproc.c +++ b/drivers/remoteproc/ti_k3_dsp_remoteproc.c @@ -24,31 +24,6 @@ #define KEYSTONE_RPROC_LOCAL_ADDRESS_MASK (SZ_16M - 1) -/* - * The C66x DSP cores have a local reset that affects only the CPU, and a - * generic module reset that powers on the device and allows the DSP internal - * memories to be accessed while the local reset is asserted. This function is - * used to release the global reset on C66x DSPs to allow loading into the DSP - * internal RAMs. The .prepare() ops is invoked by remoteproc core before any - * firmware loading, and is followed by the .start() ops after loading to - * actually let the C66x DSP cores run. This callback is invoked only in - * remoteproc mode. - */ -static int k3_dsp_rproc_prepare(struct rproc *rproc) -{ - struct k3_rproc *kproc = rproc->priv; - struct device *dev = kproc->dev; - int ret; - - ret = kproc->ti_sci->ops.dev_ops.get_device(kproc->ti_sci, - kproc->ti_sci_id); - if (ret) - dev_err(dev, "module-reset deassert failed, cannot enable internal RAM loading (%pe)\n", - ERR_PTR(ret)); - - return ret; -} - /* * This function implements the .unprepare() ops and performs the complimentary * operations to that of the .prepare() ops. The function is used to assert the @@ -418,7 +393,7 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) rproc->has_iommu = false; rproc->recovery_disabled = true; if (data->uses_lreset) { - rproc->ops->prepare = k3_dsp_rproc_prepare; + rproc->ops->prepare = k3_rproc_prepare; rproc->ops->unprepare = k3_dsp_rproc_unprepare; } kproc = rproc->priv; @@ -476,7 +451,6 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) dev_info(dev, "configured DSP for IPC-only mode\n"); rproc->state = RPROC_DETACHED; /* override rproc ops with only required IPC-only mode ops */ - rproc->ops->prepare = NULL; rproc->ops->unprepare = NULL; rproc->ops->start = NULL; rproc->ops->stop = NULL; @@ -485,20 +459,6 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) rproc->ops->get_loaded_rsc_table = k3_dsp_get_loaded_rsc_table; } else { dev_info(dev, "configured DSP for remoteproc mode\n"); - /* - * ensure the DSP local reset is asserted to ensure the DSP - * doesn't execute bogus code in .prepare() when the module - * reset is released. - */ - if (data->uses_lreset) { - ret = reset_control_status(kproc->reset); - if (ret < 0) { - return dev_err_probe(dev, ret, "failed to get reset status\n"); - } else if (ret == 0) { - dev_warn(dev, "local reset is deasserted for device\n"); - k3_rproc_reset(kproc); - } - } } ret = devm_rproc_add(dev, rproc); diff --git a/drivers/remoteproc/ti_k3_m4_remoteproc.c b/drivers/remoteproc/ti_k3_m4_remoteproc.c index 6dd93c8d0553..218d4bf941a1 100644 --- a/drivers/remoteproc/ti_k3_m4_remoteproc.c +++ b/drivers/remoteproc/ti_k3_m4_remoteproc.c @@ -21,49 +21,6 @@ #include "ti_sci_proc.h" #include "ti_k3_common.h" -/* - * The M4 cores have a local reset that affects only the CPU, and a - * generic module reset that powers on the device and allows the internal - * memories to be accessed while the local reset is asserted. This function is - * used to release the global reset on remote cores to allow loading into the - * internal RAMs. The .prepare() ops is invoked by remoteproc core before any - * firmware loading, and is followed by the .start() ops after loading to - * actually let the remote cores to run. - */ -static int k3_m4_rproc_prepare(struct rproc *rproc) -{ - struct k3_rproc *kproc = rproc->priv; - struct device *dev = kproc->dev; - int ret; - - /* If the core is running already no need to deassert the module reset */ - if (rproc->state == RPROC_DETACHED) - return 0; - - /* - * Ensure the local reset is asserted so the core doesn't - * execute bogus code when the module reset is released. - */ - ret = k3_rproc_reset(kproc); - if (ret) - return ret; - - ret = reset_control_status(kproc->reset); - if (ret <= 0) { - dev_err(dev, "local reset still not asserted\n"); - return ret; - } - - ret = kproc->ti_sci->ops.dev_ops.get_device(kproc->ti_sci, - kproc->ti_sci_id); - if (ret) { - dev_err(dev, "could not deassert module-reset for internal RAM loading\n"); - return ret; - } - - return 0; -} - /* * This function implements the .unprepare() ops and performs the complimentary * operations to that of the .prepare() ops. The function is used to assert the @@ -386,7 +343,7 @@ static int k3_m4_rproc_detach(struct rproc *rproc) } static const struct rproc_ops k3_m4_rproc_ops = { - .prepare = k3_m4_rproc_prepare, + .prepare = k3_rproc_prepare, .unprepare = k3_m4_rproc_unprepare, .start = k3_m4_rproc_start, .stop = k3_m4_rproc_stop, From patchwork Fri Jan 3 10:12:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beleswar Prasad Padhi X-Patchwork-Id: 13925464 Received: from lelvem-ot02.ext.ti.com (lelvem-ot02.ext.ti.com [198.47.23.235]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1B00E1EE7B0; Fri, 3 Jan 2025 10:13:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.235 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899205; cv=none; b=SMQaCBM/XnxWYwFSDC7q8ygF4VLfLNltrgNqo7K3BusPiUjrsEZSlY5TZ9VTuRnBL4q+9ES5WgFm33hi8E7Q7rHRj6Tn9OFAcyLLrAf27eCGFpVdhmr3TjrWu5YhnHjobWoPRF/wM52LjGZgOVU70L/qMwXAXLL8dwr52PSX+DA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899205; c=relaxed/simple; bh=9NlnU2wV+eu8xzM0zsHqoTSMIuuJCLbvm9OF4x3ZJfY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ai8SaLxPhNaxDWglTk5gGrbTUI5kA6oXrv6l2g4Wb9CH/ncYQk0Pd1o4/K57sTuN4E0bU00gHOr09EYvSkqz4ADorT2i9cPROrT2SZUciISI5uVRIhXeOpBCEgcHflj7Xl5M5g6V9l6dWJHnQmHfT5iItdHJofSaL4VEzS/fqFc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=DGw2Lau3; arc=none smtp.client-ip=198.47.23.235 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="DGw2Lau3" Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelvem-ot02.ext.ti.com (8.15.2/8.15.2) with ESMTPS id 503ADDV92382606 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 3 Jan 2025 04:13:13 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1735899193; bh=GPPkcqF4fd7djkR7onT0McQCLzdM8Tvzvyt7KIxkv3U=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=DGw2Lau3F1ii50a0BA2VD261BZpD2tMzfBbMxoAcnRlBG7bRWgft2w/nrA2Abxshr 6/7Dq0vFtvS8llg/IpMfhxcs7WAe5yzDvAgbFsXmaGDhwjarc/WXGEz5uaUtnqdmKL //aSE2wC1eFl9/mZKVbUnPPu3qFEnObmJ9+imfDQ= Received: from DLEE105.ent.ti.com (dlee105.ent.ti.com [157.170.170.35]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTP id 503ADDBl042057; Fri, 3 Jan 2025 04:13:13 -0600 Received: from DLEE111.ent.ti.com (157.170.170.22) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 3 Jan 2025 04:13:13 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE111.ent.ti.com (157.170.170.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Fri, 3 Jan 2025 04:13:12 -0600 Received: from uda0510294.dhcp.ti.com (uda0510294.dhcp.ti.com [172.24.227.151]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 503ACVSS126047; Fri, 3 Jan 2025 04:13:09 -0600 From: Beleswar Padhi To: , CC: , , , , , , , , , , Subject: [PATCH v8 10/20] remoteproc: k3: Refactor .unprepare rproc ops into common driver Date: Fri, 3 Jan 2025 15:42:21 +0530 Message-ID: <20250103101231.1508151-11-b-padhi@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103101231.1508151-1-b-padhi@ti.com> References: <20250103101231.1508151-1-b-padhi@ti.com> Precedence: bulk X-Mailing-List: linux-remoteproc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea The .unprepare rproc ops implementations in ti_k3_dsp_remoteproc.c and ti_k3_m4_remoteproc.c drivers assert the global reset on the remote processor. Refactor the implementations into ti_k3_common.c driver as k3_rproc_unprepare() and align DSP and M4 drivers to register this common function as .unprepare ops. Signed-off-by: Beleswar Padhi --- drivers/remoteproc/ti_k3_common.c | 30 ++++++++++++++++++++++ drivers/remoteproc/ti_k3_common.h | 1 + drivers/remoteproc/ti_k3_dsp_remoteproc.c | 26 +------------------ drivers/remoteproc/ti_k3_m4_remoteproc.c | 31 +---------------------- 4 files changed, 33 insertions(+), 55 deletions(-) diff --git a/drivers/remoteproc/ti_k3_common.c b/drivers/remoteproc/ti_k3_common.c index 699528e4a369..7fd8c8394d95 100644 --- a/drivers/remoteproc/ti_k3_common.c +++ b/drivers/remoteproc/ti_k3_common.c @@ -251,5 +251,35 @@ int k3_rproc_prepare(struct rproc *rproc) } EXPORT_SYMBOL_GPL(k3_rproc_prepare); +/* + * This function implements the .unprepare() ops and performs the complimentary + * operations to that of the .prepare() ops. The function is used to assert the + * global reset on applicable K3 DSP and M4 cores. This completes the second + * portion of powering down the remote core. The cores themselves are only + * halted in the .stop() callback through the local reset, and the .unprepare() + * ops is invoked by the remoteproc core after the remoteproc is stopped to + * balance the global reset. + */ +int k3_rproc_unprepare(struct rproc *rproc) +{ + struct k3_rproc *kproc = rproc->priv; + struct device *dev = kproc->dev; + int ret; + + /* If the core is going to be detached do not assert the module reset */ + if (rproc->state == RPROC_ATTACHED) + return 0; + + ret = kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci, + kproc->ti_sci_id); + if (ret) { + dev_err(dev, "module-reset assert failed\n"); + return ret; + } + + return 0; +} +EXPORT_SYMBOL_GPL(k3_rproc_unprepare); + MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("TI K3 common Remoteproc code"); diff --git a/drivers/remoteproc/ti_k3_common.h b/drivers/remoteproc/ti_k3_common.h index 22dd6e13f47a..b6b977e16af6 100644 --- a/drivers/remoteproc/ti_k3_common.h +++ b/drivers/remoteproc/ti_k3_common.h @@ -94,4 +94,5 @@ int k3_rproc_reset(struct k3_rproc *kproc); int k3_rproc_release(struct k3_rproc *kproc); int k3_rproc_request_mbox(struct rproc *rproc); int k3_rproc_prepare(struct rproc *rproc); +int k3_rproc_unprepare(struct rproc *rproc); #endif /* REMOTEPROC_TI_K3_COMMON_H */ diff --git a/drivers/remoteproc/ti_k3_dsp_remoteproc.c b/drivers/remoteproc/ti_k3_dsp_remoteproc.c index 078bfb9aa233..7e7aca192d0a 100644 --- a/drivers/remoteproc/ti_k3_dsp_remoteproc.c +++ b/drivers/remoteproc/ti_k3_dsp_remoteproc.c @@ -24,29 +24,6 @@ #define KEYSTONE_RPROC_LOCAL_ADDRESS_MASK (SZ_16M - 1) -/* - * This function implements the .unprepare() ops and performs the complimentary - * operations to that of the .prepare() ops. The function is used to assert the - * global reset on applicable C66x cores. This completes the second portion of - * powering down the C66x DSP cores. The cores themselves are only halted in the - * .stop() callback through the local reset, and the .unprepare() ops is invoked - * by the remoteproc core after the remoteproc is stopped to balance the global - * reset. This callback is invoked only in remoteproc mode. - */ -static int k3_dsp_rproc_unprepare(struct rproc *rproc) -{ - struct k3_rproc *kproc = rproc->priv; - struct device *dev = kproc->dev; - int ret; - - ret = kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci, - kproc->ti_sci_id); - if (ret) - dev_err(dev, "module-reset assert failed (%pe)\n", ERR_PTR(ret)); - - return ret; -} - /* * Power up the DSP remote processor. * @@ -394,7 +371,7 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) rproc->recovery_disabled = true; if (data->uses_lreset) { rproc->ops->prepare = k3_rproc_prepare; - rproc->ops->unprepare = k3_dsp_rproc_unprepare; + rproc->ops->unprepare = k3_rproc_unprepare; } kproc = rproc->priv; kproc->rproc = rproc; @@ -451,7 +428,6 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) dev_info(dev, "configured DSP for IPC-only mode\n"); rproc->state = RPROC_DETACHED; /* override rproc ops with only required IPC-only mode ops */ - rproc->ops->unprepare = NULL; rproc->ops->start = NULL; rproc->ops->stop = NULL; rproc->ops->attach = k3_dsp_rproc_attach; diff --git a/drivers/remoteproc/ti_k3_m4_remoteproc.c b/drivers/remoteproc/ti_k3_m4_remoteproc.c index 218d4bf941a1..25f013fa7511 100644 --- a/drivers/remoteproc/ti_k3_m4_remoteproc.c +++ b/drivers/remoteproc/ti_k3_m4_remoteproc.c @@ -21,35 +21,6 @@ #include "ti_sci_proc.h" #include "ti_k3_common.h" -/* - * This function implements the .unprepare() ops and performs the complimentary - * operations to that of the .prepare() ops. The function is used to assert the - * global reset on applicable cores. This completes the second portion of - * powering down the remote core. The cores themselves are only halted in the - * .stop() callback through the local reset, and the .unprepare() ops is invoked - * by the remoteproc core after the remoteproc is stopped to balance the global - * reset. - */ -static int k3_m4_rproc_unprepare(struct rproc *rproc) -{ - struct k3_rproc *kproc = rproc->priv; - struct device *dev = kproc->dev; - int ret; - - /* If the core is going to be detached do not assert the module reset */ - if (rproc->state == RPROC_ATTACHED) - return 0; - - ret = kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci, - kproc->ti_sci_id); - if (ret) { - dev_err(dev, "module-reset assert failed\n"); - return ret; - } - - return 0; -} - /* * This function implements the .get_loaded_rsc_table() callback and is used * to provide the resource table for a booted remote processor in IPC-only @@ -344,7 +315,7 @@ static int k3_m4_rproc_detach(struct rproc *rproc) static const struct rproc_ops k3_m4_rproc_ops = { .prepare = k3_rproc_prepare, - .unprepare = k3_m4_rproc_unprepare, + .unprepare = k3_rproc_unprepare, .start = k3_m4_rproc_start, .stop = k3_m4_rproc_stop, .attach = k3_m4_rproc_attach, From patchwork Fri Jan 3 10:12:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beleswar Prasad Padhi X-Patchwork-Id: 13925465 Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 479BB1FA24D; Fri, 3 Jan 2025 10:13:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899210; cv=none; b=bG9rqyetMICxa8eLiH3LVF5J9LR/Rq7OujNbmj/uIeumH9UcyXTGpsY0sj5nOdTT6f9RaV1vla/Vanpy7HgR1JAN/X+PQQKq20z4CqGNaZWdmJupTWCHH2JJ1USB9zWbTiQkAPeuPQJXBJ+9Jd8iqh/RJnfsTPH3eX2CuloDoP4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899210; c=relaxed/simple; bh=jQtXpwcwW7agOm98SEHPAz+qH6vwanUc/xASpzTjjUA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hnWLrkEzweiyLoWBXhLhAsxYlndq0CPKlnsIdXCRr3Dy0aFV/5Brf2hXogEDIMNrXRH7v0ctvqLYNIQLltBsc1rv0L4XswEIq5BmiTi4YwRocH9hBkDJhoXo1ZG6QMagbl9tjsqTEJFiL92Pa44qUVjULdrF9ohUAoPtWQVhS34= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=ctXVuqA9; arc=none smtp.client-ip=198.47.19.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="ctXVuqA9" Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 503ADHQq033617; Fri, 3 Jan 2025 04:13:17 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1735899197; bh=eJypcE39LhLmZrmnDZSY8wRBVWXkWGdgWsm/rwuIKKs=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ctXVuqA93Fn8/Fc8nnsgCz7Ng1HkTdABGEoDPvMebjhQMOeoZi9B+AMvB4eMicGLZ Y44lc9tQdOmONMHV5OZ4acpDVF2xAzpDdIwI6TJTD9BJNMBP6g1L/jIPQJjtylqzyx U8ozuz8OBIFEmQa+bgFsUCaMs/WxJw0wH3Bs/O5g= Received: from DFLE100.ent.ti.com (dfle100.ent.ti.com [10.64.6.21]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 503ADHcp112777 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 3 Jan 2025 04:13:17 -0600 Received: from DFLE103.ent.ti.com (10.64.6.24) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 3 Jan 2025 04:13:16 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE103.ent.ti.com (10.64.6.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Fri, 3 Jan 2025 04:13:16 -0600 Received: from uda0510294.dhcp.ti.com (uda0510294.dhcp.ti.com [172.24.227.151]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 503ACVST126047; Fri, 3 Jan 2025 04:13:13 -0600 From: Beleswar Padhi To: , CC: , , , , , , , , , , Subject: [PATCH v8 11/20] remoteproc: k3: Refactor .start rproc ops into common driver Date: Fri, 3 Jan 2025 15:42:22 +0530 Message-ID: <20250103101231.1508151-12-b-padhi@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103101231.1508151-1-b-padhi@ti.com> References: <20250103101231.1508151-1-b-padhi@ti.com> Precedence: bulk X-Mailing-List: linux-remoteproc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea The k3_dsp_rproc_start() function sets the boot address and releases the reset on the remote processor. Whereas, the k3_m4_rproc_start() function only needs to release the reset. Refactor the k3_m4_rproc_start() into ti_k3_common.c as k3_rproc_start() and align the DSP and M4 drivers to invoke this common function when releasing the reset on the remote processor. Further, do not override the .start ops with NULL when operating in IPC-only mode in ti_k3_dsp_remoteproc.c, as .start is never invoked in rproc_attach routine. Signed-off-by: Beleswar Padhi --- drivers/remoteproc/ti_k3_common.c | 15 +++++++++++++++ drivers/remoteproc/ti_k3_common.h | 1 + drivers/remoteproc/ti_k3_dsp_remoteproc.c | 4 ++-- drivers/remoteproc/ti_k3_m4_remoteproc.c | 22 +--------------------- 4 files changed, 19 insertions(+), 23 deletions(-) diff --git a/drivers/remoteproc/ti_k3_common.c b/drivers/remoteproc/ti_k3_common.c index 7fd8c8394d95..b1d828dbb334 100644 --- a/drivers/remoteproc/ti_k3_common.c +++ b/drivers/remoteproc/ti_k3_common.c @@ -281,5 +281,20 @@ int k3_rproc_unprepare(struct rproc *rproc) } EXPORT_SYMBOL_GPL(k3_rproc_unprepare); +/* + * Power up the remote processor. + * + * This function will be invoked only after the firmware for this rproc + * was loaded, parsed successfully, and all of its resource requirements + * were met. This callback is invoked only in remoteproc mode. + */ +int k3_rproc_start(struct rproc *rproc) +{ + struct k3_rproc *kproc = rproc->priv; + + return k3_rproc_release(kproc); +} +EXPORT_SYMBOL_GPL(k3_rproc_start); + MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("TI K3 common Remoteproc code"); diff --git a/drivers/remoteproc/ti_k3_common.h b/drivers/remoteproc/ti_k3_common.h index b6b977e16af6..2eb1539b3bb9 100644 --- a/drivers/remoteproc/ti_k3_common.h +++ b/drivers/remoteproc/ti_k3_common.h @@ -95,4 +95,5 @@ int k3_rproc_release(struct k3_rproc *kproc); int k3_rproc_request_mbox(struct rproc *rproc); int k3_rproc_prepare(struct rproc *rproc); int k3_rproc_unprepare(struct rproc *rproc); +int k3_rproc_start(struct rproc *rproc); #endif /* REMOTEPROC_TI_K3_COMMON_H */ diff --git a/drivers/remoteproc/ti_k3_dsp_remoteproc.c b/drivers/remoteproc/ti_k3_dsp_remoteproc.c index 7e7aca192d0a..75ab86b4e82a 100644 --- a/drivers/remoteproc/ti_k3_dsp_remoteproc.c +++ b/drivers/remoteproc/ti_k3_dsp_remoteproc.c @@ -50,7 +50,8 @@ static int k3_dsp_rproc_start(struct rproc *rproc) if (ret) return ret; - ret = k3_rproc_release(kproc); + /* Call the K3 common start function after doing DSP specific stuff */ + ret = k3_rproc_start(rproc); if (ret) return ret; @@ -428,7 +429,6 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) dev_info(dev, "configured DSP for IPC-only mode\n"); rproc->state = RPROC_DETACHED; /* override rproc ops with only required IPC-only mode ops */ - rproc->ops->start = NULL; rproc->ops->stop = NULL; rproc->ops->attach = k3_dsp_rproc_attach; rproc->ops->detach = k3_dsp_rproc_detach; diff --git a/drivers/remoteproc/ti_k3_m4_remoteproc.c b/drivers/remoteproc/ti_k3_m4_remoteproc.c index 25f013fa7511..0f1237172233 100644 --- a/drivers/remoteproc/ti_k3_m4_remoteproc.c +++ b/drivers/remoteproc/ti_k3_m4_remoteproc.c @@ -244,26 +244,6 @@ static void k3_m4_release_tsp(void *data) ti_sci_proc_release(tsp); } -/* - * Power up the M4 remote processor. - * - * This function will be invoked only after the firmware for this rproc - * was loaded, parsed successfully, and all of its resource requirements - * were met. This callback is invoked only in remoteproc mode. - */ -static int k3_m4_rproc_start(struct rproc *rproc) -{ - struct k3_rproc *kproc = rproc->priv; - struct device *dev = kproc->dev; - int ret; - - ret = k3_rproc_release(kproc); - if (ret) - dev_err(dev, "local-reset deassert failed, ret = %d\n", ret); - - return ret; -} - /* * Stop the M4 remote processor. * @@ -316,7 +296,7 @@ static int k3_m4_rproc_detach(struct rproc *rproc) static const struct rproc_ops k3_m4_rproc_ops = { .prepare = k3_rproc_prepare, .unprepare = k3_rproc_unprepare, - .start = k3_m4_rproc_start, + .start = k3_rproc_start, .stop = k3_m4_rproc_stop, .attach = k3_m4_rproc_attach, .detach = k3_m4_rproc_detach, From patchwork Fri Jan 3 10:12:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beleswar Prasad Padhi X-Patchwork-Id: 13925466 Received: from lelvem-ot01.ext.ti.com (lelvem-ot01.ext.ti.com [198.47.23.234]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 159AB1F9ABE; Fri, 3 Jan 2025 10:13:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.234 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899212; cv=none; b=KK0aPhHTAOv9x8dL/n6sX8WQV54E/vBK5ouFQCyPAPkc79mjxQuI1m+ycIWp2QjjbIQuDOQm0ZERSTiBJLJO0DzSeyuu5uDQz5OJCG3VkF/coATTTvuiOmmmiF3509lzP8a6DdOnoDjWSVEWmIkCC66V/xuyeuJrq4Px62D4/PM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899212; c=relaxed/simple; bh=aWiSdpQK7zjWmyyPvOl2065qt+wdx8FE84XxTzz/zTw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=T8x1lfIZifa3RVbucNqdOh83HiXPFJ+KwYCnG1iG0DTK0zwpg+t+xEOVqLYHdBWqWWPvuTmtS1W7QA/MmKJGi+Qg7a/hiG4lkb6+U5ZrBV+Oeqeezp8ieoeOPHpDnD5kZpBSKPdHJ+NyuyqaWLGcCGV3G3S7GD6HT8qbjdDh9DA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=AYExwbda; arc=none smtp.client-ip=198.47.23.234 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="AYExwbda" Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelvem-ot01.ext.ti.com (8.15.2/8.15.2) with ESMTPS id 503ADKTp2076457 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 3 Jan 2025 04:13:20 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1735899200; bh=35hrPhQ5n9mdBVcW2Cv4EXTWVLDWerTPkAv7UtqS630=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=AYExwbdatvclz40uVjUWXNBa8yW30Q76G1S+7AsziqXCfqy6yVMeojxPXhLs2iJr6 e+q4g43sOU8Ma9zMMpWCdHS2lE43U0HToPwImJCyz/jmmoAkFPL7ElYDJqjHppNDgZ mTTo8IsyAD+2zn3UhmT+CM5o+ff5bMfcySgX5OMQ= Received: from DFLE114.ent.ti.com (dfle114.ent.ti.com [10.64.6.35]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 503ADK07012436 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 3 Jan 2025 04:13:20 -0600 Received: from DFLE114.ent.ti.com (10.64.6.35) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 3 Jan 2025 04:13:20 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Fri, 3 Jan 2025 04:13:20 -0600 Received: from uda0510294.dhcp.ti.com (uda0510294.dhcp.ti.com [172.24.227.151]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 503ACVSU126047; Fri, 3 Jan 2025 04:13:17 -0600 From: Beleswar Padhi To: , CC: , , , , , , , , , , Subject: [PATCH v8 12/20] remoteproc: k3: Refactor .stop rproc ops into common driver Date: Fri, 3 Jan 2025 15:42:23 +0530 Message-ID: <20250103101231.1508151-13-b-padhi@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103101231.1508151-1-b-padhi@ti.com> References: <20250103101231.1508151-1-b-padhi@ti.com> Precedence: bulk X-Mailing-List: linux-remoteproc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea The .stop rproc ops implementations in ti_k3_dsp_remoteproc.c and ti_k3_m4_remoteproc.c drivers put the remote processor into reset. Refactor the implementations into ti_k3_common.c driver as k3_rproc_stop() and align DSP and M4 drivers to register this common function as .stop ops. Further, do not override the .stop ops with NULL when operating in IPC-only mode in ti_k3_dsp_remoteproc.c, as .stop is never invoked in rproc_detach routine. Signed-off-by: Beleswar Padhi --- drivers/remoteproc/ti_k3_common.c | 14 ++++++++++++++ drivers/remoteproc/ti_k3_common.h | 1 + drivers/remoteproc/ti_k3_dsp_remoteproc.c | 18 +----------------- drivers/remoteproc/ti_k3_m4_remoteproc.c | 15 +-------------- 4 files changed, 17 insertions(+), 31 deletions(-) diff --git a/drivers/remoteproc/ti_k3_common.c b/drivers/remoteproc/ti_k3_common.c index b1d828dbb334..799152d1a736 100644 --- a/drivers/remoteproc/ti_k3_common.c +++ b/drivers/remoteproc/ti_k3_common.c @@ -296,5 +296,19 @@ int k3_rproc_start(struct rproc *rproc) } EXPORT_SYMBOL_GPL(k3_rproc_start); +/* + * Stop the remote processor. + * + * This function puts the remote processor into reset, and finishes processing + * of any pending messages. This callback is invoked only in remoteproc mode. + */ +int k3_rproc_stop(struct rproc *rproc) +{ + struct k3_rproc *kproc = rproc->priv; + + return k3_rproc_reset(kproc); +} +EXPORT_SYMBOL_GPL(k3_rproc_stop); + MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("TI K3 common Remoteproc code"); diff --git a/drivers/remoteproc/ti_k3_common.h b/drivers/remoteproc/ti_k3_common.h index 2eb1539b3bb9..bfcb5d086cff 100644 --- a/drivers/remoteproc/ti_k3_common.h +++ b/drivers/remoteproc/ti_k3_common.h @@ -96,4 +96,5 @@ int k3_rproc_request_mbox(struct rproc *rproc); int k3_rproc_prepare(struct rproc *rproc); int k3_rproc_unprepare(struct rproc *rproc); int k3_rproc_start(struct rproc *rproc); +int k3_rproc_stop(struct rproc *rproc); #endif /* REMOTEPROC_TI_K3_COMMON_H */ diff --git a/drivers/remoteproc/ti_k3_dsp_remoteproc.c b/drivers/remoteproc/ti_k3_dsp_remoteproc.c index 75ab86b4e82a..a9896ba51399 100644 --- a/drivers/remoteproc/ti_k3_dsp_remoteproc.c +++ b/drivers/remoteproc/ti_k3_dsp_remoteproc.c @@ -58,21 +58,6 @@ static int k3_dsp_rproc_start(struct rproc *rproc) return 0; } -/* - * Stop the DSP remote processor. - * - * This function puts the DSP processor into reset, and finishes processing - * of any pending messages. This callback is invoked only in remoteproc mode. - */ -static int k3_dsp_rproc_stop(struct rproc *rproc) -{ - struct k3_rproc *kproc = rproc->priv; - - k3_rproc_reset(kproc); - - return 0; -} - /* * Attach to a running DSP remote processor (IPC-only mode) * @@ -203,7 +188,7 @@ static void *k3_dsp_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool static const struct rproc_ops k3_dsp_rproc_ops = { .start = k3_dsp_rproc_start, - .stop = k3_dsp_rproc_stop, + .stop = k3_rproc_stop, .kick = k3_rproc_kick, .da_to_va = k3_dsp_rproc_da_to_va, }; @@ -429,7 +414,6 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) dev_info(dev, "configured DSP for IPC-only mode\n"); rproc->state = RPROC_DETACHED; /* override rproc ops with only required IPC-only mode ops */ - rproc->ops->stop = NULL; rproc->ops->attach = k3_dsp_rproc_attach; rproc->ops->detach = k3_dsp_rproc_detach; rproc->ops->get_loaded_rsc_table = k3_dsp_get_loaded_rsc_table; diff --git a/drivers/remoteproc/ti_k3_m4_remoteproc.c b/drivers/remoteproc/ti_k3_m4_remoteproc.c index 0f1237172233..27bf8ed49f59 100644 --- a/drivers/remoteproc/ti_k3_m4_remoteproc.c +++ b/drivers/remoteproc/ti_k3_m4_remoteproc.c @@ -244,19 +244,6 @@ static void k3_m4_release_tsp(void *data) ti_sci_proc_release(tsp); } -/* - * Stop the M4 remote processor. - * - * This function puts the M4 processor into reset, and finishes processing - * of any pending messages. This callback is invoked only in remoteproc mode. - */ -static int k3_m4_rproc_stop(struct rproc *rproc) -{ - struct k3_rproc *kproc = rproc->priv; - - return k3_rproc_reset(kproc); -} - /* * Attach to a running M4 remote processor (IPC-only mode) * @@ -297,7 +284,7 @@ static const struct rproc_ops k3_m4_rproc_ops = { .prepare = k3_rproc_prepare, .unprepare = k3_rproc_unprepare, .start = k3_rproc_start, - .stop = k3_m4_rproc_stop, + .stop = k3_rproc_stop, .attach = k3_m4_rproc_attach, .detach = k3_m4_rproc_detach, .kick = k3_rproc_kick, From patchwork Fri Jan 3 10:12:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beleswar Prasad Padhi X-Patchwork-Id: 13925467 Received: from lelvem-ot02.ext.ti.com (lelvem-ot02.ext.ti.com [198.47.23.235]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0FA911FA84A; Fri, 3 Jan 2025 10:13:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.235 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899215; cv=none; b=EVkEa7Xa0YcuRWf+lsSWLGPLCC3T8XaJNY9OqqpbsLlceHATRUtPOkjQhwt7XJIYJzXL8Q9en9B4yfLAUCxmSVsv7PHH9dAnivKKld4JjSTvNXoRMGF3jkNlvsGNDMWkjMMJ3RaReiuk3LZ2Hnfls4foch0towjEoh8rzJqyDq4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899215; c=relaxed/simple; bh=HGWhO5DY563RVZtr1WtD3aDkGj33a3vpzvohs5DBaZI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PdZk52PgctnpSi2fjt/C0OPL/7GGJTpFH8JcXdlKcQEX1qTG+XDyNFl0Iya47kT975cjf9swt/6h76KzcNCrfbXssDTX/FDAE5XDDad2iUAmItgzl5V2cNX2rYRRa8JxizF3rBhy+KVTxGmqFMCRrGhzxatWRxChHUiBDa9b28k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=ogwKeIDv; arc=none smtp.client-ip=198.47.23.235 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="ogwKeIDv" Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelvem-ot02.ext.ti.com (8.15.2/8.15.2) with ESMTPS id 503ADO5O2382614 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 3 Jan 2025 04:13:24 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1735899204; bh=uRd82LX/k2X+x0gz85aF0ANVYLU3nlil1bS1yS2k/x8=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ogwKeIDvYzPBH/AeTT+j8G4AqBSi22ZfbQSrVak4kB3w7ooZKIFld4+uukuhUAneg yAeYraM2IP29Mczfd9WJXq66gwIBKB1k2UYuLPnVwYa9GLbzWeM45VjK/uSPtqPyH0 pPaRIetmKaWKJiUUvAW5F/48CUkentnTaNG0W75w= Received: from DFLE104.ent.ti.com (dfle104.ent.ti.com [10.64.6.25]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 503ADOlB126173 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 3 Jan 2025 04:13:24 -0600 Received: from DFLE105.ent.ti.com (10.64.6.26) by DFLE104.ent.ti.com (10.64.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 3 Jan 2025 04:13:24 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Fri, 3 Jan 2025 04:13:24 -0600 Received: from uda0510294.dhcp.ti.com (uda0510294.dhcp.ti.com [172.24.227.151]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 503ACVSV126047; Fri, 3 Jan 2025 04:13:20 -0600 From: Beleswar Padhi To: , CC: , , , , , , , , , , Subject: [PATCH v8 13/20] remoteproc: k3: Refactor .attach rproc ops into common driver Date: Fri, 3 Jan 2025 15:42:24 +0530 Message-ID: <20250103101231.1508151-14-b-padhi@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103101231.1508151-1-b-padhi@ti.com> References: <20250103101231.1508151-1-b-padhi@ti.com> Precedence: bulk X-Mailing-List: linux-remoteproc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea The .attach rproc ops implementations in ti_k3_dsp_remoteproc.c and ti_k3_m4_remoteproc.c drivers set the "is_attach_ongoing" flag to signify that the core is undergoing transition from detached to attached state. Refactor the implementations into ti_k3_common.c driver as k3_rproc_attach() and align DSP and M4 drivers to register this common function as .attach ops. Signed-off-by: Beleswar Padhi --- drivers/remoteproc/ti_k3_common.c | 20 ++++++++++++++++++++ drivers/remoteproc/ti_k3_common.h | 1 + drivers/remoteproc/ti_k3_dsp_remoteproc.c | 21 +-------------------- drivers/remoteproc/ti_k3_m4_remoteproc.c | 20 +------------------- 4 files changed, 23 insertions(+), 39 deletions(-) diff --git a/drivers/remoteproc/ti_k3_common.c b/drivers/remoteproc/ti_k3_common.c index 799152d1a736..296a47de9d72 100644 --- a/drivers/remoteproc/ti_k3_common.c +++ b/drivers/remoteproc/ti_k3_common.c @@ -310,5 +310,25 @@ int k3_rproc_stop(struct rproc *rproc) } EXPORT_SYMBOL_GPL(k3_rproc_stop); +/* + * Attach to a running remote processor (IPC-only mode) + * + * This rproc attach callback only needs to set the "is_attach_ongoing" flag to + * notify k3_rproc_{kick/mbox_callback} functions that the core is in the + * process of getting attached in IPC-only mode. The remote processor is already + * booted, and all required resources have been acquired during probe routine, + * so there is no need to issue any TI-SCI commands to boot the remote core. + * This callback is invoked only in IPC-only mode. + */ +int k3_rproc_attach(struct rproc *rproc) +{ + struct k3_rproc *kproc = rproc->priv; + + kproc->is_attach_ongoing = true; + + return 0; +} +EXPORT_SYMBOL_GPL(k3_rproc_attach); + MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("TI K3 common Remoteproc code"); diff --git a/drivers/remoteproc/ti_k3_common.h b/drivers/remoteproc/ti_k3_common.h index bfcb5d086cff..89175cb5a006 100644 --- a/drivers/remoteproc/ti_k3_common.h +++ b/drivers/remoteproc/ti_k3_common.h @@ -97,4 +97,5 @@ int k3_rproc_prepare(struct rproc *rproc); int k3_rproc_unprepare(struct rproc *rproc); int k3_rproc_start(struct rproc *rproc); int k3_rproc_stop(struct rproc *rproc); +int k3_rproc_attach(struct rproc *rproc); #endif /* REMOTEPROC_TI_K3_COMMON_H */ diff --git a/drivers/remoteproc/ti_k3_dsp_remoteproc.c b/drivers/remoteproc/ti_k3_dsp_remoteproc.c index a9896ba51399..43c1eda47be2 100644 --- a/drivers/remoteproc/ti_k3_dsp_remoteproc.c +++ b/drivers/remoteproc/ti_k3_dsp_remoteproc.c @@ -58,25 +58,6 @@ static int k3_dsp_rproc_start(struct rproc *rproc) return 0; } -/* - * Attach to a running DSP remote processor (IPC-only mode) - * - * This rproc attach callback only needs to set the "is_attach_ongoing" flag to - * notify k3_rproc_{kick/mbox_callback} functions that the core is in the - * process of getting attached in IPC-only mode. The remote processor is already - * booted, and all required resources have been acquired during probe routine, - * so there is no need to issue any TI-SCI commands to boot the DSP core. This - * callback is invoked only in IPC-only mode. - */ -static int k3_dsp_rproc_attach(struct rproc *rproc) -{ - struct k3_rproc *kproc = rproc->priv; - - kproc->is_attach_ongoing = true; - - return 0; -} - /* * Detach from a running DSP remote processor (IPC-only mode) * @@ -189,6 +170,7 @@ static void *k3_dsp_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool static const struct rproc_ops k3_dsp_rproc_ops = { .start = k3_dsp_rproc_start, .stop = k3_rproc_stop, + .attach = k3_rproc_attach, .kick = k3_rproc_kick, .da_to_va = k3_dsp_rproc_da_to_va, }; @@ -414,7 +396,6 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) dev_info(dev, "configured DSP for IPC-only mode\n"); rproc->state = RPROC_DETACHED; /* override rproc ops with only required IPC-only mode ops */ - rproc->ops->attach = k3_dsp_rproc_attach; rproc->ops->detach = k3_dsp_rproc_detach; rproc->ops->get_loaded_rsc_table = k3_dsp_get_loaded_rsc_table; } else { diff --git a/drivers/remoteproc/ti_k3_m4_remoteproc.c b/drivers/remoteproc/ti_k3_m4_remoteproc.c index 27bf8ed49f59..e78e35c1375c 100644 --- a/drivers/remoteproc/ti_k3_m4_remoteproc.c +++ b/drivers/remoteproc/ti_k3_m4_remoteproc.c @@ -244,24 +244,6 @@ static void k3_m4_release_tsp(void *data) ti_sci_proc_release(tsp); } -/* - * Attach to a running M4 remote processor (IPC-only mode) - * - * This rproc attach callback only needs to set the "is_attach_ongoing" flag to - * notify k3_rproc_{kick/mbox_callback} functions that the core is in the - * process of getting attached in IPC-only mode. The remote processor is already - * booted, so there is no need to issue any TI-SCI commands to boot the M4 core. - * This callback is used only in IPC-only mode. - */ -static int k3_m4_rproc_attach(struct rproc *rproc) -{ - struct k3_rproc *kproc = rproc->priv; - - kproc->is_attach_ongoing = true; - - return 0; -} - /* * Detach from a running M4 remote processor (IPC-only mode) * @@ -285,7 +267,7 @@ static const struct rproc_ops k3_m4_rproc_ops = { .unprepare = k3_rproc_unprepare, .start = k3_rproc_start, .stop = k3_rproc_stop, - .attach = k3_m4_rproc_attach, + .attach = k3_rproc_attach, .detach = k3_m4_rproc_detach, .kick = k3_rproc_kick, .da_to_va = k3_m4_rproc_da_to_va, From patchwork Fri Jan 3 10:12:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beleswar Prasad Padhi X-Patchwork-Id: 13925468 Received: from lelvem-ot01.ext.ti.com (lelvem-ot01.ext.ti.com [198.47.23.234]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 384821FA8CA; Fri, 3 Jan 2025 10:13:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.234 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899219; cv=none; b=AxSu8Dv6tytNN/iXRc7ZJN6xWIgrUOyjVoqAcT+c+5lb+EOA9Xfx2kMTQlvRgXUYt3KapFli2BU/+zKgSqSgr0iJwcd493Kn+SLTcnDNVUTtz1HJjHFuWjs7lWYZNjDl/tSTTQOQMfQrI4fdiG6tnQtiRtAcsCxBvOL6zFTErIU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899219; c=relaxed/simple; bh=WxYHpwnj589i3r7ggcViWjJur51iO7WpbyOqo4RDzxw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LkR/Uu/25OwHH4gofxEjGRbaK8gzz9fl5WsDwjRoACfb1efrlgPfWMDci6fYoWKKmZZPnDTq9crZ+Lvl6MbQjmDNlQR1zwWStcCi1CzVkRPh0zTGl4m/4IjxCLs1EIbAT/fj402AgLc2ijmFQF0kvwFO2DEU6/j97sx1r6e9PoM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=BAqvvZFB; arc=none smtp.client-ip=198.47.23.234 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="BAqvvZFB" Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelvem-ot01.ext.ti.com (8.15.2/8.15.2) with ESMTPS id 503ADSkm2076649 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 3 Jan 2025 04:13:28 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1735899208; bh=cMXq3nzKtZoHJpAJ/F6gjJpkrH4JmCG/sD2OvNtujqw=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=BAqvvZFB3fkG+VxX8dzNOaaFtU9QD/UkZcJNMGg9WkryK5exuW3eK6koFCpClM1LS q6YntZrO0xUxzxOEeAmAhDjv7k1pYJ0YriHKlw/5BIBYJwLXAGh/DPDH8VLJ828Pst poGBLJglo4x50TnzKBOlvYz3QxezwxYLxQP/rdkQ= Received: from DLEE115.ent.ti.com (dlee115.ent.ti.com [157.170.170.26]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 503ADSTW126191 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 3 Jan 2025 04:13:28 -0600 Received: from DLEE109.ent.ti.com (157.170.170.41) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 3 Jan 2025 04:13:27 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE109.ent.ti.com (157.170.170.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Fri, 3 Jan 2025 04:13:27 -0600 Received: from uda0510294.dhcp.ti.com (uda0510294.dhcp.ti.com [172.24.227.151]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 503ACVSW126047; Fri, 3 Jan 2025 04:13:24 -0600 From: Beleswar Padhi To: , CC: , , , , , , , , , , Subject: [PATCH v8 14/20] remoteproc: k3: Refactor .detach rproc ops into common driver Date: Fri, 3 Jan 2025 15:42:25 +0530 Message-ID: <20250103101231.1508151-15-b-padhi@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103101231.1508151-1-b-padhi@ti.com> References: <20250103101231.1508151-1-b-padhi@ti.com> Precedence: bulk X-Mailing-List: linux-remoteproc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea The .detach rproc ops implementations in ti_k3_dsp_remoteproc.c and ti_k3_m4_remoteproc.c drivers clears the "is_attach_ongoing" flag which was set in .attach ops. Refactor the implementations into ti_k3_common.c driver as k3_rproc_detach() and align DSP and M4 drivers to register this common function as .detach ops. Signed-off-by: Beleswar Padhi --- drivers/remoteproc/ti_k3_common.c | 19 +++++++++++++++++++ drivers/remoteproc/ti_k3_common.h | 1 + drivers/remoteproc/ti_k3_dsp_remoteproc.c | 20 +------------------- drivers/remoteproc/ti_k3_m4_remoteproc.c | 20 +------------------- 4 files changed, 22 insertions(+), 38 deletions(-) diff --git a/drivers/remoteproc/ti_k3_common.c b/drivers/remoteproc/ti_k3_common.c index 296a47de9d72..b5ef2ac0d399 100644 --- a/drivers/remoteproc/ti_k3_common.c +++ b/drivers/remoteproc/ti_k3_common.c @@ -330,5 +330,24 @@ int k3_rproc_attach(struct rproc *rproc) } EXPORT_SYMBOL_GPL(k3_rproc_attach); +/* + * Detach from a running remote processor (IPC-only mode) + * + * This rproc detach callback performs the opposite operation to attach callback + * and only needs to clear the "is_attach_ongoing" flag to ensure no mailbox + * messages are sent to or received from a detached core. The remote core is not + * stopped and will be left to continue to run its booted firmware. This callback + * is invoked only in IPC-only mode. + */ +int k3_rproc_detach(struct rproc *rproc) +{ + struct k3_rproc *kproc = rproc->priv; + + kproc->is_attach_ongoing = false; + + return 0; +} +EXPORT_SYMBOL_GPL(k3_rproc_detach); + MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("TI K3 common Remoteproc code"); diff --git a/drivers/remoteproc/ti_k3_common.h b/drivers/remoteproc/ti_k3_common.h index 89175cb5a006..c7be85b0e5ac 100644 --- a/drivers/remoteproc/ti_k3_common.h +++ b/drivers/remoteproc/ti_k3_common.h @@ -98,4 +98,5 @@ int k3_rproc_unprepare(struct rproc *rproc); int k3_rproc_start(struct rproc *rproc); int k3_rproc_stop(struct rproc *rproc); int k3_rproc_attach(struct rproc *rproc); +int k3_rproc_detach(struct rproc *rproc); #endif /* REMOTEPROC_TI_K3_COMMON_H */ diff --git a/drivers/remoteproc/ti_k3_dsp_remoteproc.c b/drivers/remoteproc/ti_k3_dsp_remoteproc.c index 43c1eda47be2..dd81bcc8e1e4 100644 --- a/drivers/remoteproc/ti_k3_dsp_remoteproc.c +++ b/drivers/remoteproc/ti_k3_dsp_remoteproc.c @@ -58,24 +58,6 @@ static int k3_dsp_rproc_start(struct rproc *rproc) return 0; } -/* - * Detach from a running DSP remote processor (IPC-only mode) - * - * This rproc detach callback performs the opposite operation to attach callback - * and only needs to clear the "is_attach_ongoing" flag to ensure no mailbox - * messages are sent to or received from a detached core. The DSP core is not - * stopped and will be left to continue to run its booted firmware. This callback - * is invoked only in IPC-only mode. - */ -static int k3_dsp_rproc_detach(struct rproc *rproc) -{ - struct k3_rproc *kproc = rproc->priv; - - kproc->is_attach_ongoing = false; - - return 0; -} - /* * This function implements the .get_loaded_rsc_table() callback and is used * to provide the resource table for a booted DSP in IPC-only mode. The K3 DSP @@ -171,6 +153,7 @@ static const struct rproc_ops k3_dsp_rproc_ops = { .start = k3_dsp_rproc_start, .stop = k3_rproc_stop, .attach = k3_rproc_attach, + .detach = k3_rproc_detach, .kick = k3_rproc_kick, .da_to_va = k3_dsp_rproc_da_to_va, }; @@ -396,7 +379,6 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) dev_info(dev, "configured DSP for IPC-only mode\n"); rproc->state = RPROC_DETACHED; /* override rproc ops with only required IPC-only mode ops */ - rproc->ops->detach = k3_dsp_rproc_detach; rproc->ops->get_loaded_rsc_table = k3_dsp_get_loaded_rsc_table; } else { dev_info(dev, "configured DSP for remoteproc mode\n"); diff --git a/drivers/remoteproc/ti_k3_m4_remoteproc.c b/drivers/remoteproc/ti_k3_m4_remoteproc.c index e78e35c1375c..6b532bda8d1d 100644 --- a/drivers/remoteproc/ti_k3_m4_remoteproc.c +++ b/drivers/remoteproc/ti_k3_m4_remoteproc.c @@ -244,31 +244,13 @@ static void k3_m4_release_tsp(void *data) ti_sci_proc_release(tsp); } -/* - * Detach from a running M4 remote processor (IPC-only mode) - * - * This rproc detach callback performs the opposite operation to attach callback - * and only needs to clear the "is_attach_ongoing" flag to ensure no mailbox - * messages are sent to or received from a detached core. The M4 core is not - * stopped and will be left to continue to run its booted firmware. This - * callback is invoked only in IPC-only mode. - */ -static int k3_m4_rproc_detach(struct rproc *rproc) -{ - struct k3_rproc *kproc = rproc->priv; - - kproc->is_attach_ongoing = false; - - return 0; -} - static const struct rproc_ops k3_m4_rproc_ops = { .prepare = k3_rproc_prepare, .unprepare = k3_rproc_unprepare, .start = k3_rproc_start, .stop = k3_rproc_stop, .attach = k3_rproc_attach, - .detach = k3_m4_rproc_detach, + .detach = k3_rproc_detach, .kick = k3_rproc_kick, .da_to_va = k3_m4_rproc_da_to_va, .get_loaded_rsc_table = k3_m4_get_loaded_rsc_table, From patchwork Fri Jan 3 10:12:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beleswar Prasad Padhi X-Patchwork-Id: 13925469 Received: from fllvem-ot03.ext.ti.com (fllvem-ot03.ext.ti.com [198.47.19.245]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 047E01FA8EC; Fri, 3 Jan 2025 10:13:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.245 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899225; cv=none; b=qJJgGbh6Ht9sAOI4Wj27HVhvA0ybpUM2mXbc8ykm1meahtsoB52ZMCoCBQXB/1hO3B8UXUoVExda9VY7FZI8NmZ0wZjmDnYFoBV8iM+AGOimOAtWQoY1X13f5c9ADPDR5j/NoY7bzxBvU6IWuA+kyqHyza5Yjczh77z1u5jIG8o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899225; c=relaxed/simple; bh=SBIBdglxUVPUrPvPV9VvYBGeZTu7MyxJT7z6oBcyD2o=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=N5/VxhacPw2Btf6kiEWemKSGayNFpt00PfzuSY5VRnob699EAn7HpHyk8MJATeWIArGRz1UleyV8Pzc5IyAGgThSBMEVD3vpmbj8F31Mjxlj9RlxXAymaic+ra80/guJKrKbeexrasyXsEtGmeZZ1WkVhIIafA8Uc2rxkKXH1tk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=nGxA9zON; arc=none smtp.client-ip=198.47.19.245 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="nGxA9zON" Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllvem-ot03.ext.ti.com (8.15.2/8.15.2) with ESMTPS id 503ADWfN2019430 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 3 Jan 2025 04:13:32 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1735899212; bh=CXWL05Dk4Kif1ALU2qQrpVKTkO7f5ZOUdelxySb2xI8=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=nGxA9zONhW0DLRMCZcLulzlje3ePtnHghyB0xOIh6qJXNJkp2l4+p+SS9RtGHo2t7 2ROLVnw87F+Q99GJMZGxxaVHxak0lTlGsTyyelGEO3UXvC0wpXbFMukUoROSNrDAZR e6tSK+/G6xKwJdDCld+co+3gfpnXcmqilbI6j3HM= Received: from DLEE107.ent.ti.com (dlee107.ent.ti.com [157.170.170.37]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTP id 503ADW8L042128; Fri, 3 Jan 2025 04:13:32 -0600 Received: from DLEE105.ent.ti.com (157.170.170.35) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 3 Jan 2025 04:13:31 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Fri, 3 Jan 2025 04:13:32 -0600 Received: from uda0510294.dhcp.ti.com (uda0510294.dhcp.ti.com [172.24.227.151]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 503ACVSX126047; Fri, 3 Jan 2025 04:13:28 -0600 From: Beleswar Padhi To: , CC: , , , , , , , , , , Subject: [PATCH v8 15/20] remoteproc: k3: Refactor .get_loaded_rsc_table ops into common driver Date: Fri, 3 Jan 2025 15:42:26 +0530 Message-ID: <20250103101231.1508151-16-b-padhi@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103101231.1508151-1-b-padhi@ti.com> References: <20250103101231.1508151-1-b-padhi@ti.com> Precedence: bulk X-Mailing-List: linux-remoteproc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea The .get_loaded_rsc_table rproc ops implementations in ti_k3_dsp_remoteproc.c and ti_k3_m4_remoteproc.c drivers return a pointer to the resource table that was pre-loaded at the base address of the DDR region reserved for firmware usage. Refactor the implementations into ti_k3_common.c driver as k3_get_loaded_rsc_table() and align DSP and M4 drivers to register this common function as .get_loaded_rsc_table ops. Signed-off-by: Beleswar Padhi --- drivers/remoteproc/ti_k3_common.c | 33 +++++++++++++++ drivers/remoteproc/ti_k3_common.h | 2 + drivers/remoteproc/ti_k3_dsp_remoteproc.c | 49 ++++------------------- drivers/remoteproc/ti_k3_m4_remoteproc.c | 34 +--------------- 4 files changed, 44 insertions(+), 74 deletions(-) diff --git a/drivers/remoteproc/ti_k3_common.c b/drivers/remoteproc/ti_k3_common.c index b5ef2ac0d399..f56d2553a669 100644 --- a/drivers/remoteproc/ti_k3_common.c +++ b/drivers/remoteproc/ti_k3_common.c @@ -349,5 +349,38 @@ int k3_rproc_detach(struct rproc *rproc) } EXPORT_SYMBOL_GPL(k3_rproc_detach); +/* + * This function implements the .get_loaded_rsc_table() callback and is used + * to provide the resource table for a booted remote processor in IPC-only + * mode. The remote processor firmwares follow a design-by-contract approach + * and are expected to have the resource table at the base of the DDR region + * reserved for firmware usage. This provides flexibility for the remote + * processor to be booted by different bootloaders that may or may not have the + * ability to publish the resource table address and size through a DT + * property. + */ +struct resource_table *k3_get_loaded_rsc_table(struct rproc *rproc, + size_t *rsc_table_sz) +{ + struct k3_rproc *kproc = rproc->priv; + struct device *dev = kproc->dev; + + if (!kproc->rmem[0].cpu_addr) { + dev_err(dev, "memory-region #1 does not exist, loaded rsc table can't be found"); + return ERR_PTR(-ENOMEM); + } + + /* + * NOTE: The resource table size is currently hard-coded to a maximum + * of 256 bytes. The most common resource table usage for K3 firmwares + * is to only have the vdev resource entry and an optional trace entry. + * The exact size could be computed based on resource table address, but + * the hard-coded value suffices to support the IPC-only mode. + */ + *rsc_table_sz = 256; + return (__force struct resource_table *)kproc->rmem[0].cpu_addr; +} +EXPORT_SYMBOL_GPL(k3_get_loaded_rsc_table); + MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("TI K3 common Remoteproc code"); diff --git a/drivers/remoteproc/ti_k3_common.h b/drivers/remoteproc/ti_k3_common.h index c7be85b0e5ac..663911dc7032 100644 --- a/drivers/remoteproc/ti_k3_common.h +++ b/drivers/remoteproc/ti_k3_common.h @@ -99,4 +99,6 @@ int k3_rproc_start(struct rproc *rproc); int k3_rproc_stop(struct rproc *rproc); int k3_rproc_attach(struct rproc *rproc); int k3_rproc_detach(struct rproc *rproc); +struct resource_table *k3_get_loaded_rsc_table(struct rproc *rproc, + size_t *rsc_table_sz); #endif /* REMOTEPROC_TI_K3_COMMON_H */ diff --git a/drivers/remoteproc/ti_k3_dsp_remoteproc.c b/drivers/remoteproc/ti_k3_dsp_remoteproc.c index dd81bcc8e1e4..0bfa3b730d1f 100644 --- a/drivers/remoteproc/ti_k3_dsp_remoteproc.c +++ b/drivers/remoteproc/ti_k3_dsp_remoteproc.c @@ -58,38 +58,6 @@ static int k3_dsp_rproc_start(struct rproc *rproc) return 0; } -/* - * This function implements the .get_loaded_rsc_table() callback and is used - * to provide the resource table for a booted DSP in IPC-only mode. The K3 DSP - * firmwares follow a design-by-contract approach and are expected to have the - * resource table at the base of the DDR region reserved for firmware usage. - * This provides flexibility for the remote processor to be booted by different - * bootloaders that may or may not have the ability to publish the resource table - * address and size through a DT property. This callback is invoked only in - * IPC-only mode. - */ -static struct resource_table *k3_dsp_get_loaded_rsc_table(struct rproc *rproc, - size_t *rsc_table_sz) -{ - struct k3_rproc *kproc = rproc->priv; - struct device *dev = kproc->dev; - - if (!kproc->rmem[0].cpu_addr) { - dev_err(dev, "memory-region #1 does not exist, loaded rsc table can't be found"); - return ERR_PTR(-ENOMEM); - } - - /* - * NOTE: The resource table size is currently hard-coded to a maximum - * of 256 bytes. The most common resource table usage for K3 firmwares - * is to only have the vdev resource entry and an optional trace entry. - * The exact size could be computed based on resource table address, but - * the hard-coded value suffices to support the IPC-only mode. - */ - *rsc_table_sz = 256; - return (__force struct resource_table *)kproc->rmem[0].cpu_addr; -} - /* * Custom function to translate a DSP device address (internal RAMs only) to a * kernel virtual address. The DSPs can access their RAMs at either an internal @@ -150,12 +118,13 @@ static void *k3_dsp_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool } static const struct rproc_ops k3_dsp_rproc_ops = { - .start = k3_dsp_rproc_start, - .stop = k3_rproc_stop, - .attach = k3_rproc_attach, - .detach = k3_rproc_detach, - .kick = k3_rproc_kick, - .da_to_va = k3_dsp_rproc_da_to_va, + .start = k3_dsp_rproc_start, + .stop = k3_rproc_stop, + .attach = k3_rproc_attach, + .detach = k3_rproc_detach, + .kick = k3_rproc_kick, + .da_to_va = k3_dsp_rproc_da_to_va, + .get_loaded_rsc_table = k3_get_loaded_rsc_table, }; static int k3_dsp_rproc_of_get_memories(struct platform_device *pdev, @@ -374,12 +343,10 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) if (ret) return dev_err_probe(dev, ret, "failed to get initial state, mode cannot be determined\n"); - /* configure J721E devices for either remoteproc or IPC-only mode */ + /* configure devices for either remoteproc or IPC-only mode */ if (p_state) { dev_info(dev, "configured DSP for IPC-only mode\n"); rproc->state = RPROC_DETACHED; - /* override rproc ops with only required IPC-only mode ops */ - rproc->ops->get_loaded_rsc_table = k3_dsp_get_loaded_rsc_table; } else { dev_info(dev, "configured DSP for remoteproc mode\n"); } diff --git a/drivers/remoteproc/ti_k3_m4_remoteproc.c b/drivers/remoteproc/ti_k3_m4_remoteproc.c index 6b532bda8d1d..e1caa5ee9a0d 100644 --- a/drivers/remoteproc/ti_k3_m4_remoteproc.c +++ b/drivers/remoteproc/ti_k3_m4_remoteproc.c @@ -21,38 +21,6 @@ #include "ti_sci_proc.h" #include "ti_k3_common.h" -/* - * This function implements the .get_loaded_rsc_table() callback and is used - * to provide the resource table for a booted remote processor in IPC-only - * mode. The remote processor firmwares follow a design-by-contract approach - * and are expected to have the resource table at the base of the DDR region - * reserved for firmware usage. This provides flexibility for the remote - * processor to be booted by different bootloaders that may or may not have the - * ability to publish the resource table address and size through a DT - * property. - */ -static struct resource_table *k3_m4_get_loaded_rsc_table(struct rproc *rproc, - size_t *rsc_table_sz) -{ - struct k3_rproc *kproc = rproc->priv; - struct device *dev = kproc->dev; - - if (!kproc->rmem[0].cpu_addr) { - dev_err(dev, "memory-region #1 does not exist, loaded rsc table can't be found"); - return ERR_PTR(-ENOMEM); - } - - /* - * NOTE: The resource table size is currently hard-coded to a maximum - * of 256 bytes. The most common resource table usage for K3 firmwares - * is to only have the vdev resource entry and an optional trace entry. - * The exact size could be computed based on resource table address, but - * the hard-coded value suffices to support the IPC-only mode. - */ - *rsc_table_sz = 256; - return (__force struct resource_table *)kproc->rmem[0].cpu_addr; -} - /* * Custom function to translate a remote processor device address (internal * RAMs only) to a kernel virtual address. The remote processors can access @@ -253,7 +221,7 @@ static const struct rproc_ops k3_m4_rproc_ops = { .detach = k3_rproc_detach, .kick = k3_rproc_kick, .da_to_va = k3_m4_rproc_da_to_va, - .get_loaded_rsc_table = k3_m4_get_loaded_rsc_table, + .get_loaded_rsc_table = k3_get_loaded_rsc_table, }; static int k3_m4_rproc_probe(struct platform_device *pdev) From patchwork Fri Jan 3 10:12:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beleswar Prasad Padhi X-Patchwork-Id: 13925470 Received: from fllvem-ot04.ext.ti.com (fllvem-ot04.ext.ti.com [198.47.19.246]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4013E1FA8E5; Fri, 3 Jan 2025 10:13:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.246 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899228; cv=none; b=l7vjo2faMVYulrCtt1fxB2EbxwyjPGfyGM6TTQT00hzJqXp1menqkp/jO6OTBeSkAJdUOf4BgMf+fzqldvzX3KVJgZz1ygPUd5OBW1h5tVApe7wFWg4SNSGfDXtyl+MbwelAjhsPRcHJiBnbzaqfNZoU8BsLRvxVVWO68P5rF6g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899228; c=relaxed/simple; bh=MTBPwjex1C92dfwP9Ce+zqig5cGatiXjEK/S09vKHcI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pM3QBqPJsheXDTulioLQdETY97TeY+DN7LElwDV67eo8VjIftiYkqsT0P+dxpi59OUWXkd7jDij4gnesDDMt3aFGW7MY2zmTqeNtB2EOm4R+btE6flW6f7tfQLX7PDov3TX4aH/j16fAw9povrLfqqAh9I/fFRyFBlxUrAVeFaE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=TM8AgAbm; arc=none smtp.client-ip=198.47.19.246 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="TM8AgAbm" Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllvem-ot04.ext.ti.com (8.15.2/8.15.2) with ESMTPS id 503ADa3l2306967 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 3 Jan 2025 04:13:36 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1735899216; bh=i2aRulhPpfXN3jzGKGrViMTOBHWmKdH6T7LKk1jq8Vo=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=TM8AgAbmJFz+jkhBzfdoh6srEdeYdc/QxlNvL/GvmqSILdYowzinHKeSIgMcpfSij YQPXa3/XRMJJs9m43wT4s3UZEVeYR2khn2GJ9EKdWSu7i1w6HNM81vx6ymUm0gGAXn l8hD+8EeYh8vZXnf//a8GBCyOZzG9c4a3SARsEs8= Received: from DLEE105.ent.ti.com (dlee105.ent.ti.com [157.170.170.35]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTP id 503ADaL7042144; Fri, 3 Jan 2025 04:13:36 -0600 Received: from DLEE111.ent.ti.com (157.170.170.22) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 3 Jan 2025 04:13:35 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE111.ent.ti.com (157.170.170.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Fri, 3 Jan 2025 04:13:35 -0600 Received: from uda0510294.dhcp.ti.com (uda0510294.dhcp.ti.com [172.24.227.151]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 503ACVSY126047; Fri, 3 Jan 2025 04:13:32 -0600 From: Beleswar Padhi To: , CC: , , , , , , , , , , Subject: [PATCH v8 16/20] remoteproc: k3: Refactor .da_to_va rproc ops into common driver Date: Fri, 3 Jan 2025 15:42:27 +0530 Message-ID: <20250103101231.1508151-17-b-padhi@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103101231.1508151-1-b-padhi@ti.com> References: <20250103101231.1508151-1-b-padhi@ti.com> Precedence: bulk X-Mailing-List: linux-remoteproc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea The .da_to_va rproc ops implementations in ti_k3_dsp_remoteproc.c and ti_k3_m4_remoteproc.c drivers return the Kernel virtual address for a corresponding rproc device address. Refactor the implementations into ti_k3_common.c driver as k3_rproc_da_to_va and align DSP and M4 drivers to register this common function as .da_to_va ops. Signed-off-by: Beleswar Padhi --- drivers/remoteproc/ti_k3_common.c | 61 ++++++++++++++++++++++ drivers/remoteproc/ti_k3_common.h | 4 ++ drivers/remoteproc/ti_k3_dsp_remoteproc.c | 63 +---------------------- drivers/remoteproc/ti_k3_m4_remoteproc.c | 58 +-------------------- 4 files changed, 67 insertions(+), 119 deletions(-) diff --git a/drivers/remoteproc/ti_k3_common.c b/drivers/remoteproc/ti_k3_common.c index f56d2553a669..520f3fa44195 100644 --- a/drivers/remoteproc/ti_k3_common.c +++ b/drivers/remoteproc/ti_k3_common.c @@ -382,5 +382,66 @@ struct resource_table *k3_get_loaded_rsc_table(struct rproc *rproc, } EXPORT_SYMBOL_GPL(k3_get_loaded_rsc_table); +/* + * Custom function to translate a remote processor device address (internal + * RAMs only) to a kernel virtual address. The remote processors can access + * their RAMs at either an internal address visible only from a remote + * processor, or at the SoC-level bus address. Both these addresses need to be + * looked through for translation. The translated addresses can be used either + * by the remoteproc core for loading (when using kernel remoteproc loader), or + * by any rpmsg bus drivers. + */ +void *k3_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *is_iomem) +{ + struct k3_rproc *kproc = rproc->priv; + void __iomem *va = NULL; + phys_addr_t bus_addr; + u32 dev_addr, offset; + size_t size; + int i; + + if (len == 0) + return NULL; + + for (i = 0; i < kproc->num_mems; i++) { + bus_addr = kproc->mem[i].bus_addr; + dev_addr = kproc->mem[i].dev_addr; + size = kproc->mem[i].size; + + if (da < KEYSTONE_RPROC_LOCAL_ADDRESS_MASK) { + /* handle rproc-view addresses */ + if (da >= dev_addr && + ((da + len) <= (dev_addr + size))) { + offset = da - dev_addr; + va = kproc->mem[i].cpu_addr + offset; + return (__force void *)va; + } + } else { + /* handle SoC-view addresses */ + if (da >= bus_addr && + (da + len) <= (bus_addr + size)) { + offset = da - bus_addr; + va = kproc->mem[i].cpu_addr + offset; + return (__force void *)va; + } + } + } + + /* handle static DDR reserved memory regions */ + for (i = 0; i < kproc->num_rmems; i++) { + dev_addr = kproc->rmem[i].dev_addr; + size = kproc->rmem[i].size; + + if (da >= dev_addr && ((da + len) <= (dev_addr + size))) { + offset = da - dev_addr; + va = kproc->rmem[i].cpu_addr + offset; + return (__force void *)va; + } + } + + return NULL; +} +EXPORT_SYMBOL_GPL(k3_rproc_da_to_va); + MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("TI K3 common Remoteproc code"); diff --git a/drivers/remoteproc/ti_k3_common.h b/drivers/remoteproc/ti_k3_common.h index 663911dc7032..622711951811 100644 --- a/drivers/remoteproc/ti_k3_common.h +++ b/drivers/remoteproc/ti_k3_common.h @@ -16,6 +16,8 @@ #ifndef REMOTEPROC_TI_K3_COMMON_H #define REMOTEPROC_TI_K3_COMMON_H +#define KEYSTONE_RPROC_LOCAL_ADDRESS_MASK (SZ_16M - 1) + /** * struct k3_rproc_mem - internal memory structure * @cpu_addr: MPU virtual address of the memory region @@ -101,4 +103,6 @@ int k3_rproc_attach(struct rproc *rproc); int k3_rproc_detach(struct rproc *rproc); struct resource_table *k3_get_loaded_rsc_table(struct rproc *rproc, size_t *rsc_table_sz); +void *k3_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, + bool *is_iomem); #endif /* REMOTEPROC_TI_K3_COMMON_H */ diff --git a/drivers/remoteproc/ti_k3_dsp_remoteproc.c b/drivers/remoteproc/ti_k3_dsp_remoteproc.c index 0bfa3b730d1f..3d888ab9de6b 100644 --- a/drivers/remoteproc/ti_k3_dsp_remoteproc.c +++ b/drivers/remoteproc/ti_k3_dsp_remoteproc.c @@ -22,8 +22,6 @@ #include "ti_sci_proc.h" #include "ti_k3_common.h" -#define KEYSTONE_RPROC_LOCAL_ADDRESS_MASK (SZ_16M - 1) - /* * Power up the DSP remote processor. * @@ -58,72 +56,13 @@ static int k3_dsp_rproc_start(struct rproc *rproc) return 0; } -/* - * Custom function to translate a DSP device address (internal RAMs only) to a - * kernel virtual address. The DSPs can access their RAMs at either an internal - * address visible only from a DSP, or at the SoC-level bus address. Both these - * addresses need to be looked through for translation. The translated addresses - * can be used either by the remoteproc core for loading (when using kernel - * remoteproc loader), or by any rpmsg bus drivers. - */ -static void *k3_dsp_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *is_iomem) -{ - struct k3_rproc *kproc = rproc->priv; - void __iomem *va = NULL; - phys_addr_t bus_addr; - u32 dev_addr, offset; - size_t size; - int i; - - if (len == 0) - return NULL; - - for (i = 0; i < kproc->num_mems; i++) { - bus_addr = kproc->mem[i].bus_addr; - dev_addr = kproc->mem[i].dev_addr; - size = kproc->mem[i].size; - - if (da < KEYSTONE_RPROC_LOCAL_ADDRESS_MASK) { - /* handle DSP-view addresses */ - if (da >= dev_addr && - ((da + len) <= (dev_addr + size))) { - offset = da - dev_addr; - va = kproc->mem[i].cpu_addr + offset; - return (__force void *)va; - } - } else { - /* handle SoC-view addresses */ - if (da >= bus_addr && - (da + len) <= (bus_addr + size)) { - offset = da - bus_addr; - va = kproc->mem[i].cpu_addr + offset; - return (__force void *)va; - } - } - } - - /* handle static DDR reserved memory regions */ - for (i = 0; i < kproc->num_rmems; i++) { - dev_addr = kproc->rmem[i].dev_addr; - size = kproc->rmem[i].size; - - if (da >= dev_addr && ((da + len) <= (dev_addr + size))) { - offset = da - dev_addr; - va = kproc->rmem[i].cpu_addr + offset; - return (__force void *)va; - } - } - - return NULL; -} - static const struct rproc_ops k3_dsp_rproc_ops = { .start = k3_dsp_rproc_start, .stop = k3_rproc_stop, .attach = k3_rproc_attach, .detach = k3_rproc_detach, .kick = k3_rproc_kick, - .da_to_va = k3_dsp_rproc_da_to_va, + .da_to_va = k3_rproc_da_to_va, .get_loaded_rsc_table = k3_get_loaded_rsc_table, }; diff --git a/drivers/remoteproc/ti_k3_m4_remoteproc.c b/drivers/remoteproc/ti_k3_m4_remoteproc.c index e1caa5ee9a0d..a959f361aae2 100644 --- a/drivers/remoteproc/ti_k3_m4_remoteproc.c +++ b/drivers/remoteproc/ti_k3_m4_remoteproc.c @@ -21,62 +21,6 @@ #include "ti_sci_proc.h" #include "ti_k3_common.h" -/* - * Custom function to translate a remote processor device address (internal - * RAMs only) to a kernel virtual address. The remote processors can access - * their RAMs at either an internal address visible only from a remote - * processor, or at the SoC-level bus address. Both these addresses need to be - * looked through for translation. The translated addresses can be used either - * by the remoteproc core for loading (when using kernel remoteproc loader), or - * by any rpmsg bus drivers. - */ -static void *k3_m4_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *is_iomem) -{ - struct k3_rproc *kproc = rproc->priv; - void __iomem *va = NULL; - phys_addr_t bus_addr; - u32 dev_addr, offset; - size_t size; - int i; - - if (len == 0) - return NULL; - - for (i = 0; i < kproc->num_mems; i++) { - bus_addr = kproc->mem[i].bus_addr; - dev_addr = kproc->mem[i].dev_addr; - size = kproc->mem[i].size; - - /* handle M4-view addresses */ - if (da >= dev_addr && ((da + len) <= (dev_addr + size))) { - offset = da - dev_addr; - va = kproc->mem[i].cpu_addr + offset; - return (__force void *)va; - } - - /* handle SoC-view addresses */ - if (da >= bus_addr && ((da + len) <= (bus_addr + size))) { - offset = da - bus_addr; - va = kproc->mem[i].cpu_addr + offset; - return (__force void *)va; - } - } - - /* handle static DDR reserved memory regions */ - for (i = 0; i < kproc->num_rmems; i++) { - dev_addr = kproc->rmem[i].dev_addr; - size = kproc->rmem[i].size; - - if (da >= dev_addr && ((da + len) <= (dev_addr + size))) { - offset = da - dev_addr; - va = kproc->rmem[i].cpu_addr + offset; - return (__force void *)va; - } - } - - return NULL; -} - static int k3_m4_rproc_of_get_memories(struct platform_device *pdev, struct k3_rproc *kproc) { @@ -220,7 +164,7 @@ static const struct rproc_ops k3_m4_rproc_ops = { .attach = k3_rproc_attach, .detach = k3_rproc_detach, .kick = k3_rproc_kick, - .da_to_va = k3_m4_rproc_da_to_va, + .da_to_va = k3_rproc_da_to_va, .get_loaded_rsc_table = k3_get_loaded_rsc_table, }; From patchwork Fri Jan 3 10:12:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beleswar Prasad Padhi X-Patchwork-Id: 13925471 Received: from lelvem-ot01.ext.ti.com (lelvem-ot01.ext.ti.com [198.47.23.234]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 201831FA8F3; Fri, 3 Jan 2025 10:13:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.234 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899231; cv=none; b=HIMIw2S4iYJy+811+AdiMldV99UiOmqeoIgVxqPWbYVcx9n23Ti6elm/fzMesBjs7F22jXHR2DDkh43MjsCpmh+HfIsOlEE6L/IGe9aq26rpyMVSHf49Pi80ZbWWsU16K4NUhv5frph5LpTavLD47CtcEIpjcZmYjTGINLAQFB4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899231; c=relaxed/simple; bh=lJR8PRopkkytVf4ql6728fLxuzuwV+dYL/21ZgUoBGQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uzVhDCGVOZSfpn5ac1wYIxkKDsDXOeTaRqmyN0N+DUrFlOmbsolO8ExX6en36vfZsGQU+Qss0mnd7xcaFsudfTPmyjocT8l1h74p/DU9j0jXLVc4JkyTmHmLR3x7Le3g8Mq8DhPpWoOlWUcLXlnylZ7O/45pzuCW0LNV3ShObos= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=uTnvLkL3; arc=none smtp.client-ip=198.47.23.234 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="uTnvLkL3" Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelvem-ot01.ext.ti.com (8.15.2/8.15.2) with ESMTPS id 503ADdRR2076701 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 3 Jan 2025 04:13:39 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1735899219; bh=b5RRY0zxO9kvIm/KXLO8fh1D0GD0556wPxucgJlFR/o=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=uTnvLkL3yC77F2EzIHYqWBinCM9+VkPWTPEMHHny/OMLNWWIC1K/tHkkhYq4wimrc fh7jXzBo3KoNx13i3jxDEopWi4DnHWXVS++n2Vg729pP0M/6imPkG8jdgCnjeTjKnT 3I31lEt1L45K4AICq3FQYqQdkdr0YjHUt5x/JT3E= Received: from DFLE114.ent.ti.com (dfle114.ent.ti.com [10.64.6.35]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTP id 503ADdOQ042155; Fri, 3 Jan 2025 04:13:39 -0600 Received: from DFLE111.ent.ti.com (10.64.6.32) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 3 Jan 2025 04:13:39 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE111.ent.ti.com (10.64.6.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Fri, 3 Jan 2025 04:13:39 -0600 Received: from uda0510294.dhcp.ti.com (uda0510294.dhcp.ti.com [172.24.227.151]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 503ACVSZ126047; Fri, 3 Jan 2025 04:13:36 -0600 From: Beleswar Padhi To: , CC: , , , , , , , , , , Subject: [PATCH v8 17/20] remoteproc: k3: Refactor of_get_memories() functions into common driver Date: Fri, 3 Jan 2025 15:42:28 +0530 Message-ID: <20250103101231.1508151-18-b-padhi@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103101231.1508151-1-b-padhi@ti.com> References: <20250103101231.1508151-1-b-padhi@ti.com> Precedence: bulk X-Mailing-List: linux-remoteproc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea The k3_{dsp_/m4_}rproc_of_get_memories() function initializes and assigns memory regions used by the remote processor. Refactor these implementations into ti_k3_common.c driver as k3_rproc_of_get_memories() and align DSP and M4 drivers to use this common function throughout. Signed-off-by: Beleswar Padhi --- drivers/remoteproc/ti_k3_common.c | 53 ++++++++++++++++++++++ drivers/remoteproc/ti_k3_common.h | 2 + drivers/remoteproc/ti_k3_dsp_remoteproc.c | 54 +---------------------- drivers/remoteproc/ti_k3_m4_remoteproc.c | 54 +---------------------- 4 files changed, 57 insertions(+), 106 deletions(-) diff --git a/drivers/remoteproc/ti_k3_common.c b/drivers/remoteproc/ti_k3_common.c index 520f3fa44195..c1c6eabb867f 100644 --- a/drivers/remoteproc/ti_k3_common.c +++ b/drivers/remoteproc/ti_k3_common.c @@ -443,5 +443,58 @@ void *k3_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *is_iomem) } EXPORT_SYMBOL_GPL(k3_rproc_da_to_va); +int k3_rproc_of_get_memories(struct platform_device *pdev, + struct k3_rproc *kproc) +{ + const struct k3_rproc_dev_data *data = kproc->data; + struct device *dev = &pdev->dev; + struct resource *res; + int num_mems = 0; + int i; + + num_mems = kproc->data->num_mems; + kproc->mem = devm_kcalloc(kproc->dev, num_mems, + sizeof(*kproc->mem), GFP_KERNEL); + if (!kproc->mem) + return -ENOMEM; + + for (i = 0; i < num_mems; i++) { + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, + data->mems[i].name); + if (!res) { + dev_err(dev, "found no memory resource for %s\n", + data->mems[i].name); + return -EINVAL; + } + if (!devm_request_mem_region(dev, res->start, + resource_size(res), + dev_name(dev))) { + dev_err(dev, "could not request %s region for resource\n", + data->mems[i].name); + return -EBUSY; + } + + kproc->mem[i].cpu_addr = devm_ioremap_wc(dev, res->start, + resource_size(res)); + if (!kproc->mem[i].cpu_addr) { + dev_err(dev, "failed to map %s memory\n", + data->mems[i].name); + return -ENOMEM; + } + kproc->mem[i].bus_addr = res->start; + kproc->mem[i].dev_addr = data->mems[i].dev_addr; + kproc->mem[i].size = resource_size(res); + + dev_dbg(dev, "memory %8s: bus addr %pa size 0x%zx va %pK da 0x%x\n", + data->mems[i].name, &kproc->mem[i].bus_addr, + kproc->mem[i].size, kproc->mem[i].cpu_addr, + kproc->mem[i].dev_addr); + } + kproc->num_mems = num_mems; + + return 0; +} +EXPORT_SYMBOL_GPL(k3_rproc_of_get_memories); + MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("TI K3 common Remoteproc code"); diff --git a/drivers/remoteproc/ti_k3_common.h b/drivers/remoteproc/ti_k3_common.h index 622711951811..8801914a7c56 100644 --- a/drivers/remoteproc/ti_k3_common.h +++ b/drivers/remoteproc/ti_k3_common.h @@ -105,4 +105,6 @@ struct resource_table *k3_get_loaded_rsc_table(struct rproc *rproc, size_t *rsc_table_sz); void *k3_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *is_iomem); +int k3_rproc_of_get_memories(struct platform_device *pdev, + struct k3_rproc *kproc); #endif /* REMOTEPROC_TI_K3_COMMON_H */ diff --git a/drivers/remoteproc/ti_k3_dsp_remoteproc.c b/drivers/remoteproc/ti_k3_dsp_remoteproc.c index 3d888ab9de6b..476f53249793 100644 --- a/drivers/remoteproc/ti_k3_dsp_remoteproc.c +++ b/drivers/remoteproc/ti_k3_dsp_remoteproc.c @@ -66,58 +66,6 @@ static const struct rproc_ops k3_dsp_rproc_ops = { .get_loaded_rsc_table = k3_get_loaded_rsc_table, }; -static int k3_dsp_rproc_of_get_memories(struct platform_device *pdev, - struct k3_rproc *kproc) -{ - const struct k3_rproc_dev_data *data = kproc->data; - struct device *dev = &pdev->dev; - struct resource *res; - int num_mems = 0; - int i; - - num_mems = kproc->data->num_mems; - kproc->mem = devm_kcalloc(kproc->dev, num_mems, - sizeof(*kproc->mem), GFP_KERNEL); - if (!kproc->mem) - return -ENOMEM; - - for (i = 0; i < num_mems; i++) { - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, - data->mems[i].name); - if (!res) { - dev_err(dev, "found no memory resource for %s\n", - data->mems[i].name); - return -EINVAL; - } - if (!devm_request_mem_region(dev, res->start, - resource_size(res), - dev_name(dev))) { - dev_err(dev, "could not request %s region for resource\n", - data->mems[i].name); - return -EBUSY; - } - - kproc->mem[i].cpu_addr = devm_ioremap_wc(dev, res->start, - resource_size(res)); - if (!kproc->mem[i].cpu_addr) { - dev_err(dev, "failed to map %s memory\n", - data->mems[i].name); - return -ENOMEM; - } - kproc->mem[i].bus_addr = res->start; - kproc->mem[i].dev_addr = data->mems[i].dev_addr; - kproc->mem[i].size = resource_size(res); - - dev_dbg(dev, "memory %8s: bus addr %pa size 0x%zx va %pK da 0x%x\n", - data->mems[i].name, &kproc->mem[i].bus_addr, - kproc->mem[i].size, kproc->mem[i].cpu_addr, - kproc->mem[i].dev_addr); - } - kproc->num_mems = num_mems; - - return 0; -} - static void k3_dsp_mem_release(void *data) { struct device *dev = data; @@ -269,7 +217,7 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) if (ret) return ret; - ret = k3_dsp_rproc_of_get_memories(pdev, kproc); + ret = k3_rproc_of_get_memories(pdev, kproc); if (ret) return ret; diff --git a/drivers/remoteproc/ti_k3_m4_remoteproc.c b/drivers/remoteproc/ti_k3_m4_remoteproc.c index a959f361aae2..a077fe2c06aa 100644 --- a/drivers/remoteproc/ti_k3_m4_remoteproc.c +++ b/drivers/remoteproc/ti_k3_m4_remoteproc.c @@ -21,58 +21,6 @@ #include "ti_sci_proc.h" #include "ti_k3_common.h" -static int k3_m4_rproc_of_get_memories(struct platform_device *pdev, - struct k3_rproc *kproc) -{ - const struct k3_rproc_dev_data *data = kproc->data; - struct device *dev = &pdev->dev; - struct resource *res; - int num_mems; - int i; - - num_mems = kproc->data->num_mems; - kproc->mem = devm_kcalloc(kproc->dev, num_mems, - sizeof(*kproc->mem), GFP_KERNEL); - if (!kproc->mem) - return -ENOMEM; - - for (i = 0; i < num_mems; i++) { - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, - data->mems[i].name); - if (!res) { - dev_err(dev, "found no memory resource for %s\n", - data->mems[i].name); - return -EINVAL; - } - if (!devm_request_mem_region(dev, res->start, - resource_size(res), - dev_name(dev))) { - dev_err(dev, "could not request %s region for resource\n", - data->mems[i].name); - return -EBUSY; - } - - kproc->mem[i].cpu_addr = devm_ioremap_wc(dev, res->start, - resource_size(res)); - if (!kproc->mem[i].cpu_addr) { - dev_err(dev, "failed to map %s memory\n", - data->mems[i].name); - return -ENOMEM; - } - kproc->mem[i].bus_addr = res->start; - kproc->mem[i].dev_addr = data->mems[i].dev_addr; - kproc->mem[i].size = resource_size(res); - - dev_dbg(dev, "memory %8s: bus addr %pa size 0x%zx va %pK da 0x%x\n", - data->mems[i].name, &kproc->mem[i].bus_addr, - kproc->mem[i].size, kproc->mem[i].cpu_addr, - kproc->mem[i].dev_addr); - } - kproc->num_mems = num_mems; - - return 0; -} - static void k3_m4_rproc_dev_mem_release(void *data) { struct device *dev = data; @@ -225,7 +173,7 @@ static int k3_m4_rproc_probe(struct platform_device *pdev) if (ret) return ret; - ret = k3_m4_rproc_of_get_memories(pdev, kproc); + ret = k3_rproc_of_get_memories(pdev, kproc); if (ret) return ret; From patchwork Fri Jan 3 10:12:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beleswar Prasad Padhi X-Patchwork-Id: 13925473 Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 544D11F942C; Fri, 3 Jan 2025 10:13:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.249 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899241; cv=none; b=KrToy4u0zHuD0k3fBdUnYSpjo5+dbsYAbHbpthUleWIZ3OkEPPfLfuKetiQERhNp05dYFgCWucdVFiQddRq+6BAJfK5tVA+SEmSZV9ZvfqIFKk8vqhCLoHZ2PzMaeQJiosS3BHRVn4BIscK6pRKvndRUMmPCrAJclfxnQJJqbmc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899241; c=relaxed/simple; bh=1zz23qw+2qCMG3n73hL3eCcT4JyUAIAk9BBZXyR5/8g=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=flfkbLQ8wZ1qTLylB8YTrl+7APY7QP1qXVvfWFKjLE3FGyJ8M9Yb7f00YjMvDg5sZmX1MALuOR1bzOQa5Mvg6e/C7O4ansYzvTCcoRXJx0TFHAsUQZGaStnxe0NpAAFVOrpIpJd8Eslh5dokrfGNOKl4R33KQoTxG5j8MyIpLYI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=uvvoLs3c; arc=none smtp.client-ip=198.47.23.249 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="uvvoLs3c" Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 503ADhBN010879; Fri, 3 Jan 2025 04:13:43 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1735899223; bh=3JzDLHbGkU1DnMefJblE3HJ6YLgh9bHa3MgCOaSNKSs=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=uvvoLs3cl9hc4/GJEDZtHVFQuzYP9C/o+NAmgi4bfhy1OyGBceImhBrG7GtCPX4XB 2ROhUFEu7WkAX1AM5sT9KxfV3SD5MCWnlBuCXmfyXhGUEhUcMgKlIQOo+parvyfn8R t8K62Eka56U15w1LGjrU7J3ImVreRsqfO+4VAKN0= Received: from DLEE108.ent.ti.com (dlee108.ent.ti.com [157.170.170.38]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 503ADhKh112917 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 3 Jan 2025 04:13:43 -0600 Received: from DLEE113.ent.ti.com (157.170.170.24) by DLEE108.ent.ti.com (157.170.170.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 3 Jan 2025 04:13:42 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Fri, 3 Jan 2025 04:13:43 -0600 Received: from uda0510294.dhcp.ti.com (uda0510294.dhcp.ti.com [172.24.227.151]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 503ACVSa126047; Fri, 3 Jan 2025 04:13:39 -0600 From: Beleswar Padhi To: , CC: , , , , , , , , , , Subject: [PATCH v8 18/20] remoteproc: k3: Refactor mem_release() functions into common driver Date: Fri, 3 Jan 2025 15:42:29 +0530 Message-ID: <20250103101231.1508151-19-b-padhi@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103101231.1508151-1-b-padhi@ti.com> References: <20250103101231.1508151-1-b-padhi@ti.com> Precedence: bulk X-Mailing-List: linux-remoteproc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea The k3_dsp_mem_release() and k3_m4_rproc_dev_mem_release() functions release the reserved memory of the device, which get auto triggered upon device removal. Refactor these functions into ti_k3_common.c driver as k3_mem_release() and align DSP and M4 drivers to use this common function throughout. Signed-off-by: Beleswar Padhi --- drivers/remoteproc/ti_k3_common.c | 8 ++++++++ drivers/remoteproc/ti_k3_common.h | 1 + drivers/remoteproc/ti_k3_dsp_remoteproc.c | 9 +-------- drivers/remoteproc/ti_k3_m4_remoteproc.c | 9 +-------- 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/drivers/remoteproc/ti_k3_common.c b/drivers/remoteproc/ti_k3_common.c index c1c6eabb867f..c8766a01dc19 100644 --- a/drivers/remoteproc/ti_k3_common.c +++ b/drivers/remoteproc/ti_k3_common.c @@ -496,5 +496,13 @@ int k3_rproc_of_get_memories(struct platform_device *pdev, } EXPORT_SYMBOL_GPL(k3_rproc_of_get_memories); +void k3_mem_release(void *data) +{ + struct device *dev = data; + + of_reserved_mem_device_release(dev); +} +EXPORT_SYMBOL_GPL(k3_mem_release); + MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("TI K3 common Remoteproc code"); diff --git a/drivers/remoteproc/ti_k3_common.h b/drivers/remoteproc/ti_k3_common.h index 8801914a7c56..31cd202be348 100644 --- a/drivers/remoteproc/ti_k3_common.h +++ b/drivers/remoteproc/ti_k3_common.h @@ -107,4 +107,5 @@ void *k3_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *is_iomem); int k3_rproc_of_get_memories(struct platform_device *pdev, struct k3_rproc *kproc); +void k3_mem_release(void *data); #endif /* REMOTEPROC_TI_K3_COMMON_H */ diff --git a/drivers/remoteproc/ti_k3_dsp_remoteproc.c b/drivers/remoteproc/ti_k3_dsp_remoteproc.c index 476f53249793..1176a6f4c977 100644 --- a/drivers/remoteproc/ti_k3_dsp_remoteproc.c +++ b/drivers/remoteproc/ti_k3_dsp_remoteproc.c @@ -66,13 +66,6 @@ static const struct rproc_ops k3_dsp_rproc_ops = { .get_loaded_rsc_table = k3_get_loaded_rsc_table, }; -static void k3_dsp_mem_release(void *data) -{ - struct device *dev = data; - - of_reserved_mem_device_release(dev); -} - static int k3_dsp_reserved_mem_init(struct k3_rproc *kproc) { struct device *dev = kproc->dev; @@ -102,7 +95,7 @@ static int k3_dsp_reserved_mem_init(struct k3_rproc *kproc) ERR_PTR(ret)); return ret; } - ret = devm_add_action_or_reset(dev, k3_dsp_mem_release, dev); + ret = devm_add_action_or_reset(dev, k3_mem_release, dev); if (ret) return ret; diff --git a/drivers/remoteproc/ti_k3_m4_remoteproc.c b/drivers/remoteproc/ti_k3_m4_remoteproc.c index a077fe2c06aa..6608b13d125b 100644 --- a/drivers/remoteproc/ti_k3_m4_remoteproc.c +++ b/drivers/remoteproc/ti_k3_m4_remoteproc.c @@ -21,13 +21,6 @@ #include "ti_sci_proc.h" #include "ti_k3_common.h" -static void k3_m4_rproc_dev_mem_release(void *data) -{ - struct device *dev = data; - - of_reserved_mem_device_release(dev); -} - static int k3_m4_reserved_mem_init(struct k3_rproc *kproc) { struct device *dev = kproc->dev; @@ -56,7 +49,7 @@ static int k3_m4_reserved_mem_init(struct k3_rproc *kproc) dev_err(dev, "device cannot initialize DMA pool (%d)\n", ret); return ret; } - ret = devm_add_action_or_reset(dev, k3_m4_rproc_dev_mem_release, dev); + ret = devm_add_action_or_reset(dev, k3_mem_release, dev); if (ret) return ret; From patchwork Fri Jan 3 10:12:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beleswar Prasad Padhi X-Patchwork-Id: 13925472 Received: from fllvem-ot03.ext.ti.com (fllvem-ot03.ext.ti.com [198.47.19.245]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 279491F9AB6; Fri, 3 Jan 2025 10:13:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.245 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899240; cv=none; b=j39KOCnJLnbjRnvWO/qoSGbsjrZI9GtgRAN/0ndfneE42IcumNfOxXWxDEmXh2u7vo+2tJNttBLgUPpTD1IHcDFnoDE2qRGVFehMWFJunjJuHelZzTWbVJfyp6u4NcgwSY1km3eK+P87lZ97XLKq2QDBWc5I+7ObBWHAlxBKS68= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899240; c=relaxed/simple; bh=SGooeC8GMOs4dNPjC+OAdnx2U4p58VHosQVqxQ1/v/Q=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QzN1QOFe84/vIbzsNpjgJBnX5wkvmKlI5NoSwJ1Bh6oirwJZXD5AsCtTqjOY+fqctW2GdTFzlwWQYWyvfVtmxKAufK3fDY4+Fus/8OWDtLhlUr63osFdRKKr9PzkrOyylSGw/rkmvnboVGJeT/etiOO6WYw97YZb+cb+ttVfLLI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=w2ujYRPs; arc=none smtp.client-ip=198.47.19.245 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="w2ujYRPs" Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllvem-ot03.ext.ti.com (8.15.2/8.15.2) with ESMTPS id 503ADlZa2019441 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 3 Jan 2025 04:13:47 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1735899227; bh=x3uIxvzuz9RvkvE4KPqs0onDM5GxLBDnjxj7J4ekkPs=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=w2ujYRPskuECbQS5A8Bbf9swqegPZSOVDXtAqO5zFRoCQdWTifBHFJNzQip5hHADQ TFWhe4PRS/OX0HgB8NjkGo4Y1pndmBuQZOCot2XGoHDMdPvAqIMKWP4kS7ZY3yu+dT C4NYD9n7rWmyuM7Wq5QCbWsr8H5bDP40DbM47DVc= Received: from DLEE114.ent.ti.com (dlee114.ent.ti.com [157.170.170.25]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTP id 503ADlmQ042181; Fri, 3 Jan 2025 04:13:47 -0600 Received: from DLEE110.ent.ti.com (157.170.170.21) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 3 Jan 2025 04:13:46 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE110.ent.ti.com (157.170.170.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Fri, 3 Jan 2025 04:13:46 -0600 Received: from uda0510294.dhcp.ti.com (uda0510294.dhcp.ti.com [172.24.227.151]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 503ACVSb126047; Fri, 3 Jan 2025 04:13:43 -0600 From: Beleswar Padhi To: , CC: , , , , , , , , , , Subject: [PATCH v8 19/20] remoteproc: k3: Refactor reserved_mem_init() functions into common driver Date: Fri, 3 Jan 2025 15:42:30 +0530 Message-ID: <20250103101231.1508151-20-b-padhi@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103101231.1508151-1-b-padhi@ti.com> References: <20250103101231.1508151-1-b-padhi@ti.com> Precedence: bulk X-Mailing-List: linux-remoteproc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea The k3_{dsp_/m4_}reserved_mem_init() functions initialize the reserved memory regions associated with the remote processor. Refactor these functions into ti_k3_common.c driver as k3_reserved_mem_init() and align DSP and M4 drivers to use this common function throughout. Signed-off-by: Beleswar Padhi --- drivers/remoteproc/ti_k3_common.c | 70 ++++++++++++++++++++++ drivers/remoteproc/ti_k3_common.h | 1 + drivers/remoteproc/ti_k3_dsp_remoteproc.c | 72 +---------------------- drivers/remoteproc/ti_k3_m4_remoteproc.c | 71 +--------------------- 4 files changed, 73 insertions(+), 141 deletions(-) diff --git a/drivers/remoteproc/ti_k3_common.c b/drivers/remoteproc/ti_k3_common.c index c8766a01dc19..8fa14b7dde25 100644 --- a/drivers/remoteproc/ti_k3_common.c +++ b/drivers/remoteproc/ti_k3_common.c @@ -504,5 +504,75 @@ void k3_mem_release(void *data) } EXPORT_SYMBOL_GPL(k3_mem_release); +int k3_reserved_mem_init(struct k3_rproc *kproc) +{ + struct device *dev = kproc->dev; + struct device_node *np = dev->of_node; + struct device_node *rmem_np; + struct reserved_mem *rmem; + int num_rmems; + int ret, i; + + num_rmems = of_property_count_elems_of_size(np, "memory-region", + sizeof(phandle)); + if (num_rmems < 0) { + dev_err(dev, "device does not reserved memory regions (%d)\n", + num_rmems); + return -EINVAL; + } + if (num_rmems < 2) { + dev_err(dev, "device needs at least two memory regions to be defined, num = %d\n", + num_rmems); + return -EINVAL; + } + + /* use reserved memory region 0 for vring DMA allocations */ + ret = of_reserved_mem_device_init_by_idx(dev, np, 0); + if (ret) { + dev_err(dev, "device cannot initialize DMA pool (%d)\n", ret); + return ret; + } + ret = devm_add_action_or_reset(dev, k3_mem_release, dev); + if (ret) + return ret; + + num_rmems--; + kproc->rmem = devm_kcalloc(dev, num_rmems, sizeof(*kproc->rmem), GFP_KERNEL); + if (!kproc->rmem) + return -ENOMEM; + + /* use remaining reserved memory regions for static carveouts */ + for (i = 0; i < num_rmems; i++) { + rmem_np = of_parse_phandle(np, "memory-region", i + 1); + if (!rmem_np) + return -EINVAL; + + rmem = of_reserved_mem_lookup(rmem_np); + of_node_put(rmem_np); + if (!rmem) + return -EINVAL; + + kproc->rmem[i].bus_addr = rmem->base; + /* 64-bit address regions currently not supported */ + kproc->rmem[i].dev_addr = (u32)rmem->base; + kproc->rmem[i].size = rmem->size; + kproc->rmem[i].cpu_addr = devm_ioremap_wc(dev, rmem->base, rmem->size); + if (!kproc->rmem[i].cpu_addr) { + dev_err(dev, "failed to map reserved memory#%d at %pa of size %pa\n", + i + 1, &rmem->base, &rmem->size); + return -ENOMEM; + } + + dev_dbg(dev, "reserved memory%d: bus addr %pa size 0x%zx va %pK da 0x%x\n", + i + 1, &kproc->rmem[i].bus_addr, + kproc->rmem[i].size, kproc->rmem[i].cpu_addr, + kproc->rmem[i].dev_addr); + } + kproc->num_rmems = num_rmems; + + return 0; +} +EXPORT_SYMBOL_GPL(k3_reserved_mem_init); + MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("TI K3 common Remoteproc code"); diff --git a/drivers/remoteproc/ti_k3_common.h b/drivers/remoteproc/ti_k3_common.h index 31cd202be348..525d1da65105 100644 --- a/drivers/remoteproc/ti_k3_common.h +++ b/drivers/remoteproc/ti_k3_common.h @@ -108,4 +108,5 @@ void *k3_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, int k3_rproc_of_get_memories(struct platform_device *pdev, struct k3_rproc *kproc); void k3_mem_release(void *data); +int k3_reserved_mem_init(struct k3_rproc *kproc); #endif /* REMOTEPROC_TI_K3_COMMON_H */ diff --git a/drivers/remoteproc/ti_k3_dsp_remoteproc.c b/drivers/remoteproc/ti_k3_dsp_remoteproc.c index 1176a6f4c977..40187d03206f 100644 --- a/drivers/remoteproc/ti_k3_dsp_remoteproc.c +++ b/drivers/remoteproc/ti_k3_dsp_remoteproc.c @@ -66,76 +66,6 @@ static const struct rproc_ops k3_dsp_rproc_ops = { .get_loaded_rsc_table = k3_get_loaded_rsc_table, }; -static int k3_dsp_reserved_mem_init(struct k3_rproc *kproc) -{ - struct device *dev = kproc->dev; - struct device_node *np = dev->of_node; - struct device_node *rmem_np; - struct reserved_mem *rmem; - int num_rmems; - int ret, i; - - num_rmems = of_property_count_elems_of_size(np, "memory-region", - sizeof(phandle)); - if (num_rmems < 0) { - dev_err(dev, "device does not reserved memory regions (%pe)\n", - ERR_PTR(num_rmems)); - return -EINVAL; - } - if (num_rmems < 2) { - dev_err(dev, "device needs at least two memory regions to be defined, num = %d\n", - num_rmems); - return -EINVAL; - } - - /* use reserved memory region 0 for vring DMA allocations */ - ret = of_reserved_mem_device_init_by_idx(dev, np, 0); - if (ret) { - dev_err(dev, "device cannot initialize DMA pool (%pe)\n", - ERR_PTR(ret)); - return ret; - } - ret = devm_add_action_or_reset(dev, k3_mem_release, dev); - if (ret) - return ret; - - num_rmems--; - kproc->rmem = devm_kcalloc(dev, num_rmems, sizeof(*kproc->rmem), GFP_KERNEL); - if (!kproc->rmem) - return -ENOMEM; - - /* use remaining reserved memory regions for static carveouts */ - for (i = 0; i < num_rmems; i++) { - rmem_np = of_parse_phandle(np, "memory-region", i + 1); - if (!rmem_np) - return -EINVAL; - - rmem = of_reserved_mem_lookup(rmem_np); - of_node_put(rmem_np); - if (!rmem) - return -EINVAL; - - kproc->rmem[i].bus_addr = rmem->base; - /* 64-bit address regions currently not supported */ - kproc->rmem[i].dev_addr = (u32)rmem->base; - kproc->rmem[i].size = rmem->size; - kproc->rmem[i].cpu_addr = devm_ioremap_wc(dev, rmem->base, rmem->size); - if (!kproc->rmem[i].cpu_addr) { - dev_err(dev, "failed to map reserved memory#%d at %pa of size %pa\n", - i + 1, &rmem->base, &rmem->size); - return -ENOMEM; - } - - dev_dbg(dev, "reserved memory%d: bus addr %pa size 0x%zx va %pK da 0x%x\n", - i + 1, &kproc->rmem[i].bus_addr, - kproc->rmem[i].size, kproc->rmem[i].cpu_addr, - kproc->rmem[i].dev_addr); - } - kproc->num_rmems = num_rmems; - - return 0; -} - static void k3_dsp_release_tsp(void *data) { struct ti_sci_proc *tsp = data; @@ -214,7 +144,7 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) if (ret) return ret; - ret = k3_dsp_reserved_mem_init(kproc); + ret = k3_reserved_mem_init(kproc); if (ret) return dev_err_probe(dev, ret, "reserved memory init failed\n"); diff --git a/drivers/remoteproc/ti_k3_m4_remoteproc.c b/drivers/remoteproc/ti_k3_m4_remoteproc.c index 6608b13d125b..ae8335c8f9e9 100644 --- a/drivers/remoteproc/ti_k3_m4_remoteproc.c +++ b/drivers/remoteproc/ti_k3_m4_remoteproc.c @@ -21,75 +21,6 @@ #include "ti_sci_proc.h" #include "ti_k3_common.h" -static int k3_m4_reserved_mem_init(struct k3_rproc *kproc) -{ - struct device *dev = kproc->dev; - struct device_node *np = dev->of_node; - struct device_node *rmem_np; - struct reserved_mem *rmem; - int num_rmems; - int ret, i; - - num_rmems = of_property_count_elems_of_size(np, "memory-region", - sizeof(phandle)); - if (num_rmems < 0) { - dev_err(dev, "device does not reserved memory regions (%d)\n", - num_rmems); - return -EINVAL; - } - if (num_rmems < 2) { - dev_err(dev, "device needs at least two memory regions to be defined, num = %d\n", - num_rmems); - return -EINVAL; - } - - /* use reserved memory region 0 for vring DMA allocations */ - ret = of_reserved_mem_device_init_by_idx(dev, np, 0); - if (ret) { - dev_err(dev, "device cannot initialize DMA pool (%d)\n", ret); - return ret; - } - ret = devm_add_action_or_reset(dev, k3_mem_release, dev); - if (ret) - return ret; - - num_rmems--; - kproc->rmem = devm_kcalloc(dev, num_rmems, sizeof(*kproc->rmem), GFP_KERNEL); - if (!kproc->rmem) - return -ENOMEM; - - /* use remaining reserved memory regions for static carveouts */ - for (i = 0; i < num_rmems; i++) { - rmem_np = of_parse_phandle(np, "memory-region", i + 1); - if (!rmem_np) - return -EINVAL; - - rmem = of_reserved_mem_lookup(rmem_np); - of_node_put(rmem_np); - if (!rmem) - return -EINVAL; - - kproc->rmem[i].bus_addr = rmem->base; - /* 64-bit address regions currently not supported */ - kproc->rmem[i].dev_addr = (u32)rmem->base; - kproc->rmem[i].size = rmem->size; - kproc->rmem[i].cpu_addr = devm_ioremap_wc(dev, rmem->base, rmem->size); - if (!kproc->rmem[i].cpu_addr) { - dev_err(dev, "failed to map reserved memory#%d at %pa of size %pa\n", - i + 1, &rmem->base, &rmem->size); - return -ENOMEM; - } - - dev_dbg(dev, "reserved memory%d: bus addr %pa size 0x%zx va %pK da 0x%x\n", - i + 1, &kproc->rmem[i].bus_addr, - kproc->rmem[i].size, kproc->rmem[i].cpu_addr, - kproc->rmem[i].dev_addr); - } - kproc->num_rmems = num_rmems; - - return 0; -} - static void k3_m4_release_tsp(void *data) { struct ti_sci_proc *tsp = data; @@ -170,7 +101,7 @@ static int k3_m4_rproc_probe(struct platform_device *pdev) if (ret) return ret; - ret = k3_m4_reserved_mem_init(kproc); + ret = k3_reserved_mem_init(kproc); if (ret) return dev_err_probe(dev, ret, "reserved memory init failed\n"); From patchwork Fri Jan 3 10:12:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Beleswar Prasad Padhi X-Patchwork-Id: 13925474 Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D20DA1F9427; Fri, 3 Jan 2025 10:13:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.249 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899242; cv=none; b=GAZm+KSKS3U8MI/ATvZc8+PvmjMPHv7Lr59hrwwkPyMsfcWnCHxwNulVdFc9l4zyoNjUlx1Fumu3tOT96wPxfbxSfqpNAemaJ3oqjg8yk+eWERI6hdqmuEX7v5RNpYhBybXq/i8FwskTHFF+hhyukQeBJYZ01/7YgBdEtQt7Nio= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735899242; c=relaxed/simple; bh=7AlOVCumyE5chjHqUW2rw6A+EOQ7AZWZbauB+SODX2c=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bqVQ0A6D3TRc2u+kJNm6G4e0FKF4EhKiq09y1xJ6VDl+8yb5UtmyAG9U7dgwlMv6qO0sMGpUsjlppDQFyybVMeyg9WBVEowHrJXD5U5WyujBPPmuoEJrnOboIW5DiAHxjpbtvRNeX1NteaYNYLK5CgLvOTyf9API/LArtoppY2U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=oTt8iB73; arc=none smtp.client-ip=198.47.23.249 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="oTt8iB73" Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 503ADprU010898; Fri, 3 Jan 2025 04:13:51 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1735899231; bh=naeYvQEmTPXahTm4W5qFBWgHA76+YAZCObhSMS/zdLc=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=oTt8iB73kVWpZS4ITqIghJEVPaZyRDWOPeIzdZ77ufFr1RZ1mSo8IwSxODg37O6FM DW/4GKvbplYh/kvX1rS8Pdwys2/ZWXHNfdEFZa98zhFApzbiWBHzyMe2db9x/me3ad bPYibZJDkjn79lJ5WT5VRkFhp4jmSfvVhqUVJ4j4= Received: from DLEE107.ent.ti.com (dlee107.ent.ti.com [157.170.170.37]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 503ADpMG126275 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 3 Jan 2025 04:13:51 -0600 Received: from DLEE108.ent.ti.com (157.170.170.38) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 3 Jan 2025 04:13:50 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE108.ent.ti.com (157.170.170.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Fri, 3 Jan 2025 04:13:50 -0600 Received: from uda0510294.dhcp.ti.com (uda0510294.dhcp.ti.com [172.24.227.151]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 503ACVSc126047; Fri, 3 Jan 2025 04:13:47 -0600 From: Beleswar Padhi To: , CC: , , , , , , , , , , Subject: [PATCH v8 20/20] remoteproc: k3: Refactor release_tsp() functions into common driver Date: Fri, 3 Jan 2025 15:42:31 +0530 Message-ID: <20250103101231.1508151-21-b-padhi@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250103101231.1508151-1-b-padhi@ti.com> References: <20250103101231.1508151-1-b-padhi@ti.com> Precedence: bulk X-Mailing-List: linux-remoteproc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea The k3_{dsp_/m4_}release_tsp() functions release the TI-SCI processor control of a remote processor, which is auto triggered upon device removal. Refactor these functions into ti_k3_common.c driver as k3_release_tsp() and align DSP and M4 drivers to use this common function throughout. Signed-off-by: Beleswar Padhi --- drivers/remoteproc/ti_k3_common.c | 8 ++++++++ drivers/remoteproc/ti_k3_common.h | 1 + drivers/remoteproc/ti_k3_dsp_remoteproc.c | 9 +-------- drivers/remoteproc/ti_k3_m4_remoteproc.c | 9 +-------- 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/drivers/remoteproc/ti_k3_common.c b/drivers/remoteproc/ti_k3_common.c index 8fa14b7dde25..d5bdda5d4976 100644 --- a/drivers/remoteproc/ti_k3_common.c +++ b/drivers/remoteproc/ti_k3_common.c @@ -574,5 +574,13 @@ int k3_reserved_mem_init(struct k3_rproc *kproc) } EXPORT_SYMBOL_GPL(k3_reserved_mem_init); +void k3_release_tsp(void *data) +{ + struct ti_sci_proc *tsp = data; + + ti_sci_proc_release(tsp); +} +EXPORT_SYMBOL_GPL(k3_release_tsp); + MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("TI K3 common Remoteproc code"); diff --git a/drivers/remoteproc/ti_k3_common.h b/drivers/remoteproc/ti_k3_common.h index 525d1da65105..94cac6c1ac62 100644 --- a/drivers/remoteproc/ti_k3_common.h +++ b/drivers/remoteproc/ti_k3_common.h @@ -109,4 +109,5 @@ int k3_rproc_of_get_memories(struct platform_device *pdev, struct k3_rproc *kproc); void k3_mem_release(void *data); int k3_reserved_mem_init(struct k3_rproc *kproc); +void k3_release_tsp(void *data); #endif /* REMOTEPROC_TI_K3_COMMON_H */ diff --git a/drivers/remoteproc/ti_k3_dsp_remoteproc.c b/drivers/remoteproc/ti_k3_dsp_remoteproc.c index 40187d03206f..f5f17c18fc1b 100644 --- a/drivers/remoteproc/ti_k3_dsp_remoteproc.c +++ b/drivers/remoteproc/ti_k3_dsp_remoteproc.c @@ -66,13 +66,6 @@ static const struct rproc_ops k3_dsp_rproc_ops = { .get_loaded_rsc_table = k3_get_loaded_rsc_table, }; -static void k3_dsp_release_tsp(void *data) -{ - struct ti_sci_proc *tsp = data; - - ti_sci_proc_release(tsp); -} - static int k3_dsp_rproc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -136,7 +129,7 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev) dev_err_probe(dev, ret, "ti_sci_proc_request failed\n"); return ret; } - ret = devm_add_action_or_reset(dev, k3_dsp_release_tsp, kproc->tsp); + ret = devm_add_action_or_reset(dev, k3_release_tsp, kproc->tsp); if (ret) return ret; diff --git a/drivers/remoteproc/ti_k3_m4_remoteproc.c b/drivers/remoteproc/ti_k3_m4_remoteproc.c index ae8335c8f9e9..f17e44cebdc7 100644 --- a/drivers/remoteproc/ti_k3_m4_remoteproc.c +++ b/drivers/remoteproc/ti_k3_m4_remoteproc.c @@ -21,13 +21,6 @@ #include "ti_sci_proc.h" #include "ti_k3_common.h" -static void k3_m4_release_tsp(void *data) -{ - struct ti_sci_proc *tsp = data; - - ti_sci_proc_release(tsp); -} - static const struct rproc_ops k3_m4_rproc_ops = { .prepare = k3_rproc_prepare, .unprepare = k3_rproc_unprepare, @@ -93,7 +86,7 @@ static int k3_m4_rproc_probe(struct platform_device *pdev) ret = ti_sci_proc_request(kproc->tsp); if (ret < 0) return dev_err_probe(dev, ret, "ti_sci_proc_request failed\n"); - ret = devm_add_action_or_reset(dev, k3_m4_release_tsp, kproc->tsp); + ret = devm_add_action_or_reset(dev, k3_release_tsp, kproc->tsp); if (ret) return ret;