From patchwork Wed May 1 12:17:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13650513 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 55A3F54FA1 for ; Wed, 1 May 2024 12:18:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714565887; cv=none; b=LBzdU3OSdOz8lE4cX4IQgN/5mVf5VeHKJNiSdY9w/ypk2fBRGHFhULTTKpYgsLhf0e9yzL9sNYlOw9jffnEt/VzB/Ik7Mhwv8Pbp+yDNIKVaaIxMANRrHm5DGfgA++0byytoNbI07c3usD4A6IEruqhPK3uquBnXzi/GjmcNmY4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714565887; c=relaxed/simple; bh=EWOsbQ8d8Nb/EJHNU/jBnJqaPWlguzEkjOm3OBX3Ncc=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=i4RGN6F2bLbg3ttf9RfbgvVuZR66L9iHh+tTJeRDAzRmnVL8O6NKPsWn3rWOI1aS1JEQjmXmVotCqd/G/Y1nPrfpRjgHJWi6wmD+VfYY44bp9++J9/eCyMClw47oIn55uQWkOSJiOOdlEjGJKMWhgD3VCn8BKfJHKePfF35bZg8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=mb3DeCIb; arc=none smtp.client-ip=209.85.214.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="mb3DeCIb" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-1ec4dc64c6cso12442715ad.0 for ; Wed, 01 May 2024 05:18:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1714565884; x=1715170684; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=9EhfEaMFfLrGfmVLdeaNNG6PlGGzfTCBnCOLnM+VG1c=; b=mb3DeCIbbmpn3mHmnE+oFMaBcjecbbNlK/QZrkms2jJA+3UDdtWoHK2u6fd8O99oZV DZBPdOibNnGXR/3fneUHY+xliWTnRI4Yk251Fr01JZPBrtLxyecpW6F6JERJZOJHfhnU 9VSHoa/4LO5UkRm2Cq4GDGXTbYnbX62v3YbATpAkiiC0SwS+qHzgeqWWKsrvz+muHPZx a5Bem5TxCjlzNR6RyHla9iEHu2QstpVxZq5QL+K436kdbR9ARUGPE1DtoWHHOoNcgnVj sP/QXa/KGts1fsgIsDV4V1xUJv/SPujSnedypd6/rUF4JVGitabA+3a0Rc4ZtYqP6hYB i7eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714565884; x=1715170684; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9EhfEaMFfLrGfmVLdeaNNG6PlGGzfTCBnCOLnM+VG1c=; b=iurwboF9h+lec+1gWlXuMZ0+4Zbwv4mb1Wcui1M8ncAcbdgWXtYIVoALPGxbVb+qam XYH32XY3LgMmUde70XUSQtwuS8bxXDARRlF3o+Rx9VJYvSq2Io1yVp+VPhuBTF7TI/wO D2LupmfbDAZfpdG0JkGCyrk9b3ZwaLn4NIPVekIPIk5l8kYoXCpp/MQPQZRnvulciDYP 6kBnMhhLOqbWh52vQukP/p2izmyHSUkp1cltSJ1fd1xJb4b/JTjzdOiiKWDIvFd7fP3g Z8ILihC194MTaTsUYJ5BJRagQRvYX3dTtQws4tAv2fucXP1kBkX2F6MECl7D87jU/vGx xOog== X-Forwarded-Encrypted: i=1; AJvYcCWdgBbezKD31N9t6qVgB33QzZOR3OBVp81ST+zhZr5J3A6ua/+okhJEg9pUPohUotXcsPOiseyuDhq19CI0DDgOPChTXFMYUo7aMQ== X-Gm-Message-State: AOJu0YyEfxoImP4VftwW7zwZteai8gBT9Ph4IQ9/Ac962/lw8i/adt3E Tffunq0LvJJIS9RcJNyyV8aPjHUWKeeZSg/14C6oy2rVWOwZDyNAC1kysM87hWM= X-Google-Smtp-Source: AGHT+IGKp6Ma/BFy2R+UnRNFa2ZVdvrW3j2wb0D3bLNHdRHpaQg8W2PvjVIveWAJa/pc36T5TUO8jg== X-Received: by 2002:a17:902:efcf:b0:1e5:c06b:3330 with SMTP id ja15-20020a170902efcf00b001e5c06b3330mr2036008plb.24.1714565884004; Wed, 01 May 2024 05:18:04 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.188.106]) by smtp.gmail.com with ESMTPSA id im15-20020a170902bb0f00b001ec8888b22esm1336900plb.65.2024.05.01.05.17.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 05:18:03 -0700 (PDT) From: Sunil V L To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-serial@vger.kernel.org, acpica-devel@lists.linux.dev Cc: Catalin Marinas , Will Deacon , Paul Walmsley , Albert Ou , "Rafael J . Wysocki" , Len Brown , Bjorn Helgaas , Anup Patel , Thomas Gleixner , Samuel Holland , Greg Kroah-Hartman , Jiri Slaby , Robert Moore , Conor Dooley , Andrew Jones , Andy Shevchenko , Marc Zyngier , Atish Kumar Patra , Andrei Warkentin , Haibo1 Xu , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Sunil V L Subject: [PATCH v5 00/17] RISC-V: ACPI: Add external interrupt controller support Date: Wed, 1 May 2024 17:47:25 +0530 Message-Id: <20240501121742.1215792-1-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.40.1 Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This series adds support for the below ECR approved by ASWG. 1) MADT - https://drive.google.com/file/d/1oMGPyOD58JaPgMl1pKasT-VKsIKia7zR/view?usp=sharing The series primarily enables irqchip drivers for RISC-V ACPI based platforms. The series can be broadly categorized like below. 1) PCI ACPI related functions are migrated from arm64 to common file so that we don't need to duplicate them for RISC-V. 2) Added support for re-ordering the probe of interrupt controllers when IRQCHIP_ACPI_DECLARE is used. 3) To ensure probe order between interrupt controllers and devices, implicit dependency is created similar to when _DEP is present. 4) Added 8250 serial driver for a generic 16550 UART which is enumerated as ACPI platform device. 5) ACPI support added in RISC-V interrupt controller drivers. Changes since RFC v4: 1) Removed RFC tag as the RFCv4 design looked reasonable. 2) Dropped PCI patch needed to avoid warning when there is no MSI controller. This will be sent later separately after the current series. 3) Dropped PNP handling of _DEP since there is new ACPI ID for generic 16550 UART. Added the serial driver patch instead. 4) Rebased to latest linux-next. 5) Reordered/squashed patches in the series Changes since RFC v3: 1) Moved to _DEP method instead of fw_devlink. 2) PLIC/APLIC driver probe using namespace devices. 3) Handling PNP devices as part of clearing dependency. 4) Rebased to latest linux-next to get AIA DT drivers. Changes since RFC v2: 1) Introduced fw_devlink for ACPI nodes for IRQ dependency. 2) Dropped patches in drivers which are not required due to fw_devlink support. 3) Dropped pci_set_msi() patch and added a patch in pci_create_root_bus(). 4) Updated pnp_irq() patch so that none of the actual PNP drivers need to change. Changes since RFC v1: 1) Abandoned swnode approach as per Marc's feedback. 2) To cope up with AIA series changes which changed irqchip driver probe from core_initcall() to platform_driver, added patches to support deferred probing. 3) Rebased on top of Anup's AIA v11 and added tags. To test the series, 1) qemu should be built using the riscv_acpi_namespace_v2 branch at https://github.com/vlsunil/qemu.git 2) EDK2 should be built using the instructions at: https://github.com/tianocore/edk2/blob/master/OvmfPkg/RiscVVirt/README.md NOTE: One should be able to use u-boot as well as per instructions from Björn. https://lore.kernel.org/lkml/87a5lqsrvh.fsf@all.your.base.are.belong.to.us/ 3) Build Linux using this series. Run Qemu: qemu-system-riscv64 \ -M virt,pflash0=pflash0,pflash1=pflash1,aia=aplic-imsic \ -m 2G -smp 8 \ -serial mon:stdio \ -device virtio-gpu-pci -full-screen \ -device qemu-xhci \ -device usb-kbd \ -blockdev node-name=pflash0,driver=file,read-only=on,filename=RISCV_VIRT_CODE.fd \ -blockdev node-name=pflash1,driver=file,filename=RISCV_VIRT_VARS.fd \ -netdev user,id=net0 -device virtio-net-pci,netdev=net0 \ -kernel arch/riscv/boot/Image \ -initrd rootfs.cpio \ -append "root=/dev/ram ro console=ttyS0 rootwait earlycon=uart8250,mmio,0x10000000" To boot with APLIC only, use aia=aplic. To boot with PLIC, remove aia= option. This series is also available in acpi_b2_v5 branch at https://github.com/vlsunil/linux.git Based-on: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tag/?h=next-20240501 Sunil V L (17): arm64: PCI: Migrate ACPI related functions to pci-acpi.c ACPI: scan: Add a weak function to reorder the IRQCHIP probe ACPI: bus: Add acpi_riscv_init function ACPI: scan: Refactor dependency creation ACPI: scan: Add RISC-V interrupt controllers to honor list ACPI: scan: Define weak function to populate dependencies ACPI: bus: Add RINTC IRQ model for RISC-V ACPI: pci_link: Clear the dependencies after probe ACPI: RISC-V: Implement PCI related functionality ACPI: RISC-V: Implement function to reorder irqchip probe entries ACPI: RISC-V: Initialize GSI mapping structures ACPI: RISC-V: Implement function to add implicit dependencies irqchip/riscv-intc: Add ACPI support for AIA irqchip/riscv-imsic: Add ACPI support irqchip/riscv-aplic: Add ACPI support irqchip/sifive-plic: Add ACPI support serial: 8250: Add 8250_acpi driver arch/arm64/kernel/pci.c | 191 ------------ arch/riscv/Kconfig | 3 + arch/riscv/configs/defconfig | 1 + arch/riscv/include/asm/irq.h | 57 ++++ arch/riscv/kernel/acpi.c | 31 +- drivers/acpi/Kconfig | 3 + drivers/acpi/bus.c | 4 + drivers/acpi/pci_link.c | 3 + drivers/acpi/riscv/Makefile | 2 +- drivers/acpi/riscv/init.c | 14 + drivers/acpi/riscv/init.h | 4 + drivers/acpi/riscv/irq.c | 329 +++++++++++++++++++++ drivers/acpi/scan.c | 65 ++-- drivers/irqchip/irq-riscv-aplic-direct.c | 20 +- drivers/irqchip/irq-riscv-aplic-main.c | 70 +++-- drivers/irqchip/irq-riscv-aplic-main.h | 1 + drivers/irqchip/irq-riscv-aplic-msi.c | 9 +- drivers/irqchip/irq-riscv-imsic-early.c | 52 +++- drivers/irqchip/irq-riscv-imsic-platform.c | 32 +- drivers/irqchip/irq-riscv-imsic-state.c | 115 ++++--- drivers/irqchip/irq-riscv-imsic-state.h | 2 +- drivers/irqchip/irq-riscv-intc.c | 102 ++++++- drivers/irqchip/irq-sifive-plic.c | 89 ++++-- drivers/pci/pci-acpi.c | 182 ++++++++++++ drivers/tty/serial/8250/8250_acpi.c | 96 ++++++ drivers/tty/serial/8250/Kconfig | 8 + drivers/tty/serial/8250/Makefile | 1 + include/acpi/acpi_bus.h | 2 + include/linux/acpi.h | 9 + include/linux/irqchip/riscv-imsic.h | 10 + 30 files changed, 1155 insertions(+), 352 deletions(-) create mode 100644 drivers/acpi/riscv/init.c create mode 100644 drivers/acpi/riscv/init.h create mode 100644 drivers/acpi/riscv/irq.c create mode 100644 drivers/tty/serial/8250/8250_acpi.c