rsion: vendor=baseguard
 engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.80.40
 definitions=2025-10-22_04,2025-10-13_01,2025-03-28_01
X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0
 impostorscore=0 adultscore=0 priorityscore=1501 spamscore=0 phishscore=0
 clxscore=1011 bulkscore=0 malwarescore=0 lowpriorityscore=0 suspectscore=0
 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0
 reason=mlx scancount=1 engine=8.19.0-2510020000 definitions=main-2510180022
X-DKIM: signer='ibm.com' status='pass' reason=''
DKIMCheck: Server passes DKIM test, 0 Spam score
X-Spam-Score: 0.5 (/)
X-Spam-Report: Spam detection software, running on the system "witcher.mxrouting.net", has
 performed the tests listed below against this email.
 Information: https://mxroutedocs.com/directadmin/spamfilters/
 ---
 Content analysis details:   (0.5 points)
 ---
  pts rule name              description
 ---- ---------------------- -----------------------------------------
  1.5 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level
                             mail domains are different
  0.0 RCVD_IN_DNSWL_BLOCKED  RBL: ADMINISTRATOR NOTICE: The query to
                             DNSWL was blocked.  See
                             http://wiki.apache.org/spamassassin/DnsBlocklists#DnsBlocklists-dnsbl-block
                              for more information.
                             [147.75.80.249 listed in list.dnswl.org]
  0.1 DKIM_SIGNED            Message has a DKIM or DK signature, not necessarily
                             valid
 -0.1 DKIM_VALID             Message has at least one valid DKIM or DK signature
 -1.0 MAILING_LIST_MULTI     Multiple indicators imply a widely-seen list
                             manager
SpamTally: Final spam score: 5

Hi Huacai, Hi Jan, Hi Bjorn,

