From patchwork Fri Sep 22 10:18:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gangurde, Abhijit" X-Patchwork-Id: 143341 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5462462vqi; Fri, 22 Sep 2023 03:33:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHSjxE5+C9IRmuzBD/Pg3fMHT0inurKhoLEgNxRybYD5Y7hLW5dCrXMTe5hh9bYGdB5P9SD X-Received: by 2002:a17:902:ced2:b0:1bd:a42a:215e with SMTP id d18-20020a170902ced200b001bda42a215emr9355023plg.38.1695378820865; Fri, 22 Sep 2023 03:33:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1695378820; cv=pass; d=google.com; s=arc-20160816; b=rD60EEaouk5/39BKFSGa1HLW9+st8lff0A9r45fCyW2/sYCGUPR7JHm9AaPAzk3bmO 27eCFmhQCJUmN8iNKh1o2h4d1O4PohkuO5g1D00TbmN/K1XiYlFmxeeXjOVFh+unoM1x SiVVGCa7P7H4UqxZ/QHyWuj84acWs881S2XZEwVyVWmRZeIwPMC89lElukfnLLRHNBhC +bLyhUp0yoRduzKkt8vI6UTGDUearDLZ9YZRmGJR4NEVOM7teozSwzKslnjJLDmnHNxj siAgYRYh27Cf28gfZLALtB0iIrsE5/LVQOHGqi5gN47LjxQK63Jj/QcCyDyJySgwy6zP Ubjg== ARC-Message-Signature: i=2; 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=lWdFKqdqFvcKr0tggVILraPrUN5NAaGzalvfyAF5imM=; fh=BBcpQBnlfDEdguxJRJNpGATDBGfge68Vcv7Y3ei2uQ4=; b=aoz91GQwbmq9d54dpaKEkBwyFXJ3ht1AfgMxU0/ROMkWo1dEl3/gef3J9+TFlgex8C VacE/Emr9h+Usp1rbE9CMe5tUDCCU4BYRQZIkRxG35IpVMPlaxGUoz2cTsp9IaxAdIgN GqvuKAq2ZlOeSjZ/Hly60IajGAbMBeUq7a+RpIQDGEJl/FSbLUmX6IJJVnTfTfiEwOZH 0n9pwFXMIQSyG0zspeAjeuJoFRMyN+Z/D+cLcHdHA/Uxn0+CBy2g52zN8sPW3I5wwVXI VKe6wUokywjrABGhWT8RBCaJW4F2zYkTUpZM+Hgw2McGdSZp5cOmFgl8z45Nh55OT2KX muSQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=Aewha2pF; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id kz4-20020a170902f9c400b001c20db25108si3353470plb.41.2023.09.22.03.33.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 03:33:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=Aewha2pF; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 4CC8B83CCA44; Fri, 22 Sep 2023 03:21:04 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232789AbjIVKUm (ORCPT + 30 others); Fri, 22 Sep 2023 06:20:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233253AbjIVKUj (ORCPT ); Fri, 22 Sep 2023 06:20:39 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2086.outbound.protection.outlook.com [40.107.244.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82AB594 for ; Fri, 22 Sep 2023 03:20:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=myUA7u9jU/B2Gpdn4xtuRe9+UdA5Ijhn+thC5lR5Xwdt7E5P8tIvwhgn2Sv3UaKzkibIbj9zfw1MMkUAe/KdflLwbjxSGQfRuUcHV53CXT5O6mYNQqr7WZnKOkTtbzz307GLs2VYnfKo/erBSwn2EV1q/xIbFs89jJC8g3ak+8j2gVfF7X6BcYnG09orAzaI3fz4UrcEt6gJanzwTgKrkJvlhjBxUA3X3ZWW49//CxvjDvSpeJy7nImKVvtuJRm+p9/8y5M2AcVjw11WJFud5cLD4k+sVaB/JTTQ/aJyktts82JrLF104cmj4QjxJaDXhjO+uiDbmJhpKv6or2SulA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lWdFKqdqFvcKr0tggVILraPrUN5NAaGzalvfyAF5imM=; b=OWOEkf79BLnxZFLfiudyuF2RrvSbMOzWnZXS5eR9jgCWCvz4qgez6JWdMTSZRtWfYFvWZCaYvThqHwQAALbpJUZXg1tygW5LaqFB3g/E38NKtnlqsmfeBVJD8mKCOfn0Gy4DPlH8IEXTu3e9d8Y84SaojUcKmnVmoY/GxT8nosaD05OF7qHItJ90kEueD3dLLBfUH1AWqFnSWxP9QPb606mlRZPF4Os8AQatxgbk1mdg83FKYs/8gIv9oN3oAuizYW3o9QEW9cy+xZgYBgSEpVSyNCNArsAhitf2uOd36h/29tz/lTHImnn2Z6fqQCEY+qnvuEHylX6Xjp1Ga6mlkA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linuxfoundation.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lWdFKqdqFvcKr0tggVILraPrUN5NAaGzalvfyAF5imM=; b=Aewha2pFMga9jNOB/gYeKlrRZHz3GdULPFCyl1iYvybHd6+PMK0RGq15E+qmOCmo3blM7QIEj9W83XXaR781OI+GWluULEuNyeIrRW5aFn8/X2Q2wF7Phdb/W47wGbtStTyrZ8vKmvfTagL3Deardybv4hP9uRibHrNmQx/yORI= Received: from CYXPR02CA0050.namprd02.prod.outlook.com (2603:10b6:930:cd::10) by MW3PR12MB4428.namprd12.prod.outlook.com (2603:10b6:303:57::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.23; Fri, 22 Sep 2023 10:20:27 +0000 Received: from CY4PEPF0000EE39.namprd03.prod.outlook.com (2603:10b6:930:cd:cafe::5f) by CYXPR02CA0050.outlook.office365.com (2603:10b6:930:cd::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.34 via Frontend Transport; Fri, 22 Sep 2023 10:20:27 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EE39.mail.protection.outlook.com (10.167.242.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6792.20 via Frontend Transport; Fri, 22 Sep 2023 10:20:27 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Fri, 22 Sep 2023 05:20:23 -0500 Received: from xhdipdslab59.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Fri, 22 Sep 2023 05:20:15 -0500 From: Abhijit Gangurde To: , , CC: , , , , , Abhijit Gangurde , Nipun Gupta , "Pieter Jansen van Vuuren" Subject: [PATCH v5 5/5] cdx: add sysfs for subsystem, class and revision Date: Fri, 22 Sep 2023 15:48:28 +0530 Message-ID: <20230922101828.33456-6-abhijit.gangurde@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230922101828.33456-1-abhijit.gangurde@amd.com> References: <20230922101828.33456-1-abhijit.gangurde@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE39:EE_|MW3PR12MB4428:EE_ X-MS-Office365-Filtering-Correlation-Id: d4dcd3c4-e81e-459c-4ce8-08dbbb558acd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7R6rzVhaekV7YotWhunvbH/p15Zu/5Czrf/gl94z+GxS9mz37G1p7xnvMsElrws+z0IoY70RnE5x27AWTR9Vd3BHFTqqYLTRij4C11iGCRxIyIHLibvY3X3jjkpyAZFRI1EoAbybkcNu6QosBRWsN9kwgK5VsCjKyN2OgsGk3qbGz8lFgRfaYRdXsBsh1rDBY5dFx1F4vTF+wwn7ZBEehtGoBiIYrcGcVseEkATFkkRDVT/0dXfCE5/pJYNXtOkbEbZ+AwkChST2O/lPo41IchHu44UPKlQVAtc8e2agqLx7P/str5naj+Nd9/DiExBlPYVBPBGGT8IBHafoohssJCfE9uJDXpSo8ak/n4IpTjLPveSWZO8aBvl82npmr+uQZOJfB07XHwibxl46tz1RUOAJeOvmO55g4FsNBfYEfc6NjB+esSnuqHwCCeE28REYRzxLUq4mXJXhWVh3swDJuJQpYhErzpm80Pv0mYKDiBGE7QCAhtON/4+iNNEtS2jGZzHiuX9OJcT+oahHVxTy27V7O++2YCcpla3CDHKFAmubSneTUjGzf3L8QIGueC1ti/4ZA5gQEZD5qlFUd6P+tVafljeg3H7BGW1d8GXls4oJqDCXTWn9/RdpTlWvtXBlYyJQdz3Vzf+I+V4Aa7MJFTIutjB1V/jFgatSADFq+qdVE2d1xHATivFIacyBw8tVc+Q8IfPMkUy/Q/xndDzGkee7c+em9KqjdG+Fiyh7EzRgkOlHjL1RRRxuWvkAA64UNamoSiwcrUrtkwZWWyD/j/WFvcWwLQyIq1ssUIgr7wvXzAD5+eHZYfaFErvGM59v X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(136003)(396003)(346002)(39860400002)(376002)(82310400011)(1800799009)(186009)(451199024)(230921699003)(46966006)(40470700004)(36840700001)(6666004)(82740400003)(40480700001)(356005)(86362001)(40460700003)(81166007)(2616005)(1076003)(26005)(36756003)(336012)(426003)(83380400001)(110136005)(44832011)(316002)(70206006)(54906003)(70586007)(2906002)(47076005)(36860700001)(8936002)(8676002)(4326008)(41300700001)(30864003)(478600001)(5660300002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2023 10:20:27.7288 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d4dcd3c4-e81e-459c-4ce8-08dbbb558acd X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EE39.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4428 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 22 Sep 2023 03:21:04 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777733542700907421 X-GMAIL-MSGID: 1777733542700907421 CDX controller provides subsystem vendor, subsystem device, class and revision info of the device along with vendor and device ID in native endian format. CDX Bus system uses this information to bind the cdx device to the cdx device driver. Co-developed-by: Puneet Gupta Signed-off-by: Puneet Gupta Co-developed-by: Nipun Gupta Signed-off-by: Nipun Gupta Signed-off-by: Abhijit Gangurde Reviewed-by: Pieter Jansen van Vuuren Tested-by: Nikhil Agarwal --- Changes in v5: - None Changes in v4: - None Changes in v3: - None Changes in v2: - Improve documentation and commit message Documentation/ABI/testing/sysfs-bus-cdx | 45 +++++++++++++++++++++++++ drivers/cdx/cdx.c | 29 +++++++++++++++- drivers/cdx/cdx.h | 8 +++++ drivers/cdx/controller/mcdi_functions.c | 7 ++++ include/linux/cdx/cdx_bus.h | 27 +++++++++++++-- include/linux/mod_devicetable.h | 10 ++++++ scripts/mod/devicetable-offsets.c | 4 +++ scripts/mod/file2alias.c | 8 +++++ 8 files changed, 135 insertions(+), 3 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-bus-cdx b/Documentation/ABI/testing/sysfs-bus-cdx index d25875359741..e71a6daccfbe 100644 --- a/Documentation/ABI/testing/sysfs-bus-cdx +++ b/Documentation/ABI/testing/sysfs-bus-cdx @@ -70,6 +70,36 @@ Description: of a device manufacturer. Combination of Vendor ID and Device ID identifies a device. +What: /sys/bus/cdx/devices/.../subsystem_vendor +Date: July 2023 +Contact: puneet.gupta@amd.com +Description: + Subsystem Vendor ID for this CDX device, in hexadecimal. + Subsystem Vendor ID is 16 bit identifier specific to the + card manufacturer. + +What: /sys/bus/cdx/devices/.../subsystem_device +Date: July 2023 +Contact: puneet.gupta@amd.com +Description: + Subsystem Device ID for this CDX device, in hexadecimal + Subsystem Device ID is 16 bit identifier specific to the + card manufacturer. + +What: /sys/bus/cdx/devices/.../class +Date: July 2023 +Contact: puneet.gupta@amd.com +Description: + This file contains the class of the CDX device, in hexadecimal. + Class is 24 bit identifier specifies the functionality of the device. + +What: /sys/bus/cdx/devices/.../revision +Date: July 2023 +Contact: puneet.gupta@amd.com +Description: + This file contains the revision field of the CDX device, in hexadecimal. + Revision is 8 bit revision identifier of the device. + What: /sys/bus/cdx/devices/.../reset Date: March 2023 Contact: nipun.gupta@amd.com @@ -96,3 +126,18 @@ Description: For example:: # echo 1 > /sys/bus/cdx/devices/.../remove + +What: /sys/bus/cdx/devices/.../modalias +Date: July 2023 +Contact: nipun.gupta@amd.com +Description: + This attribute indicates the CDX ID of the device. + That is in the format: + cdx:vXXXXdXXXXsvXXXXsdXXXXcXXXXXX, + where: + + - vXXXX contains the vendor ID; + - dXXXX contains the device ID; + - svXXXX contains the subsystem vendor ID; + - sdXXXX contains the subsystem device ID; + - cXXXXXX contains the device class. diff --git a/drivers/cdx/cdx.c b/drivers/cdx/cdx.c index 7687b9371210..b7d5e1a3b410 100644 --- a/drivers/cdx/cdx.c +++ b/drivers/cdx/cdx.c @@ -181,7 +181,10 @@ cdx_match_one_device(const struct cdx_device_id *id, { /* Use vendor ID and device ID for matching */ if ((id->vendor == CDX_ANY_ID || id->vendor == dev->vendor) && - (id->device == CDX_ANY_ID || id->device == dev->device)) + (id->device == CDX_ANY_ID || id->device == dev->device) && + (id->subvendor == CDX_ANY_ID || id->subvendor == dev->subsystem_vendor) && + (id->subdevice == CDX_ANY_ID || id->subdevice == dev->subsystem_device) && + !((id->class ^ dev->class) & id->class_mask)) return id; return NULL; } @@ -327,6 +330,10 @@ static DEVICE_ATTR_RO(field) cdx_config_attr(vendor, "0x%04x\n"); cdx_config_attr(device, "0x%04x\n"); +cdx_config_attr(subsystem_vendor, "0x%04x\n"); +cdx_config_attr(subsystem_device, "0x%04x\n"); +cdx_config_attr(revision, "0x%02x\n"); +cdx_config_attr(class, "0x%06x\n"); static ssize_t remove_store(struct device *dev, struct device_attribute *attr, @@ -372,6 +379,17 @@ static ssize_t reset_store(struct device *dev, struct device_attribute *attr, } static DEVICE_ATTR_WO(reset); +static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct cdx_device *cdx_dev = to_cdx_device(dev); + + return sprintf(buf, "cdx:v%04Xd%04Xsv%04Xsd%04Xc%06X\n", cdx_dev->vendor, + cdx_dev->device, cdx_dev->subsystem_vendor, cdx_dev->subsystem_device, + cdx_dev->class); +} +static DEVICE_ATTR_RO(modalias); + static ssize_t driver_override_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) @@ -403,6 +421,11 @@ static struct attribute *cdx_dev_attrs[] = { &dev_attr_reset.attr, &dev_attr_vendor.attr, &dev_attr_device.attr, + &dev_attr_subsystem_vendor.attr, + &dev_attr_subsystem_device.attr, + &dev_attr_class.attr, + &dev_attr_revision.attr, + &dev_attr_modalias.attr, &dev_attr_driver_override.attr, NULL, }; @@ -634,6 +657,10 @@ int cdx_device_add(struct cdx_dev_params *dev_params) cdx_dev->req_id = dev_params->req_id; cdx_dev->vendor = dev_params->vendor; cdx_dev->device = dev_params->device; + cdx_dev->subsystem_vendor = dev_params->subsys_vendor; + cdx_dev->subsystem_device = dev_params->subsys_device; + cdx_dev->class = dev_params->class; + cdx_dev->revision = dev_params->revision; cdx_dev->bus_num = dev_params->bus_num; cdx_dev->dev_num = dev_params->dev_num; cdx_dev->cdx = dev_params->cdx; diff --git a/drivers/cdx/cdx.h b/drivers/cdx/cdx.h index c436ac7ac86f..d17b5a501e8d 100644 --- a/drivers/cdx/cdx.h +++ b/drivers/cdx/cdx.h @@ -16,21 +16,29 @@ * @parent: Associated CDX controller * @vendor: Vendor ID for CDX device * @device: Device ID for CDX device + * @subsys_vendor: Sub vendor ID for CDX device + * @subsys_device: Sub device ID for CDX device * @bus_num: Bus number for this CDX device * @dev_num: Device number for this device * @res: array of MMIO region entries * @res_count: number of valid MMIO regions * @req_id: Requestor ID associated with CDX device + * @class: Class of the CDX Device + * @revision: Revision of the CDX device */ struct cdx_dev_params { struct cdx_controller *cdx; u16 vendor; u16 device; + u16 subsys_vendor; + u16 subsys_device; u8 bus_num; u8 dev_num; struct resource res[MAX_CDX_DEV_RESOURCES]; u8 res_count; u32 req_id; + u32 class; + u8 revision; }; /** diff --git a/drivers/cdx/controller/mcdi_functions.c b/drivers/cdx/controller/mcdi_functions.c index 0e1e35d91242..65dca2aa1d3f 100644 --- a/drivers/cdx/controller/mcdi_functions.c +++ b/drivers/cdx/controller/mcdi_functions.c @@ -120,6 +120,13 @@ int cdx_mcdi_get_dev_config(struct cdx_mcdi *cdx, dev_params->vendor = MCDI_WORD(outbuf, CDX_BUS_GET_DEVICE_CONFIG_OUT_VENDOR_ID); dev_params->device = MCDI_WORD(outbuf, CDX_BUS_GET_DEVICE_CONFIG_OUT_DEVICE_ID); + dev_params->subsys_vendor = MCDI_WORD(outbuf, + CDX_BUS_GET_DEVICE_CONFIG_OUT_SUBSYS_VENDOR_ID); + dev_params->subsys_device = MCDI_WORD(outbuf, + CDX_BUS_GET_DEVICE_CONFIG_OUT_SUBSYS_DEVICE_ID); + dev_params->class = MCDI_DWORD(outbuf, + CDX_BUS_GET_DEVICE_CONFIG_OUT_DEVICE_CLASS) & 0xFFFFFF; + dev_params->revision = MCDI_BYTE(outbuf, CDX_BUS_GET_DEVICE_CONFIG_OUT_DEVICE_REVISION); return 0; } diff --git a/include/linux/cdx/cdx_bus.h b/include/linux/cdx/cdx_bus.h index ac715bc84315..245ef7e26d5d 100644 --- a/include/linux/cdx/cdx_bus.h +++ b/include/linux/cdx/cdx_bus.h @@ -40,6 +40,19 @@ typedef int (*cdx_dev_configure_cb)(struct cdx_controller *cdx, u8 bus_num, u8 dev_num, struct cdx_device_config *dev_config); +/** + * CDX_DEVICE - macro used to describe a specific CDX device + * @vend: the 16 bit CDX Vendor ID + * @dev: the 16 bit CDX Device ID + * + * This macro is used to create a struct cdx_device_id that matches a + * specific device. The subvendor and subdevice fields will be set to + * CDX_ANY_ID. + */ +#define CDX_DEVICE(vend, dev) \ + .vendor = (vend), .device = (dev), \ + .subvendor = CDX_ANY_ID, .subdevice = CDX_ANY_ID + /** * CDX_DEVICE_DRIVER_OVERRIDE - macro used to describe a CDX device with * override_only flags. @@ -48,10 +61,12 @@ typedef int (*cdx_dev_configure_cb)(struct cdx_controller *cdx, * @driver_override: the 32 bit CDX Device override_only * * This macro is used to create a struct cdx_device_id that matches only a - * driver_override device. + * driver_override device. The subvendor and subdevice fields will be set to + * CDX_ANY_ID. */ #define CDX_DEVICE_DRIVER_OVERRIDE(vend, dev, driver_override) \ - .vendor = (vend), .device = (dev), .override_only = (driver_override) + .vendor = (vend), .device = (dev), .subvendor = CDX_ANY_ID,\ + .subdevice = CDX_ANY_ID, .override_only = (driver_override) /** * struct cdx_ops - Callbacks supported by CDX controller. @@ -92,6 +107,10 @@ struct cdx_controller { * @cdx: CDX controller associated with the device * @vendor: Vendor ID for CDX device * @device: Device ID for CDX device + * @subsystem_vendor: Subsystem Vendor ID for CDX device + * @subsystem_device: Subsystem Device ID for CDX device + * @class: Class for the CDX device + * @revision: Revision of the CDX device * @bus_num: Bus number for this CDX device * @dev_num: Device number for this device * @res: array of MMIO region entries @@ -109,6 +128,10 @@ struct cdx_device { struct cdx_controller *cdx; u16 vendor; u16 device; + u16 subsystem_vendor; + u16 subsystem_device; + u32 class; + u8 revision; u8 bus_num; u8 dev_num; struct resource res[MAX_CDX_DEV_RESOURCES]; diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h index b0678b093cb2..aa3c28781248 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h @@ -935,6 +935,12 @@ enum { * struct cdx_device_id - CDX device identifier * @vendor: Vendor ID * @device: Device ID + * @subvendor: Subsystem vendor ID (or CDX_ANY_ID) + * @subdevice: Subsystem device ID (or CDX_ANY_ID) + * @class: Device class + * Most drivers do not need to specify class/class_mask + * as vendor/device is normally sufficient. + * @class_mask: Limit which sub-fields of the class field are compared. * @override_only: Match only when dev->driver_override is this driver. * * Type of entries in the "device Id" table for CDX devices supported by @@ -943,6 +949,10 @@ enum { struct cdx_device_id { __u16 vendor; __u16 device; + __u16 subvendor; + __u16 subdevice; + __u32 class; + __u32 class_mask; __u32 override_only; }; diff --git a/scripts/mod/devicetable-offsets.c b/scripts/mod/devicetable-offsets.c index abe65f8968dd..7a659aa3114a 100644 --- a/scripts/mod/devicetable-offsets.c +++ b/scripts/mod/devicetable-offsets.c @@ -265,6 +265,10 @@ int main(void) DEVID(cdx_device_id); DEVID_FIELD(cdx_device_id, vendor); DEVID_FIELD(cdx_device_id, device); + DEVID_FIELD(cdx_device_id, subvendor); + DEVID_FIELD(cdx_device_id, subdevice); + DEVID_FIELD(cdx_device_id, class); + DEVID_FIELD(cdx_device_id, class_mask); DEVID_FIELD(cdx_device_id, override_only); return 0; diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 38120f932b0d..abc4781d5db7 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -1458,6 +1458,10 @@ static int do_cdx_entry(const char *filename, void *symval, { DEF_FIELD(symval, cdx_device_id, vendor); DEF_FIELD(symval, cdx_device_id, device); + DEF_FIELD(symval, cdx_device_id, subvendor); + DEF_FIELD(symval, cdx_device_id, subdevice); + DEF_FIELD(symval, cdx_device_id, class); + DEF_FIELD(symval, cdx_device_id, class_mask); DEF_FIELD(symval, cdx_device_id, override_only); switch (override_only) { @@ -1475,6 +1479,10 @@ static int do_cdx_entry(const char *filename, void *symval, ADD(alias, "v", vendor != CDX_ANY_ID, vendor); ADD(alias, "d", device != CDX_ANY_ID, device); + ADD(alias, "sv", subvendor != CDX_ANY_ID, subvendor); + ADD(alias, "sd", subdevice != CDX_ANY_ID, subdevice); + ADD(alias, "c", class_mask == 0xFFFFFF, class); + return 1; }