Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3436793yba; Mon, 29 Apr 2019 02:15:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqzFRGZIet/b7Sd2SroNmRIKWD+zbfFf0jVa0fOaNMYnC0RQ4NymYx1+D/UJvPiTf6nB1uH/ X-Received: by 2002:aa7:9a9a:: with SMTP id w26mr24693986pfi.116.1556529300345; Mon, 29 Apr 2019 02:15:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556529300; cv=none; d=google.com; s=arc-20160816; b=pRzIFUbIN9lgmWJv6yGkuMlb0INMzZBM9EYPF3Ig5CsS8Xye293h8QaiUR2sSpcuY1 hQC+dn3gE8MDR4Crbkz62GiELVvrb7SKn7n94RMyymmRrEHDjAKGAlo3JxWJtz+BFeiH RKTgopmoZqIzVBaxg2UqUTPTHlAy/qvMbeJzMLcJiQbndUp4SzKwtCShMP8LHkb27Iep Cq2LhSkrSvR2qgyF5cR/mwjaZ9+PU4aCWwrx80d49lLSxmw6o8/JSxK3Mgn5jcd1gyMS GH544AiDKqUurIzdlA1MFvFf3XgyQUgGFRUs+kDLqONWzGA3U4Ap+TcyB4OxN8Zm4GNa Y7Nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=GOUYXfa1Fi+E7rntxntRUN/zYpwmZU53jDyTpmQHAVU=; b=hU2VHH3EFH3ImkVZp7EVRdHQJPYWEXTJcJDfcTA2U0Ekxfaidrt30xJ/GhL061Xce8 p6fVFFHws8sNSoHGg+02k9mmfgjhbLQ00egBd0+8PfKt7Mid5aOWUfzjxq7XTIeABtu/ UFDcyI1Kt2R4MbaE6T+5zaxdUDdk5vF0aPhU18SdxHZXnXiF8UfqsNChwkTlClK3c0qf 74kPQjxxUJctrtU4EzihWZSIjF69s7X/VHjPyGXs4PwXZjztO68I9zy7fQbovq5bUrTR U2nAURS0Gz9KIox91eFC7qOlcKr2HdezjL+j6ZinMXhtZZuX4Vr6NY3KS7pPfuxdfTHp JLpg== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 2si32353163pld.334.2019.04.29.02.14.45; Mon, 29 Apr 2019 02:15:00 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727855AbfD2JMn (ORCPT + 99 others); Mon, 29 Apr 2019 05:12:43 -0400 Received: from mga02.intel.com ([134.134.136.20]:32625 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727833AbfD2JMl (ORCPT ); Mon, 29 Apr 2019 05:12:41 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Apr 2019 02:12:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,409,1549958400"; d="scan'208";a="165988200" Received: from hao-dev.bj.intel.com ([10.238.157.65]) by fmsmga004.fm.intel.com with ESMTP; 29 Apr 2019 02:12:39 -0700 From: Wu Hao To: atull@kernel.org, mdf@kernel.org, linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linux-api@vger.kernel.org, Wu Hao , Xu Yilun Subject: [PATCH v2 03/18] fpga: dfl: fme: align PR buffer size per PR datawidth Date: Mon, 29 Apr 2019 16:55:36 +0800 Message-Id: <1556528151-17221-4-git-send-email-hao.wu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1556528151-17221-1-git-send-email-hao.wu@intel.com> References: <1556528151-17221-1-git-send-email-hao.wu@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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