I noticed that with commit a02fd05661d7 ("PCI: Extend isolated function
probing to LoongArch") LoongArch now also makes use of the isolated
function probing. First, nice to see this sees more users and that the
interface is useful to you.=C2=A0

Seeing this, I was reminded of an issue I ran into when using this
mechanism with SR-IOV capable devices. In that case VFs with devfn > 7
and PCI_SLOT(devfn) !=3D 0 wouldn't get probed.
This is because if a device is found next_fn() will check whether dev-
>multifunction is set. So if for example devfn =3D=3D 8 is found (fn =3D=3D=
 0)
dev->multifunction won't be set in pci_scan_slot() and for VFs it's
also not set via PCI_HEADER_TYPE_MFD. So we won't check for devfn =3D=3D 9
even though that could very well be there.

Now for s390 this currently doesn't cause issues because for all
multifunction devices we have, we either get a VF alone and then since
commit 25f39d3dcb48 ("s390/pci: Ignore RID for isolated VFs") use devfn
=3D=3D 0, or we have the parent PF passed-through and then VFs always get
hot plugged after SR-IOV enable, which then uses
pci_scan_single_device(). And for non VFs we always have devfn =3D=3D 0
and/or devfn =3D=3D 1 and multifunction via the header. So in a sense the
above commit works around the issue, though that wasn't its primary
intention.

Did either of you also run into this issue or can reproduce it?

Somewhat related, if ARI is enabled this would also break the isolated
function case including on s390 where ARI is used by the platform
firmware, but detected as off by Linux because there is no struct
pci_dev associated with the PCI bus. If I patch Linux to correctly
detect ARI, it no longer finds an isolated PF with devfn =3D=3D 1.

Thanks,
Niklas Schnelle


From - Wed Oct 22 13:31:20 2025
X-Mozilla-Status: 0001
X-Mozilla-Status2: 00000000
Return-Path: <arch-general-bounces@lists.archlinux.org>
Delivered-To: hi@josie.lol
Received: from witcher.mxrouting.net
	by witcher.mxrouting.net with LMTP
	id sLERGSjT+GisigAAYBR5ng
	(envelope-from <arch-general-bounces@lists.archlinux.org>)
	for <hi@josie.lol>; Wed, 22 Oct 2025 12:50:48 +0000
Return-path: <arch-gDhWWXs9G3gXEggM0A8=
ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1761134032; c=relaxed/simple;
	bh=pwQk5zAt/ju7QPDJfmEeV5nnlUGY2G1Vk6+0+y39tYM=;
	h=From:To:Cc:Subject:Date:Message-Id; b=mPa8yxzUlDPbFltS3iSDikCJDaeR7WGUlUInXCN3Kt86kUTO0ctCPNzwR0mgyWMz5GHgWYATRzrpyd+TAQLqOycnVRz6w/txTQFrr/LWskVnJ8xf3uB2WT6E9vF6ouTXkarPQ69IxkA5dIQ8Fvj+CjaMqVbG1EYsN9L9oCw+k2A=
ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn; spf=pass smtp.mailfrom=iscas.ac.cn; arc=none smtp.client-ip=159.226.251.21
Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn
Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iscas.ac.cn
Received: from localhost.localdomain (unknown [202.112.113.212])
	by APP-01 (Coremail) with SMTP id qwCowACnAaS3xfho7Kr3Ew--.6894S2;
	Wed, 22 Oct 2025 19:53:35 +0800 (CST)
From: Ma Ke <make24@iscas.ac.cn>
To: will@kernel.org,
	mark.rutland@arm.com,
	robin.murphy@arm.com,
	james.clark@linaro.org,
	ilkka@os.amperecomputing.com,
	make24@iscas.ac.cn,
	u.kleine-koenig@baylibre.com,
	bwicaksono@nvidia.com,
	suzuki.poulose@arm.com
Cc: linux-arm-kernel@lists.infradead.org,
	linux-perf-users@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	akpm@linux-foundation.org,
	stable@vger.kernel.org
Subject: [PATCH RESEND] perf: arm_cspmu: fix error handling in arm_cspmu_impl_unregister()
Date: Wed, 22 Oct 2025 19:53:25 +0800
Message-Id: <20251022115325.25900-1-make24@iscas.ac.cn>
X-Mailer: git-send-email 2.17.1
X-CM-TRANSID:qwCowACnAaS3xfho7Kr3Ew--.6894S2
X-Coremail-Antispam: 1UD129KBjvJXoW7ZF1DtrWrtF1DCry5Xr43KFg_yoW8GryUpF
	47CFW5ZFyvgr4UK39rA3yUZFWUCa1YkwnYkry8G34F9Fn3Zry3t348Kr9ag3W8JFZ8Jayj
	q34aqrn5G3W5t3DanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2
	9KBjDU0xBIdaVrnRJUUUPj14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0
	rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02
	1l84ACjcxK6xIIjxv20xvE14v26r1j6r1xM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j
	6F4UM28EF7xvwVC2z280aVAFwI0_Cr1j6rxdM28EF7xvwVC2z280aVCY1x0267AKxVW0oV
	Cq3wAac4AC62xK8xCEY4vEwIxC4wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC
	0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUGVWUXwAv7VC2z280aVAFwI0_Jr0_Gr
	1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IE
	rcIFxwACI402YVCY1x02628vn2kIc2xKxwCY1x0262kKe7AKxVWUtVW8ZwCY02Avz4vE14
	v_Gw4l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AK
	xVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrx
	kI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v2
	6r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8Jw
	CI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfUO38nUUUU
	U
X-CM-SenderInfo: ppdnvj2u6l2u1dvotugofq/
Precedence: bulk
X-Mailing-List: stable@vger.kernel.org
List-Id: <stable.vger.kernel.org>
List-Subscribe: <mailto:stable+subscribe@vger.kernel.org>
List-Unsubscribe: <mailto:stable+unsubscribe@vger.kernel.org>
X-Spam-Score: 0.5 (/)
X-Spam-Report: Spam detection software, running on the system "witcher.mxrouting.net", has
 performed the tests listed below against this email.
 Information: https://mxroutedocs.com/directadmin/spamfilters/
 ---
 Content analysis details:   (0.5 points)
 ---
  pts rule name              description
 ---- ---------------------- -----------------------------------------
  0.0 RCVD_IN_DNSWL_BLOCKED  RBL: ADMINISTRATOR NOTICE: The query to
                             DNSWL was blocked.  See
                             http://wiki.apache.org/spamassassin/DnsBlocklists#DnsBlocklists-dnsbl-block
                              for more information.
                             [139.178.88.99 listed in list.dnswl.org]
  1.5 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level
                             mail domains are different
 -1.0 MAILING_LIST_MULTI     Multiple indicators imply a widely-seen list
                             manager
SpamTally: Final spam score: 5

driver_find_device() calls get_device() to increment the reference
count once a matching device is found. device_release_driver()
releases the driver, but it does not decrease the reference count that
was incremented by driver_find_device(). At the end of the loop, there
is no put_device() to balance the reference count. To avoid reference
count leakage, add put_device() to decrease the reference count.

Found by code review.

Cc: stable@vger.kernel.org
Fixes: bfc653aa89cb ("perf: arm_cspmu: Separate Arm and vendor module")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
---
 drivers/perf/arm_cspmu/arm_cspmu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/perf/arm_cspmu/arm_cspmu.c b/drivers/perf/arm_cspmu/arm_cspmu.c
index efa9b229e701..e0d4293f06f9 100644
--- a/drivers/perf/arm_cspmu/arm_cspmu.c
+++ b/drivers/perf/arm_cspmu/arm_cspmu.c
@@ -1365,8 +1365,10 @@ void arm_cspmu_impl_unregister(const struct arm_cspmu_impl_match *impl_match)
 
 	/* Unbind the driver from all matching backend devices. */
 	while ((dev = driver_find_device(&arm_cspmu_driver.driver, NULL,
-			match, arm_cspmu_match_device)))
+			match, arm_cspmu_match_device))) {
 		device_release_driver(dev);
+		put_device(dev);
+	}
 
 	mutex_lock(&arm_cspmu_lock);
 
