Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp962674pxp; Wed, 16 Mar 2022 22:46:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKuuIKF2FPPo0dGR35/lrzajsQbfFjlCtHYsipN3yk10ausYYNR7YMOwmxnbMBmhaRySEo X-Received: by 2002:a17:90a:ea83:b0:1bc:2cb6:78e0 with SMTP id h3-20020a17090aea8300b001bc2cb678e0mr3483659pjz.20.1647495990877; Wed, 16 Mar 2022 22:46:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647495990; cv=none; d=google.com; s=arc-20160816; b=M+sbv7iG7dldDjQtlminMSM2JJE1Ti4s9oAg8uZRRPM2RD5wDDsRTYz9CH7x6nmnhm RYz76hozXdUYS/4b9gY/Z7xOf265qMqnsyJPPoH9JObuxRyUh/PI28p/3uR361qH841i YzC0ug7lM+c2GtBwUs09W2q/icu/OCMyiNDTg5KW8GXa53do+HzxARZIKx+9TbWYiuaV zBcS4q13MW9hDiyW5V2GQOxmByL8dUqfVyO/XhA+LwXwBiyi10qn20NnBjx09nfwSz8Q cSVwG63/FhAEq0mLSIHFyBvIYZzlPThM3zY+DaxaDe7iwEMXiC4wJGh6syCS22OWScET 37iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Dk/MQsdOMO35Mbsfkqidgy9FKL1at+GO+WWVnhHoXzo=; b=Sa8p3AXYPxxrFnuVsNFuL8OvqKhTw/hafIUVQNdvcYKKyPmXH16gGTeW6IpspkJ572 mV91n3SvhV7etde2KCcVv3mlC5eSrnS8cjkZIItvq1MjJnkqGWdr6ZR1TyHUFDqfAWHz xgtV9eRn0DCbNVpYPBU9sdZEeoD+WqeTKHahL8MTBIIcEum+Dmz2awdVA2789BsKThwT GJF+68L31095MtDP5kFiXZmB9gzDbkAfzCklL/ZvzVZA6nLkhjaJuYK5jRFfF3qePlbQ ih1Xy+3rkUIohdlGI4xFo3Jea0G/H0Pp7HbLMSsuaFB5+kRMUTNrkg3ttzWWTcVAw8eG b1bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ISA3UHjm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id v8-20020a17090331c800b001538b03ac21si3453208ple.210.2022.03.16.22.46.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 22:46:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ISA3UHjm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4B8418B6D2; Wed, 16 Mar 2022 21:41:16 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347479AbiCPHNX (ORCPT + 99 others); Wed, 16 Mar 2022 03:13:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354231AbiCPHMz (ORCPT ); Wed, 16 Mar 2022 03:12:55 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C09A5DE54; Wed, 16 Mar 2022 00:11:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1647414702; x=1678950702; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BbcJfJHFs7h3DBzP//dTgYkN4sqD2gOtwRAt4y/7sbQ=; b=ISA3UHjm0e4IDet9v7Q7ALfvOPkAdmXpCWfFQBxCUngtvv7m3QTT0qy1 +6w/qWQ/7xtroFC8PPIIABNhJ/xXrrc/NSAsQDdsc7+8mLaOHyy67W5tT P8luulIQRAJ4kzlhzy2Z1dyWF0EIKVg05mUjO3UdxVGBZw0WBAmUfuA66 gILqDZ8vFgunbsDTsE4vGt065XU7sB1oPGW767Vpib9/QvSPRxMOPfNIN obEfxbgf3UUvA9dr9E9ryNecTVpM4Z3M2Rr9FyAzZY+91V5ssDgla6jU4 JB4HZ6miSxQKa1DAAOFZnsH1Fza2BUJNPHFoke8d36U703TRcd2XMqjOL A==; X-IronPort-AV: E=McAfee;i="6200,9189,10286"; a="281289028" X-IronPort-AV: E=Sophos;i="5.90,186,1643702400"; d="scan'208";a="281289028" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Mar 2022 00:11:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,186,1643702400"; d="scan'208";a="646538338" Received: from unknown (HELO localhost.localdomain.sh.intel.com) ([10.238.175.107]) by orsmga004.jf.intel.com with ESMTP; 16 Mar 2022 00:11:38 -0700 From: Tianfei Zhang To: hao.wu@intel.com, trix@redhat.com, mdf@kernel.org, yilun.xu@intel.com, linux-fpga@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, rdunlap@infradead.org Cc: corbet@lwn.net, Tianfei zhang , Matthew Gerlach Subject: [PATCH v6 2/6] fpga: dfl: tracking port conntected with AFU Date: Wed, 16 Mar 2022 03:08:10 -0400 Message-Id: <20220316070814.1916017-3-tianfei.zhang@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220316070814.1916017-1-tianfei.zhang@intel.com> References: <20220316070814.1916017-1-tianfei.zhang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tianfei zhang Introducing flags in dfl_fpga_cdev to track extensions or new features discovered during DFL enumeration. It uses some lowest bits of flags to track the port status which the AFU was connected to port device or not. In legacy model, the AFU was connected to Port device, but in "multiple VFs per PR slot" model, the AFU or PR slot without connected to Port device directly. Signed-off-by: Matthew Gerlach Signed-off-by: Tianfei zhang --- drivers/fpga/dfl.c | 11 ++++++++++- drivers/fpga/dfl.h | 12 ++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c index 599bb21d86af..712c53363fda 100644 --- a/drivers/fpga/dfl.c +++ b/drivers/fpga/dfl.c @@ -1124,8 +1124,10 @@ static void build_info_complete(struct build_feature_devs_info *binfo) static int parse_feature_fiu(struct build_feature_devs_info *binfo, resource_size_t ofst) { + struct dfl_fpga_cdev *cdev = binfo->cdev; int ret = 0; u32 offset; + u32 port; u16 id; u64 v; @@ -1160,8 +1162,15 @@ static int parse_feature_fiu(struct build_feature_devs_info *binfo, v = readq(binfo->ioaddr + NEXT_AFU); offset = FIELD_GET(NEXT_AFU_NEXT_DFH_OFST, v); - if (offset) + if (offset) { + if (dfh_id_to_type(id) == PORT_ID) { + port = FIELD_GET(PORT_CAP_PORT_NUM, + readq(binfo->ioaddr + PORT_HDR_CAP)); + cdev->flags |= dfl_feat_port_connect_afu(port); + } + return parse_feature_afu(binfo, offset); + } dev_dbg(binfo->dev, "No AFUs detected on FIU %d\n", id); diff --git a/drivers/fpga/dfl.h b/drivers/fpga/dfl.h index 1fd493e82dd8..bc56b7e8c01b 100644 --- a/drivers/fpga/dfl.h +++ b/drivers/fpga/dfl.h @@ -461,6 +461,16 @@ int dfl_fpga_enum_info_add_irq(struct dfl_fpga_enum_info *info, unsigned int nr_irqs, int *irq_table); void dfl_fpga_enum_info_free(struct dfl_fpga_enum_info *info); +/* + * Bitfields in flags of dfl_fpga_cdev. + * + * 0 - (DFL_PORT_CONNECT_BITS -1): AFU was connected with Port device. + * DFL_PORT_CONNECT_BITS - 63: reserved. + */ +#define dfl_feat_port_connect_afu(port) (BIT_ULL(port)) +#define DFL_PORT_CONNECT_BITS MAX_DFL_FPGA_PORT_NUM +#define DFL_FEAT_PORT_CONNECT_MASK ((1UL << (DFL_PORT_CONNECT_BITS)) - 1) + /** * struct dfl_fpga_cdev - container device of DFL based FPGA * @@ -470,6 +480,7 @@ void dfl_fpga_enum_info_free(struct dfl_fpga_enum_info *info); * @lock: mutex lock to protect the port device list. * @port_dev_list: list of all port feature devices under this container device. * @released_port_num: released port number under this container device. + * @flags: extensions discovered during DFL enumeration. */ struct dfl_fpga_cdev { struct device *parent; @@ -478,6 +489,7 @@ struct dfl_fpga_cdev { struct mutex lock; struct list_head port_dev_list; int released_port_num; + u64 flags; }; struct dfl_fpga_cdev * -- 2.26.2