Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp1586250lqb; Sun, 26 May 2024 07:46:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVl04kFOZelh3TT3a1LmOTWYxQSdaVJgbtb2AB+LvV2UeJ3yB9uo9JyFspLWlkEcIbukzRFDI97vBo6axcWdorN2EYwBAMEXKzcn6uAHg== X-Google-Smtp-Source: AGHT+IHXcJotK2GI2s0BdUZrvRlsR6Md1C3MDekJYe5xGP4tezeq8IfAbGv8ScAxTM0d/7fgxA0R X-Received: by 2002:a50:9986:0:b0:572:a073:a39a with SMTP id 4fb4d7f45d1cf-578518fecdbmr7242466a12.5.1716734815031; Sun, 26 May 2024 07:46:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716734815; cv=pass; d=google.com; s=arc-20160816; b=qGkkw5/V1IJwq55G80OvhRlL9VPwjJWfwU/w/PBD++zJenNYsx1TMCiDkia6sTRiSw 0VBXAEhXbl+4vhEXoEtVwseQkJ+q+TvovaoPiVIbofoI7fTkOp13aVtP1TKnAwutHPAm Cxuf8d+DjzQ8FH3cyMxntR9ywwdM6AwM8TDSzVzTqUKE9zZhjnzsYB3MiHXeBIGyCIUh vuawuVbytjZ0rup5bUDHsi/wT9RQSFoKKug97urHN2hQjRSMjDVjMJWH0y48UuiedIz5 WIC/LIGVmztBfvlGwiP7YO1nVaDvRYsYVeiS6NltIX7G/0FkXlaDSDUHA+zN0ldriwKq 0lRA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:dkim-signature; bh=PXxPXglWm8XATSaQ0NFCFC3asxv7XPwSdYw6ZgYO648=; fh=8LiUEBFbdZxB0ei2GaVcdery34LQ7ONiGRp3x6PIPn0=; b=QwSMM7VdB2NNcwefH1i9uiMY+ylSvOiiwXyvKRpyorm2bEHKdzXFk2egyW9ACljnO5 fAB7KCLYi8b5WdfenUo90Z1cAS8dNTFSzRP7SPTNrG6E3WZFVsxR8xv86RMaZpq8lv5Z C+yjqSYJ8icp6qmJGklCvj07j7D2btAemlOsAH1RvfyvFeO+AWv02Wz6OMAk/Kv3fWTv PDLpfoKzr0MaCkKZO6IbBlgLZsRH3SE1qxlhacbBwQivLxe01WyRpLJPeWux5Rdsq9Rs Pt+DwocP/1tcWGjQ2WL1SbrtIUSYsUHfgDOuzuj2fzltAsPaoOesJ1/Wr0dkc4edUCso HptQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=cckBrXwF; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-189762-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189762-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-579bfc0be26si1466487a12.81.2024.05.26.07.46.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 May 2024 07:46:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-189762-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=cckBrXwF; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-189762-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189762-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id C1E031F2162D for ; Sun, 26 May 2024 14:46:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8F4261803A; Sun, 26 May 2024 14:45:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="cckBrXwF" Received: from out30-119.freemail.mail.aliyun.com (out30-119.freemail.mail.aliyun.com [115.124.30.119]) (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 309AD17C72; Sun, 26 May 2024 14:45:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.119 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716734752; cv=none; b=K5SbZw8pyj2ri5ONlgiVPxEpYyiJ7sa6FnzpHcz9MUNtQp+xrYUljqnGOcLeAqgwY5SicjcKn/BxzHWVYJiKPy3G02B3KALXdJYfpDG3+C32ESXemDLb2ms6phpi9IN/ufx56MFvicO9RwISwLBhPnO6PsZP2TF1WwGbetuaxqE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716734752; c=relaxed/simple; bh=ZlQaGFLsWgK/IQ4mDeumheHUefmrW+eLzLuRalsap/U=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=pC317MDPAmq8g1dc13t38jvvzKhsBugLqp3sMLjTpGPzOAOLTnkTj2MVD7ZxegSLShpjH2GYVlrft8+IvGQmmi9aujt3ZbdAH7Ja8jhUMJGTfl9p+4a0OIqQpai1Nb4YpG/RSs3hNKS1N/Q02wZSkuwSAYpav0KBraTp+rl7bWE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=cckBrXwF; arc=none smtp.client-ip=115.124.30.119 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1716734739; h=Content-Type:Mime-Version:Subject:From:Date:Message-Id:To; bh=PXxPXglWm8XATSaQ0NFCFC3asxv7XPwSdYw6ZgYO648=; b=cckBrXwFAsScaszIBZ+LZtnSNtPZa8qlozDXt5/xeN97UOEZn5EF+84tfYUS82PLaSfdWSD69vt3CxwiQ8x8boaybZuktIhN0b8JR//kp5W2YsBVWCr9PSMhDDzW95kiyXu4lxQRMD/4SGU/LW2Z8N8ETPEF5LVdaEM+P//dRA8= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R141e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033032014031;MF=yaoma@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0W7Bp-mL_1716734737; Received: from smtpclient.apple(mailfrom:yaoma@linux.alibaba.com fp:SMTPD_---0W7Bp-mL_1716734737) by smtp.aliyun-inc.com; Sun, 26 May 2024 22:45:39 +0800 Content-Type: text/plain; charset=utf-8 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Subject: Re: [PATCH] PCI: pciehp: Use appropriate conditions to check the hotplug controller status From: yaoma In-Reply-To: Date: Sun, 26 May 2024 22:45:36 +0800 Cc: yaoma , bhelgaas@google.com, weirongguang@kylinos.cn, kanie@linux.alibaba.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: <7855600C-4BB6-417B-8F91-24F4F7E0820E@linux.alibaba.com> References: <20240524063023.77148-1-yaoma@linux.alibaba.com> To: Lukas Wunner X-Mailer: Apple Mail (2.3696.120.41.1.1) Hi, > 2024=E5=B9=B45=E6=9C=8824=E6=97=A5 15:53=EF=BC=8CLukas Wunner = =E5=86=99=E9=81=93=EF=BC=9A >=20 > On Fri, May 24, 2024 at 02:30:23PM +0800, Bitao Hu wrote: >> The values of 'present' and 'link_active' have similar meanings: >> the value is %1 if the status is ready, and %0 if it is not. If the >> hotplug controller itself is not available, the value should be >> %-ENODEV. However, both %1 and %-ENODEV are considered true, which >> obviously does not meet expectations. 'Slot(xx): Card present' and >> 'Slot(xx): Link Up' should only be output when the value is %1. > [...] >> --- a/drivers/pci/hotplug/pciehp_ctrl.c >> +++ b/drivers/pci/hotplug/pciehp_ctrl.c >> @@ -276,10 +276,10 @@ void = pciehp_handle_presence_or_link_change(struct controller *ctrl, u32 = events) >> case OFF_STATE: >> ctrl->state =3D POWERON_STATE; >> mutex_unlock(&ctrl->state_lock); >> - if (present) >> + if (present > 0) >> ctrl_info(ctrl, "Slot(%s): Card present\n", >> slot_name(ctrl)); >> - if (link_active) >> + if (link_active > 0) >> ctrl_info(ctrl, "Slot(%s): Link Up\n", >> slot_name(ctrl)); >> ctrl->request_result =3D pciehp_enable_slot(ctrl); >=20 > We already handle the "<=3D 0" case immediately above this code = excerpt: >=20 > if (present <=3D 0 && link_active <=3D 0) { > ... > } I'm not sure if the following scenarios would occur in actual production = environment, but from the code level, there is the possibility of =E2=80=9Cpresent <=3D= 0 && link_active > 0=E2=80=9D or =E2=80=9Cpresent > 0 && link_active <=3D 0=E2=80=9D. In these cases, = the =E2=80=9C<=3D 0=E2=80=9D conditions will not be properly handled, and =E2=80=9Cctrl_info=E2=80=9D will output = incorrect prompt messages. > So neither "present" nor "link_active" can be < 0 at this point. >=20 Best Regards, Bitao Hu=