Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3139039ybg; Thu, 24 Oct 2019 22:53:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqw05lQnFZX6XoiP4WjA4dqMC7H4HeIvtlBTIjZZexCII2PNgW4PJawCs+xiyQ1oFe1LPrnw X-Received: by 2002:aa7:d985:: with SMTP id u5mr2026895eds.108.1571982823502; Thu, 24 Oct 2019 22:53:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571982823; cv=none; d=google.com; s=arc-20160816; b=cSgMvHss0fBniCz9TyDHrUCBa1Gmb3c2d6wYK8IbOUHWOaxoNBByngYensxseNdYF1 khmSktLsdR1K7Sgi3jMKgEsX7JtVKFhjlLgeWUm0f9P6BfeLBYnrXrkz/DO+9a3Upbkg y2gJoCROS9Lb28/7AX0IM72N1CgAabw7y585x2nua7ohCDAE+BT3cw4xacf5mQPcT4zS g8vWSpSqLxnym0SLaRsn8i4O4ZB9Nhc/wX5Z1khW94VFWXBEAtKejv63v03+AQHZIUEp Q+QwTE/zNxuPwvHRmEdOy//Hvhgn3DtCjRgPLWAc5Oh9V7Wt/Hfm3ELD8YrKi5oXtLDm gMzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=1IGvtUPysDRA91FTOescx2kpHJFqAhIjlVquf9JVXdY=; b=nvyu95xgvhqygGc6jH3aGg4ia5/q6xnr1bJvpKs+BPalvLlkDHH4vnSJGS9mUYNBvX sWwnKrhwqXxkMWsRKKkowBoXBgkaaQb5FglthXenHkk+cASl4TRHsO4yQLJ9mGLD+VQi RbhTYCGCEG2n7v+ASpHB4n0YJy1F3Psra8SCv4ny9EG0cHya8LrJLOGpxNX7szIrnZO8 UDD9F/K8Tco0Ma1z6FdIZLWBLiwXKvlzhkqr1Oy9Wx5J8lVzrgY7VwHfk62lBRblHCdS CRrqCDI+o0w4v81XGMvNXtvIztsjjG/KCtQ/W0lkB4jKmuiadDhxDK9i9TZoIYbDxSfb FrnQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j9si532057edt.32.2019.10.24.22.53.20; Thu, 24 Oct 2019 22:53:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438670AbfJXJiM (ORCPT + 99 others); Thu, 24 Oct 2019 05:38:12 -0400 Received: from mga09.intel.com ([134.134.136.24]:1200 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438652AbfJXJiJ (ORCPT ); Thu, 24 Oct 2019 05:38:09 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Oct 2019 02:38:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,224,1569308400"; d="scan'208";a="210117869" Received: from lahna.fi.intel.com (HELO lahna) ([10.237.72.157]) by fmsmga001.fm.intel.com with SMTP; 24 Oct 2019 02:38:04 -0700 Received: by lahna (sSMTP sendmail emulation); Thu, 24 Oct 2019 12:38:03 +0300 Date: Thu, 24 Oct 2019 12:38:03 +0300 From: Mika Westerberg To: Bjorn Helgaas Cc: "Rafael J. Wysocki" , Lukas Wunner , Keith Busch , Andy Shevchenko , Frederick Lawler , "Gustavo A . R . Silva" , Sinan Kaya , Kai-Heng Feng , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/2] PCI: pciehp: Prevent deadlock on disconnect Message-ID: <20191024093803.GU2819@lahna.fi.intel.com> References: <20190812143133.75319-2-mika.westerberg@linux.intel.com> <20191022230006.GA46791@google.com> <20191023075248.GO2819@lahna.fi.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191023075248.GO2819@lahna.fi.intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 23, 2019 at 10:52:53AM +0300, Mika Westerberg wrote: > > Shouldn't we check for slot_status being an error response (~0) > > instead of looking for PCIBIOS_DEVICE_NOT_FOUND? There are 7 RsvdP > > bits in Slot Status, so ~0 is not a valid value for the register. > > > > All 16 bits of Link Status are defined, but ~0 is still an invalid > > value because the Current Link Speed and Negotiated Link Width fields > > only define a few valid encodings. > > Indeed that's a good point. I'll try that. Just checking if I understand correctly what you are suggesting. Currently we use pcie_capability_read_word() and check the return value. If the device is gone it returns an error and resets *val to 0. That only works if pci_dev_is_disconnected() is true so we would need to do something like below. pciehp_check_link_active(): ret = pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lnk_status); if (ret == PCIBIOS_DEVICE_NOT_FOUND || lnk_status == (u16)~0) return -ENODEV; Or you mean that we check only for ~0 in which case we either need to use pci_read_config_word() directly here or modify pcie_capability_read_word() return ~0 instead of clearing it?