From patchwork Fri Jul 26 22:59:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kisel X-Patchwork-Id: 13743245 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 14BDAC3DA49 for ; Fri, 26 Jul 2024 23:01:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=4vaIu2cEtSVp+bjNc+RfZaBe8pNFl4ohmrBuqhrOtgc=; b=v3Cge4uw/DfX0/1z6Ra/IRkX6u LmT0WtgeczAi67828AnGJUFLbACJmZ7ZKzymYEwWPRDqIhrIi8KDiV9HJ/Njazm5hM1TIkp5p9oPv tfwaqEtvW7Nb0WcNfanlqoobtNBajy2bBqeMBFbDJXmvKQAeO7bykOyZ7rPE9CaAyBq8pwqa8U004 LFMUHLliP8xlTKdxzv26pPDIEEuqPMIEclyk5h+e7VgTH0JyeZTxU+qVpDXIQEWMlzaMHRIwHUnmV hJTFZ9aRg9KfE+MuzQ3fZ3Es18s/ak2Htmm/e07ZQkCGKVJQTJkjenffCVBn5vxIfdSG/wLFAMMlb J7qbhJVg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXTwN-00000005IDD-336l; Fri, 26 Jul 2024 23:01:35 +0000 Received: from linux.microsoft.com ([13.77.154.182]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXTuP-00000005HIa-22gX for linux-arm-kernel@lists.infradead.org; Fri, 26 Jul 2024 22:59:34 +0000 Received: from romank-3650.corp.microsoft.com (unknown [131.107.159.62]) by linux.microsoft.com (Postfix) with ESMTPSA id CBF7D20B7131; Fri, 26 Jul 2024 15:59:29 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com CBF7D20B7131 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1722034770; bh=4vaIu2cEtSVp+bjNc+RfZaBe8pNFl4ohmrBuqhrOtgc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ifls2ATr8KECM4bvDJ5IAeXj1JMZS5t3yp814sYi/dAkxL35MPfq6JG2HfH7Q/XkJ uX0zS1bBgTDoeA3MrkbFjwyhF5BvqDZY24fonP8+uxqueoEHNx/dd9O85VfP7K9jzA /9lBCoUC18fqOQrPZctyv6Q5OlKj/Uuqfd90xvkE= From: Roman Kisel To: arnd@arndb.de, bhelgaas@google.com, bp@alien8.de, catalin.marinas@arm.com, dave.hansen@linux.intel.com, decui@microsoft.com, haiyangz@microsoft.com, hpa@zytor.com, kw@linux.com, kys@microsoft.com, lenb@kernel.org, lpieralisi@kernel.org, mingo@redhat.com, rafael@kernel.org, robh@kernel.org, tglx@linutronix.de, wei.liu@kernel.org, will@kernel.org, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, x86@kernel.org Cc: apais@microsoft.com, benhill@microsoft.com, ssengar@microsoft.com, sunilmut@microsoft.com, vdso@hexbites.dev Subject: [PATCH v3 6/7] Drivers: hv: vmbus: Get the IRQ number from DT Date: Fri, 26 Jul 2024 15:59:09 -0700 Message-Id: <20240726225910.1912537-7-romank@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240726225910.1912537-1-romank@linux.microsoft.com> References: <20240726225910.1912537-1-romank@linux.microsoft.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240726_155933_769116_411738BC X-CRM114-Status: GOOD ( 15.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The VMBus driver uses ACPI for interrupt assignment on arm64 hence it won't function in the VTL mode where only DeviceTree can be used. Update the VMBus driver to discover interrupt configuration via DeviceTree and indicate DMA cache coherency. Signed-off-by: Roman Kisel --- drivers/hv/vmbus_drv.c | 49 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index 12a707ab73f8..7eee7caff5f6 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -2306,6 +2306,34 @@ static int vmbus_acpi_add(struct platform_device *pdev) } #endif +static int __maybe_unused vmbus_set_irq(struct platform_device *pdev) +{ + struct irq_desc *desc; + int irq; + + irq = platform_get_irq(pdev, 0); + if (irq == 0) { + pr_err("VMBus interrupt mapping failure\n"); + return -EINVAL; + } + if (irq < 0) { + pr_err("VMBus interrupt data can't be read from DeviceTree, error %d\n", irq); + return irq; + } + + desc = irq_to_desc(irq); + if (!desc) { + pr_err("No interrupt descriptor for VMBus virq %d\n", irq); + return -ENODEV; + } + + vmbus_irq = irq; + vmbus_interrupt = desc->irq_data.hwirq; + pr_debug("VMBus virq %d, hwirq %d\n", vmbus_irq, vmbus_interrupt); + + return 0; +} + static int vmbus_device_add(struct platform_device *pdev) { struct resource **cur_res = &hyperv_mmio; @@ -2320,6 +2348,12 @@ static int vmbus_device_add(struct platform_device *pdev) if (ret) return ret; +#ifndef HYPERVISOR_CALLBACK_VECTOR + ret = vmbus_set_irq(pdev); + if (ret) + return ret; +#endif + for_each_of_range(&parser, &range) { struct resource *res; @@ -2338,6 +2372,21 @@ static int vmbus_device_add(struct platform_device *pdev) cur_res = &res->sibling; } + /* + * Hyper-V always assumes DMA cache coherency, and the DMA subsystem + * might default to 'not coherent' on some architectures. + * Avoid high-cost cache coherency maintenance done by the CPU. + */ +#if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \ + defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \ + defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL) + + if (!of_property_read_bool(np, "dma-coherent")) + pr_warn("Assuming cache coherent DMA transactions, no 'dma-coherent' node supplied\n"); + pdev->dev.dma_coherent = true; + +#endif + return ret; }