Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp15338476rwb; Mon, 28 Nov 2022 10:22:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf7QSt0wyEXX+ZryYsqARXubhHzMZj99LElMSbDCICgXQC5bsBVJ2au6I1R3KiXya6aKGqPn X-Received: by 2002:a17:90b:35cc:b0:213:258e:7435 with SMTP id nb12-20020a17090b35cc00b00213258e7435mr54566966pjb.137.1669659741251; Mon, 28 Nov 2022 10:22:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669659741; cv=none; d=google.com; s=arc-20160816; b=TrqgJDhii1P8ESo9iA7Jz1rO0blxlh4pU6yduMv6sgrHy6+wmZjHnUPJmu9HqgnEv1 7GxJqyvsGFsubDcG1pyzDiZ9gIk/5mqx/x32vRM8hHo0+LSE5YDBkwxwCSqkLgGtDbrP eqCRFpi3nCWrQptT2DqTxJvBgtD2VJfeB1V7UjdyQgVIDgivahV9luK9pfmLW1nYkTvj KgXFv3VqMD9qkZW8MxCTEI+BKt3f+wrpxlcXXvKJObGs2SnX0uccCAL9loZ6zhNii+1e 85DPt0Ir4x9fmkx04n/lvxTrQ376bRrOq0r90h+Ksi/0oOO1x8YWzq6YxzVEiAP+Uzz+ RocQ== 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=HI9u2GFU8htEiR6UUb2OPsnPLZvoUE7rjEHPYn4ZC0s=; b=pKPnV5XgDHfxtpIaHBuNfBOBX5oOZ5brXDP07HL9iAr07pC5VQDS+IIEPMff+CSTC4 8440ygt4kZpv7XG0JLm31E2GSKHPpBr2221mhGFO2Mri+OekP5sj8azE7vw2p9IQXJL0 dcyqe2KmBnrSoGBJkqR5Bf9L7sVsEVobfsfVFm8NQpETczqL3XrJeED6uPXZHzaOwuZM QxGphcMg/NlV4HZvnNB6TUedZ/6nB0wCDjHKquL+M0o2h7uzsRApcs5nSBumNwXSregD GfCrznz68Lz4+7bFVhoFkjD8rOUcZIShJXhokL4eLZTR0fjl0GOezmeUc5DWCf+lyE0F V05w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=MX5pYwNw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 21-20020a631355000000b0046af0960898si13020378pgt.625.2022.11.28.10.22.10; Mon, 28 Nov 2022 10:22:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=MX5pYwNw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234233AbiK1STo (ORCPT + 84 others); Mon, 28 Nov 2022 13:19:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234216AbiK1SS6 (ORCPT ); Mon, 28 Nov 2022 13:18:58 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C88A0391CB; Mon, 28 Nov 2022 10:03:44 -0800 (PST) Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2ASE3NwJ015383; Mon, 28 Nov 2022 18:03:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=HI9u2GFU8htEiR6UUb2OPsnPLZvoUE7rjEHPYn4ZC0s=; b=MX5pYwNwIwlU78BE+DGO0jKLWheLH0iRy6k/M/Ll2+0G6KQ4xxeO/ryqUYvA7H46BiKS p/Pgozpi+qI1dzciUAHrDsXKq+ivF3/71wKjJBrzK7TqPRcJ4c/+AKAsujXshybbL3v+ azztqT3fH/yYuZHBMOYZq+PrDzRujfX+VGIny40/gGbzsE8AtxyBXZMrSEfJax1QQrGp tiiewN6I9oGLEPuaWA9r6ZsJCqu0iePolcTEpWmg3M0Ve9C2BxLYFJnPoLE7AYIF5T9+ YVHjqnnPfzCZwIHgnVkGiygZbvdzeuVBjXvVNOn60wNaG6Z7UX92NLUWV4sbHMLduHNu ow== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3m39rxwcjx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 28 Nov 2022 18:03:34 +0000 Received: from nalasex01b.na.qualcomm.com (nalasex01b.na.qualcomm.com [10.47.209.197]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 2ASI3YvT000515 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 28 Nov 2022 18:03:34 GMT Received: from sarannya-linux.qualcomm.com (10.80.80.8) by nalasex01b.na.qualcomm.com (10.47.209.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 28 Nov 2022 10:03:29 -0800 From: Sarannya S To: , , , , CC: , , , Sarannya S , Deepak Kumar Singh , Andy Gross , Bjorn Andersson , Konrad Dybcio Subject: [PATCH V4 2/3] rpmsg: glink: Add support to handle signals command Date: Mon, 28 Nov 2022 23:32:54 +0530 Message-ID: <1669658575-21993-3-git-send-email-quic_sarannya@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1669658575-21993-1-git-send-email-quic_sarannya@quicinc.com> References: <1669658575-21993-1-git-send-email-quic_sarannya@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01b.na.qualcomm.com (10.47.209.197) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: XcZciRpjdvWSmUcXpHErjRp7B_iefpSY X-Proofpoint-ORIG-GUID: XcZciRpjdvWSmUcXpHErjRp7B_iefpSY X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-28_15,2022-11-28_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 mlxscore=0 malwarescore=0 adultscore=0 impostorscore=0 phishscore=0 clxscore=1015 priorityscore=1501 spamscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211280132 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Remote peripherals send signal notifications over glink with commandID 15. Add support to send and receive the signal command and based signals enable or disable flow control with remote host. Signed-off-by: Chris Lew Signed-off-by: Deepak Kumar Singh Signed-off-by: Sarannya S --- drivers/rpmsg/qcom_glink_native.c | 63 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c index 115c0a1..01d0a49 100644 --- a/drivers/rpmsg/qcom_glink_native.c +++ b/drivers/rpmsg/qcom_glink_native.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -203,9 +204,15 @@ static const struct rpmsg_endpoint_ops glink_endpoint_ops; #define RPM_CMD_TX_DATA_CONT 12 #define RPM_CMD_READ_NOTIF 13 #define RPM_CMD_RX_DONE_W_REUSE 14 +#define RPM_CMD_SIGNALS 15 #define GLINK_FEATURE_INTENTLESS BIT(1) +#define NATIVE_DTR_SIG NATIVE_DSR_SIG +#define NATIVE_DSR_SIG BIT(31) +#define NATIVE_RTS_SIG NATIVE_CTS_SIG +#define NATIVE_CTS_SIG BIT(30) + static void qcom_glink_rx_done_work(struct work_struct *work); static struct glink_channel *qcom_glink_alloc_channel(struct qcom_glink *glink, @@ -1001,6 +1008,57 @@ static int qcom_glink_rx_open_ack(struct qcom_glink *glink, unsigned int lcid) return 0; } +/** + * qcom_glink_set_flow_control() - convert a signal cmd to wire format and + * transmit + * @ept: Rpmsg endpoint for channel. + * @enable: True/False - enable or disable flow control + * + * Return: 0 on success or standard Linux error code. + */ +static int qcom_glink_set_flow_control(struct rpmsg_endpoint *ept, bool enable) +{ + struct glink_channel *channel = to_glink_channel(ept); + struct qcom_glink *glink = channel->glink; + struct glink_msg msg; + u32 sigs = 0; + + if (enable) + sigs |= NATIVE_DTR_SIG | NATIVE_RTS_SIG; + + msg.cmd = cpu_to_le16(RPM_CMD_SIGNALS); + msg.param1 = cpu_to_le16(channel->lcid); + msg.param2 = cpu_to_le32(sigs); + + return qcom_glink_tx(glink, &msg, sizeof(msg), NULL, 0, true); +} + +static int qcom_glink_handle_signals(struct qcom_glink *glink, + unsigned int rcid, unsigned int sigs) +{ + struct glink_channel *channel; + unsigned long flags; + bool enable = false; + + spin_lock_irqsave(&glink->idr_lock, flags); + channel = idr_find(&glink->rcids, rcid); + spin_unlock_irqrestore(&glink->idr_lock, flags); + if (!channel) { + dev_err(glink->dev, "signal for non-existing channel\n"); + return -EINVAL; + } + + if (!channel->ept.flow_cb) + return 0; + + if (sigs & (NATIVE_DSR_SIG | NATIVE_CTS_SIG)) + enable = true; + + channel->ept.flow_cb(channel->ept.rpdev, channel->ept.priv, enable); + + return 0; +} + static irqreturn_t qcom_glink_native_intr(int irq, void *data) { struct qcom_glink *glink = data; @@ -1065,6 +1123,10 @@ static irqreturn_t qcom_glink_native_intr(int irq, void *data) qcom_glink_handle_intent_req_ack(glink, param1, param2); qcom_glink_rx_advance(glink, ALIGN(sizeof(msg), 8)); break; + case RPM_CMD_SIGNALS: + qcom_glink_handle_signals(glink, param1, param2); + qcom_glink_rx_advance(glink, ALIGN(sizeof(msg), 8)); + break; default: dev_err(glink->dev, "unhandled rx cmd: %d\n", cmd); ret = -EINVAL; @@ -1440,6 +1502,7 @@ static const struct rpmsg_endpoint_ops glink_endpoint_ops = { .sendto = qcom_glink_sendto, .trysend = qcom_glink_trysend, .trysendto = qcom_glink_trysendto, + .set_flow_control = qcom_glink_set_flow_control, }; static void qcom_glink_rpdev_release(struct device *dev) -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project