Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp2591552ybg; Fri, 31 Jul 2020 04:48:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJweP8k9RG+g+kSz60bLdf0O4uaFUZVGuGxfyIOHPDJaS6kIWlvuc3Co9gJwjiaLwMBqJ568 X-Received: by 2002:a17:906:dd5:: with SMTP id p21mr3889452eji.416.1596196124955; Fri, 31 Jul 2020 04:48:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596196124; cv=none; d=google.com; s=arc-20160816; b=K/fuh0oXRs2YhibaolW63JiriBUXuolR7C05h1J6OQaQ93xBVshqilDOU+M0BrPS3f VmfFJOFjAF1Fa5jZ17owRp7ocPeV3c7zBPKrbueMDNf9S2ADXKYLdp6PHVz524/Dw2IZ cFqjzq/LNQVX3Lf8DQ43JF+cxwfQzh3eBoVbmdd1xKmvWjvT7LuRb63BuovRVZfGP0yh AipgCvMOsAgl1CBvJHvdbF3HkcaYTrj+T5Pp/DSF7KN9TKSp7T3WNhpORG6RP+TMg2M3 PZxa0bNhRCBCWOLGCX32oTv6tZg6+oSB2zOzgg3l0Hh243W/5rUfdnrI/uKQ6yGu/hzP ZQaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=k7ltq3/ZPaKQIqQq9LylBJfe8kS7T2cxwS2tEwGJ8FM=; b=bwIuUjzoo+VHPm058hq2IwfJhlizDtsBbwqUz667HEPH1NvIXKqICQd6/EL2VNqiSB N0v0YfymJ0KmGSoJWUaF8TMJuI3Hg0wyuA2y00u65rVNzzLoRdzdbq+Y7FKcI0idkgeJ HdMLdqM5lAm0X5eyauSNFr1lp+Ti2B6YnGITEY79CMJfPpZlviYqvBvS2DEsQ8Z/dW2H CINEQ6cT6EaRbbUkUzC/iVa2EZ3zEhNX3auN+SCJL1bhAWllC5FEGhJqOO59u6YkGdDH sQJUGzMZo5mVNXlCNimyeSYHBOKgYx1WraFKLm9Swgs9xNAH2BgL3B3/adceOvH9Jgrr guWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=joW8sDzX; 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=st.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m26si5724482ejn.667.2020.07.31.04.48.22; Fri, 31 Jul 2020 04:48:44 -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=@st.com header.s=STMicroelectronics header.b=joW8sDzX; 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=st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732862AbgGaLsC (ORCPT + 99 others); Fri, 31 Jul 2020 07:48:02 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:15206 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732814AbgGaLry (ORCPT ); Fri, 31 Jul 2020 07:47:54 -0400 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06VBbbei031331; Fri, 31 Jul 2020 13:47:51 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=k7ltq3/ZPaKQIqQq9LylBJfe8kS7T2cxwS2tEwGJ8FM=; b=joW8sDzXNZeMc8r5/zaM+7A1pWt15kDnuOuf/mIpk+QIvdT8vxGhwQGhQ++9Q3uOSpwD +Qs0E6PvtCSd3CE4cO1Z3QG51g7ryzi8wgFSzS6uD4jLWfh0gMy8b9NG+JxWhqrYPywo 6EU3H90l/YFqnnObN75RSzJXaNWXxCVRcknNH+WgXf90XEoLBl+LTNtEcRE6/Q4zEldj FEIAvoWI7kPK/XuWJ8ssyFvDRGXPYmubuBmUOnOViCgQMfwsqhBFHVaOmfJqwOh6tUk/ 8fiEltUKyWbT0g5km1A9ZduM2x/f8BQI2AELq1U6XkrpLwhhFOpoa5pklFjzfIfTAddU fQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 32g9v9xgsm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 31 Jul 2020 13:47:51 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id BF65E10002A; Fri, 31 Jul 2020 13:47:50 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id B3FA02A7A83; Fri, 31 Jul 2020 13:47:50 +0200 (CEST) Received: from localhost (10.75.127.47) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 31 Jul 2020 13:47:50 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Subject: [PATCH 9/9] rpmsg: ns: name service announcement endianness Date: Fri, 31 Jul 2020 13:47:32 +0200 Message-ID: <20200731114732.12815-10-arnaud.pouliquen@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731114732.12815-1-arnaud.pouliquen@st.com> References: <20200731114732.12815-1-arnaud.pouliquen@st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.47] X-ClientProxiedBy: SFHDAG5NODE1.st.com (10.75.127.13) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-31_04:2020-07-31,2020-07-31 signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The endianness has to be fixed to ensure that both sides can decode the message. The Little endian format is used according to the generic virtio implementation. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/rpmsg_ns.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/rpmsg/rpmsg_ns.c b/drivers/rpmsg/rpmsg_ns.c index cc2bd47c415a..b478e2b55213 100644 --- a/drivers/rpmsg/rpmsg_ns.c +++ b/drivers/rpmsg/rpmsg_ns.c @@ -33,8 +33,8 @@ enum rpmsg_ns_flags { */ struct rpmsg_ns_msg { char name[RPMSG_NAME_SIZE]; - u32 addr; - u32 flags; + __le32 addr; + __le32 flags; } __packed; /** @@ -57,8 +57,8 @@ static int rpmsg_ns_channel_announce(struct rpmsg_device *rpdev, int ns_flag) return -EINVAL; strncpy(nsm.name, rpdev->id.name, RPMSG_NAME_SIZE); - nsm.addr = rpdev->ept->addr; - nsm.flags = ns_flag; + nsm.addr = cpu_to_le32(rpdev->ept->addr); + nsm.flags = cpu_to_le32(ns_flag); return rpmsg_send_offchannel(rpdev->ept, RPMSG_NS_ADDR, RPMSG_NS_ADDR, &nsm, sizeof(nsm)); @@ -84,6 +84,7 @@ static int rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len, struct rpmsg_device *newch; struct rpmsg_channel_info chinfo; struct device *dev = &rpdev->dev; + unsigned int flags = le32_to_cpu(msg->flags); int ret; #if defined(CONFIG_DYNAMIC_DEBUG) @@ -101,13 +102,13 @@ static int rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len, strncpy(chinfo.name, msg->name, sizeof(chinfo.name)); chinfo.src = RPMSG_ADDR_ANY; - chinfo.dst = msg->addr; + chinfo.dst = le32_to_cpu(msg->addr); dev_info(dev, "%sing channel %s addr 0x%x\n", - msg->flags & RPMSG_NS_DESTROY ? "destroy" : "creat", - msg->name, msg->addr); + flags & RPMSG_NS_DESTROY ? "destroy" : "creat", + msg->name, chinfo.dst); - if (msg->flags & RPMSG_NS_DESTROY) { + if (flags & RPMSG_NS_DESTROY) { ret = rpmsg_release_channel(rpdev, &chinfo); if (ret) dev_err(dev, "rpmsg_destroy_channel failed: %d\n", ret); -- 2.17.1