Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1219770lqj; Mon, 3 Jun 2024 14:08:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW4gW266Ni1c9bnErzMdQ+osxfpwnr6C/uXNo/3ve5on583s312dX3jOugkVUEnckPEAM34BLJz53gFwITo7VpbzcwdCW+WVgB77kvYMw== X-Google-Smtp-Source: AGHT+IGN5Ssj+1Amqy3NK+qzr9ESkzOeDZUTnBj0ncciHCHxWBIdoDBF+tm/0XnFa81AgKGuaoXS X-Received: by 2002:a92:c26a:0:b0:374:8088:44df with SMTP id e9e14a558f8ab-3748b991564mr133314085ab.11.1717448890370; Mon, 03 Jun 2024 14:08:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717448890; cv=pass; d=google.com; s=arc-20160816; b=EOAI/YjBjoEzy+j7CImNUNXEYky2spzQzpbkKAU6VoHTtBZd62z5ufVGf3/uqsxrWu xYny/zpvBq4vkaiT6zXEHotBiCEWuoWrKDwVjij0ReW18okwBqgvm2AyXLkLeeSyiXv/ m+DcWNfNJ1FIN7rSxLiHS89rEHwcNuZ77JpnLsmLZJhp2ZenkOGN+Q2KB4xlsu1k6pLG KjVmCSYi3mcou75CzidujphgC5jbhn6ff2x5DNzyGWls5qXRBjCP7bCu13B/bMbhWcGv jZppvoalVzfpX+/wG+8aAypzJ2Ss1JPzjtL8jfPSvoflOq2k+LgkcL8iFFkqGDQskLc3 CBmg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:subject:cc:to:from :date:dkim-signature; bh=IuNPdUzOC7+bgYLBDC8ORLNZU0tdhDwdGD6vY1Obt/E=; fh=VLZJsFhrSU18NogSSV8I9KVYmqBkTln2HYyIEtVzvoU=; b=rnCogWa/zH/aY7t5vSZFLaZFGx2oBwBQ4lCpRRvgh9Uz6RzUOTmNYsdaAIoZLuguXN OQ97eVPDLEugt9nEKIAK1lzTpAAv6GM9sPVIqGfHxlC0UmiA61qXDXqKz2SNz9nhgTUq Wj22i81rDDtmac5U0oAGmORx6l4bvhJ3zaeo4L4OPc+k79m9TCD0wiQ2woJERp8VxFgk ARejquLJBSs6XOxrvOt1jdcV9+UP+DAUAQXCJ2Q2wvXD9BDuH+9GuJU62D1Xd3xZWEHf JpU8fkQebfwPaaWS1SAYmMNIn6avGA2KlDEvSj5uv47oX72m1Xz4pJAaGTxtIMzIK1RG LsCA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GDyEutqp; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-199703-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199703-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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-6c4b69d2ddasi6821799a12.664.2024.06.03.14.08.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 14:08:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199703-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=@kernel.org header.s=k20201202 header.b=GDyEutqp; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-199703-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199703-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 90F89B23E0A for ; Mon, 3 Jun 2024 20:55:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D55E213B59A; Mon, 3 Jun 2024 20:55:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GDyEutqp" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E9A4CB651; Mon, 3 Jun 2024 20:55:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717448114; cv=none; b=tGjgzG/QlKR6KBpJ8EbeyZMHmRfAy86aPqkOCD8MWu0fmNJtYnGcskZPh3xJxkkV/zSHTtT6YJR9tmnFWoTa7sapRJDP+uyqlk424WouwoSVSpofuHV5F1P/9FH6NxFa7T9pxX0+F/AMUR9vnUWtfuXcdMhwEskEkgEZAOigLXg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717448114; c=relaxed/simple; bh=e1Wa7H9oZRv5OJi/Dfq+GIl0QsVGQOnJwkBTjlncu04=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; b=cNmo1JXtq77HnZfKmJDLy05jfdVbfrpM8/HEk8B25qFo6Uj+eFlFafJOgr5Feu8Q6rNeGBfsEzWjX+6/ftNO31CwdRiH9FoocsM/1SF5f79k8+xVXjGTZbePZzrgdb6b8/ekPVSUsDB2vr8GhkuPMIwzFrr0C8MRNAbc3SLCPLg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GDyEutqp; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30A80C2BD10; Mon, 3 Jun 2024 20:55:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717448113; bh=e1Wa7H9oZRv5OJi/Dfq+GIl0QsVGQOnJwkBTjlncu04=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=GDyEutqpwhllhwg5on9ZxtZUmUN2TugxIT87TekGPEiju3rtJhSvSObWjgQurn62L 8HKWqYBm7NtYzAxFTma0DuyTvQSSRUMDAHDAoMimgvPCdmgbmd5wGKmsnVjWX536Xy yzvHnqY0BkC6iJCjUGUMwvhREslSldEQw4hoTD3mlfQU/qZ8Vlh7u0/xhAMPgmvbA0 EeqEfHWJmylej3sE7OCuzzp7nxuRWjfxhtuv3Dpl0mzvdz3DKttPHiFwC1FS/zft7+ dcflda4o2HFn5rRMbMhXk7/nyUeYu+TkWZGMWo+VSnpiYvmimOm5hLmH+XwIv3He30 LEXWMV1tnLhAQ== Date: Mon, 3 Jun 2024 15:55:11 -0500 From: Bjorn Helgaas To: Jiwei Sun Cc: nirmal.patel@linux.intel.com, jonathan.derrick@linux.dev, 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, ahuang12@lenovo.com Subject: Re: [PATCH] PCI: vmd: Create domain symlink before pci_bus_add_devices Message-ID: <20240603205511.GA692326@bhelgaas> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240603140329.7222-1-sjiwei@163.com> On Mon, Jun 03, 2024 at 10:03:29PM +0800, Jiwei Sun wrote: > 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 device > 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. Add "()" after function names in subject and commit log. > 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"); Seems OK to me. IIUC, this "domain" link is created in the directory of the VMD pci_dev, and it points to the directory of the new "root bus" behind the VMD. Since it's unrelated to the *devices* on that new root bus, I would probably move this even earlier, so it's with the other code that sets up the new root bus, e.g., somewhere around vmd_attach_resources(). > 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 >