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: 2404901 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork2.kernel.org (Postfix) with ESMTP id B81AADF2A1 for ; Mon, 8 Apr 2013 02:38:15 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UOwgr-0008T7-6w; Sun, 07 Apr 2013 20:59:53 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UOp40-0000RD-9R; Sun, 07 Apr 2013 12:51:16 +0000 Received: from mail-lb0-f179.google.com ([209.85.217.179]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UOp3v-0000Qm-Ir for linux-arm-kernel@lists.infradead.org; Sun, 07 Apr 2013 12:51:12 +0000 Received: by mail-lb0-f179.google.com with SMTP id t1so4979746lbd.38 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=jvITTKSNTh1PPdM/PrmBlzsfbrVdFQygytd9nkDa/GKaZGpCTqcnfeZ7wdz0AQ8PBb Xae9d4yHvOH3P1XOt45v21sZgZ1klUluULvWDsRX6hkuBZxzVTAy7idUs6VBKX5KLamw ovpCOa8vC/LbpcvgAZCbueei2xkNrouRYRAPvuVgDaOV1jHk7zG11cnHymT0gq9cI7Hc WNGqHRsRonv/5pS3+R7n3/sd456YY6v+ADNLhk6pdZvczvk6FIA1i6wfJa7aBTGp/YRF yDa6J6CLMOLrqgPafyTEZBmCJhaF4/4A4FCP5XlZjGzGO54aWxs1w307/inCCKZnfdS8 9RnA== 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: ALoCoQmO0lSB8TQUvadbH1/TpYalhubcoDB78DoNgqnFwrgIm4MoaXRF66nPAAM9UoKVKcyeJdnu X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130407_085111_804356_6FB44375 X-CRM114-Status: GOOD ( 15.57 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.217.179 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: davinci-linux-open-source , "linux-doc@vger.kernel.org" , "Ring, Chris" , "Nori, Sekhar" , Rob Landley , "Grosen, Mark" , linux-arm X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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); }