Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp607ybt; Tue, 7 Jul 2020 14:16:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRSxqX0vzUpwYNmNHxjwpy/ARAsbRNVyTEUxtbPMJ7DgUtqrjrvZH+e+HXM46/raRRuVyp X-Received: by 2002:a17:906:b45:: with SMTP id v5mr47417531ejg.464.1594156604780; Tue, 07 Jul 2020 14:16:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594156604; cv=none; d=google.com; s=arc-20160816; b=Ei+tS8atpLtMoWCbHbqMadNf7wukarvIEZli6NKjuWOl6Oye3ta4fY2J7/U3kZXiMS 0gVa+RsExM75MzBWIL/KRiJXYSYQZcxOxYZTPQRkE2TWMs8u+V3ljq3jgq3cdxWlzIBo kA6hVrK317eUaEWcDAfcmHs0yx6KdPbPShGELhZoIURnJOJwhwJxS5P9v860ic1v7dlJ rUGrSYtK2mXTIgz5Zh0YZ89WOjMuRYsWvrNJVJrPvckMZgQdZacu+NAiTZ7fFy5OixBl M8GbpXJQnL9lFztrDA+tzyM2TFrLyVgs0QOvplfcmh06p5b9QlLqW/IsB6eDLF5nh7lY A1UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=kNdhCSa8RWdoQ1Qw/Izmt1HpD4OJoWvmGsBpjHdVCp8=; b=iVbIGTsUYWOsRyJPwTWHuq3/mRSKXefU1Y4TTWYR2M8ObHz6fKxMj0FJoukRUwLpEl 5Mf03j/tLf/iqECGokM6DLOdqUlgdLceoNWZSnd3NbiTYMQlQPsAbkBpU8OEKH13Csgy g6G57mAZnQ2vRiA8F48IF+Fv2AWJTgU/S4vMSYEcg/bhaAjVlFaMROHvfyqF3MLMlDcu yVOjNwJB+/WZKfdhuCrjzbklPxxFmWMbQIw6Vnf8rl227NyxRN9cbMt9jIoT4XuWL6dM y4TkR36GGB9gY3AUngKeIRvoYE7duIO6psFcsfWmXF/kLDfTFClnkbznt71rqxz2NR7D HxQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IchCb4hb; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d5si16243284ejm.223.2020.07.07.14.16.22; Tue, 07 Jul 2020 14:16:44 -0700 (PDT) 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=@kernel.org header.s=default header.b=IchCb4hb; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729129AbgGGVPU (ORCPT + 99 others); Tue, 7 Jul 2020 17:15:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:60074 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728201AbgGGVPT (ORCPT ); Tue, 7 Jul 2020 17:15:19 -0400 Received: from localhost (mobile-166-175-191-139.mycingular.net [166.175.191.139]) (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 1D5CB2075B; Tue, 7 Jul 2020 21:15:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594156518; bh=1s/robryCgQa82sfCBKNWG/m6UpXwTxp0ZAypBuWLWk=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=IchCb4hb83xx8DKThJRMTwMstsiVfgZEEeFqqBFOG3C+1Aq2rpPYsuBLaobwTaGPD bUInFODWCspThMhVQdtN1Z3lDOA6mY5VhF9TYuSKt3+kj4zksrutjtbZRUBzalqVBC oObl6DpyIhX9E+DIYsSFxTQ9kHSrJ8iooI3ls+6k= Date: Tue, 7 Jul 2020 16:15:16 -0500 From: Bjorn Helgaas To: Vaibhav Gupta Cc: Vaibhav Gupta , Bjorn Helgaas , bjorn@helgaas.com, "David S. Miller" , linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, skhan@linuxfoundation.org, linux-ide@vger.kernel.org Subject: Re: [PATCH v2 2/4] ide: triflex: use generic power management Message-ID: <20200707211516.GA385934@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 08, 2020 at 02:23:22AM +0530, Vaibhav Gupta wrote: > On Wed, Jul 8, 2020, 2:12 AM Bjorn Helgaas wrote: > > On Fri, Jul 03, 2020 at 01:44:26PM +0530, Vaibhav Gupta wrote: > > > -static int triflex_ide_pci_resume(struct pci_dev *dev) > > > +/* > > > + * We must not disable or powerdown the device. > > > + * APM bios refuses to suspend if IDE is not accessible. > > > + */ > > > +static void triflex_pci_pm_cap_fixup(struct pci_dev *pdev) > > > { > > > - struct ide_host *host = pci_get_drvdata(dev); > > > - int rc; > > > - > > > - pci_set_power_state(dev, PCI_D0); > > > - > > > - rc = pci_enable_device(dev); > > > - if (rc) > > > - return rc; > > > - > > > - pci_restore_state(dev); > > > - pci_set_master(dev); > > > - > > > - if (host->init_chipset) > > > - host->init_chipset(dev); > > > - > > > - return 0; > > > + dev_info(&pdev->dev, "Disable triflex to be turned off by PCI > > CORE\n"); > > > > I would change this message to "Disabling PCI power management" to be > > more like existing messages: > > > > "PM disabled\n" > > "Disabling PCI power management to avoid bug\n" > > "Disabling PCI power management on camera ISP\n" > > > > > + pdev->pm_cap = 0; > > > } > > > -#else > > > -#define triflex_ide_pci_suspend NULL > > > -#define triflex_ide_pci_resume NULL > > > -#endif > > > +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_COMPAQ, > > > + PCI_DEVICE_ID_COMPAQ_TRIFLEX_IDE, > > > + triflex_pci_pm_cap_fixup); > > > > I don't think this needs to be a fixup. This could be done in the > > probe routine (triflex_init_one()). > > > > Doing it as a fixup means the PCI core will check every PCI device > > to see if it matches PCI_DEVICE_ID_COMPAQ_TRIFLEX_IDE, which is a > > little extra useless overhead and quirks are a little bit magic > > because it's not as obvious how they're called. > > > > But since triflex_init_one() is called only for the devices we care > > about, you can just do: > > > > static int triflex_init_one(struct pci_dev *dev, const struct > > pci_device_id *id) > > { > > dev->pm_cap = 0; > > dev_info(...); > > return ide_pci_init_one(dev, &triflex_device, NULL); > > } > > > Seems a better approach. And in that case I won't need this extra patch > just for triflex. I can put dev->pm_cap=0 change > in [Patch 1/1] along with other ide drivers. Hmm, I just noticed that there are actually *two* drivers (triflex.c and pata_triflex.c) for this same device, and they both have this comment about "APM BIOS refusing to suspend if IDE is not accessible" and therefore preventing suspend of IDE. At least, the comment seems to imply that calling pci_save_state() is a way to prevent suspend of the device. That seems like a strange way to do it, but ... Anyway, I wonder if a single quirk in drivers/pci/quirks.c would be better. A preliminary patch could add a quirk (keeping the comment) and remove the pci_save_state() from both triflex_ide_pci_suspend() and triflex_ata_pci_device_suspend(). Then you could proceed with these generic PM changes on top of that. Maybe make the dev_info() mention that you're disabling PM to avoid an APM BIOS suspend defect so users have a clue about why. Bjorn