Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2698482ybd; Thu, 27 Jun 2019 17:51:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqy/8sQhi0OG7WaAgRf8wFuL5q83UImxUBGmBk+hMtsw6AacB/xeJc+IPAISo6DLN+s89Qh7 X-Received: by 2002:a17:902:b43:: with SMTP id 61mr8256099plq.322.1561683060622; Thu, 27 Jun 2019 17:51:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561683060; cv=none; d=google.com; s=arc-20160816; b=pbimMIrICYKKPTqpTDw/8c/7MeUJSHkNfcSB8VO+Zm5BAWnhCmnpkNS5JKEH1Qp46o yGx1VO73pHxdSGJLsY+nacjzsvSdUOMlVfwxn2jfN2e4HC8/wAY3IBkI/qAsY/mLq1sM Qix0XB73S9NpTqlhnGLLxEhvgqTxPiWbIJZSrxIqtlinETJp0CfDeN7c78xJGlLPVFEI XwtHjuofCQE0YwDKWSdkgcM1j7jf5EKmSyyCwF8lCTZPtGtL3ZOa9MXCrU0kckPyNNOh Uy7MqPF719MqyOCqx4JEAgTZAsd500RS9Ly+wCMKQ1XJuVG4U7ePnBw03djNYpNVEhek S6vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=OncWFB2MqnR1/OaJA7wEfh0+edJpgnnSs9Q1oS9q/ZA=; b=NfU0I0SU48Jl9uOGUXKMFoLV3HIn87T7Mv9DOzFJD0Za0sYHDn+dqcPRouIo5UZYxS 7rglfalaRXSkI9cDBaA0hEjRGY1WxHiTIyOUjoRgqLuSq4VLr/6R5HihTiMIsGvHSMnR NfZfEwCun3mxHELr6uSX9Ti4pKpFZ7R3RUt54j4fn3xYQlsrMQe3kgjSktuPn/S33Ynl +fmRsSh0y66V/7alXIHjfWRJ7KppMcZjBNU5UpJ5yLiUO2RHzejGLoDEyzEEcY+g9R15 S7ZJOSqWf/JrgNXvfWYhAsluTzh40Y0cBrSDt5dgY0Q5TdH0yJ2ODm1N7/93vKX1VILq 9WVg== 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j63si638834pgc.185.2019.06.27.17.50.44; Thu, 27 Jun 2019 17:51: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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726837AbfF1AuX (ORCPT + 99 others); Thu, 27 Jun 2019 20:50:23 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:33003 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726823AbfF1AuV (ORCPT ); Thu, 27 Jun 2019 20:50:21 -0400 Received: by mail-pl1-f194.google.com with SMTP id c14so2223139plo.0 for ; Thu, 27 Jun 2019 17:50:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OncWFB2MqnR1/OaJA7wEfh0+edJpgnnSs9Q1oS9q/ZA=; b=iPcm3YqYCCy0eKnSpuMUzVB+EPfqRs60e7VFGg3kXsUb3vqQ6JUpJzVyZ4AHfdczS0 IIxSWumv5VkjViY/LsraNhFljDchJxQuRhzkSVK1PG8TUwrVjHft8yuPlQ7UyuIXqDCv x05jU+xGICkEGgcTFeZcaAP2vGtKgaw59g4MMu4yDe3CVSbX3CO6DD4VkpOQdC25kTeI kIYisueg5E7yQoInjMD/vJZMiIsKqUc4ru+OPRJIhkqtiLehAvJv7sLNBLsds7yqLZEW VO3j+6BOrGZuIuI/kKj/xsvHK6TT6SlvtAu5boIUC8ciNWiGCqIBGugljjQW3nZ2Z9YO 13sg== X-Gm-Message-State: APjAAAX8ukZYlVhAnN1nyNAtZMhBwG2+UXdyWYnVZqgEZb4j6mKq7eeA JywgwuXifztCpnXl/oSL7/h8rg== X-Received: by 2002:a17:902:e490:: with SMTP id cj16mr7942734plb.136.1561683020604; Thu, 27 Jun 2019 17:50:20 -0700 (PDT) Received: from localhost (c-76-21-109-208.hsd1.ca.comcast.net. [76.21.109.208]) by smtp.gmail.com with ESMTPSA id h2sm269882pgs.17.2019.06.27.17.50.19 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 27 Jun 2019 17:50:19 -0700 (PDT) From: Moritz Fischer To: linux-fpga@vger.kernel.org, gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Wu Hao , Xu Yilun , Alan Tull , Moritz Fischer Subject: [PATCH 03/15] fpga: dfl: fme: align PR buffer size per PR datawidth Date: Thu, 27 Jun 2019 17:49:39 -0700 Message-Id: <20190628004951.6202-4-mdf@kernel.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190628004951.6202-1-mdf@kernel.org> References: <20190628004951.6202-1-mdf@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wu Hao 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 Signed-off-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 6ec0f09e5994..3c71dc3faaf5 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.22.0