Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1090782pxb; Tue, 9 Nov 2021 05:06:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJxbkkIZsjbzMG+UPtDMjPYM0CYZMLHUmXWXuzv400/uWflXQ2t9MmzPxzGUyRn5Ne2GQnWf X-Received: by 2002:a92:c261:: with SMTP id h1mr4674714ild.291.1636463164878; Tue, 09 Nov 2021 05:06:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636463164; cv=none; d=google.com; s=arc-20160816; b=U/4Eu1FhLFilGv+e/ozcIGBM9DtIxyTWhjwNDs6hA7N3+0n2fFePDaGEaDqaCL3HDN MUexNYXzAp5chUfyjNI1c+pO2Js5mAEbKbGTKZPt1DwVd34LIebTyKeH2cJnTnx/gPQO FSRNAJFG6b2486lneGhd6gzKLPJMZOc43L8SKsr0UxqlfgTYpsiFkdSEWNBFH25Vwoqs LRod9/RSfzTp0vZ9x0UKLYpDicAGYJFUMUKPG6OtmA5NPjgFna3XuaRbP/M68Qmnyn1g tbwRUhzaivCR3ugyUvOzFMtfPe6s/AQ1k7o80OIVV0p1QsJOpNVd2Eemss4m3gJi64xu lF8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=lJJCnNSdYrPC6zwfxXa2NxkhiYXvKAkFn+lMGtOyPTk=; b=LGhdtv5OC7ITWJfV4QDciRaIP/PF27mtOPwrJRK0908b135spruorRbxbmhiw/spsn hEFksoKzoM9HsWleTlsGRsmH+8m8UMAN5magerh/UjPQYaFcGxFPfG429symMtUqgkvn WkmFjJX1ZZmpF05cLAqBuzS2ftm/4mYu+fvpZq2p8B0f3b4GwoQd2qKM2jSHVYow3116 ZTiBLfBG/4XIp59qEemjwW+fKUrV9pTspiLmBO6b8wcocJfNNkV6zWVxW18NEisB+4KJ 0acieQzwomSTJ92fnCtfIRqeog3rNuM2ZB8Kba0ztABIhWsfHAuF6Jwp20QgeAZ8Cpow JMaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=p5J9N3Gq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x1si39989858ilv.27.2021.11.09.05.05.49; Tue, 09 Nov 2021 05:06:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=p5J9N3Gq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239555AbhKIGpF (ORCPT + 99 others); Tue, 9 Nov 2021 01:45:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:32808 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229591AbhKIGpE (ORCPT ); Tue, 9 Nov 2021 01:45:04 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id E672660234; Tue, 9 Nov 2021 06:42:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1636440139; bh=B1IguEi2bwhHxjOBHleDUZl379REYQJYKiP/fzsjmag=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=p5J9N3GqT9v/BHqm+jT0fWwRW4bhsapm+tDX5PeGixFPln6G6/dPAP2jgByTNU2N8 K3ebZ/mnEy0PE/Yd2DAlh5GZIKHGqjIY6fJ+oq+2RtsxVaalciqNiJXVlEtYLMkQzH XXRbG/57WQZ3Hh/G1a3gZDhHPbpsMkYcrE14Bl58= Date: Tue, 9 Nov 2021 07:42:09 +0100 From: Greg Kroah-Hartman To: Bjorn Helgaas Cc: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , Robert =?utf-8?B?xZp3acSZY2tp?= , linux-i2c@vger.kernel.org, Bjorn Helgaas , linux-pci@vger.kernel.org, "Rafael J. Wysocki" , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] pci: Don't call resume callback for nearly bound devices Message-ID: References: <20211108212226.253mwl4wp7xjckqz@pengutronix.de> <20211109025619.GA1131403@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20211109025619.GA1131403@bhelgaas> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 08, 2021 at 08:56:19PM -0600, Bjorn Helgaas wrote: > [+cc Greg: new device_is_bound() use] > > On Mon, Nov 08, 2021 at 10:22:26PM +0100, Uwe Kleine-K?nig wrote: > > pci_pm_runtime_resume() exits early when the device to resume isn't > > bound yet: > > > > if (!to_pci_driver(dev->driver)) > > return 0; > > > > This however isn't true when the device currently probes and > > local_pci_probe() calls pm_runtime_get_sync() because then the driver > > core already setup dev->driver. As a result the driver's resume callback > > is called before the driver's probe function is called and so more often > > than not required driver data isn't setup yet. > > > > So replace the check for the device being unbound by a check that only > > becomes true after .probe() succeeded. > > I like the fact that this patch is short and simple. > > But there are 30+ users of to_pci_driver(). This patch asserts that > *one* of them, pci_pm_runtime_resume(), is special and needs to test > device_is_bound() instead of using to_pci_driver(). > > It's special because the current PM implementation calls it via > pm_runtime_get_sync() before the driver's .probe() method. That > connection is a little bit obscure and fragile. What if the PM > implementation changes? > > Maybe we just need a comment there about why it looks different than > the other PM interfaces? > > I also notice that the only other uses of device_is_bound() > outside the driver core are in iommu_group_store_type() and > regulator_resolve_supply(). This patch seems like a reasonable use, > but I always look twice when we do something unique. I agree that this looks really odd. No one should care outside of the driver core to call device_is_bound(), as if a driver is being called, implicitly you know that the device is bound to that driver. Why does the PCI core care if a device is bound to a pci driver at this point in time? But, this does feel like an odd use of to_pci_driver() here, what needs to be known here, if a pci driver is in control of a device here or not? thanks, greg k-h