Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4618756ioa; Wed, 27 Apr 2022 07:36:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPAkaGjwxoCUJfDXazh0ALemmHFXpz2wsyyIODbHZyX5+j4adwurtK+86TNoflDVfwcZYq X-Received: by 2002:a17:90a:4a95:b0:1d8:2918:7065 with SMTP id f21-20020a17090a4a9500b001d829187065mr31016208pjh.117.1651070179629; Wed, 27 Apr 2022 07:36:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651070179; cv=none; d=google.com; s=arc-20160816; b=ik6GI1kIrxs5Wt4Edx4EDN1VUxCIxLWo2s+dvUXt59S3EwW8Mq6M5vQowJbc3GTS6t T13bLP+jKynWIB6S166prxUSgXXTaxcBzfQz+6zTRw/FKh4jolrIayM52GThO95t53mz 9P6gSVg6miLurEqXxYS14ThQzudq8h4xmCrnJXT8qQcBBQc+VBkBhUNf/SSctagfHnX0 e9FiwEt8wMJVL5B5NSYD+IVtC5djr48ZorIN44I6ncEjwTS10csCWhaRFuR+IkKcbKZf 9l/MXNyaXLjDOal7uvD0+KmxbR41kVqW+Mbq2G/vumSxMFeDv3G/N9IoxuCHRQiDiL7l KyXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=cblFLWU9Obld6XdJ/tWy2TbBqCQ/EgkBLiVDV/EwnE8=; b=R7wqFg7FZmHFpVvayUKAQ1lysPaIzZwnZI6L9IKzHgDM3dies+2mnprIxgX6Uh+fUi uFGf7hm1EjYY7uQcyZcRTB8U7AcFlhQjOU8vDwCSJ7wQdcQtC1G9sO26J3q3KGsMehO0 2Ti7Hw6QQtyGJMfjErYf7TY7U8SKJEh9DGUVLySGwnxFYzA3rRIumXUja759793Krrlv Q6Y/DqwE2JT8uF3UGFShj3SbT/Um+wMlJ7/FBQRTAfsAe16JBQ8ttJzgeiN66uWm01h5 Uj4/4UxO5sWd2/NU8yX75eo4aKQSAzv6W/Da8Pe+AL9XlJqGQm/8R0AmVg1Qb0+25oJ5 WaRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=BCyogB2z; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id s14-20020a170902ea0e00b0015d0062ecc6si2008566plg.228.2022.04.27.07.36.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 07:36:19 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=BCyogB2z; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B843A4757C; Wed, 27 Apr 2022 07:08:22 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237151AbiD0OLN (ORCPT + 99 others); Wed, 27 Apr 2022 10:11:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237258AbiD0OLK (ORCPT ); Wed, 27 Apr 2022 10:11:10 -0400 Received: from alexa-out-sd-01.qualcomm.com (alexa-out-sd-01.qualcomm.com [199.106.114.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA70E4EA29; Wed, 27 Apr 2022 07:07:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1651068474; x=1682604474; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=cblFLWU9Obld6XdJ/tWy2TbBqCQ/EgkBLiVDV/EwnE8=; b=BCyogB2zQwYVpaI4Wyg/ClTnpnRTZnT7H4OgDKJ3+osds0vYTK7z7c6P gQz4UN74uVemaXzrPpSfpv/CZ1V9O+FH9zZZiyp0heb2IkS5gIqmBYTrk W6ExBO5Z1HVx/QuuSgSRvzMw0ULWIyCD10ZAMWfm46EIHp3MYWswnEfkV o=; Received: from unknown (HELO ironmsg01-sd.qualcomm.com) ([10.53.140.141]) by alexa-out-sd-01.qualcomm.com with ESMTP; 27 Apr 2022 07:07:53 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg01-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2022 07:07:52 -0700 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Wed, 27 Apr 2022 07:07:52 -0700 Received: from jhugo-lnx.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Wed, 27 Apr 2022 07:07:51 -0700 From: Jeffrey Hugo To: , , , , , , , , CC: , , , , Jeffrey Hugo Subject: [PATCH] PCI: hv: Fix hv_arch_irq_unmask() for multi-MSI Date: Wed, 27 Apr 2022 08:07:33 -0600 Message-ID: <1651068453-29588-1-git-send-email-quic_jhugo@quicinc.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the multi-MSI case, hv_arch_irq_unmask() will only operate on the first MSI of the N allocated. This is because only the first msi_desc is cached and it is shared by all the MSIs of the multi-MSI block. This means that hv_arch_irq_unmask() gets the correct address, but the wrong data (always 0). This can break MSIs. Lets assume MSI0 is vector 34 on CPU0, and MSI1 is vector 33 on CPU0. hv_arch_irq_unmask() is called on MSI0. It uses a hypercall to configure the MSI address and data (0) to vector 34 of CPU0. This is correct. Then hv_arch_irq_unmask is called on MSI1. It uses another hypercall to configure the MSI address and data (0) to vector 33 of CPU0. This is wrong, and results in both MSI0 and MSI1 being routed to vector 33. Linux will observe extra instances of MSI1 and no instances of MSI0 despite the endpoint device behaving correctly. For the multi-MSI case, we need unique address and data info for each MSI, but the cached msi_desc does not provide that. However, that information can be gotten from the int_desc cached in the chip_data by compose_msi_msg(). Fix the multi-MSI case to use that cached information instead. Since hv_set_msi_entry_from_desc() is no longer applicable, remove it. Signed-off-by: Jeffrey Hugo --- drivers/pci/controller/pci-hyperv.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c index 5800ecf..7aea0b7 100644 --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -611,13 +611,6 @@ static unsigned int hv_msi_get_int_vector(struct irq_data *data) return cfg->vector; } -static void hv_set_msi_entry_from_desc(union hv_msi_entry *msi_entry, - struct msi_desc *msi_desc) -{ - msi_entry->address.as_uint32 = msi_desc->msg.address_lo; - msi_entry->data.as_uint32 = msi_desc->msg.data; -} - static int hv_msi_prepare(struct irq_domain *domain, struct device *dev, int nvec, msi_alloc_info_t *info) { @@ -647,6 +640,7 @@ static void hv_arch_irq_unmask(struct irq_data *data) { struct msi_desc *msi_desc = irq_data_get_msi_desc(data); struct hv_retarget_device_interrupt *params; + struct tran_int_desc *int_desc; struct hv_pcibus_device *hbus; struct cpumask *dest; cpumask_var_t tmp; @@ -661,6 +655,7 @@ static void hv_arch_irq_unmask(struct irq_data *data) pdev = msi_desc_to_pci_dev(msi_desc); pbus = pdev->bus; hbus = container_of(pbus->sysdata, struct hv_pcibus_device, sysdata); + int_desc = data->chip_data; spin_lock_irqsave(&hbus->retarget_msi_interrupt_lock, flags); @@ -668,7 +663,8 @@ static void hv_arch_irq_unmask(struct irq_data *data) memset(params, 0, sizeof(*params)); params->partition_id = HV_PARTITION_ID_SELF; params->int_entry.source = HV_INTERRUPT_SOURCE_MSI; - hv_set_msi_entry_from_desc(¶ms->int_entry.msi_entry, msi_desc); + params->int_entry.msi_entry.address.as_uint32 = int_desc->address & 0xffffffff; + params->int_entry.msi_entry.data.as_uint32 = int_desc->data; params->device_id = (hbus->hdev->dev_instance.b[5] << 24) | (hbus->hdev->dev_instance.b[4] << 16) | (hbus->hdev->dev_instance.b[7] << 8) | -- 2.7.4