From patchwork Tue Feb 13 19:04:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 128290 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp4569830ljc; Tue, 13 Feb 2018 11:09:35 -0800 (PST) X-Google-Smtp-Source: AH8x2274yphNQ35qwIjK+CycTBP0//gEcEOeMeH0SGvInx/0YqHa4nYjbsq5EW8g/z1GUbg7KK6d X-Received: by 10.101.80.69 with SMTP id k5mr1793351pgo.431.1518548975097; Tue, 13 Feb 2018 11:09:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518548975; cv=none; d=google.com; s=arc-20160816; b=RYct0yu+1TkzUxpjnCjBcC8qk0HLJykDpE0ZYQEJMOzSmRcbN9l4sRf4oG6QYCRt52 NbBTCbVIgdcl51qiQP7f+yEpUilKzQ5TLSqnKNGGPOvWfTxpN8aAjwDaj23e0n5qvOP7 YU3TXdn1doHaPXILWyjLTag9CRQ1OZPz46BGEewDwAz+2VNafg6OlHeJQNoFweEOVioB BpXuUQ1noZS8dCZnq7ZGG2r5osNs1rUBcXwPNQeyScGI1UOexS68ABn98umsqTWF7xTK kzmqEtRYYceh4p/9rHFrHFr0Ge+HPBoGPPXnZ1AldLlna+rzRgyXWBNR/f5jtLxgy/r+ RGXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=si0AWi6+PCh4G615+EENacNhnhmLnZx1A7pjfUV4L94=; b=ph6Z8GS+Dg8r9qvM8K8h3wiRB31iyBudcen5hNKPNyZuGzUJPoVGA/NWKYlO9rl7S/ UFT49I8aDOO97CuBfYFFzTvKre9X8nTfB+VuQ30Bfbv3NmT0lnZ3k9qjFPdFdoFTYiM7 uor4UrRbtco0D4zmcrUu7nWoagpKz6hR1VUZRxSueguhZRXUmC9aI0hxx3MIOVvzssfY 7Jrw5k3Sx06Ff6r/ycdGLKIYON6VJXXrTzzlFwMt10sUgSHVj6a9WuzhvP1EoGmXF4x6 9Z7npzFQ3KW3jyw2lwvZBb7+dIaAnpa2KLD4SeCEwbnnDWxrmUp9xT2Fy3dsNw6K+ZKY IVNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=hUcgmbzA; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p3-v6si6195976pld.86.2018.02.13.11.09.34; Tue, 13 Feb 2018 11:09:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=hUcgmbzA; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753011AbeBMTJd (ORCPT + 10 others); Tue, 13 Feb 2018 14:09:33 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:36752 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752400AbeBMTJc (ORCPT ); Tue, 13 Feb 2018 14:09:32 -0500 Received: by mail-pg0-f67.google.com with SMTP id j9so522936pgv.3 for ; Tue, 13 Feb 2018 11:09:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=O8xXWGRRalWR9ldNKooYC7fkxNzO24HiEhMCBis1piA=; b=hUcgmbzAoZ5iozzHdkLdzRyvk378Evlu2k8WUjcXI1CcqwFK7XsuzpxND+zxXxMsqU d2G2AYAssFVhmK8zRSQ7iIoQs5KY1MfsQeiukFYWO3NhTEosLyPhY6ulvK4Idyoq39Qw BiBtqnZrLuRohfzGB5Ad4MzrdIi21hegJoVgU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=O8xXWGRRalWR9ldNKooYC7fkxNzO24HiEhMCBis1piA=; b=jOfA+Uh7POPCQ/SKRHoxFsS390P70OeTJi6f7OaLkRyXMP20/2PNvbGhUQfgDsDngd cfP89IwIOQDXsrCbPplP/KZvWFWqzIT2U8CkyAW/MKVT1JYPLGu/j6PagWb/CY3thTuV uULXvdCwLuWHgrcot71BoXZpEZO8Wg5BCEmrvf8g/kayS71QjN5tRX9KWoicwXbDBA9G YAYSrT0xsT5V4Id26JNtLoCAjv/j/KlcSAqOx3fBM3vLHEmKCOu8tNvNiY1F5B3eSjId QrwS7c2nSIfHW6PjoOVtpDXvBUT/yf0qGwGF7nPKCmA6uNjjKxClSvFTZh/WQAxafY9y FirQ== X-Gm-Message-State: APf1xPCn0ncNODLCoCZVj6MqGGcvkDBbifXWAws+z/9L7dxTAPBMHee0 Jzg5s3/E9eJC+N3p07zvZPP6EA== X-Received: by 10.167.129.195 with SMTP id c3mr2020270pfn.14.1518548647712; Tue, 13 Feb 2018 11:04:07 -0800 (PST) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id y4sm15478765pfm.16.2018.02.13.11.04.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Feb 2018 11:04:06 -0800 (PST) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson , Chris Lew , Arun Kumar Neelakantam , Srini Kandagatla Cc: linux-remoteproc@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] rpmsg: glink: Use spinlock in tx path Date: Tue, 13 Feb 2018 11:04:04 -0800 Message-Id: <20180213190404.25026-1-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.15.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Switch the tx_lock to a spinlock we allow clients to use rpmsg_trysend() from atomic context. In order to allow clients to sleep while waiting for space in the FIFO we release the lock temporarily around the delay; which should be replaced by sending a READ_NOTIF and waiting for the remote to signal us that space has been made available. Signed-off-by: Bjorn Andersson --- drivers/rpmsg/qcom_glink_native.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) -- 2.15.0 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Tested-by: Srinivas kandagatla diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c index e0f31ed096a5..6e950e9afa82 100644 --- a/drivers/rpmsg/qcom_glink_native.c +++ b/drivers/rpmsg/qcom_glink_native.c @@ -113,7 +113,7 @@ struct qcom_glink { spinlock_t rx_lock; struct list_head rx_queue; - struct mutex tx_lock; + spinlock_t tx_lock; spinlock_t idr_lock; struct idr lcids; @@ -288,15 +288,14 @@ static int qcom_glink_tx(struct qcom_glink *glink, const void *data, size_t dlen, bool wait) { unsigned int tlen = hlen + dlen; + unsigned long flags; int ret; /* Reject packets that are too big */ if (tlen >= glink->tx_pipe->length) return -EINVAL; - ret = mutex_lock_interruptible(&glink->tx_lock); - if (ret) - return ret; + spin_lock_irqsave(&glink->tx_lock, flags); while (qcom_glink_tx_avail(glink) < tlen) { if (!wait) { @@ -304,7 +303,12 @@ static int qcom_glink_tx(struct qcom_glink *glink, goto out; } + /* Wait without holding the tx_lock */ + spin_unlock_irqrestore(&glink->tx_lock, flags); + usleep_range(10000, 15000); + + spin_lock_irqsave(&glink->tx_lock, flags); } qcom_glink_tx_write(glink, hdr, hlen, data, dlen); @@ -313,7 +317,7 @@ static int qcom_glink_tx(struct qcom_glink *glink, mbox_client_txdone(glink->mbox_chan, 0); out: - mutex_unlock(&glink->tx_lock); + spin_unlock_irqrestore(&glink->tx_lock, flags); return ret; } @@ -1567,7 +1571,7 @@ struct qcom_glink *qcom_glink_native_probe(struct device *dev, glink->features = features; glink->intentless = intentless; - mutex_init(&glink->tx_lock); + spin_lock_init(&glink->tx_lock); spin_lock_init(&glink->rx_lock); INIT_LIST_HEAD(&glink->rx_queue); INIT_WORK(&glink->rx_work, qcom_glink_work);