Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp947698pxb; Thu, 4 Feb 2021 00:50:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJypb0wEbugkwBHvkIC9vt04fMLDRrnxbC2SCLoe2nhltPKcEb44VODxura4xyDke2DmUl53 X-Received: by 2002:a17:906:a00e:: with SMTP id p14mr7108494ejy.532.1612428658377; Thu, 04 Feb 2021 00:50:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612428658; cv=none; d=google.com; s=arc-20160816; b=x/+lwxUheon/LwigG5m41iGQQG7P1cH4nXphPd9lQvWCECQjZjuv2FK8p7FGIg7Td+ MY3Mkv5geUSsTi0EXklOOAaaKU4OJZNg4LzeVI5CF+p+yWGuZg7RfIho7YiDngQf2MJS sSUZs91uYSf4GcmCBXE95mY1N7vVm7WRf2Hj9jEC+2z2siQc1D77bVnPC8sfjbdtdwWu XKMkc7fgPJInIRH/0vWrOaOmn7xa+7zQgURpEp9lu8ymVjZbf9l/hPzDv2oalAre380+ u/+oe4kEb1bjMY2CKu5CrfZzJGCjx3a82BaQI/9qWOu+pQfqZoo1kv1Y/qW9/yu6y+cK kTwA== 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=MuyXJB7WjUr+M+1phw3VLrgCeO68qXJXMtTO20gRugM=; b=lwzy6Vy7/nbZxwf4fsOCq+Mn4qUI7uUiT4KcESx8Kyp9EO9WLRJ7mK2JGrUPxXOzK2 JtAwHYUwwUmXWr5l1iA/xoYB4rEHGMswY/8LQmroWZwCGQYDjHVBJh9xBSA4WEEWS7kL 6GBh9cmienU/BKM0ge6MBYfRjLxa4hm/Gd5V293pYVLTzg6MZTDYO9MdTuPuGQEewmNb ALbW7hGcVJf8dxLxz7ALut7zEMsWFAJoKwmAbtl8XYZTdlS/XIrCtsYtZprOqdRMv09v EWJa48dcUND1Gn4R+3pwH/7OQLpSS2Gr8g55Nl9b7wZ9sLNukZGRtGRoJNXfXCnh/iLR NEbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=OdD6FZc+; 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 z7si3125411edm.477.2021.02.04.00.50.32; Thu, 04 Feb 2021 00:50:58 -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=OdD6FZc+; 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 S235196AbhBDIr6 (ORCPT + 99 others); Thu, 4 Feb 2021 03:47:58 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:36308 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235161AbhBDIra (ORCPT ); Thu, 4 Feb 2021 03:47:30 -0500 Received: from pps.filterd (m0241204.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 1148kaox000463; Thu, 4 Feb 2021 09:46:43 +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=MuyXJB7WjUr+M+1phw3VLrgCeO68qXJXMtTO20gRugM=; b=OdD6FZc+Iqv+QMDMCkjZrgq7IdxJ4c9JDNuT+6d8mVhLcrGfDdGrqPqUKe1525z3xGUg eyHpIGgf0Sk5buAFBRCVzt6jhDSUA8Dtgi/TofjEHn1GWJR8ci5Jxls+qXw+r94AR4VU IVJAKXCxMBEWrmhYcpjnk5qWRcwxyrvC7HVeY8covzyQMweyXyVUVeHiCeZt57lP3eSg M3B8Y/EFvzq+1L+12unc8NcZ/hWlwFK8byQUGhhZaZtYMa07kS4/BKcmOaYtgmL/g1fz szK1n4pj9vvenDm7R9nllsRY3Dd2FpETuLOJCgV/C8FK6L3TUMsaIZpBM4+MpREwABqT Rw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 36ey7h7g1p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Feb 2021 09:46:43 +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 CE01810002A; Thu, 4 Feb 2021 09:46:42 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id C183A22AE52; Thu, 4 Feb 2021 09:46:42 +0100 (CET) Received: from localhost (10.75.127.48) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 4 Feb 2021 09:46:42 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v3 14/15] rpmsg: char: no dynamic endpoint management for the default one Date: Thu, 4 Feb 2021 09:45:33 +0100 Message-ID: <20210204084534.10516-15-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210204084534.10516-1-arnaud.pouliquen@foss.st.com> References: <20210204084534.10516-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.48] X-ClientProxiedBy: SFHDAG2NODE3.st.com (10.75.127.6) To SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369,18.0.737 definitions=2021-02-04_03:2021-02-04,2021-02-04 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 d5aa874865f7..0b0a6b7c0c9a 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 ept 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