[PATCH 095/109] drm/amd/ras: filter out invalid pages from extended page addresses

Alex Deucher <[email protected]>
Newsgroups org.freedesktop.lists.amd-gfx
Message-ID <[email protected]>
From: YiPeng Chai <[email protected]>

Filter out invalid pages from extended page addresses.

Signed-off-by: YiPeng Chai <[email protected]>
Reviewed-by: Tao Zhou <[email protected]>
Signed-off-by: Alex Deucher <[email protected]>
---
 drivers/gpu/drm/amd/ras/core/ras_umc.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/ras/core/ras_umc.c b/drivers/gpu/drm/amd/ras/core/ras_umc.c
index 299426d6d8318..4cce9f5c65932 100644
--- a/drivers/gpu/drm/amd/ras/core/ras_umc.c
+++ b/drivers/gpu/drm/amd/ras/core/ras_umc.c
@@ -233,7 +233,8 @@ static int ras_umc_expand_row_pages(struct ras_core_context *ras_core,
 
 	row_pa = retired_addr & ~(flip_mask);
 
-	if (count < nr_page_pfns)
+	if ((count < nr_page_pfns) &&
+	    !ras_core_check_address_sanity(ras_core, row_pa))
 		page_pfns[count++] = RAS_ADDR_TO_PFN(row_pa);
 
 	subset = flip_mask;
@@ -243,7 +244,8 @@ static int ras_umc_expand_row_pages(struct ras_core_context *ras_core,
 		if (count >= nr_page_pfns)
 			break;
 
-		page_pfns[count++] = RAS_ADDR_TO_PFN(addr);
+		if (!ras_core_check_address_sanity(ras_core, addr))
+			page_pfns[count++] = RAS_ADDR_TO_PFN(addr);
 
 		subset = (subset - 1) & flip_mask;
 	};
@@ -271,7 +273,7 @@ int ras_umc_convert_record_to_row_pages(struct ras_core_context *ras_core,
 	}
 
 	count = ras_umc_expand_row_pages(ras_core, record, page_pfns, nr_page_pfns);
-	if (count > 0)
+	if (count >= 0)
 		record->cur_nps_valid_page_num = count;
 
 	return count;
@@ -656,10 +658,13 @@ static int ras_umc_update_eeprom_ram_data(struct ras_core_context *ras_core,
 	struct eeprom_store_record *data = &ras_umc->umc_err_data.ram_data;
 	int j;
 
-	if (!bps || !page_pfns || !nr_page_pfns ||
+	if (!bps || !page_pfns ||
 		(nr_page_pfns > ras_umc->max_pages_per_row))
 		return -EINVAL;
 
+	if (!nr_page_pfns)
+		return 0;
+
 	if (!data->space_left &&
 		ras_umc_realloc_err_data_space(ras_core, data, 256))
 		return -ENOMEM;
-- 
2.55.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.