Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2604042imu; Mon, 19 Nov 2018 03:17:25 -0800 (PST) X-Google-Smtp-Source: AJdET5ctQ4iwefZhzsBwNOgDZvmRuMTCQGh/4VSdoVgiI2AHuGbgyRFq5nSNFHhFR5g5A9FM8oGs X-Received: by 2002:a17:902:8507:: with SMTP id bj7-v6mr21536316plb.99.1542626245085; Mon, 19 Nov 2018 03:17:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542626245; cv=none; d=google.com; s=arc-20160816; b=WvyUtbmhZnXZ9N0DBb8f7AML0GddOw3CVs+e6UIbX4H/Sb+HiK3JN71d1Wpsuhptqe 1ybuz+b8sqqG0AnlZCRZ0nCVOd4nSfV1HTIc36B5eS+fhkCVgiQlowP3oEtLlYVkxGRV I3Q0uczohYAOOufVvNwQSAjEXhNS5y3C0wTbaTFkCOmsZ6HjYU7ybNd1cQuweFpcUJfg 1wWOLE39CEMcVAuy41MyRr4H0ufgGm1KKEre9xPVm4aAZ5Eu/SY0yiu75Q/paqcoRP3k NYkoyB/cGougUlbPiWpX/9GkKMPQW4x8IYdNA6FuVscpe3pVabp+3ooHESWHMFsXZN3Q vV/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=m2aVc8a7iS5ByscS0VScNypZVH72xHYhK5jzuzui1/o=; b=TPMVHn3GQm5M6wBso5YbVmq/suDXVoS+ojkV/8mmJQ3SHH+ctIOjt6QY3CIr4S5HI1 gL1FDqvov9o5mn+G1JahQKbH6T9H995UHYiqB1QF3uJXZcy47YuqNJXcSUjzSPoGQOro c2ZB27jZGE/u9Dl7hVQ2YDqLKoTvQUmxi9cJRzF3JAzW3N5O8zMyp8775/eno8LaoXUM kM4o8RdREeM2jybyxp6Qhl6kl9+ZhZ69JR5mfeJGgOHr94aMBtE98B0XDZX/rKDvOLw/ MshmiUYuIC1EuPOqrO7DXkRx0PGRaDIxtjC/0/AO5gY3QJDgabwNiaRaWcP/W8wUgzYn 5Qqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@plaes.org header.s=mail header.b=CQ8spknN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u72si39781219pgc.360.2018.11.19.03.17.10; Mon, 19 Nov 2018 03:17:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@plaes.org header.s=mail header.b=CQ8spknN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728685AbeKSVho (ORCPT + 99 others); Mon, 19 Nov 2018 16:37:44 -0500 Received: from plaes.org ([188.166.43.21]:45964 "EHLO plaes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728557AbeKSVhn (ORCPT ); Mon, 19 Nov 2018 16:37:43 -0500 Received: from plaes.org (localhost [127.0.0.1]) by plaes.org (Postfix) with ESMTPSA id 9112B40282; Mon, 19 Nov 2018 11:14:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=plaes.org; s=mail; t=1542626063; bh=0aXq0jHH2dIIrN9BHuRRU2v7P8vIWouXCDJtrFzJZlc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=CQ8spknN404eVnSBpNSloUrPkTs7U7LWRoKVuivP4hIrf9IeGQyK/jDOUYpY0lPn/ HW4Zf4cQnfXEju0v3TA3V9ZM50plw75Fa6J9Z5Yg19x7YFHMM66/w0E2aLKh6Do4tS 8nj5ndmCZ++D1fe0nzWnV7Zw3qkR0y/R7S7PzP6btmKcaD+xoj/QBfc0+8AMc4SPhH G8DKWHU8Q36iq2UJ/PlXWHjL7qOqjMgl4N53iBDuV7RuczIjEkG9LwDQlvvTVvHcjt s2VcG3pmF8SVl+tDxdqBx+oKI8p4gAXoGMpZvJH/S/uqYv2JyW+KqG71LAEXX3tknl v1C3l2B5X2q4g== Date: Mon, 19 Nov 2018 11:14:22 +0000 From: Priit Laes To: Kalle Valo Cc: Larry Finger , Kees Cook , Jia-Ju Bai , "Gustavo A. R. Silva" , Colin Ian King , Arend van Spriel , Varsha Rao , linux-wireless@vger.kernel.org, b43-dev@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 3/3] b43: Use cordic algorithm from kernel library Message-ID: <20181119111422.6vbxnmo4lgm6kl55@plaes.org> References: <20181118082327.ttrz2nl5owi2hoqv@plaes.org> <87lg5pcppn.fsf@kamboji.qca.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87lg5pcppn.fsf@kamboji.qca.qualcomm.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 19, 2018 at 12:43:32PM +0200, Kalle Valo wrote: > Larry Finger writes: > > >>>> @@ -1570,10 +1571,10 @@ static u16 b43_nphy_gen_load_samples(struct b43_wldev *dev, u32 freq, u16 max, > >>>> angle = 0; > >>>> for (i = 0; i < len; i++) { > >>>> - samples[i] = b43_cordic(angle); > >>>> + samples[i] = cordic_calc_iq(angle); > >>>> angle += rot; > >>>> - samples[i].q = CORDIC_CONVERT(samples[i].q * max); > >>>> - samples[i].i = CORDIC_CONVERT(samples[i].i * max); > >>>> + samples[i].q = CORDIC_FLOAT(samples[i].q * max); > >>>> + samples[i].i = CORDIC_FLOAT(samples[i].i * max); > >>>> } > >>>> i = b43_nphy_load_samples(dev, samples, len); > >>> > >>> There is a fundamental flaw in this patch. Routine b43_cordic() takes an > >>> angle in degrees scaled by 2^16, whereas cordic_calc_iq() takes an angle in > >>> degrees. For a given input, the two routines must get different answers. At > >>> a minimum, the calculation of rot would need to remove the left shift of 16. > >> > >> Thanks for the hint. I modified my "test harness" a bit to plot out values > >> from -360 .. 360 and transformed the theta for b43_cordic argument > >> using CORDIC_FIXED macro: > >> > >> b43_cordic(CORDIC_FIXED(theta)); > >> cordic_calc_iq(theta); > >> > >> Then I plotted the results and well.. they are not that pretty. > >> While the results give > >> identical answers between certain ranges of degrees, the cordic > >> algorithm for b43 seems > >> to be broken for certain ranges: (-270..-180 ; -90 .. 0; 90.. 180 and 270..360). > >> > >> You can find my test harnesses here: > >> > >> https://gist.github.com/plaes/284993a4fc65e0926d0628a11f0cf874 > > > > I found a problem with the b43 implementation. The local variables for > > that routine includes > > > > u32 angle = 0; > > > > If one looks further down in the algorithm, if the reduced value of > > "theta" is less than 0, then "angle" should be negative. That causes > > the calculation to blow up. This explains why some ranges of angles > > got the same result for both routines. When that declaration is > > changed to "int angle = 0", the two routines give the same answer for > > all inputs. > > > > My test setup has a hardware failure, thus I cannot test your patch, > > but I now believe it to be correct. Thus your first and third patches > > may be annotated with > > ACKed-by: Larry Finger > > > > One thing that should be done is to fix the error in the b43 code for > > stable as it was introduced in 2.6.34. I propose adding the attached > > patched to your series placed between your current 2nd and 3rd patches > > so that the old kernels get fixed. Of course, your 3rd patch will need > > to be revised. If all 4 of the patches get submitted together there > > will be no problems with the timing. My change will exist for seconds > > in the mainline kernel, but it will get propagated back through > > stable. > > Sorry Larry, I'm not fully understanding what you mean here. So I'm > going to just drop the whole series and assume that Priit will submit a > new version. Please let me know if I should do something else. Yes, drop this one and I will submit v4 with one extra patch fixing the cordic algorithm in the stable kernel. > > -- > Kalle Valo