From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE2F0C43460 for ; Wed, 7 Apr 2021 13:44:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A837161353 for ; Wed, 7 Apr 2021 13:44:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236546AbhDGNo4 (ORCPT ); Wed, 7 Apr 2021 09:44:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233321AbhDGNoy (ORCPT ); Wed, 7 Apr 2021 09:44:54 -0400 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0859BC061756; Wed, 7 Apr 2021 06:44:44 -0700 (PDT) Received: by mail-pg1-x534.google.com with SMTP id p12so9092617pgj.10; Wed, 07 Apr 2021 06:44:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=yvoTrhwWmXyM0wgHP8pY/H3NzCMF21CuCGmfBMdW+Vs=; b=DoKAZLxODOMVxOKmpKVH+qV6lHmQ9tHVmr6Z/OdhuA3EHOK4iTP/OpoG/KhjduHuET RMB5XGOCZzKBofrSD0EfLhyA3C6Sd87ftvlOWlS1KiJxCQQEHyHjae/nGhQ6TRZYq+uk yOKjdaQpPQZe7+V5NrMtri+Wed+IRpTbJ4jr8ipBGKZPol7ctA/EQp9cLbL6/QEp0q2Z Z6XzZhQyoAcqdvijFEdm78ptP8OWvPHCTgwR44bwaJR826quPjMH3lshrcAssPz+UmCF zNhhroAlF+7bCUjedb447o3Cuhf5gIe01iffw5SVEQFWb+JJOIqLgaVeg4kqE3QCo7DB e7mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=yvoTrhwWmXyM0wgHP8pY/H3NzCMF21CuCGmfBMdW+Vs=; b=Bs1HrocFpfvz0f6P91b6fDHx9wQfaLjzaPyCbzko48xMAJbcJc6ILH6h7O0eMLuQOS QK7e4vDDlm81/oShZR7ez+Jfl6PyZJcGkQcgEjT/HashhspiMRSrlOdeqJEZkJTN4rB6 o5tQ3cQ9Vn0iWZl/N+lTCKrX6Mmap4p898nR9aijlyutWGM3iYAnVa9lVi6urFJliC+T EL/bN2vGVh9X/iNxs+FAhxvCw70tvg51reOTZ5Fn7RLRvEeFXeFsNOpP0h84Eeys4kYW BtwJ3cyd5s/q7933zeTg9IkRBiN5Wj+D38LYpi5qckLmGMq7mXUWyRrLQ5tOl/naODCy QigQ== X-Gm-Message-State: AOAM5305BFToT49CSP4Q//EvsOthpynvBbe8fAnHjZsFSC8AJGSgAnFl iHZqty0hgZlOwGBFpXR6llc= X-Google-Smtp-Source: ABdhPJzRyVqodpiDGZq1wRg0jF6R5KocBXyhlIs+hVvasRMzKMsXIekD1S9q/Z3qKsZhIAOPWkeGqw== X-Received: by 2002:a63:ab05:: with SMTP id p5mr3379513pgf.149.1617803083467; Wed, 07 Apr 2021 06:44:43 -0700 (PDT) Received: from localhost ([103.77.152.190]) by smtp.gmail.com with ESMTPSA id b1sm6304272pgf.84.2021.04.07.06.44.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Apr 2021 06:44:43 -0700 (PDT) Date: Wed, 7 Apr 2021 19:13:43 +0530 From: "ameynarkhede03@gmail.com" To: Leon Romanovsky Cc: Raphael Norwitz , alex.williamson@redhat.com, bhelgaas@google.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] PCI: merge slot and bus reset implementations Message-ID: <20210407134343.6u2vbxavhes32zwj@archlinux> References: <20210401053656.16065-1-raphael.norwitz@nutanix.com> <20210401105616.71156d08@omen> <20210406081626.31f19c0f@x1.home.shazbot.org> <20210407082356.53subv4np2fx777x@archlinux> <20210407130601.aleyww5d5mttitry@archlinux> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 21/04/07 04:37PM, Leon Romanovsky wrote: > On Wed, Apr 07, 2021 at 06:36:01PM +0530, ameynarkhede03@gmail.com wrote: > > On 21/04/07 03:30PM, Leon Romanovsky wrote: > > > On Wed, Apr 07, 2021 at 01:53:56PM +0530, ameynarkhede03@gmail.com wrote: > > > > On 21/04/07 10:23AM, Leon Romanovsky wrote: > > > > > On Tue, Apr 06, 2021 at 08:16:26AM -0600, Alex Williamson wrote: > > > > > > On Sun, 4 Apr 2021 11:04:32 +0300 > > > > > > Leon Romanovsky wrote: > > > > > > > > > > > > > On Thu, Apr 01, 2021 at 10:56:16AM -0600, Alex Williamson wrote: > > > > > > > > On Thu, 1 Apr 2021 15:27:37 +0300 > > > > > > > > Leon Romanovsky wrote: > > > > > > > > > > > > > > > > > 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); > > > > > > > > > > > > > > > > > > > > > > > > That'd be news to me, do you have a reference? I've never seen > > > > > > > > complaints for ternaries previously. Thanks, > > > > > > > > > > > > > > The complaint is not to ternaries, but to the function call as one of > > > > > > > the parameters, that makes it harder to read. > > > > > > > > > > > > Sorry, I don't find a function call as a parameter to a ternary to be > > > > > > extraordinary, nor do I find it to be a discouraged usage model within > > > > > > the kernel. This seems like a pretty low bar for hard to read code. > > > > > > > > > > It is up to us where this bar is set. > > > > > > > > > > Thanks > > > > On the side note there are plenty of places where this pattern is used > > > > though > > > > for example - > > > > kernel/time/clockevents.c:328: > > > > return force ? clockevents_program_min_delta(dev) : -ETIME; > > > > > > > > kernel/trace/trace_kprobe.c:233: > > > > return tk ? within_error_injection_list(trace_kprobe_address(tk)) : > > > > false; > > > > > > > > kernel/signal.c:3104: > > > > return oset ? put_compat_sigset(oset, &old_set, sizeof(*oset)) : 0; > > > > etc > > > > > > Did you look when they were introduced? > > > > > > Thanks > > > > > that code trace_kprobe in 2 years old. > > If you want more recent example checkout > > drivers/pci/controller/pcie-brcmstb.c:1112,1117: > > return pcie->rescal ? brcm_phy_cntl(pcie, 1) : 0; > > which was introduced 7 months ago. > > There are lot of examples in pci.c also. > > Yeah, I know, copy-paste is a powerful tool. > > Can we please progress with this patch instead of doing > archaeological research? > > Thanks > Sorry I didn't understand what you said. Thanks, Amey