Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp745347pxp; Fri, 11 Mar 2022 14:02:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJyinM0BZ8eVHlbEpLOivEQw0M44hzJ0gzpeVYWqRa7J8wnhdkbx0SJwDUs3NebNZ7EoqYLB X-Received: by 2002:a17:90b:38c3:b0:1c5:930e:b044 with SMTP id nn3-20020a17090b38c300b001c5930eb044mr2364749pjb.198.1647036129458; Fri, 11 Mar 2022 14:02:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647036129; cv=none; d=google.com; s=arc-20160816; b=FamzBWy8+hNpzpG0F0bRsmKb9Hip2Cr/Z/tVvoVm3Q7TvSBICEIU0UIAEvf9x/ZSDw l5XpbNIOPuE6mOq6zCkBhmNqDnUwd58ClEERwc+7TWni+mlzG/wp+54UgDcYUbhP7iWB mVFUEkX7mPbJo+0xxoVY/cKfl5nVR2LwSHTF0YabwaJ3nkTw3+t++hUV0Us/OCZm9Mfw sWNkXEDN7V2Obm5Fw0OsKQ+lQ4f/38smpFxmdi1n+iy/3D0l1H65dnRIIRheZvP8uXA0 4nY3ScaPMLDcUQnxTkttB8dqZI6tVsu6pu6y8Sdkr62Utx2wvEx96PgqZH2njBFLmn2R j5lA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=LUSMJZaSCOInms14RSkZuv1490JYpoNfCDuDCVEa3X4=; b=c5VvGNIteLvtnnaaeAEBSFIziwWeh8CT/HDcHXXqW3L0Vsh+WQYlnVxSKdG3GpGedA 3vt/1lT00mV5nlzxrDrb9elvYCJ3B7SD/3wMXMl+Xk10ixitc7+syU4wKyK1kvak2+lA vaYG9RTGWKmy5W8AcUWSG4bA8brhSDzKh1ZmRmcYuh+BgdYgzl/XTrO7H5+uJu/xUFS2 rtpoye4pxhU67X9hBphbRFP060SUFgMUPpR4tZBR4kM+kJGUApYDpJmZHiE4ZQWB8BHb sVNEA4Zksk8rjSaozSa9xhgNf0TMqBelxbrP2sSMQZ+8KorKehZOaBbGq1P3iw+jXzsI XCog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EYtDVx1l; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id c15-20020a170903234f00b00151de413311si10289394plh.67.2022.03.11.14.02.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 14:02:09 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EYtDVx1l; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 0EEEF21273; Fri, 11 Mar 2022 13:17:32 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345540AbiCKCPq (ORCPT + 99 others); Thu, 10 Mar 2022 21:15:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233354AbiCKCPo (ORCPT ); Thu, 10 Mar 2022 21:15:44 -0500 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC0C8C5DA9; Thu, 10 Mar 2022 18:14:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646964883; x=1678500883; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Dv5GNx9VK3y1DpDwUXAucqtut9NvxauOUvgUnuU3e1w=; b=EYtDVx1lbhYHY6uz750EBobkU1fo0j6iwMG8FC4w+tHDrVUR2nRfnxW/ XOMacHwf62YV2drKae9vwIeINwbe2H76CZiA3QDMQBkG6oj4XrZEPGWSV 7VtkYVmOf0Wy/MZglERq4dbpQaPmZ7BzuP1XjhTsr25jHcbGgG8ZfwI2u 0Iq3z5xdHkwH2ub6QxWpHMMJRjoTXP7kmetM7tRwVDD5kzEA0F1+EdEdi JrIEAvC5PcTew/ZhLLu70POxb+ezHxl7mBRylD9QUZeqLqEORsy8MakPL gaqQ6L07FM+MT71sES3aHL0kDv9cYPJ+nbHN8NUKF+wQSA76vHILgnxj8 A==; X-IronPort-AV: E=McAfee;i="6200,9189,10282"; a="255667100" X-IronPort-AV: E=Sophos;i="5.90,172,1643702400"; d="scan'208";a="255667100" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2022 18:14:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,172,1643702400"; d="scan'208";a="548318297" Received: from unknown (HELO localhost.localdomain.sh.intel.com) ([10.238.175.107]) by fmsmga007.fm.intel.com with ESMTP; 10 Mar 2022 18:14:38 -0800 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 v3] fpga: dfl: check feature type before parse irq info Date: Thu, 10 Mar 2022 21:11:21 -0500 Message-Id: <20220311021121.1504442-1-tianfei.zhang@intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.4 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 The feature ID of "Port User Interrupt" and the "PMCI Subsystem" are identical, 0x12, but one is for FME, other is for Port. It should check the feature type While parsing the irq info in parse_feature_irqs(). --- v3: Remove "Fixes" in commit log with Hao's comment, this is a extension not a bug fix. v2: add DFL Feature ID Registry in documentation. Signed-off-by: Tianfei Zhang --- Documentation/fpga/dfl.rst | 11 +++++++++++ drivers/fpga/dfl.c | 38 ++++++++++++++++++++++---------------- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/Documentation/fpga/dfl.rst b/Documentation/fpga/dfl.rst index ef9eec71f6f3..14f342bb85e4 100644 --- a/Documentation/fpga/dfl.rst +++ b/Documentation/fpga/dfl.rst @@ -502,6 +502,17 @@ Developer only needs to provide a sub feature driver with matched feature id. FME Partial Reconfiguration Sub Feature driver (see drivers/fpga/dfl-fme-pr.c) could be a reference. +Individual DFL drivers are bound DFL devices based on Feature Type and Feature ID. +The definition of Feature Type and Feature ID can be found: + +https://github.com/OPAE/linux-dfl-feature-id/blob/master/dfl-feature-ids.rst + +If you want to add a new feature ID for FPGA DFL feature device, we recommend that +use a pull request to reserve a feature ID for DFL. Here is the DFL Feature ID +Registry: + +https://github.com/OPAE/linux-dfl-feature-id + Location of DFLs on a PCI Device ================================ The original method for finding a DFL on a PCI device assumed the start of the diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c index 599bb21d86af..6bff39ff21a0 100644 --- a/drivers/fpga/dfl.c +++ b/drivers/fpga/dfl.c @@ -940,9 +940,12 @@ static int parse_feature_irqs(struct build_feature_devs_info *binfo, { void __iomem *base = binfo->ioaddr + ofst; unsigned int i, ibase, inr = 0; + enum dfl_id_type type; int virq; u64 v; + type = feature_dev_id_type(binfo->feature_dev); + /* * Ideally DFL framework should only read info from DFL header, but * current version DFL only provides mmio resources information for @@ -957,22 +960,25 @@ static int parse_feature_irqs(struct build_feature_devs_info *binfo, * code will be added. But in order to be compatible to old version * DFL, the driver may still fall back to these quirks. */ - switch (fid) { - case PORT_FEATURE_ID_UINT: - v = readq(base + PORT_UINT_CAP); - ibase = FIELD_GET(PORT_UINT_CAP_FST_VECT, v); - inr = FIELD_GET(PORT_UINT_CAP_INT_NUM, v); - break; - case PORT_FEATURE_ID_ERROR: - v = readq(base + PORT_ERROR_CAP); - ibase = FIELD_GET(PORT_ERROR_CAP_INT_VECT, v); - inr = FIELD_GET(PORT_ERROR_CAP_SUPP_INT, v); - break; - case FME_FEATURE_ID_GLOBAL_ERR: - v = readq(base + FME_ERROR_CAP); - ibase = FIELD_GET(FME_ERROR_CAP_INT_VECT, v); - inr = FIELD_GET(FME_ERROR_CAP_SUPP_INT, v); - break; + if (type == PORT_ID) { + switch (fid) { + case PORT_FEATURE_ID_UINT: + v = readq(base + PORT_UINT_CAP); + ibase = FIELD_GET(PORT_UINT_CAP_FST_VECT, v); + inr = FIELD_GET(PORT_UINT_CAP_INT_NUM, v); + break; + case PORT_FEATURE_ID_ERROR: + v = readq(base + PORT_ERROR_CAP); + ibase = FIELD_GET(PORT_ERROR_CAP_INT_VECT, v); + inr = FIELD_GET(PORT_ERROR_CAP_SUPP_INT, v); + break; + } + } else if (type == FME_ID) { + if (fid == FME_FEATURE_ID_GLOBAL_ERR) { + v = readq(base + FME_ERROR_CAP); + ibase = FIELD_GET(FME_ERROR_CAP_INT_VECT, v); + inr = FIELD_GET(FME_ERROR_CAP_SUPP_INT, v); + } } if (!inr) { -- 2.26.2