Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4202212pxf; Tue, 23 Mar 2021 05:30:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdmeEEFmt5Dn+b5fedX50AGMSonUsg/UU7bWhD1t/0jGQSJIBZNmSVyPmUvlU6oREQhEGy X-Received: by 2002:a50:ee95:: with SMTP id f21mr4439521edr.130.1616502605679; Tue, 23 Mar 2021 05:30:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616502605; cv=none; d=google.com; s=arc-20160816; b=vDooFaEo1qZYSGliRjvVkEx9EVUCIdeO/gWoxx6o+DB3mu3AqbicGAoW7gI3h2YpaA 0iuiQUZolLkwRMwfwaZ6fMyEuP1K2SJQqBcajXIgF+IkCPXIeIL1Wi2heV6oCYygP5bB 3OYI0MfJZno4kdeLE9Ti0DFj6V+X/3ZK9RIPeUWgCTakjxhS/2DZefkBBFSrf4qNjUaQ 5SOcjQEC812eTmZmkZ9kCVSjdhmHiEeCQMqc81MvCGUIlp30vgv9svJQX1aifoaA1aSw G1jFxXe8AYGaHtIL1UuNQbv0TFjaFb2lcZZzVwBENaTH6o6AVv242LfEo58FXUtFH/LC /zng== 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=lDGOrCrB6nkec/s32E4KlBp1JOhuABrodB4bccFmmoQ=; b=yeIFpSQu/ob9qOEKvIwldVPdRnibKT9EOXdg0+ZFFjLY/9sWx+RX2dszdb/Qk7uuRo IuMlEXZGrBj8+1nqxGl7Aw7h0zg8qFNklAQ27retBubIB/SzElLhuQKkUs48MkbvXBpR RkHlXdQF8rIS0eS6uR0sD0H9r5jwPAZ4ZKa4y4Zo0ZXLZfMvW8jECKncRyusAxaBSQmv V9ML4Is9NobjQCZp/vc7z91/871ZBoPN8zkma4+7iFQCpNPXVMeMxEs3gPUE+RUYuii9 YMbPhLH78UEW/NWGnzgSB5679yCF5d/8BwbLpkCJxtjoC9V5Y/2XhZQjHjIBU0xFUG7w A6PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b="zWTv8/wJ"; 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 8si4948531ejx.637.2021.03.23.05.29.43; Tue, 23 Mar 2021 05:30:05 -0700 (PDT) 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="zWTv8/wJ"; 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 S231172AbhCWM3E (ORCPT + 99 others); Tue, 23 Mar 2021 08:29:04 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:57420 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229884AbhCWM2m (ORCPT ); Tue, 23 Mar 2021 08:28:42 -0400 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 12NCMA7U026737; Tue, 23 Mar 2021 13:28:38 +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=lDGOrCrB6nkec/s32E4KlBp1JOhuABrodB4bccFmmoQ=; b=zWTv8/wJGbOufjuZw2Bd7OAWia1gHBhnO67w6QKGmrWZ0+7MYp+X7hB9jsojaZj3Y8be P6y6vn8BO3bpsQbn2S1UVLfT/cos+Y8tG+WINI7UThCEZso98pbiWBnpUw3ept+Qanzy FRv2r9bGTFelIhBt/+XhCW9tkXnQlXv+quNNiX06X6+z9+KCQR7s4oqPVoQRc4z1FWp8 M40QicgwqFhOewMG+dAdpYE5NQQqNcqLLiedP1x0Qqhqjv+ltbBF6JnlffZGbr7ouicd ppN62dpxRwjEwLYuSNG9GPk/0mJMtAenvv0xR0Lyq0EK3bRSfuaIC7VS73rBVlA0XYgW lA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 37d8tpfat5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 23 Mar 2021 13:28:38 +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 AE2D110002A; Tue, 23 Mar 2021 13:28:37 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 9ECCD24CF47; Tue, 23 Mar 2021 13:28:37 +0100 (CET) Received: from localhost (10.75.127.45) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 23 Mar 2021 13:28:36 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH 6/7] rpmsg: char: No dynamic endpoint management for the default one Date: Tue, 23 Mar 2021 13:27:36 +0100 Message-ID: <20210323122737.23035-7-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210323122737.23035-1-arnaud.pouliquen@foss.st.com> References: <20210323122737.23035-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.45] X-ClientProxiedBy: SFHDAG3NODE3.st.com (10.75.127.9) 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-03-23_06:2021-03-22,2021-03-23 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Do not dynamically manage the default endpoint associated to the rpmsg device. The ept address must not change. This update is needed to manage the rpmsg-raw channel. In this case a default endpoint is used and its 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 69e774edb74b..8064244f8f18 100644 --- a/drivers/rpmsg/rpmsg_char.c +++ b/drivers/rpmsg/rpmsg_char.c @@ -114,17 +114,26 @@ 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; if (eptdev->ept) return -EBUSY; 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; @@ -136,12 +145,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