Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp337835lqb; Thu, 14 Mar 2024 12:39:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUqUBPxSYJlTCtj0UCKZV9zjKEsJxygKfD9pVkjFpSRisCBlmSjSAvn0gj2iKpYQUn3vZ3eFS4ifMaeWm9fl6NxYqFefgneU1jDvEjpAA== X-Google-Smtp-Source: AGHT+IHnu9djCtSjSkaDQvLOs0sYTM5b+LBFR18DqOetAomNxfX3QXe3Ei5FJnKsVWhld47+UwTy X-Received: by 2002:a05:620a:47aa:b0:788:264a:73c2 with SMTP id dt42-20020a05620a47aa00b00788264a73c2mr1895254qkb.39.1710445157768; Thu, 14 Mar 2024 12:39:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710445157; cv=pass; d=google.com; s=arc-20160816; b=yPJv99hCNuhgBtdrYFp06W96Zn49xDEREG3km0Y8NTE/UYqCSOv6IonvGf0qt7BFnt atItkfpc3ObrnlFmK8y+kQRBz16bj2qjQeaYesCvCBrM7R0gKfUh+AR7XnDGhBsjS9yt +tir92huyBu0hKTsZpuIXnRTtUgLaC70S021WZVKi61MbVhJ/ZdjIY9cyPlBAahH1Db7 bjZvn2sC7xDZBGSCs5Aqk5FrysVU4d3stOPwcV9c06iWvFpRUAIX8ITMGjxeTrB/6UQH OsnkB72lwqXl/+B7NnOfQHHD65XgIVjGD+o+hQw3ag2NBs2k5MhfaqWQr3m7ELw+l1cP MIKw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=B/KaWl0GPaaZMb8ZSsPnu+zNN9UBDBkXGIQ15mbtGUE=; fh=A/guFSLMWbHYvzWkG4uRcSH7plflvNt4K18lm9ZmgYk=; b=Bpr7dX1DdvGi7lTJoNZsxwAwj4PVjr7qMDC2G+etPSr6p5cIoJ2gSlwT1UV8dcsgn5 gJfgWAbzka87obpqTVGx7yMnLfsVy2MY+RjJXRsDLpl4LH7JRvgfZi8uucqDF2eEpVx5 xrGFp1rYUF7JAmDcWXK+9+9Wpn1jREmbCzKVXgP/4B1kTD8wavaFXK+YGV/GGjsu5tcg bqiUO8fpoJ/NOWpu0600EZPG1EhYm3/E+qzwA8J71gBJ63rnqlwIpY0irChpZMdrrFJ6 VGTnsE5Xc01RK09w9M0dBgTuVLLb8zdjzeqOCU5mNE+Kd/oyTztUfHZ5uLBX5suxqZkP ho6A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="THa41/Ga"; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-wireless+bounces-4771-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-4771-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id l13-20020a05620a0c0d00b0078833fb85c1si2046311qki.570.2024.03.14.12.39.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 12:39:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-4771-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="THa41/Ga"; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-wireless+bounces-4771-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-4771-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 6F0291C21314 for ; Thu, 14 Mar 2024 19:39:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 651C974BED; Thu, 14 Mar 2024 19:39:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="THa41/Ga" X-Original-To: linux-wireless@vger.kernel.org Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C306D2E410 for ; Thu, 14 Mar 2024 19:39:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710445154; cv=none; b=oAwXIzG+yRIx5L5jXI4KkUtXy/kkrSvlun2j7nHSFGPgXooi3PbmcH0HdPpi9/qU3o7xh2Xt4boHRN4sKOULmmDJZb02Sx5yc/lRClN+Tbc+ANFoJ4OKkZsYPkCDXqEsCzsg8PymLqssJF3QsR1PnU3BX4EQE+FdRTB/DLUYj9o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710445154; c=relaxed/simple; bh=yO1Y9ijNN5HaD+qJhn+gjdK4bWQxw3YOGyQhAb5wyvs=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=ajy3OBS1RnOqmxMdulpocKqKXk/7+610uYC69JYkPMLI8ll5caVrPaKSerOSHZxR6TuE5ueBcVcodPIgzWL64QNsqKB4BIaUVWGAyqKBiEU9WXCOvoKYn511uTjKszJy7WU0KZCK47tb9QncI1iY65iSu38UW50vBrmHuDNEYXI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=THa41/Ga; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 42EIMmt7022229; Thu, 14 Mar 2024 19:39:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= message-id:date:mime-version:subject:to:cc:references:from :in-reply-to:content-type:content-transfer-encoding; s= qcppdkim1; bh=B/KaWl0GPaaZMb8ZSsPnu+zNN9UBDBkXGIQ15mbtGUE=; b=TH a41/GaB+S41ITRbJw/hVbZa1hX7u+WxqPHI49eYSqGgNvBYwyMTw+hV5GHWCo+a+ dakDrJWFhFsTo/RKhDwam+WjMjOUUrRu17wOsz+jIFZ0Z2mdeYMbGsa6ZgjyC7yq LJsRWZqMhliqpYMLG081fgomwQcFMONOZ/2p+P3wlkc6grLQtO6MGzAsoQmaxNI8 EH8x4alcpVerOKPMHqKuZmYTxYC4in55tdD4LWc2LCrPY5ND+RAsoQTz2BTtwcf9 7fVG5Ah7HK3WkBxJiB7xVxcfa4uFfX9LTTZGSda+fSTv9S3mQw+TfRksdWRBdKe9 38D3PEI2KuVLJm8g0ymg== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3wuujsst9r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 Mar 2024 19:39:05 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 42EJd4Pr021692 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 Mar 2024 19:39:04 GMT Received: from [10.50.25.76] (10.80.80.8) 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; Thu, 14 Mar 2024 12:39:01 -0700 Message-ID: Date: Fri, 15 Mar 2024 01:08:56 +0530 Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 01/12] wifi: ath12k: add multiple radio support in a single MAC HW un/register Content-Language: en-US To: Jonas Gorski , Jeff Johnson , Kalle Valo CC: , , Karthikeyan Periyasamy References: <20240312135557.1778379-1-quic_ramess@quicinc.com> <20240312135557.1778379-2-quic_ramess@quicinc.com> <4a527729-2bf8-47ce-8275-d36b76bde95c@quicinc.com> <3178cf8c-d328-4fe2-b3be-f5c4c908f20f@quicinc.com> <605a673e-3686-47d0-b71b-1e314fde65db@quicinc.com> <87il1qf571.fsf@kernel.org> <87edcef4qi.fsf@kernel.org> From: Rameshkumar Sundaram In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: 0_OefDgNq13k7S93VxIRSDVzQWLAKFsD X-Proofpoint-GUID: 0_OefDgNq13k7S93VxIRSDVzQWLAKFsD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-14_13,2024-03-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 bulkscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 clxscore=1011 impostorscore=0 lowpriorityscore=0 mlxlogscore=999 spamscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2402120000 definitions=main-2403140152 On 3/14/2024 1:26 AM, Jonas Gorski wrote: > On Wed, 13 Mar 2024 at 20:18, Jeff Johnson wrote: >> >> On 3/13/2024 9:58 AM, Kalle Valo wrote: >>> Kalle Valo writes: >>> >>>> Jeff Johnson writes: >>>> >>>>> On 3/13/2024 5:57 AM, Rameshkumar Sundaram wrote: >>>>>> On 3/13/2024 3:23 AM, Jeff Johnson wrote: >>>>>>> and guess we have to figure out how to suppress the ath12k-check issues with >>>>>>> this macro >>>>>> ath12k-check complains about the reuse of ah and index arguments which >>>>>> may get evaluated multiple times if its an arithmetic expression, But >>>>>> areas where we use the macro in our code aren't doing so. >>>>>> Do you have any suggestions here ? or shall we go back and use this >>>>>> for-loop inline. >>>>> >>>>> The macro makes sense -- we'll need to update the overrides in ath12k-check. >>>> >>>> IIRC it is possible to avoid variable reuse in macros with typeof() >>>> operator (or something like that). I can't remember the details right >>>> now but I think there are examples in the kernel code. >>> >>> Here's the GCC documentation with an example: >>> >>> https://gcc.gnu.org/onlinedocs/gcc/Typeof.html >>> Thanks Kalle for the references, as Jeff mentioned below, we need to reuse the arguments since we write to ar and index arguments on each iteration. Defining local vars using typeof() without limiting their scope (since we are defining a for_each iterator{}) leads other issues like redefinition of variables in functions where we use this macro more than once :( Also even if we somehow manage to convince check-patch, we'll still end up evaluating index and ar arguments in every iteration of loop. This just gives an impression to check-patch that the macro is unsafe (although logically its not). Experts, what is the standard we should follow here. Please suggest. >> >> the problem here is that the macro actually writes to those arguments multiple >> times, so we actually need to reuse the arguments >> >> the macro as defined exactly matches the semantics of other for_each macros in >> the kernel, i.e. see in include/linux/list.h: >> #define list_for_each(pos, head) \ >> for (pos = (head)->next; !list_is_head(pos, (head)); pos = pos->next) >> >> what I don't understand is why list_for_each() doesn't trigger the same >> checkpatch issues. even stranger is that if I copy that macro into ath12k then >> I do see the same checkpatch issues: >> CHECK: Macro argument reuse 'pos' - possible side-effects? >> #998: FILE: drivers/net/wireless/ath/ath12k/core.h:998: >> +#define list_for_each(pos, head) \ >> + for (pos = (head)->next; !list_is_head(pos, (head)); pos = pos->next) >> >> CHECK: Macro argument reuse 'head' - possible side-effects? >> #998: FILE: drivers/net/wireless/ath/ath12k/core.h:998: >> +#define list_for_each(pos, head) \ >> + for (pos = (head)->next; !list_is_head(pos, (head)); pos = pos->next) >> >> So I'm really confused since I don't see anything in checkpatch.pl that would >> cause the behavior to change between macros in include/linux/list.h vs macros >> in drivers/net/wireless/ath/ath12k/core.h > > The definition of the macro causes the complaint, not the usage of it. > If you run checkpatch.pl on include/linux/list.h, you'll get the same > output: > > $ ./scripts/checkpatch.pl --strict --file include/linux/list.h > ... > CHECK: Macro argument reuse 'pos' - possible side-effects? > #686: FILE: include/linux/list.h:686: > +#define list_for_each(pos, head) \ > + for (pos = (head)->next; !list_is_head(pos, (head)); pos = pos->next) > > CHECK: Macro argument reuse 'head' - possible side-effects? > #686: FILE: include/linux/list.h:686: > +#define list_for_each(pos, head) \ > + for (pos = (head)->next; !list_is_head(pos, (head)); pos = pos->next) > ... Thanks Jonas and Jeff for your insights!!