Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5300894rdb; Wed, 13 Dec 2023 05:08:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IFjRZKpNOQuetRhzZhwk5HmnUIXlWWb8zriK6UtTapmANrnfXsNyCpn10R5N7GcdVzkBd3Y X-Received: by 2002:a05:6a20:13d9:b0:190:e402:8bc6 with SMTP id ho25-20020a056a2013d900b00190e4028bc6mr5556752pzc.43.1702472912589; Wed, 13 Dec 2023 05:08:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702472912; cv=none; d=google.com; s=arc-20160816; b=pMoL6v/7U6d30qGE8HrgAkJ3rPM2Yz43xPgeZRvq3Eca2f6BfzR2mpEQx+IcGKHjoz JHos5rKk79+YKB1s4pYvHMWDlN2Wc+atYFfWscBRqvMnqI98tvT1cP5nTclxlUgOtwpN mc02n4HjasHCDbFkrmgJ0j+ilK1EASUVfZnQBcymzQIqj12hPEk01EK1OBsG5PkPYjgv ieeeAwBI6z3vGP/J//NF07GLogn3lnVuKkf5jRfxdhSDPuxeDqpkF1U1OsgoedX2BeWU SBU9lrry+CqphPLy8TV6WmzxDWzZGZlz2ahZqKDeoyfwgo14aviUtNjBIC4lEdYD5oOJ ZvMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=oq35m8UDN5+zPY9ewt2RtIa4c0oMjIHlIbqs8SytbI4=; fh=1qeGCfbWZV4N2xAlIkWNCbq/syzsYiOV8r94u6dtrj4=; b=zQwzq3BfqapJMWqxqmXwTJ9kgyP/QymV0NZKuNkUx2Cq6w2iSxJsDieUeovAJ8o7Y8 bQbPJadWoDLQLplF/PBv1YUvdavEDOG1PcsOP0/IXlZ4oSbJZ0qUc5644nFME8teS0wm z4VKt0B8T9TprSpNjHdKsAvHHuxO/O/ulGISh8vDpkpl2hiJWzmeCONTLjn2iTrYVHxt J+C5WGuLXcl63wQXBX8iqjm8R6+afeWXcuLHMs07jwXZdqjmpTnrZNXptyLexrpunyuD uk3iQEsRv/9DcnoFJ4ksRquRrOOa/odDTBHDplFFbjPuPu2yBuNDFReUzRl+v7sVGFtF RH1w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id bx2-20020a056a02050200b005bdfb8a9048si9969523pgb.67.2023.12.13.05.08.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 05:08:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 92AA680AD9B1; Wed, 13 Dec 2023 05:08:24 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379129AbjLMNIJ convert rfc822-to-8bit (ORCPT + 99 others); Wed, 13 Dec 2023 08:08:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379083AbjLMNII (ORCPT ); Wed, 13 Dec 2023 08:08:08 -0500 Received: from mail-oo1-f52.google.com (mail-oo1-f52.google.com [209.85.161.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55AF3B2; Wed, 13 Dec 2023 05:08:11 -0800 (PST) Received: by mail-oo1-f52.google.com with SMTP id 006d021491bc7-59158202d22so58389eaf.0; Wed, 13 Dec 2023 05:08:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702472890; x=1703077690; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dfzhlsnoq9Ysoezun43pMBPmJAkFvJFC0eB1jMYm89g=; b=LLSJ6rosSw0zGs1doQW5MzW1mS2bWTmK+S29GsQkQNM+ma2nfzKcj/UaaACJoRA5pk 4nrkPN+Xp2/NXZk4UoOcO36Eq95buwJWC6qlmI8zZSApH4ftqx2pHYkVUvCe0DF8VOVV +HOWZp7/kgunTBIntjL7Ngh7O0xPqruUx4Zjw0LojUUJTe3zsosTLdeVlDsakrmiXl2t P2Ds+qwXH816LRDucarCJyfATuYMc0EU1ovclGcAew009zUeLQdoK9i0amrbencM2pZ4 58NYDIegCsDoVw1HS5YARNE0aFYfYzc3VVj8aEtp4fVlf5qnmt7EuwZk2RR7x+Dj3VYK 2vgw== X-Gm-Message-State: AOJu0Yyaywyq6fLLDllCRHOVFiHKjkWaTU7BYP1iRlCp5n8QLmvMx+Uq E4/1SiSJ/x7w84JbFe/FICVcF5RKjPEVl6J/PxA= X-Received: by 2002:a05:6871:892:b0:203:1727:c6b with SMTP id r18-20020a056871089200b0020317270c6bmr2841209oaq.5.1702472890600; Wed, 13 Dec 2023 05:08:10 -0800 (PST) MIME-Version: 1.0 References: <20231213003614.1648343-1-imammedo@redhat.com> <20231213003614.1648343-3-imammedo@redhat.com> In-Reply-To: <20231213003614.1648343-3-imammedo@redhat.com> From: "Rafael J. Wysocki" Date: Wed, 13 Dec 2023 14:07:59 +0100 Message-ID: Subject: Re: [RFC 2/2] PCI: acpiphp: slowdown hotplug if hotplugging multiple devices at a time To: Igor Mammedov Cc: linux-kernel@vger.kernel.org, Dongli Zhang , linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, mst@redhat.com, rafael@kernel.org, lenb@kernel.org, bhelgaas@google.com, mika.westerberg@linux.intel.com, boris.ostrovsky@oracle.com, joe.jin@oracle.com, stable@vger.kernel.org, Fiona Ebner , Thomas Lamprecht Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 13 Dec 2023 05:08:24 -0800 (PST) On Wed, Dec 13, 2023 at 1:36 AM Igor Mammedov wrote: > > previous commit ("PCI: acpiphp: enable slot only if it hasn't been enabled already" > introduced a workaround to avoid a race between SCSI_SCAN_ASYNC job and > bridge reconfiguration in case of single HBA hotplug. > However in virt environment it's possible to pause machine hotplug several > HBAs and let machine run. That can hit the same race when 2nd hotplugged > HBA will start re-configuring bridge. > Do the same thing as SHPC and throttle down hotplug of 2nd and up > devices within single hotplug event. > > Signed-off-by: Igor Mammedov > --- > drivers/pci/hotplug/acpiphp_glue.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c > index 6b11609927d6..30bca2086b24 100644 > --- a/drivers/pci/hotplug/acpiphp_glue.c > +++ b/drivers/pci/hotplug/acpiphp_glue.c > @@ -37,6 +37,7 @@ > #include > #include > #include > +#include > > #include "../pci.h" > #include "acpiphp.h" > @@ -700,6 +701,7 @@ static void trim_stale_devices(struct pci_dev *dev) > static void acpiphp_check_bridge(struct acpiphp_bridge *bridge) > { > struct acpiphp_slot *slot; > + int nr_hp_slots = 0; > > /* Bail out if the bridge is going away. */ > if (bridge->is_going_away) > @@ -723,6 +725,10 @@ static void acpiphp_check_bridge(struct acpiphp_bridge *bridge) > > /* configure all functions */ > if (slot->flags != SLOT_ENABLED) { > + if (nr_hp_slots) > + msleep(1000); Why is 1000 considered the most suitable number here? Any chance to define a symbol for it? And won't this affect the cases when the race in question is not a concern? Also, adding arbitrary timeouts is not the most robust way of addressing race conditions IMV. Wouldn't it be better to add some proper synchronization between the pieces of code that can race with each other? > + > + ++nr_hp_slots; > enable_slot(slot, true); > } > } else { > --