From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43C9DC43462 for ; Tue, 11 May 2021 16:16:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 10D066186A for ; Tue, 11 May 2021 16:16:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231774AbhEKQR7 (ORCPT ); Tue, 11 May 2021 12:17:59 -0400 Received: from ale.deltatee.com ([204.191.154.188]:53762 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230382AbhEKQR6 (ORCPT ); Tue, 11 May 2021 12:17:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=deltatee.com; s=20200525; h=Subject:In-Reply-To:MIME-Version:Date: Message-ID:From:References:Cc:To:content-disposition; bh=qGEiJKxfeZlmzsrJW3D8SgKWMOzFWWlWIF4SmeuVBPk=; b=ntkDNl1ZjZzOkVld9EYsyBSR1g ccd5oF9LMU67fzPYv90Fwd4Y1irj0V7v+J2klm0JE5M1ASoPOI1v0sVaTjnacpcS7HVdLPMGZV53T Voce44zY08R7yplObv7E+p1wa3HXD+WtmqJblO81rvwsCCqqF7TCljrzQSVWdPadK8YUd1giXo/Id mQxd8+ma4bxpKkqwsmr5XLNJqp1HOZcmOKxXmN0mc0yd6UeCYgkSE8YEBTkEIOjJLydxxDyOyvbvR mMI1FijYE0fyHBeqo+wH0Wg6i0iNhQohX2tpxc/fQ6jXzWaqfrVm5nJt/xrQzecC6pVVLM788y8OF KTnNa/sw==; Received: from guinness.priv.deltatee.com ([172.16.1.162]) by ale.deltatee.com with esmtp (Exim 4.92) (envelope-from ) id 1lgV3p-0006e9-2V; Tue, 11 May 2021 10:16:42 -0600 To: Don Dutile , John Hubbard , linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, linux-mm@kvack.org, iommu@lists.linux-foundation.org Cc: Stephen Bates , Christoph Hellwig , Dan Williams , Jason Gunthorpe , =?UTF-8?Q?Christian_K=c3=b6nig?= , Matthew Wilcox , Daniel Vetter , Jakowski Andrzej , Minturn Dave B , Jason Ekstrand , Dave Hansen , Xiong Jianxin , Bjorn Helgaas , Ira Weiny , Robin Murphy References: <20210408170123.8788-1-logang@deltatee.com> <20210408170123.8788-3-logang@deltatee.com> From: Logan Gunthorpe Message-ID: <65ae4aa7-b646-c270-6c51-2e9c686c5f03@deltatee.com> Date: Tue, 11 May 2021 10:16:40 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-CA Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 172.16.1.162 X-SA-Exim-Rcpt-To: robin.murphy@arm.com, ira.weiny@intel.com, helgaas@kernel.org, jianxin.xiong@intel.com, dave.hansen@linux.intel.com, jason@jlekstrand.net, dave.b.minturn@intel.com, andrzej.jakowski@intel.com, daniel.vetter@ffwll.ch, willy@infradead.org, christian.koenig@amd.com, jgg@ziepe.ca, dan.j.williams@intel.com, hch@lst.de, sbates@raithlin.com, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, jhubbard@nvidia.com, ddutile@redhat.com X-SA-Exim-Mail-From: logang@deltatee.com Subject: Re: [PATCH 02/16] PCI/P2PDMA: Avoid pci_get_slot() which sleeps X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-05-11 10:05 a.m., Don Dutile wrote: > ... add a flag (set for p2pdma use)  to the function to print out what the root->devfn is, and what > the device is so the needed quirk &/or modification can added to handle when this assumption fails; > or make it a prdebug that can be flipped on for this failing situation, again, to add needed change to accomodate. Good idea! Will add. >>     root = NULL; >>  out: >>     pci_dev_get(root); >>     return root; >> } >> EXPORT_SYMBOL(pci_get_root_slot); >> >> ...I think that's a lot clearer to the reader, about what's going on here. >> >> Note that I'm not really sure if it *is* safe, I would need to ask other >> PCIe subsystem developers with more experience. But I don't think anyone >> is trying to make p2pdma calls so early that PCIe buses are uninitialized. >> >> >>> + >>> +    if (!root || root->devfn) >>>           return false; >>>         vendor = root->vendor; >>>       device = root->device; >>> -    pci_dev_put(root); > and the reason to remove the dev_put is b/c it can sleep as well? > is that ok, given the dev_get that John put into the new pci_get_root_slot()? > ... seems like a locking version with no get/put's is needed, or, fix the host-bridge setups so no !NULL self pointers. The dev_get is redundant here seeing we hold references to child devices. It was only in the previous code because we were using pci_get_slot() to get the device which did the get for us. Logan