Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4003709yba; Tue, 7 May 2019 10:28:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqx7UAZHFugE7wt8fufOqh6Cqe9D8bSKb98I3cVQJPYwbd9G70ORKhimkVjO6U8nFczKx+v2 X-Received: by 2002:a17:902:2d:: with SMTP id 42mr27138385pla.34.1557250129007; Tue, 07 May 2019 10:28:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557250129; cv=none; d=google.com; s=arc-20160816; b=MQzg7FeAXt2mkNmg2pvdob7EcIbmeDl2oE0mp6OnYb2oJxWktaqMNZYsBIYwpBgyqt hHu5Oj7RfkMCkPqM3ly1XDCZZSJXH926rWN3AR6RjUFGlhXC365O/E2a3s7P8y8OTf8W 1kzi/U0MJ5wG9F0WH/dKdUbRJsInXxU31WEV6d7VO1WmbZu0di0MXIvrPpH2epyRyVUJ f0WOJbZTHDofkILjw0LdDUaApzjmjDVfRCxwF9v125AwQuoC/nbKQSDzNJoz03YXfSpZ j+xVIZV/cE5vNgFHqKUx6iZDgSNPkBqWxZ5vEOgx7TewwW52fTPpyoyITB68lG0EM1AJ XOdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=2GznVx19aBlSBwrY4k/2U/6uFTPH38asKDdyd9v7fLM=; b=ikG9m//NJpeRmyrNjq9p5ZEP7HEG4u+OHV2uir4gi42v5Ode/vCFFZrPa8ES+KmNiS la6Uz0/U3raGws6BMJSvcNydWmU1YrrhiijSBzdSou2N7haMzSkIZ69nbwZdpRC9OH9L SgP4hgl9KGCy2VzOzAv/Faz9ApGaLrfIXaKyYbhfFMzX4tbDubMUkWHbFf1dP42FBfAM rjeBXfnRwYHq85dn28JGxWshLwJHsQgmTMrCAfqDodOU6uMycVDZ5c+2iuNnBtMoMgap PVASpesJhaOchNNBi2jszwl9vZfIPwSn8nu6kdETOc2JMH58WELjddcf4Y7Rs6L/09mT ulKA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e24si18150865pgv.555.2019.05.07.10.28.33; Tue, 07 May 2019 10:28:48 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727257AbfEGR1f (ORCPT + 99 others); Tue, 7 May 2019 13:27:35 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:40747 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726958AbfEGR1f (ORCPT ); Tue, 7 May 2019 13:27:35 -0400 Received: by mail-pl1-f195.google.com with SMTP id b3so8507644plr.7 for ; Tue, 07 May 2019 10:27:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=2GznVx19aBlSBwrY4k/2U/6uFTPH38asKDdyd9v7fLM=; b=FxXidNKmX148t8giKiuVZ0xyCPAZ9CauiqWZf39yRWId7G9pWYy1KWNHPHzmRaUQuz eg8EyGuePynECK6hA+Nc/Lmg8PYe0J96WBkBXzqj9s7KoNCkfrTVW0iEkauDvRRbTH2c TUhW+l/gH7Q8WYY2+6DscrMiw6mC8dKFswWUDpOZZBMWOVEtwVAlSQYNsa7j0D8Rg3L/ Qaa5748BpcCyhDYR3xTLr8fTdmPlAQ0nBE39jg/H0dcNlmGcJqy/Iaq3f9yRkJvGYc5B bRSL10fqQxiqBi16oQMtjqYD6A7vJGkvrGm894MkWlF0W8N9HJxDzLCMVF/XivqiT3u5 b3jA== X-Gm-Message-State: APjAAAXr2UqVLSxh1ZvsuPhoPbC6TZ9+MwdToNU4sxs42v6+7Vjte6Yp XwZ9L/McKpYjbKJUv41sSBpESg== X-Received: by 2002:a17:902:100a:: with SMTP id b10mr36618902pla.239.1557250054263; Tue, 07 May 2019 10:27:34 -0700 (PDT) Received: from localhost ([2601:647:4700:2953:ec49:968:583:9f8]) by smtp.gmail.com with ESMTPSA id y3sm22725826pge.7.2019.05.07.10.27.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 May 2019 10:27:33 -0700 (PDT) Date: Tue, 7 May 2019 10:27:32 -0700 From: Moritz Fischer To: Wu Hao Cc: atull@kernel.org, mdf@kernel.org, linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Xu Yilun Subject: Re: [PATCH v2 03/18] fpga: dfl: fme: align PR buffer size per PR datawidth Message-ID: <20190507172732.GB26690@archbox> References: <1556528151-17221-1-git-send-email-hao.wu@intel.com> <1556528151-17221-4-git-send-email-hao.wu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1556528151-17221-4-git-send-email-hao.wu@intel.com> User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 29, 2019 at 04:55:36PM +0800, Wu Hao wrote: > Current driver checks if input bitstream file size is aligned or > not per PR data width (default 32bits). It requires one additional > step for end user when they generate the bitstream file, padding > extra zeros to bitstream file to align its size per PR data width, > but they don't have to as hardware will drop extra padding bytes > automatically. > > In order to simplify the user steps, this patch aligns PR buffer > size per PR data width in driver, to allow user to pass unaligned > size bitstream files to driver. > > Signed-off-by: Xu Yilun > Signed-off-by: Wu Hao > Acked-by: Alan Tull Acked-by: Moritz Fischer > --- > drivers/fpga/dfl-fme-pr.c | 14 +++++++++----- > 1 file changed, 9 insertions(+), 5 deletions(-) > > diff --git a/drivers/fpga/dfl-fme-pr.c b/drivers/fpga/dfl-fme-pr.c > index 6ec0f09..3c71dc3 100644 > --- a/drivers/fpga/dfl-fme-pr.c > +++ b/drivers/fpga/dfl-fme-pr.c > @@ -74,6 +74,7 @@ static int fme_pr(struct platform_device *pdev, unsigned long arg) > struct dfl_fme *fme; > unsigned long minsz; > void *buf = NULL; > + size_t length; > int ret = 0; > u64 v; > > @@ -85,9 +86,6 @@ static int fme_pr(struct platform_device *pdev, unsigned long arg) > if (port_pr.argsz < minsz || port_pr.flags) > return -EINVAL; > > - if (!IS_ALIGNED(port_pr.buffer_size, 4)) > - return -EINVAL; > - > /* get fme header region */ > fme_hdr = dfl_get_feature_ioaddr_by_id(&pdev->dev, > FME_FEATURE_ID_HEADER); > @@ -103,7 +101,13 @@ static int fme_pr(struct platform_device *pdev, unsigned long arg) > port_pr.buffer_size)) > return -EFAULT; > > - buf = vmalloc(port_pr.buffer_size); > + /* > + * align PR buffer per PR bandwidth, as HW ignores the extra padding > + * data automatically. > + */ > + length = ALIGN(port_pr.buffer_size, 4); > + > + buf = vmalloc(length); > if (!buf) > return -ENOMEM; > > @@ -140,7 +144,7 @@ static int fme_pr(struct platform_device *pdev, unsigned long arg) > fpga_image_info_free(region->info); > > info->buf = buf; > - info->count = port_pr.buffer_size; > + info->count = length; > info->region_id = port_pr.port_id; > region->info = info; > > -- > 1.8.3.1 >