Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp994658lqj; Mon, 3 Jun 2024 07:17:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVkyExu1Le+VI4FvQOkk5BFIFuRAkT8yOiv80cNtmLz2Gae3uEAXPi/MLM9ClB3kv5rhiAqsaP86HuKIbKmK7h6U/4VFK+7AYdnvEbllg== X-Google-Smtp-Source: AGHT+IHVpZu5p/eg1sfCmf7gF5uGsn39kkNx3+fSpQaOkipTEeCPGG2nQ4ZkzvfcrpGbgPQeXhzM X-Received: by 2002:a05:6a20:12cb:b0:1af:6911:7ff4 with SMTP id adf61e73a8af0-1b26f17e121mr9582834637.7.1717424277309; Mon, 03 Jun 2024 07:17:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717424277; cv=pass; d=google.com; s=arc-20160816; b=P/cxd/oi8T1rPtFGCiAQ2fw4qdVVMk02WtGyYHTTwlbDqvOZ+nXUzdyFmfLJgn8aKe iGLF5Nvo9pyyOQSJPJPSLx8dpVl3nnq9dH23FxlSCVJrFNs3vDkpBMyl5fIsEFC0cE6f twNExZke5prc91hGPwIKs5xBd4pcqGYx/qJGRyzqFjGazBnSFBiuVbyRAB1Gmqn6XUwC sPhXb21dsd0mO6YHFHmD6G/ge2Y1fwo9qXbrcl+RtpxmLeK8l4J+DSANMkkx3+Pu4wEl 9ux1wdNh/i79Qrev9Q2lF3CjO4FM04zUTarG5VcYD30lpXrAB/IhkhHPlLBwhiZ35+wQ KB5g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=iXigcK1/rNJxXW9WTe11+jDAKyiolDNuGVVDMYRGuUs=; fh=CXz1qotO/hqxdvV8aCr9kAL1aKsPxXiJ5ujDF9dGEi4=; b=KR3ZVD+IatuO0wgp/CdRPoqHv75Aj+10WheMJNoPmyA8Myv3416RDrgvyz6SB1lb2Y WDgWHVOmhzfKI8/4LbPXMPOLlvMBEHfHCKmQyxFDp7TYDt6Jnk59vq7MIy+6bbmItUnv ydeDSicWWkMtB/IpnNVDwTTNPRGljiswRRsSop6FkJXM/eOaCXUqn7YcCDbL0f4t5Roi DRWtOjl28Og5tV69Xl1BEOZrvZCmgeuD+ntD8N9mMNhgibI56quM+lcx/lhP3lU2mIc3 530yqsIvml8ZDJWoNorz3FjDObWipFH2gX3k7vjj0GZLKdRQlfQP2EjOqRn0sv6e/tR2 mWAA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=blspyjEN; arc=pass (i=1 spf=pass spfdomain=163.com dkim=pass dkdomain=163.com dmarc=pass fromdomain=163.com); spf=pass (google.com: domain of linux-kernel+bounces-199264-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199264-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6c35515738asi6544925a12.232.2024.06.03.07.17.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 07:17:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199264-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=blspyjEN; arc=pass (i=1 spf=pass spfdomain=163.com dkim=pass dkdomain=163.com dmarc=pass fromdomain=163.com); spf=pass (google.com: domain of linux-kernel+bounces-199264-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199264-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 08569B2346E for ; Mon, 3 Jun 2024 14:04:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AC11912DDBC; Mon, 3 Jun 2024 14:04:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="blspyjEN" Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.2]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0D25115C3; Mon, 3 Jun 2024 14:04:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.2 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717423471; cv=none; b=U9zNJzMO93wpg9xtNDFgSo+10BQI/RbxoL+xmG9kbIA5zAKbfCi2y35xpDfiveuiELNkaO6YHNsetJYUsEd7vNVLVDAn1BLJfOPjL+sROmFAstcMdEFUGrRmeLON9oXBPreJKohCFYffHwwW36pxltLeuguxbJygEJVAx12bJgA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717423471; c=relaxed/simple; bh=Xoq1p+b3eBnSukSfe9FWye+UT3Hp7+xp0/RNktg5xCg=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=Ja8aFUebqZMiU71jPWvOrXjjLyYiNaZrcGBIiKKeX7kZMFz85sxtqlmVGCvRefPwLj6FjVyCN/Q3au9NpDD7qucT81NTqrAx/892pLeDsz+jDA0TDxXt9BLeH7WN8fXhwTVbOWEXN7uPrmoF3GoHeOCYZhbuu03cREaLb5gMPAg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=blspyjEN; arc=none smtp.client-ip=220.197.31.2 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=iXigc K1/rNJxXW9WTe11+jDAKyiolDNuGVVDMYRGuUs=; b=blspyjEN/rpWEKJ0FJsqo DuWO8ccEWGP56E3Ld1s6yAGjV6mqCWqrysW42U3RBzmA2ULMctHjQ2ODGKfWyaDR U9E7iduQQaDSox1li7vuZit+EBXrRPrWqOuqPS/v+ZNRLyLN/d+Mktyd1UKH44wo 2xXFpfwqgf8YEBpALnewYs= Received: from localhost.localdomain (unknown [120.244.62.148]) by gzga-smtp-mta-g3-4 (Coremail) with SMTP id _____wDHr3IzzV1mhWbsCQ--.60420S2; Mon, 03 Jun 2024 22:03:32 +0800 (CST) From: Jiwei Sun To: nirmal.patel@linux.intel.com, jonathan.derrick@linux.dev Cc: lpieralisi@kernel.org, kw@linux.com, robh@kernel.org, bhelgaas@google.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, sunjw10@lenovo.com, sjiwei@163.com, ahuang12@lenovo.com Subject: [PATCH] PCI: vmd: Create domain symlink before pci_bus_add_devices Date: Mon, 3 Jun 2024 22:03:29 +0800 Message-Id: <20240603140329.7222-1-sjiwei@163.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:_____wDHr3IzzV1mhWbsCQ--.60420S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxGr13Kr45urW3GF4ruF1DAwb_yoW5AFyrpF 4rWay2yr9rGw4fXayDA348X34Yva1qv345J3s8K3429r9xAFyF9rW09rZ8AFWqyF4qka4a vwsrXF1S93Z8KaDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0piX_-PUUUUU= X-CM-SenderInfo: 5vml4vrl6rljoofrz/1tbiWxzymWV4JPg6sQABsn From: Jiwei Sun During booting into the kernel, the following error message appears: (udev-worker)[2149]: nvme1n1: '/sbin/mdadm -I /dev/nvme1n1'(err) 'mdadm: Unable to get real path for '/sys/bus/pci/drivers/vmd/0000:c7:00.5/domain/device'' (udev-worker)[2149]: nvme1n1: '/sbin/mdadm -I /dev/nvme1n1'(err) 'mdadm: /dev/nvme1n1 is not attached to Intel(R) RAID controller.' (udev-worker)[2149]: nvme1n1: '/sbin/mdadm -I /dev/nvme1n1'(err) 'mdadm: No OROM/EFI properties for /dev/nvme1n1' (udev-worker)[2149]: nvme1n1: '/sbin/mdadm -I /dev/nvme1n1'(err) 'mdadm: no RAID superblock on /dev/nvme1n1.' (udev-worker)[2149]: nvme1n1: Process '/sbin/mdadm -I /dev/nvme1n1' failed with exit code 1. This symptom prevents the OS from booting successfully. After a NVMe disk is probed/added by the nvme driver, the udevd executes some rule scripts by invoking mdadm command to detect if there is a mdraid associated with this NVMe disk. The mdadm determines if one NVMe devce is connected to a particular VMD domain by checking the domain symlink. Here is the root cause: Thread A Thread B Thread mdadm vmd_enable_domain pci_bus_add_devices __driver_probe_device ... work_on_cpu schedule_work_on : wakeup Thread B nvme_probe : wakeup scan_work to scan nvme disk and add nvme disk then wakeup udevd : udevd executes mdadm command flush_work main : wait for nvme_probe done ... __driver_probe_device find_driver_devices : probe next nvme device : 1) Detect the domain ... symlink; 2) Find the ... domain symlink from ... vmd sysfs; 3) The ... domain symlink is not ... created yet, failed sysfs_create_link : create domain symlink sysfs_create_link is invoked at the end of vmd_enable_domain. However, this implementation introduces a timing issue, where mdadm might fail to retrieve the vmd symlink path because the symlink has not been created yet. Fix the issue by creating VMD domain symlinks before invoking pci_bus_add_devices. Signed-off-by: Jiwei Sun Suggested-by: Adrian Huang --- drivers/pci/controller/vmd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c index 87b7856f375a..3f208c5f9ec9 100644 --- a/drivers/pci/controller/vmd.c +++ b/drivers/pci/controller/vmd.c @@ -961,12 +961,12 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features) list_for_each_entry(child, &vmd->bus->children, node) pcie_bus_configure_settings(child); + WARN(sysfs_create_link(&vmd->dev->dev.kobj, &vmd->bus->dev.kobj, + "domain"), "Can't create symlink to domain\n"); + pci_bus_add_devices(vmd->bus); vmd_acpi_end(); - - WARN(sysfs_create_link(&vmd->dev->dev.kobj, &vmd->bus->dev.kobj, - "domain"), "Can't create symlink to domain\n"); return 0; } -- 2.27.0