All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ath9k_hw: fix PA predistortion miscalibration
@ 2013-05-28 16:04 Felix Fietkau
  2013-05-28 17:37 ` Dan Williams
  2013-05-28 17:45 ` John W. Linville
  0 siblings, 2 replies; 4+ messages in thread
From: Felix Fietkau @ 2013-05-28 16:04 UTC (permalink / raw)
  To: linux-wireless; +Cc: linville, mcgrof, felixb

If any bins from the training data are skipped (i != max_index), the
calculated compensation curve gets distorted, and the signal will be
wildly overamplified. This may be the cause of the reported hardware
damage that was caused by PA predistortion (because of which PAPRD was
disabled by default).

When calculating the x_est, Y, theta values, the use of max_index and i
was reversed. i points to the bin index whereas max_index refers to the
index of the calculated arrays.

Note that PA predistortion is still disabled, it will be re-enabled
after it has been properly validated.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
---
 drivers/net/wireless/ath/ath9k/ar9003_paprd.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
index 09c1f9d..6343cc9 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
@@ -454,6 +454,8 @@ static bool create_pa_curve(u32 *data_L, u32 *data_U, u32 *pa_table, u16 *gain)
 		if (accum_cnt <= thresh_accum_cnt)
 			continue;
 
+		max_index++;
+
 		/* sum(tx amplitude) */
 		accum_tx = ((data_L[i] >> 16) & 0xffff) |
 		    ((data_U[i] & 0x7ff) << 16);
@@ -468,20 +470,21 @@ static bool create_pa_curve(u32 *data_L, u32 *data_U, u32 *pa_table, u16 *gain)
 
 		accum_tx <<= scale_factor;
 		accum_rx <<= scale_factor;
-		x_est[i + 1] = (((accum_tx + accum_cnt) / accum_cnt) + 32) >>
-		    scale_factor;
+		x_est[max_index] =
+			(((accum_tx + accum_cnt) / accum_cnt) + 32) >>
+			scale_factor;
 
