From patchwork Wed Apr 19 22:23:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Kumar Patra X-Patchwork-Id: 13217568 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C943CC77B7C for ; Wed, 19 Apr 2023 22:24:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 32A27900039; Wed, 19 Apr 2023 18:24:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 21498900002; Wed, 19 Apr 2023 18:24:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 08E64900039; Wed, 19 Apr 2023 18:24:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id EA6C2900002 for ; Wed, 19 Apr 2023 18:24:23 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id C1AFE4018F for ; Wed, 19 Apr 2023 22:24:23 +0000 (UTC) X-FDA: 80699570406.21.1CBF937 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by imf11.hostedemail.com (Postfix) with ESMTP id E8D2340008 for ; Wed, 19 Apr 2023 22:24:21 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=Hy5Vjaj1; spf=pass (imf11.hostedemail.com: domain of atishp@rivosinc.com designates 209.85.214.173 as permitted sender) smtp.mailfrom=atishp@rivosinc.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681943062; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=joeGaZNojBtAEH48oFyXyXsTdXyxZ+syATM0NtCwkJg=; b=WsDmxexP2WtGEX9LICqRgeeh0mw86SRavqeKCR8bc9sXSGZz7SV3b/XwbvkJASTOvRzeQd HDVZcY55hpj6CareiQ4USYrs+hJaY/7ydAP0329dSds8GKFzC+rxz9LVejrCn4N92sr9Qi UpmRNivfCSjjwvgwmqZk8cmd3HyNQPU= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=Hy5Vjaj1; spf=pass (imf11.hostedemail.com: domain of atishp@rivosinc.com designates 209.85.214.173 as permitted sender) smtp.mailfrom=atishp@rivosinc.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681943062; a=rsa-sha256; cv=none; b=xbEhZMEkj33RBaXiuFu9wU9NcI3ttgPxmVNpTUhRkihWCiq4nQNYfdsvpj5SrDPQNwdBVX gjyPN0A5E6/g370FHBbgufdko3J+sgXh0TYSo9CYE0d0HJ5YeLaKkBDC8MBnrzgBSYeDSl xnHNOquTFWGtRldpy9a4LuvT9IINvGU= Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-1a526aa3dd5so5221825ad.3 for ; Wed, 19 Apr 2023 15:24:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1681943061; x=1684535061; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=joeGaZNojBtAEH48oFyXyXsTdXyxZ+syATM0NtCwkJg=; b=Hy5Vjaj1GFlfqXFgFU4Wk7wYhL+AdW+GISShF7pbpQzBCAzoyX06mKj9riDONUvoTu KJygh5nscsoyPvItPChqrHSXQPxDp5bYRAnKsEvFqcmijRhCw38xeSwetTsF9AvkbUYf hVmE7FSAH4Q4wrzRD6pw23VK9AaSnKgovUSlZ9QXs++6xGQZcPVEtNzbYKNpDmb7ydxL pihm7AbjTblUz+nkMI32xYxKW27gseqDrV0RGKN4T43bczPSmCXLp3fRh/utmO9YHtoB Sey/VFplr9PE2lySTaLRpT3t0lbZnm/yfBcOsJhGI8vtN1zAVWuoZu9OzywwnPC3RL4n V1wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681943061; x=1684535061; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=joeGaZNojBtAEH48oFyXyXsTdXyxZ+syATM0NtCwkJg=; b=CkcA2qBnMNzF/13arL+JU2Vv285+gQqp2ra8Q5SseSaDXI4S9UrmVytOrvecfnIEIx b7QFufIkG6HxEgh6s75nqlaOkeFt4vG0OJnTkVkKJWRMjXfOvth5tIpaF6LQArU/G2QE DcVn5HtUSoVa6aoo25GISDTByN/ejm6vOqMMLJkhlDLf0HtgmPaGpIOvzvd44aSP4hed qXnwjpBrcsYjnwbzPUvEb8sS/2ZbjdZAGAmqIYu3GxQwBfBeuuEw9h/XN2fCa91jzXuz ludq1xesL8jXLbJQJ9I16ylfNPAetG153nM3hM/57eODWTt7+3v8czDwVjcmK5L+BbX3 Eftg== X-Gm-Message-State: AAQBX9edaQ3lYFVvo+sBCI+dU6kAaDww+9R+BtWwq2VrT2KYuaKahKiq t7/Dg05C6JuHZgZIM6LcCRzUaw== X-Google-Smtp-Source: AKy350bpDV/yb/MMXonhLvjhCzwnd1ozKuOFojavKdcbbpka5zKY4L/5Rw/zrIiOtje9GuJuXPaRMw== X-Received: by 2002:a17:902:7891:b0:1a1:bf22:2b6e with SMTP id q17-20020a170902789100b001a1bf222b6emr6634040pll.43.1681943060762; Wed, 19 Apr 2023 15:24:20 -0700 (PDT) Received: from atishp.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id e4-20020a170902744400b001a681fb3e77sm11867810plt.44.2023.04.19.15.24.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 15:24:20 -0700 (PDT) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Rajnesh Kanwal , Alexandre Ghiti , Andrew Jones , Andrew Morton , Anup Patel , Atish Patra , Suzuki K Poulose , Will Deacon , Marc Zyngier , Sean Christopherson , linux-coco@lists.linux.dev, Dylan Reid , abrestic@rivosinc.com, Samuel Ortiz , Jiri Slaby , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , Paolo Bonzini , Uladzislau Rezki Subject: [RFC kvmtool 10/10] riscv: cove: Don't emit interrupt_map for pci devices in fdt. Date: Wed, 19 Apr 2023 15:23:50 -0700 Message-Id: <20230419222350.3604274-11-atishp@rivosinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230419222350.3604274-1-atishp@rivosinc.com> References: <20230419222350.3604274-1-atishp@rivosinc.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: E8D2340008 X-Stat-Signature: rfdcz18711qgff8pq9isydaeoy4zpg63 X-HE-Tag: 1681943061-102582 X-HE-Meta: U2FsdGVkX19IEul4tRhGHXaPglIxRODfKnCe2jdslgqE+lLoshFkJdb2O3agYyTvZ24O1oYkxrD8bzkrxu1akzlaY0zUNoQOUiXxvpwqli2HmQShmpgplHJUrnGgDcaKcT8Qxy8BdPCnytY4S9fGHGfA0JR9Uesmr+D2cO9YBVhQUGqFh9on9C/FHKv+SwDef5oah9F3DH2NM6BddySDuPEw+A9d2r089hOzwpt4oCkj2LRR6mgzsB76Fm6zboe9MOOqJ6oaDeiqOQ+BPa1X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fn2ypCWRsUnMpBY2aVViBPGiF0g712hjnkM9RshQQ7tj1k6E0yvgWMNtbHU1823En0a2Xc8PrH0XKLUgOY4p9jEKbYUJU/eTQnXnTSW1yux5Lp/36SxtQ5RrVM0wgPtxhC1CGxsOUWsFj5fqh3+iqRInTgcLtjV4LQgx3B0iO9zPs= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Rajnesh Kanwal CoVE VMs don't support pin based interrupts yet as APLIC isn't supported. Signed-off-by: Rajnesh Kanwal --- riscv/fdt.c | 2 +- riscv/include/kvm/kvm-arch.h | 2 +- riscv/pci.c | 83 +++++++++++++++++++----------------- 3 files changed, 46 insertions(+), 41 deletions(-) diff --git a/riscv/fdt.c b/riscv/fdt.c index a7d32b3..115ae17 100644 --- a/riscv/fdt.c +++ b/riscv/fdt.c @@ -232,7 +232,7 @@ static int setup_fdt(struct kvm *kvm) } /* PCI host controller */ - pci__generate_fdt_nodes(fdt); + pci__generate_fdt_nodes(fdt, kvm); _FDT(fdt_end_node(fdt)); diff --git a/riscv/include/kvm/kvm-arch.h b/riscv/include/kvm/kvm-arch.h index 08ac54a..9f6967f 100644 --- a/riscv/include/kvm/kvm-arch.h +++ b/riscv/include/kvm/kvm-arch.h @@ -104,7 +104,7 @@ void aia__create(struct kvm *kvm); void plic__create(struct kvm *kvm); -void pci__generate_fdt_nodes(void *fdt); +void pci__generate_fdt_nodes(void *fdt, struct kvm *kvm); int riscv__add_irqfd(struct kvm *kvm, unsigned int gsi, int trigger_fd, int resample_fd); diff --git a/riscv/pci.c b/riscv/pci.c index 9760ca3..31ea286 100644 --- a/riscv/pci.c +++ b/riscv/pci.c @@ -17,7 +17,7 @@ struct of_interrupt_map_entry { u32 irqchip_sense; } __attribute__((packed)); -void pci__generate_fdt_nodes(void *fdt) +void pci__generate_fdt_nodes(void *fdt, struct kvm *kvm) { struct device_header *dev_hdr; struct of_interrupt_map_entry irq_map[OF_PCI_IRQ_MAP_MAX]; @@ -67,51 +67,56 @@ void pci__generate_fdt_nodes(void *fdt) _FDT(fdt_property(fdt, "reg", &cfg_reg_prop, sizeof(cfg_reg_prop))); _FDT(fdt_property(fdt, "ranges", ranges, sizeof(ranges))); - /* Generate the interrupt map ... */ - dev_hdr = device__first_dev(DEVICE_BUS_PCI); - while (dev_hdr && nentries < ARRAY_SIZE(irq_map)) { - struct of_interrupt_map_entry *entry; - struct pci_device_header *pci_hdr = dev_hdr->data; - u8 dev_num = dev_hdr->dev_num; - u8 pin = pci_hdr->irq_pin; - u8 irq = pci_hdr->irq_line; + /* CoVE VMs do not support pin based interrupts yet as APLIC isn't + * supported. + */ + if (!kvm->cfg.arch.cove_vm) { + /* Generate the interrupt map ... */ + dev_hdr = device__first_dev(DEVICE_BUS_PCI); + while (dev_hdr && nentries < ARRAY_SIZE(irq_map)) { + struct of_interrupt_map_entry *entry; + struct pci_device_header *pci_hdr = dev_hdr->data; + u8 dev_num = dev_hdr->dev_num; + u8 pin = pci_hdr->irq_pin; + u8 irq = pci_hdr->irq_line; - entry = ((void *)irq_map) + (nsize * nentries); - *entry = (struct of_interrupt_map_entry) { - .pci_irq_mask = { - .pci_addr = { - .hi = cpu_to_fdt32(of_pci_b_ddddd(dev_num)), - .mid = 0, - .lo = 0, + entry = ((void *)irq_map) + (nsize * nentries); + *entry = (struct of_interrupt_map_entry) { + .pci_irq_mask = { + .pci_addr = { + .hi = cpu_to_fdt32(of_pci_b_ddddd(dev_num)), + .mid = 0, + .lo = 0, + }, + .pci_pin = cpu_to_fdt32(pin), }, - .pci_pin = cpu_to_fdt32(pin), - }, - .irqchip_phandle = cpu_to_fdt32(riscv_irqchip_phandle), - .irqchip_line = cpu_to_fdt32(irq), - }; + .irqchip_phandle = cpu_to_fdt32(riscv_irqchip_phandle), + .irqchip_line = cpu_to_fdt32(irq), + }; - if (riscv_irqchip_line_sensing) - entry->irqchip_sense = cpu_to_fdt32(IRQ_TYPE_LEVEL_HIGH); + if (riscv_irqchip_line_sensing) + entry->irqchip_sense = cpu_to_fdt32(IRQ_TYPE_LEVEL_HIGH); - nentries++; - dev_hdr = device__next_dev(dev_hdr); - } + nentries++; + dev_hdr = device__next_dev(dev_hdr); + } - _FDT(fdt_property(fdt, "interrupt-map", irq_map, nsize * nentries)); + _FDT(fdt_property(fdt, "interrupt-map", irq_map, nsize * nentries)); - /* ... and the corresponding mask. */ - if (nentries) { - struct of_pci_irq_mask irq_mask = { - .pci_addr = { - .hi = cpu_to_fdt32(of_pci_b_ddddd(-1)), - .mid = 0, - .lo = 0, - }, - .pci_pin = cpu_to_fdt32(7), - }; + /* ... and the corresponding mask. */ + if (nentries) { + struct of_pci_irq_mask irq_mask = { + .pci_addr = { + .hi = cpu_to_fdt32(of_pci_b_ddddd(-1)), + .mid = 0, + .lo = 0, + }, + .pci_pin = cpu_to_fdt32(7), + }; - _FDT(fdt_property(fdt, "interrupt-map-mask", &irq_mask, - sizeof(irq_mask))); + _FDT(fdt_property(fdt, "interrupt-map-mask", &irq_mask, + sizeof(irq_mask))); + } } /* Set MSI parent if available */