From patchwork Thu Mar 19 16:23:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suman Anna X-Patchwork-Id: 11447651 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D6A0C17E6 for ; Thu, 19 Mar 2020 16:23:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B53402072C for ; Thu, 19 Mar 2020 16:23:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="TfC6MYlL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727732AbgCSQXc (ORCPT ); Thu, 19 Mar 2020 12:23:32 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:56776 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727720AbgCSQXb (ORCPT ); Thu, 19 Mar 2020 12:23:31 -0400 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 02JGNQ74025510; Thu, 19 Mar 2020 11:23:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1584635006; bh=lGsXIdBBDeCl9BXLknAF5FNesbgy4vakhzEJrnxzea8=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=TfC6MYlLf+Wh7U6hUUViricRMheByV5hxwEWBkxhXOev+bLRVVcKEQiztt+XPkR0e BaTTLaBsvci/SiUcAmRVCGgqZVys4e+HJ8/Nd5Alyxvp3DEIebNd51/Qd1Fc53iTDW RDsAWLy2WnJStEnLCNsj01vASXtXFGkp9pEGCbl4= Received: from DFLE100.ent.ti.com (dfle100.ent.ti.com [10.64.6.21]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 02JGNQCP007186 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 19 Mar 2020 11:23:26 -0500 Received: from DFLE108.ent.ti.com (10.64.6.29) 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.1847.3; Thu, 19 Mar 2020 11:23:25 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Thu, 19 Mar 2020 11:23:26 -0500 Received: from lelv0597.itg.ti.com (lelv0597.itg.ti.com [10.181.64.32]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 02JGNQQa037838; Thu, 19 Mar 2020 11:23:26 -0500 Received: from localhost ([10.250.86.212]) by lelv0597.itg.ti.com (8.14.7/8.14.7) with ESMTP id 02JGNPOb066549; Thu, 19 Mar 2020 11:23:25 -0500 From: Suman Anna To: Bjorn Andersson , Loic Pallardy CC: Mathieu Poirier , Arnaud Pouliquen , Tero Kristo , , , Suman Anna Subject: [PATCH v2 1/2] remoteproc: fall back to using parent memory pool if no dedicated available Date: Thu, 19 Mar 2020 11:23:20 -0500 Message-ID: <20200319162321.20632-2-s-anna@ti.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200319162321.20632-1-s-anna@ti.com> References: <20200319162321.20632-1-s-anna@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org From: Tero Kristo In some cases, like with OMAP remoteproc, we are not creating dedicated memory pool for the virtio device. Instead, we use the same memory pool for all shared memories. The current virtio memory pool handling forces a split between these two, as a separate device is created for it, causing memory to be allocated from bad location if the dedicated pool is not available. Fix this by falling back to using the parent device memory pool if dedicated is not available. Fixes: 086d08725d34 ("remoteproc: create vdev subdevice with specific dma memory pool") Signed-off-by: Tero Kristo Signed-off-by: Suman Anna --- v2: - Address Arnaud's concerns about hard-coded memory-region index 0 - Update the comment around the new code addition v1: https://patchwork.kernel.org/patch/11422721/ drivers/remoteproc/remoteproc_virtio.c | 15 +++++++++++++++ include/linux/remoteproc.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c index eb817132bc5f..b687715cdf4b 100644 --- a/drivers/remoteproc/remoteproc_virtio.c +++ b/drivers/remoteproc/remoteproc_virtio.c @@ -369,6 +369,21 @@ int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id) goto out; } } + } else { + struct device_node *np = rproc->dev.parent->of_node; + + /* + * If we don't have dedicated buffer, just attempt to re-assign + * the reserved memory from our parent. A default memory-region + * at index 0 from the parent's memory-regions is assigned for + * the rvdev dev to allocate from, and this can be customized + * by updating the vdevbuf_mem_id in platform drivers if + * desired. Failure is non-critical and the allocations will + * fall back to global pools, so don't check return value + * either. + */ + of_reserved_mem_device_init_by_idx(dev, np, + rproc->vdevbuf_mem_id); } /* Allocate virtio device */ diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index ed127b2d35ca..07bd73a6d72a 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -481,6 +481,7 @@ struct rproc_dump_segment { * @auto_boot: flag to indicate if remote processor should be auto-started * @dump_segments: list of segments in the firmware * @nb_vdev: number of vdev currently handled by rproc + * @vdevbuf_mem_id: default memory-region index for allocating vdev buffers */ struct rproc { struct list_head node; @@ -514,6 +515,7 @@ struct rproc { bool auto_boot; struct list_head dump_segments; int nb_vdev; + u8 vdevbuf_mem_id; u8 elf_class; }; From patchwork Thu Mar 19 16:23:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suman Anna X-Patchwork-Id: 11447653 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0BE1092A for ; Thu, 19 Mar 2020 16:23:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DFCEE2072C for ; Thu, 19 Mar 2020 16:23:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="UWKk46eV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727792AbgCSQXc (ORCPT ); Thu, 19 Mar 2020 12:23:32 -0400 Received: from lelv0142.ext.ti.com ([198.47.23.249]:39032 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727399AbgCSQXb (ORCPT ); Thu, 19 Mar 2020 12:23:31 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 02JGNRSY087050; Thu, 19 Mar 2020 11:23:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1584635007; bh=InLyviOkfFOPkDrw3fsPx+IycNhWr/qvF9UvPT91rPQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=UWKk46eVJesUFUnliJecoZN01llOhTN+aRKM3g76mu04W7PPR/KuPD4aiszhfEPEk AMU9Qw6+/8lpVNXO9w7x2oIPQabg/4uGF4grRSD/FDtEB/Ds+RPNEXsNVLenczBZEk T4cEoTvgrRA9Kj+5buRnF78J+VpiUILfgh39ss3E= 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 ESMTPS id 02JGNR5v096819 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 19 Mar 2020 11:23:27 -0500 Received: from DFLE112.ent.ti.com (10.64.6.33) 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.1847.3; Thu, 19 Mar 2020 11:23:27 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) 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.1847.3 via Frontend Transport; Thu, 19 Mar 2020 11:23:27 -0500 Received: from lelv0597.itg.ti.com (lelv0597.itg.ti.com [10.181.64.32]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 02JGNR8w100125; Thu, 19 Mar 2020 11:23:27 -0500 Received: from localhost ([10.250.86.212]) by lelv0597.itg.ti.com (8.14.7/8.14.7) with ESMTP id 02JGNQrH066554; Thu, 19 Mar 2020 11:23:26 -0500 From: Suman Anna To: Bjorn Andersson , Loic Pallardy CC: Mathieu Poirier , Arnaud Pouliquen , Tero Kristo , , , Suman Anna Subject: [PATCH v2 2/2] remoteproc: Fix and restore the parenting hierarchy for vdev Date: Thu, 19 Mar 2020 11:23:21 -0500 Message-ID: <20200319162321.20632-3-s-anna@ti.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200319162321.20632-1-s-anna@ti.com> References: <20200319162321.20632-1-s-anna@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org The commit 086d08725d34 ("remoteproc: create vdev subdevice with specific dma memory pool") has introduced a new vdev subdevice for each vdev declared in the firmware resource table and made it as the parent for the created virtio rpmsg devices instead of the previous remoteproc device. This changed the overall parenting hierarchy for the rpmsg devices, which were children of virtio devices, and does not allow the corresponding rpmsg drivers to retrieve the parent rproc device through the rproc_get_by_child() API. Fix this by restoring the remoteproc device as the parent. The new vdev subdevice can continue to inherit the DMA attributes from the remoteproc's parent device (actual platform device). Fixes: 086d08725d34 ("remoteproc: create vdev subdevice with specific dma memory pool") Signed-off-by: Suman Anna Reviewed-by: Mathieu Poirier Acked-by: Arnaud Pouliquen --- v2: No code changes, picked up review tags v1: https://patchwork.kernel.org/patch/11422725/ drivers/remoteproc/remoteproc_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index a9ac1d01e09b..0962855f27fc 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -514,7 +514,7 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc, /* Initialise vdev subdevice */ snprintf(name, sizeof(name), "vdev%dbuffer", rvdev->index); - rvdev->dev.parent = rproc->dev.parent; + rvdev->dev.parent = &rproc->dev; rvdev->dev.dma_pfn_offset = rproc->dev.parent->dma_pfn_offset; rvdev->dev.release = rproc_rvdev_release; dev_set_name(&rvdev->dev, "%s#%s", dev_name(rvdev->dev.parent), name);