Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp2825772img; Sun, 24 Mar 2019 20:24:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqw8ZZL2N+bnDcqlgT6Bz+jCIY/k7Rn1ZZOBYL3vN7e2VWyDi66qjr3+Iip2zDtfxImAVaZp X-Received: by 2002:a65:6283:: with SMTP id f3mr21713682pgv.108.1553484299396; Sun, 24 Mar 2019 20:24:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553484299; cv=none; d=google.com; s=arc-20160816; b=FSixsJJ+7ElTmuG7QViLYd0BM5KqnzNW/q/dVili6RdlPqr4sM/JWGxMGVqUClengj ONkNQa0/8Z2RaHkpFy7WHKqxEiEGrAI3vMXri9KbFYJ05mgPEkKqJbIIcOAQLc06UKjv OMrK/UcyhtVKrh8qM4VVGjJ11E6sbMEP5C7/57KRV1hEW6HJ5bij3Yoy1FrF2lVmEAkB IkOmv4iIccj5V0j965+v3spWMnXQmxiRUxhEWDIDawAVHuqJgIAuTCI8/YGq0lYx+j2r CyWiU8dGf43gIcGyR3IIo3s/TGF+9dLAwuEDGY+MzDOFG3qx6186ktEyuaNk0FnS/1+6 phIg== 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=iySVN0Q4fAHWMog3ujbiVxPz5+5l/moADQcmMMGR8o4=; b=XRawQv49jCm4olhF8JZLVrlpylD8X4fB8nck3MOnVhr5s4pWQYG3XgNBvgcuEQ+Paw hCqQeeTmRBBbyZKKv1T5KPfFcsW5/NYlTeMFmZeiF9yCEVMOHuqjeYZVbTrgajoQxpp5 1UwGL/aqQLhgI52in/AnAW7O1iTVWoBe7W+kcS7atEcmPpidUIp5JRSIdeAyLc7ghFoJ Eifhn0D5H5t36R51Zh/+gfTNQKxTgbplzbkmsM8DrMx/e+VFt1/jJFqJFDIn8kVbThhf ctXylkS1L24Nj/CyXoztFVuUUUMOUcSXa+TkxqbMNB1UBL8d8nUKOKV4E9IAad4ddn7I 6faw== 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 e71si12547646pgc.593.2019.03.24.20.24.44; Sun, 24 Mar 2019 20:24:59 -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 S1729529AbfCYDX5 (ORCPT + 99 others); Sun, 24 Mar 2019 23:23:57 -0400 Received: from mga18.intel.com ([134.134.136.126]:19145 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729518AbfCYDXw (ORCPT ); Sun, 24 Mar 2019 23:23:52 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Mar 2019 20:23:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,256,1549958400"; d="scan'208";a="310109617" Received: from hao-dev.bj.intel.com ([10.238.157.65]) by orsmga005.jf.intel.com with ESMTP; 24 Mar 2019 20:23:49 -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 02/17] fpga: dfl: fme: align PR buffer size per PR datawidth Date: Mon, 25 Mar 2019 11:07:29 +0800 Message-Id: <1553483264-5379-3-git-send-email-hao.wu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1553483264-5379-1-git-send-email-hao.wu@intel.com> References: <1553483264-5379-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 --- 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); 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