From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 11F083290B0 for ; Sat, 15 Aug 2026 09:39:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786786773; cv=none; b=t+0QGdDtFuJsFwvtg/0KbDCHajuvxBf2cpfAxAuw02PwQKBqpVTQYSKsk8hs1+kpJozw979NAQA2QxHbjPVbbvRSNbnip5CEh6Z18OMfFsXajxFktx0ZFw4xH8chstQQMmP2KZnoAGnnqi6PzuZk4dPNlYzyF3EljV5YjZ48eZM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786786773; c=relaxed/simple; bh=CI0QIMmHQhXYmipUnZ4obBPXirDkukhV2/mM2zGuyOk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=eV8uaKdzUG6fd6BlfrJSpX8b7Gel0DeliKEWGewH8In5F4ETfQLlU9tBzPktARvrNZH3Hfw6qdvEHTLw1R2wC6ffBC8F6YRiusu8HTHZNTHeciqpGv7eplMZq1+mPNecvDt6iJNN7YOHWonKMZtEQg0HQ4ytEUn7XARtGjPw4+Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=QpA0c7vE; arc=none smtp.client-ip=209.85.167.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QpA0c7vE" Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-5b0231a3e86so1661214e87.0 for ; Sat, 15 Aug 2026 02:39:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786786770; x=1787391570; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=Wu3vmS60bFGjaB0EqV/uEdj+HM7TnRWaMX7yzwT7SDM=; b=QpA0c7vEMbxSAbFkXNQQqFRlBOxvnQvPvmYKYJhch+XkXXfhl7TzuZBfGv87KN7ouq JIb6KpRU7Iq/pjT2VrTttMq5wUo4IoqtwIgzA2ZbbHXRPiYZno8WGTo/l6t7qdXdEnI8 pRnz4ahAFGRXFNH7XYvLFOn1Iyk07m+lguWo02cSpt8mp49YIR44Dis0ebKw08ccZseF QtuDY6uFdZ3DQorr8mKw9B1PVIGp2IuJVYXrRmYqiUl81byGr6XFj+oGOV/CdY75A83/ rkraOM8BafCANzVbEJTvwWY37ltDdHJghqQBbZI4hZS0GNOqaYmAqwZ0Zrqftp6gUQtj mQRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786786770; x=1787391570; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Wu3vmS60bFGjaB0EqV/uEdj+HM7TnRWaMX7yzwT7SDM=; b=W7zzOtsb56uSoKTsIGl6afcYzd/AiyG3qkQQqpxT/GEUpNa9l2avqkAZCJVovQfYIV OFA2mXfW846htra4b66RepHxUbGZjJ23wNMumrLyNg2IlEm+rRlAFuNhJgIN7b+Sh1UQ if+5P1yWZ12/B8GRvlbNu9OIi0bUtf3t+y0tgQQPIIPAcuHMSplDoLXg0Y0xF9Nv5utT q8i3lc5TpjZ7OUGyEhEiq5/aGfjUSkVG1IvHe0haSrerWI+O2d8tjlKQw+xl/ZZqbynP PURet8ekIXfJxuQQvURj+D5jS3PRObfsoXsVgJERUc82A9e9KkOcg2nZrATeVmx0F+TH yesw== X-Forwarded-Encrypted: i=1; AHgh+Roi8Xym69w28XaguvuYvlR2T3GdrWkdEIu1gYAcf3stJhGcrCucg05Ah6lYu5mG1Ef5/FFV6mJjVq0uM/E=@vger.kernel.org X-Gm-Message-State: AOJu0YxpdYWwr8s5CaObSWjKECiUWDhMyojlcGHiLUMzAsAbyKy/R+54 GXsEszBCVntTkXlRHiElHFCeByQtEs2wT7AJ3AHdRR9mm/fjCOmg9o86 X-Gm-Gg: AR+sD11B3lpCD6bcR9PXdyeqFx3scx2r73abUHfiWBH4vUx4Of8XroUO/9YUtMXww/7 wEjxr3+y2iJxeQQ/ZeimsxOh0oLf7Z08q0ZJmEIIXqDDEXW9W8udff/DsYHbWDjal7lJSzttlim JhD/248npuuFiNKzwiDMfhaSz6U4E/byr2Eb7A1jbpH98jg1zX0xjn5TQqLh44evnur/tX9oQsb 4CQ0f6O2dSqUO6e2UYID+N4IYXotAkPGXl+MHYV+bcZZkJIhJ5je3jdQk2idhoU02jASwqCOrMA qbji91N1IutJoZBOIBvoSiI99xN5jDQkWPUd6rZJafWDtYW3U1qNPTshz9eOpdNnZY/gmq6Ps7H 41kLkG0hs8wu5zi9VJ0Lf0Rr4rVJvfHkWwueVAEGkHmt7x+LhYTYAcVa68GC4HEwrgEfTsxqp03 TzX79D6mrBagf81I1F5XLPERGGQ42FFLAqO3/MM3jLSNCkVEVchgjy6T+aYTvSFBHzE1a5+WMm+ 1XTPhxF3jFjpxs/vmEXmm9xhgekTp12q0R3n76d7E8Uz6YCJy6dngPhOkwe1QLO4A9CCZXo X-Received: by 2002:a05:6512:8344:b0:5b0:1b78:495d with SMTP id 2adb3069b0e04-5b459118b21mr1156022e87.24.1786786769962; Sat, 15 Aug 2026 02:39:29 -0700 (PDT) Received: from archlinux ([94.180.44.22]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5b458bedf9fsm1040316e87.46.2026.08.15.02.39.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Aug 2026 02:39:29 -0700 (PDT) From: Arsenii Pashchenko To: pkshih@realtek.com Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, Arsenii Pashchenko Subject: [PATCH rtw-next v6 0/3] wifi: rtw88: rtw8822c: refactor DAC IQ calibration to s32 Date: Sat, 15 Aug 2026 16:39:21 +0700 Message-ID: X-Mailer: git-send-email 2.55.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This series refactors the Digital-to-Analog Converter (DAC) IQ calibration routines in the rtw8822c driver, eliminating legacy unsigned workarounds in favor of native signed math. The original code heavily relies on unsigned 32-bit math mapped over a 10-bit circular hardware register scale centered around 0x200. This introduces complex nested boundary checks, custom bubble sort rules, and custom min/max tracking helpers. By migrating the temporary stack arrays and signatures to signed s32 and utilizing the kernel's FIELD_GET_SIGNED() API, the coordination system is linearized. This allows the removal of internal custom helpers, collapses unsigned wrap-around logic into standard linear operations, and enables the drop-in integration of the kernel's native heapsort library. The series is broken down as follows: Patch 1: Introduces GENMASK constants for register fields and replaces manual bit shifts with standard FIELD_GET() macros. Patch 2: Converts stack buffers and function signatures to signed s32, switches sampling to FIELD_GET_SIGNED(), and straightens out the validation windows and hardware offset mapping. Patch 3: Replaces custom bubble sort logic and unused helpers with a direct call to the kernel's native sort() library using a safe, overflow-proof relational comparator. AI Disclosure: An AI assistant was used for source code analysis and conceptual consultation regarding the signed math transformation. All code modifications, final implementations, and refactoring steps were written, reviewed, and verified manually by the author. Testing: - Note: The author does not possess the actual rtw8822c hardware. Actual throughput and runtime performance verification is left to the vendor or community testers. - Every patch in the series was verified with scripts/checkpatch.pl and yielded 0 errors and 0 warnings. - Each patch was sequentially built (bisected and compiled) to ensure there are no compiler warnings, pointer type mismatches, or broken builds at any intermediate step. --- Changes in v6: - Noted lack of physical hardware for throughput testing in the cover letter. - Fixed a typo in the subject prefix of patch 2 ("fi:" -> "wifi:"). - Optimized the min/max search loop in rtw8822c_dac_cal_iq_search() by starting from index 1 since index 0 is used for initialization. - Reverted an accidental change that broke the compilation. Changes in v5: - Fixed a typo in the subject prefix of patch 2 ("fi:" -> "wifi:"). Changes in v4: - Flattened the series from 4 to 3 patches to avoid intermediate broken states where sign-extended variables interacted with unsigned check logic, ensuring 100% clean bisectability. - Leveraged FIELD_GET_SIGNED() for modern, native handling of 10-bit signed hardware entries as suggested during review. - Shifted definition of register field masks from the .c file into the shared rtw8822c.h header file according to subsystem design patterns. - Stripped out custom rtw8822c_dac_iq_sort() wrapper, invoking the kernel sort() library directly inside the main calibration search loop. Changes in v3: - Corrected the subject prefix target tree from wireless-next to rtw-next as requested by the maintainer. Changes in v2: - Fixed missing target tree name in the subject prefix (switched to wireless-next). Arsenii Pashchenko (3): wifi: rtw88: rtw8822c: Use bitfield macros for DAC IQ sampling wifi: rtw88: rtw8822c: Convert DAC IQ calibration path to signed math wifi: rtw88: rtw8822c: Replace custom DAC IQ sorting with kernel sort drivers/net/wireless/realtek/rtw88/rtw8822c.c | 155 ++++++------------ drivers/net/wireless/realtek/rtw88/rtw8822c.h | 3 + 2 files changed, 49 insertions(+), 109 deletions(-) -- 2.55.0