From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753208AbaHMNlN (ORCPT ); Wed, 13 Aug 2014 09:41:13 -0400 Received: from mail-ig0-f169.google.com ([209.85.213.169]:33730 "EHLO mail-ig0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750757AbaHMNlL (ORCPT ); Wed, 13 Aug 2014 09:41:11 -0400 MIME-Version: 1.0 X-Originating-IP: [89.139.17.117] In-Reply-To: <53EA3E78.6000304@ti.com> References: <1404420815-42108-1-git-send-email-s-anna@ti.com> <53EA3E78.6000304@ti.com> From: Ohad Ben-Cohen Date: Wed, 13 Aug 2014 16:40:50 +0300 Message-ID: Subject: Re: [PATCH] rpmsg: compute number of buffers to allocate from vrings To: Suman Anna Cc: Rusty Russell , "linux-kernel@vger.kernel.org" , "linux-omap@vger.kernel.org" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Suman, On Tue, Aug 12, 2014 at 7:19 PM, Suman Anna wrote: > Yes, I was playing around with using less buffers in the remoteproc > resource table for the vrings. The remoteproc virtio code creates the > vrings using the number of buffers based on .num field value of struct > fw_rsc_vdev_vring in the resource table. The virtio rpmsg probe code > though tries to set up the receive buffers for the same virtqueue based > on the current hard-coded value of 512 buffers and virtqueue_add_inbuf > would fail as the virtqueue is created with less number of buffers and > throws a WARN_ON. Gotcha - thanks for the details. Limiting the number of buffers in case the vrings are too small makes sense, but let's use RPMSG_NUM_BUFS as an upper bound, so wacky resource tables won't trigger unreasonable memory waste. Something in the lines of: vrp->num_bufs = min(PMSG_NUM_BUFS, virtqueue_get_vring_size(vrp->rvq) * 2); Should probably do the trick. Does this satisfy your requirement? Thanks, Ohad.