Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp4988167img; Tue, 26 Mar 2019 23:04:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqz6mYAV8My1fRs4t9/p/aY57WWU5lTZ94usLdY3ZJXdscDv5XEqoWMGfWvCzt37HrrSVdY+ X-Received: by 2002:a65:6656:: with SMTP id z22mr31494397pgv.95.1553666647650; Tue, 26 Mar 2019 23:04:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553666647; cv=none; d=google.com; s=arc-20160816; b=H2B6Gd6dvzCjqldDXihruG6zrc+/v40uc6B4ZIsZiIF8cWR0k7r+VECjCOdAr0T36j uaQrub6TfSGC+SsnCXQWp8zWe/m9Adrdz6eEixAspI4Rvg7ekzg9KDhZ3stF2nKW+fVn GWnBmeDRPEbmG7Q509AEJ1SFrKBa2QcGIwcWnI4M5e8akYv8JzZVuOzVBK9ZkHoa4Fhj gMY9GWfQ7kEx23sHStwvpczXaS82DlxZ4lWriP9UErzGCV6K6lJjhN/b/peM8P4XgcJc TRGn3QHzX+0+pfVEnerLBjxX4npMamuQBOUEqrUn7JIEt+prXl9qUla90t5RuqGxbBXi u0Tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Ct5EMw3Drc7Iju6FxWDqUaJoP7W3XyNnLCjfAR+/g6A=; b=fa5avUh9UqDIxVD4jzgWIznrw3JZdDxygD+z3iVU/GxuneYnO8WBGS8yDePJurIMUJ 7uoRuIj6CZYH6df46Rv01AasSIGabT4+hRw0xFuC41SbfIvm9dRhmP0PAg74tN2+BtLP gWg66V/2k+301E8vBIzhAYNTs3eulE8aeghQmUry9eP4lr49xkvItnavf+IMqDdJybz5 85Go0ia6iWIkyXEOcN0oCGeFxleXOeq8EdvwJ+6oSXG9SOxprEirMWjuHXFRykAepMYi rTK9MAc7v6pJdLd4BY+E0Hg8nRQfTCwFUZ0gvkFBKpMyQ9LfmdlSjSrK92JQ2pXzexSM EMew== 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 b7si20086556plb.0.2019.03.26.23.03.52; Tue, 26 Mar 2019 23:04:07 -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 S1732489AbfC0GCF (ORCPT + 99 others); Wed, 27 Mar 2019 02:02:05 -0400 Received: from mga01.intel.com ([192.55.52.88]:12891 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725730AbfC0GCF (ORCPT ); Wed, 27 Mar 2019 02:02:05 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Mar 2019 23:02:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,275,1549958400"; d="scan'208";a="137595271" Received: from hao-dev.bj.intel.com (HELO localhost) ([10.238.157.65]) by orsmga003.jf.intel.com with ESMTP; 26 Mar 2019 23:02:02 -0700 Date: Wed, 27 Mar 2019 13:46:37 +0800 From: Wu Hao To: Scott Wood Cc: atull@kernel.org, mdf@kernel.org, linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Ananda Ravuri , Xu Yilun Subject: Re: [PATCH 03/17] fpga: dfl: fme: support 512bit data width PR Message-ID: <20190327054637.GC20968@hao-dev> References: <1553483264-5379-1-git-send-email-hao.wu@intel.com> <1553483264-5379-4-git-send-email-hao.wu@intel.com> <127a9356a7bf597d35dd361f2b16bf80460f0370.camel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <127a9356a7bf597d35dd361f2b16bf80460f0370.camel@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 25, 2019 at 05:53:50PM -0500, Scott Wood wrote: > On Mon, 2019-03-25 at 11:07 +0800, Wu Hao wrote: > > @@ -200,21 +228,32 @@ static int fme_mgr_write(struct fpga_manager *mgr, > > pr_credit = FIELD_GET(FME_PR_STS_PR_CREDIT, > > pr_status); > > } > > > > - if (count < 4) { > > + if (count < priv->pr_datawidth) { > > dev_err(dev, "Invalid PR bitstream size\n"); > > return -EINVAL; > > Shouldn't this have become a WARN_ON in patch 2 given that the kernel > already pads the buffer? Thanks a lot for the review and comments. I agree. it's better to use WARN_ON this place. > > > } > > > > - pr_data = 0; > > - pr_data |= FIELD_PREP(FME_PR_DATA_PR_DATA_RAW, > > - *(((u32 *)buf) + i)); > > - writeq(pr_data, fme_pr + FME_PR_DATA); > > - count -= 4; > > + switch (priv->pr_datawidth) { > > + case 4: > > + pr_data = 0; > > + pr_data |= FIELD_PREP(FME_PR_DATA_PR_DATA_RAW, > > + *((u32 *)buf)); > > I know it's not new, but why not just "pr_data = FIELD..."? Const should > also be preserved in the cast, and you can drop one set of parentheses. Yes, agree, will fix this. > > > + writeq(pr_data, fme_pr + FME_PR_DATA); > > + break; > > + case 64: > > + copy512((void *)buf, fme_pr + FME_PR_512_DATA); > > + break; > > Unnecessary cast. Will fix this. > > > + default: > > + ret = -EFAULT; > > + goto done; > > How is it EFAULT? Any other value for pr_datawidth should be WARN_ON > since it's set by kernel code. Agree, will fix this in the next version. > > > @@ -159,13 +161,10 @@ static int fme_pr(struct platform_device *pdev, > > unsigned long arg) > > fpga_bridges_put(®ion->bridge_list); > > > > put_device(®ion->dev); > > -unlock_exit: > > - mutex_unlock(&pdata->lock); > > free_exit: > > vfree(buf); > > - if (copy_to_user((void __user *)arg, &port_pr, minsz)) > > - return -EFAULT; > > - > > Why is the copy_to_user being removed? This code is not needed at all but added by mistake i think. Sorry, i should move these code into a separated patch with proper comments to avoid confusion. Thanks Hao > > -Scott