-- 
2.17.1



From - Wed Oct 22 13:31:23 2025
X-Mozilla-Status: 0001
X-Mozilla-Status2: 00000000
Return-Path: <linux-s390+bounces-14113-hi=josie.lol@vger.kernel.org>
Delivered-To: hi@josie.lol
Received: from witcher.mxrouting.net
	by witcher.mxrouting.net with LMTP
	id EJ+FJWvT+GjF5QAAYBR5ng
	(envelope-from <linux-s390+bounces-14113-hi=josie.lol@vger.kernel.org>)
	for <hi@josie.lol>; Wed, 22 Oct 2025 12:51:55 +0000
Return-path: <linux-s390+bounces-14113-hi=josie.lol@vger.kernel.org>
Envelope-to: hi@josie.lol
Delivery-date: Wed, 22 Oct 2025 12:51:55 +0000
Received: from sv.mirrors.kernel.org ([139.178.88.99])
	by witcher.mxrouting.net with esmtps  (TLS1.3) tls TLS_AES_256_GCM_SHA384
	(Exim 4.98)
	(envelope-from <linux-s390+bounces-14113-hi=josie.lol@vger.kernel.org>)
	id 1vBYJn-00000000OzT-01yA
	for hi@josie.lol;
	Wed, 22 Oct 2025 12:51:55 +0000
Received: from smtp.subspace.kernel.org (relay.kernel.org [52.25.139.140])
	(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by sv.mirrors.kernel.org (Postfix) with ESMTPS id 744FB5E560B
	for <hi@josie.lol>; Wed, 22 Oct 2025 12:50:35 +0000 (UTC)
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 28B1D348477;
	Wed, 22 Oct 2025 12:49:32 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="c+GsN7Ok";
	dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="XL9aqYXe"
X-Original-To: linux-s390@vger.kernel.org
Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id B7D3F3451C7;
	Wed, 22 Oct 2025 12:49:19 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55
ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1761137371; cv=none; b=J+/+Ndn//nBiUGZuGncRhJfPYOhVGh5TrHSe0p7QjaIikIepGJ5xBAjVPRmqJB4M7t6rnaOI9PGwinZQzooc2vm7XMJ4d+zVWdvG21eZtPAM7WC76rkZQSWM2MRKFTi8eUxRd3RSGCq+/3qmK3c8GXKNrJIspbobtRATevR1Adc=
ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1761137371; c=relaxed/simple;
	bh=V1mfCsRfXgy86CzSvOjy9288devaZUurilfSaMjXsyI=;
	h=Message-ID:From:To:Cc:Subject:References:MIME-Version:
	 Content-Type:Date; b=k6MgLVtnZUMXT78XUOrSwKz+kCHf85k6bj0AzHcQuA0MhWXkeYwKcXyBPmy4TwLyzPCiRm7tzDFHLLa6NRVUlFevuqKsXRhb4NcpFrdHDl/a8KH+/JTWqev2T47yK3pCMmdeOKlPm4On9cC/yW3C73UVtT+zWO1PSC7JuFo+FaI=
ARC-Authentication-Results:i=1; smtp.subspace.