From patchwork Fri Jul 9 13:42:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12367393 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ACAD9C07E9B for ; Fri, 9 Jul 2021 13:42:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 990A46135C for ; Fri, 9 Jul 2021 13:42:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231905AbhGINpe (ORCPT ); Fri, 9 Jul 2021 09:45:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:24398 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231704AbhGINpe (ORCPT ); Fri, 9 Jul 2021 09:45:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625838170; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eICYZGUDhJbeDPmUPqBV9vlRHs0mVJ7xA2q2MeZ8RDY=; b=KjwmebJMIVG2mYqkMIDDN38GSqs3mem8NNqst2LIXtlFCD6U70VBjRzFOhycbznY69MCSJ TR8kXNpnoU1UUTcvVojehjE0iPw3N4Y4Pp16TLLvqMAcuZQMfkFRRdDpLiwGBSGn7TMw4a aYasvcDPOGU+o/TaZgvR0kzMqO1UO5Q= Received: from mail-oi1-f198.google.com (mail-oi1-f198.google.com [209.85.167.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-48-p1609fBBNqO_2jEgXrA5Jg-1; Fri, 09 Jul 2021 09:42:49 -0400 X-MC-Unique: p1609fBBNqO_2jEgXrA5Jg-1 Received: by mail-oi1-f198.google.com with SMTP id i133-20020acab88b0000b0290240dce28bb8so6709441oif.2 for ; Fri, 09 Jul 2021 06:42:49 -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=eICYZGUDhJbeDPmUPqBV9vlRHs0mVJ7xA2q2MeZ8RDY=; b=W1M7iNWl+6eEyGpcrqWKYZf5jBMPbfVS7HvobShMshLwAjj916HhXN6cqlkCn+Pn7g 8r6VeNtZp9PRSsOdUHmXM5E2EuOe7w/hFvp5ABvyZH7z/j9BHCI0D62iKvahy2Oap8aR EPGveOyPyvZWuEUUgXESioM0vq5Z9rKOQThuuU1a9JNMDqiZ0mrpvMH/U2w4YHRVEYD4 Qm2aQXA+aNijyfE1MYH8LjQG2nWnZjlheZsQNJQ5udHexIEle1bpnoW+elpEeWDNWxNB r4Do2z3jXUl2A+/wu0B/dccwalLi98e1iQqGW5SoUrK5XQrjHIPlIVIBwOUj6E2zEN1T ztgQ== X-Gm-Message-State: AOAM533G09tksyyWX1o7CDQmSN0H6zoHK8V3WHnXLHQkzTdqorO6P/m4 aomIknlP37qmp8ugvwj5ilnY2xlV5fBebAO4oL6Dghiz2HrziYRZ1jM3d7oQFgkQqfbq/yzMnKQ 0TQ4ry1idHcosJR0Oor6M2g== X-Received: by 2002:a05:6830:14c1:: with SMTP id t1mr24595631otq.181.1625838168671; Fri, 09 Jul 2021 06:42:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZkviZR++lAyxlrXr/DaCGuPzhC3U4w6gekpqQEZ8FSG9+Q4q87cWl6PhKIEbKXTP88ZwBLg== X-Received: by 2002:a05:6830:14c1:: with SMTP id t1mr24595608otq.181.1625838168457; Fri, 09 Jul 2021 06:42:48 -0700 (PDT) Received: from localhost.localdomain.com (075-142-250-213.res.spectrum.com. [75.142.250.213]) by smtp.gmail.com with ESMTPSA id j23sm1215948oie.9.2021.07.09.06.42.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jul 2021 06:42:48 -0700 (PDT) From: trix@redhat.com To: mdf@kernel.org, corbet@lwn.net, hao.wu@intel.com Cc: linux-fpga@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Tom Rix Subject: [PATCH v2 1/4] fpga: region: introduce fpga_region_ops Date: Fri, 9 Jul 2021 06:42:26 -0700 Message-Id: <20210709134229.2510349-3-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210709134229.2510349-1-trix@redhat.com> References: <20210709134229.2510349-1-trix@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org From: Tom Rix Convert passing of a get_bridges() function pointer in the the *fpga_region_create() to passing an ops table with get_bridges() as an element. For backward compatibility, because *create() could take a NULL function pointer, *create() and take a NULL ops table. Non NULL uses were converted to ops tables. Add a fpga_region_get_bridges() wrapper handle to the NULL cases. Signed-off-by: Tom Rix --- Documentation/driver-api/fpga/fpga-region.rst | 6 +++- drivers/fpga/dfl-fme-pr.c | 2 +- drivers/fpga/dfl-fme-region.c | 6 +++- drivers/fpga/fpga-region.c | 32 +++++++++++-------- drivers/fpga/of-fpga-region.c | 6 +++- include/linux/fpga/fpga-region.h | 22 ++++++++++--- 6 files changed, 53 insertions(+), 21 deletions(-) diff --git a/Documentation/driver-api/fpga/fpga-region.rst b/Documentation/driver-api/fpga/fpga-region.rst index 363a8171ab0a5..2f621de51130d 100644 --- a/Documentation/driver-api/fpga/fpga-region.rst +++ b/Documentation/driver-api/fpga/fpga-region.rst @@ -46,6 +46,7 @@ API to add a new FPGA region ---------------------------- * struct fpga_region — The FPGA region struct +* struct fpga_region_ops — Low level FPGA region driver ops * devm_fpga_region_create() — Allocate and init a region struct * fpga_region_register() — Register an FPGA region * fpga_region_unregister() — Unregister an FPGA region @@ -63,7 +64,7 @@ The FPGA region will need to specify which bridges to control while programming the FPGA. The region driver can build a list of bridges during probe time (:c:expr:`fpga_region->bridge_list`) or it can have a function that creates the list of bridges to program just before programming -(:c:expr:`fpga_region->get_bridges`). The FPGA bridge framework supplies the +(:c:expr:`fpga_region_ops->get_bridges`). The FPGA bridge framework supplies the following APIs to handle building or tearing down that list. * fpga_bridge_get_to_list() — Get a ref of an FPGA bridge, add it to a @@ -75,6 +76,9 @@ following APIs to handle building or tearing down that list. .. kernel-doc:: include/linux/fpga/fpga-region.h :functions: fpga_region +.. kernel-doc:: include/linux/fpga/fpga-region.h + :functions: fpga_region_ops + .. kernel-doc:: drivers/fpga/fpga-region.c :functions: devm_fpga_region_create diff --git a/drivers/fpga/dfl-fme-pr.c b/drivers/fpga/dfl-fme-pr.c index 1194c0e850e07..5869f7cb188f6 100644 --- a/drivers/fpga/dfl-fme-pr.c +++ b/drivers/fpga/dfl-fme-pr.c @@ -151,7 +151,7 @@ static int fme_pr(struct platform_device *pdev, unsigned long arg) * reenabling the bridge to clear things out between accleration runs. * so no need to hold the bridges after partial reconfiguration. */ - if (region->get_bridges) + if (region->rops && region->rops->get_bridges) fpga_bridges_put(®ion->bridge_list); put_device(®ion->dev); diff --git a/drivers/fpga/dfl-fme-region.c b/drivers/fpga/dfl-fme-region.c index 1eeb42af10122..ca7277d3d30a9 100644 --- a/drivers/fpga/dfl-fme-region.c +++ b/drivers/fpga/dfl-fme-region.c @@ -27,6 +27,10 @@ static int fme_region_get_bridges(struct fpga_region *region) return fpga_bridge_get_to_list(dev, region->info, ®ion->bridge_list); } +static const struct fpga_region_ops fme_fpga_region_ops = { + .get_bridges = fme_region_get_bridges, +}; + static int fme_region_probe(struct platform_device *pdev) { struct dfl_fme_region_pdata *pdata = dev_get_platdata(&pdev->dev); @@ -39,7 +43,7 @@ static int fme_region_probe(struct platform_device *pdev) if (IS_ERR(mgr)) return -EPROBE_DEFER; - region = devm_fpga_region_create(dev, mgr, fme_region_get_bridges); + region = devm_fpga_region_create(dev, mgr, &fme_fpga_region_ops); if (!region) { ret = -ENOMEM; goto eprobe_mgr_put; diff --git a/drivers/fpga/fpga-region.c b/drivers/fpga/fpga-region.c index a4838715221ff..dfa35c2dc2720 100644 --- a/drivers/fpga/fpga-region.c +++ b/drivers/fpga/fpga-region.c @@ -18,6 +18,14 @@ static DEFINE_IDA(fpga_region_ida); static struct class *fpga_region_class; +static int fpga_region_get_bridges(struct fpga_region *region) +{ + if (region->rops && region->rops->get_bridges) + return region->rops->get_bridges(region); + + return 0; +} + struct fpga_region *fpga_region_class_find( struct device *start, const void *data, int (*match)(struct device *, const void *)) @@ -115,12 +123,10 @@ int fpga_region_program_fpga(struct fpga_region *region) * In some cases, we already have a list of bridges in the * fpga region struct. Or we don't have any bridges. */ - if (region->get_bridges) { - ret = region->get_bridges(region); - if (ret) { - dev_err(dev, "failed to get fpga region bridges\n"); - goto err_unlock_mgr; - } + ret = fpga_region_get_bridges(region); + if (ret) { + dev_err(dev, "failed to get fpga region bridges\n"); + goto err_unlock_mgr; } ret = fpga_bridges_disable(®ion->bridge_list); @@ -147,7 +153,7 @@ int fpga_region_program_fpga(struct fpga_region *region) return 0; err_put_br: - if (region->get_bridges) + if (region->rops && region->rops->get_bridges) fpga_bridges_put(®ion->bridge_list); err_unlock_mgr: fpga_mgr_unlock(region->mgr); @@ -183,7 +189,7 @@ ATTRIBUTE_GROUPS(fpga_region); * fpga_region_create - alloc and init a struct fpga_region * @parent: device parent * @mgr: manager that programs this region - * @get_bridges: optional function to get bridges to a list + * @rops: optional pointer to struct for fpga region ops * * The caller of this function is responsible for freeing the resulting region * struct with fpga_region_free(). Using devm_fpga_region_create() instead is @@ -194,7 +200,7 @@ ATTRIBUTE_GROUPS(fpga_region); struct fpga_region *fpga_region_create(struct device *parent, struct fpga_manager *mgr, - int (*get_bridges)(struct fpga_region *)) + const struct fpga_region_ops *rops) { struct fpga_region *region; int id, ret = 0; @@ -208,7 +214,7 @@ struct fpga_region goto err_free; region->mgr = mgr; - region->get_bridges = get_bridges; + region->rops = rops; mutex_init(®ion->mutex); INIT_LIST_HEAD(®ion->bridge_list); @@ -255,7 +261,7 @@ static void devm_fpga_region_release(struct device *dev, void *res) * devm_fpga_region_create - create and initialize a managed FPGA region struct * @parent: device parent * @mgr: manager that programs this region - * @get_bridges: optional function to get bridges to a list + * @rops: optional pointer to struct for fpga region ops * * This function is intended for use in an FPGA region driver's probe function. * After the region driver creates the region struct with @@ -270,7 +276,7 @@ static void devm_fpga_region_release(struct device *dev, void *res) struct fpga_region *devm_fpga_region_create(struct device *parent, struct fpga_manager *mgr, - int (*get_bridges)(struct fpga_region *)) + const struct fpga_region_ops *rops) { struct fpga_region **ptr, *region; @@ -278,7 +284,7 @@ struct fpga_region if (!ptr) return NULL; - region = fpga_region_create(parent, mgr, get_bridges); + region = fpga_region_create(parent, mgr, rops); if (!region) { devres_free(ptr); } else { diff --git a/drivers/fpga/of-fpga-region.c b/drivers/fpga/of-fpga-region.c index e3c25576b6b9d..2c99605e008a6 100644 --- a/drivers/fpga/of-fpga-region.c +++ b/drivers/fpga/of-fpga-region.c @@ -138,6 +138,10 @@ static int of_fpga_region_get_bridges(struct fpga_region *region) return 0; } +static const struct fpga_region_ops of_fpga_region_ops = { + .get_bridges = of_fpga_region_get_bridges, +}; + /** * child_regions_with_firmware * @overlay: device node of the overlay @@ -405,7 +409,7 @@ static int of_fpga_region_probe(struct platform_device *pdev) if (IS_ERR(mgr)) return -EPROBE_DEFER; - region = devm_fpga_region_create(dev, mgr, of_fpga_region_get_bridges); + region = devm_fpga_region_create(dev, mgr, &of_fpga_region_ops); if (!region) { ret = -ENOMEM; goto eprobe_mgr_put; diff --git a/include/linux/fpga/fpga-region.h b/include/linux/fpga/fpga-region.h index 27cb706275dba..d712344fd00a7 100644 --- a/include/linux/fpga/fpga-region.h +++ b/include/linux/fpga/fpga-region.h @@ -7,6 +7,20 @@ #include #include +struct fpga_region; + +/** + * struct fpga_region_ops - ops for low level fpga region drivers + * @get_bridges: optional function to get bridges to a list + * + * fpga_region_ops are the low level functions implemented by a specific + * fpga region driver. The optional ones are tested for NULL before being + * called, so leaving them out is fine. + */ +struct fpga_region_ops { + int (*get_bridges)(struct fpga_region *region); +}; + /** * struct fpga_region - FPGA Region structure * @dev: FPGA Region device @@ -16,7 +30,7 @@ * @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 + * @rops: optional pointer to struct for fpga region ops */ struct fpga_region { struct device dev; @@ -26,7 +40,7 @@ struct fpga_region { struct fpga_image_info *info; struct fpga_compat_id *compat_id; void *priv; - int (*get_bridges)(struct fpga_region *region); + const struct fpga_region_ops *rops; }; #define to_fpga_region(d) container_of(d, struct fpga_region, dev) @@ -39,13 +53,13 @@ int fpga_region_program_fpga(struct fpga_region *region); struct fpga_region *fpga_region_create(struct device *dev, struct fpga_manager *mgr, - int (*get_bridges)(struct fpga_region *)); + const struct fpga_region_ops *rops); void fpga_region_free(struct fpga_region *region); int fpga_region_register(struct fpga_region *region); void fpga_region_unregister(struct fpga_region *region); struct fpga_region *devm_fpga_region_create(struct device *dev, struct fpga_manager *mgr, - int (*get_bridges)(struct fpga_region *)); + const struct fpga_region_ops *rops); #endif /* _FPGA_REGION_H */ From patchwork Fri Jul 9 13:42:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12367397 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E81F9C07E99 for ; Fri, 9 Jul 2021 13:42:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D034F6135C for ; Fri, 9 Jul 2021 13:42:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231932AbhGINph (ORCPT ); Fri, 9 Jul 2021 09:45:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:53218 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231936AbhGINph (ORCPT ); Fri, 9 Jul 2021 09:45:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625838173; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UjO7PzMYDwKqWrTVmLCQJSFoOel7Kb6tJJsCfZrgkBA=; b=HozXq1XpWK0ajA2no/hoU0Eh+u1mLa4EW/gvxSjg8WmN7LmgEzgoEIDD0eVtpa7Vy3KEpL 0o8n/lwiuY3KNvm3uuWuecPMDtLGgim7su/+vqkPFyWwqKm1QGNePLZpDMjeAbYG8xQ47x ZzWvmKuVYcCZIAGgaBpWjBRIrDU4T74= Received: from mail-ot1-f71.google.com (mail-ot1-f71.google.com [209.85.210.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-243-7pTV36HOMWywn6s_P2HYzQ-1; Fri, 09 Jul 2021 09:42:52 -0400 X-MC-Unique: 7pTV36HOMWywn6s_P2HYzQ-1 Received: by mail-ot1-f71.google.com with SMTP id c3-20020a9d61430000b0290474c23d2dbcso6128650otk.15 for ; Fri, 09 Jul 2021 06:42:52 -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=UjO7PzMYDwKqWrTVmLCQJSFoOel7Kb6tJJsCfZrgkBA=; b=EfluSnlqf+YCHUokdDJmsLhPKU5VB5EG0uJpUjuhUFOPiJCcGEk+NEXTczDb3OYAqs R25jDSMh3jfn0fkn93sJrpitHT2/ON0oRv8cPkG43GahNMjejiwIxvDq6k6Jcr/csdjm +JE17slGiD5NVEFXI/cEJwacC+VZ+HKNNXLVCO+Bg1kxQhmBvhGImhAGj+4DBn5cRdGa ZO4NzIhL280kkCFne/QS+7Rn4THem+gesPdTH1CmI23i47PSSxTGQnDOulid+DvwnoBI /laLMbwJdc80/P/N5E3dUyGrKwORUtEw2lawb39P4DSnBJJrFeNwrYe27Qy1KXE9KJQ8 CTqg== X-Gm-Message-State: AOAM533Qn4xC0DP+kxGfZqVWKKBc0fITfDD+ZpZSDYGenLLUXxps4uif PHkHLVzYzcmYqbzdkWlyPggU1J9RLBfiD4a2R7LqTO8SLr8gOzp8846sglD+Rt2PHiqPzCrIfX0 jTu3ji7g5Qu+nfiNCp2rdyA== X-Received: by 2002:a9d:dc1:: with SMTP id 59mr27753475ots.246.1625838171651; Fri, 09 Jul 2021 06:42:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyoYUu5i8N6kNaYl0+QLRwq8xSRtvtf+Xpkl+ciyEx190t+NOwxARHU2zfR4lvNfosXtdwtGQ== X-Received: by 2002:a9d:dc1:: with SMTP id 59mr27753455ots.246.1625838171426; Fri, 09 Jul 2021 06:42:51 -0700 (PDT) Received: from localhost.localdomain.com (075-142-250-213.res.spectrum.com. [75.142.250.213]) by smtp.gmail.com with ESMTPSA id j23sm1215948oie.9.2021.07.09.06.42.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jul 2021 06:42:51 -0700 (PDT) From: trix@redhat.com To: mdf@kernel.org, corbet@lwn.net, hao.wu@intel.com Cc: linux-fpga@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Tom Rix Subject: [PATCH v2 2/4] fpga: region: introduce compat_id_show op Date: Fri, 9 Jul 2021 06:42:27 -0700 Message-Id: <20210709134229.2510349-4-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210709134229.2510349-1-trix@redhat.com> References: <20210709134229.2510349-1-trix@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org From: Tom Rix The sysfs reported value for compat_id is implementation dependent. So add an optional op to fpga_region_ops to allow an implementation to override the default. Signed-off-by: Tom Rix --- drivers/fpga/fpga-region.c | 3 +++ include/linux/fpga/fpga-region.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/drivers/fpga/fpga-region.c b/drivers/fpga/fpga-region.c index dfa35c2dc2720..864dd4f290e3b 100644 --- a/drivers/fpga/fpga-region.c +++ b/drivers/fpga/fpga-region.c @@ -169,6 +169,9 @@ static ssize_t compat_id_show(struct device *dev, { struct fpga_region *region = to_fpga_region(dev); + if (region->rops && region->rops->compat_id_show) + return region->rops->compat_id_show(region, buf); + if (!region->compat_id) return -ENOENT; diff --git a/include/linux/fpga/fpga-region.h b/include/linux/fpga/fpga-region.h index d712344fd00a7..236d3819f1c13 100644 --- a/include/linux/fpga/fpga-region.h +++ b/include/linux/fpga/fpga-region.h @@ -12,6 +12,7 @@ struct fpga_region; /** * struct fpga_region_ops - ops for low level fpga region drivers * @get_bridges: optional function to get bridges to a list + * @compat_id_show: optional function emit to sysfs a compatible id * * fpga_region_ops are the low level functions implemented by a specific * fpga region driver. The optional ones are tested for NULL before being @@ -19,6 +20,7 @@ struct fpga_region; */ struct fpga_region_ops { int (*get_bridges)(struct fpga_region *region); + ssize_t (*compat_id_show)(struct fpga_region *region, char *buf); }; /** From patchwork Fri Jul 9 13:42:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12367399 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F39EC07E9C for ; Fri, 9 Jul 2021 13:43:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4C2686135C for ; Fri, 9 Jul 2021 13:43:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232029AbhGINpo (ORCPT ); Fri, 9 Jul 2021 09:45:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:29469 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232009AbhGINpk (ORCPT ); Fri, 9 Jul 2021 09:45:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625838177; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8wz+VSo4V9K18GbntS6U5gCGz01NIx30Fco4WkjLLzY=; b=AQuOhYOMxoKjq3Jv+ETM0VluDGglm1ZczPsQeDSSoT4Pd2n+qfRFNJwDsjBGSbbE0/FaXI VZOwxCBJPJq7THzbvheWU1Mu0QcbcGCh06QKuUHnJ790PZAB8BWEL/mqiQLjg+vcT10f6q 0bd/WVoJ+JA76sj+UoFe4lhO5i4hLsg= Received: from mail-oo1-f71.google.com (mail-oo1-f71.google.com [209.85.161.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-188--yZszxaXMH6t0r8wu-2VOg-1; Fri, 09 Jul 2021 09:42:55 -0400 X-MC-Unique: -yZszxaXMH6t0r8wu-2VOg-1 Received: by mail-oo1-f71.google.com with SMTP id o186-20020a4a2cc30000b029025bea4a7246so2748649ooo.8 for ; Fri, 09 Jul 2021 06:42:55 -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=8wz+VSo4V9K18GbntS6U5gCGz01NIx30Fco4WkjLLzY=; b=louyv3DgBsnuk7kwkhnILkVYRJ7iWIAF8vgnninQd5iwRenKEgKYTaCbAXBOHAD1Kj c3wGOUuTn4srda+mdLQQl8mv30D34ex2qlm4q5IeWpnvkxVMdaBxlYdcpjU7hcazZZci 9Es6tzXleAZMtaL8XHLMwYUeYvN/6lNY7nHaNu3EDrxztMstLF0gN8lrurL8cBzVBwt6 AU1MmUVwgT6Auqzvr8z/+l1uWRloDKLe1hnyRUWaGjs10UXcsSK1HukRc144W7JiIfcN fwGgysHf1ZQqco9XnJyIYKd2LNHqlbPL6lFaQLliyHHqaX0eEGa4g22Nr9NEGmeZ3aMT t4cA== X-Gm-Message-State: AOAM532pArQrqEV37soB2XItD+h6oahvVg7yxh++c01RCfLVjbX+cGyX Y6QaqDIUY9Know9/4yJVBb83F9QrEnhzHAx1346nf/ReXL1+PkBtoJqGlpw7DWl/qOThk04GT5d vbcofXvWzG5dYBT3gGpIbrw== X-Received: by 2002:a05:6830:1bd8:: with SMTP id v24mr28542668ota.343.1625838175131; Fri, 09 Jul 2021 06:42:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyct9gWfuz8J4WdA0JiUc5G3he1tUaqh++CoaPW1Hq4K8Vh7x7DTNLAC9435HjMvp1BII3xog== X-Received: by 2002:a05:6830:1bd8:: with SMTP id v24mr28542648ota.343.1625838174975; Fri, 09 Jul 2021 06:42:54 -0700 (PDT) Received: from localhost.localdomain.com (075-142-250-213.res.spectrum.com. [75.142.250.213]) by smtp.gmail.com with ESMTPSA id j23sm1215948oie.9.2021.07.09.06.42.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jul 2021 06:42:54 -0700 (PDT) From: trix@redhat.com To: mdf@kernel.org, corbet@lwn.net, hao.wu@intel.com Cc: linux-fpga@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Tom Rix Subject: [PATCH v2 3/4] fpga: dfl: implement the compat_id_show region op Date: Fri, 9 Jul 2021 06:42:28 -0700 Message-Id: <20210709134229.2510349-5-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210709134229.2510349-1-trix@redhat.com> References: <20210709134229.2510349-1-trix@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org From: Tom Rix Make sure dfl will work as previously when compat_id is removed from struct fpga_manager. Store and pass the compat_id values internal to dfl. Signed-off-by: Tom Rix Reported-by: kernel test robot --- drivers/fpga/dfl-fme-mgr.c | 16 +++++++++++++--- drivers/fpga/dfl-fme-region.c | 14 ++++++++++++++ drivers/fpga/dfl.h | 14 ++++++++++++++ 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/drivers/fpga/dfl-fme-mgr.c b/drivers/fpga/dfl-fme-mgr.c index d5861d13b3069..cd0b9157ea6e5 100644 --- a/drivers/fpga/dfl-fme-mgr.c +++ b/drivers/fpga/dfl-fme-mgr.c @@ -22,6 +22,7 @@ #include #include +#include "dfl.h" #include "dfl-fme-pr.h" /* FME Partial Reconfiguration Sub Feature Register Set */ @@ -70,6 +71,7 @@ struct fme_mgr_priv { void __iomem *ioaddr; u64 pr_error; + struct dfl_compat_id compat_id; }; static u64 pr_error_to_mgr_status(u64 err) @@ -272,13 +274,21 @@ static const struct fpga_manager_ops fme_mgr_ops = { .status = fme_mgr_status, }; -static void fme_mgr_get_compat_id(void __iomem *fme_pr, - struct fpga_compat_id *id) +static void _fme_mgr_get_compat_id(void __iomem *fme_pr, + struct dfl_compat_id *id) { id->id_l = readq(fme_pr + FME_PR_INTFC_ID_L); id->id_h = readq(fme_pr + FME_PR_INTFC_ID_H); } +void fme_mgr_get_compat_id(struct fpga_manager *mgr, + struct dfl_compat_id *id) +{ + struct fme_mgr_priv *priv = mgr->priv; + *id = priv->compat_id; +} +EXPORT_SYMBOL_GPL(fme_mgr_get_compat_id); + static int fme_mgr_probe(struct platform_device *pdev) { struct dfl_fme_mgr_pdata *pdata = dev_get_platdata(&pdev->dev); @@ -306,7 +316,7 @@ static int fme_mgr_probe(struct platform_device *pdev) if (!compat_id) return -ENOMEM; - fme_mgr_get_compat_id(priv->ioaddr, compat_id); + _fme_mgr_get_compat_id(priv->ioaddr, &priv->compat_id); mgr = devm_fpga_mgr_create(dev, "DFL FME FPGA Manager", &fme_mgr_ops, priv); diff --git a/drivers/fpga/dfl-fme-region.c b/drivers/fpga/dfl-fme-region.c index ca7277d3d30a9..d21eacbf2469f 100644 --- a/drivers/fpga/dfl-fme-region.c +++ b/drivers/fpga/dfl-fme-region.c @@ -17,6 +17,7 @@ #include #include +#include "dfl.h" #include "dfl-fme-pr.h" static int fme_region_get_bridges(struct fpga_region *region) @@ -27,8 +28,21 @@ static int fme_region_get_bridges(struct fpga_region *region) return fpga_bridge_get_to_list(dev, region->info, ®ion->bridge_list); } +static ssize_t fme_region_compat_id_show(struct fpga_region *region, char *buf) +{ + struct fpga_manager *mgr = region->mgr; + struct dfl_compat_id compat_id; + + fme_mgr_get_compat_id(mgr, &compat_id); + + return sysfs_emit(buf, "%016llx%016llx\n", + (unsigned long long)compat_id.id_h, + (unsigned long long)compat_id.id_l); +} + static const struct fpga_region_ops fme_fpga_region_ops = { .get_bridges = fme_region_get_bridges, + .compat_id_show = fme_region_compat_id_show, }; static int fme_region_probe(struct platform_device *pdev) diff --git a/drivers/fpga/dfl.h b/drivers/fpga/dfl.h index 2b82c96ba56c7..a83fd11b390fc 100644 --- a/drivers/fpga/dfl.h +++ b/drivers/fpga/dfl.h @@ -169,6 +169,20 @@ #define PORT_UINT_CAP_INT_NUM GENMASK_ULL(11, 0) /* Interrupts num */ #define PORT_UINT_CAP_FST_VECT GENMASK_ULL(23, 12) /* First Vector */ +/** + * struct dfl_compat_id - id for compatibility check + * + * @id_h: high 64bit of the compat_id + * @id_l: low 64bit of the compat_id + */ +struct dfl_compat_id { + u64 id_h; + u64 id_l; +}; + +void fme_mgr_get_compat_id(struct fpga_manager *mgr, + struct dfl_compat_id *id); + /** * struct dfl_fpga_port_ops - port ops * From patchwork Fri Jul 9 13:42:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12367401 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B49BC07E9E for ; Fri, 9 Jul 2021 13:43:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E555C61374 for ; Fri, 9 Jul 2021 13:43:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232023AbhGINpo (ORCPT ); Fri, 9 Jul 2021 09:45:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58085 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232051AbhGINpo (ORCPT ); Fri, 9 Jul 2021 09:45:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625838180; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KlPPUF0Gcbw6/yHTlRqjYQVdox+0fqPhBKj6QGPVVk8=; b=OcSMGlgjUbPa4vWWHNuymXlVMi1LmD6xbrzlNI+0aa9mQE9Jl4fc2O4v/sc4YCjqPOdTzA hYlpCjuuCiu4VPp8KRtvL17r8IMmiWb+0s8tHIWQf+zwXYZohxMnBI1CZmdNQbtOJwxTKf 9u7RFcSQ8hXI5rak3ZOMZfkwDpKY2FM= Received: from mail-oi1-f200.google.com (mail-oi1-f200.google.com [209.85.167.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-277-et6x_6HhMF2NEtvcrZK8Nw-1; Fri, 09 Jul 2021 09:42:58 -0400 X-MC-Unique: et6x_6HhMF2NEtvcrZK8Nw-1 Received: by mail-oi1-f200.google.com with SMTP id l189-20020acabbc60000b02901f566a77bb8so6693955oif.7 for ; Fri, 09 Jul 2021 06:42:58 -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=KlPPUF0Gcbw6/yHTlRqjYQVdox+0fqPhBKj6QGPVVk8=; b=sWBGujhu17J0tQdMTjTnnc4uoigdsPmwZa6tHj1V/0V8NwOMLzRNM0uCLsWR/30nq+ HEQVAZb8llgJxxhMbfJaWbiaTkI/D+5oUeUVYw2ymN9OqhYWsRlQ6hgjgrKEYjLpYWn2 s1b9cDu7jU44qmK+KCYImDLgRKkEApbyxEwTBs14FL/ky/xWtm5vetEwUDGRNE/NCbOf 7f6/n6Cy+COYSoXAHLwttj/M7zQAmzJqXIsZKspjb4wTNxtT3N4lb9AGCeohkWiGIh3S pCI20KqDjliS8U81U66ojtQdj2S25J7whKhCjwnXiYco8cX/jaMjCWxdLiR9U4IAF4CL JK3g== X-Gm-Message-State: AOAM530Is+5dP1x2wr3uRVrwQRITxQCNdCgllFrAtzsrUx2AD/blRONT PO1GZQ8fVhGEJiBfjRWkjQVe7FtSsx+//NwAoj9fTH8CBXcpis7jgVo20mkbuJmSOGGzNyz12es wjSfzqfstw8DKe77wtAumiQ== X-Received: by 2002:a05:6830:916:: with SMTP id v22mr25514349ott.201.1625838178195; Fri, 09 Jul 2021 06:42:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZB10we+gSjX2AbpriYStSZIsyFAqiV/1xYA1P7bwk1YCEK7j4xSxMnm+CRKGwJ5ih2KGX9Q== X-Received: by 2002:a05:6830:916:: with SMTP id v22mr25514334ott.201.1625838178022; Fri, 09 Jul 2021 06:42:58 -0700 (PDT) Received: from localhost.localdomain.com (075-142-250-213.res.spectrum.com. [75.142.250.213]) by smtp.gmail.com with ESMTPSA id j23sm1215948oie.9.2021.07.09.06.42.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jul 2021 06:42:57 -0700 (PDT) From: trix@redhat.com To: mdf@kernel.org, corbet@lwn.net, hao.wu@intel.com Cc: linux-fpga@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Tom Rix Subject: [PATCH v2 4/4] fpga: remove compat_id from fpga_manager and fpga_region Date: Fri, 9 Jul 2021 06:42:29 -0700 Message-Id: <20210709134229.2510349-6-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210709134229.2510349-1-trix@redhat.com> References: <20210709134229.2510349-1-trix@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org From: Tom Rix compat_id is implementation specific. So the data should be stored at the implemeation layer, not the infrastructure layer. Remove the compat_id elements and supporting code. Printing out the compat_id is done with the fpga_region compat_id_show() op. Signed-off-by: Tom Rix --- drivers/fpga/dfl-fme-mgr.c | 7 ------- drivers/fpga/dfl-fme-region.c | 1 - drivers/fpga/fpga-region.c | 7 +------ include/linux/fpga/fpga-mgr.h | 13 ------------- include/linux/fpga/fpga-region.h | 2 -- 5 files changed, 1 insertion(+), 29 deletions(-) diff --git a/drivers/fpga/dfl-fme-mgr.c b/drivers/fpga/dfl-fme-mgr.c index cd0b9157ea6e5..8c5423eeffe75 100644 --- a/drivers/fpga/dfl-fme-mgr.c +++ b/drivers/fpga/dfl-fme-mgr.c @@ -292,7 +292,6 @@ EXPORT_SYMBOL_GPL(fme_mgr_get_compat_id); static int fme_mgr_probe(struct platform_device *pdev) { struct dfl_fme_mgr_pdata *pdata = dev_get_platdata(&pdev->dev); - struct fpga_compat_id *compat_id; struct device *dev = &pdev->dev; struct fme_mgr_priv *priv; struct fpga_manager *mgr; @@ -312,10 +311,6 @@ static int fme_mgr_probe(struct platform_device *pdev) return PTR_ERR(priv->ioaddr); } - compat_id = devm_kzalloc(dev, sizeof(*compat_id), GFP_KERNEL); - if (!compat_id) - return -ENOMEM; - _fme_mgr_get_compat_id(priv->ioaddr, &priv->compat_id); mgr = devm_fpga_mgr_create(dev, "DFL FME FPGA Manager", @@ -323,8 +318,6 @@ static int fme_mgr_probe(struct platform_device *pdev) if (!mgr) return -ENOMEM; - mgr->compat_id = compat_id; - return devm_fpga_mgr_register(dev, mgr); } diff --git a/drivers/fpga/dfl-fme-region.c b/drivers/fpga/dfl-fme-region.c index d21eacbf2469f..be1d57ee37666 100644 --- a/drivers/fpga/dfl-fme-region.c +++ b/drivers/fpga/dfl-fme-region.c @@ -64,7 +64,6 @@ static int fme_region_probe(struct platform_device *pdev) } region->priv = pdata; - region->compat_id = mgr->compat_id; platform_set_drvdata(pdev, region); ret = fpga_region_register(region); diff --git a/drivers/fpga/fpga-region.c b/drivers/fpga/fpga-region.c index 864dd4f290e3b..b08d3914716f0 100644 --- a/drivers/fpga/fpga-region.c +++ b/drivers/fpga/fpga-region.c @@ -172,12 +172,7 @@ static ssize_t compat_id_show(struct device *dev, if (region->rops && region->rops->compat_id_show) return region->rops->compat_id_show(region, buf); - 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); + return -ENOENT; } static DEVICE_ATTR_RO(compat_id); diff --git a/include/linux/fpga/fpga-mgr.h b/include/linux/fpga/fpga-mgr.h index ec2cd8bfceb00..ebdea215a8643 100644 --- a/include/linux/fpga/fpga-mgr.h +++ b/include/linux/fpga/fpga-mgr.h @@ -143,24 +143,12 @@ struct fpga_manager_ops { #define FPGA_MGR_STATUS_IP_PROTOCOL_ERR BIT(3) #define FPGA_MGR_STATUS_FIFO_OVERFLOW_ERR BIT(4) -/** - * struct fpga_compat_id - id for compatibility check - * - * @id_h: high 64bit of the compat_id - * @id_l: low 64bit of the compat_id - */ -struct fpga_compat_id { - u64 id_h; - u64 id_l; -}; - /** * struct fpga_manager - fpga manager structure * @name: name of low level fpga manager * @dev: fpga manager device * @ref_mutex: only allows one reference to fpga manager * @state: state of fpga manager - * @compat_id: FPGA manager id for compatibility check. * @mops: pointer to struct of fpga manager ops * @priv: low level driver private date */ @@ -169,7 +157,6 @@ struct fpga_manager { struct device dev; struct mutex ref_mutex; enum fpga_mgr_states state; - struct fpga_compat_id *compat_id; const struct fpga_manager_ops *mops; void *priv; }; diff --git a/include/linux/fpga/fpga-region.h b/include/linux/fpga/fpga-region.h index 236d3819f1c13..afc79784b2823 100644 --- a/include/linux/fpga/fpga-region.h +++ b/include/linux/fpga/fpga-region.h @@ -30,7 +30,6 @@ struct fpga_region_ops { * @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 * @rops: optional pointer to struct for fpga region ops */ @@ -40,7 +39,6 @@ struct fpga_region { struct list_head bridge_list; struct fpga_manager *mgr; struct fpga_image_info *info; - struct fpga_compat_id *compat_id; void *priv; const struct fpga_region_ops *rops; };