Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp138299lqr; Wed, 5 Jun 2024 01:06:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVu+j3cyfQAuug+F+OvWd6PsHKHUe4LVLc4PyKZ6rpK5ImaPU2AXbKt9GIlIl8gGFkMI/jGFSl/8chCv24ahoxAwEBRx/KYjIevt03fvA== X-Google-Smtp-Source: AGHT+IHUZW3CMW9yIeNY1ZsV9zPXBrg9KxOSMx5GNsqGfJq839ZE/nznXIc86ss6DLH8dXHtonQy X-Received: by 2002:ac8:590d:0:b0:43a:cfc5:9cdf with SMTP id d75a77b69052e-4402b619e9bmr21723021cf.32.1717574772953; Wed, 05 Jun 2024 01:06:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717574772; cv=pass; d=google.com; s=arc-20160816; b=AF5q0h7RvEIAK4D5626jv9FgxTEqXdsGBVtZ7wG0o6Q5iwurL1+fg4bc6s6WQW8aUy 95y7Aeh9DPqP74KMhJt/5pcBh2q5dcenHritQwj7knn3krUU3PJob7RqqWOKT740Ed96 0j6Qhsy3WC+RGU643YXx5Lx2sySO0CK0nStnUiYRqzMwZQa2CXV72tG5bjt51CNZ6q8v oRHVun5xyGKVMO/OYBxlwKYQwjoKgUS0xQvuw1u0kBEFesxy9A7Vs8z5GP0CnT5EZ9yp IvlS7h3tovU+yCQ789njdQmq56LRuwtoyx9/v+XxtscZoNdH5mBmZTsfNdSzTMEX0jCk lf1w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=PVpxHacadX3v1Jpi8ge1wxLL0LsNrEZCAoTEQu6/AwY=; fh=SJQJ0vW7Np4n1TQfGmyH7+snHuOwVOWcfsimWRAJ8Y4=; b=zBm4VHFLbmtR0Qa3BUioIlX8q+X0wCN6pYXFbmuIxxwJENtILsLRCilejguVXznSbI DWo9K8tP01Wyt1b+DKGd6s+Ypgi1ZE859J9HQWjVxgMGlSLeC6jgAUafuwLQjfb6vNAd PChgH8qPwMicnbovELMvMDrbtQqeHUZpdqDubVsPyxVi2p9KMfdUPkpuXhwyHbh6wa5+ IRZ74xCvOrpNN7u03nptJ7cyfv41kMqvvlGTdCGLcySjsIpqmBlDgSx6SX6lY9dUCQCa mBpSivuzIUFMGsxV4WQztZCaa2ETNZtRqB6ky8n8KhnbWOdJSZDkYt/Mpijp3Ust/y76 Tnww==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=EsVF6wF+; 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-201923-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201923-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-4402b6de886si14524831cf.642.2024.06.05.01.06.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 01:06:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-201923-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=EsVF6wF+; 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-201923-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201923-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 532301C21027 for ; Wed, 5 Jun 2024 08:06:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5266C18F2E1; Wed, 5 Jun 2024 08:06:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="EsVF6wF+" Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.2]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 367D21922FC; Wed, 5 Jun 2024 08:05:59 +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=1717574764; cv=none; b=hDFc8RRYiYCYpgDKoLPllbbZtuz7tqto0DWaa2fAwdv7rPgwgtm/g9ZFh1Ap17wUGklYQLPJPYOik0qqzyw5DA5IgvmRvM8iHW+2ZxDmC7fnlX+9fgD1rwewsGZ4EIid8EVgbkkBmiawOKUBz9RRvUus8GnpkxmopMV2Suae4+0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717574764; c=relaxed/simple; bh=MEkf72hbkHlFJhXcMR6uH2GgppBTzzZuYu9Bj9tZ+aw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=SNzUIPk/ZfACMY9o5V75530YjATtiiOBvSSmKvqiSIOq7Prh8xJP62fTBxppiY7RrVXtfRKA4EBk7wbOcqqQfGFVDljAzDwDdRKOCsuqdxVL0aljjCdyxwTpVTJeGPygiFsF4yJtx39cn52uaQqEMA5zYr0omXKSZUwQq8od6Tw= 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=EsVF6wF+; 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=Message-ID:Date:MIME-Version:Subject:From: Content-Type; bh=PVpxHacadX3v1Jpi8ge1wxLL0LsNrEZCAoTEQu6/AwY=; b=EsVF6wF+sJPffZeWM1rhAChqEu4bITXYoFmrAnqS0mK4VKkvs9LSkCLg8f5DEH 8eNfxwJKTS/K/4ilGTCFTHukBib8y1BS23Pqlv1f77nLI0IeWH7X9261vp3HbVPZ uwK43GaO4pVRvrK/XVhrjIhFKzEPMkILQvX/jZ3pT/85Q= Received: from [10.0.2.15] (unknown [111.205.43.230]) by gzga-smtp-mta-g1-4 (Coremail) with SMTP id _____wD3f6gCHGBmGz6GBw--.28481S2; Wed, 05 Jun 2024 16:04:19 +0800 (CST) Message-ID: Date: Wed, 5 Jun 2024 16:04:18 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] PCI: vmd: Create domain symlink before pci_bus_add_devices() Content-Language: en-US To: Paul M Stillwell Jr , 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, ahuang12@lenovo.com References: <20240604135153.9182-1-sjiwei@163.com> From: Jiwei Sun In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-CM-TRANSID:_____wD3f6gCHGBmGz6GBw--.28481S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxCrWftr1DKF17Gw47Wr47XFb_yoWrJFWrpF WrWa1jvFW7Gr47XayDZ3W8WryYvw4vv34UJ3sxK347Z34DAFy09FW0gFs8ArWqvF1q93W2 vwsrXF1S9wn5KaDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UYD7-UUUUU= X-CM-SenderInfo: 5vml4vrl6rljoofrz/1tbiWwb0mWV4JSWaTQAAs6 On 6/5/24 02:00, Paul M Stillwell Jr wrote: > On 6/4/2024 6:51 AM, 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 >> 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 >> --- >> v2 changes: >>   - Add "()" after function names in subject and commit log >>   - Move sysfs_create_link() after vmd_attach_resources() >> >> --- >>   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..d0e33e798bb9 100644 >> --- a/drivers/pci/controller/vmd.c >> +++ b/drivers/pci/controller/vmd.c >> @@ -925,6 +925,9 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features) >>           dev_set_msi_domain(&vmd->bus->dev, >>                      dev_get_msi_domain(&vmd->dev->dev)); >>   +    WARN(sysfs_create_link(&vmd->dev->dev.kobj, &vmd->bus->dev.kobj, >> +                   "domain"), "Can't create symlink to domain\n"); >> + > > I think you should move the sysfs_remove_link() line in vmd_remove() down as well. Indeed, thanks for your suggestion. I will modify it in v3 patch. Thanks, Regards, Jiwei > > Paul > >>       vmd_acpi_begin(); >>         pci_scan_child_bus(vmd->bus); >> @@ -964,9 +967,6 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features) >>       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; >>   } >>