From patchwork Fri Nov 29 07:43:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: CLEMENT MATHIEU--DRIF X-Patchwork-Id: 13888453 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EAD6DD6EBE5 for ; Fri, 29 Nov 2024 07:46:58 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGvfh-00080s-Me; Fri, 29 Nov 2024 02:44:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGvfU-0007y8-6W for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:44:00 -0500 Received: from smarthost1.eviden.com ([80.78.11.82]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGvfS-0002l6-FD for qemu-devel@nongnu.org; Fri, 29 Nov 2024 02:43:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eviden.com; i=@eviden.com; q=dns/txt; s=mail; t=1732866239; x=1764402239; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=ytktZtEYU0dSCIMqO67HHQkh/DLqPU7KZ/tIFWoIeww=; b=nLO7oFl1vVw/df1gXC30zEz+WpNpsTM0Fxzn4pMLcgjUGbjUBVhcbCwY r7wfARh/vpQo105yjpKXgDuEg3vwFr/eKGgUA9A93EIbDYp8rxHGOT7/t 8LPTlHG+QaQCYarhi51vK4qB9P1OY5Y6fOmavvhiJdKMFGzgCj7R6qUV0 2BueMoIk13IdJRzMjtOr1AQIuGDlvwJY/rff4HqlcoHnjkDfwA7KOJb9B 88g1fmkPilv7Cv9afC9Uic5Kam/eDRg/G5nRgyWrp6BYvWdKxKj7+Dtl3 7ZAbTVHaO52FFBxBnv7CeTRF+W0r6dhHF5FT3lSrSjY/zj1dVPacbtVoQ Q==; X-IronPort-AV: E=Sophos;i="6.12,194,1728943200"; d="scan'208";a="25664403" X-MGA-submission: MDEZNtdPT7zhjxTYdsJrzrE+B6bVspPyFTlwnXiC3c0sDTOXXYyoguh6IRmIQlbOY9N2ou1BBqPSfMgmMD8SJV7ecvGH11DB3plEM01gkIeaQD+ZKoKEFLl1X445PcoEdK9GhsPdMQCxe9X/CrBGQrE8BTRBY5y1A4qhVmg8023mOQ== Received: from mail-am6eur05lp2109.outbound.protection.outlook.com (HELO EUR05-AM6-obe.outbound.protection.outlook.com) ([104.47.18.109]) by smarthost1.eviden.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2024 08:43:57 +0100 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=M9CEcEtqqX9zHpWO6AKvaEpGFpbnghc7YUuMt+sZOkBDyUlb3cf+YVqkvxY4+iRiU1HjW9AbvwBR+tuP8XXSmTQ5PvUgTNYjMKYBMs/6Ty9fDTEJlZpAYyblHRyeDLnMuV4KQ6gSK5sRsMQ0/SFgfX4lpYU5MpbY7TR8LeBrMWtEFQK4IEMYqHqrB7AmbrP8L4/WNuROteNK7SycLmRf69ZAPtJHl4RDWM5jLC/rwhqoqfYqyrDKjRZ6KiDXNZFXJ1lSEV4YDTR9zD3PtnCMrEtV1Y7KrpV6ujMXAmN9k3QlNgyxlQ1jZPPgfJOLKdc+bj7PQJeVlEcBvMW45GbUWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=ytktZtEYU0dSCIMqO67HHQkh/DLqPU7KZ/tIFWoIeww=; b=dxyUqNORLKCKo2zLcesLl33bujECXchdUOryzmB4Zm1xhlK/KgKp727tfi3kHUM9AzAGoAK4Lajk3DLruS1ygLDujjGM1kSST7daVyMDCCLvGpOMwUjfq87XClEAuoFGIDy0uQcZUQSjvkyic3k0kpCb9BypnytrSgbvg2nHLGFP5gV9oyH5+eRjeQnMvqgkMr+3pYFaOOMvIHjhj1RMrkCIYT6ghOY7/amUz2PXt0L8psXXDsRLvsEzzVS2SFC71OZ3TnVXcGy497kRlpdpH9ayRaOeDOvlyOnfPCVMN5MsU2U1+h9SH0yI/nIVYpGp+DHTYsAR9df3VBSUR5pMKw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=eviden.com; dmarc=pass action=none header.from=eviden.com; dkim=pass header.d=eviden.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Eviden.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ytktZtEYU0dSCIMqO67HHQkh/DLqPU7KZ/tIFWoIeww=; b=iCo7xBMu0XGJ7O0uqilEkecBAg72+PyLYxFkQtxnCgYLckLaqTp361wDSYzH4fLvznT5x8UJFSEUTavmMQROoSNjQfgoJc2LmtE8tcRpYFjZ+d5iHURuV8m5BRXzmVw/fREhc/WzAIjYeKHbjs8AwYPPM1BDEOgc29VoBY5dbk2G1zKS8R4G9r0FpqrfmNm0tqS6DxF8hJkR5136auXSPDWHZkZ0+BKnmNqIwVO0Jl2B2JDoeiQDWsUOIqbjdn34GtArxByKQv2465g1HNkkUBXYvvr1Bv7AcUQn+DKQ1wei1T2HvFVONUWtAVaJoPYEqDAdrnNQEa5kk7vXNroohQ== Received: from AM8PR07MB7602.eurprd07.prod.outlook.com (2603:10a6:20b:24b::7) by AS8PR07MB7847.eurprd07.prod.outlook.com (2603:10a6:20b:39e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.15; Fri, 29 Nov 2024 07:43:54 +0000 Received: from AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d]) by AM8PR07MB7602.eurprd07.prod.outlook.com ([fe80::fbd7:ca71:b636:6f9d%5]) with mapi id 15.20.8207.014; Fri, 29 Nov 2024 07:43:54 +0000 From: CLEMENT MATHIEU--DRIF To: "qemu-devel@nongnu.org" CC: "jasowang@redhat.com" , "zhenzhong.duan@intel.com" , "kevin.tian@intel.com" , "yi.l.liu@intel.com" , "joao.m.martins@oracle.com" , "peterx@redhat.com" , "mst@redhat.com" , "tjeznach@rivosinc.com" , "minwoo.im@samsung.com" , CLEMENT MATHIEU--DRIF Subject: [PATCH v1 07/19] pcie: Helper function to check if ATS is enabled Thread-Topic: [PATCH v1 07/19] pcie: Helper function to check if ATS is enabled Thread-Index: AQHbQjJw7Xoxk7N7VUCV2WyGQB2/QQ== Date: Fri, 29 Nov 2024 07:43:54 +0000 Message-ID: <20241129074332.87535-8-clement.mathieu--drif@eviden.com> References: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> In-Reply-To: <20241129074332.87535-1-clement.mathieu--drif@eviden.com> Accept-Language: en-GB, fr-FR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=eviden.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AM8PR07MB7602:EE_|AS8PR07MB7847:EE_ x-ms-office365-filtering-correlation-id: ea94c5a2-8bb6-4cb9-c5f9-08dd104992fe x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|366016|7416014|1800799024|376014|38070700018; x-microsoft-antispam-message-info: =?utf-8?q?rWhDn6HTtGisUOz5QSJc2/SZrZXJEN5?= =?utf-8?q?s20g3YuZvDU0kaIMnIMDwdVulmLhnw8uUw200OFSHA6I6pvSUusPzuz5HB8yOklWp?= =?utf-8?q?Hx6B02tqUcSDZuBhq8zL8jdTQpKwDeKwLdQeowYP1D8j/ynjTSya0i1tKc/oyObX1?= =?utf-8?q?azuZ15pePKykS/WZ1k9x1Mgp0fbfAfDtZKmPaWUBJEGxLmgYd5XP/QNF9OgRrj95N?= =?utf-8?q?Els59XT3po23RmL8F9OBQlPRM0gRFgY9E9kFvJ0tgUVYjiYtN6uk41PGmnTkK2V1g?= =?utf-8?q?TBkKoIgu2tuVzOx7RO6AQwfJOeod7Z3L6ZeRaPX8h/hoIPDFrprjuBonodjFEq6BO?= =?utf-8?q?fWM0zKgmxWggxaDetcEP1Hjf8x7cmah1vo27njKMTdaTURPXNSLYAEkeGWWwemJjE?= =?utf-8?q?lRVXZf71RQ2E+0WDczumFkqj8WpwizSV4zNecjjiGgKkTJ0DL3kCL8UjNOp8G/oNd?= =?utf-8?q?NkAjVF/hHgBS3j+8AAs2UD4WMiqFzapQMEKLhpuVaPvEtM6IFdB5t3ppngmnnzWgA?= =?utf-8?q?xE+cXTT0XDYwic1l7W4Q7KrX8Xd5Q1SRnf3q2T8ts8G8u0iHuw1f2c8e5+oOAQ9eQ?= =?utf-8?q?kK49zBtdMUyntuWnS1LwWYUeLduncRNcN9aiNmVt77UTlWXbNIAbVoXL3QcXid6ob?= =?utf-8?q?d4Q5kKS9oY7p1l8yRh3n8rFCfSTyR/OEjNuswaqqL/oS1PLgWkKwLmbrefquG6wEZ?= =?utf-8?q?DDilbTUnV4ck/XWPcA6SFlJk72Uegl86fMLVH2j1/37JS3JGCO3lKKCeMX3LBd2CI?= =?utf-8?q?AogvMgwsU6u8jLvt0vG/9+dJYiBWcQ88uFGT0l0V3djzth4L3zGUIDP8Rj074/0dV?= =?utf-8?q?h36Y7gv2RQvmNM6z1QT+Tk4HBs1nEofzYNPLktjMQvELk/XV3VFaas1j7nkHudcNu?= =?utf-8?q?1ZjjWdvOzYUqsJsPU9l5IFZww7V72U3h2Eh7x0nSaJgB5rdIq99SPn+Dl0nX1uYJj?= =?utf-8?q?n0DlHZkmsIzxCuv7qsgerisDLxPqoP3pinzZQ7mOfO6Fl2bovLiQveFcsGgaAoz7i?= =?utf-8?q?NH+IVN8qDoanYDRe/fyAD62HJH+hfYCF8iR6Z9+tKzajfpDYHHFNN0r4leDVd3d8c?= =?utf-8?q?tgRb5cZIni+LXFtoPT/2s2leR9pKQDruyIL/YK0If9FMAWSUBV+gCjTHQF7eFMftI?= =?utf-8?q?Bz93UMD81H5pjf04Vi3Ci+cweuggAD3ch9H5/p/dnzwg9xo8sRX1iSlvk8lS7f/Ab?= =?utf-8?q?boaUP82ux5IDaVVTkBTbZ72W8l4gRkNQkHGohNiwhbbqQKpKITfSN5ZAveUGyGBmC?= =?utf-8?q?755og9lcyG2DnQTtBIIwZe9GrkY9WMAe8gjNdPWmL3KEmCQ6HKrB3+G5Gse+gccN/?= =?utf-8?q?P0BDYTintS9Dp2HB93WLD0fj3jAZ5Gt8Ng=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM8PR07MB7602.eurprd07.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(7416014)(1800799024)(376014)(38070700018); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?LzhvxtmUpjFsSTSqMXGv1IUg4riK?= =?utf-8?q?S2p6dnKfL6oPpI1rjzQGrhBrzejbwB3KpYqZ9YxljfphO4jqYJL+1igy19e2VIBVd?= =?utf-8?q?MUDqpiq5Kbw4dbyVGQWbskJXVyW99McIXpFEEbLMzXscGTeRSqWQbbUT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qqyMX/tQgEB?= =?utf-8?q?TntinpB6CdwqTnfnWzDwhIGT8nbfFJAQjImvkrC5T9Fe+7fq1qa5oyAAR3M8sEPra?= =?utf-8?q?4IuiuNlFkeo4p6+uFiPsjewhDGplWdWr2T01Jy2lnIvvKXLKdT5beAMPyOUCQtV5g?= =?utf-8?q?fh4PwtVCuagWedybwrmab77Q8cFGKIYrrmlp/rs53ySe7J3VlC6siwzBkvqzKVl+7?= =?utf-8?q?hTrXU7uENH4Nx3rOgXQNxvkXKRbFLq5FaT1d8AabscltI3TNdkOJfyUmw8dnZFB7u?= =?utf-8?q?u6DsZqTEN8LdB2niMraWvNgeFiS1Odi0A7LkYXbmc5tZosOu3BdU4iujgxgGZOhg/?= =?utf-8?q?UbnqaLpiY5bixlNN/h5DxOFGXtuWaG2IHW7E5NbSH4nEDpBwrNwNd/gXQ+sFWX5dw?= =?utf-8?q?RxzmNoAz8nfRFjiSFk/wWhOmAKOx0iR5qhvNn7M09NVUE2umNIfLBgGuPoxVtpOTq?= =?utf-8?q?LXArFsdHTsjPRb3ClwiZzFwXTmqqsVQe7EzMwiN9jEbURQFx4SuC6jkHQSEOADNMl?= =?utf-8?q?sVCTm0NbqNFglJ8cezRummqnEfaRirPAwVE3RxZ/KmKYK1LWu+8Bdx0=3D?= Content-ID: MIME-Version: 1.0 X-OriginatorOrg: eviden.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AM8PR07MB7602.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ea94c5a2-8bb6-4cb9-c5f9-08dd104992fe X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Nov 2024 07:43:54.1081 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 7d1c7785-2d8a-437d-b842-1ed5d8fbe00a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: BXszZwXww1PrisbXNPACx0KC9qFL13JYzX3fDsgMb2sS7n9M5hMuZ3bNi7MJCLaMCJjBYI3lF/bsily79k8wx4+Af90LzyMx0NHgkXpqYto/DMu9j1nmWW1ZEF4EVLvl X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR07MB7847 Received-SPF: pass client-ip=80.78.11.82; envelope-from=clement.mathieu--drif@eviden.com; helo=smarthost1.eviden.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Clément Mathieu--Drif ats_enabled checks whether the capability is present or not. If so, we read the configuration space to get the status of the feature (enabled or not). Signed-off-by: Clément Mathieu--Drif --- hw/pci/pcie.c | 9 +++++++++ include/hw/pci/pcie.h | 1 + 2 files changed, 10 insertions(+) diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index b6e84acc93..72bdf07834 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -1243,3 +1243,12 @@ bool pcie_pasid_enabled(const PCIDevice *dev) return (pci_get_word(dev->config + dev->exp.pasid_cap + PCI_PASID_CTRL) & PCI_PASID_CTRL_ENABLE) != 0; } + +bool pcie_ats_enabled(const PCIDevice *dev) +{ + if (!pci_is_express(dev) || !dev->exp.ats_cap) { + return false; + } + return (pci_get_word(dev->config + dev->exp.ats_cap + PCI_ATS_CTRL) & + PCI_ATS_CTRL_ENABLE) != 0; +} diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h index 63604ccc6e..7e7b8baa6e 100644 --- a/include/hw/pci/pcie.h +++ b/include/hw/pci/pcie.h @@ -158,4 +158,5 @@ void pcie_pasid_init(PCIDevice *dev, uint16_t offset, uint8_t pasid_width, bool exec_perm, bool priv_mod); bool pcie_pasid_enabled(const PCIDevice *dev); +bool pcie_ats_enabled(const PCIDevice *dev); #endif /* QEMU_PCIE_H */