[cosmic,bionic] scsi: megaraid_sas: Use 63-bit DMA addressing

Message ID 20190129170759.15118-1-marcelo.cerri@canonical.com
State New
Headers show
Series
  • [cosmic,bionic] scsi: megaraid_sas: Use 63-bit DMA addressing
Related show

Commit Message

Marcelo Henrique Cerri Jan. 29, 2019, 5:07 p.m.
From: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>

BugLink: http://bugs.launchpad.net/bugs/1795453

Although MegaRAID controllers support 64-bit DMA addressing, as per
hardware design, DMA address with all 64-bits set
(0xFFFFFFFF-FFFFFFFF) results in a firmware fault.

Driver will set 63-bit DMA mask to ensure the above address will not be
used.

Cc: stable@vger.kernel.org
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 894169db12463cea08d0e2a9e35f42b291340e5a)
[mhcerri: fixed context]
Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>

Conflicts:
	drivers/scsi/megaraid/megaraid_sas_base.c
---
 drivers/scsi/megaraid/megaraid_sas_base.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

Comments

Colin King Jan. 29, 2019, 5:12 p.m. | #1
On 29/01/2019 17:07, Marcelo Henrique Cerri wrote:
> From: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
> 
> BugLink: http://bugs.launchpad.net/bugs/1795453
> 
> Although MegaRAID controllers support 64-bit DMA addressing, as per
> hardware design, DMA address with all 64-bits set
> (0xFFFFFFFF-FFFFFFFF) results in a firmware fault.
> 
> Driver will set 63-bit DMA mask to ensure the above address will not be
> used.
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
> (cherry picked from commit 894169db12463cea08d0e2a9e35f42b291340e5a)
> [mhcerri: fixed context]
> Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>
> 
> Conflicts:
> 	drivers/scsi/megaraid/megaraid_sas_base.c
> ---
>  drivers/scsi/megaraid/megaraid_sas_base.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
> index 2d6f6414a2a2..7b1a92dd844f 100644
> --- a/drivers/scsi/megaraid/megaraid_sas_base.c
> +++ b/drivers/scsi/megaraid/megaraid_sas_base.c
> @@ -6000,13 +6000,13 @@ static int megasas_io_attach(struct megasas_instance *instance)
>   * @instance:		Adapter soft state
>   * Description:
>   *
> - * For Ventura, driver/FW will operate in 64bit DMA addresses.
> + * For Ventura, driver/FW will operate in 63bit DMA addresses.
>   *
>   * For invader-
>   *	By default, driver/FW will operate in 32bit DMA addresses
>   *	for consistent DMA mapping but if 32 bit consistent
> - *	DMA mask fails, driver will try with 64 bit consistent
> - *	mask provided FW is true 64bit DMA capable
> + *	DMA mask fails, driver will try with 63 bit consistent
> + *	mask provided FW is true 63bit DMA capable
>   *
>   * For older controllers(Thunderbolt and MFI based adapters)-
>   *	driver/FW will operate in 32 bit consistent DMA addresses.
> @@ -6020,14 +6020,14 @@ megasas_set_dma_mask(struct megasas_instance *instance)
>  
>  	pdev = instance->pdev;
>  	consistent_mask = (instance->adapter_type == VENTURA_SERIES) ?
> -				DMA_BIT_MASK(64) : DMA_BIT_MASK(32);
> +				DMA_BIT_MASK(63) : DMA_BIT_MASK(32);
>  
>  	if (IS_DMA64) {
> -		if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)) &&
> +		if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(63)) &&
>  		    dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)))
>  			goto fail_set_dma_mask;
>  
> -		if ((*pdev->dev.dma_mask == DMA_BIT_MASK(64)) &&
> +		if ((*pdev->dev.dma_mask == DMA_BIT_MASK(63)) &&
>  		    (dma_set_coherent_mask(&pdev->dev, consistent_mask) &&
>  		     dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)))) {
>  			/*
> @@ -6040,7 +6040,7 @@ megasas_set_dma_mask(struct megasas_instance *instance)
>  			if (!(scratch_pad_2 & MR_CAN_HANDLE_64_BIT_DMA_OFFSET))
>  				goto fail_set_dma_mask;
>  			else if (dma_set_mask_and_coherent(&pdev->dev,
> -							   DMA_BIT_MASK(64)))
> +							   DMA_BIT_MASK(63)))
>  				goto fail_set_dma_mask;
>  		}
>  	} else if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)))
> @@ -6052,8 +6052,8 @@ megasas_set_dma_mask(struct megasas_instance *instance)
>  		instance->consistent_mask_64bit = true;
>  
>  	dev_info(&pdev->dev, "%s bit DMA mask and %s bit consistent mask\n",
> -		 ((*pdev->dev.dma_mask == DMA_BIT_MASK(64)) ? "64" : "32"),
> -		 (instance->consistent_mask_64bit ? "64" : "32"));
> +		 ((*pdev->dev.dma_mask == DMA_BIT_MASK(64)) ? "63" : "32"),
> +		 (instance->consistent_mask_64bit ? "63" : "32"));
>  
>  	return 0;
>  
> 
Positive test results. Cherry pick looks good.

Acked-by: Colin Ian King <colin.king@canonical.com>
Khaled Elmously Jan. 29, 2019, 5:14 p.m. | #2
On 2019-01-29 15:07:59 , Marcelo Henrique Cerri wrote:
> From: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
> 
> BugLink: http://bugs.launchpad.net/bugs/1795453
> 
> Although MegaRAID controllers support 64-bit DMA addressing, as per
> hardware design, DMA address with all 64-bits set
> (0xFFFFFFFF-FFFFFFFF) results in a firmware fault.
> 
> Driver will set 63-bit DMA mask to ensure the above address will not be
> used.
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
> (cherry picked from commit 894169db12463cea08d0e2a9e35f42b291340e5a)
> [mhcerri: fixed context]
> Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>
> 
> Conflicts:
> 	drivers/scsi/megaraid/megaraid_sas_base.c
> ---
>  drivers/scsi/megaraid/megaraid_sas_base.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
> index 2d6f6414a2a2..7b1a92dd844f 100644
> --- a/drivers/scsi/megaraid/megaraid_sas_base.c
> +++ b/drivers/scsi/megaraid/megaraid_sas_base.c
> @@ -6000,13 +6000,13 @@ static int megasas_io_attach(struct megasas_instance *instance)
>   * @instance:		Adapter soft state
>   * Description:
>   *
> - * For Ventura, driver/FW will operate in 64bit DMA addresses.
> + * For Ventura, driver/FW will operate in 63bit DMA addresses.
>   *
>   * For invader-
>   *	By default, driver/FW will operate in 32bit DMA addresses
>   *	for consistent DMA mapping but if 32 bit consistent
> - *	DMA mask fails, driver will try with 64 bit consistent
> - *	mask provided FW is true 64bit DMA capable
> + *	DMA mask fails, driver will try with 63 bit consistent
> + *	mask provided FW is true 63bit DMA capable
>   *
>   * For older controllers(Thunderbolt and MFI based adapters)-
>   *	driver/FW will operate in 32 bit consistent DMA addresses.
> @@ -6020,14 +6020,14 @@ megasas_set_dma_mask(struct megasas_instance *instance)
>  
>  	pdev = instance->pdev;
>  	consistent_mask = (instance->adapter_type == VENTURA_SERIES) ?
> -				DMA_BIT_MASK(64) : DMA_BIT_MASK(32);
> +				DMA_BIT_MASK(63) : DMA_BIT_MASK(32);
>  
>  	if (IS_DMA64) {
> -		if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)) &&
> +		if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(63)) &&
>  		    dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)))
>  			goto fail_set_dma_mask;
>  
> -		if ((*pdev->dev.dma_mask == DMA_BIT_MASK(64)) &&
> +		if ((*pdev->dev.dma_mask == DMA_BIT_MASK(63)) &&
>  		    (dma_set_coherent_mask(&pdev->dev, consistent_mask) &&
>  		     dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)))) {
>  			/*
> @@ -6040,7 +6040,7 @@ megasas_set_dma_mask(struct megasas_instance *instance)
>  			if (!(scratch_pad_2 & MR_CAN_HANDLE_64_BIT_DMA_OFFSET))
>  				goto fail_set_dma_mask;
>  			else if (dma_set_mask_and_coherent(&pdev->dev,
> -							   DMA_BIT_MASK(64)))
> +							   DMA_BIT_MASK(63)))
>  				goto fail_set_dma_mask;
>  		}
>  	} else if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)))
> @@ -6052,8 +6052,8 @@ megasas_set_dma_mask(struct megasas_instance *instance)
>  		instance->consistent_mask_64bit = true;
>  
>  	dev_info(&pdev->dev, "%s bit DMA mask and %s bit consistent mask\n",
> -		 ((*pdev->dev.dma_mask == DMA_BIT_MASK(64)) ? "64" : "32"),
> -		 (instance->consistent_mask_64bit ? "64" : "32"));
> +		 ((*pdev->dev.dma_mask == DMA_BIT_MASK(64)) ? "63" : "32"),
> +		 (instance->consistent_mask_64bit ? "63" : "32"));
>  
>  	return 0;
>

I guess that should be "backported from" since you had to adjust. I'll fix that

Acked-by: Khalid Elmously <khalid.elmously@canonical.com>
Khaled Elmously Feb. 1, 2019, 2:01 a.m. | #3
On 2019-01-29 15:07:59 , Marcelo Henrique Cerri wrote:
> From: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
> 
> BugLink: http://bugs.launchpad.net/bugs/1795453
> 
> Although MegaRAID controllers support 64-bit DMA addressing, as per
> hardware design, DMA address with all 64-bits set
> (0xFFFFFFFF-FFFFFFFF) results in a firmware fault.
> 
> Driver will set 63-bit DMA mask to ensure the above address will not be
> used.
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
> (cherry picked from commit 894169db12463cea08d0e2a9e35f42b291340e5a)
> [mhcerri: fixed context]
> Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>
> 
> Conflicts:
> 	drivers/scsi/megaraid/megaraid_sas_base.c
> ---
>  drivers/scsi/megaraid/megaraid_sas_base.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
> index 2d6f6414a2a2..7b1a92dd844f 100644
> --- a/drivers/scsi/megaraid/megaraid_sas_base.c
> +++ b/drivers/scsi/megaraid/megaraid_sas_base.c
> @@ -6000,13 +6000,13 @@ static int megasas_io_attach(struct megasas_instance *instance)
>   * @instance:		Adapter soft state
>   * Description:
>   *
> - * For Ventura, driver/FW will operate in 64bit DMA addresses.
> + * For Ventura, driver/FW will operate in 63bit DMA addresses.
>   *
>   * For invader-
>   *	By default, driver/FW will operate in 32bit DMA addresses
>   *	for consistent DMA mapping but if 32 bit consistent
> - *	DMA mask fails, driver will try with 64 bit consistent
> - *	mask provided FW is true 64bit DMA capable
> + *	DMA mask fails, driver will try with 63 bit consistent
> + *	mask provided FW is true 63bit DMA capable
>   *
>   * For older controllers(Thunderbolt and MFI based adapters)-
>   *	driver/FW will operate in 32 bit consistent DMA addresses.
> @@ -6020,14 +6020,14 @@ megasas_set_dma_mask(struct megasas_instance *instance)
>  
>  	pdev = instance->pdev;
>  	consistent_mask = (instance->adapter_type == VENTURA_SERIES) ?
> -				DMA_BIT_MASK(64) : DMA_BIT_MASK(32);
> +				DMA_BIT_MASK(63) : DMA_BIT_MASK(32);
>  
>  	if (IS_DMA64) {
> -		if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)) &&
> +		if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(63)) &&
>  		    dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)))
>  			goto fail_set_dma_mask;
>  
> -		if ((*pdev->dev.dma_mask == DMA_BIT_MASK(64)) &&
> +		if ((*pdev->dev.dma_mask == DMA_BIT_MASK(63)) &&
>  		    (dma_set_coherent_mask(&pdev->dev, consistent_mask) &&
>  		     dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)))) {
>  			/*
> @@ -6040,7 +6040,7 @@ megasas_set_dma_mask(struct megasas_instance *instance)
>  			if (!(scratch_pad_2 & MR_CAN_HANDLE_64_BIT_DMA_OFFSET))
>  				goto fail_set_dma_mask;
>  			else if (dma_set_mask_and_coherent(&pdev->dev,
> -							   DMA_BIT_MASK(64)))
> +							   DMA_BIT_MASK(63)))
>  				goto fail_set_dma_mask;
>  		}
>  	} else if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)))
> @@ -6052,8 +6052,8 @@ megasas_set_dma_mask(struct megasas_instance *instance)
>  		instance->consistent_mask_64bit = true;
>  
>  	dev_info(&pdev->dev, "%s bit DMA mask and %s bit consistent mask\n",
> -		 ((*pdev->dev.dma_mask == DMA_BIT_MASK(64)) ? "64" : "32"),
> -		 (instance->consistent_mask_64bit ? "64" : "32"));
> +		 ((*pdev->dev.dma_mask == DMA_BIT_MASK(64)) ? "63" : "32"),
> +		 (instance->consistent_mask_64bit ? "63" : "32"));
>  
>  	return 0;
>  
> -- 
> 2.17.1
> 
> 
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team

Patch

diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index 2d6f6414a2a2..7b1a92dd844f 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -6000,13 +6000,13 @@  static int megasas_io_attach(struct megasas_instance *instance)
  * @instance:		Adapter soft state
  * Description:
  *
- * For Ventura, driver/FW will operate in 64bit DMA addresses.
+ * For Ventura, driver/FW will operate in 63bit DMA addresses.
  *
  * For invader-
  *	By default, driver/FW will operate in 32bit DMA addresses
  *	for consistent DMA mapping but if 32 bit consistent
- *	DMA mask fails, driver will try with 64 bit consistent
- *	mask provided FW is true 64bit DMA capable
+ *	DMA mask fails, driver will try with 63 bit consistent
+ *	mask provided FW is true 63bit DMA capable
  *
  * For older controllers(Thunderbolt and MFI based adapters)-
  *	driver/FW will operate in 32 bit consistent DMA addresses.
@@ -6020,14 +6020,14 @@  megasas_set_dma_mask(struct megasas_instance *instance)
 
 	pdev = instance->pdev;
 	consistent_mask = (instance->adapter_type == VENTURA_SERIES) ?
-				DMA_BIT_MASK(64) : DMA_BIT_MASK(32);
+				DMA_BIT_MASK(63) : DMA_BIT_MASK(32);
 
 	if (IS_DMA64) {
-		if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)) &&
+		if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(63)) &&
 		    dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)))
 			goto fail_set_dma_mask;
 
-		if ((*pdev->dev.dma_mask == DMA_BIT_MASK(64)) &&
+		if ((*pdev->dev.dma_mask == DMA_BIT_MASK(63)) &&
 		    (dma_set_coherent_mask(&pdev->dev, consistent_mask) &&
 		     dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)))) {
 			/*
@@ -6040,7 +6040,7 @@  megasas_set_dma_mask(struct megasas_instance *instance)
 			if (!(scratch_pad_2 & MR_CAN_HANDLE_64_BIT_DMA_OFFSET))
 				goto fail_set_dma_mask;
 			else if (dma_set_mask_and_coherent(&pdev->dev,
-							   DMA_BIT_MASK(64)))
+							   DMA_BIT_MASK(63)))
 				goto fail_set_dma_mask;
 		}
 	} else if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)))
@@ -6052,8 +6052,8 @@  megasas_set_dma_mask(struct megasas_instance *instance)
 		instance->consistent_mask_64bit = true;
 
 	dev_info(&pdev->dev, "%s bit DMA mask and %s bit consistent mask\n",
-		 ((*pdev->dev.dma_mask == DMA_BIT_MASK(64)) ? "64" : "32"),
-		 (instance->consistent_mask_64bit ? "64" : "32"));
+		 ((*pdev->dev.dma_mask == DMA_BIT_MASK(64)) ? "63" : "32"),
+		 (instance->consistent_mask_64bit ? "63" : "32"));
 
 	return 0;