Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3466397img; Mon, 25 Mar 2019 10:52:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqyYLxvT7gR3hqBAq1arJrSShwDeDRHYVeKom3XAD72YZkftUUlpQWzs33NakL8mlryHwRnw X-Received: by 2002:a63:6ac1:: with SMTP id f184mr5323997pgc.25.1553536330959; Mon, 25 Mar 2019 10:52:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553536330; cv=none; d=google.com; s=arc-20160816; b=VulkZl60PNkBqnUzN4UgBSe031qqSfQ7XS6pMvULtiiia+wurnW2RXzDYa63l9DUqN hF7A+IwpmdQQT5lU62cubxjenNvASg6d8NhksAc1+LaxrKJwRNzvwoFao38/InPYb2nH ZUhPAxyalfjix3uGZFXMT86HsEmJdCd6zQtnVT2DgBL1PjBRF3HAjyRBgFwHBqrUhZ4/ 37XxHNpoVX67YWBDHbzM1jeStFxPCQNe6q++WWAf5K7c14cp/T0wX53otfXkmR7vFENU vFPcaQLU1frbcX3s6oFjf87BGHkzYqs9tPXkrWM6jYJnLIHNx3YO+jN+UVHmOkh+tbQ+ Ih5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=0Wi6j5OhkZIdGLeFio6wmuOGmYbNCvoZcPWAy9VW6hY=; b=EPka7Ft3rq+6mupeeHnfk5Zr/IypwXyyf1BdnWpopnaCmXEwLl6RrbD9PHqy0rMXMY Vlxn16r7SmwmiyHZsuA+TP0gGNPg223AF3qx5YZX4s1tXJlt9BYjvKoK1a5kCkGtsJ5l ekXdTw2GYSLsckGbUR0DXr96Cuczy1Zhymhzvh5L0gx4DddIWijvzcu6FrRF7Ph0XrzV xF1EBJGUYLJa2hvvPLX15ZssW1b5u2wTyfNtmQ8rM8WJGuzln+nQa2qncs33pz2JIenA QhxSBmX0qxduUtb/rb+v7WJixG1QZ7Y5ppiyj51HfwENHlhCI0oV+LHIQjhq+ofOCbRR w6TA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QYEofgxw; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u185si8539255pgd.489.2019.03.25.10.51.55; Mon, 25 Mar 2019 10:52:10 -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=@kernel.org header.s=default header.b=QYEofgxw; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729786AbfCYRvT (ORCPT + 99 others); Mon, 25 Mar 2019 13:51:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:40982 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726024AbfCYRvT (ORCPT ); Mon, 25 Mar 2019 13:51:19 -0400 Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5BCAF2087E; Mon, 25 Mar 2019 17:51:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553536278; bh=YXo5aNrKEK0EVlMeYrxPR4GBMUR8+qdSey7Xzlh+O/U=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=QYEofgxwTNcuoA3hpYeV20JlMdKEOorB1Q7ctsVKuJytn7Fgxs/AiISFgF+5Lv/gC oWo1EBEWre+153b1fOBv4ioOZmkzrWSWIaHQuM2LJy9NZwqBldcg7rpsLMiCOwlAnF bbXr4kcD/Oa6BVTm0Q0zMv9G2L/zqkGec38tWUpE= Received: by mail-ed1-f45.google.com with SMTP id x14so5693888eds.1; Mon, 25 Mar 2019 10:51:18 -0700 (PDT) X-Gm-Message-State: APjAAAU6tdyt77lOoRBBTy7oueUMSYawVQcYuphldd6SEqgN40Zf5/5K QjeluU2VL32iUq43Jlqs/zvvXBSkNyX9YcXFJOk= X-Received: by 2002:a17:906:5949:: with SMTP id g9mr14883618ejr.15.1553536276904; Mon, 25 Mar 2019 10:51:16 -0700 (PDT) MIME-Version: 1.0 References: <1553483264-5379-1-git-send-email-hao.wu@intel.com> <1553483264-5379-3-git-send-email-hao.wu@intel.com> In-Reply-To: <1553483264-5379-3-git-send-email-hao.wu@intel.com> From: Alan Tull Date: Mon, 25 Mar 2019 12:50:40 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 02/17] fpga: dfl: fme: align PR buffer size per PR datawidth To: Wu Hao Cc: Moritz Fischer , linux-fpga@vger.kernel.org, linux-kernel , linux-api@vger.kernel.org, Xu Yilun Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Mar 24, 2019 at 10:23 PM Wu Hao wrote: Hi Hao, Looks good, one question below. > > 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 > --- > 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 d9ca955..c1fb1fe 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); Since it may not be completely filled, would it be worthwhile to alloc a zero'ed buff? Alan > 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; > > -- > 2.7.4 >