Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp936725pxf; Wed, 7 Apr 2021 15:31:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlBdwYpfUq6hyMsSDawb0lKIobWsjco6yQXAYLuWYzCEC0nWS92dvyNllfYDZfq9lVsjRy X-Received: by 2002:a05:6a00:78c:b029:1f5:d587:1701 with SMTP id g12-20020a056a00078cb02901f5d5871701mr4808598pfu.59.1617834676939; Wed, 07 Apr 2021 15:31:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617834676; cv=none; d=google.com; s=arc-20160816; b=OVfYYf4BaHxBDk9nIzJiMgA31MJmxPMvZnta/3q4yz+n5WiQdgVA4maf/HD54oy2+c M3Uysi1rzygslrIezgkGkcQ8JPbx8eAEaFXSlZGJkncJmJxShwnQf9fnZ4FXvqdw4moj KMYQ4hlRI71vq0Te2LjX/n5msuMBWYPMDhzSD5qvlgQ/Stoxer/Pjbjm8/w4fRzbvsDQ M+K7bmAnC6Q1RZO0xphadUd5fC+0ja9z7MaG8Y25NXRqvOoy5taZmG95uTTS8DPXo37X EP/bcvvokYRsZAcfp2NZuvREB0o8IS8ceZPTS/WBW9Fqc3GZ6Mi//pR1QLgnlwfhDV8w HIUg== 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=kV++7Kd/m1qEMs/QW5Ab8K+zdJQGM9oIiL22VIftIws=; b=inUfrCfWGsfetncPQ3v3oMGZmBPvkGE7dEGJuE7HEHZW/UwcU29xtZ2jkZRjQbbSgz gyG/3+BFKlw4e3+3JlChTg8aG0RsAi6yh8cHpEEUAx4d6Gpcojju/E9xJtST0iVvibQn L623/9G9MjN7i0Bj6ex3a7k2cpJfGZ08fzREfNE2+hAWYzukH1xdLOyLi0vhUU8Kpsak uiFmkhJX4AtukQE9dSMb/17GD57D3wc5Z1O4r8ktieRfs/1DPGZInfe/Gpu8icWOE3NY hV2DaFmc7elR9Go5VxorC5DT1IQYLwyi3MruA+mo8wq0kiaJi8QVdD9YfZ9XcE44IzGF Qq3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eprpbL5z; 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 p69si24788367pgp.313.2021.04.07.15.31.03; Wed, 07 Apr 2021 15:31:16 -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=eprpbL5z; 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 S1346579AbhDGHYH (ORCPT + 99 others); Wed, 7 Apr 2021 03:24:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:60056 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346594AbhDGHYF (ORCPT ); Wed, 7 Apr 2021 03:24:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 16F0B61369; Wed, 7 Apr 2021 07:23:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617780233; bh=zr0/pQRi0wQf+wUkOOWdNkfJEyHnsU7Lgu1Fb25P4g4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=eprpbL5zs1HVNKL4QAMx1V8pCWNK2yOixiXFcTgWWczy1uRJDSPeKZSIDvp4kGp+o MaTcv9Ohvmr/Lpa1veYoWs1MKfe3/t0ZlbM7J6z3EZjjGgrui/mlTCRyAd6iRxKYFN TKQt53dkTSvLePbRf5jWvLHzAdzu6JdRI+D2WcjYU1SGwemitMXUW4I8eHz3/121o8 yYvLvC/GuAuEZGL45JyE6ZeuLQv+2UOMypPUTYxa1SQcRsJ6d1IFe/EyeQgA3jNVX+ tDdNfyW7sryc80lQSw1t4ESgbG+tPZG9T417r1ZgPQFugKoT3/zeU0mgCw9cJSGeax JTEIUNI6+Tlzg== Date: Wed, 7 Apr 2021 10:23:49 +0300 From: Leon Romanovsky To: Alex Williamson Cc: Raphael Norwitz , "bhelgaas@google.com" , "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "ameynarkhede03@gmail.com" Subject: Re: [PATCH] PCI: merge slot and bus reset implementations Message-ID: References: <20210401053656.16065-1-raphael.norwitz@nutanix.com> <20210401105616.71156d08@omen> <20210406081626.31f19c0f@x1.home.shazbot.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210406081626.31f19c0f@x1.home.shazbot.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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