From nobody Fri Jul 04 03:22:40 2025 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4bYJq45Hn3z60VT5; Fri, 04 Jul 2025 03:22:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bYJq43LZMz3VpD; Fri, 04 Jul 2025 03:22:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1751599360; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=pN3ynQtonN/XkduL2C4Ikk55lxV7TohL9vKrigGNS2w=; b=lVcamMqVOxy8xVAgVShhtB0FStyWWKzHf39USKulRcONKAOI8U6p+K+do82oJv7JthOTZf xmKco8Sv95c9B1nGVU8TuUMBng0ceK7wpBrVAf864g6aV3vKxlSlTuQkLtWp8JZSQdoLpe nlFakIYwnClRWeDUXLKZiY9OJug5WQL7x8PNdK4d9WY5KMo0ayLIcVaSrlpcsjqXxllJyo eNbxO9DQusxwIai86Js0F3JjVnPO4S4j0u4umQILBrZ622qSLJnSv8/kQZZDjV9dImURmF Jrssh3kuaniA29oqCdKpHXT/u2a05nM8QzlfpBMqIByE+JaQ1NApItSIOJJ7jA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1751599360; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=pN3ynQtonN/XkduL2C4Ikk55lxV7TohL9vKrigGNS2w=; b=dlQPVZ2IGBhRt/m3R2VC3bOO70KMbVJxuud1ElnV/+hK+ysD69YIOLt24rghQQm/pxm0XU VtIq8cqsiiVvy7ZnkrP53791fS74YoRiax4xhFYEKw37bcLaqQmvh0wR7GZYqSJ14hEZvm Jlw3cJwde46bQRG9Fh5hv3+kPaA9HLFcF4qhGOA1mECBM+hq2YNbyLxT65XACNI3nf3e30 vVvLvYFkufdhr6h370eB/02Eh1kxfbGa3X65rNmu+bgl/T5rg2MWU+qQpxtXsxRiyUqv4c AigrGtfYMx8TGFMpavXlvtYMm5/oVRFWFRm4TDWg5mTH5FjIVmYZAZ0KxeNT7g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1751599360; a=rsa-sha256; cv=none; b=xqEMlQMROMxC6VhbRZ1sVRoQVy7qZTsZvRV8lEJALbvsk/84wvu/HNLk4qNJbdeco3bT3m mI+wRvxYK5zK4HD1wmxggXKbtjwDaQKnHPTX/zntY3Mjs3YruIUlySc89GfXFVIPZ+g067 +HLfyYEgpzNHGxCHpzCo52AlxMiC8LC7dzu8E/GA54fv37TDfxNEQ4iTEQrDTxuXE9bDHn BIDJq0HV7RBKhkPeMp3q0uPLuB26SZaeyIdJpNVFWGKv8Hxgs3tG68hyUGx88hav5lXNXG /hevEvkYx4ebFM/l/zHpyH1IbpEj2CdTlyY9rjiToyqAcLCCRLwKMHaffxMq4A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4bYJq42snrzZ4Y; Fri, 04 Jul 2025 03:22:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 5643MeJf079659; Fri, 4 Jul 2025 03:22:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 5643Me8q079656; Fri, 4 Jul 2025 03:22:40 GMT (envelope-from git) Date: Fri, 4 Jul 2025 03:22:40 GMT Message-Id: <202507040322.5643Me8q079656@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 2ddfcc013c25 - main - LinuxKPI: acpi: provide union [linuxkpi]_acpi_(object|buffer) List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2ddfcc013c251f13c8c9b24970b8134ddd49afea Auto-Submitted: auto-generated The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=2ddfcc013c251f13c8c9b24970b8134ddd49afea commit 2ddfcc013c251f13c8c9b24970b8134ddd49afea Author: Bjoern A. Zeeb AuthorDate: 2025-06-15 10:38:56 +0000 Commit: Bjoern A. Zeeb CommitDate: 2025-07-04 03:22:22 +0000 LinuxKPI: acpi: provide union [linuxkpi]_acpi_(object|buffer) Provide union acpi_(object|buffer) as linuxkpi_ versions and in Linux native lower case spelling so that driver code compiles unmodified. Use the linuxkpi_ prefix to avoid name clashes with the native ACPI implementation which uses CamelCase. Use the linuxkpi_ names internally and redefine the linuxkpi_ unions to their native names so they are avail as expected in drivers. As a transition to not break drm-kmod which has in-place (no #ifdef) changes from Linux spelling ot FreeBSD spelling, introduce LINUXKPI_WANT_LINUX_ACPI so we have the Linux spelling as an opt-in. That way the transition can happen gracefully and once "top-of-trees" are all sorted we can remove the #ifdefs here again. Bump __FreeBSD_version to be able to detect this change. Sponsored by: The FreeBSD Foundation MFC after: 3 days Reviewed by: wulf (previous version), dumbbell Differential Revision: https://reviews.freebsd.org/D50863 --- sys/compat/linuxkpi/common/include/acpi/acpi.h | 76 ++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 5 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/acpi/acpi.h b/sys/compat/linuxkpi/common/include/acpi/acpi.h index e0218bdde12e..1e398d05ba20 100644 --- a/sys/compat/linuxkpi/common/include/acpi/acpi.h +++ b/sys/compat/linuxkpi/common/include/acpi/acpi.h @@ -3,6 +3,10 @@ * * Copyright (c) 2017 Mark Johnston * Copyright (c) 2020 Vladimir Kondratyev + * Copyright (c) 2025 The FreeBSD Foundation + * + * Portions of this software were developed by Björn Zeeb + * under sponsorship from the FreeBSD Foundation. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -30,6 +34,13 @@ #ifndef _LINUXKPI_ACPI_ACPI_H_ #define _LINUXKPI_ACPI_ACPI_H_ +/* + * LINUXKPI_WANT_LINUX_ACPI is a temporary workaround to allow drm-kmod + * to update all needed branches without breaking builds. + * Once that happened and checks are implemented based on __FreeBSD_verison + * we will remove these conditions again. + */ + /* * FreeBSD import of ACPICA has a typedef for BOOLEAN which conflicts with * amdgpu driver. Workaround it on preprocessor level. @@ -46,8 +57,8 @@ typedef int64_t INT64; #include #undef BOOLEAN +typedef ACPI_IO_ADDRESS acpi_io_address; typedef ACPI_HANDLE acpi_handle; -typedef ACPI_OBJECT acpi_object; typedef ACPI_OBJECT_HANDLER acpi_object_handler; typedef ACPI_OBJECT_TYPE acpi_object_type; typedef ACPI_STATUS acpi_status; @@ -55,12 +66,62 @@ typedef ACPI_STRING acpi_string; typedef ACPI_SIZE acpi_size; typedef ACPI_WALK_CALLBACK acpi_walk_callback; +union linuxkpi_acpi_object { + acpi_object_type type; + struct { + acpi_object_type type; + UINT64 value; + } integer; + struct { + acpi_object_type type; + UINT32 length; + char *pointer; + } string; + struct { + acpi_object_type type; + UINT32 length; + UINT8 *pointer; + } buffer; + struct { + acpi_object_type type; + UINT32 count; + union linuxkpi_acpi_object *elements; + } package; + struct { + acpi_object_type type; + acpi_object_type actual_type; + acpi_handle handle; + } reference; + struct { + acpi_object_type type; + UINT32 proc_id; + acpi_io_address pblk_address; + UINT32 pblk_length; + } processor; + struct { + acpi_object_type type; + UINT32 system_level; + UINT32 resource_order; + } power_resource; +}; + +#ifdef LINUXKPI_WANT_LINUX_ACPI +struct linuxkpi_acpi_buffer { + acpi_size length; /* Length in bytes of the buffer */ + void *pointer; /* pointer to buffer */ +}; + +typedef struct linuxkpi_acpi_buffer lkpi_acpi_buffer_t; +#else +typedef ACPI_BUFFER lkpi_acpi_buffer_t; +#endif + static inline ACPI_STATUS acpi_evaluate_object(ACPI_HANDLE Object, ACPI_STRING Pathname, - ACPI_OBJECT_LIST *ParameterObjects, ACPI_BUFFER *ReturnObjectBuffer) + ACPI_OBJECT_LIST *ParameterObjects, lkpi_acpi_buffer_t *ReturnObjectBuffer) { return (AcpiEvaluateObject( - Object, Pathname, ParameterObjects, ReturnObjectBuffer)); + Object, Pathname, ParameterObjects, (ACPI_BUFFER *)ReturnObjectBuffer)); } static inline const char * @@ -83,9 +144,9 @@ acpi_get_data(ACPI_HANDLE ObjHandle, ACPI_OBJECT_HANDLER Handler, void **Data) } static inline ACPI_STATUS -acpi_get_name(ACPI_HANDLE Object, UINT32 NameType, ACPI_BUFFER *RetPathPtr) +acpi_get_name(ACPI_HANDLE Object, UINT32 NameType, lkpi_acpi_buffer_t *RetPathPtr) { - return (AcpiGetName(Object, NameType, RetPathPtr)); + return (AcpiGetName(Object, NameType, (ACPI_BUFFER *)RetPathPtr)); } static inline ACPI_STATUS @@ -101,4 +162,9 @@ acpi_put_table(ACPI_TABLE_HEADER *Table) AcpiPutTable(Table); } +#ifdef LINUXKPI_WANT_LINUX_ACPI +#define acpi_object linuxkpi_acpi_object +#define acpi_buffer linuxkpi_acpi_buffer +#endif + #endif /* _LINUXKPI_ACPI_ACPI_H_ */