Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2298878iof; Wed, 8 Jun 2022 01:49:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/oyptB0xGV+rGx6fsyGn37+RYJCwG+V2yJ6LmUFHIdjRluNLTIHJJeLREDdwI+3+//e1s X-Received: by 2002:a05:6a00:1513:b0:51c:3ca8:47a4 with SMTP id q19-20020a056a00151300b0051c3ca847a4mr7306837pfu.48.1654678190629; Wed, 08 Jun 2022 01:49:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654678190; cv=none; d=google.com; s=arc-20160816; b=yJGmrYstB+imgWM1TMsgoqoQYScyV8vu7nd5H4hRkLhcZtgdt+Cspb/vD5aBoA6je/ y20Y+Q3T4Ap4HXIO6AYF4+NwmLhgMFxtPYlSaTsAoYkap0rMkHfjTo8a1aQvP95lkgD/ P5OsuActRkNXt9fXaHRHsx7QjDTgiohkUhLR3DiAEdMjVpXjks79XqD+8WkgYpiC15Zv V5J0RJEh5gSI9wAa7pV4D9oYuIgOgKQYHbYXgHVOyf3xtsCR5d/eW8DL8bAuQRHLuQvX xBuVWWivyy0+Gx9JRBzfm40uYCZ65yftWRzPTCtVWaGyof1rEijFYZInWB7D+GU4KGM4 Z/xg== 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=HS2tVe61KzrUqms7DIAgt9EyNPA+XwdzGMJ9STg48/k=; b=AhsS9CaF3lblybMzGK9F7gvZzIIiMt7Mk3Ao4xJNpFf4PYY2tvZwZUIgsKgImFwK+q QWAf14RiVsG3eD3G+g3MJG5hW4CCbDQx05yJVoRYvb0zUXH0aY+aYmhKjwacgWSyVx/C Mi+1UevwR5yb8txpYA9GXjs0fJxQYNMnIHYUS3pIbYVBk2ZwQ/T5wHVHg4mkRpb8o+0w OcPqFi6g6TOgus7YB5z1EN/wfBn6bjvXDsT0uFSWHhDkCMWy6cIQOmZ4bwInwQOp8m/+ IeH4i1DSpsyp7ZJNcm4XNdm4IMK2uJjzNteDBTOqpfsnAABtS+JMYrhbZeXpNkWvPwbi 5QvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=xkjKm1PU; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id v22-20020a636116000000b003fcffa687efsi23477672pgb.242.2022.06.08.01.49.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 01:49:50 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=xkjKm1PU; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B19EE39A3E2; Wed, 8 Jun 2022 01:13:06 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231759AbiFHEwr (ORCPT + 99 others); Wed, 8 Jun 2022 00:52:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231495AbiFHEvv (ORCPT ); Wed, 8 Jun 2022 00:51:51 -0400 Received: from alexa-out-sd-01.qualcomm.com (alexa-out-sd-01.qualcomm.com [199.106.114.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8394262E1A; Tue, 7 Jun 2022 18:17:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1654651044; x=1686187044; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=HS2tVe61KzrUqms7DIAgt9EyNPA+XwdzGMJ9STg48/k=; b=xkjKm1PU8/e7H+lq9+VpOCWj2t/BX5f/26b8/sA7nLsX1/kdRVLX7RhN XInOcAd2LnRbewzALWePTN55YgaJSMFWI2ALotdxBpRAjAs1pyTcGcZ2s KD2pq3I362xLtzFjc5fGVF0ioYFcxX/CVn+fNK8IL1r6WF7D+LdnQa1A/ k=; Received: from unknown (HELO ironmsg01-sd.qualcomm.com) ([10.53.140.141]) by alexa-out-sd-01.qualcomm.com with ESMTP; 07 Jun 2022 18:17:20 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg01-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jun 2022 18:17:20 -0700 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Tue, 7 Jun 2022 18:17:20 -0700 Received: from hu-clew-lv.qualcomm.com (10.49.16.6) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Tue, 7 Jun 2022 18:17:19 -0700 From: Chris Lew To: , CC: , , , Subject: [PATCH 3/4] rpmsg: glink: Try to send rx done in irq Date: Tue, 7 Jun 2022 18:16:44 -0700 Message-ID: <1654651005-15475-4-git-send-email-quic_clew@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1654651005-15475-1-git-send-email-quic_clew@quicinc.com> References: <1654651005-15475-1-git-send-email-quic_clew@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nalasex01a.na.qualcomm.com (10.47.209.196) X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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 Some remote processors and usecases such as audio playback are sensitive to the response time of rx done. Try to send the rx done cmd from irq context. If trysend fails, defer the rx done work like before. Signed-off-by: Chris Lew --- drivers/rpmsg/qcom_glink_native.c | 60 ++++++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c index 07586514991f..799e602113a1 100644 --- a/drivers/rpmsg/qcom_glink_native.c +++ b/drivers/rpmsg/qcom_glink_native.c @@ -497,12 +497,11 @@ static void qcom_glink_send_close_ack(struct qcom_glink *glink, qcom_glink_tx(glink, &req, sizeof(req), NULL, 0, true); } -static void qcom_glink_rx_done_work(struct work_struct *work) +static int qcom_glink_send_rx_done(struct qcom_glink *glink, + struct glink_channel *channel, + struct glink_core_rx_intent *intent, + bool wait) { - struct glink_channel *channel = container_of(work, struct glink_channel, - intent_work); - struct qcom_glink *glink = channel->glink; - struct glink_core_rx_intent *intent, *tmp; struct { u16 id; u16 lcid; @@ -510,26 +509,41 @@ static void qcom_glink_rx_done_work(struct work_struct *work) } __packed cmd; unsigned int cid = channel->lcid; - unsigned int iid; - bool reuse; + unsigned int iid = intent->id; + bool reuse = intent->reuse; + int ret; + + cmd.id = reuse ? RPM_CMD_RX_DONE_W_REUSE : RPM_CMD_RX_DONE; + cmd.lcid = cid; + cmd.liid = iid; + + ret = qcom_glink_tx(glink, &cmd, sizeof(cmd), NULL, 0, wait); + if (ret) + return ret; + + if (!reuse) { + kfree(intent->data); + kfree(intent); + } + + return 0; +} + +static void qcom_glink_rx_done_work(struct work_struct *work) +{ + struct glink_channel *channel = container_of(work, struct glink_channel, + intent_work); + struct qcom_glink *glink = channel->glink; + struct glink_core_rx_intent *intent, *tmp; unsigned long flags; spin_lock_irqsave(&channel->intent_lock, flags); list_for_each_entry_safe(intent, tmp, &channel->done_intents, node) { list_del(&intent->node); spin_unlock_irqrestore(&channel->intent_lock, flags); - iid = intent->id; - reuse = intent->reuse; - cmd.id = reuse ? RPM_CMD_RX_DONE_W_REUSE : RPM_CMD_RX_DONE; - cmd.lcid = cid; - cmd.liid = iid; + qcom_glink_send_rx_done(glink, channel, intent, true); - qcom_glink_tx(glink, &cmd, sizeof(cmd), NULL, 0, true); - if (!reuse) { - kfree(intent->data); - kfree(intent); - } spin_lock_irqsave(&channel->intent_lock, flags); } spin_unlock_irqrestore(&channel->intent_lock, flags); @@ -539,6 +553,8 @@ static void qcom_glink_rx_done(struct qcom_glink *glink, struct glink_channel *channel, struct glink_core_rx_intent *intent) { + int ret = -EAGAIN; + /* We don't send RX_DONE to intentless systems */ if (glink->intentless) { kfree(intent->data); @@ -555,10 +571,14 @@ static void qcom_glink_rx_done(struct qcom_glink *glink, /* Schedule the sending of a rx_done indication */ spin_lock(&channel->intent_lock); - list_add_tail(&intent->node, &channel->done_intents); - spin_unlock(&channel->intent_lock); + if (list_empty(&channel->done_intents)) + ret = qcom_glink_send_rx_done(glink, channel, intent, false); - schedule_work(&channel->intent_work); + if (ret) { + list_add_tail(&intent->node, &channel->done_intents); + schedule_work(&channel->intent_work); + } + spin_unlock(&channel->intent_lock); } /** -- 2.7.4