Received: by 10.223.185.116 with SMTP id b49csp2973260wrg; Mon, 5 Mar 2018 11:45:04 -0800 (PST) X-Google-Smtp-Source: AG47ELvl548fe7XuTqmudZWSRM0RRcNpTfWdWo6KRUMSkQe3lhA8i9dO/SqcgW6m2mk/gg85+HYP X-Received: by 10.99.163.80 with SMTP id v16mr13047491pgn.19.1520279104516; Mon, 05 Mar 2018 11:45:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520279104; cv=none; d=google.com; s=arc-20160816; b=rYEvl+7suNX5j1XUlqbDotcpObK2Ri4RU58Puku65DqS0jNJz+mkMZfbHtv0oi3R3v Rx2gY5kImByqdo3sn+fO7LbeQjlSlGv7ZiZSbMTTw5nmdtIX4n/yEzKrJE6C58RdwLJ6 5sv1zr+85v2jaRmDyQEa9baryqufSLQJRddaFDT1f/so36p3PIfujrfEOmB1lDVnBoG3 RDULXi8x3wj0aTqzAnBXO2IIglw6Nn9Gqyx94ydYdEAD+eFCKs4rHuw8DbA/QFzzrVLr WLDNdgk3b7+ULHnFpVIU+LrC9gmOANXwIWlukyfzLHBBwH3ALnU9A17uW31HvSYZwSAU 8s3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dmarc-filter :arc-authentication-results; bh=VtgwzcFrBHjcnKNQcAM0j6ifmeFGcRzcwd05OsczE2g=; b=HlQnBL+OnnJycU2oymkF6mn6xa4S2iXvY4sQBglaFzAQ9zwYvlYY8UIJqPWg21VpaQ hcmX8T6z/TolHgnAZrXMHvcmB81dpMcIbnD2izI4AYU96yX2Xg4j9mBSU+5+2kp3M+GT dSMjHRu9luZ2BBjTBsglpFBaI9y2r8HoKXjZyCQVn10taSMV7Ts49oQ7MXkLDvji6ROS Ox+S01eNRslewxCuWuz6VblMgYb+Z3xUHr6sUdWKJNYMXNGSRw9mRh4iPPo4PntQ81Uo WOlC5On7mTDfmiSw1A+l9b9v1+puTaX3fU18nkb+xDDXgyr34chk+FMmNSEuieBOnUH/ a9Lw== 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 30-v6si9651593pld.724.2018.03.05.11.44.50; Mon, 05 Mar 2018 11:45:04 -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 S932126AbeCETnZ (ORCPT + 99 others); Mon, 5 Mar 2018 14:43:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:60254 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751490AbeCETnX (ORCPT ); Mon, 5 Mar 2018 14:43:23 -0500 Received: from mail-vk0-f49.google.com (mail-vk0-f49.google.com [209.85.213.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 16E28206B2; Mon, 5 Mar 2018 19:43:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 16E28206B2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=atull@kernel.org Received: by mail-vk0-f49.google.com with SMTP id u200so10704030vke.4; Mon, 05 Mar 2018 11:43:23 -0800 (PST) X-Gm-Message-State: APf1xPByLs/dVI1VIdobqsJXYhtka959XQ6NBEC1uwwCJuY9Bg55GhJi Mno7Umn7jEznnhS39zbV8PaMJ8YSIvaI1KuSEKo= X-Received: by 10.31.221.135 with SMTP id u129mr10989073vkg.186.1520279002190; Mon, 05 Mar 2018 11:43:22 -0800 (PST) MIME-Version: 1.0 Received: by 10.159.60.71 with HTTP; Mon, 5 Mar 2018 11:42:41 -0800 (PST) In-Reply-To: <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> <20180301061750.GB8999@hao-dev> From: Alan Tull Date: Mon, 5 Mar 2018 13:42:41 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 13/24] fpga: region: add compat_id support To: Wu Hao Cc: Moritz Fischer , linux-fpga@vger.kernel.org, linux-kernel , linux-api@vger.kernel.org, "Kang, Luwei" , "Zhang, Yi Z" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 1, 2018 at 12:17 AM, Wu Hao wrote: > 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. It would be helpful to add some explanation here that although the intended function of compat_id is set, the way the actual value is defined or calculated is set by the layer that is creating the FPGA region. >> > 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; Yes, thanks! Alan > >> >> > + >> > + 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 >> > > -- > To unsubscribe from this list: send the line "unsubscribe linux-fpga" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html