Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3403691ybi; Sun, 26 May 2019 22:40:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqzcbruAVEy1Ds6mV3Xlx49JEnko5tOONT8E9O+fS5gtso6TWXhZ8/oEp5tV/F4EjOffHMRG X-Received: by 2002:a62:1846:: with SMTP id 67mr115087619pfy.33.1558935646894; Sun, 26 May 2019 22:40:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558935646; cv=none; d=google.com; s=arc-20160816; b=mM8GFbGUDdTAiHeEEFE8uD/ouWDvro0RbhpPgGX6TOHiXI7uiF+LZJXMYt7QrRDoWM 24R8OKK0nRpRtvc7vEan3vhVUv+2jFqCgcDMciSsIARa21chrOo5U3r2R5KzefZSXTln Xi50mMCgJYMxeFa3ItxTTIa8FnsnN6eckVtkGEbzbANawikYZyd1wSd4ZbZajPYFIher rDZIRdV+4tbb9SeFBzJMx3CDUroB5Q7MiWcfd31xVdolT77mS53ZEgfhSUIgVylYBc2H VbaRphKSObAyf5V2hbdCja7I5xSJEqIYkzmZILDEq1nQPJ6jtZX5CXHHtn5kV2t/Mgcg iwkQ== 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=h3vNLaBNImcNqES7FGvoXcq19OkmZRcF+8qANRQRzVoDK5v0qGRcyX/pb0J86JyCWP FGD3qartiq/y2ntsJbSIvyUYhHAIruWHWzi+rinhyy1nJQXBp9/YhFRUPoklbKWE1QSa otBnfR/uabOFpA0hr8T1ewJNoA7j819LK2GSGCwz/5cPIRAHxgBH/1QLdO+bk49htD4B V00NS752mz2Tn2r1Il9/i3NjAceWtSuMLN0trYpPXXg9GXx1O/tpv0Y5H88rKYaZ+9tM JgGgo0zqyxRXfrkONSc/Amg5wa+qTkFMWIIHZu2w+tH6mzJNIk8gNjKKxl0D5TFYVbHq Gs8A== 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 r2si16921184pjb.0.2019.05.26.22.40.31; Sun, 26 May 2019 22:40:46 -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 S1726396AbfE0FjD (ORCPT + 99 others); Mon, 27 May 2019 01:39:03 -0400 Received: from mga04.intel.com ([192.55.52.120]:7420 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726350AbfE0FjB (ORCPT ); Mon, 27 May 2019 01:39:01 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 May 2019 22:39:01 -0700 X-ExtLoop1: 1 Received: from hao-dev.bj.intel.com ([10.238.157.65]) by orsmga001.jf.intel.com with ESMTP; 26 May 2019 22:38:59 -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 v3 03/16] fpga: dfl: fme: align PR buffer size per PR datawidth Date: Mon, 27 May 2019 13:22:13 +0800 Message-Id: <1558934546-12171-4-git-send-email-hao.wu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1558934546-12171-1-git-send-email-hao.wu@intel.com> References: <1558934546-12171-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