Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2976194lqp; Mon, 25 Mar 2024 15:17:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX9TzZsuz3Gmu0q54BZT/NsIYFrvvzobIq/FLXAx2s6yOi1GYS6tWVCH8c4zGWDNKxkKqpOMG15W3cMzpUfzJrtitMu3NdAEohDepkBbg== X-Google-Smtp-Source: AGHT+IGZM9BvJb3Nt3aAYfQY1TZknmUHuJxj9YhGkKPvHkBo9ZGoKpy5D0HGbe0wQbeDt0VpgzwU X-Received: by 2002:a05:6a20:748e:b0:1a3:c4f8:e9a9 with SMTP id p14-20020a056a20748e00b001a3c4f8e9a9mr4461543pzd.8.1711405041995; Mon, 25 Mar 2024 15:17:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711405041; cv=pass; d=google.com; s=arc-20160816; b=G+KWs56QJRlC6nr+dSzuQXlSQQTB0SCSY4PGxLwGa+gjjm/aYjbHY7hz4CLor0CzI1 JaA0Aox1r/VxUhpeTzf2EO5d/cYQVYvcPWPjtyuksJBz8HHv+4IuYczFVmkd2VEBLmtF d+p1BcoA7SQg76Rq49ldGNeWz8iHYCEDQONXfp7WqwPSxOaJWqTjna9ELrAx+4LYN8Fr fycux3Y+uDmMrHx3Y1Z0YHcvo10k3cdeChoicpfIeM+Rzlk0rSi73f7osmZBvnv0RTTP chuwbqLtG5dYwu4DnVDK892cs9b8Pw+hNaPAFkZ5cscWDZOBvlOHnYcBryLHK7Sn/etW FNqA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=tKXhoVxPg5C+dVfOy7qx8bL/k7u1CDts/NDjjX4UgBc=; fh=HDf79k3LfEffSs/Tt7CEl85BJKTVZQG1Zn6R38+doh8=; b=yC/v5D0vSNW71RZ9ohyBsi7WgIm6cTF2ZmNx7yCzdrYNROcTC1bS5hYoq/5HkkItzD yRLJ3lSWSQTwUu6G797FkplSgeWSnzNlu15cFNStOpbfeF+4J4UyC+o3iJStiplx5Li/ dEfSqkoiykf5YoFuEwN2LmjG8uUmXavlKVLdsvvcZXTqzJIb70UIMqWe89x3jkRmtcy5 qoLkVyiDG5eL31HvhF1uD5Rbnl1I7kDN1gr3drUWFtMYsluZifNn6WJ0Aj4gpM8huy/J usrQrdrE6worQmyv7+t+Ov+TuMn9INq8aFWz4rB29YDe42Lv/skV2r7GDY/bbNHD7xtd CT2w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=iLkYIVoJ; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=QPEuQCd4; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-117502-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117502-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id t5-20020a170902e84500b001dddb9f06bfsi6058677plg.479.2024.03.25.15.17.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 15:17:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-117502-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=iLkYIVoJ; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=QPEuQCd4; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-117502-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117502-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id C7AE7C630E7 for ; Mon, 25 Mar 2024 17:41:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DC34814BFA6; Mon, 25 Mar 2024 16:46:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="iLkYIVoJ"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="QPEuQCd4" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E47D514A0AE; Mon, 25 Mar 2024 16:46:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711385215; cv=none; b=u5lmOOXVuzNXxQy5DNYKA+ABI9+5YrLxZ/wePJzgC1k9EkrIvp6h2pxuS3gNSnXpEHmTy7FR0AyXUyjSmYH+wyRUjMGPP1DNTXzV3A0I0U+Ww+nkdusYefYuXwzPXJ033qvkmTKJeGcxqFrcjYIWjHO5lKnDyrARvveFBGqRB1Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711385215; c=relaxed/simple; bh=kkKsl7G83w2Z6fBYpfUtbXFKRkoJ/tLbomY1v4sLbWQ=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=uwJUF9X5mfqUfriVBHUi4irsYx52h4ArzgcoaDQanXamZY4Mz6A99eGg1YoN4kKJH/dfq+K1qIWIkrIL7soczH6yszOpUvpXV92MEFRLT0EZT3bcxQx+CEhy/7d2HA3d30GGoINzmDhH0pBEUnRDLDcCtNB6x4osrB9gvkH7qU4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=iLkYIVoJ; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=QPEuQCd4; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Mon, 25 Mar 2024 16:46:50 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1711385211; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tKXhoVxPg5C+dVfOy7qx8bL/k7u1CDts/NDjjX4UgBc=; b=iLkYIVoJN4DXtyeCd+LAOe8oRA4pPOglAxOAWny5JYD2uunHJOjpGv9h1o/ddfit6ZIAeW KOtiLKpuIFFOYenouyNFdgRwatkps00/UCmX/NNJHatYLLClOliuQB0UKhI6M8vE2Q5VOY dSHJi3gR9p3tF4o1WKZnfi6fGajDFEQgdFXX7TcF24RUWMKRVwW50R5S48h0lVLHPV0nIS WoUL41dy0hcdKiJI2rVM4Fvz5aSO/18qrCpbNPp0jkvBLAZ3EqeWFTVfQorJ9ncvz/Qqsn 4qIj6we55MK3wRx16xiE/oqYkI6VQU1Rrjo6zW6r31TJqGGWhGQe09z35jxfNQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1711385211; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tKXhoVxPg5C+dVfOy7qx8bL/k7u1CDts/NDjjX4UgBc=; b=QPEuQCd4zDZns5byBeJjwpTo64NRDFDP2EslEKZpH7zEQjlkfUheWYnMBm3nAslwd13zb3 x59jK5WOywZ21BCQ== From: "tip-bot2 for Anup Patel" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: irq/core] irqchip/riscv-imsic: Add device MSI domain support for platform devices Cc: Anup Patel , Thomas Gleixner , bjorn@rivosinc.com, x86@kernel.org, linux-kernel@vger.kernel.org, maz@kernel.org In-Reply-To: <20240307140307.646078-4-apatel@ventanamicro.com> References: <20240307140307.646078-4-apatel@ventanamicro.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <171138521051.10875.18294982315541434339.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the irq/core branch of tip: Commit-ID: 027e125acdbad79e9a7274940e8bf92299b208af Gitweb: https://git.kernel.org/tip/027e125acdbad79e9a7274940e8bf92299b= 208af Author: Anup Patel AuthorDate: Thu, 07 Mar 2024 19:33:01 +05:30 Committer: Thomas Gleixner CommitterDate: Mon, 25 Mar 2024 17:38:28 +01:00 irqchip/riscv-imsic: Add device MSI domain support for platform devices The Linux platform MSI support allows per-device MSI domains so add a platform irqchip driver for RISC-V IMSIC which provides a base IRQ domain with MSI parent support for platform device domains. The IMSIC platform driver assumes that the IMSIC state is already initialized by the IMSIC early driver. Signed-off-by: Anup Patel Signed-off-by: Thomas Gleixner Tested-by: Bj=C3=B6rn T=C3=B6pel Reviewed-by: Bj=C3=B6rn T=C3=B6pel Link: https://lore.kernel.org/r/20240307140307.646078-4-apatel@ventanamicro.c= om --- drivers/irqchip/Makefile | 2 +- drivers/irqchip/irq-riscv-imsic-platform.c | 343 ++++++++++++++++++++- drivers/irqchip/irq-riscv-imsic-state.h | 1 +- 3 files changed, 345 insertions(+), 1 deletion(-) create mode 100644 drivers/irqchip/irq-riscv-imsic-platform.c diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile index 972aa9f..c139098 100644 --- a/drivers/irqchip/Makefile +++ b/drivers/irqchip/Makefile @@ -95,7 +95,7 @@ obj-$(CONFIG_QCOM_MPM) +=3D irq-qcom-mpm.o obj-$(CONFIG_CSKY_MPINTC) +=3D irq-csky-mpintc.o obj-$(CONFIG_CSKY_APB_INTC) +=3D irq-csky-apb-intc.o obj-$(CONFIG_RISCV_INTC) +=3D irq-riscv-intc.o -obj-$(CONFIG_RISCV_IMSIC) +=3D irq-riscv-imsic-state.o irq-riscv-imsic-earl= y.o +obj-$(CONFIG_RISCV_IMSIC) +=3D irq-riscv-imsic-state.o irq-riscv-imsic-earl= y.o irq-riscv-imsic-platform.o obj-$(CONFIG_SIFIVE_PLIC) +=3D irq-sifive-plic.o obj-$(CONFIG_STARFIVE_JH8100_INTC) +=3D irq-starfive-jh8100-intc.o obj-$(CONFIG_IMX_IRQSTEER) +=3D irq-imx-irqsteer.o diff --git a/drivers/irqchip/irq-riscv-imsic-platform.c b/drivers/irqchip/irq= -riscv-imsic-platform.c new file mode 100644 index 0000000..35291bf --- /dev/null +++ b/drivers/irqchip/irq-riscv-imsic-platform.c @@ -0,0 +1,343 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2021 Western Digital Corporation or its affiliates. + * Copyright (C) 2022 Ventana Micro Systems Inc. + */ + +#define pr_fmt(fmt) "riscv-imsic: " fmt +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "irq-riscv-imsic-state.h" + +static bool imsic_cpu_page_phys(unsigned int cpu, unsigned int guest_index, + phys_addr_t *out_msi_pa) +{ + struct imsic_global_config *global; + struct imsic_local_config *local; + + global =3D &imsic->global; + local =3D per_cpu_ptr(global->local, cpu); + + if (BIT(global->guest_index_bits) <=3D guest_index) + return false; + + if (out_msi_pa) + *out_msi_pa =3D local->msi_pa + (guest_index * IMSIC_MMIO_PAGE_SZ); + + return true; +} + +static void imsic_irq_mask(struct irq_data *d) +{ + imsic_vector_mask(irq_data_get_irq_chip_data(d)); +} + +static void imsic_irq_unmask(struct irq_data *d) +{ + imsic_vector_unmask(irq_data_get_irq_chip_data(d)); +} + +static int imsic_irq_retrigger(struct irq_data *d) +{ + struct imsic_vector *vec =3D irq_data_get_irq_chip_data(d); + struct imsic_local_config *local; + + if (WARN_ON(!vec)) + return -ENOENT; + + local =3D per_cpu_ptr(imsic->global.local, vec->cpu); + writel_relaxed(vec->local_id, local->msi_va); + return 0; +} + +static void imsic_irq_compose_vector_msg(struct imsic_vector *vec, struct ms= i_msg *msg) +{ + phys_addr_t msi_addr; + + if (WARN_ON(!vec)) + return; + + if (WARN_ON(!imsic_cpu_page_phys(vec->cpu, 0, &msi_addr))) + return; + + msg->address_hi =3D upper_32_bits(msi_addr); + msg->address_lo =3D lower_32_bits(msi_addr); + msg->data =3D vec->local_id; +} + +static void imsic_irq_compose_msg(struct irq_data *d, struct msi_msg *msg) +{ + imsic_irq_compose_vector_msg(irq_data_get_irq_chip_data(d), msg); +} + +#ifdef CONFIG_SMP +static void imsic_msi_update_msg(struct irq_data *d, struct imsic_vector *ve= c) +{ + struct msi_msg msg =3D { }; + + imsic_irq_compose_vector_msg(vec, &msg); + irq_data_get_irq_chip(d)->irq_write_msi_msg(d, &msg); +} + +static int imsic_irq_set_affinity(struct irq_data *d, const struct cpumask *= mask_val, + bool force) +{ + struct imsic_vector *old_vec, *new_vec; + struct irq_data *pd =3D d->parent_data; + + old_vec =3D irq_data_get_irq_chip_data(pd); + if (WARN_ON(!old_vec)) + return -ENOENT; + + /* If old vector cpu belongs to the target cpumask then do nothing */ + if (cpumask_test_cpu(old_vec->cpu, mask_val)) + return IRQ_SET_MASK_OK_DONE; + + /* If move is already in-flight then return failure */ + if (imsic_vector_get_move(old_vec)) + return -EBUSY; + + /* Get a new vector on the desired set of CPUs */ + new_vec =3D imsic_vector_alloc(old_vec->hwirq, mask_val); + if (!new_vec) + return -ENOSPC; + + /* Point device to the new vector */ + imsic_msi_update_msg(d, new_vec); + + /* Update irq descriptors with the new vector */ + pd->chip_data =3D new_vec; + + /* Update effective affinity of parent irq data */ + irq_data_update_effective_affinity(pd, cpumask_of(new_vec->cpu)); + + /* Move state of the old vector to the new vector */ + imsic_vector_move(old_vec, new_vec); + + return IRQ_SET_MASK_OK_DONE; +} +#endif + +static struct irq_chip imsic_irq_base_chip =3D { + .name =3D "IMSIC", + .irq_mask =3D imsic_irq_mask, + .irq_unmask =3D imsic_irq_unmask, + .irq_retrigger =3D imsic_irq_retrigger, + .irq_compose_msi_msg =3D imsic_irq_compose_msg, + .flags =3D IRQCHIP_SKIP_SET_WAKE | + IRQCHIP_MASK_ON_SUSPEND, +}; + +static int imsic_irq_domain_alloc(struct irq_domain *domain, unsigned int vi= rq, + unsigned int nr_irqs, void *args) +{ + struct imsic_vector *vec; + + /* Multi-MSI is not supported yet. */ + if (nr_irqs > 1) + return -EOPNOTSUPP; + + vec =3D imsic_vector_alloc(virq, cpu_online_mask); + if (!vec) + return -ENOSPC; + + irq_domain_set_info(domain, virq, virq, &imsic_irq_base_chip, vec, + handle_simple_irq, NULL, NULL); + irq_set_noprobe(virq); + irq_set_affinity(virq, cpu_online_mask); + + return 0; +} + +static void imsic_irq_domain_free(struct irq_domain *domain, unsigned int vi= rq, + unsigned int nr_irqs) +{ + struct irq_data *d =3D irq_domain_get_irq_data(domain, virq); + + imsic_vector_free(irq_data_get_irq_chip_data(d)); + irq_domain_free_irqs_parent(domain, virq, nr_irqs); +} + +static int imsic_irq_domain_select(struct irq_domain *domain, struct irq_fws= pec *fwspec, + enum irq_domain_bus_token bus_token) +{ + const struct msi_parent_ops *ops =3D domain->msi_parent_ops; + u32 busmask =3D BIT(bus_token); + + if (fwspec->fwnode !=3D domain->fwnode || fwspec->param_count !=3D 0) + return 0; + + /* Handle pure domain searches */ + if (bus_token =3D=3D ops->bus_select_token) + return 1; + + return !!(ops->bus_select_mask & busmask); +} + +#ifdef CONFIG_GENERIC_IRQ_DEBUGFS +static void imsic_irq_debug_show(struct seq_file *m, struct irq_domain *d, + struct irq_data *irqd, int ind) +{ + if (!irqd) { + imsic_vector_debug_show_summary(m, ind); + return; + } + + imsic_vector_debug_show(m, irq_data_get_irq_chip_data(irqd), ind); +} +#endif + +static const struct irq_domain_ops imsic_base_domain_ops =3D { + .alloc =3D imsic_irq_domain_alloc, + .free =3D imsic_irq_domain_free, + .select =3D imsic_irq_domain_select, +#ifdef CONFIG_GENERIC_IRQ_DEBUGFS + .debug_show =3D imsic_irq_debug_show, +#endif +}; + +static bool imsic_init_dev_msi_info(struct device *dev, + struct irq_domain *domain, + struct irq_domain *real_parent, + struct msi_domain_info *info) +{ + const struct msi_parent_ops *pops =3D real_parent->msi_parent_ops; + + /* MSI parent domain specific settings */ + switch (real_parent->bus_token) { + case DOMAIN_BUS_NEXUS: + if (WARN_ON_ONCE(domain !=3D real_parent)) + return false; +#ifdef CONFIG_SMP + info->chip->irq_set_affinity =3D imsic_irq_set_affinity; +#endif + break; + default: + WARN_ON_ONCE(1); + return false; + } + + /* Is the target supported? */ + switch (info->bus_token) { + case DOMAIN_BUS_DEVICE_MSI: + /* + * Per-device MSI should never have any MSI feature bits + * set. It's sole purpose is to create a dumb interrupt + * chip which has a device specific irq_write_msi_msg() + * callback. + */ + if (WARN_ON_ONCE(info->flags)) + return false; + + /* Core managed MSI descriptors */ + info->flags |=3D MSI_FLAG_ALLOC_SIMPLE_MSI_DESCS | + MSI_FLAG_FREE_MSI_DESCS; + break; + case DOMAIN_BUS_WIRED_TO_MSI: + break; + default: + WARN_ON_ONCE(1); + return false; + } + + /* Use hierarchial chip operations re-trigger */ + info->chip->irq_retrigger =3D irq_chip_retrigger_hierarchy; + + /* + * Mask out the domain specific MSI feature flags which are not + * supported by the real parent. + */ + info->flags &=3D pops->supported_flags; + + /* Enforce the required flags */ + info->flags |=3D pops->required_flags; + + return true; +} + +#define MATCH_PLATFORM_MSI BIT(DOMAIN_BUS_PLATFORM_MSI) + +static const struct msi_parent_ops imsic_msi_parent_ops =3D { + .supported_flags =3D MSI_GENERIC_FLAGS_MASK, + .required_flags =3D MSI_FLAG_USE_DEF_DOM_OPS | + MSI_FLAG_USE_DEF_CHIP_OPS, + .bus_select_token =3D DOMAIN_BUS_NEXUS, + .bus_select_mask =3D MATCH_PLATFORM_MSI, + .init_dev_msi_info =3D imsic_init_dev_msi_info, +}; + +int imsic_irqdomain_init(void) +{ + struct imsic_global_config *global; + + if (!imsic || !imsic->fwnode) { + pr_err("early driver not probed\n"); + return -ENODEV; + } + + if (imsic->base_domain) { + pr_err("%pfwP: irq domain already created\n", imsic->fwnode); + return -ENODEV; + } + + /* Create Base IRQ domain */ + imsic->base_domain =3D irq_domain_create_tree(imsic->fwnode, + &imsic_base_domain_ops, imsic); + if (!imsic->base_domain) { + pr_err("%pfwP: failed to create IMSIC base domain\n", imsic->fwnode); + return -ENOMEM; + } + imsic->base_domain->flags |=3D IRQ_DOMAIN_FLAG_MSI_PARENT; + imsic->base_domain->msi_parent_ops =3D &imsic_msi_parent_ops; + + irq_domain_update_bus_token(imsic->base_domain, DOMAIN_BUS_NEXUS); + + global =3D &imsic->global; + pr_info("%pfwP: hart-index-bits: %d, guest-index-bits: %d\n", + imsic->fwnode, global->hart_index_bits, global->guest_index_bits); + pr_info("%pfwP: group-index-bits: %d, group-index-shift: %d\n", + imsic->fwnode, global->group_index_bits, global->group_index_shift); + pr_info("%pfwP: per-CPU IDs %d at base PPN %pa\n", + imsic->fwnode, global->nr_ids, &global->base_addr); + pr_info("%pfwP: total %d interrupts available\n", + imsic->fwnode, num_possible_cpus() * (global->nr_ids - 1)); + + return 0; +} + +static int imsic_platform_probe(struct platform_device *pdev) +{ + struct device *dev =3D &pdev->dev; + + if (imsic && imsic->fwnode !=3D dev->fwnode) { + dev_err(dev, "fwnode mismatch\n"); + return -ENODEV; + } + + return imsic_irqdomain_init(); +} + +static const struct of_device_id imsic_platform_match[] =3D { + { .compatible =3D "riscv,imsics" }, + {} +}; + +static struct platform_driver imsic_platform_driver =3D { + .driver =3D { + .name =3D "riscv-imsic", + .of_match_table =3D imsic_platform_match, + }, + .probe =3D imsic_platform_probe, +}; +builtin_platform_driver(imsic_platform_driver); diff --git a/drivers/irqchip/irq-riscv-imsic-state.h b/drivers/irqchip/irq-ri= scv-imsic-state.h index 8ec9649..5ae2f69 100644 --- a/drivers/irqchip/irq-riscv-imsic-state.h +++ b/drivers/irqchip/irq-riscv-imsic-state.h @@ -103,5 +103,6 @@ void imsic_vector_debug_show_summary(struct seq_file *m, = int ind); void imsic_state_online(void); void imsic_state_offline(void); int imsic_setup_state(struct fwnode_handle *fwnode); +int imsic_irqdomain_init(void); =20 #endif