From patchwork Mon Jan 9 22:39:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 41205 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2420201wrt; Mon, 9 Jan 2023 14:44:12 -0800 (PST) X-Google-Smtp-Source: AMrXdXseZrLKY36r/cojXs8cabsksA1VW7xfbJjcrAyuHKCfov7Txi2Gz3otCcFbbijy1cu0YjLB X-Received: by 2002:aa7:d689:0:b0:461:7ae:c244 with SMTP id d9-20020aa7d689000000b0046107aec244mr57736682edr.35.1673304252085; Mon, 09 Jan 2023 14:44:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673304252; cv=none; d=google.com; s=arc-20160816; b=dYsNDF3qDW2VCTseCGXdr1b299xp0jDIBcK0gYqZoMjJKUcVUjfFCQ60lM+xWzIe3Y k57aJYA5J5/mdNyp3A2gDfW4RfIdiqvd9J1AtUuRwV+hTSSHZ/SKjmXqGCKZAZz75Ium VuY2ApHSauKG7CZ5wCVMkzOthTRHqpE8iyTiA3L7U9wdM34Nb5N+SDSmljabKx1zZWdd wsaAjq1glaALZmWXJniXLU/y7qeLvES2N+Pgkkr2E723s+pTEJJZEkgUUWqT6X6VCERN lHm5/PJJuql6jyuyuFuYy73K2eibYULB19QkZ4lbzJl2UnDhyf+4iaSonaJIY/wBQgIu 1piw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Y9T5mXuEeB6ZHBIcoZEDpgHVBZE6CIMC1qry4NKe/sE=; b=WpkV7XGsdA5pWiFhbjY+SnP75GD1IwTWCWm01jH7xe2/j8jBL/nPi2gN7/nVmBsF2f oGrfvGN8E8C9eHIfRv3mLOaXYlp/gZpb7511X0zrbND9NEAOT5AM86MlBXHmNWAjwZNf r0Z9hN+cgmjxicYTpqqZPCFDuPGWaIOAw26mCpUnfh/yEJl3XrvARshMU4wF2bIxlYLf 9UYk7b/L+tuVU8HBm4zPfvN6qt6lndVqzXhD5YrndXObXfhOxBY5QWzDKfu9GZTfJTMV tbpom5uad8KnuKx5x2QjT+aKCU9i629ddsGQbMfWekht/OOwAnRFtmitVyugth0wv8g7 aTyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=klCLtulN; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h2-20020a056402280200b0047f9f11dab3si11683637ede.25.2023.01.09.14.43.42; Mon, 09 Jan 2023 14:44:12 -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=klCLtulN; 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 S238003AbjAIWkx (ORCPT + 99 others); Mon, 9 Jan 2023 17:40:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237870AbjAIWkM (ORCPT ); Mon, 9 Jan 2023 17:40:12 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8E4B13DD2; Mon, 9 Jan 2023 14:40:11 -0800 (PST) Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 309KFLl0024402; Mon, 9 Jan 2023 22:40:08 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-transfer-encoding : content-type; s=qcppdkim1; bh=Y9T5mXuEeB6ZHBIcoZEDpgHVBZE6CIMC1qry4NKe/sE=; b=klCLtulNiMbtEZoGh3oTk1DIzuDqahHdcllN+RxnK/kYqnU88JOkPdrOEnZtC64wyOLI +iJ7tQwhdGVc3WlDmTG/s+j8ZdkrQU5LyZNvbaHpPIBCVCqlfEPmnZIQrk9yuiu4b9Zi 7L7EEyCZhiKPlYg8YJ1pHbo2cePFBuZyMP4FrGpIAp/O2EdUHoUbd0s+D8Em4vKsBQj+ aZvzSa06vna0DS42S6TccU3f9uktqf3+gL+8k9te2A+qyojG1Q4KGZqieQei7HWSpG+l iWAPd7r2F3IXL+yTbYoaupybilk9obG5VnOsrOfGJSxOcNXPav2YXYw45eC5tQgA/yqv eQ== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3n0ssh87rq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Jan 2023 22:40:08 +0000 Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 309Me7Ql027265 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 9 Jan 2023 22:40:07 GMT Received: from hu-bjorande-lv.qualcomm.com (10.49.16.6) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 9 Jan 2023 14:40:07 -0800 From: Bjorn Andersson To: Bjorn Andersson , Mathieu Poirier , Chris Lew CC: , , Subject: [PATCH 1/6] rpmsg: glink: Extract tx kick operation Date: Mon, 9 Jan 2023 14:39:56 -0800 Message-ID: <20230109224001.1706516-2-quic_bjorande@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230109224001.1706516-1-quic_bjorande@quicinc.com> References: <20230109224001.1706516-1-quic_bjorande@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: IPNUsT6Ll7ntQkrbwh-_c6G9OLHea3P5 X-Proofpoint-ORIG-GUID: IPNUsT6Ll7ntQkrbwh-_c6G9OLHea3P5 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-09_14,2023-01-09_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 phishscore=0 spamscore=0 clxscore=1015 suspectscore=0 adultscore=0 impostorscore=0 bulkscore=0 malwarescore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301090157 X-Spam-Status: No, score=1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_SBL_CSS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754586679771083301?= X-GMAIL-MSGID: =?utf-8?q?1754586679771083301?= Refactor out the tx kick operations to its own function, in preparation for pushing the details to the individual transports. Signed-off-by: Bjorn Andersson Reviewed-by: Chris Lew --- drivers/rpmsg/qcom_glink_native.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c index 115c0a1eddb1..5fd8b70271b7 100644 --- a/drivers/rpmsg/qcom_glink_native.c +++ b/drivers/rpmsg/qcom_glink_native.c @@ -303,6 +303,12 @@ static void qcom_glink_tx_write(struct qcom_glink *glink, glink->tx_pipe->write(glink->tx_pipe, hdr, hlen, data, dlen); } +static void qcom_glink_tx_kick(struct qcom_glink *glink) +{ + mbox_send_message(glink->mbox_chan, NULL); + mbox_client_txdone(glink->mbox_chan, 0); +} + static void qcom_glink_send_read_notify(struct qcom_glink *glink) { struct glink_msg msg; @@ -313,8 +319,7 @@ static void qcom_glink_send_read_notify(struct qcom_glink *glink) qcom_glink_tx_write(glink, &msg, sizeof(msg), NULL, 0); - mbox_send_message(glink->mbox_chan, NULL); - mbox_client_txdone(glink->mbox_chan, 0); + qcom_glink_tx_kick(glink); } static int qcom_glink_tx(struct qcom_glink *glink, @@ -355,9 +360,7 @@ static int qcom_glink_tx(struct qcom_glink *glink, } qcom_glink_tx_write(glink, hdr, hlen, data, dlen); - - mbox_send_message(glink->mbox_chan, NULL); - mbox_client_txdone(glink->mbox_chan, 0); + qcom_glink_tx_kick(glink); out: spin_unlock_irqrestore(&glink->tx_lock, flags); @@ -1046,9 +1049,7 @@ static irqreturn_t qcom_glink_native_intr(int irq, void *data) break; case RPM_CMD_READ_NOTIF: qcom_glink_rx_advance(glink, ALIGN(sizeof(msg), 8)); - - mbox_send_message(glink->mbox_chan, NULL); - mbox_client_txdone(glink->mbox_chan, 0); + qcom_glink_tx_kick(glink); break; case RPM_CMD_INTENT: qcom_glink_handle_intent(glink, param1, param2, avail); From patchwork Mon Jan 9 22:39:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 41204 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2420178wrt; Mon, 9 Jan 2023 14:44:08 -0800 (PST) X-Google-Smtp-Source: AMrXdXsqp7uN/dvmLoMJGu2/DF5HFKMorkbCvXt8CFu8jYAwzg2Zjyxd8vl2SNplmgfeRrQmqGIJ X-Received: by 2002:a17:906:838b:b0:851:97ca:7fc9 with SMTP id p11-20020a170906838b00b0085197ca7fc9mr1952738ejx.40.1673304248612; Mon, 09 Jan 2023 14:44:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673304248; cv=none; d=google.com; s=arc-20160816; b=0/ffHaThjx9rnEQ+PknoEuDiSS4KFZUjqv4VoYPsTg7PHKbQJLPWjfzuZnVXGxcafb tw3bYNyzYGUQXKfqqIqdo2XyMXv50G00WXdwgIErZdk/hbJsuHb/KV/UHfksJTH1LXpW VXvN9YG1t/XFB2NSfMAfCLmISJYum+3IrirGBq+j+lGyq5JPsB7nMiEHGn5iaX9vRXvE RWiXdZmq/eOe5urENirvNndDughHJv1KbfUMNO1uRo5Upr++xqtag7MC4QCeH6Vx/dO4 +dNw3KlQnTFMV/NlEcjxkAer+89NNhmnsnvd8d8IJfs+8gSGaFP024Ks9dcHYkgW63sK 1e0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4e8Mz6h5RL7FchyNrlIzMuzEyjtxoOYy8k36C7ow1bQ=; b=dQJhDEcLuGoUhu0kQ2ejxqztZpDCf+cVuWsMrG01bDXhzGa4D9bmLI2eLrLhK1rbEK Gez/CHn7vH6Ox3Laz6L2NnGOhkBJTAUcG/i61RTqxwmSASuF+AYryYlcrO6GcXumgBSa COcDB04GXI/EvIMELnHhiFyzzcR+emX7980xwizPv8yHU1264X4y1Hxvn0d0R/C7q4uM 8sshP5xSwLwy+azBOUKdDyQJvrUxON/zk9MXiOApSzQkz2a5oGB4V9P5KeoZGin9493K N3akhy/s3FLnXsdLpTBS0ppHeY1iwdh2BTicFaDLQgQOP8DTA0SMtXwP8c7QYOzqErPi Nl/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=SLO8blYc; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ds19-20020a170907725300b0073dd7598686si8745801ejc.270.2023.01.09.14.43.42; Mon, 09 Jan 2023 14:44:08 -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=SLO8blYc; 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 S238006AbjAIWk4 (ORCPT + 99 others); Mon, 9 Jan 2023 17:40:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237616AbjAIWkN (ORCPT ); Mon, 9 Jan 2023 17:40:13 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E05A2F58C; Mon, 9 Jan 2023 14:40:12 -0800 (PST) Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 309LepaQ020592; Mon, 9 Jan 2023 22:40:09 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-transfer-encoding : content-type; s=qcppdkim1; bh=4e8Mz6h5RL7FchyNrlIzMuzEyjtxoOYy8k36C7ow1bQ=; b=SLO8blYcV7A/7Pyi2k5MqTRRT6FXPnRBds0FEHT4SMSKrO8VU+4lBS26OPWnar8Uz+67 maaA/gKcX98WeAwDVIdauD1evkv9V8kofz18Firsbtw/EgOf1LyWJL1QVtckviVPzTmr FJnlE9FyuBXn3Sgg4qSnDiwGKGz6/BtYyxrd/kjlOa0YBWhvx6vVBLzURh9Cd/5PaUVe 75EeD3rczl8FFwcV0+JjaR1DILoGTwVfCspVXDnwtKIRQBgmEPYUCmNSfHxqL2vejF90 E+EOEVuEWo7itvcvxHg3Q3nASyF9Rvdi+h1PvKsUB9Hmc+Y3FWDyk1f/11iWxWv8KA5y Zg== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3my14fv7wq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Jan 2023 22:40:08 +0000 Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 309Me7AF026530 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 9 Jan 2023 22:40:07 GMT Received: from hu-bjorande-lv.qualcomm.com (10.49.16.6) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 9 Jan 2023 14:40:07 -0800 From: Bjorn Andersson To: Bjorn Andersson , Mathieu Poirier , Chris Lew CC: , , Subject: [PATCH 2/6] rpmsg: glink: smem: Wrap driver context Date: Mon, 9 Jan 2023 14:39:57 -0800 Message-ID: <20230109224001.1706516-3-quic_bjorande@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230109224001.1706516-1-quic_bjorande@quicinc.com> References: <20230109224001.1706516-1-quic_bjorande@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: S51Z6nBS4a13u6ylmerCopeu_qajcnSu X-Proofpoint-ORIG-GUID: S51Z6nBS4a13u6ylmerCopeu_qajcnSu X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-09_14,2023-01-09_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 spamscore=0 impostorscore=0 priorityscore=1501 bulkscore=0 adultscore=0 phishscore=0 clxscore=1015 suspectscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301090157 X-Spam-Status: No, score=1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_SBL_CSS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754586675695625089?= X-GMAIL-MSGID: =?utf-8?q?1754586675695625089?= The Glink SMEM driver allocates a struct device and hangs two devres-allocated pipe objects thereon. To facilitate the move of interrupt and mailbox handling to the driver, introduce a wrapper object capturing the device, glink reference and remote processor id. The type of the remoteproc reference is updated, as these are specifically targetting the SMEM implementation. Signed-off-by: Bjorn Andersson --- drivers/remoteproc/qcom_common.h | 3 +- drivers/rpmsg/qcom_glink_smem.c | 76 ++++++++++++++++++++------------ include/linux/rpmsg/qcom_glink.h | 12 ++--- 3 files changed, 55 insertions(+), 36 deletions(-) diff --git a/drivers/remoteproc/qcom_common.h b/drivers/remoteproc/qcom_common.h index c35adf730be0..2747c7d9ba44 100644 --- a/drivers/remoteproc/qcom_common.h +++ b/drivers/remoteproc/qcom_common.h @@ -6,6 +6,7 @@ #include "remoteproc_internal.h" #include +struct qcom_glink_smem; struct qcom_sysmon; struct qcom_rproc_glink { @@ -15,7 +16,7 @@ struct qcom_rproc_glink { struct device *dev; struct device_node *node; - struct qcom_glink *edge; + struct qcom_glink_smem *edge; }; struct qcom_rproc_subdev { diff --git a/drivers/rpmsg/qcom_glink_smem.c b/drivers/rpmsg/qcom_glink_smem.c index 579bc4443f6d..703e63fa5a86 100644 --- a/drivers/rpmsg/qcom_glink_smem.c +++ b/drivers/rpmsg/qcom_glink_smem.c @@ -33,6 +33,14 @@ #define SMEM_GLINK_NATIVE_XPRT_FIFO_0 479 #define SMEM_GLINK_NATIVE_XPRT_FIFO_1 480 +struct qcom_glink_smem { + struct device dev; + + struct qcom_glink *glink; + + u32 remote_pid; +}; + struct glink_smem_pipe { struct qcom_glink_pipe native; @@ -41,7 +49,7 @@ struct glink_smem_pipe { void *fifo; - int remote_pid; + struct qcom_glink_smem *smem; }; #define to_smem_pipe(p) container_of(p, struct glink_smem_pipe, native) @@ -49,13 +57,14 @@ struct glink_smem_pipe { static size_t glink_smem_rx_avail(struct qcom_glink_pipe *np) { struct glink_smem_pipe *pipe = to_smem_pipe(np); + struct qcom_glink_smem *smem = pipe->smem; size_t len; void *fifo; u32 head; u32 tail; if (!pipe->fifo) { - fifo = qcom_smem_get(pipe->remote_pid, + fifo = qcom_smem_get(smem->remote_pid, SMEM_GLINK_NATIVE_XPRT_FIFO_1, &len); if (IS_ERR(fifo)) { pr_err("failed to acquire RX fifo handle: %ld\n", @@ -179,45 +188,49 @@ static void glink_smem_tx_write(struct qcom_glink_pipe *glink_pipe, static void qcom_glink_smem_release(struct device *dev) { - kfree(dev); + struct qcom_glink_smem *smem = container_of(dev, struct qcom_glink_smem, dev); + + kfree(smem); } -struct qcom_glink *qcom_glink_smem_register(struct device *parent, - struct device_node *node) +struct qcom_glink_smem *qcom_glink_smem_register(struct device *parent, + struct device_node *node) { struct glink_smem_pipe *rx_pipe; struct glink_smem_pipe *tx_pipe; struct qcom_glink *glink; - struct device *dev; + struct qcom_glink_smem *smem; u32 remote_pid; __le32 *descs; size_t size; int ret; - dev = kzalloc(sizeof(*dev), GFP_KERNEL); - if (!dev) + smem = kzalloc(sizeof(*smem), GFP_KERNEL); + if (!smem) return ERR_PTR(-ENOMEM); - dev->parent = parent; - dev->of_node = node; - dev->release = qcom_glink_smem_release; - dev_set_name(dev, "%s:%pOFn", dev_name(parent->parent), node); - ret = device_register(dev); + smem->dev.parent = parent; + smem->dev.of_node = node; + smem->dev.release = qcom_glink_smem_release; + dev_set_name(&smem->dev, "%s:%pOFn", dev_name(parent->parent), node); + ret = device_register(&smem->dev); if (ret) { pr_err("failed to register glink edge\n"); - put_device(dev); + put_device(&smem->dev); return ERR_PTR(ret); } - ret = of_property_read_u32(dev->of_node, "qcom,remote-pid", + ret = of_property_read_u32(smem->dev.of_node, "qcom,remote-pid", &remote_pid); if (ret) { - dev_err(dev, "failed to parse qcom,remote-pid\n"); + dev_err(&smem->dev, "failed to parse qcom,remote-pid\n"); goto err_put_dev; } - rx_pipe = devm_kzalloc(dev, sizeof(*rx_pipe), GFP_KERNEL); - tx_pipe = devm_kzalloc(dev, sizeof(*tx_pipe), GFP_KERNEL); + smem->remote_pid = remote_pid; + + rx_pipe = devm_kzalloc(&smem->dev, sizeof(*rx_pipe), GFP_KERNEL); + tx_pipe = devm_kzalloc(&smem->dev, sizeof(*tx_pipe), GFP_KERNEL); if (!rx_pipe || !tx_pipe) { ret = -ENOMEM; goto err_put_dev; @@ -226,20 +239,20 @@ struct qcom_glink *qcom_glink_smem_register(struct device *parent, ret = qcom_smem_alloc(remote_pid, SMEM_GLINK_NATIVE_XPRT_DESCRIPTOR, 32); if (ret && ret != -EEXIST) { - dev_err(dev, "failed to allocate glink descriptors\n"); + dev_err(&smem->dev, "failed to allocate glink descriptors\n"); goto err_put_dev; } descs = qcom_smem_get(remote_pid, SMEM_GLINK_NATIVE_XPRT_DESCRIPTOR, &size); if (IS_ERR(descs)) { - dev_err(dev, "failed to acquire xprt descriptor\n"); + dev_err(&smem->dev, "failed to acquire xprt descriptor\n"); ret = PTR_ERR(descs); goto err_put_dev; } if (size != 32) { - dev_err(dev, "glink descriptor of invalid size\n"); + dev_err(&smem->dev, "glink descriptor of invalid size\n"); ret = -EINVAL; goto err_put_dev; } @@ -252,31 +265,31 @@ struct qcom_glink *qcom_glink_smem_register(struct device *parent, ret = qcom_smem_alloc(remote_pid, SMEM_GLINK_NATIVE_XPRT_FIFO_0, SZ_16K); if (ret && ret != -EEXIST) { - dev_err(dev, "failed to allocate TX fifo\n"); + dev_err(&smem->dev, "failed to allocate TX fifo\n"); goto err_put_dev; } tx_pipe->fifo = qcom_smem_get(remote_pid, SMEM_GLINK_NATIVE_XPRT_FIFO_0, &tx_pipe->native.length); if (IS_ERR(tx_pipe->fifo)) { - dev_err(dev, "failed to acquire TX fifo\n"); + dev_err(&smem->dev, "failed to acquire TX fifo\n"); ret = PTR_ERR(tx_pipe->fifo); goto err_put_dev; } + rx_pipe->smem = smem; rx_pipe->native.avail = glink_smem_rx_avail; rx_pipe->native.peak = glink_smem_rx_peak; rx_pipe->native.advance = glink_smem_rx_advance; - rx_pipe->remote_pid = remote_pid; + tx_pipe->smem = smem; tx_pipe->native.avail = glink_smem_tx_avail; tx_pipe->native.write = glink_smem_tx_write; - tx_pipe->remote_pid = remote_pid; *rx_pipe->tail = 0; *tx_pipe->head = 0; - glink = qcom_glink_native_probe(dev, + glink = qcom_glink_native_probe(&smem->dev, GLINK_FEATURE_INTENT_REUSE, &rx_pipe->native, &tx_pipe->native, false); @@ -285,17 +298,22 @@ struct qcom_glink *qcom_glink_smem_register(struct device *parent, goto err_put_dev; } - return glink; + smem->glink = glink; + + return smem; + err_put_dev: - device_unregister(dev); + device_unregister(&smem->dev); return ERR_PTR(ret); } EXPORT_SYMBOL_GPL(qcom_glink_smem_register); -void qcom_glink_smem_unregister(struct qcom_glink *glink) +void qcom_glink_smem_unregister(struct qcom_glink_smem *smem) { + struct qcom_glink *glink = smem->glink; + qcom_glink_native_remove(glink); qcom_glink_native_unregister(glink); } diff --git a/include/linux/rpmsg/qcom_glink.h b/include/linux/rpmsg/qcom_glink.h index 22fc3a69b683..bfbd48f435fa 100644 --- a/include/linux/rpmsg/qcom_glink.h +++ b/include/linux/rpmsg/qcom_glink.h @@ -5,7 +5,7 @@ #include -struct qcom_glink; +struct qcom_glink_smem; #if IS_ENABLED(CONFIG_RPMSG_QCOM_GLINK) void qcom_glink_ssr_notify(const char *ssr_name); @@ -15,20 +15,20 @@ static inline void qcom_glink_ssr_notify(const char *ssr_name) {} #if IS_ENABLED(CONFIG_RPMSG_QCOM_GLINK_SMEM) -struct qcom_glink *qcom_glink_smem_register(struct device *parent, - struct device_node *node); -void qcom_glink_smem_unregister(struct qcom_glink *glink); +struct qcom_glink_smem *qcom_glink_smem_register(struct device *parent, + struct device_node *node); +void qcom_glink_smem_unregister(struct qcom_glink_smem *glink); #else -static inline struct qcom_glink * +static inline struct qcom_glink_smem * qcom_glink_smem_register(struct device *parent, struct device_node *node) { return NULL; } -static inline void qcom_glink_smem_unregister(struct qcom_glink *glink) {} +static inline void qcom_glink_smem_unregister(struct qcom_glink_smem *glink) {} #endif #endif From patchwork Mon Jan 9 22:39:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 41200 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2419935wrt; Mon, 9 Jan 2023 14:43:29 -0800 (PST) X-Google-Smtp-Source: AMrXdXsSgojrcs2Z4wbj7Q5hNwXByPRjsZTD9wbAdl+FQL0bkkG/kNjl/2VcmUESoqSgOSuA4Hva X-Received: by 2002:a17:906:b053:b0:7ad:ca80:5669 with SMTP id bj19-20020a170906b05300b007adca805669mr69638115ejb.64.1673304209670; Mon, 09 Jan 2023 14:43:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673304209; cv=none; d=google.com; s=arc-20160816; b=drAuICgXNGCZ/XwvUUwy6rP3Xu4EUHPfOPsLAwQ4IQu9Z2FVlvHR99cVOOrzdKFA2O cFZtxnRFaFurWGDk3xV2LaS+Z2uxQS/lr7eUud6CgfQcvKLeZBmimpH1N0qP3At8QCaY hZI5UaVn0R+M8vetNWin92xxKkcyoNyeKche/ZxVzkxC/02UiFhIg19fgeAxUC67zkA6 MObTa5d0X6cUEmdPPzNrnfUBl80Cr7ZQSfrcb3PBh4PKPRHMeSXoZ+k8I743lkMUIs3l eZ8aTqIAaMa6Rmj/GUfH3JU7RstLUtVVY+mCmLM02AOB4PT8eYkXXHJpK51xuQGL1hgw nZMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Fo+XDG1NWFHnUwew+NJYKC5jDr9wAAH4NTYJKeieCi0=; b=sSRQ4CKNv3TYw51dcwX1ZW9mFQtX933rN9naxM20SiTYRY5NHE67YNWsbPItOBapV9 Xm2GhFCrs574mR9g5tFMOxwF2OS5er1dbOVgPfZ4klLcS9fJJWhAg6rqBjuWPMS+zlOB 4liEm6vD+URDcg46uls3DjB6Cp6OYTpmPLV+OXo26OMnHLuokyzIpgHCjvwz7c5WuFu/ gfXPvG+XJghaUz7EGIb7rBYjvWp5WpmiWk4Aldnn43mawY/lgc2AlZwMwFcJhDGPVi+6 dyEf6MrGQ85123VZPfcDxfM0Y7hfXs+E36cjO0kcVp7D7L7Sy5Kx0v6Af5VwTCZf3E/t 7CwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=W7TtcXJr; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wv1-20020a170907080100b007ae10525573si10593724ejb.671.2023.01.09.14.43.06; Mon, 09 Jan 2023 14:43:29 -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=W7TtcXJr; 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 S237974AbjAIWkk (ORCPT + 99 others); Mon, 9 Jan 2023 17:40:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237926AbjAIWkP (ORCPT ); Mon, 9 Jan 2023 17:40:15 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2780613FA2; Mon, 9 Jan 2023 14:40:14 -0800 (PST) Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 309MdkFf006180; Mon, 9 Jan 2023 22:40:09 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-transfer-encoding : content-type; s=qcppdkim1; bh=Fo+XDG1NWFHnUwew+NJYKC5jDr9wAAH4NTYJKeieCi0=; b=W7TtcXJrQCe9JzF1PtgbKg3l1289i15yKC8c18ZLRQIYNZ1E3ygVtxCwK8aGbPq/ec7o SiXUbjCZTcaAb/g20ONw0u0JFC3vGnkpAfHGCcT4ovtW3qPK1+vXM9t8P28+wpTNbyMz riAG5YI6wfNYzKB7R+i/QgnjMnFE8BbUGg/z+848y501ZJm+4d5ATvOkm+iJstWv6P2q CQII8LPsmplQf1S7tvN6vdJzkDOtboqQvSvEA5ZNdUTtH5e3OwxAKnRGyCmOxMGTesnu hsIbsb8vZRDXN8FFVrnMIg4ntUs/TN1DRdCcWSdgF03E4G4ghK5il7Fh9e3UykchL1iN JQ== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3mxx3w4ecx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Jan 2023 22:40:09 +0000 Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 309Me8sx026536 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 9 Jan 2023 22:40:08 GMT Received: from hu-bjorande-lv.qualcomm.com (10.49.16.6) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 9 Jan 2023 14:40:07 -0800 From: Bjorn Andersson To: Bjorn Andersson , Mathieu Poirier , Chris Lew CC: , , Subject: [PATCH 3/6] rpmsg: glink: rpm: Wrap driver context Date: Mon, 9 Jan 2023 14:39:58 -0800 Message-ID: <20230109224001.1706516-4-quic_bjorande@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230109224001.1706516-1-quic_bjorande@quicinc.com> References: <20230109224001.1706516-1-quic_bjorande@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: a-8e6U_0kPQ2TBsYH21HLqpya64i3SJd X-Proofpoint-GUID: a-8e6U_0kPQ2TBsYH21HLqpya64i3SJd X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-09_14,2023-01-09_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 lowpriorityscore=0 adultscore=0 priorityscore=1501 malwarescore=0 clxscore=1015 bulkscore=0 suspectscore=0 mlxscore=0 phishscore=0 impostorscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301090157 X-Spam-Status: No, score=1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_SBL_CSS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754586634704174408?= X-GMAIL-MSGID: =?utf-8?q?1754586634704174408?= As with the SMEM driver update, wrap the RPM context in a struct to facilitate the upcoming changes of moving IRQ and mailbox registration to the driver. Signed-off-by: Bjorn Andersson Reviewed-by: Chris Lew --- drivers/rpmsg/qcom_glink_rpm.c | 44 ++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/drivers/rpmsg/qcom_glink_rpm.c b/drivers/rpmsg/qcom_glink_rpm.c index f64f45d1a735..6443843df6ca 100644 --- a/drivers/rpmsg/qcom_glink_rpm.c +++ b/drivers/rpmsg/qcom_glink_rpm.c @@ -53,6 +53,13 @@ struct glink_rpm_pipe { void __iomem *fifo; }; +struct glink_rpm { + struct qcom_glink *glink; + + struct glink_rpm_pipe rx_pipe; + struct glink_rpm_pipe tx_pipe; +}; + static size_t glink_rpm_rx_avail(struct qcom_glink_pipe *glink_pipe) { struct glink_rpm_pipe *pipe = to_rpm_pipe(glink_pipe); @@ -257,8 +264,7 @@ static int glink_rpm_parse_toc(struct device *dev, static int glink_rpm_probe(struct platform_device *pdev) { struct qcom_glink *glink; - struct glink_rpm_pipe *rx_pipe; - struct glink_rpm_pipe *tx_pipe; + struct glink_rpm *rpm; struct device_node *np; void __iomem *msg_ram; size_t msg_ram_size; @@ -266,9 +272,8 @@ static int glink_rpm_probe(struct platform_device *pdev) struct resource r; int ret; - rx_pipe = devm_kzalloc(&pdev->dev, sizeof(*rx_pipe), GFP_KERNEL); - tx_pipe = devm_kzalloc(&pdev->dev, sizeof(*tx_pipe), GFP_KERNEL); - if (!rx_pipe || !tx_pipe) + rpm = devm_kzalloc(&pdev->dev, sizeof(*rpm), GFP_KERNEL); + if (!rpm) return -ENOMEM; np = of_parse_phandle(dev->of_node, "qcom,rpm-msg-ram", 0); @@ -283,36 +288,39 @@ static int glink_rpm_probe(struct platform_device *pdev) return -ENOMEM; ret = glink_rpm_parse_toc(dev, msg_ram, msg_ram_size, - rx_pipe, tx_pipe); + &rpm->rx_pipe, &rpm->tx_pipe); if (ret) return ret; /* Pipe specific accessors */ - rx_pipe->native.avail = glink_rpm_rx_avail; - rx_pipe->native.peak = glink_rpm_rx_peak; - rx_pipe->native.advance = glink_rpm_rx_advance; - tx_pipe->native.avail = glink_rpm_tx_avail; - tx_pipe->native.write = glink_rpm_tx_write; + rpm->rx_pipe.native.avail = glink_rpm_rx_avail; + rpm->rx_pipe.native.peak = glink_rpm_rx_peak; + rpm->rx_pipe.native.advance = glink_rpm_rx_advance; + rpm->tx_pipe.native.avail = glink_rpm_tx_avail; + rpm->tx_pipe.native.write = glink_rpm_tx_write; - writel(0, tx_pipe->head); - writel(0, rx_pipe->tail); + writel(0, rpm->tx_pipe.head); + writel(0, rpm->rx_pipe.tail); - glink = qcom_glink_native_probe(&pdev->dev, + glink = qcom_glink_native_probe(dev, 0, - &rx_pipe->native, - &tx_pipe->native, + &rpm->rx_pipe.native, + &rpm->tx_pipe.native, true); if (IS_ERR(glink)) return PTR_ERR(glink); - platform_set_drvdata(pdev, glink); + rpm->glink = glink; + + platform_set_drvdata(pdev, rpm); return 0; } static int glink_rpm_remove(struct platform_device *pdev) { - struct qcom_glink *glink = platform_get_drvdata(pdev); + struct glink_rpm *rpm = platform_get_drvdata(pdev); + struct qcom_glink *glink = rpm->glink; qcom_glink_native_remove(glink); From patchwork Mon Jan 9 22:39:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 41201 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2419956wrt; Mon, 9 Jan 2023 14:43:32 -0800 (PST) X-Google-Smtp-Source: AMrXdXs8rkCtHb8JwYvxg6a+iFHWoCTSCtBB9ns5o1QA39VcsSNZ2zXze7j59EYx6tQQdnIl0Dto X-Received: by 2002:a17:906:9e06:b0:84d:35e1:2781 with SMTP id fp6-20020a1709069e0600b0084d35e12781mr6821195ejc.46.1673304212155; Mon, 09 Jan 2023 14:43:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673304212; cv=none; d=google.com; s=arc-20160816; b=gZZhTpTsoIZVu4T3wRzJorHkapvesq4iRYGSoF3UBdkaojBlcDU7lbFw2qlgJRG5Dh VUIi3ICpkbN9JQfljSzt+1WgmP73WDv5OwiHUovnMwmiMDYo4MWIioiIf/Siaf9VjEdT CfbQDvQzK2a46e8JaoAGSKQwjKm4h59TYqQi3aWnDBuRij2KJ0DOGHxPQ1NNccyCV6hL 07P77j0uq2Qw6biwQOKYWS1hZj04jj/ekF4Rk55jqsjMAUu+clWO8sqaa7xQHQUixgOl 5q3SSqoWdgRpySS9BsKNnqvtScalV2lQlGSwtHQMp54c8cEml1g+7TEV4S0b8w5xwYmB Uo4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+SMlSdL97syI43DpjKDXJvwPE6lMtuB/fs9f7CilYLo=; b=BUAg3neEdcPaLL5AEg3PDAsuv1uXo1jSgkvBy8YD06Z+2t+D5PAJlL39g1xiH9RiWe dysrwIgRm4Zmj2228QktOFghMwYDG6kyPZfbAOEnEeJ7TyD2RwBFQaWffpRW/yI74aIV WyLMvaYQyu54SHDKYlpui7/ttPNobg/RQQsWyPSZv+ujM4KE27kkSuDnVRgtbLM7AVDa MEbGjmr2Ziz4hPcGKCTdoknofFJffeJ0AgPwzuxDEF58boT4cBCighrrQ/hGBRnqn1/t 1Bj+htsIa/qqCs1Ton3m5XZHBIT99V3xuURXp24V/21MPmGcCdpW1LYEmmizM3etgJBB Udqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=H54YKqPB; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ho18-20020a1709070e9200b0084d4707b4c8si3819120ejc.687.2023.01.09.14.43.08; Mon, 09 Jan 2023 14:43:32 -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=H54YKqPB; 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 S237927AbjAIWkd (ORCPT + 99 others); Mon, 9 Jan 2023 17:40:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237882AbjAIWkO (ORCPT ); Mon, 9 Jan 2023 17:40:14 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98F4F13CD5; Mon, 9 Jan 2023 14:40:13 -0800 (PST) Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 309MBXFM032168; Mon, 9 Jan 2023 22:40:09 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-transfer-encoding : content-type; s=qcppdkim1; bh=+SMlSdL97syI43DpjKDXJvwPE6lMtuB/fs9f7CilYLo=; b=H54YKqPBGyX19nw/HRG7axAUqXSVJ3fLchR1yEQ2QCyWWB+EaorgtWhwpAhkdbVE34dr f9rtw2bOKbO/hj3owoiGI8FtD5HNKhL96oVAlavR1fGRoH/clal3xdmRya7/RD4ZIdAW kFt84uthj0sI96YZfzWMV10/Vs+1O3IH6xujHbYs4B5Ix8EhNyHh2Hzl7MzvUrzldYEZ aiMDKJxT6QPfH9iSfXiJfYXJnKXhgBaUM9YUcdnLD0MYNNuMcD8Rs/nRqHf0JvzN1O0j IzMzX4qaqacC/sS1rV3MAy3ikOU/VVSDdrPfZxOeoBRj+YW7PeaCxuR93/aAmjm2uDaG Aw== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3mxx3w4ecy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Jan 2023 22:40:09 +0000 Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 309Me8eT027294 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 9 Jan 2023 22:40:08 GMT Received: from hu-bjorande-lv.qualcomm.com (10.49.16.6) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 9 Jan 2023 14:40:08 -0800 From: Bjorn Andersson To: Bjorn Andersson , Mathieu Poirier , Chris Lew CC: , , Subject: [PATCH 4/6] rpmsg: glink: Move irq and mbox handling to transports Date: Mon, 9 Jan 2023 14:39:59 -0800 Message-ID: <20230109224001.1706516-5-quic_bjorande@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230109224001.1706516-1-quic_bjorande@quicinc.com> References: <20230109224001.1706516-1-quic_bjorande@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: Bpbf_kpH4kQlwFhSSTGy9zbjuPU6-OGf X-Proofpoint-GUID: Bpbf_kpH4kQlwFhSSTGy9zbjuPU6-OGf X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-09_14,2023-01-09_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 lowpriorityscore=0 adultscore=0 priorityscore=1501 malwarescore=0 clxscore=1015 bulkscore=0 suspectscore=0 mlxscore=0 phishscore=0 impostorscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301090157 X-Spam-Status: No, score=1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_SBL_CSS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754586637867460032?= X-GMAIL-MSGID: =?utf-8?q?1754586637867460032?= Not all GLINK transports uses an interrupt and a mailbox instance. The interrupt for RPM needs to be IRQF_NOSUSPEND, while it seems reasonable for the SMEM interrupt to use irq_set_wake. The glink struct device is constructed in the SMEM and RPM drivers but torn down in the core driver. Move the interrupt and kick handling into the SMEM and RPM driver, to improve this and facilitate further improvements. Signed-off-by: Bjorn Andersson --- drivers/rpmsg/qcom_glink_native.c | 48 ++------------------------ drivers/rpmsg/qcom_glink_native.h | 3 +- drivers/rpmsg/qcom_glink_rpm.c | 50 ++++++++++++++++++++++++++- drivers/rpmsg/qcom_glink_smem.c | 56 +++++++++++++++++++++++++++++-- 4 files changed, 108 insertions(+), 49 deletions(-) diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c index 5fd8b70271b7..db5d946d5901 100644 --- a/drivers/rpmsg/qcom_glink_native.c +++ b/drivers/rpmsg/qcom_glink_native.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include @@ -78,11 +77,8 @@ struct glink_core_rx_intent { /** * struct qcom_glink - driver context, relates to one remote subsystem * @dev: reference to the associated struct device - * @mbox_client: mailbox client - * @mbox_chan: mailbox channel * @rx_pipe: pipe object for receive FIFO * @tx_pipe: pipe object for transmit FIFO - * @irq: IRQ for signaling incoming events * @rx_work: worker for handling received control messages * @rx_lock: protects the @rx_queue * @rx_queue: queue of received control messages to be processed in @rx_work @@ -98,14 +94,9 @@ struct glink_core_rx_intent { struct qcom_glink { struct device *dev; - struct mbox_client mbox_client; - struct mbox_chan *mbox_chan; - struct qcom_glink_pipe *rx_pipe; struct qcom_glink_pipe *tx_pipe; - int irq; - struct work_struct rx_work; spinlock_t rx_lock; struct list_head rx_queue; @@ -305,8 +296,7 @@ static void qcom_glink_tx_write(struct qcom_glink *glink, static void qcom_glink_tx_kick(struct qcom_glink *glink) { - mbox_send_message(glink->mbox_chan, NULL); - mbox_client_txdone(glink->mbox_chan, 0); + glink->tx_pipe->kick(glink->tx_pipe); } static void qcom_glink_send_read_notify(struct qcom_glink *glink) @@ -1004,9 +994,8 @@ static int qcom_glink_rx_open_ack(struct qcom_glink *glink, unsigned int lcid) return 0; } -static irqreturn_t qcom_glink_native_intr(int irq, void *data) +void qcom_glink_native_intr(struct qcom_glink *glink) { - struct qcom_glink *glink = data; struct glink_msg msg; unsigned int param1; unsigned int param2; @@ -1075,9 +1064,8 @@ static irqreturn_t qcom_glink_native_intr(int irq, void *data) if (ret) break; } - - return IRQ_HANDLED; } +EXPORT_SYMBOL(qcom_glink_native_intr); /* Locally initiated rpmsg_create_ept */ static struct glink_channel *qcom_glink_create_local(struct qcom_glink *glink, @@ -1723,7 +1711,6 @@ struct qcom_glink *qcom_glink_native_probe(struct device *dev, struct qcom_glink_pipe *tx, bool intentless) { - int irq; int ret; struct qcom_glink *glink; @@ -1754,27 +1741,6 @@ struct qcom_glink *qcom_glink_native_probe(struct device *dev, if (ret) dev_err(dev, "failed to add groups\n"); - glink->mbox_client.dev = dev; - glink->mbox_client.knows_txdone = true; - glink->mbox_chan = mbox_request_channel(&glink->mbox_client, 0); - if (IS_ERR(glink->mbox_chan)) { - if (PTR_ERR(glink->mbox_chan) != -EPROBE_DEFER) - dev_err(dev, "failed to acquire IPC channel\n"); - return ERR_CAST(glink->mbox_chan); - } - - irq = of_irq_get(dev->of_node, 0); - ret = devm_request_irq(dev, irq, - qcom_glink_native_intr, - IRQF_NO_SUSPEND | IRQF_SHARED, - "glink-native", glink); - if (ret) { - dev_err(dev, "failed to request IRQ\n"); - return ERR_PTR(ret); - } - - glink->irq = irq; - ret = qcom_glink_send_version(glink); if (ret) return ERR_PTR(ret); @@ -1800,7 +1766,6 @@ void qcom_glink_native_remove(struct qcom_glink *glink) int cid; int ret; - disable_irq(glink->irq); qcom_glink_cancel_rx_work(glink); ret = device_for_each_child(glink->dev, NULL, qcom_glink_remove_device); @@ -1817,15 +1782,8 @@ void qcom_glink_native_remove(struct qcom_glink *glink) idr_destroy(&glink->lcids); idr_destroy(&glink->rcids); - mbox_free_channel(glink->mbox_chan); } EXPORT_SYMBOL_GPL(qcom_glink_native_remove); -void qcom_glink_native_unregister(struct qcom_glink *glink) -{ - device_unregister(glink->dev); -} -EXPORT_SYMBOL_GPL(qcom_glink_native_unregister); - MODULE_DESCRIPTION("Qualcomm GLINK driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/rpmsg/qcom_glink_native.h b/drivers/rpmsg/qcom_glink_native.h index e9a8671616c7..0129fe1b2b6c 100644 --- a/drivers/rpmsg/qcom_glink_native.h +++ b/drivers/rpmsg/qcom_glink_native.h @@ -24,6 +24,7 @@ struct qcom_glink_pipe { void (*write)(struct qcom_glink_pipe *glink_pipe, const void *hdr, size_t hlen, const void *data, size_t dlen); + void (*kick)(struct qcom_glink_pipe *glink_pipe); }; struct device; @@ -35,6 +36,6 @@ struct qcom_glink *qcom_glink_native_probe(struct device *dev, struct qcom_glink_pipe *tx, bool intentless); void qcom_glink_native_remove(struct qcom_glink *glink); +void qcom_glink_native_intr(struct qcom_glink *glink); -void qcom_glink_native_unregister(struct qcom_glink *glink); #endif diff --git a/drivers/rpmsg/qcom_glink_rpm.c b/drivers/rpmsg/qcom_glink_rpm.c index 6443843df6ca..9136645d6251 100644 --- a/drivers/rpmsg/qcom_glink_rpm.c +++ b/drivers/rpmsg/qcom_glink_rpm.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -56,6 +57,11 @@ struct glink_rpm_pipe { struct glink_rpm { struct qcom_glink *glink; + int irq; + + struct mbox_client mbox_client; + struct mbox_chan *mbox_chan; + struct glink_rpm_pipe rx_pipe; struct glink_rpm_pipe tx_pipe; }; @@ -186,6 +192,24 @@ static void glink_rpm_tx_write(struct qcom_glink_pipe *glink_pipe, writel(head, pipe->head); } +static void glink_rpm_tx_kick(struct qcom_glink_pipe *glink_pipe) +{ + struct glink_rpm_pipe *pipe = to_rpm_pipe(glink_pipe); + struct glink_rpm *rpm = container_of(pipe, struct glink_rpm, tx_pipe); + + mbox_send_message(rpm->mbox_chan, NULL); + mbox_client_txdone(rpm->mbox_chan, 0); +} + +static irqreturn_t qcom_glink_rpm_intr(int irq, void *data) +{ + struct glink_rpm *rpm = data; + + qcom_glink_native_intr(rpm->glink); + + return IRQ_HANDLED; +} + static int glink_rpm_parse_toc(struct device *dev, void __iomem *msg_ram, size_t msg_ram_size, @@ -292,12 +316,28 @@ static int glink_rpm_probe(struct platform_device *pdev) if (ret) return ret; + rpm->irq = of_irq_get(dev->of_node, 0); + ret = devm_request_irq(dev, rpm->irq, qcom_glink_rpm_intr, + IRQF_NO_SUSPEND | IRQF_NO_AUTOEN, + "glink-rpm", rpm); + if (ret) { + dev_err(dev, "failed to request IRQ\n"); + return ret; + } + + rpm->mbox_client.dev = dev; + rpm->mbox_client.knows_txdone = true; + rpm->mbox_chan = mbox_request_channel(&rpm->mbox_client, 0); + if (IS_ERR(rpm->mbox_chan)) + return dev_err_probe(dev, PTR_ERR(rpm->mbox_chan), "failed to acquire IPC channel\n"); + /* Pipe specific accessors */ rpm->rx_pipe.native.avail = glink_rpm_rx_avail; rpm->rx_pipe.native.peak = glink_rpm_rx_peak; rpm->rx_pipe.native.advance = glink_rpm_rx_advance; rpm->tx_pipe.native.avail = glink_rpm_tx_avail; rpm->tx_pipe.native.write = glink_rpm_tx_write; + rpm->tx_pipe.native.kick = glink_rpm_tx_kick; writel(0, rpm->tx_pipe.head); writel(0, rpm->rx_pipe.tail); @@ -307,13 +347,17 @@ static int glink_rpm_probe(struct platform_device *pdev) &rpm->rx_pipe.native, &rpm->tx_pipe.native, true); - if (IS_ERR(glink)) + if (IS_ERR(glink)) { + mbox_free_channel(rpm->mbox_chan); return PTR_ERR(glink); + } rpm->glink = glink; platform_set_drvdata(pdev, rpm); + enable_irq(rpm->irq); + return 0; } @@ -322,8 +366,12 @@ static int glink_rpm_remove(struct platform_device *pdev) struct glink_rpm *rpm = platform_get_drvdata(pdev); struct qcom_glink *glink = rpm->glink; + disable_irq(rpm->irq); + qcom_glink_native_remove(glink); + mbox_free_channel(rpm->mbox_chan); + return 0; } diff --git a/drivers/rpmsg/qcom_glink_smem.c b/drivers/rpmsg/qcom_glink_smem.c index 703e63fa5a86..eec47ae98d67 100644 --- a/drivers/rpmsg/qcom_glink_smem.c +++ b/drivers/rpmsg/qcom_glink_smem.c @@ -7,8 +7,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -36,8 +38,12 @@ struct qcom_glink_smem { struct device dev; + int irq; struct qcom_glink *glink; + struct mbox_client mbox_client; + struct mbox_chan *mbox_chan; + u32 remote_pid; }; @@ -186,6 +192,24 @@ static void glink_smem_tx_write(struct qcom_glink_pipe *glink_pipe, *pipe->head = cpu_to_le32(head); } +static void glink_smem_tx_kick(struct qcom_glink_pipe *glink_pipe) +{ + struct glink_smem_pipe *pipe = to_smem_pipe(glink_pipe); + struct qcom_glink_smem *smem = pipe->smem; + + mbox_send_message(smem->mbox_chan, NULL); + mbox_client_txdone(smem->mbox_chan, 0); +} + +static irqreturn_t qcom_glink_smem_intr(int irq, void *data) +{ + struct qcom_glink_smem *smem = data; + + qcom_glink_native_intr(smem->glink); + + return IRQ_HANDLED; +} + static void qcom_glink_smem_release(struct device *dev) { struct qcom_glink_smem *smem = container_of(dev, struct qcom_glink_smem, dev); @@ -277,6 +301,24 @@ struct qcom_glink_smem *qcom_glink_smem_register(struct device *parent, goto err_put_dev; } + smem->irq = of_irq_get(smem->dev.of_node, 0); + ret = devm_request_irq(&smem->dev, smem->irq, qcom_glink_smem_intr, + IRQF_NO_SUSPEND | IRQF_NO_AUTOEN, + "glink-smem", smem); + if (ret) { + dev_err(&smem->dev, "failed to request IRQ\n"); + goto err_put_dev; + } + + smem->mbox_client.dev = &smem->dev; + smem->mbox_client.knows_txdone = true; + smem->mbox_chan = mbox_request_channel(&smem->mbox_client, 0); + if (IS_ERR(smem->mbox_chan)) { + ret = dev_err_probe(&smem->dev, PTR_ERR(smem->mbox_chan), + "failed to acquire IPC channel\n"); + goto err_put_dev; + } + rx_pipe->smem = smem; rx_pipe->native.avail = glink_smem_rx_avail; rx_pipe->native.peak = glink_smem_rx_peak; @@ -285,6 +327,7 @@ struct qcom_glink_smem *qcom_glink_smem_register(struct device *parent, tx_pipe->smem = smem; tx_pipe->native.avail = glink_smem_tx_avail; tx_pipe->native.write = glink_smem_tx_write; + tx_pipe->native.kick = glink_smem_tx_kick; *rx_pipe->tail = 0; *tx_pipe->head = 0; @@ -295,13 +338,17 @@ struct qcom_glink_smem *qcom_glink_smem_register(struct device *parent, false); if (IS_ERR(glink)) { ret = PTR_ERR(glink); - goto err_put_dev; + goto err_free_mbox; } smem->glink = glink; + enable_irq(smem->irq); + return smem; +err_free_mbox: + mbox_free_channel(smem->mbox_chan); err_put_dev: device_unregister(&smem->dev); @@ -314,8 +361,13 @@ void qcom_glink_smem_unregister(struct qcom_glink_smem *smem) { struct qcom_glink *glink = smem->glink; + disable_irq(smem->irq); + qcom_glink_native_remove(glink); - qcom_glink_native_unregister(glink); + + device_unregister(&smem->dev); + + mbox_free_channel(smem->mbox_chan); } EXPORT_SYMBOL_GPL(qcom_glink_smem_unregister); From patchwork Mon Jan 9 22:40:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 41202 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2420021wrt; Mon, 9 Jan 2023 14:43:42 -0800 (PST) X-Google-Smtp-Source: AMrXdXtB72FYetSOJ0iLEnm70oy691ffhMBwAY/clrDTTqDUOO/tsKZ5YYrx4Yn7dOWzwNzqIWNv X-Received: by 2002:a05:6402:5d6:b0:467:8e69:ff10 with SMTP id n22-20020a05640205d600b004678e69ff10mr60488770edx.26.1673304222188; Mon, 09 Jan 2023 14:43:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673304222; cv=none; d=google.com; s=arc-20160816; b=w2Ffy54/hP8MBmSCt8NZ8G2f/kEV8SEKCR1YFNwMPm/zhZNaZLuR+nFoiUIc4D+sx1 L1aELSErYkPvNO6kuCsLXPHRv6Mq00cXrDtYSzDGFYcLAlyr4mpUWhmAmQNkyuuhVT9G 2fTq7CrRvJJrp+fKBnYi/Qzp+tFZeG0uB1c1bqhw8PgV0YmvQutg1PrNqUrntNmRxhUl bJ2el9V+Mub8Pu1mlgZ1De0nuMuU6H7GeAGXoIcTOMG7bX7ZTn3D2gXbaZI81slDyueg g3jfQ7mFtsmlNffr8mlGoqqMpb3yrlr335PiPl37367Qh3wjE8qMzcl03lZqwKYScb+m La0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Glrtv76v1bUv28bnY+eZovy/+aP3haJt+dyyflPqbj4=; b=jT8PyyDIMscnj+dYik1gWYsiAEfHbAmbp9WANHZHiGsn0L6J86Eyg4guEplVJEXrp8 ZChQf79r0YhRfrhb1aTsMWXTO2z7fheGKy+mCXomTr1DdTQdtCZU0VQzRpPXsrLzvxC2 3PMcpPXbK17BHZOLF+nzIc3FX2Hehdho3fLwRt/rqUxG4lLSPNpW4EJxG09xuFoT80k2 m1tFzgsjLuGQIj3X7ojnx8xDgkPi688aCjyR00w9Sj/TCoBctLenSumZ0/mKcHHGey8p d69pXPrCLewsWuR6EnJDUY/HcSDdy0+r8vceP3WyQsL/sAmVX0LJ0FlOReq9RYD5QgRw VD9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=lCtRi4+f; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h2-20020a056402280200b0047f9f11dab3si11683615ede.25.2023.01.09.14.43.16; Mon, 09 Jan 2023 14:43:42 -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=lCtRi4+f; 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 S237988AbjAIWkq (ORCPT + 99 others); Mon, 9 Jan 2023 17:40:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237876AbjAIWkO (ORCPT ); Mon, 9 Jan 2023 17:40:14 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1A3013DD2; Mon, 9 Jan 2023 14:40:13 -0800 (PST) Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 309LaGkU011502; Mon, 9 Jan 2023 22:40:10 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-transfer-encoding : content-type; s=qcppdkim1; bh=Glrtv76v1bUv28bnY+eZovy/+aP3haJt+dyyflPqbj4=; b=lCtRi4+f1azhFm3NYPuzOdrU2NgHeyxLxNmrCkMKXR1+bFu67su1ys4jnraIzYRAKoxc TaVKCIIFgXsMchmLDC/pUDtTcJ9OLwNaZxHzEGAaMWzGX3MIjflFPrSJ3ys6q/mKkJUm fyfAEDKCgRWi2GJHuEykeaTbt4A0Vr9SXkmASEhf8OfiRvRAQGx+AfTSLnE/zXRmUC0m tUlXlbimTeHhYMWk+j/IzIbc5vm5ooswfSx3bfVuYXiX2oScT9nSEAobB+DjIajAxY/4 9sO8b7A8NwK04TMxP1hSWvuCo4ea8f/GGvqNJ0bm/zue3sgeBECWYt1YjZsOW/UwQapm tg== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3my0u147fm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Jan 2023 22:40:09 +0000 Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 309Me88L027303 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 9 Jan 2023 22:40:08 GMT Received: from hu-bjorande-lv.qualcomm.com (10.49.16.6) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 9 Jan 2023 14:40:08 -0800 From: Bjorn Andersson To: Bjorn Andersson , Mathieu Poirier , Chris Lew CC: , , Subject: [PATCH 5/6] rpmsg: glink: Fail qcom_glink_tx() once remove has been initiated Date: Mon, 9 Jan 2023 14:40:00 -0800 Message-ID: <20230109224001.1706516-6-quic_bjorande@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230109224001.1706516-1-quic_bjorande@quicinc.com> References: <20230109224001.1706516-1-quic_bjorande@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: BFabGhtaB_nTNpYI2eFPRkM3WKEDJ2Rl X-Proofpoint-ORIG-GUID: BFabGhtaB_nTNpYI2eFPRkM3WKEDJ2Rl X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-09_14,2023-01-09_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 clxscore=1015 adultscore=0 malwarescore=0 lowpriorityscore=0 impostorscore=0 priorityscore=1501 phishscore=0 mlxscore=0 spamscore=0 mlxlogscore=808 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301090157 X-Spam-Status: No, score=1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_SBL_CSS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754586647818534227?= X-GMAIL-MSGID: =?utf-8?q?1754586647818534227?= Upon removing the glink edge communication is at best one-way. This means that the very common scenario of glink requesting intents will not be possible to serve. Typically a successful transmission results in the client waiting for a response, with some timeout and a mechanism for aborting that timeout. Because of this, once the glink edge is defunct once removal is commenced it's better to fail transmissions fast. Signed-off-by: Bjorn Andersson Reviewed-by: Chris Lew --- drivers/rpmsg/qcom_glink_native.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c index db5d946d5901..d81d0729493e 100644 --- a/drivers/rpmsg/qcom_glink_native.c +++ b/drivers/rpmsg/qcom_glink_native.c @@ -90,6 +90,7 @@ struct glink_core_rx_intent { * @intentless: flag to indicate that there is no intent * @tx_avail_notify: Waitqueue for pending tx tasks * @sent_read_notify: flag to check cmd sent or not + * @abort_tx: flag indicating that all tx attempts should fail */ struct qcom_glink { struct device *dev; @@ -111,6 +112,8 @@ struct qcom_glink { bool intentless; wait_queue_head_t tx_avail_notify; bool sent_read_notify; + + bool abort_tx; }; enum { @@ -326,12 +329,22 @@ static int qcom_glink_tx(struct qcom_glink *glink, spin_lock_irqsave(&glink->tx_lock, flags); + if (glink->abort_tx) { + ret = -EIO; + goto out; + } + while (qcom_glink_tx_avail(glink) < tlen) { if (!wait) { ret = -EAGAIN; goto out; } + if (glink->abort_tx) { + ret = -EIO; + goto out; + } + if (!glink->sent_read_notify) { glink->sent_read_notify = true; qcom_glink_send_read_notify(glink); @@ -1763,11 +1776,18 @@ static int qcom_glink_remove_device(struct device *dev, void *data) void qcom_glink_native_remove(struct qcom_glink *glink) { struct glink_channel *channel; + unsigned long flags; int cid; int ret; qcom_glink_cancel_rx_work(glink); + /* Fail all attempts at sending messages */ + spin_lock_irqsave(&glink->tx_lock, flags); + glink->abort_tx = true; + wake_up_all(&glink->tx_avail_notify); + spin_unlock_irqrestore(&glink->tx_lock, flags); + ret = device_for_each_child(glink->dev, NULL, qcom_glink_remove_device); if (ret) dev_warn(glink->dev, "Can't remove GLINK devices: %d\n", ret); From patchwork Mon Jan 9 22:40:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 41199 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2419843wrt; Mon, 9 Jan 2023 14:43:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXsANfSMv/LQ/5Q+gaQGTy7jFTSJz2EVl1VGs+aSINjCzgiqMW1cVghNiwY98jw38rJWyYCJ X-Received: by 2002:a05:6402:4506:b0:46d:35f6:5a9b with SMTP id ez6-20020a056402450600b0046d35f65a9bmr16714996edb.24.1673304197510; Mon, 09 Jan 2023 14:43:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673304197; cv=none; d=google.com; s=arc-20160816; b=soS4VhTNxu61bfcrCf7Ac1Z6A7zWPxzGMOyxZ+ruQwBo3+wI6do8x8JW7tEjx8Z4EY nwDzEorcygCZklrZbE204nLFBoDSuP5AL5Xw14XHM4wzkKrfTR9Ao2gsr7JUT4q+yNUr P5QwmiCyV8mTS4WEEzU7I3Is6gS89KDE7bNszA6iaIrCEc+wK9nw0uPal/EiMJ/ygeFX V60oBS5h17k9XghAMSvzPCvicNbtDJwOeR8j3gIbSi3wY3v2ZjDjpi7+7GPrbJr5FhKp D3l0gLsAcSfSpwAP5Wf5QJ12RSWQEKu1eV8Jp8k/CmU15loCv5zOCqt0Qf4V26VJJnrr HUdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BY0U/IfBBmjexzqkP5sEll4FvdKK3LgbuOw30SuZ9hE=; b=UtSGw+hHMAwOZqtxjtUvcfW58Fk7VvAArVAU+UjvWftqjdFePzX3NpVNwLPvwSI7Ky OhIeQcbjx275QSJ2DtFcyCs+hrUjMX6x4IQ1W6735/DymWTNOpPjBZRBFLMmBhQ0zksl Es1MYgyRH46RQNUsJAnH3wk9IBU/NzAIjxPx2ig7Hbo22zcaZQRig0p4T45rYlixFbDd BQWD/+LDoQtp8NIPtFdtVM25a65kFiQL6AP+T4IMCu+ZxqbXVtOTiTZCXAISFS91e1Cr but+90Q/wEnHGrXOscRuyRXvrlv2MAwX8+Z74ugkxin1GkOxKfzUDJGWNnOJzm4K7zgH yLlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=NZ9Qk5ar; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s18-20020a056402165200b0048f5c0d9c6fsi7027792edx.349.2023.01.09.14.42.54; Mon, 09 Jan 2023 14:43:17 -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=NZ9Qk5ar; 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 S237693AbjAIWk3 (ORCPT + 99 others); Mon, 9 Jan 2023 17:40:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237922AbjAIWkO (ORCPT ); Mon, 9 Jan 2023 17:40:14 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32F5F13FA6; Mon, 9 Jan 2023 14:40:14 -0800 (PST) Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 309Maet2015718; Mon, 9 Jan 2023 22:40:11 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-transfer-encoding : content-type; s=qcppdkim1; bh=BY0U/IfBBmjexzqkP5sEll4FvdKK3LgbuOw30SuZ9hE=; b=NZ9Qk5arFonnNXYATWjh6w5EirdQuiGHRPsCDeALkQiG2iOZ8i6s7QvlBtiphZbGbgOQ 9Aex3DpPfXHArYf7ZyV8wdFfCz/2prOi/CzcOHG3sW9uMxdEXmlZoDuQ6WnbFbMCKdeo 8MN8TWJQzFwpW81HrlSJDHVpxYjlI7aKpSCuq2MLlBW9gHP/BxCNEbWiainB6n8J0n/I 3diP69QomN7KxkUFHscheswdTx9eDLotIdL3F/nw/tWAvSSE+ammzDAqmJ7zZ74rMxKS mzmmNX2YZMSKdiEO0QKlFors35GURIEBEH2vxMtyVDT21TGZJt4a+yVRLJuNJn72qseO nQ== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3my1wu452d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Jan 2023 22:40:11 +0000 Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 309MeBbH003685 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 9 Jan 2023 22:40:11 GMT Received: from hu-bjorande-lv.qualcomm.com (10.49.16.6) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 9 Jan 2023 14:40:08 -0800 From: Bjorn Andersson To: Bjorn Andersson , Mathieu Poirier , Chris Lew CC: , , Subject: [PATCH 6/6] rpmsg: glink: Cancel pending intent requests at removal Date: Mon, 9 Jan 2023 14:40:01 -0800 Message-ID: <20230109224001.1706516-7-quic_bjorande@quicinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230109224001.1706516-1-quic_bjorande@quicinc.com> References: <20230109224001.1706516-1-quic_bjorande@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: OMw4aFvjcilatTXB6ds_brK0IJd9sMuF X-Proofpoint-GUID: OMw4aFvjcilatTXB6ds_brK0IJd9sMuF X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-09_14,2023-01-09_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=749 malwarescore=0 clxscore=1015 mlxscore=0 priorityscore=1501 impostorscore=0 spamscore=0 lowpriorityscore=0 phishscore=0 suspectscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301090157 X-Spam-Status: No, score=0.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754586621878655301?= X-GMAIL-MSGID: =?utf-8?q?1754586621878655301?= During removal of the glink edge interrupts are disabled and no more incoming messages are being serviced. In addition to the remote endpoint being defunct that means that any outstanding requests for intents will not be serviced, and qcom_glink_request_intent() will blindly wait for up to 10 seconds. Mark the intent request as not granted and complete the intent request completion to fail the waiting client immediately. Once the current intent request is failed, any potential clients waiting for the intent request mutex will not enter the same wait, as the qcom_glink_tx() call will fail fast. Signed-off-by: Bjorn Andersson Reviewed-by: Chris Lew --- drivers/rpmsg/qcom_glink_native.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c index d81d0729493e..bb14e7edeadc 100644 --- a/drivers/rpmsg/qcom_glink_native.c +++ b/drivers/rpmsg/qcom_glink_native.c @@ -423,6 +423,12 @@ static void qcom_glink_handle_intent_req_ack(struct qcom_glink *glink, complete(&channel->intent_req_comp); } +static void qcom_glink_intent_req_abort(struct glink_channel *channel) +{ + channel->intent_req_result = 0; + complete(&channel->intent_req_comp); +} + /** * qcom_glink_send_open_req() - send a RPM_CMD_OPEN request to the remote * @glink: Ptr to the glink edge @@ -1788,6 +1794,12 @@ void qcom_glink_native_remove(struct qcom_glink *glink) wake_up_all(&glink->tx_avail_notify); spin_unlock_irqrestore(&glink->tx_lock, flags); + /* Abort any senders waiting for intent requests */ + spin_lock_irqsave(&glink->idr_lock, flags); + idr_for_each_entry(&glink->lcids, channel, cid) + qcom_glink_intent_req_abort(channel); + spin_unlock_irqrestore(&glink->idr_lock, flags); + ret = device_for_each_child(glink->dev, NULL, qcom_glink_remove_device); if (ret) dev_warn(glink->dev, "Can't remove GLINK devices: %d\n", ret);