Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp7941366pxb; Fri, 19 Feb 2021 03:28:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJw+TKdPcFSFlVrZVZW7vU9lQ1kx9J/g/Xmrj33m+O8y1QRQJYy1SZyaObp8WTBUWTvCnm1C X-Received: by 2002:a05:6402:4310:: with SMTP id m16mr8693034edc.207.1613734094411; Fri, 19 Feb 2021 03:28:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613734094; cv=none; d=google.com; s=arc-20160816; b=uW0OWM5+hUWR4eJS7BUuc1MooRxguDtGk1hkssudd0AXnDh7CTsoOKmVXbUhFOnIkC gKtEbJoJdhUt+z5LD3bLWposXw9AZsDArTavhx5Y8fugqESk4BZjrJkuCgmM957ypgFe ZUXOuZONDQ6wTkfGU9E11FPzSQmHWCcY6Bohv1D/TkT+ixTMivGF/6SGnZpk7hBgG3C/ Yym1FRZ9zetVw8knRl1K9mEBQfnHxF5dcl2o0JB0T7YD+sNqazXRHq4bu0y4X88JaKpW Bi3JA/nbnWJpzWh+04Vb3k4c4XrlvAcaHbEUumg7QRRDI1Wq6c/oa4KQeUeBKkr1J50K EEGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=vvNAyI9ruMSPKPHLlkuNsluMR8Afys++5OiV9+LgOgg=; b=qeoDXB36kHUd64Q+XWzZPbjJtYhjn/MocqNyiQyeSUdkShs6SgD/t8TyvLTi7i6Lia Cls7PHh7EXRiichZu0VYxJkrFC1D764Fnfi9YTGUmxg2deck/ghfTMytzdhxI4xrDQRq bZHbrPrrVjj9eeemNtTaDzf9No2A7cBAip8tYePDUm8IGAeOkq32fqM70wNYX36n+5ij 1eFGubg8vRkByivBjWX7lAqczLqx4jwzfDHAvaH3txsfwTFP1RrTX/7nxT/jJg1QJzze 1VQAlKHEPBGR7SBEKS/z1hdxcoxohe/hfJKZX4r5+L91qpPwaHELiXNgsswjaekW4ou+ AJzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=UZ73H0lO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z102si5627958ede.224.2021.02.19.03.27.50; Fri, 19 Feb 2021 03:28:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=UZ73H0lO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230412AbhBSLY5 (ORCPT + 99 others); Fri, 19 Feb 2021 06:24:57 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:58279 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230421AbhBSLT5 (ORCPT ); Fri, 19 Feb 2021 06:19:57 -0500 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 11JBILXl024274; Fri, 19 Feb 2021 12:19:11 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=vvNAyI9ruMSPKPHLlkuNsluMR8Afys++5OiV9+LgOgg=; b=UZ73H0lOyhNxPzMHFJIGTNr0iv0hHMWbojSCd66muagxu9omG7Zp4Y/DyyoIaazgsA83 KrpKmWVKEAWE+m12OE2zxaNTFB7D3TtGaqnnupIhy2WC1iPy7Eyp0Ry/2Y8zAoLcB0L5 M79kQOmRCQnt6T4l/GtLZKvUf4KZ89eOhwTde9ovxNkeupHssb5qg6HC3uh7qPAbdpuR EH+G4WS0SNeKJKnCnIL8HyiPbh5K7k6vr8c7OQ8jyoeSi7xwcUOC2qmT1XzeFz1PVUM5 dUbGs1ZQzijCtlxQaema0WIhfi+hXtmDyHvIXgoXNRogElZhoWs6I0zuj3aknowRt4nR Hg== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 36sqadeywc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 19 Feb 2021 12:19:11 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 3AD49100034; Fri, 19 Feb 2021 12:19:11 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 2D054221760; Fri, 19 Feb 2021 12:19:11 +0100 (CET) Received: from localhost (10.75.127.47) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 19 Feb 2021 12:19:10 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v5 15/16] rpmsg: char: no dynamic endpoint management for the default one Date: Fri, 19 Feb 2021 12:15:00 +0100 Message-ID: <20210219111501.14261-16-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> References: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.47] X-ClientProxiedBy: SFHDAG3NODE1.st.com (10.75.127.7) To SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369,18.0.761 definitions=2021-02-19_04:2021-02-18,2021-02-19 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Do not dynamically manage the default endpoint. The ept address must not change. This update is needed to manage the RPMSG_CREATE_DEV_IOCTL. In this case a default endpoint is used and it's address must not change or been reused by another service. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/rpmsg_char.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c index c98b0e69679b..8d3f9d6c20ad 100644 --- a/drivers/rpmsg/rpmsg_char.c +++ b/drivers/rpmsg/rpmsg_char.c @@ -114,14 +114,23 @@ static int rpmsg_eptdev_open(struct inode *inode, struct file *filp) struct rpmsg_endpoint *ept; struct rpmsg_device *rpdev = eptdev->rpdev; struct device *dev = &eptdev->dev; + u32 addr = eptdev->chinfo.src; get_device(dev); - ept = rpmsg_create_ept(rpdev, rpmsg_ept_cb, eptdev, eptdev->chinfo); - if (!ept) { - dev_err(dev, "failed to open %s\n", eptdev->chinfo.name); - put_device(dev); - return -EINVAL; + /* + * The RPMsg device can has been created by a ns announcement. In this + * case a default endpoint has been created. Reuse it to avoid to manage + * a new address on each open close. + */ + ept = rpdev->ept; + if (!ept || addr != ept->addr) { + ept = rpmsg_create_ept(rpdev, rpmsg_ept_cb, eptdev, eptdev->chinfo); + if (!ept) { + dev_err(dev, "failed to open %s\n", eptdev->chinfo.name); + put_device(dev); + return -EINVAL; + } } eptdev->ept = ept; @@ -133,12 +142,17 @@ static int rpmsg_eptdev_open(struct inode *inode, struct file *filp) static int rpmsg_eptdev_release(struct inode *inode, struct file *filp) { struct rpmsg_eptdev *eptdev = cdev_to_eptdev(inode->i_cdev); + struct rpmsg_device *rpdev = eptdev->rpdev; struct device *dev = &eptdev->dev; - /* Close the endpoint, if it's not already destroyed by the parent */ + /* + * Close the endpoint, if it's not already destroyed by the parent and it is not the + * default one. + */ mutex_lock(&eptdev->ept_lock); if (eptdev->ept) { - rpmsg_destroy_ept(eptdev->ept); + if (eptdev->ept != rpdev->ept) + rpmsg_destroy_ept(eptdev->ept); eptdev->ept = NULL; } mutex_unlock(&eptdev->ept_lock); -- 2.17.1