Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp727202pxf; Thu, 1 Apr 2021 11:57:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMFqIUjmnUWq7xd7HuhGPNsIUW4l0a2BfDd2VJCLl7eRYOznhJ8E2AG+NpXUnwKBu0uV2C X-Received: by 2002:a17:907:7651:: with SMTP id kj17mr10626668ejc.127.1617303430140; Thu, 01 Apr 2021 11:57:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617303430; cv=none; d=google.com; s=arc-20160816; b=LN0mtO7B1KCJDLC6jSKuFFTe+bCRnzOctTenHfp8hxx650SRyC/YF8/Cra8DF4ttJ2 xR1MNmX8Xu48UX01wW7eS0c+EDUfqUeXzPvO692hc+ry7VeXHzP7ts1BLE0prbx5sEEb Mfe4wPrUgXKQIXlEKqnpHHyuYkc3WbfpibBL8r9t2SqqDC3UIB0SqErG298MLLdTdJw9 bTtlW9WXGCHwzf508IueygJaUA88ejXshf4VkZZ/3rfDtN+M/LBbfQ5f6a6k83enTKj1 wxB9aM1JJRMXcBn0drWIY5u8rXVLrPiFEyacyLEViPpCGYhhVD15jdSht3TcwFpE//MA WZbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=YBj7Sd8W3vREp/pasV5nsO4TSXqnKc5iAkPsK7dZg2E=; b=ClhGqhH1jYuWS7P5m6S6jLds+ST1NrPOB8+fWsq7EufQh+5OT1NSGH3qPWBPKU9Nd/ FXM1fLPDKXXIvOLv7XchqQoZn5nRBJE8qqlpb+t59SayJmcJRTHGAf/FFievvPW9qt4X a+ocZmdvWZtLciIYiV5zahAKRvy3UOzf3+cXnTRURUqjsfMSohdiKlUildD81T+cZRP9 cUVBwtdkT9ITw0LkOs9sl8PpQKkoJkH89vihC13jdricxeYoB8gkILlKAWrcM9O75ncU B1IxSzmjndR1M2c9mspdSDXox5c7K087FP0wl8P2GTkWiSqf5s9g5r+8uqnH2AZakH/+ eclQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IKEIEtKN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i13si4724084edq.522.2021.04.01.11.56.45; Thu, 01 Apr 2021 11:57:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IKEIEtKN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239027AbhDASyS (ORCPT + 99 others); Thu, 1 Apr 2021 14:54:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:38154 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238558AbhDASo7 (ORCPT ); Thu, 1 Apr 2021 14:44:59 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 769D66112D; Thu, 1 Apr 2021 12:27:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617280061; bh=6hbeoJ4IU0VAYkOxOutAUGEasgxae6JptOzfhG1Kkfc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=IKEIEtKNXNCtYYmT5WvsSYESDz2+fglABxfVImzWJebuOYggWp+qEKUuAmnddpoxN CFqyOL18PjAK9dpeO7E8cAIVdZ+IJAHRlguVex37xyKPUy2hVzlAhlZf7MEznyHHat Iz0ZwzkKf7A6GQCjN4B+jA4DOO93J00hO8M5C1FCS+TJJ3J1JPVw1mxiOx9Gmko9Rm O2BZaVrujhcTB3Eqi5BnyymxM6xT0rxZRU5weGSr9end4PIMoT5PY45cblzSgICzpy ZQLD0EGUcnn0ZaCH5Uw5TbRzK/zU0peIX8X9WxZ7Lm/8JTY72iHpcccyx5+//3hAUI RFIqe9HkabqEQ== Date: Thu, 1 Apr 2021 15:27:37 +0300 From: Leon Romanovsky To: Raphael Norwitz Cc: "bhelgaas@google.com" , "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "alex.williamson@redhat.com" , "ameynarkhede03@gmail.com" Subject: Re: [PATCH] PCI: merge slot and bus reset implementations Message-ID: References: <20210401053656.16065-1-raphael.norwitz@nutanix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210401053656.16065-1-raphael.norwitz@nutanix.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 01, 2021 at 05:37:16AM +0000, Raphael Norwitz wrote: > Slot resets are bus resets with additional logic to prevent a device > from being removed during the reset. Currently slot and bus resets have > separate implementations in pci.c, complicating higher level logic. As > discussed on the mailing list, they should be combined into a generic > function which performs an SBR. This change adds a function, > pci_reset_bus_function(), which first attempts a slot reset and then > attempts a bus reset if -ENOTTY is returned, such that there is now a > single device agnostic function to perform an SBR. > > This new function is also needed to add SBR reset quirks and therefore > is exposed in pci.h. > > Link: https://lkml.org/lkml/2021/3/23/911 > > Suggested-by: Alex Williamson > Signed-off-by: Amey Narkhede > Signed-off-by: Raphael Norwitz > --- > drivers/pci/pci.c | 17 +++++++++-------- > include/linux/pci.h | 1 + > 2 files changed, 10 insertions(+), 8 deletions(-) > > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c > index 16a17215f633..12a91af2ade4 100644 > --- a/drivers/pci/pci.c > +++ b/drivers/pci/pci.c > @@ -4982,6 +4982,13 @@ static int pci_dev_reset_slot_function(struct pci_dev *dev, int probe) > return pci_reset_hotplug_slot(dev->slot->hotplug, probe); > } > > +int pci_reset_bus_function(struct pci_dev *dev, int probe) > +{ > + int rc = pci_dev_reset_slot_function(dev, probe); > + > + return (rc == -ENOTTY) ? pci_parent_bus_reset(dev, probe) : rc; The previous coding style is preferable one in the Linux kernel. int rc = pci_dev_reset_slot_function(dev, probe); if (rc != -ENOTTY) return rc; return pci_parent_bus_reset(dev, probe); > +} > + > static void pci_dev_lock(struct pci_dev *dev) > { > pci_cfg_access_lock(dev); > @@ -5102,10 +5109,7 @@ int __pci_reset_function_locked(struct pci_dev *dev) > rc = pci_pm_reset(dev, 0); > if (rc != -ENOTTY) > return rc; > - rc = pci_dev_reset_slot_function(dev, 0); > - if (rc != -ENOTTY) > - return rc; > - return pci_parent_bus_reset(dev, 0); > + return pci_reset_bus_function(dev, 0); > } > EXPORT_SYMBOL_GPL(__pci_reset_function_locked); > > @@ -5135,13 +5139,10 @@ int pci_probe_reset_function(struct pci_dev *dev) > if (rc != -ENOTTY) > return rc; > rc = pci_pm_reset(dev, 1); > - if (rc != -ENOTTY) > - return rc; > - rc = pci_dev_reset_slot_function(dev, 1); > if (rc != -ENOTTY) > return rc; > > - return pci_parent_bus_reset(dev, 1); > + return pci_reset_bus_function(dev, 1); > } > > /** > diff --git a/include/linux/pci.h b/include/linux/pci.h > index 86c799c97b77..979d54335ac1 100644 > --- a/include/linux/pci.h > +++ b/include/linux/pci.h > @@ -1228,6 +1228,7 @@ int pci_probe_reset_bus(struct pci_bus *bus); > int pci_reset_bus(struct pci_dev *dev); > void pci_reset_secondary_bus(struct pci_dev *dev); > void pcibios_reset_secondary_bus(struct pci_dev *dev); > +int pci_reset_bus_function(struct pci_dev *dev, int probe); > void pci_update_resource(struct pci_dev *dev, int resno); > int __must_check pci_assign_resource(struct pci_dev *dev, int i); > int __must_check pci_reassign_resource(struct pci_dev *dev, int i, resource_size_t add_size, resource_size_t align); > -- > 2.20.1