diff mbox series

[v2,2/6] soc: hisilicon: kunpeng_hccs: Return failure on having not die or port information

Message ID 20240823031059.32579-3-lihuisong@huawei.com (mailing list archive)
State New, archived
Headers show
Series [v2,1/6] soc: hisilicon: kunpeng_hccs: Fix a PCC typo | expand

Commit Message

Huisong Li Aug. 23, 2024, 3:10 a.m. UTC
Driver is unavailable if all die number or all port number obtained from
firmware are zero. So return failure in this case.

Signed-off-by: Huisong Li <lihuisong@huawei.com>
---
 drivers/soc/hisilicon/kunpeng_hccs.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Jonathan Cameron Aug. 23, 2024, 8:33 a.m. UTC | #1
On Fri, 23 Aug 2024 11:10:55 +0800
Huisong Li <lihuisong@huawei.com> wrote:

> Driver is unavailable if all die number or all port number obtained from
> firmware are zero. So return failure in this case.

Perhaps should include a little info on whether there are firmware's out
there that do this or not?  I.e. Fix, or hardening?

> 
> Signed-off-by: Huisong Li <lihuisong@huawei.com>
Otherwise, this lgtm.
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> ---
>  drivers/soc/hisilicon/kunpeng_hccs.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/soc/hisilicon/kunpeng_hccs.c b/drivers/soc/hisilicon/kunpeng_hccs.c
> index c4a57328f22a..6e88f597f267 100644
> --- a/drivers/soc/hisilicon/kunpeng_hccs.c
> +++ b/drivers/soc/hisilicon/kunpeng_hccs.c
> @@ -451,6 +451,7 @@ static int hccs_query_all_die_info_on_platform(struct hccs_dev *hdev)
>  	struct device *dev = hdev->dev;
>  	struct hccs_chip_info *chip;
>  	struct hccs_die_info *die;
> +	bool has_die_info = false;
>  	u8 i, j;
>  	int ret;
>  
> @@ -459,6 +460,7 @@ static int hccs_query_all_die_info_on_platform(struct hccs_dev *hdev)
>  		if (!chip->die_num)
>  			continue;
>  
> +		has_die_info = true;
>  		chip->dies = devm_kzalloc(hdev->dev,
>  				chip->die_num * sizeof(struct hccs_die_info),
>  				GFP_KERNEL);
> @@ -480,7 +482,7 @@ static int hccs_query_all_die_info_on_platform(struct hccs_dev *hdev)
>  		}
>  	}
>  
> -	return 0;
> +	return has_die_info ? 0 : -EINVAL;
>  }
>  
>  static int hccs_get_bd_info(struct hccs_dev *hdev, u8 opcode,
> @@ -601,6 +603,7 @@ static int hccs_query_all_port_info_on_platform(struct hccs_dev *hdev)
>  	struct device *dev = hdev->dev;
>  	struct hccs_chip_info *chip;
>  	struct hccs_die_info *die;
> +	bool has_port_info = false;
>  	u8 i, j;
>  	int ret;
>  
> @@ -611,6 +614,7 @@ static int hccs_query_all_port_info_on_platform(struct hccs_dev *hdev)
>  			if (!die->port_num)
>  				continue;
>  
> +			has_port_info = true;
>  			die->ports = devm_kzalloc(dev,
>  				die->port_num * sizeof(struct hccs_port_info),
>  				GFP_KERNEL);
> @@ -629,7 +633,7 @@ static int hccs_query_all_port_info_on_platform(struct hccs_dev *hdev)
>  		}
>  	}
>  
> -	return 0;
> +	return has_port_info ? 0 : -EINVAL;
>  }
>  
>  static int hccs_get_hw_info(struct hccs_dev *hdev)
Huisong Li Aug. 27, 2024, 11:04 a.m. UTC | #2
在 2024/8/23 16:33, Jonathan Cameron 写道:
> On Fri, 23 Aug 2024 11:10:55 +0800
> Huisong Li <lihuisong@huawei.com> wrote:
>
>> Driver is unavailable if all die number or all port number obtained from
>> firmware are zero. So return failure in this case.
> Perhaps should include a little info on whether there are firmware's out
> there that do this or not?  I.e. Fix, or hardening?
Ack
just hardening code.
>
>> Signed-off-by: Huisong Li <lihuisong@huawei.com>
> Otherwise, this lgtm.
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
>> ---
>>   drivers/soc/hisilicon/kunpeng_hccs.c | 8 ++++++--
>>   1 file changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/soc/hisilicon/kunpeng_hccs.c b/drivers/soc/hisilicon/kunpeng_hccs.c
>> index c4a57328f22a..6e88f597f267 100644
>> --- a/drivers/soc/hisilicon/kunpeng_hccs.c
>> +++ b/drivers/soc/hisilicon/kunpeng_hccs.c
>> @@ -451,6 +451,7 @@ static int hccs_query_all_die_info_on_platform(struct hccs_dev *hdev)
>>   	struct device *dev = hdev->dev;
>>   	struct hccs_chip_info *chip;
>>   	struct hccs_die_info *die;
>> +	bool has_die_info = false;
>>   	u8 i, j;
>>   	int ret;
>>   
>> @@ -459,6 +460,7 @@ static int hccs_query_all_die_info_on_platform(struct hccs_dev *hdev)
>>   		if (!chip->die_num)
>>   			continue;
>>   
>> +		has_die_info = true;
>>   		chip->dies = devm_kzalloc(hdev->dev,
>>   				chip->die_num * sizeof(struct hccs_die_info),
>>   				GFP_KERNEL);
>> @@ -480,7 +482,7 @@ static int hccs_query_all_die_info_on_platform(struct hccs_dev *hdev)
>>   		}
>>   	}
>>   
>> -	return 0;
>> +	return has_die_info ? 0 : -EINVAL;
>>   }
>>   
>>   static int hccs_get_bd_info(struct hccs_dev *hdev, u8 opcode,
>> @@ -601,6 +603,7 @@ static int hccs_query_all_port_info_on_platform(struct hccs_dev *hdev)
>>   	struct device *dev = hdev->dev;
>>   	struct hccs_chip_info *chip;
>>   	struct hccs_die_info *die;
>> +	bool has_port_info = false;
>>   	u8 i, j;
>>   	int ret;
>>   
>> @@ -611,6 +614,7 @@ static int hccs_query_all_port_info_on_platform(struct hccs_dev *hdev)
>>   			if (!die->port_num)
>>   				continue;
>>   
>> +			has_port_info = true;
>>   			die->ports = devm_kzalloc(dev,
>>   				die->port_num * sizeof(struct hccs_port_info),
>>   				GFP_KERNEL);
>> @@ -629,7 +633,7 @@ static int hccs_query_all_port_info_on_platform(struct hccs_dev *hdev)
>>   		}
>>   	}
>>   
>> -	return 0;
>> +	return has_port_info ? 0 : -EINVAL;
>>   }
>>   
>>   static int hccs_get_hw_info(struct hccs_dev *hdev)
> .
diff mbox series

