Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp3438053pxx; Mon, 2 Nov 2020 08:54:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJx4bwgZ+9Tc92bzMGOxYcifCia/VkA72XGDuUOWaL+cRxap6VXkxoo9N7IQGRQer10WCxkO X-Received: by 2002:aa7:cb8f:: with SMTP id r15mr17681878edt.356.1604336066644; Mon, 02 Nov 2020 08:54:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604336066; cv=none; d=google.com; s=arc-20160816; b=Js+BJfw8bvtiCC1lhdSK5Ba3IkjKu1W5JU+yBHJPTyIKa+3s/khbeQOH+IhICpZvmL 8M+QFFCVpdnbIlamgqfrhjYlNKp+lib/hRZkISgk6ExWz84p+hyoGrD6CO1xwPaG6BgN McfAah8RIXKtyzODTdnsqahENFz+SyZWC296PbgVo3JT52Pc4HdOGGfkrtsSYR7BUgU2 bYOaVdGicrDojYr47ADXf+3hbG05Nz+BadKposbymPKm/OrVD/ny0esvhC6HLtnGK5fP ReMT0vFJNKgEw/tctAwLxM+iw2WYNGxBstF2WtSf7/p5ah+HaYAZo2zWDZbYB3xf7tHd Yddw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZfFrvqo7DqkFljFYrfz490r27HiLjLHSzp/wVexiQxI=; b=BiUUQRPFz4D1EiFhAdrYo7a2J447zf26bpYPR/adwLPo2hp8KccKtAaqiHKlDruxVz BRyLc+qZc3sgDiheAfCXeuC+WHSOV0AAwuP7JPME8vj6Er3RgAcKlaQ/k5NcmvmINafR HyoizLdM1XVKZA3EIJQokJR8ivwgjg9mIrECqeR9Wm+SHfXNobR4wYJUWJqdkJOQiBxv 5HXPaxj1mJHoRLqcaqrZkOdhkFh87JAwv/5Ivlwyo+Nj6GAORO2HO6oETtbeZ2X85aol fNt6vG2sUnxe1Owus2b1E/rvckAVl9C9LkwAso+jmmgOoEwTdh+pIs6zMlb2rAd9KqxC Ya9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="IdnDTo/Z"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w19si5007876edi.177.2020.11.02.08.54.02; Mon, 02 Nov 2020 08:54:26 -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=@gmail.com header.s=20161025 header.b="IdnDTo/Z"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727386AbgKBQwQ (ORCPT + 99 others); Mon, 2 Nov 2020 11:52:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727209AbgKBQwQ (ORCPT ); Mon, 2 Nov 2020 11:52:16 -0500 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47265C0617A6; Mon, 2 Nov 2020 08:52:16 -0800 (PST) Received: by mail-pf1-x442.google.com with SMTP id 13so11607330pfy.4; Mon, 02 Nov 2020 08:52:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZfFrvqo7DqkFljFYrfz490r27HiLjLHSzp/wVexiQxI=; b=IdnDTo/Z15gQQJenXHbz48rYyZ/viY+gIX4WeuWdw9YrvB5qHMPlW9Isvh8v/xjYQI 0kWZQNPsIkfFdOAjHYKP+c03Rh33P4ZJMStTRU1josXmDvOOc1vNyzmuUFxBPB3Qdrc5 ljpB3kLsnIHr0K044vjKgn0TpYJNwEvJt1tPcQgSCiUkMgdXAfiOH5cF9qXnOEKUWD0P hGkzzS9vDdqsfIS15adkZY7sb3CkU/GjCpwUppvlmyAxLmQk0jhk08kZzv2Qr9evE1jI TysSsLBvylG7r7fpMdwCYyLH6l4ofk8UcOAi2WaYRI4+4shSaRYRXhoZ0ONrcbsaK5OE I9sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZfFrvqo7DqkFljFYrfz490r27HiLjLHSzp/wVexiQxI=; b=EnpL0T4Wuv54VK67AsdQdr/VWyY/hdBvaLOgovv2hAr9TgAXJsQY5Z1hiMFmzOyCs0 5LsKd2qsqKtTKQf0UFgKwdI8bde8v4exAHaJ+Y3dVLBg/YJmCmM13omguTDeJJkRyxxe Ep3EJnDJxGuav5hWFQ3Esd4YxwSGOoaW5B3LmCFHTy1w/MX/Q2aMHDqoS51vJGc/+ycP oBU75ZqBxQfrb9VCmc0MUJK/kI8cACK3CI6A8O8C14cDvjLvVr3Gj85GDkBvAbTkc2dY P5zCsWpND9zqI4rP4wRoSXrzBWSsqfEgrD1xLOpn12gViA5OO/FtkCgJJ4t9wwLD8yxb fB5w== X-Gm-Message-State: AOAM530o4Rs5WE/8Tdfi97P2kDZXz3GDm2uDcz/bpufOoeUhXr7NjnCX rP7rGNPuxZ83tAZ892+NkzE= X-Received: by 2002:a17:90a:8b93:: with SMTP id z19mr11878765pjn.123.1604335935795; Mon, 02 Nov 2020 08:52:15 -0800 (PST) Received: from varodek.localdomain ([223.179.149.110]) by smtp.gmail.com with ESMTPSA id t74sm4953233pfc.47.2020.11.02.08.52.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 08:52:15 -0800 (PST) From: Vaibhav Gupta To: Bjorn Helgaas , Bjorn Helgaas , Bjorn Helgaas , Vaibhav Gupta , Adam Radford , "James E.J. Bottomley" , "Martin K. Petersen" , Adaptec OEM Raid Solutions , Hannes Reinecke , Bradley Grove , John Garry , Don Brace , Xiang Chen , James Smart , Dick Kennedy , Kashyap Desai , Sumit Saxena , Shivasharan S , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , Jack Wang , Balsundar P Cc: Vaibhav Gupta , Shuah Khan , linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, linux-scsi@vger.kernel.org, esc.storagedev@microsemi.com, megaraidlinux.pdl@broadcom.com, MPT-FusionLinux.pdl@broadcom.com Subject: [PATCH v4 09/29] scsi: arcmsr: use generic power management Date: Mon, 2 Nov 2020 22:17:10 +0530 Message-Id: <20201102164730.324035-10-vaibhavgupta40@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201102164730.324035-1-vaibhavgupta40@gmail.com> References: <20201102164730.324035-1-vaibhavgupta40@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Drivers should do only device-specific jobs. But in general, drivers using legacy PCI PM framework for .suspend()/.resume() have to manage many PCI PM-related tasks themselves which can be done by PCI Core itself. This brings extra load on the driver and it directly calls PCI helper functions to handle them. Switch to the new generic framework by updating function signatures and define a "struct dev_pm_ops" variable to bind PM callbacks. Also, remove unnecessary calls to the PCI Helper functions along with the legacy .suspend & .resume bindings. Signed-off-by: Vaibhav Gupta --- drivers/scsi/arcmsr/arcmsr_hba.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c index c7ba4cbd197b..907f5af3bbd4 100644 --- a/drivers/scsi/arcmsr/arcmsr_hba.c +++ b/drivers/scsi/arcmsr/arcmsr_hba.c @@ -113,8 +113,8 @@ static int arcmsr_bios_param(struct scsi_device *sdev, static int arcmsr_queue_command(struct Scsi_Host *h, struct scsi_cmnd *cmd); static int arcmsr_probe(struct pci_dev *pdev, const struct pci_device_id *id); -static int arcmsr_suspend(struct pci_dev *pdev, pm_message_t state); -static int arcmsr_resume(struct pci_dev *pdev); +static int __maybe_unused arcmsr_suspend(struct device *dev); +static int __maybe_unused arcmsr_resume(struct device *dev); static void arcmsr_remove(struct pci_dev *pdev); static void arcmsr_shutdown(struct pci_dev *pdev); static void arcmsr_iop_init(struct AdapterControlBlock *acb); @@ -216,13 +216,14 @@ static struct pci_device_id arcmsr_device_id_table[] = { }; MODULE_DEVICE_TABLE(pci, arcmsr_device_id_table); +static SIMPLE_DEV_PM_OPS(arcmsr_pm_ops, arcmsr_suspend, arcmsr_resume); + static struct pci_driver arcmsr_pci_driver = { .name = "arcmsr", .id_table = arcmsr_device_id_table, .probe = arcmsr_probe, .remove = arcmsr_remove, - .suspend = arcmsr_suspend, - .resume = arcmsr_resume, + .driver.pm = &arcmsr_pm_ops, .shutdown = arcmsr_shutdown, }; /* @@ -1126,8 +1127,9 @@ static void arcmsr_free_irq(struct pci_dev *pdev, pci_free_irq_vectors(pdev); } -static int arcmsr_suspend(struct pci_dev *pdev, pm_message_t state) +static int __maybe_unused arcmsr_suspend(struct device *dev) { + struct pci_dev *pdev = to_pci_dev(dev); struct Scsi_Host *host = pci_get_drvdata(pdev); struct AdapterControlBlock *acb = (struct AdapterControlBlock *)host->hostdata; @@ -1140,28 +1142,18 @@ static int arcmsr_suspend(struct pci_dev *pdev, pm_message_t state) flush_work(&acb->arcmsr_do_message_isr_bh); arcmsr_stop_adapter_bgrb(acb); arcmsr_flush_adapter_cache(acb); - pci_set_drvdata(pdev, host); - pci_save_state(pdev); - pci_disable_device(pdev); - pci_set_power_state(pdev, pci_choose_state(pdev, state)); return 0; } -static int arcmsr_resume(struct pci_dev *pdev) +static int __maybe_unused arcmsr_resume(struct device *dev) { + struct pci_dev *pdev = to_pci_dev(dev); struct Scsi_Host *host = pci_get_drvdata(pdev); struct AdapterControlBlock *acb = (struct AdapterControlBlock *)host->hostdata; - pci_set_power_state(pdev, PCI_D0); - pci_restore_state(pdev); - if (pci_enable_device(pdev)) { - pr_warn("%s: pci_enable_device error\n", __func__); - return -ENODEV; - } if (arcmsr_set_dma_mask(acb)) goto controller_unregister; - pci_set_master(pdev); if (arcmsr_request_irq(pdev, acb) == FAILED) goto controller_stop; switch (acb->adapter_type) { @@ -1206,9 +1198,7 @@ static int arcmsr_resume(struct pci_dev *pdev) if (acb->adapter_type == ACB_ADAPTER_TYPE_F) arcmsr_free_io_queue(acb); arcmsr_unmap_pciregion(acb); - pci_release_regions(pdev); scsi_host_put(host); - pci_disable_device(pdev); return -ENODEV; } -- 2.28.0