Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp880245pxf; Wed, 7 Apr 2021 14:01:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxynCuThCokO+em3BhcxefUlHMkfgxt5cYOQ+yUeD0iXtakrBnNWahwmn2mwdpU71T6PFXo X-Received: by 2002:a17:906:23e9:: with SMTP id j9mr5879967ejg.78.1617829301064; Wed, 07 Apr 2021 14:01:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617829301; cv=none; d=google.com; s=arc-20160816; b=g/o2H43MNA7uahmcy8B3RrD1JugPSTle+a0EXPfboY/WH7Jx6awPAyd2BuwYWUXOqX /9b9reI+mnbN7HJxSqx39xk+fghm2zNgaOck+wJloa/s5KSAbMdITCruVjFrGdcHy4iS mjSNkxrf79iWx3iOQ7jS2CvdcG+DW5JkLHsFpcHV3Ra2PNNshDWuAhTm9l0ZlRk84ZlL pCVPdefWhO0QX/RcnQf5tLgZ5rbrmYyF3x2GQQVXmPRt6td7hLMQ4o1XqUMBX6pJiZNq 9H/zSRAWZKVXPRnf9RstndpdlYAR/+2WoD0uDJCjW3crR6Rpj1WJx2Y4c84v7BB3phTD UZsA== 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=w6x1JaJJswXDRLPdzMKjakBv3oDpC21g21byrf7hBec=; b=XAIB3kJnR4u0qhzRLGwGquoAzbcuxVkb+Xo4okZ5tc4g/EvEV9+wps+KnBNIR7iTTK IYYwLF73h6B3w0jyJw6VyIjHqjijT9ayvU5Qod3q+JnSu+A85WNMqbc8adWSpNLQ0BqQ yCjX/9KYxkKYSpu9dmZxZo/2KYbnoy7K4nJAmyFiC7fBPIpj/pUcq1FtC4gcdysSxs4G tgvyByj7KDDfZkkRtDQM3dSQNQHACu1Xh22QmkjTm2MOuMx8VY7FkmfYIL2hQhJefleU tpEzRoqCEedn2cwCNAVLzjn/rvUbaNkeA7Vr2fFW/J5HIouTBrZ3O0dMLPt8m908Hlhy 8G3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ejHnGwmu; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bg8si15378492ejb.592.2021.04.07.14.01.17; Wed, 07 Apr 2021 14:01:41 -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=@gmail.com header.s=20161025 header.b=ejHnGwmu; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234292AbhDGNHO (ORCPT + 99 others); Wed, 7 Apr 2021 09:07:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233590AbhDGNHN (ORCPT ); Wed, 7 Apr 2021 09:07:13 -0400 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 397AAC061756; Wed, 7 Apr 2021 06:07:02 -0700 (PDT) Received: by mail-pg1-x529.google.com with SMTP id d10so8168599pgf.12; Wed, 07 Apr 2021 06:07:02 -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=w6x1JaJJswXDRLPdzMKjakBv3oDpC21g21byrf7hBec=; b=ejHnGwmupOSP6O3pYirdbklm+kJ+2OA2Egwj3xANUZxTm1vqLVNshLMu1RlNYmHBFy xVwiLY1c1OdGP/FFgQAasjJcRIstI/EPpKavIu8JbDmFHeYqknI6oKurz3I3Nno7Ek0T t6l3NFRDJ3Z23r1O4T+vg3sESwkoo4+s3vxhtcj+1vYRxzk/Oxgimy6XsiDAOLNVvLNG QBKXmzlymUVyWyiem+0SQHol1y2K4r5r4BShlFriFkkFspvRXyoPm6prLvKj+UlTqP+8 /A6w20lT96pROzb4Y24YXF/EKlFsVNuta8PulBFGs21PhLj068UGMrNTcjN66+Z8G2lu 9IiA== 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=w6x1JaJJswXDRLPdzMKjakBv3oDpC21g21byrf7hBec=; b=taflkDctOx44CjnupUIPsPZ7cgqLp27TeBtwyAXJinV1BvQZPxQKHvCtAzyyt3jjAG X+93tNRQWGvX7EB9nEY/qkIfzcJeCoXq+zzPpyShHL0MHBvoKsuSjPcdnsPuRiEmhKWm 9hGBqFvpLJMAjlzF97PVEppDVfOnZuRbsUL9ADCLcpZ8ZTMV1Ix7bYttGf+Uk/5yFWKv gZJenHyxEFBEhtgbQnfia4DfWBjqaNZUCK5aJV//fIg33smqIK/jhoWp5Qaa4+80klRw iFh2yBdTB1gi5RhHfkQ+Xdt8XxPV9kILVu+fjpbFFwvxSOkntJAyb+6Wld1FD1DByvj2 cr1Q== X-Gm-Message-State: AOAM533GZ7rnAii7dTt0LuH+NOjqu8+h4uWCv4QjT1PLXiVdRNNAvM6Q TdvJV1S7n3woTAt+3j+h94s= X-Received: by 2002:aa7:9a89:0:b029:200:1eed:1388 with SMTP id w9-20020aa79a890000b02902001eed1388mr2876710pfi.79.1617800821618; Wed, 07 Apr 2021 06:07:01 -0700 (PDT) Received: from localhost ([103.77.152.190]) by smtp.gmail.com with ESMTPSA id w16sm2095444pfn.200.2021.04.07.06.07.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Apr 2021 06:07:01 -0700 (PDT) Date: Wed, 7 Apr 2021 18:36:01 +0530 From: "ameynarkhede03@gmail.com" To: Leon Romanovsky Cc: Raphael Norwitz , AlexWilliamson@archlinux, 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: <20210407130601.aleyww5d5mttitry@archlinux> References: <20210401053656.16065-1-raphael.norwitz@nutanix.com> <20210401105616.71156d08@omen> <20210406081626.31f19c0f@x1.home.shazbot.org> <20210407082356.53subv4np2fx777x@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 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. Thanks, Amey