Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2542720pxp; Sun, 13 Mar 2022 22:07:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywacSbj+JnPXL4n+cVgyQqPWb6msJZqibfyhWrRr1OlL1+7BnZ05sA781bCJOujYP1/34h X-Received: by 2002:a17:906:4cc7:b0:6d0:7efb:49f with SMTP id q7-20020a1709064cc700b006d07efb049fmr16862500ejt.639.1647234436014; Sun, 13 Mar 2022 22:07:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647234436; cv=none; d=google.com; s=arc-20160816; b=jjNlMtpisrllClOaU9TCTAhs9An71sahkL5XZTesPplv8Tg4aFvISepfbhpUClRSSE yMquNTexDfLOYTh2zTaVBCsz4HALSjXxJAUkN7BLNmZz9patfd6VUXUYQCk7oys79g2/ JMndXEfIhH1TQlZjNVpe45BQ2hTdlDAHqgDWXklV4goWJVgfdoxSq8H8xTPFgx8N7u2k 11mDtfZ/J0CPWnyll7Z6O34Y42zklm2FonECGvL9JyS3p53UXA+VTeklc55fOOJvAyKU IsNfHTp6a6ASQW8bgWSxsRsczAMXIASZeoHKgG6bLvbk0iXQaAAXzestP7/ymIK7RP4C vBSQ== 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=om9kPPPrXwRx/ok09WbO1iOOb60uxSKsF4Qk3Y0aVG8=; b=X8P8njSuWUed0UfwOnO1H6RVG6ar/t5d+8p6H55QDOv7LLKAFAdTExd9o1wtxCHfqc 8s1a3pjktLga4Uxs8M+kxlQc2jMyVCTw3nc8qLQDX+JoXtAr0b82P0owsG9x7+qy8mks ohiFaoF75FMzluO6E5J1gQkCdf+S0v39bNBBZ3bNPah8AedESqjxZ0HNMZhRM3NBnJDr QTing5PkRQ8BvtDKPijYLyWCYh6ZkkXyFtBNNLYRxlJ9SxYqHZAx8bkXEQhHTVosqowM cYLWobmNI0W6Pr0oQPawxiOcA4FC/NZqkN3oJqcZeqg1wWkqicE7CZ+T+oWcBz7mSS3M kv4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DGRwBe+t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k6-20020a170906054600b006a79e13f94esi8116994eja.294.2022.03.13.22.06.47; Sun, 13 Mar 2022 22:07:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DGRwBe+t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234442AbiCMK7s (ORCPT + 99 others); Sun, 13 Mar 2022 06:59:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235020AbiCMK63 (ORCPT ); Sun, 13 Mar 2022 06:58:29 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9C1117776D; Sun, 13 Mar 2022 03:57:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1647169041; x=1678705041; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LkGpYCVnDBt3WyXwks8kIFpgzT6/MDg8eLb8oYB0Lkk=; b=DGRwBe+t554g7D9ng6nIKhhk12yjTLFL8PkAD+R8XhUkzeOJ4jsvRzvd fMW0UAR7ZXazkrY0SoKNqpvVarpvYoOwB87buyu5gbs0uBqnT6Fedzm9d 1fDrkC2MFxUPUXG32otFrmNA4uMtXsj8cesDDg7Yrzwpj9yUqbDIiehe2 6kf6h8rE/wp1ttS4jur/700H5+6jQ5zy02An5aM9Mvv6+EaRTdhuilT/2 /Xy25rLc+JJ7SyK98ncWqtnz9uoYrVzTXXUhicUWtLJu8/IhjP/uab++x O4nnor+I2sdstJFEU+VePimLehcaaLHHOJWD8Hp/vVlYExLOhkN9cNS1T Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10284"; a="319086331" X-IronPort-AV: E=Sophos;i="5.90,178,1643702400"; d="scan'208";a="319086331" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2022 03:56:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,178,1643702400"; d="scan'208";a="713380333" Received: from unknown (HELO localhost.localdomain.sh.intel.com) ([10.238.175.107]) by orsmga005.jf.intel.com with ESMTP; 13 Mar 2022 03:56:09 -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 Cc: corbet@lwn.net, Tianfei zhang Subject: [PATCH v5 4/6] fpga: dfl: configure port access mode for afu connected with port Date: Sun, 13 Mar 2022 06:52:40 -0400 Message-Id: <20220313105242.1567774-5-tianfei.zhang@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220313105242.1567774-1-tianfei.zhang@intel.com> References: <20220313105242.1567774-1-tianfei.zhang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 In legacy model, we should set AfuAccessCtrl (Bit 55) in PORTn_OFFSET register to switch VF and PF for AFU. But in "multiple VFs per PR slot" model, the PF/VF mux hardware unit will statically configure the funciton mapping without set the AfuAccessCtrl by software. This patch check the port status in dfl_fpga_cdev->flags before configure the port access mode. Signed-off-by: Tianfei zhang --- drivers/fpga/dfl.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c index b95b29c5c81d..71e0725b6be0 100644 --- a/drivers/fpga/dfl.c +++ b/drivers/fpga/dfl.c @@ -1666,6 +1666,17 @@ static void config_port_access_mode(struct device *fme_dev, int port_id, #define config_port_vf_mode(dev, id) config_port_access_mode(dev, id, true) #define config_port_pf_mode(dev, id) config_port_access_mode(dev, id, false) +static int dfl_check_port_connect_afu(struct device *dev, u64 flags) +{ + void __iomem *base; + int port; + + base = dfl_get_feature_ioaddr_by_id(dev, PORT_FEATURE_ID_HEADER); + port = FIELD_GET(PORT_CAP_PORT_NUM, readq(base + PORT_HDR_CAP)); + + return flags & dfl_feat_port_connect_afu(port); +} + /** * dfl_fpga_cdev_config_ports_pf - configure ports to PF access mode * @@ -1683,7 +1694,9 @@ void dfl_fpga_cdev_config_ports_pf(struct dfl_fpga_cdev *cdev) if (device_is_registered(&pdata->dev->dev)) continue; - config_port_pf_mode(cdev->fme_dev, pdata->id); + /* configure port access mode for AFU connected to Port device */ + if (dfl_check_port_connect_afu(&pdata->dev->dev, cdev->flags)) + config_port_pf_mode(cdev->fme_dev, pdata->id); } mutex_unlock(&cdev->lock); } @@ -1722,7 +1735,9 @@ int dfl_fpga_cdev_config_ports_vf(struct dfl_fpga_cdev *cdev, int num_vfs) if (device_is_registered(&pdata->dev->dev)) continue; - config_port_vf_mode(cdev->fme_dev, pdata->id); + /* configure port access mode for AFU connected to Port device */ + if (dfl_check_port_connect_afu(&pdata->dev->dev, cdev->flags)) + config_port_vf_mode(cdev->fme_dev, pdata->id); } done: mutex_unlock(&cdev->lock); -- 2.26.2