Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp1626704ybd; Wed, 26 Jun 2019 22:03:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqyt3Sy53Am6gzEOTJQ8sTZGb621uY4M9MKiY5alnxGvsKb2ishu/qZbi4FnELrnrLpq3f4i X-Received: by 2002:a17:902:8a8a:: with SMTP id p10mr2378396plo.88.1561611827102; Wed, 26 Jun 2019 22:03:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561611827; cv=none; d=google.com; s=arc-20160816; b=0OK1yQP/icVwBTRNrSTnM0/U11JFCL9QbSpQMS0M6kTTF7B9XP74pkl1WTAmnLUckT FFLh4W/GA1u1gA/llnclca6AT42ewBH0of3dNIZATNQ/QCVAVZLJ5EECcVqePMc9jZPc Et/IY5kK8/xSipzoluLHoxqhHYsJLJDYi2HaQE+gv0QzmvnA/CQfPwepyPJUxHzOriVF hVA7jSjaIuRFI90jvT5uQ56qoQSK1L/WieIshIyf01A3e5mzYLEpyRUPi59chw3jOVsi 92zq7v/1oTKN5pHOdRFoDyxgM/ZDLzWjpyNUIGvZFaUye3HU7ZLvtZcyIH4kpMtK+qI7 n7eg== 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=QK9BdFB/ESnMSIjj0SPrPV5Sq/8/hGEDgpsS6bEiZdk=; b=OZ5Asuke7j37TAEt1m7qrJPwXlZP0wCMUNW2FpDSsuJMQFfdoG3GwXutu1QZZisoV/ BDG7OT6NLuOoLT0NOBRdNf30Ugj6OtmsICMj+omdMeBdV7ABK/O3rRHaBYDUl1d58zag HQVJYvUA7cK/Qqd6B4a4r8n4kxD/0cRCX38QOVMTW95vjsFB5PCEC/O9ZBe8A6rGz7Mi Jj+EJnIiCtUOC/9cU49e2e6r59Sf/9BZnz91GxAsNNpDtLDb5gLhYzZyhzyQzvlJuJzz 7Uwmcxp2owlwv41A/6ZNHYKjR2yE0VDND8Oait73VcQo2qii4Uw3s3XSuluHxZekTwMG /xMw== 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 gn14si1249426plb.395.2019.06.26.22.03.30; Wed, 26 Jun 2019 22:03:47 -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 S1727281AbfF0FB7 (ORCPT + 99 others); Thu, 27 Jun 2019 01:01:59 -0400 Received: from mga11.intel.com ([192.55.52.93]:22916 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726563AbfF0FBz (ORCPT ); Thu, 27 Jun 2019 01:01:55 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jun 2019 22:01:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,422,1557212400"; d="scan'208";a="173005029" Received: from hao-dev.bj.intel.com ([10.238.157.65]) by orsmga002.jf.intel.com with ESMTP; 26 Jun 2019 22:01:53 -0700 From: Wu Hao To: mdf@kernel.org, linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linux-api@vger.kernel.org, yilun.xu@intel.com, hao.wu@intel.com, gregkh@linuxfoundation.org, atull@kernel.org Subject: [PATCH v4 03/15] fpga: dfl: fme: align PR buffer size per PR datawidth Date: Thu, 27 Jun 2019 12:44:43 +0800 Message-Id: <1561610695-5414-4-git-send-email-hao.wu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1561610695-5414-1-git-send-email-hao.wu@intel.com> References: <1561610695-5414-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 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