Re: [PATCH v2] EDAC/altera: use SDMMC compatibles to select A10/S10 IRQ layout

Dinh Nguyen <[email protected]>
Newsgroups org.kernel.vger.linux-edac,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
Hi Rounak,

Thanks you for this patch and attempting to clean this up.

On 6/16/26 17:17, Rounak Das wrote:
> The SDMMC ECC IRQ layout selection uses CONFIG_64BIT to distinguish
> between Arria10 and Stratix10 paths. This is architecture-based,
> while the interrupt layout is a hardware property described by DT
> compatible strings.
> 
> Select the SDMMC IRQ layout via of_device_is_compatible() checks
> for altr,socfpga-s10-sdmmc-ecc in both altr_portb_setup() and
> altr_edac_a10_device_add().
> 
> This keeps the existing behavior for both SoCs while making the
> selection mechanism hardware-descriptive.
> 
> Signed-off-by: Rounak Das <[email protected]>
> ---
>   drivers/edac/altera_edac.c | 105 +++++++++++++++++++------------------
>   1 file changed, 53 insertions(+), 52 deletions(-)
> 
> diff --git a/drivers/edac/altera_edac.c b/drivers/edac/altera_edac.c
> index 4edd2088c2db6..161331ef57c01 100644
> --- a/drivers/edac/altera_edac.c
> +++ b/drivers/edac/altera_edac.c
> @@ -1548,15 +1548,16 @@ static int altr_portb_setup(struct altr_edac_device_dev *device)
>   
>   	/*
>   	 * Update the PortB IRQs - A10 has 4, S10 has 2, Index accordingly
> -	 *
> -	 * FIXME: Instead of ifdefs with different architectures the driver
> -	 *        should properly use compatibles.
>   	 */
> -#ifdef CONFIG_64BIT
> -	altdev->sb_irq = irq_of_parse_and_map(np, 1);
> -#else
> -	altdev->sb_irq = irq_of_parse_and_map(np, 2);
> -#endif
> +
> +	/* Using compatibles to determine the IRQ Index */
> +	bool is_s10_sdmmc = of_device_is_compatible(np, "altr,socfpga-s10-sdmmc-ecc");

How come you've decided to look at the sdmmc-ecc compatible instead of
"altr,socfpga-s10-ecc-manager"?

