Message ID | 20231213-wmi_host_mem_chunks_flexarray-v1-5-92922d92fa2c@quicinc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp7925249dys; Wed, 13 Dec 2023 09:07:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IF9oQc5WJY3WaQrIYpOY9h0homZHDy2uGkd611jameDTUEe1ITa8jZjlguugZJhh60fsAfk X-Received: by 2002:a05:6a00:27a1:b0:6ce:7612:6c30 with SMTP id bd33-20020a056a0027a100b006ce76126c30mr4165579pfb.65.1702487243340; Wed, 13 Dec 2023 09:07:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702487243; cv=none; d=google.com; s=arc-20160816; b=JWwVOqe6oTWSg2Y5wh/dh6KLUjs+n4Q/xhT669bhGpv8jp5PDicPTSHSisJLzDEjNo 34E8EkSjqMk31J33JJexZ1h7V+EHMQkDJUJUCBOS6eJLhqdaplmhTwO7xl+E8HLfQ9MV XsmDDBEyANn2BVI4wIXzoqzT/IyIzJGILKUBDJD0dMDIMSjl+fM6/sibCLbRkhg2wrRP IPpS0KJn88nnCVZJiG5bTyF1xHbxp3dFAIGvXy4YLZnM/MX/VtJpY/hTw7Z2hrYHRTu2 BdHYA44f+vlwShSWADsiQv36LPTvilhskLXtLZvm6gk6eLrozdFxm+BYcKStj90xB+fU mWDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=HBkJg4RH7YDK3ha87v5K+pqVsnazTKHG8ainsAEr/kU=; fh=f4dIorfYpvrEtypEqDl0xAr0U3fgNW6JnHp2tNMuoOs=; b=kYNQN2kNIzhsMD+x3fK9QJZnWNFARQqUsoZnnfK9x4CRH5ywg/5d7+JEuFKdZjOlOe 9PqI28L5M6PiNClBQsJcf7jKsc5R870agrAy0sPprr7B5aO0T9XgqZgQppEf1+s4XSaC L6DzzRc4H8amax8axhBnDF8BT71LGboHGsms7gTPW12eUWv9iLdiaellWfxIUkX5NWAQ l36bhtAk3I5fGlTttYrhFHOQILPAH1IHM4JoC5yhrKNblzHs2+II3uqRLesaCkprMEC7 PGMPxu/PdC9TrbCUBDsGLAKkuZjkGAeg9dIV5Vhs/DipvFW9Z8hySHLnCbl7rxKEH6sw jqzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=AolB2rK7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id bz14-20020a056a02060e00b005c6582f7984si10257565pgb.749.2023.12.13.09.07.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 09:07:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=AolB2rK7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 41ADA80309EB; Wed, 13 Dec 2023 09:07:22 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233693AbjLMRHN (ORCPT <rfc822;dexuan.linux@gmail.com> + 99 others); Wed, 13 Dec 2023 12:07:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229458AbjLMRHM (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 13 Dec 2023 12:07:12 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35BE7E4; Wed, 13 Dec 2023 09:07:18 -0800 (PST) Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 3BDGeQdj030900; Wed, 13 Dec 2023 17:06:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:date:subject:mime-version:content-type :content-transfer-encoding:message-id:references:in-reply-to:to :cc; s=qcppdkim1; bh=HBkJg4RH7YDK3ha87v5K+pqVsnazTKHG8ainsAEr/kU =; b=AolB2rK7cKPRJt6zGVQNTGvgG696ifM6Qf6/yAJq3DaUXMmpU8pOre3nvGs WPNzQRgDqhZy4jNA+i/gL17hTcqBqLcI5lM69SKK9I49+/hG4nCX5XERz+9sQZv0 13305rDqkghovhH5U2jva30tPFbKahlu4TOHfnDQBMe41Fwskq7WfWG3useoWJkj sIWJHrmoeHogu1RNO+H2BcuxlLhXHMi7T9NOczvRq82GAEq/lBOhnQSOjuaNhnRX fLEXCmkKfluCKY74U3zXvWJKlgHdyrx1Hnu76GQ57NTrIwKvgVocfAyD5+48VQpM ctxj7ghaTO0567z16rMS4l8mFMA== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3uy3rpt008-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Dec 2023 17:06:42 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3BDH6ggn024422 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Dec 2023 17:06:42 GMT Received: from [169.254.0.1] (10.49.16.6) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Wed, 13 Dec 2023 09:06:41 -0800 From: Jeff Johnson <quic_jjohnson@quicinc.com> Date: Wed, 13 Dec 2023 09:06:43 -0800 Subject: [PATCH 5/6] wifi: ath10k: use flexible array in struct wmi_tdls_peer_capabilities MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-ID: <20231213-wmi_host_mem_chunks_flexarray-v1-5-92922d92fa2c@quicinc.com> References: <20231213-wmi_host_mem_chunks_flexarray-v1-0-92922d92fa2c@quicinc.com> In-Reply-To: <20231213-wmi_host_mem_chunks_flexarray-v1-0-92922d92fa2c@quicinc.com> To: Kalle Valo <kvalo@kernel.org>, Jeff Johnson <quic_jjohnson@quicinc.com> CC: Kees Cook <keescook@chromium.org>, "Gustavo A. R. Silva" <gustavo@embeddedor.com>, <ath10k@lists.infradead.org>, <linux-wireless@vger.kernel.org>, <linux-kernel@vger.kernel.org> X-Mailer: b4 0.12.3 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01b.na.qualcomm.com (10.47.209.197) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: lFjd1BGrthF5pN5KiuQOD21E2VVZ7ela X-Proofpoint-GUID: lFjd1BGrthF5pN5KiuQOD21E2VVZ7ela X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-09_01,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 spamscore=0 mlxscore=0 suspectscore=0 impostorscore=0 adultscore=0 malwarescore=0 mlxlogscore=817 bulkscore=0 priorityscore=1501 phishscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2312130122 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 13 Dec 2023 09:07:22 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785187263893725030 X-GMAIL-MSGID: 1785187263893725030 |
Series |
wifi: ath10k: use flexible arrays
|
|
Commit Message
Jeff Johnson
Dec. 13, 2023, 5:06 p.m. UTC
Currently struct wmi_tdls_peer_capabilities defines:
struct wmi_channel peer_chan_list[1];
Per the guidance in [1] this should be a flexible array, and at one
point Gustavo was trying to fix this [2], but had questions about the
correct behavior when the associated peer_chan_len is 0.
I have been unable to determine if firmware requires that at least one
record be present even if peer_chan_len is 0. But since that is the
current behavior, follow the example from [3] and replace the
one-element array with a union that contains both a flexible array and
a single instance of the array element. This results in a struct that
has the same footprint as the original, so no other driver changes are
required.
No functional changes, compile tested only.
[1] https://docs.kernel.org/process/deprecated.html#zero-length-and-one-element-arrays
[2] https://lore.kernel.org/linux-wireless/626ae2e7-66f8-423b-b17f-e75c1a6d29b3@embeddedor.com/
[3] https://lore.kernel.org/linux-wireless/202308301529.AC90A9EF98@keescook/
Signed-off-by: Jeff Johnson <quic_jjohnson@quicinc.com>
---
drivers/net/wireless/ath/ath10k/wmi.h | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
Comments
On Wed, Dec 13, 2023 at 09:06:43AM -0800, Jeff Johnson wrote: > Currently struct wmi_tdls_peer_capabilities defines: > struct wmi_channel peer_chan_list[1]; > > Per the guidance in [1] this should be a flexible array, and at one > point Gustavo was trying to fix this [2], but had questions about the > correct behavior when the associated peer_chan_len is 0. > > I have been unable to determine if firmware requires that at least one > record be present even if peer_chan_len is 0. But since that is the > current behavior, follow the example from [3] and replace the > one-element array with a union that contains both a flexible array and > a single instance of the array element. This results in a struct that > has the same footprint as the original, so no other driver changes are > required. > > No functional changes, compile tested only. > > [1] https://docs.kernel.org/process/deprecated.html#zero-length-and-one-element-arrays > [2] https://lore.kernel.org/linux-wireless/626ae2e7-66f8-423b-b17f-e75c1a6d29b3@embeddedor.com/ > [3] https://lore.kernel.org/linux-wireless/202308301529.AC90A9EF98@keescook/ > > Signed-off-by: Jeff Johnson <quic_jjohnson@quicinc.com> Again, good to keep the struct the same size. Reviewed-by: Kees Cook <keescook@chromium.org>
On 12/13/23 11:06, Jeff Johnson wrote: > Currently struct wmi_tdls_peer_capabilities defines: > struct wmi_channel peer_chan_list[1]; > > Per the guidance in [1] this should be a flexible array, and at one > point Gustavo was trying to fix this [2], but had questions about the > correct behavior when the associated peer_chan_len is 0. > > I have been unable to determine if firmware requires that at least one > record be present even if peer_chan_len is 0. But since that is the > current behavior, follow the example from [3] and replace the > one-element array with a union that contains both a flexible array and > a single instance of the array element. This results in a struct that > has the same footprint as the original, so no other driver changes are > required. > > No functional changes, compile tested only. > > [1] https://docs.kernel.org/process/deprecated.html#zero-length-and-one-element-arrays > [2] https://lore.kernel.org/linux-wireless/626ae2e7-66f8-423b-b17f-e75c1a6d29b3@embeddedor.com/ > [3] https://lore.kernel.org/linux-wireless/202308301529.AC90A9EF98@keescook/ > > Signed-off-by: Jeff Johnson <quic_jjohnson@quicinc.com> Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org> Thanks! -- Gustavo > --- > drivers/net/wireless/ath/ath10k/wmi.h | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/wireless/ath/ath10k/wmi.h b/drivers/net/wireless/ath/ath10k/wmi.h > index e16410e348ca..b64b6e214bae 100644 > --- a/drivers/net/wireless/ath/ath10k/wmi.h > +++ b/drivers/net/wireless/ath/ath10k/wmi.h > @@ -7162,7 +7162,13 @@ struct wmi_tdls_peer_capabilities { > __le32 is_peer_responder; > __le32 pref_offchan_num; > __le32 pref_offchan_bw; > - struct wmi_channel peer_chan_list[1]; > + union { > + /* to match legacy implementation allocate room for > + * at least one record even if peer_chan_len is 0 > + */ > + struct wmi_channel peer_chan_min_allocation; > + DECLARE_FLEX_ARRAY(struct wmi_channel, peer_chan_list); > + }; > } __packed; > > struct wmi_10_4_tdls_peer_update_cmd { >
diff --git a/drivers/net/wireless/ath/ath10k/wmi.h b/drivers/net/wireless/ath/ath10k/wmi.h index e16410e348ca..b64b6e214bae 100644 --- a/drivers/net/wireless/ath/ath10k/wmi.h +++ b/drivers/net/wireless/ath/ath10k/wmi.h @@ -7162,7 +7162,13 @@ struct wmi_tdls_peer_capabilities { __le32 is_peer_responder; __le32 pref_offchan_num; __le32 pref_offchan_bw; - struct wmi_channel peer_chan_list[1]; + union { + /* to match legacy implementation allocate room for + * at least one record even if peer_chan_len is 0 + */ + struct wmi_channel peer_chan_min_allocation; + DECLARE_FLEX_ARRAY(struct wmi_channel, peer_chan_list); + }; } __packed; struct wmi_10_4_tdls_peer_update_cmd {