-		Y[i + 1] = ((((accum_rx + accum_cnt) / accum_cnt) + 32) >>
+		Y[max_index] =
+			((((accum_rx + accum_cnt) / accum_cnt) + 32) >>
 			    scale_factor) +
-			    (1 << scale_factor) * max_index + 16;
+			(1 << scale_factor) * i + 16;
 
 		if (accum_ang >= (1 << 26))
 			accum_ang -= 1 << 27;
 
-		theta[i + 1] = ((accum_ang * (1 << scale_factor)) + accum_cnt) /
-		    accum_cnt;
-
-		max_index++;
+		theta[max_index] =
+			((accum_ang * (1 << scale_factor)) + accum_cnt) /
+			accum_cnt;
 	}
 
 	/*
-- 
1.8.0.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ath9k_hw: fix PA predistortion miscalibration
  2013-05-28 16:04 [PATCH] ath9k_hw: fix PA predistortion miscalibration Felix Fietkau
@ 2013-05-28 17:37 ` Dan Williams
  2013-05-28 17:45 ` John W. Linville
  1 sibling, 0 replies; 4+ messages in thread
From: Dan Williams @ 2013-05-28 17:37 UTC (permalink / raw)
  To: Felix Fietkau; +Cc: linux-wireless, linville, mcgrof, felixb

On Tue, 2013-05-28 at 18:04 +0200, Felix Fietkau wrote:
> If any bins from the training data are skipped (i != max_index), the
> calculated compensation curve gets distorted, and the signal will be
> wildly overamplified. This may be the cause of the reported hardware
> damage that was caused by PA predistortion (because of which PAPRD was
> disabled by default).
> 
> When calculating the x_est, Y, theta values, the use of max_index and i
> was reversed. i points to the bin index whereas max_index refers to the
> index of the calculated arrays.

Maybe add a comment in the code about the meaning of max_index and i, if
there isn't one already?

Dan

> Note that PA predistortion is still disabled, it will be re-enabled
> after it has been properly validated.
> 
> Signed-off-by: Felix Fietkau <nbd@openwrt.org>
> ---
>  drivers/net/wireless/ath/ath9k/ar9003_paprd.c | 19 +++++++++++--------
>  1 file changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
> index 09c1f9d..6343cc9 100644
> --- a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
> +++ b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
> @@ -454,6 +454,8 @@ static bool create_pa_curve(u32 *data_L, u32 *data_U, u32 *pa_table, u16 *gain)
>  		if (accum_cnt <= thresh_accum_cnt)
>  			continue;
>  
> +		max_index++;
> +
>  		/* sum(tx amplitude) */
>  		accum_tx = ((data_L[i] >> 16) & 0xffff) |
>  		    ((data_U[i] & 0x7ff) << 16);
> @@ -468,20 +470,21 @@ static bool create_pa_curve(u32 *data_L, u32 *data_U, u32 *pa_table, u16 *gain)
>  
>  		accum_tx <<= scale_factor;
>  		accum_rx <<= scale_factor;
> -		x_est[i + 1] = (((accum_tx + accum_cnt) / accum_cnt) + 32) >>
> -		    scale_factor;
> +		x_est[max_index] =
> +			(((accum_tx + accum_cnt) / accum_cnt) + 32) >>
> +			scale_factor;
>  
> -		Y[i + 1] = ((((accum_rx + accum_cnt) / accum_cnt) + 32) >>
> +		Y[max_index] =
> +			((((accum_rx + accum_cnt) / accum_cnt) + 32) >>
>  			    scale_factor) +
> -			    (1 << scale_factor) * max_index + 16;
> +			(1 << scale_factor) * i + 16;
>  
>  		if (accum_ang >= (1 << 26))
>  			accum_ang -= 1 << 27;
>  
> -		theta[i + 1] = ((accum_ang * (1 << scale_factor)) + accum_cnt) /
> -		    accum_cnt;
> -
> -		max_index++;
> +		theta[max_index] =
> +			((accum_ang * (1 << scale_factor)) + accum_cnt) /
> +			accum_cnt;
>  	}
>  
>  	/*



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ath9k_hw: fix PA predistortion miscalibration
  2013-05-28 16:04 [PATCH] ath9k_hw: fix PA predistortion miscalibration Felix Fietkau
  2013-05-28 17:37 ` Dan Williams
@ 2013-05-28 17:45 ` John W. Linville
  2013-05-28 20:21   ` Felix Fietkau
  1 sibling, 1 reply; 4+ messages in thread
From: John W. Linville @ 2013-05-28 17:45 UTC (permalink / raw)
  To: Felix Fietkau; +Cc: linux-wireless, mcgrof, felixb

Is this a fix for 3.10?  Should it go to stable?

On Tue, May 28, 2013 at 06:04:44PM +0200, Felix Fietkau wrote:
> If any bins from the training data are skipped (i != max_index), the
> calculated compensation curve gets distorted, and the signal will be
> wildly overamplified. This may be the cause of the reported hardware
> damage that was caused by PA predistortion (because of which PAPRD was
> disabled by default).
> 
> When calculating the x_est, Y, theta values, the use of max_index and i
> was reversed. i points to the bin index whereas max_index refers to the
> index of the calculated arrays.
> 
> Note that PA predistortion is still disabled, it will be re-enabled
> after it has been properly validated.
> 
> Signed-off-by: Felix Fietkau <nbd@openwrt.org>
> ---
>  drivers/net/wireless/ath/ath9k/ar9003_paprd.c | 19 +++++++++++--------
>  1 file changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
> index 09c1f9d..6343cc9 100644
> --- a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
> +++ b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c
> @@ -454,6 +454,8 @@ static bool create_pa_curve(u32 *data_L, u32 *data_U, u32 *pa_table, u16 *gain)
>  		if (accum_cnt <= thresh_accum_cnt)
>  			continue;
>  
> +		max_index++;
> +
>  		/* sum(tx amplitude) */
>  		accum_tx = ((data_L[i] >> 16) & 0xffff) |
>  		    ((data_U[i] & 0x7ff) << 16);
> @@ -468,20 +470,21 @@ static bool create_pa_curve(u32 *data_L, u32 *data_U, u32 *pa_table, u16 *gain)
>  
>  		accum_tx <<= scale_factor;
>  		accum_rx <<= scale_factor;
> -		x_est[i + 1] = (((accum_tx + accum_cnt) / accum_cnt) + 32) >>
> -		    scale_factor;
> +		x_est[max_index] =
> +			(((accum_tx + accum_cnt) / accum_cnt) + 32) >>
> +			scale_factor;
>  
> -		Y[i + 1] = ((((accum_rx + accum_cnt) / accum_cnt) + 32) >>
> +		Y[max_index] =
> +			((((accum_rx + accum_cnt) / accum_cnt) + 32) >>
>  			    scale_factor) +
> -			    (1 << scale_factor) * max_index + 16;
> +			(1 << scale_factor) * i + 16;
>  
>  		if (accum_ang >= (1 << 26))
>  			accum_ang -= 1 << 27;
>  
> -		theta[i + 1] = ((accum_ang * (1 << scale_factor)) + accum_cnt) /
> -		    accum_cnt;
> -
> -		max_index++;
> +		theta[max_index] =
> +			((accum_ang * (1 << scale_factor)) + accum_cnt) /
> +			accum_cnt;
>  	}
>  
>  	/*
> -- 
> 1.8.0.2
> 
> 

-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ath9k_hw: fix PA predistortion miscalibration
  2013-05-28 17:45 ` John W. Linville
@ 2013-05-28 20:21   ` Felix Fietkau
  0 siblings, 0 replies; 4+ messages in thread
From: Felix Fietkau @ 2013-05-28 20:21 UTC (permalink / raw)
  To: John W. Linville; +Cc: linux-wireless, mcgrof, felixb

On 2013-05-28 7:45 PM, John W. Linville wrote:
> Is this a fix for 3.10?  Should it go to stable?
PA predistortion has been disabled for a few releases now. It'll
probably take some time to get this functionality properly validated, so
having this fix in 3.11 is good enough.

- Felix


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-05-28 20:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-28 16:04 [PATCH] ath9k_hw: fix PA predistortion miscalibration Felix Fietkau
2013-05-28 17:37 ` Dan Williams
2013-05-28 17:45 ` John W. Linville
2013-05-28 20:21   ` Felix Fietkau

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.