Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1031454iob; Fri, 13 May 2022 20:20:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfBdDxWFEfgnMuowsBFhWFdkPOYKJNG6n1yyROGFD2vNKdyz82l8kdlLNdo0aNfo4/7uI0 X-Received: by 2002:a5d:5547:0:b0:20c:7a44:d8e7 with SMTP id g7-20020a5d5547000000b0020c7a44d8e7mr6227903wrw.349.1652498418964; Fri, 13 May 2022 20:20:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652498418; cv=none; d=google.com; s=arc-20160816; b=n7uTBofhVj0MJIxgJ+x9ncYWawcMUH39cmqfs3bAR0HeVDbu+Ccuv97rrEj1rQ+ACQ NSfbueoFiEbUokBdkGHgp1KxCLnsxSo5Db0jKUXl/Y0HXSC86WTUyt3qAYNO55qYO4G5 fxZKsN6pPXry1gp3K3sUbVgkE3sP61Z74xkw4mH5EXBc7ikGe7ymAfEBgiRlCw2UZ2NJ 5TrLDf1fuUaop73e1WzXQ69PHKyovErrW9+01hME8IRrZuXN1rjSP1nHuqP4b1ftdq4d S6NSl7Q+iQ91SMkVtFy1ULn1q5X+ToUZnerWTGc9wKSUAFIcgqVvySGig9/rA2RLE1eH N0Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature; bh=s0WN2+DMgoJiF82+YJyYinfUJAknvVrSPwJB+rRF9gQ=; b=NcPX3xGSpl8EVLB40k7IyhQZFpF5GoMqENuZLPbuxBIgEkeTs7eUXKdecN5UxrHeEF cAHpon9VhlTOkB7WSAzmi248ky4bupuY5gYqxTVp5KFwRuSUegDYWQQmdE/Q4PwIw7R4 OKQv2LVAxMi+RJ+w2+UxcIzIbCMOJz4OKFX3KurTrusCaotP62Q53zAzCHWp1IeALiKA l1FWTi0CzGbvcMUluPNslbxkgE73UCElFmHHoTwBif017IhVQZXl8axxp0Sa2fWU3wXm Hy6gQrow3huAoIvsnxuHolsAFpq9eXY0sMSD2taGUkZIh7Hxee0vh/ixUn80qGtcf6tu u21Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=NaAVK5d3; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id h11-20020a05600016cb00b0020cffb3e5c6si22163wrf.616.2022.05.13.20.20.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 20:20:18 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=NaAVK5d3; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 799BA3F4FA7; Fri, 13 May 2022 16:58:11 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381396AbiEMOsS (ORCPT + 99 others); Fri, 13 May 2022 10:48:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381469AbiEMOsP (ORCPT ); Fri, 13 May 2022 10:48:15 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8AA937A89; Fri, 13 May 2022 07:48:11 -0700 (PDT) Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24DEgBoh005087; Fri, 13 May 2022 14:48:06 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : subject : from : to : cc : date : in-reply-to : references : content-type : mime-version : content-transfer-encoding; s=pp1; bh=s0WN2+DMgoJiF82+YJyYinfUJAknvVrSPwJB+rRF9gQ=; b=NaAVK5d3kh+qI2QaPxZIOumP4yRyhotiYkUL+ZvN/2Mb+vkB3yFZMjCBsJ/o5/1QUl3O qBuniOO5j/JUZm93E6UBMJKqJInnUXusv+6oHn8ps/JQnJy8J0WHFQLhbnFSPJgGknBn XDfrlc0H95gSIYedaVd5J/xeXccn9SrsVwKbZe2QAiTmT+cCzyDOKc5y/nJ95S4uNIu7 tR7UkCo30QQofjT/i/klMD061X35ctogoR5+jRTYUv0/XQ+VYqXlvdsworvmohVw/bVw q/PmsStj2yCN3Sr4aiFl0+673qK7r/XL0xyjtKTtluPpIIjWHzNnLh/7G7oTOCoW5Pqa sw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3g1sasg4yr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 13 May 2022 14:48:06 +0000 Received: from m0098393.ppops.net (m0098393.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 24DEhCti007397; Fri, 13 May 2022 14:48:05 GMT Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3g1sasg4xr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 13 May 2022 14:48:05 +0000 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 24DEhDPR029087; Fri, 13 May 2022 14:48:03 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma02fra.de.ibm.com with ESMTP id 3fwgd8xw6b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 13 May 2022 14:48:03 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 24DElaBA22872536 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 13 May 2022 14:47:36 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E14A611C04A; Fri, 13 May 2022 14:47:59 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6391A11C04C; Fri, 13 May 2022 14:47:59 +0000 (GMT) Received: from sig-9-145-187-37.de.ibm.com (unknown [9.145.187.37]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 13 May 2022 14:47:59 +0000 (GMT) Message-ID: Subject: Re: [PATCH RESEND v5 1/4] PCI: Clean up pci_scan_slot() From: Niklas Schnelle To: Bjorn Helgaas Cc: Bjorn Helgaas , Jan Kiszka , Matthew Rosato , Pierre Morel , linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-s390@vger.kernel.org, linux-pci@vger.kernel.org Date: Fri, 13 May 2022 16:47:59 +0200 In-Reply-To: <20220513140723.GA947754@bhelgaas> References: <20220513140723.GA947754@bhelgaas> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 (3.28.5-18.el8) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: t1w7uGj-nGGZKoUEgGqr151EM79LEoyh X-Proofpoint-GUID: wP6AhWUfDf8XmTpqUNVK3Nxwg3MHzNzd X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-13_04,2022-05-13_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 impostorscore=0 phishscore=0 mlxscore=0 suspectscore=0 malwarescore=0 mlxlogscore=584 spamscore=0 adultscore=0 priorityscore=1501 bulkscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205130064 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2022-05-13 at 09:07 -0500, Bjorn Helgaas wrote: > On Thu, May 12, 2022 at 04:56:42PM +0200, Niklas Schnelle wrote: > > On Thu, 2022-05-05 at 10:38 +0200, Niklas Schnelle wrote: > > > While determining the next PCI function is factored out of > > > pci_scan_slot() into next_fn() the former still handles the first > > > function as a special case. This duplicates the code from the scan loop. > > > > > > Furthermore the non ARI branch of next_fn() is generally hard to > > > understand and especially the check for multifunction devices is hidden > > > in the handling of NULL devices for non-contiguous multifunction. It > > > also signals that no further functions need to be scanned by returning > > > 0 via wraparound and this is a valid function number. > > > > > > Improve upon this by transforming the conditions in next_fn() to be > > > easier to understand. > > > > > > By changing next_fn() to return -ENODEV instead of 0 when there is no > > > next function we can then handle the initial function inside the loop > > > and deduplicate the shared handling. This also makes it more explicit > > > that only function 0 must exist. > > > > > > No functional change is intended. > > > > > > Cc: Jan Kiszka > > > Signed-off-by: Niklas Schnelle > > > --- > > > > Friendly ping :-) > > Thanks and sorry for the delay. I'm off today for my daughter's > wedding reception but will get back to it next week. No worries, have a great day and congratulations! > Just to expose > some of my thought process (and not to request more work from you!) > I've been wondering whether b1bd58e448f2 ("PCI: Consolidate > "next-function" functions") is really causing us more trouble than > it's worth. In some ways that makes the single next-function harder > to read. But I guess the hypervisor special case is not exactly a > "next-function" thing -- it's a "keep scanning even if there's no fn > 0" thing. > > Bjorn Yeah I do see your point. Let's discuss next week.