Received: by 10.223.185.116 with SMTP id b49csp7073499wrg; Wed, 28 Feb 2018 22:28:28 -0800 (PST) X-Google-Smtp-Source: AG47ELvSsKe2b69eDzcZ81y1CZt2TyoVHvcMm0466ffZTkhUbKMPzhNlhTWTEsw9KlRpFGrLeQhl X-Received: by 10.99.95.201 with SMTP id t192mr681394pgb.313.1519885708610; Wed, 28 Feb 2018 22:28:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519885708; cv=none; d=google.com; s=arc-20160816; b=LKAZtiPwO7c0lGVQ72h3g/gfa4xKPGn9U2+HmTVRvx1sTs7l7J+vVOP9equCF2JAaQ fFTHSb8UtoZjBYACKWPEVwPVRJZy+idJGWin2ZqVsyl+cAPQ0JsAnLWdHRyok+V8/Ii4 bWX28I2K73SHmPrjQ/YjFPgql560pzcqmeYzyla3Z6wZLwQNjbY3iCvaIMxF73wvDWaC oKVlaCzdekXhTluqE4AXZwGsDoC9NAmLCFcvwVaujgimmjih2H0STLqVqdNz+J4M1K4V zz/+m4SHqjmpFso1QsFfBX67D7rPgWvPPZlGyG4JL8bBmRtHMSMGJaFWdWHBToyzOEiu kJhw== 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:arc-authentication-results; bh=qsH27D3dL54PwnKJ/K+EFEivSwRR2WAEADKlgDVN5GA=; b=VswKtieflhbMv7wX+s3JBzKFBGKJRob8RNhUeI2am7ZXNCExmMxmohEwSpUJQejPYM c9DjbnjSgfv79GtMVIdJiN2OOI52GObTVqWtwYBPWNgtnLD0hK0cbE5LVErgfgEV1RkD rzJP/dD1yAV+hop9YlnMjz6AcQSYVej77Azk/0TsJPuaEn0rMw/xsB//rc2j5WShi+dJ ZadsSbh0pOyRLt3VxBbnD+monELV1LKLcoyVUqNJYkyXklcyP9D/mrvEpihL/5IKsGMR t6AZlG8/AYoGp1jFe8XtjYI1o8tN9/6LJZv+YDCYP56qSUYWSTg1fvHvB9N2FVZKzX81 4k8g== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 73si2502539pfr.363.2018.02.28.22.28.13; Wed, 28 Feb 2018 22:28:28 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966329AbeCAG1f (ORCPT + 99 others); Thu, 1 Mar 2018 01:27:35 -0500 Received: from mga09.intel.com ([134.134.136.24]:14079 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966268AbeCAG1d (ORCPT ); Thu, 1 Mar 2018 01:27:33 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Feb 2018 22:27:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,407,1515484800"; d="scan'208";a="207919910" Received: from hao-dev.bj.intel.com (HELO localhost) ([10.238.157.61]) by fmsmga005.fm.intel.com with ESMTP; 28 Feb 2018 22:27:30 -0800 Date: Thu, 1 Mar 2018 14:17:50 +0800 From: Wu Hao To: Alan Tull Cc: Moritz Fischer , linux-fpga@vger.kernel.org, linux-kernel , linux-api@vger.kernel.org, "Kang, Luwei" , "Zhang, Yi Z" Subject: Re: [PATCH v4 13/24] fpga: region: add compat_id support Message-ID: <20180301061750.GB8999@hao-dev> References: <1518513893-4719-1-git-send-email-hao.wu@intel.com> <1518513893-4719-14-git-send-email-hao.wu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Wed, Feb 28, 2018 at 04:55:15PM -0600, Alan Tull wrote: > On Tue, Feb 13, 2018 at 3:24 AM, Wu Hao wrote: > > Hi Hao, Hi Alan, Thanks for the review. > > > This patch introduces a compat_id member and sysfs interface for each > > fpga-region, e.g userspace applications could read the compat_id > > from the sysfs interface for compatibility checking before PR. > > > > Signed-off-by: Wu Hao > > --- > > Documentation/ABI/testing/sysfs-class-fpga-region | 5 +++++ > > drivers/fpga/fpga-region.c | 19 +++++++++++++++++++ > > include/linux/fpga/fpga-region.h | 13 +++++++++++++ > > 3 files changed, 37 insertions(+) > > create mode 100644 Documentation/ABI/testing/sysfs-class-fpga-region > > > > diff --git a/Documentation/ABI/testing/sysfs-class-fpga-region b/Documentation/ABI/testing/sysfs-class-fpga-region > > new file mode 100644 > > index 0000000..419d930 > > --- /dev/null > > +++ b/Documentation/ABI/testing/sysfs-class-fpga-region > > @@ -0,0 +1,5 @@ > > +What: /sys/class/fpga_region//compat_id > > +Date: February 2018 > > +KernelVersion: 4.16 > > +Contact: Wu Hao > > +Description: FPGA region id for compatibility check. > > diff --git a/drivers/fpga/fpga-region.c b/drivers/fpga/fpga-region.c > > index 660a91b..babec96 100644 > > --- a/drivers/fpga/fpga-region.c > > +++ b/drivers/fpga/fpga-region.c > > @@ -162,6 +162,24 @@ int fpga_region_program_fpga(struct fpga_region *region) > > } > > EXPORT_SYMBOL_GPL(fpga_region_program_fpga); > > > > +static ssize_t compat_id_show(struct device *dev, > > + struct device_attribute *attr, char *buf) > > +{ > > + struct fpga_region *region = to_fpga_region(dev); > > This looks good, but not all users of FPGA are going to use compat_id. > How would you feel about making it a pointer in struct fpga_region? > With compat_id as a pointer, could check for non-null compat_id > pointer and return an error if it wasn't initialized. It sounds good to me. if (!region->compat_id) return -ENOENT; > > > + > > + return sprintf(buf, "%016llx%016llx\n", > > + (unsigned long long)region->compat_id.id_h, > > + (unsigned long long)region->compat_id.id_l); > > +} > > + > > +static DEVICE_ATTR_RO(compat_id); > > + > > +static struct attribute *fpga_region_attrs[] = { > > + &dev_attr_compat_id.attr, > > + NULL, > > +}; > > +ATTRIBUTE_GROUPS(fpga_region); > > + > > int fpga_region_register(struct fpga_region *region) > > { > > struct device *dev = region->parent; > > @@ -226,6 +244,7 @@ static int __init fpga_region_init(void) > > if (IS_ERR(fpga_region_class)) > > return PTR_ERR(fpga_region_class); > > > > + fpga_region_class->dev_groups = fpga_region_groups; > > fpga_region_class->dev_release = fpga_region_dev_release; > > > > return 0; > > diff --git a/include/linux/fpga/fpga-region.h b/include/linux/fpga/fpga-region.h > > index 423c87e..bf97dcc 100644 > > --- a/include/linux/fpga/fpga-region.h > > +++ b/include/linux/fpga/fpga-region.h > > @@ -6,6 +6,17 @@ > > #include > > > > /** > > + * struct fpga_region_compat_id - FPGA Region id for compatibility check > > + * > > + * @id_h: high 64bit of the compat_id > > + * @id_l: low 64bit of the compat_id > > + */ > > +struct fpga_region_compat_id { > > + u64 id_h; > > + u64 id_l; > > I guess each user will choose how to define these bits. Yes. > > > +}; > > + > > +/** > > * struct fpga_region - FPGA Region structure > > * @dev: FPGA Region device > > * @parent: parent device > > @@ -13,6 +24,7 @@ > > * @bridge_list: list of FPGA bridges specified in region > > * @mgr: FPGA manager > > * @info: FPGA image info > > + * @compat_id: FPGA region id for compatibility check. > > * @priv: private data > > * @get_bridges: optional function to get bridges to a list > > * @groups: optional attribute groups. > > @@ -24,6 +36,7 @@ struct fpga_region { > > struct list_head bridge_list; > > struct fpga_manager *mgr; > > struct fpga_image_info *info; > > + struct fpga_region_compat_id compat_id; > > Here it would be a pointer instead. Yes. Will update this patch. Thanks Hao > > Alan > > > void *priv; > > int (*get_bridges)(struct fpga_region *region); > > const struct attribute_group **groups; > > -- > > 2.7.4 > >