From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (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 C05F434165B for ; Sat, 15 Aug 2026 05:35:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786772129; cv=none; b=eHg1MCztWuMu5qpEupvHUtDYfFdAUX/0Y3Jml5BKaD0EjUP70TLMyZop64v15rMwVDeM7eMy46O9yIU2m37dhsAqNj5NMDxp+pmWXlQpFd9umHKvPCvrWNksXadaEeFPFcEIsa8uG9TMisSp9MDz5cwHq7j3i4WnRof33bxC2ks= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786772129; c=relaxed/simple; bh=HPjvee4tWjdNfjrS8b48i0A+diT0QeGe2s0ssvlK6O4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=hycNqBglqK6Xxb1HEWN9b4q6NvtS8le3+k3I6sN37wwYGf/1GTX9TIrfDUXyLUPSapkx/YFebBau5KnPR+RMYphKy8TspItOGf+9JkeDYawCsRCayYChuGHgNpTNi/PzP897sQJdO2lzOPVQKOJLdz97YhrqXO5CM+QrJ+nk2uQ= 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=V3xMcaD9; arc=none smtp.client-ip=209.85.167.51 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="V3xMcaD9" Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-5aeb2bc82ccso1988592e87.2 for ; Fri, 14 Aug 2026 22:35:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786772125; x=1787376925; 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=lOfR4Pe/uKrMH/SqExULCOZ9If7xjyi11dlJoIyDO1k=; b=V3xMcaD9t7fwrCarhB8H2KGtUFy1m57hftzKNRHua3cF7JLTbCGJJRM8fEvlqQXT1m ObOoZ8E+GTWmf1XAb5ze3wMkoUhsqyfn3qwgf6cmvUY3sWonzJaOnXiphOU1O+zTq/MD 9L52NyqDaLSiKri2Jos8ic8wQ0xOJ2M47NQgv9L2Q50FlhGBk+8vldYOgSY2A3a7sAvK 6uCha8FBQifKeyQcVs+qL/s1KG//mlEjdUf8zT/wcW09oKq9b6tx4KrqMStQTNOBrEKC dUsY5WyzUND0hgxrBm0S4OLDwmxmR+T1dCOeKwfGtaEsQY9+/zlA/+ffMOoAdpy35imw Kj5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786772125; x=1787376925; 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=lOfR4Pe/uKrMH/SqExULCOZ9If7xjyi11dlJoIyDO1k=; b=KhXyWDZcgpAPBfAwy5NPMwjK+yG9uiYIXXa6+aLJ6vU1yZGLrKRT/2w38+WRalQxWl 0tW64SNBKMzycflBtJwR7dxW0oUb1jeg5aVyUqCeIM+1rLblh395u9hmBOjTOKB97HFp 6SXHIKLKwzUFNIOVMYVcvf4hcSNqwz1BTSsLGhb/Xm/ibWkcfVUTZKcktUdm3jpYAX2c SmJ/Q39VrhlB1T6bTxJzpTPUj5URpxfoHJqL1K/xsv1BZqB/NfdCt/C9urHRrSRgu7XV ywEOCfhnuVbgE59Kz71ZCpBI7uGU7jqWiSaJBWKIbmGkfNMJZVFpjrcR6vUt41o8fHXU +Dww== X-Forwarded-Encrypted: i=1; AHgh+Rq2EmkdPBRzdUCyjoHTnWumUenZ6rbMAQkTP5dTKu4guqOIEpQnZpjDfT2hhGmfLIFV7Ke7gm5YPUnOOmk=@vger.kernel.org X-Gm-Message-State: AOJu0YzucYOX/1Ed/NYTWYQ3ZFcy2coyelv3p96sxN5x/e+i0w63XB1D hHKVM7TCLOx1RvdiqKqHZCbqKGnLmxCFTYlzEW4p219yKyJlP2Db7hqg X-Gm-Gg: AR+sD13lfhJSHEgYXZWyj5xMyC0TVXVCAcba53Ay1l77+tugBSzDSfITdG10OIG302X c6LfIHGJBz551GGt+r2XNLvlode36QDaDI5gq7kTuuxme6dzm4Hpwn8BSYo95bhEf3jgbdJ+e81 kFPnzjh+J0Nnsh7a032+9lBfKy9dkcGDH9fWWGT9KP+9Bm4DmmQtEarqlcJSuxXekosVClu2ScQ m3pjqPs5PhAYPJnLDDL9DCuCVD17hZFi3ImHulDJdcKiDQUKfyGqqUpC7I27duS3ka1QHccqNv+ 3JU/AHNFot0rBYdneo845z8NjGGpE6YzdPzrir+/PVcinplUJIrQfhN8QzJ6Rhb5v4MWXHoR0Er Cs/pPrcuHzoZFFKwSxSc7rnZYPruGZsQ+DCdty82Pj98S2Og6bxzKFDmC5uONOffRtmkHCto8LD J38czH8e1OMoaXW3ScgsdPsCSAN4QQTXolejGPsis9OGEZN7mdQUfSEPKUK5c7sE3Uy3y8Xas0P x2MZggXbrAxF6xFTlPWa9BvLQ0RNzsPgMKTMQpuKBJ2VoC1lWzMa5AMnr/nDQ== X-Received: by 2002:a05:6512:1294:b0:5ae:b259:75a1 with SMTP id 2adb3069b0e04-5b4591173a3mr1629900e87.12.1786772124530; Fri, 14 Aug 2026 22:35:24 -0700 (PDT) Received: from archlinux ([94.180.44.22]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5b458c0a033sm932577e87.67.2026.08.14.22.35.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2026 22:35:24 -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 v4 0/3] wifi: rtw88: rtw8822c: refactor DAC IQ calibration to s32 Date: Sat, 15 Aug 2026 12:35:16 +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: - 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 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 fi: 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 | 151 +++++------------- drivers/net/wireless/realtek/rtw88/rtw8822c.h | 3 + 2 files changed, 47 insertions(+), 107 deletions(-) -- 2.55.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) (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 E4DD81A8F84 for ; Sat, 15 Aug 2026 05:46:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786772804; cv=none; b=tqCKW8kZqYxcleYqJtkrlhIukpZtCDsWT2fhvLuCsfFW2lUmqSCNMvQalSnaKizHB+RyERwp/VIWzm1zIFzQ7U/OjIKXpQba+06JbFFcWo6aRPhjv9PovpNqrvq5Tv1xcrJupzrQZ6Lp9FUDy9pWK6qUX24kV/EYLPDEEsvDPck= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786772804; c=relaxed/simple; bh=UZydWhieuZfX6HJyIP5HEC62kZX3uQrbt57ATZdDl6A=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=FYvV2FA4N9pMmnrIV0pvWshzdCQ2bPAZXRj1FzQE7m0tpkfzH/OdmzgQoGWDZhNS6WvwQejJOO7+2ZA3zG2Qee4VDvXFC7PlOJLOKHDHPmGnoYRFiqS3PtSl+EPC/1LoDJW2Q/VRoMPmueZZRNGi5Ki+GL0W1aPM01PNxG+n1AQ= 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=VzQbh+7p; arc=none smtp.client-ip=209.85.167.50 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="VzQbh+7p" Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-5aeb59d54b1so1794238e87.1 for ; Fri, 14 Aug 2026 22:46:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786772801; x=1787377601; 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=vaUjVYA4Mz8er7Ul0quD61wBLUzHk1GEuAFgBoYaZD8=; b=VzQbh+7pogN1OyGVTTsdvIS4yH2F+tGpuH9udfJVpNHKU5G5Eh8h34SrfqO42oLZP7 hw95VsrAC/dvGKKxJHYt1aXkPJ58LZ/IPh1VniKc/qruJQf3XPJRh+xezWUC3E1H/0cr 1378H8uwpABsBciMtDbiFnB5N1w9oi05kt2O0QtfBhfLm0PMSXoZknhn28dtatKHFhHp 6lvw3d7qHBBxGn4Y1wFOFw97a00svFF5//XzvoG9I7SRbuvumQMurb1nUAHbogvY1PnY Cs/y5uBp+O5i3ioztA43ACHIyTEcOWlySMOnviw/24EtV3kaoVBWTdbY6yg+LobZFbtB Exxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786772801; x=1787377601; 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=vaUjVYA4Mz8er7Ul0quD61wBLUzHk1GEuAFgBoYaZD8=; b=Xf7lzJnMk2Bj3lthRCH0UQTiRFN2BdE0lORGRy7ZpKrJ6xsisaYB04McYwxKPV77bJ U28MHIMS1GFju3Fv/Ik93qd2T3PoNL4RI9T9Oz4Qz7b4/QxQ5/lhj7uMk2QpdoJOxEX7 Xf28O53KvnPKePykbJFrhyXAEx4eVx5ob3cf3UUF/+TV1elhT1K0/2DDBnEvlLm61sGt h3A+Tj3Hjt/kk+vFlW23Jvo12oG778WFBL98Nk6A8B01NOBOmwNCJYsLKoF+Js9OvqPZ XNjgPx+GCoxaZxm0WreZ9HCep9J8meFqexb9wOm6bjLAu8H21vMcuqm3m5N8CHihWit1 wonQ== X-Forwarded-Encrypted: i=1; AHgh+RqzytATrIDE7JkQIjoehYQCDedEMHkIsiI/GASWCqi2wGBXk8FzF+TV9qllZj3e6NKhuOc275O+HYarmgA=@vger.kernel.org X-Gm-Message-State: AOJu0YzLEB5OqmSmrVHtbeD07vbAjAdIU57nnF2BXAeHafvsDM1OqNwv UdNmzPWrM3mBn11d2Un5KqVwgkupsTgczOC3UAXItjEequBuJMjuMwb8Pfx+46Ld X-Gm-Gg: AR+sD13V2UrFmIX5AebbnyDJvOF5adt1jEuE3oI0wmlF6ufmQxbDbFoyLJym+XYU/mN lzqpfXe7/E1+T1rCDMadvMj/6ZL8zL9H1zfgxyPAqUaelKyxGNpAAJSl228xwWI55aO94hXaWig smVEaa+j+shxaqQRbqVkBmQKaC5VXw2OVEhwtLRXmBT3kI1abUPth7KcwnKI96obavRDlrZx32W AEEpm7PwDDCcsxVDhtI2T2pX4XQGgVQRZiP4iLpy+4J7dRqRMaW+RlSAUQas0osf2PL/Aiei/rP Nib5fcjJelch62It/VWBVDasd+PjmILBnxswTHCBs8yjMzeigvhoSRQwA/Nm/xeuJlHDZaQcLTl 8YM+Ay+5sxPnmhWOnXV1GqsexiKTwT8/95Q1bpAmxWjYpVqVeXsWDJUUO14BGHvhyP/tKxZ/XYY KG6jCPP/99XBhLwW6eFpy6h6444RPEykYvV9M1/pILGe9MtiUNGFmxW5WasuHKYXaDeg3JIlNhh KZFYydJLyPXrrOx14wqoz18Za+WVwgIye0Djq6m3lXq+fjqBGK/CUiLdl9lBw== X-Received: by 2002:a05:6512:a82:b0:5b0:12e1:486c with SMTP id 2adb3069b0e04-5b4591206a1mr1629233e87.24.1786772800985; Fri, 14 Aug 2026 22:46:40 -0700 (PDT) Received: from archlinux ([94.180.44.22]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5b458bed96esm967527e87.40.2026.08.14.22.46.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2026 22:46:38 -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 v5 0/3] wifi: rtw88: rtw8822c: refactor DAC IQ calibration to s32 Date: Sat, 15 Aug 2026 12:46:31 +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 Message-ID: <20260815054631.NPhw16LlL1yAeaNNGaod2XiwUAn4idCLGnvPAe4Ib_s@z> 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: - 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 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 fi: 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 | 151 +++++------------- drivers/net/wireless/realtek/rtw88/rtw8822c.h | 3 + 2 files changed, 47 insertions(+), 107 deletions(-) -- 2.55.0