> +
> +	if (is_s10_sdmmc)
> +		altdev->sb_irq = irq_of_parse_and_map(np, 1);
> +	else
> +		altdev->sb_irq = irq_of_parse_and_map(np, 2);
> +
>   	if (!altdev->sb_irq) {
>   		edac_printk(KERN_ERR, EDAC_DEVICE, "Error PortB SBIRQ alloc\n");
>   		rc = -ENODEV;
> @@ -1570,29 +1571,29 @@ static int altr_portb_setup(struct altr_edac_device_dev *device)
>   		goto err_release_group_1;
>   	}
>   
> -#ifdef CONFIG_64BIT
> -	/* Use IRQ to determine SError origin instead of assigning IRQ */
> -	rc = of_property_read_u32_index(np, "interrupts", 1, &altdev->db_irq);
> -	if (rc) {
> -		edac_printk(KERN_ERR, EDAC_DEVICE,
> -			    "Error PortB DBIRQ alloc\n");
> -		goto err_release_group_1;
> -	}
> -#else
> -	altdev->db_irq = irq_of_parse_and_map(np, 3);
> -	if (!altdev->db_irq) {
> -		edac_printk(KERN_ERR, EDAC_DEVICE, "Error PortB DBIRQ alloc\n");
> -		rc = -ENODEV;
> -		goto err_release_group_1;
> -	}
> -	rc = devm_request_irq(&altdev->ddev, altdev->db_irq,
> -			      prv->ecc_irq_handler, IRQF_TRIGGER_HIGH,
> -			      ecc_name, altdev);
> -	if (rc) {
> -		edac_printk(KERN_ERR, EDAC_DEVICE, "PortB DBERR IRQ error\n");
> -		goto err_release_group_1;
> +	if (is_s10_sdmmc) {
> +		/* Use IRQ to determine SError origin instead of assigning IRQ */
> +		rc = of_property_read_u32_index(np, "interrupts", 1, &altdev->db_irq);
> +		if (rc) {
> +			edac_printk(KERN_ERR, EDAC_DEVICE,
> +					"Error PortB DBIRQ alloc\n");
> +			goto err_release_group_1;
> +		}
> +	} else {
> +		altdev->db_irq = irq_of_parse_and_map(np, 3);
> +		if (!altdev->db_irq) {
> +			edac_printk(KERN_ERR, EDAC_DEVICE, "Error PortB DBIRQ alloc\n");
> +			rc = -ENODEV;
> +			goto err_release_group_1;
> +		}
> +		rc = devm_request_irq(&altdev->ddev, altdev->db_irq,
> +					prv->ecc_irq_handler, IRQF_TRIGGER_HIGH,
> +					ecc_name, altdev);
> +		if (rc) {
> +			edac_printk(KERN_ERR, EDAC_DEVICE, "PortB DBERR IRQ error\n");
> +			goto err_release_group_1;
> +		}
>   	}
> -#endif
>   
>   	rc = edac_device_add_device(dci);
>   	if (rc) {
> @@ -1974,29 +1975,29 @@ static int altr_edac_a10_device_add(struct altr_arria10_edac *edac,
>   		goto err_release_group1;
>   	}
>   
> -#ifdef CONFIG_64BIT
> -	/* Use IRQ to determine SError origin instead of assigning IRQ */
> -	rc = of_property_read_u32_index(np, "interrupts", 0, &altdev->db_irq);
> -	if (rc) {
> -		edac_printk(KERN_ERR, EDAC_DEVICE,
> -			    "Unable to parse DB IRQ index\n");
> -		goto err_release_group1;
> -	}
> -#else
> -	altdev->db_irq = irq_of_parse_and_map(np, 1);
> -	if (!altdev->db_irq) {
> -		edac_printk(KERN_ERR, EDAC_DEVICE, "Error allocating DBIRQ\n");
> -		rc = -ENODEV;
> -		goto err_release_group1;
> -	}
> -	rc = devm_request_irq(edac->dev, altdev->db_irq, prv->ecc_irq_handler,
> -			      IRQF_TRIGGER_HIGH,
> -			      ecc_name, altdev);
> -	if (rc) {
> -		edac_printk(KERN_ERR, EDAC_DEVICE, "No DBERR IRQ resource\n");
> -		goto err_release_group1;
> +	if (of_device_is_compatible(np, "altr,socfpga-s10-sdmmc-ecc")) {

I'd like to avoid adding more calls to get compatible in the code if 
possible.

> +		/* Use IRQ to determine SError origin instead of assigning IRQ */
> +		rc = of_property_read_u32_index(np, "interrupts", 0, &altdev->db_irq);
> +		if (rc) {
> +			edac_printk(KERN_ERR, EDAC_DEVICE,
> +					"Unable to parse DB IRQ index\n");
> +			goto err_release_group1;
> +		}
> +	} else {
> +		altdev->db_irq = irq_of_parse_and_map(np, 1);
> +		if (!altdev->db_irq) {
> +			edac_printk(KERN_ERR, EDAC_DEVICE, "Error allocating DBIRQ\n");
> +			rc = -ENODEV;
> +			goto err_release_group1;
> +		}
> +		rc = devm_request_irq(edac->dev, altdev->db_irq, prv->ecc_irq_handler,
> +					IRQF_TRIGGER_HIGH,
> +					ecc_name, altdev);
> +		if (rc) {
> +			edac_printk(KERN_ERR, EDAC_DEVICE, "No DBERR IRQ resource\n");
> +			goto err_release_group1;
> +		}
>   	}
> -#endif
>   
>   	rc = edac_device_add_device(dci);
>   	if (rc) {

Got a few checkpatch warnings:

CHECK: Alignment should match open parenthesis
#84: FILE: drivers/edac/altera_edac.c:1579:
+			edac_printk(KERN_ERR, EDAC_DEVICE,
+					"Error PortB DBIRQ alloc\n");

CHECK: Alignment should match open parenthesis
#95: FILE: drivers/edac/altera_edac.c:1590:
+		rc = devm_request_irq(&altdev->ddev, altdev->db_irq,
+					prv->ecc_irq_handler, IRQF_TRIGGER_HIGH,

CHECK: Alignment should match open parenthesis
#136: FILE: drivers/edac/altera_edac.c:1983:
+			edac_printk(KERN_ERR, EDAC_DEVICE,
+					"Unable to parse DB IRQ index\n");

CHECK: Alignment should match open parenthesis
#147: FILE: drivers/edac/altera_edac.c:1994:
+		rc = devm_request_irq(edac->dev, altdev->db_irq, prv->ecc_irq_handler,
+					IRQF_TRIGGER_HIGH,


Thanks,
Dinh
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.