Received: by 10.213.65.68 with SMTP id h4csp52267imn; Mon, 19 Mar 2018 19:16:14 -0700 (PDT) X-Google-Smtp-Source: AG47ELsQy+EEWjP0ChNjhqjgA4SdkeYonizcH/L684/II8aE88V+V9+KdKsOBSQy1m2AGQxvqaE8 X-Received: by 10.98.82.144 with SMTP id g138mr11956772pfb.239.1521512174176; Mon, 19 Mar 2018 19:16:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521512174; cv=none; d=google.com; s=arc-20160816; b=U+2ZtVfv0YtxGO5WAOIV94gyIrI68T6w/WGVz0cWzwDtWRW64fZrriq+OVI/S/aopO RaQhbEB5r4M2ijtBVJ35xno6X5e94o/UUuj9VwVhZFt2yvgfkC+pCFzAUpECJSujkK4E 3LKBjHju+QSELhDYu3G/Uw86h5Z1wkJbU9xQeZuTK/XJ+zOJfDXSxqhMSHBQhESLCEZp 2q3fSdCrKpS2DGnND8m6S3T7RpcXlW2PhjUy5t64Zmw4fxADLOlI+wG561UPHAxQKSlR 741a9LJ1RCEm8ZLK4LZhHGDbZoXZ9KBNq2uYfXp8rkcOOqwAe0RhQxkAHlM7WmmwSkj1 RT6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=WJEYCdbNnrT9R6Zwgntm6HImeXf9+dCP+cC2NIlm9Bg=; b=cO+uP6B1KqZmtA6VDlUhkRPjxBNTXYwxzuZG5pWFx2SOjSCUMwlcti4yKpZBaVSP7J IGwsPS+S3tQKDNm14fy158Xevt5Hkol33ayiWEvcupTEJSlFDi73IJa5FTVnufCrBwKn o/za/X5CJFJaY4NN18K8TQRnbv4py7UgiJMY45VRiBDuQ7Uq33tbR1vR237PDNk0MAJv 5ZOlNHERYVDkzy8LIul8iB4OZzSs59e+R0mzgQfZ5WCGYgXp+dXooHEyayFTpRgI8G+N 5I6rr15MNNkEqqyCQjSV/X7PvwldHLyZXAYHs4V2MtPeLAG8gHpFn72DIzSPH2WXkAs2 t4MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gBp6NJMm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (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 b17si499514pfd.155.2018.03.19.19.16.00; Mon, 19 Mar 2018 19:16:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gBp6NJMm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751774AbeCTCOv (ORCPT + 99 others); Mon, 19 Mar 2018 22:14:51 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:38466 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751699AbeCTCOk (ORCPT ); Mon, 19 Mar 2018 22:14:40 -0400 Received: by mail-pl0-f67.google.com with SMTP id m22-v6so77241pls.5 for ; Mon, 19 Mar 2018 19:14:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=WJEYCdbNnrT9R6Zwgntm6HImeXf9+dCP+cC2NIlm9Bg=; b=gBp6NJMm0T7Re77RGcciuxCw1FPRDhNWSqk/82Aq72ZhQ5c5BAO5yEX7zTfE9bWIWE 5hcVQEG2RRS9EFBoF/KJsHW3XF3cnbSX36H0+uJ8RC23hyclp08864b9GQ7qjtGxXvu4 J1ZhxgIti04C1TxGM3nub3k69GxZ7qubdTx+s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=WJEYCdbNnrT9R6Zwgntm6HImeXf9+dCP+cC2NIlm9Bg=; b=PelE84XskIqHw3Msv/I29T6SlOsD9m/yqdimOLf83Gv5YEtTdRZ6KuMSqqC/FvcEqh IItxblDLkvmqU4gQBKwG2o5EAltex5YGTY8ZwYv50JiMU58uMtx1oMCC/C4Gr4e1ZcFE 9q+FlMgVP38OkloDZ01bUnlrFN9nl/xQ4E35UGpkVBysW10HV2rALCjQt0TGLr3OygqJ suw1LoLlGG735guiBHIQdfe9Fzh7814lvm6Whtk3ZWq0pmONL9YTUv4I61wwD6GdfG4U UqfOV24kC/QZdElmt5a7ZfPRMXTAQpZZAc11TMMeJULXalAlaumvLW7WW86dTHasUZe9 zrdA== X-Gm-Message-State: AElRT7H1grm5EoMQuwWyYJeXYRYPCs28xy6xk57we4lKi9YcqYisRXgk iOczV6dMtebsbC51s7sxWsbbv+lwZKw= X-Received: by 2002:a17:902:20ca:: with SMTP id v10-v6mr15007997plg.9.1521512079960; Mon, 19 Mar 2018 19:14:39 -0700 (PDT) Received: from [172.16.64.21] ([218.255.99.6]) by smtp.googlemail.com with ESMTPSA id a5sm643373pfn.66.2018.03.19.19.14.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Mar 2018 19:14:39 -0700 (PDT) Subject: Re: [PATCH] rpmsg: glink: Use spinlock in tx path To: Bjorn Andersson , Ohad Ben-Cohen , Chris Lew , Arun Kumar Neelakantam Cc: linux-remoteproc@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20180213190404.25026-1-bjorn.andersson@linaro.org> From: Srinivas Kandagatla Message-ID: <572c1691-cb6d-773b-a9e9-19ad1da079a5@linaro.org> Date: Tue, 20 Mar 2018 10:14:36 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20180213190404.25026-1-bjorn.andersson@linaro.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 14/02/18 03:04, Bjorn Andersson wrote: > 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 > --- with ret set to 0 in qcom_glink_tx() Tested-by: Srinivas kandagatla > drivers/rpmsg/qcom_glink_native.c | 16 ++++++++++------ > 1 file changed, 10 insertions(+), 6 deletions(-) > > 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); >