From patchwork Sun Apr 7 12:50:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ohad Ben Cohen X-Patchwork-Id: 2403011 Return-Path: X-Original-To: patchwork-davinci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from bear.ext.ti.com (bear.ext.ti.com [192.94.94.41]) by patchwork1.kernel.org (Postfix) with ESMTP id 037503FC71 for ; Sun, 7 Apr 2013 12:55:30 +0000 (UTC) Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id r37CpAlI028366; Sun, 7 Apr 2013 07:51:10 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id r37CpA2M007229; Sun, 7 Apr 2013 07:51:10 -0500 Received: from dlelxv24.itg.ti.com (172.17.1.199) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.2.342.3; Sun, 7 Apr 2013 07:51:10 -0500 Received: from linux.omap.com (dlelxs01.itg.ti.com [157.170.227.31]) by dlelxv24.itg.ti.com (8.13.8/8.13.8) with ESMTP id r37CpAKO011078; Sun, 7 Apr 2013 07:51:10 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 67A2380627; Sun, 7 Apr 2013 07:51:10 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp52.itg.ti.com (dflp52.itg.ti.com [128.247.22.96]) by linux.omap.com (Postfix) with ESMTP id D523380626 for ; Sun, 7 Apr 2013 07:51:08 -0500 (CDT) Received: from medina.ext.ti.com (medina.ext.ti.com [192.91.81.31]) by dflp52.itg.ti.com (8.13.7/8.13.8) with ESMTP id r37Cp8WW024313 for ; Sun, 7 Apr 2013 07:51:08 -0500 (CDT) Received: from mail6.bemta8.messagelabs.com (mail6.bemta8.messagelabs.com [216.82.243.55]) by medina.ext.ti.com (8.13.7/8.13.7) with ESMTP id r37Cp8o1013198 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 7 Apr 2013 07:51:08 -0500 Received: from [216.82.242.147:19809] by server-15.bemta-8.messagelabs.com id 6A/41-20337-BBB61615; Sun, 07 Apr 2013 12:51:07 +0000 X-Env-Sender: ohad@wizery.com X-Msg-Ref: server-16.tower-95.messagelabs.com!1365339065!21529781!1 X-Originating-IP: [209.85.215.51] X-SpamReason: No, hits=0.3 required=7.0 tests=RCVD_BY_IP X-StarScan-Received: X-StarScan-Version: 6.8.6.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 2972 invoked from network); 7 Apr 2013 12:51:07 -0000 Received: from mail-la0-f51.google.com (HELO mail-la0-f51.google.com) (209.85.215.51) by server-16.tower-95.messagelabs.com with RC4-SHA encrypted SMTP; 7 Apr 2013 12:51:07 -0000 Received: by mail-la0-f51.google.com with SMTP id fo13so4648895lab.10 for ; Sun, 07 Apr 2013 05:51:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-originating-ip:in-reply-to:references :from:date:message-id:subject:to:cc:content-type:x-gm-message-state; bh=eKXGaXWxbBYrYIEreeCeHc3VdUvYaOm3bKw+gGRjkRY=; b=E/NXqTVWXch0CVbo+NQJSlSRBAIVcpW3ASm5Zz7RqrlUzqVxnMN/96N5GrH+Q3OuQX kAIA1SP/A95lUROY3HbcvIz+m+nqu/KttAP4vEUd6HKDMhMZ1F+Pv3wJsWQyyl3e+YTp cSLnE0EQ+28lYLCyc9zw3Ttoxg9ci3++TPKcGrr4YETVkWp4Kjs0nxg95HVBwgsZXUHQ 3hYhh0RJqIhUelZL85pZ22ESXytp+7J69cF+58GEIBBw4E50ki4Q7so7CdMmTGVRRFQt oNdRJTj8IgDeN/LgTGGOBkcW3ahb4QEuINg+vW2u2OGTMGwJL6Jy5V6KZy++5wUDBO2a a6tA== X-Received: by 10.112.28.4 with SMTP id x4mr9768680lbg.33.1365339065406; Sun, 07 Apr 2013 05:51:05 -0700 (PDT) MIME-Version: 1.0 Received: by 10.112.100.39 with HTTP; Sun, 7 Apr 2013 05:50:45 -0700 (PDT) X-Originating-IP: [93.172.123.88] In-Reply-To: <1364521307-1219-2-git-send-email-rtivy@ti.com> References: <1364521307-1219-1-git-send-email-rtivy@ti.com> <1364521307-1219-2-git-send-email-rtivy@ti.com> From: Ohad Ben-Cohen Date: Sun, 7 Apr 2013 15:50:45 +0300 Message-ID: Subject: Re: [PATCH v9 1/6] rpmsg: Process all available messages in virtqueue callback To: Robert Tivy X-Gm-Message-State: ALoCoQl8SyupYkLPTh6NQy3kkvlHtLgplMnHgRNjpR33CxuMdX9F5R0T05jaSVP6UwLgSMZLwBZf CC: davinci-linux-open-source , "linux-doc@vger.kernel.org" , Rob Landley , linux-arm X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com On Fri, Mar 29, 2013 at 4:41 AM, Robert Tivy wrote: > Change virtqueue callback function rpmsg_recv_done() to process all > available messages instead of just one message. > > Signed-off-by: Robert Tivy I'm thinking instead of adding an indentation level, let's split the _recv function. This is what I have in mind - let me know if it works for you - thanks: diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c index a59684b..42b9872 100644 --- a/drivers/rpmsg/virtio_rpmsg_bus.c +++ b/drivers/rpmsg/virtio_rpmsg_bus.c @@ -776,22 +776,11 @@ out: } EXPORT_SYMBOL(rpmsg_send_offchannel_raw); -/* called when an rx buffer is used, and it's time to digest a message */ -static void rpmsg_recv_done(struct virtqueue *rvq) +static int rpmsg_recv_single(struct virtproc_info *vrp, struct device *dev, + struct rpmsg_hdr *msg, unsigned int len) { - struct rpmsg_hdr *msg; - unsigned int len; struct rpmsg_endpoint *ept; struct scatterlist sg; - struct virtproc_info *vrp = rvq->vdev->priv; - struct device *dev = &rvq->vdev->dev; - int err; - - msg = virtqueue_get_buf(rvq, &len); - if (!msg) { - dev_err(dev, "uhm, incoming signal, but no used buffer ?\n"); - return; - } dev_dbg(dev, "From: 0x%x, To: 0x%x, Len: %d, Flags: %d, Reserved: %d\n", msg->src, msg->dst, msg->len, @@ -806,7 +795,7 @@ static void rpmsg_recv_done(struct virtqueue *rvq) if (len > RPMSG_BUF_SIZE || msg->len > (len - sizeof(struct rpmsg_hdr))) { dev_warn(dev, "inbound msg too big: (%d, %d)\n", len, msg->len); - return; + return -EINVAL; } /* use the dst addr to fetch the callback of the appropriate user */ @@ -842,9 +831,39 @@ static void rpmsg_recv_done(struct virtqueue *rvq) err = virtqueue_add_buf(vrp->rvq, &sg, 0, 1, msg, GFP_KERNEL); if (err < 0) { dev_err(dev, "failed to add a virtqueue buffer: %d\n", err); + return err; + } + + return 0; +} + +/* called when an rx buffer is used, and it's time to digest a message */ +static void rpmsg_recv_done(struct virtqueue *rvq) +{ + struct virtproc_info *vrp = rvq->vdev->priv; + struct device *dev = &rvq->vdev->dev; + struct rpmsg_hdr *msg; + unsigned int len, msgs_received = 0; + int err; + + msg = virtqueue_get_buf(rvq, &len); + if (!msg) { + dev_err(dev, "uhm, incoming signal, but no used buffer ?\n"); return; } + while (msg) { + err = rpmsg_recv_single(vrp, dev, msg, len); + if (err) + break; + + msgs_received++; + + msg = virtqueue_get_buf(rvq, &len); + }; + + dev_dbg(dev, "Received %u messages\n", msgs_received); + /* tell the remote processor we added another available rx buffer */ virtqueue_kick(vrp->rvq); }