Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1353663ybt; Tue, 7 Jul 2020 13:44:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmZNA77/cAnA4tfm4iwWVxYy7rWVknfbmS8KMmn9G0nx2EXqVhaUEFcT2Lazy/RXxPYTW4 X-Received: by 2002:a17:906:1357:: with SMTP id x23mr51692751ejb.148.1594154645631; Tue, 07 Jul 2020 13:44:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594154645; cv=none; d=google.com; s=arc-20160816; b=p8QNO2+Vr7p33Vs/W1NJ5NhU/jROjtp5uVVlouoWx8u79Js7RWtNjGtig0nEurMHIq vEqx8hFiYBSmPtM8F3H9AfTlw9Ky6qXOs7KRba4D7N3oguU349r9zvFrGxjYAoMfgpdf KFqEDLIChVPjSl4076kq5yEgl49stCMAT7DbFlkQZHwZWuWdUCJhdl1adFOhV/Wv97pp 9God6Emh+AVuVvvrvi2hka9gzWbjNRvwDFklE6FXABKLYYs+K/qe8BW0qLSjRoHsgzt3 y1/+MLrJl+0gQc5nkUCWtCBPLNiH1bx+QmNA9SRtTquvRD9CBV31G1syFZmZdo8UyYX7 NWmA== 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=BciXDVO1lHIjeLHLiU/cxTv+0I3I1zWBvQS/sP+fUBk=; b=dlM2ur6lOkThGBa2LqrLAY1UCQfeFwV2WSU69HeY2oDAcC+tz+02OLqTLsiBMh8H8C HAR1/fh0ljZT/d0cVe1FY3flU891o/x7nVNkHHEq69tH2DGUFpFiUEB24gtZFClRsyPB GBOl5JVRvgdVv7PnJvuwa1zeLFXSgJFfxE75RWCkc3xJe/1HKTWCckm6KMckAa9CpsD0 g5pNvZP/E63gi0L5yu9A2R5YuBFscbppjuCjgozhizr95c/SwTTUkytCaXuOmElOP3TZ 8GAfKiTRgLDfAI7WOKWn//KsqiFOp1K+NwB4aQ3bojILr5NZ8F3EyhSljE7tuMCw38Jt Unog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=j2EUy+Xh; 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 ss22si16782455ejb.530.2020.07.07.13.43.42; Tue, 07 Jul 2020 13:44:05 -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=j2EUy+Xh; 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 S1728936AbgGGUmE (ORCPT + 99 others); Tue, 7 Jul 2020 16:42:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:51542 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726273AbgGGUmD (ORCPT ); Tue, 7 Jul 2020 16:42:03 -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 988CC206F6; Tue, 7 Jul 2020 20:42:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594154523; bh=AnGRUUPwqzcwpLs6pEvzN/rJFDFLsWpe3uIVEGqiWr8=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=j2EUy+Xh9X4HarBCOIEDlDUsFtpmrZdVwzS2NDWjlKi4VsuWloS9i5zmnmiW5oSTG K3EXcBM9inuude2+oF3BTJOtX9Gb83ucYZnVtHsEn5l4gxgJAUJaEsBiIF0RN4JuNz ze09c/EdDdu7pfVYHQ39lSmUG5z8HoARoOkS6lfc= Date: Tue, 7 Jul 2020 15:42:01 -0500 From: Bjorn Helgaas To: Vaibhav Gupta Cc: Bjorn Helgaas , bjorn@helgaas.com, Vaibhav Gupta , "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: <20200707204201.GA382915@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200703081428.1011527-3-vaibhavgupta40@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 03, 2020 at 01:44:26PM +0530, Vaibhav Gupta wrote: > While upgrading ide_pci_suspend() and ide_pci_resume(), all other source > files, using same callbacks, were also updated except > drivers/ide/triflex.c. This is because the driver does not want to power > off the device during suspend. A quirk was required for the same. > > This patch provides the fix. Another driver, > drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c, makes use of > a quirk for similar goal. Hence a similar quirk has been applied for > triflex. > > Compile-tested only. > > Signed-off-by: Vaibhav Gupta > --- > drivers/ide/triflex.c | 45 +++++++++++-------------------------------- > 1 file changed, 11 insertions(+), 34 deletions(-) > > diff --git a/drivers/ide/triflex.c b/drivers/ide/triflex.c > index 1886bbfb9e5d..f707f11c296d 100644 > --- a/drivers/ide/triflex.c > +++ b/drivers/ide/triflex.c > @@ -100,48 +100,25 @@ static const struct pci_device_id triflex_pci_tbl[] = { > }; > MODULE_DEVICE_TABLE(pci, triflex_pci_tbl); > > -#ifdef CONFIG_PM > -static int triflex_ide_pci_suspend(struct pci_dev *dev, pm_message_t state) > -{ > - /* > - * We must not disable or powerdown the device. > - * APM bios refuses to suspend if IDE is not accessible. > - */ > - pci_save_state(dev); > - return 0; > -} > - > -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); } > static struct pci_driver triflex_pci_driver = { > .name = "TRIFLEX_IDE", > .id_table = triflex_pci_tbl, > .probe = triflex_init_one, > .remove = ide_pci_remove, > - .suspend = triflex_ide_pci_suspend, > - .resume = triflex_ide_pci_resume, > + .driver.pm = &ide_pci_pm_ops, > }; > > static int __init triflex_ide_init(void) > -- > 2.27.0 >