Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp4421262pxb; Mon, 21 Feb 2022 21:04:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJz2aOcdR8Xg+8XanvRd7RGaZsinMmU0DJ3bZwzTchSfOGJsOuBItBavh0EOzsU7rk2Ydop/ X-Received: by 2002:a17:90a:174f:b0:1bc:66ef:d733 with SMTP id 15-20020a17090a174f00b001bc66efd733mr2371410pjm.88.1645506285892; Mon, 21 Feb 2022 21:04:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645506285; cv=none; d=google.com; s=arc-20160816; b=yuSQnb6L4EYzWkgtc5/UL9HSPSld0o23sUtYrZ6TCWqljd7CyUjkP5A/FN1fwINckH kksQMr0eEtU7hwedEoXa4lnB0JyP0RNdjTLuoUiWgzly7Vb86SSVac8/uz8R8v9WL+p8 ezBix7g85+7/L2ygf5LL+LhKh/SsYUl3cejvOwvqxSonrUzDUMes39nEk3QSOoKkzY88 qwVLuJrTwB5rjdMSO4rAybKGJRjXUB3ZMS3m+HymDb9mTG1aB9/GeL0h9klVKi4Pv8H/ hif3f01V94RXuyFtJPPChs7P1iNESENcOtfUu9E7A4zlUUQ6OsCEYV29g2aOdsWQH4/2 psig== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ITLdKo9jNEWn6H7tpQS9tkFRVTiV0TGNrIDgWtquuzw=; b=I1+ccmZNe2TJQ0oTpff7YGzJFFGAtrB3bM4E7UgY4D0ELGzGKARXV/xx1JtD88ihRk IgAGvDTUiKsb8yIqUSFJGxxfqnQP2aWs0IwVfrw7Zhe8Go7YhZZursMjYX1SKwX1elK6 TyZMViYKtJ79+1oS+DP28mM99jJW3Jnw5VcE763qt8ArfHNHniB/6dMPWvJdfHFQ52Be 7RyHfYjhd0TSp0Lf0ZazRsIRIHKMLq0HMBGeSKF1drZadvk1/5xjQVjES0xhdDOWv4yL 1pdxqu0TXyhkWYSps1Dc2oRMOlUe1WYHr4cj3EAcsMVOGUMkbs5W1j5fpkIogkTzvHcs h5jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=x2ShE3k6; 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=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id q2si153798plc.155.2022.02.21.21.04.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 21:04:45 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=x2ShE3k6; 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=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 61E6A93988; Mon, 21 Feb 2022 20:38:01 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352672AbiBUJrq (ORCPT + 99 others); Mon, 21 Feb 2022 04:47:46 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:59638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343960AbiBUJlR (ORCPT ); Mon, 21 Feb 2022 04:41:17 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EC8C3CA51; Mon, 21 Feb 2022 01:17:29 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8A868608C4; Mon, 21 Feb 2022 09:17:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9AACFC340E9; Mon, 21 Feb 2022 09:17:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1645435047; bh=Vz4WDZtoUOzAcf9QAL9mQykts41Q8Xh0KlaY1mwEN2o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=x2ShE3k6FL4OA7b54Jz3FoaBhJsF1JTiW/biKgjjzNU8GbKGekguLv24XgzoeEQV+ lunGosk41cNzm6O3dfVAu4RFUPE+dyQK0d0x6SmZHJez4pdVgqV//yVU4/dzGTbduL 3Sws32DwHpoPiIEw7v0RujyYQSTkcEVvHkAPxAW8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Long Li , Michael Kelley , Purna Pavan Chandra Aekkaladevi , Lorenzo Pieralisi , Wei Liu Subject: [PATCH 5.16 025/227] PCI: hv: Fix NUMA node assignment when kernel boots with custom NUMA topology Date: Mon, 21 Feb 2022 09:47:24 +0100 Message-Id: <20220221084935.674987825@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220221084934.836145070@linuxfoundation.org> References: <20220221084934.836145070@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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 From: Long Li commit 3149efcdf2c6314420c418dfc94de53bfd076b1f upstream. When kernel boots with a NUMA topology with some NUMA nodes offline, the PCI driver should only set an online NUMA node on the device. This can happen during KDUMP where some NUMA nodes are not made online by the KDUMP kernel. This patch also fixes the case where kernel is booting with "numa=off". Fixes: 999dd956d838 ("PCI: hv: Add support for protocol 1.3 and support PCI_BUS_RELATIONS2") Signed-off-by: Long Li Reviewed-by: Michael Kelley Tested-by: Purna Pavan Chandra Aekkaladevi Acked-by: Lorenzo Pieralisi Link: https://lore.kernel.org/r/1643247814-15184-1-git-send-email-longli@linuxonhyperv.com Signed-off-by: Wei Liu Signed-off-by: Greg Kroah-Hartman --- drivers/pci/controller/pci-hyperv.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -1899,8 +1899,17 @@ static void hv_pci_assign_numa_node(stru if (!hv_dev) continue; - if (hv_dev->desc.flags & HV_PCI_DEVICE_FLAG_NUMA_AFFINITY) - set_dev_node(&dev->dev, hv_dev->desc.virtual_numa_node); + if (hv_dev->desc.flags & HV_PCI_DEVICE_FLAG_NUMA_AFFINITY && + hv_dev->desc.virtual_numa_node < num_possible_nodes()) + /* + * The kernel may boot with some NUMA nodes offline + * (e.g. in a KDUMP kernel) or with NUMA disabled via + * "numa=off". In those cases, adjust the host provided + * NUMA node to a valid NUMA node used by the kernel. + */ + set_dev_node(&dev->dev, + numa_map_to_online_node( + hv_dev->desc.virtual_numa_node)); put_pcichild(hv_dev); }