Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3678767ybg; Fri, 25 Oct 2019 07:29:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqx2mfitAm1pQ+9RfLSUQhl+/4qRFutK754b+VQAzi4OD0AI2WPb+wI8ZBOJEMOVQZDFB9X4 X-Received: by 2002:aa7:de16:: with SMTP id h22mr4148328edv.183.1572013757467; Fri, 25 Oct 2019 07:29:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572013757; cv=none; d=google.com; s=arc-20160816; b=rCK6G5E1zxDrrhcRAmFC7P4U5xEPpdofhFr+tPO5dp1fM6j6KRy+imVhTBVanClTit /5EtH/xisRVX7uVPhOXd8NCxXP/9AwWgiFZfzKcSM9IL/nq22zn0w/aKyV1ZO/vL4JUf /bV3IS7aDOdd8SxbhNAArIpuZZsKUDmtSmHayX646Rwpw1jcMFyvyYzpr8y1xW1WkFR+ jYV5nJ+kr1G3dPN5zlSKjlhj5kNupcZbqDBJAl7F3UcyZEHbpRCqjYql56UvhXscLwLp kMf1+dMgvjufE9nw/ix5QMz1J7DDK1h7JDG7DeDBsLHHwGF0ujkc5Xmk4vR6NEqjIX77 RXsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:message-id:subject:cc:to:from:date :dkim-signature; bh=pzNYnw8YJTNEV6n5A/L2tP+Tw8ao0yd/oZcn3lalHaQ=; b=LnhEfUFvM9AyV702yZ52GM6fnnAhBq+8OwYgFrq70O9w5/ta6xVq7SB0A+33KD8w+h Cqwdw/651/x2ZtgUm5mygK1BjBIwc7CdFW4ZT5FZsTlB9lmNiKzpDVO7br+vs7gvYTK6 tklQEFUvRVzN40yMSuR0OQKe/bdpmXHugNkDRuwp1jLvk8+myaAG/i207S/flpmk2QMQ NViYoXw4n1ZTZS1kAGP9Ny663wuggcm4VxN0JO4fyGNjU6QokHaDrBrszYMCWr+Lxuhl FgTmmyyTyXxM7Ra4xQqch2bHB5qMcXXTKecP+KWGeW5TNx6kFtq44cs2FCUtipqc6jCM 3yNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qtbTWnH9; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d25si1423762edb.19.2019.10.25.07.28.54; Fri, 25 Oct 2019 07:29:17 -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; dkim=pass header.i=@kernel.org header.s=default header.b=qtbTWnH9; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439936AbfJXRLF (ORCPT + 99 others); Thu, 24 Oct 2019 13:11:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:42418 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2439855AbfJXRLE (ORCPT ); Thu, 24 Oct 2019 13:11:04 -0400 Received: from localhost (unknown [69.71.4.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DC4FC20650; Thu, 24 Oct 2019 17:11:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571937064; bh=50LiASavYQZLbe6nfO7wdHLLLfE3YL2HyvzWd+ySzPE=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=qtbTWnH9LA3tbkJFClj5FPXT3Mtrc4X0jALff5Ub3dJQBOsMB9ZTw5xWY6LnRIT1K DshfISJ7KzW+Ubkjy5thaBOIiRSFSEC/CxfvkfZtPfvzDzpw4YMQP+D0Rz4BiCbtJq kIZ8ib0J215lecEYJkXFVeeKcJ6aULHrnG+QixvI= Date: Thu, 24 Oct 2019 12:11:02 -0500 From: Bjorn Helgaas To: Mika Westerberg 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: <20191024171102.GA147451@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191024093803.GU2819@lahna.fi.intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 24, 2019 at 12:38:03PM +0300, Mika Westerberg wrote: > 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; Yes, I guess this is what you'd have to do. > 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? I *would* like to explore removing the "*val = 0" code from pci_capability_read*(), but not in the context of this issue.