Patch

diff --git a/drivers/soc/hisilicon/kunpeng_hccs.c b/drivers/soc/hisilicon/kunpeng_hccs.c
index c4a57328f22a..6e88f597f267 100644
--- a/drivers/soc/hisilicon/kunpeng_hccs.c
+++ b/drivers/soc/hisilicon/kunpeng_hccs.c
@@ -451,6 +451,7 @@  static int hccs_query_all_die_info_on_platform(struct hccs_dev *hdev)
 	struct device *dev = hdev->dev;
 	struct hccs_chip_info *chip;
 	struct hccs_die_info *die;
+	bool has_die_info = false;
 	u8 i, j;
 	int ret;
 
@@ -459,6 +460,7 @@  static int hccs_query_all_die_info_on_platform(struct hccs_dev *hdev)
 		if (!chip->die_num)
 			continue;
 
+		has_die_info = true;
 		chip->dies = devm_kzalloc(hdev->dev,
 				chip->die_num * sizeof(struct hccs_die_info),
 				GFP_KERNEL);
@@ -480,7 +482,7 @@  static int hccs_query_all_die_info_on_platform(struct hccs_dev *hdev)
 		}
 	}
 
-	return 0;
+	return has_die_info ? 0 : -EINVAL;
 }
 
 static int hccs_get_bd_info(struct hccs_dev *hdev, u8 opcode,
@@ -601,6 +603,7 @@  static int hccs_query_all_port_info_on_platform(struct hccs_dev *hdev)
 	struct device *dev = hdev->dev;
 	struct hccs_chip_info *chip;
 	struct hccs_die_info *die;
+	bool has_port_info = false;
 	u8 i, j;
 	int ret;
 
@@ -611,6 +614,7 @@  static int hccs_query_all_port_info_on_platform(struct hccs_dev *hdev)
 			if (!die->port_num)
 				continue;
 
+			has_port_info = true;
 			die->ports = devm_kzalloc(dev,
 				die->port_num * sizeof(struct hccs_port_info),
 				GFP_KERNEL);
@@ -629,7 +633,7 @@  static int hccs_query_all_port_info_on_platform(struct hccs_dev *hdev)
 		}
 	}
 
-	return 0;
+	return has_port_info ? 0 : -EINVAL;
 }
 
 static int hccs_get_hw_info(struct hccs_dev *hdev)