[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID:
<MA0P287MB2262DBC84878347B78CA50ECFEB42@MA0P287MB2262.INDP287.PROD.OUTLOOK.COM>
Date: Wed, 9 Apr 2025 15:53:04 +0800
From: Chen Wang <unicorn_wang@...look.com>
To: Inochi Amaoto <inochiama@...il.com>, Thomas Gleixner
<tglx@...utronix.de>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley <conor+dt@...nel.org>
Cc: linux-kernel@...r.kernel.org, devicetree@...r.kernel.org,
sophgo@...ts.linux.dev, Yixun Lan <dlan@...too.org>,
Longbin Li <looong.bin@...il.com>
Subject: Re: [PATCH v3 4/4] irqchip/sg2042-msi: Add the Sophgo SG2044 MSI
interrupt controller
On 2025/4/8 13:01, Inochi Amaoto wrote:
> Add support for Sophgo SG2044 MSI interrupt controller.
>
> Signed-off-by: Inochi Amaoto <inochiama@...il.com>
> Reviewed-by: Chen Wang <unicorn_wang@...look.com>
> ---
> drivers/irqchip/irq-sg2042-msi.c | 61 ++++++++++++++++++++++++++++++--
> 1 file changed, 58 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/irqchip/irq-sg2042-msi.c b/drivers/irqchip/irq-sg2042-msi.c
> index 30a1d2bfd474..2935ca213306 100644
> --- a/drivers/irqchip/irq-sg2042-msi.c
> +++ b/drivers/irqchip/irq-sg2042-msi.c
> @@ -19,8 +19,6 @@
>
> #include "irq-msi-lib.h"
>
> -#define SG2042_MAX_MSI_VECTOR 32
> -
> struct sg204x_msi_chip_info {
> const struct irq_chip *irqchip;
> const struct msi_parent_ops *parent_ops;
> @@ -44,7 +42,7 @@ struct sg204x_msi_chipdata {
> u32 irq_first;
> u32 num_irqs;
>
> - DECLARE_BITMAP(msi_map, SG2042_MAX_MSI_VECTOR);
> + unsigned long *msi_map;
Regarding the common parts of SG2042 and SG2044, I noticed that you
changed DECLARE_BITMAP back to dynamic application. If there is a next
version, I suggest you mention it in the commit information.
Otherwise, LGTM.
Reviewed-by: Chen Wang <wangchen20@...as.ac.cn>
> struct mutex msi_map_lock;
>
> const struct sg204x_msi_chip_info *chip_info;
> @@ -96,6 +94,35 @@ static const struct irq_chip sg2042_msi_middle_irq_chip = {
> .irq_compose_msi_msg = sg2042_msi_irq_compose_msi_msg,
> };
>
> +static void sg2044_msi_irq_ack(struct irq_data *d)
> +{
> + struct sg204x_msi_chipdata *data = irq_data_get_irq_chip_data(d);
> +
> + writel(0, (unsigned int *)data->reg_clr + d->hwirq);
> + irq_chip_ack_parent(d);
> +}
> +
> +static void sg2044_msi_irq_compose_msi_msg(struct irq_data *d, struct msi_msg *msg)
> +{
> + struct sg204x_msi_chipdata *data = irq_data_get_irq_chip_data(d);
> + phys_addr_t doorbell = data->doorbell_addr + 4 * (d->hwirq / 32);
> +
> + msg->address_lo = lower_32_bits(doorbell);
> + msg->address_hi = upper_32_bits(doorbell);
> + msg->data = d->hwirq % 32;
> +}
> +
> +static struct irq_chip sg2044_msi_middle_irq_chip = {
> + .name = "SG2044 MSI",
> + .irq_ack = sg2044_msi_irq_ack,
> + .irq_mask = irq_chip_mask_parent,
> + .irq_unmask = irq_chip_unmask_parent,
> +#ifdef CONFIG_SMP
> + .irq_set_affinity = irq_chip_set_affinity_parent,
> +#endif
> + .irq_compose_msi_msg = sg2044_msi_irq_compose_msi_msg,
> +};
> +
> static int sg204x_msi_parent_domain_alloc(struct irq_domain *domain, unsigned int virq, int hwirq)
> {
> struct sg204x_msi_chipdata *data = domain->host_data;
> @@ -175,6 +202,22 @@ static const struct msi_parent_ops sg2042_msi_parent_ops = {
> .init_dev_msi_info = msi_lib_init_dev_msi_info,
> };
>
> +#define SG2044_MSI_FLAGS_REQUIRED (MSI_FLAG_USE_DEF_DOM_OPS | \
> + MSI_FLAG_USE_DEF_CHIP_OPS)
> +
> +#define SG2044_MSI_FLAGS_SUPPORTED (MSI_GENERIC_FLAGS_MASK | \
> + MSI_FLAG_PCI_MSIX)
> +
> +static const struct msi_parent_ops sg2044_msi_parent_ops = {
> + .required_flags = SG2044_MSI_FLAGS_REQUIRED,
> + .supported_flags = SG2044_MSI_FLAGS_SUPPORTED,
> + .chip_flags = MSI_CHIP_FLAG_SET_EOI | MSI_CHIP_FLAG_SET_ACK,
> + .bus_select_mask = MATCH_PCI_MSI,
> + .bus_select_token = DOMAIN_BUS_NEXUS,
> + .prefix = "SG2044-",
> + .init_dev_msi_info = msi_lib_init_dev_msi_info,
> +};
> +
> static int sg204x_msi_init_domains(struct sg204x_msi_chipdata *data,
> struct irq_domain *plic_domain, struct device *dev)
> {
> @@ -255,6 +298,12 @@ static int sg2042_msi_probe(struct platform_device *pdev)
>
> mutex_init(&data->msi_map_lock);
>
> + data->msi_map = devm_bitmap_zalloc(&pdev->dev, data->num_irqs, GFP_KERNEL);
> + if (!data->msi_map) {
> + dev_err(&pdev->dev, "Unable to allocate msi mapping\n");
> + return -ENOMEM;
> + }
> +
> return sg204x_msi_init_domains(data, plic_domain, dev);
> }
>
> @@ -263,8 +312,14 @@ static const struct sg204x_msi_chip_info sg2042_chip_info = {
> .parent_ops = &sg2042_msi_parent_ops,
> };
>
> +static const struct sg204x_msi_chip_info sg2044_chip_info = {
> + .irqchip = &sg2044_msi_middle_irq_chip,
> + .parent_ops = &sg2044_msi_parent_ops,
> +};
> +
> static const struct of_device_id sg2042_msi_of_match[] = {
> { .compatible = "sophgo,sg2042-msi", .data = &sg2042_chip_info },
> + { .compatible = "sophgo,sg2044-msi", .data = &sg2044_chip_info },
> { }
> };
>
Powered by blists - more mailing lists