From patchwork Wed Mar 15 09:55:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: You-Sheng Yang X-Patchwork-Id: 1757263 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Pc5PB0PTJz1yWr for ; Wed, 15 Mar 2023 20:55:42 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1pcNr4-0006tz-0e; Wed, 15 Mar 2023 09:55:34 +0000 Received: from mail-pj1-f43.google.com ([209.85.216.43]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1pcNr2-0006t2-FW for kernel-team@lists.ubuntu.com; Wed, 15 Mar 2023 09:55:32 +0000 Received: by mail-pj1-f43.google.com with SMTP id u3-20020a17090a450300b00239db6d7d47so1329364pjg.4 for ; Wed, 15 Mar 2023 02:55:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678874130; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=47AQDzY7I6gU7uhnQjxdwOzww+oVCn0Jd5LR0qNjTaw=; b=IhgmdUlBhzTtf6LwX849PH9ZW8yxWDMOat62bXPMUw3hEUeFXohZOLmM9tLJYEcd0a lrnVV5/uiblAzsBSkmlskA+nKZjC2wsuHZpK6roB9oI2ISW1pjM9nPJz/gUYlaqdOGPF QKx3dvemBd7uYXvIHr6X4WBw+nchR4BkS5sIrZtJPQtVQIwAUHA4YDyOEXG/frb1gUSU ajrmzQxluNFk0mxlXrx64YAh60EQJofwL9jc0lWE1WhqEjsvBh2FQsbrJ1JbBiQc7spo R8+Y+8UYZjN8wt3xp3ZYsSCJ85cY3wlwHafYWLGTpS8Yeq5n+qzgGo44XJ2GLJk2tY0f 10bw== X-Gm-Message-State: AO0yUKVIp7B/tA7O3BlnHp694hgzW6clOiRbiawkzVVXFzrZOPvbNzIk N9f+dalYf9F2D2xKOnNDA5JefGvBvcg= X-Google-Smtp-Source: AK7set8Ik7hHdeZp4a61Bq8ZAXDV8N64Ja6gayDKzqQplpw5PraWxvdtf/zyjFaxXJ2gMcNpySJS7A== X-Received: by 2002:a17:90b:1d03:b0:23e:fa90:ba3e with SMTP id on3-20020a17090b1d0300b0023efa90ba3emr1212975pjb.13.1678874130391; Wed, 15 Mar 2023 02:55:30 -0700 (PDT) Received: from yewun.. (61-227-101-134.dynamic-ip.hinet.net. [61.227.101.134]) by smtp.gmail.com with ESMTPSA id ju17-20020a170903429100b0019cbd37a335sm3252111plb.93.2023.03.15.02.55.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 02:55:30 -0700 (PDT) From: You-Sheng Yang To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/1][SRU][Lunar][Unstable] UBUNTU: SAUCE: PCI: vmd: guard device addition and removal Date: Wed, 15 Mar 2023 17:55:03 +0800 Message-Id: <20230315095503.2317568-2-vicamo.yang@canonical.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230315095503.2317568-1-vicamo.yang@canonical.com> References: <20230315095503.2317568-1-vicamo.yang@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.216.43; envelope-from=vicamo@gmail.com; helo=mail-pj1-f43.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: "You-Sheng Yang (vicamo)" BugLink: https://bugs.launchpad.net/bugs/2011389 vmd may fail to create sysfs entry while `pci_rescan_bus()` called in some other drivers like wwan. sysfs: cannot create duplicate filename '/devices/.../resource0' Call Trace: sysfs_warn_dup.cold+0x17/0x34 sysfs_add_bin_file_mode_ns+0xc0/0xf0 sysfs_create_bin_file+0x6d/0xb0 pci_create_attr+0x117/0x260 pci_create_resource_files+0x6b/0x150 pci_create_sysfs_dev_files+0x18/0x30 pci_bus_add_device+0x30/0x80 pci_bus_add_devices+0x31/0x80 pci_bus_add_devices+0x5b/0x80 vmd_enable_domain.constprop.0+0x6b7/0x880 [vmd] vmd_probe+0x16d/0x193 [vmd] Fixes: 185a383ada2e ("x86/PCI: Add driver for Intel Volume Management Device (VMD)") Suggested-by: Kai-Heng Feng Signed-off-by: You-Sheng Yang (vicamo) --- drivers/pci/controller/vmd.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c index 769eedeb8802..f050991bd1e9 100644 --- a/drivers/pci/controller/vmd.c +++ b/drivers/pci/controller/vmd.c @@ -838,9 +838,13 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features) pci_add_resource_offset(&resources, &vmd->resources[1], offset[0]); pci_add_resource_offset(&resources, &vmd->resources[2], offset[1]); + pci_lock_rescan_remove(); + vmd->bus = pci_create_root_bus(&vmd->dev->dev, vmd->busn_start, &vmd_ops, sd, &resources); if (!vmd->bus) { + pci_unlock_rescan_remove(); + pci_free_resource_list(&resources); vmd_remove_irq_domain(vmd); return -ENODEV; @@ -893,6 +897,8 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features) vmd_acpi_end(); + pci_unlock_rescan_remove(); + WARN(sysfs_create_link(&vmd->dev->dev.kobj, &vmd->bus->dev.kobj, "domain"), "Can't create symlink to domain\n"); return 0;