From patchwork Thu Aug 9 19:41:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10561865 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B2E6113BB for ; Thu, 9 Aug 2018 19:42:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4B6B2B979 for ; Thu, 9 Aug 2018 19:42:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 995012B982; Thu, 9 Aug 2018 19:42:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A70E2B979 for ; Thu, 9 Aug 2018 19:42:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727038AbeHIWIe (ORCPT ); Thu, 9 Aug 2018 18:08:34 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:1352 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726744AbeHIWIe (ORCPT ); Thu, 9 Aug 2018 18:08:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1533843736; x=1565379736; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=FTGqDOhuZEzQvGNsqN5f7CD0NpBd9iVe5zVTm1gzBF4=; b=qmBkPLgcof400BQWKYAOSg1RQyRj/IL2Kdyl4UcLG8y57ei4KepJz6Nh feRljfjtqtiqmj8JHcIahsNmFEQZO+C4QjRRSsucCxOOxH04fR1oaqdsc nbuJfIaHoIHTH9YxEltagGfP8YCYuSFzU3S+yb4RnGmFe22doHM7yviKe N/ZdvkKknNRfbWLb2KYw+5WLfD/9pS1zCoNVrFNvKCxoBCkNsnbU1rDrg 85nLNYEUe3UYLPrVEnRqo8fEEamvosSYysAILJeykeoeooaw9RNE9BtAi acw/0fQn26HoT+jf3nRDMvMUicCbN4Epj3KJZhWM/R4oyKjn7rjB3gwF4 A==; X-IronPort-AV: E=Sophos;i="5.53,215,1531756800"; d="scan'208";a="191119603" Received: from mail-sn1nam01lp0115.outbound.protection.outlook.com (HELO NAM01-SN1-obe.outbound.protection.outlook.com) ([207.46.163.115]) by ob1.hgst.iphmx.com with ESMTP; 10 Aug 2018 03:42:15 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wI+s4MwBrSmy5NNqSWT/DtiAZ5iYPWdEiEdzNNuZvJk=; b=WJ9s0hMm0ayg2ZvFTarrSjXABmZKyBvPvexCjiwBblzyHwC4xC9w/NzU2S4+d0y+wE3DMfbNdWR5TJiFq9fqnsHLt73srjjVBLrPCIuyc3+f7LpCdjYl3zpI6j4VKptmbSnrQIcQQCih414FDoHriPi5CKFEismHUbOI63ZniUY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Bart.VanAssche@wdc.com; Received: from asus.hsd1.ca.comcast.net (174.62.111.89) by MWHPR04MB1198.namprd04.prod.outlook.com (2603:10b6:300:71::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1038.23; Thu, 9 Aug 2018 19:42:09 +0000 From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , "Martin K . Petersen" , Ming Lei , Jianchao Wang , Hannes Reinecke , Johannes Thumshirn , Alan Stern Subject: [PATCH v6 08/12] block, scsi: Introduce blk_pm_runtime_exit() Date: Thu, 9 Aug 2018 12:41:45 -0700 Message-Id: <20180809194149.15285-9-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180809194149.15285-1-bart.vanassche@wdc.com> References: <20180809194149.15285-1-bart.vanassche@wdc.com> MIME-Version: 1.0 X-Originating-IP: [174.62.111.89] X-ClientProxiedBy: MWHPR2201CA0066.namprd22.prod.outlook.com (2603:10b6:301:5e::19) To MWHPR04MB1198.namprd04.prod.outlook.com (2603:10b6:300:71::23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7eef31ac-c1e9-4f5e-9732-08d5fe30328d X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:MWHPR04MB1198; X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;3:rSTZHJRKdhP9Ogut2pMmnIXvzs9OcuZdD6aI5bma781SbudO4GtL9krJifyTOlyb2S6I9iMESx848lc2dmmO8hKKvyGNWkqdtPIa5gpwjdawgqgFOYvdIVJEcXXaTaZuSQnNfRaJ2NXOOB3MuVmCrQFH7MCuIPu7zFZHaeAM5h3bRqaw6cvg2ArlH9nHhsJmxjMlgPHV92YZ3cywoFLxPn3XFWyR2zmybnFPBiYzHlrk8mZ5U73TlSSzEl7BEiX9;25:wZ+dH7aijOapnSd69TijTFc6pVVuRg0k+mS/rDasGzaDWFLhYtXnwGHyo2ZlmhI+BpcmRupTQcetNAT2M/eXO/grYdGTMtpyyDU/3X1jtl8i/7uiI1Had52oH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tnuwivcbSJ3NonQSIkL4kZbFLMPMeHyfu1tYZdDCTak3VbeAlvz8+U6rsb15S6u1+U/MflV+dptkDI7rhlD79uxaLfEimjeYkK4tF+gywvTLHTkRYo5bGitUoRsgQi/8wAbJqcAPSNIvVfgTzNKrcX0omFeJpQJPJxtjJzZhnc9F+MrCuj6mctIZPxDQRdV/iF/4GuQV7ANa7J4Q0PXsy/4LiWTyyXhia0PHw5LPUHML72MATk0GwsXV7kqjpgqAD28hTU19deMgu5S7EPFQh3P6kjr9ArpadPcOEkSC5WrQeMQkRGDRnAedPwLiepE8G9y6hpX9C+7ku2HOcxauCIt+/j+2u3m1KHmI= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(35762410373642)(146099531331640); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231311)(944501410)(52105095)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(6072148)(201708071742011)(7699016);SRVR:MWHPR04MB1198;BCL:0;PCL:0;RULEID:;SRVR:MWHPR04MB1198; X-Forefront-PRVS: 0759F7A50A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(396003)(39860400002)(136003)(366004)(346002)(376002)(199004)(189003)(76176011)(50466002)(476003)(51416003)(4326008)(478600001)(52116002)(6486002)(105586002)(72206003)(48376002)(5660300001)(47776003)(305945005)(2616005)(956004)(7736002)(6916009)(6666003)(486006)(8936002)(2906002)(68736007)(36756003)(66066001)(186003)(446003)(81166006)(50226002)(8676002)(81156014)(316002)(6506007)(386003)(106356001)(97736004)(25786009)(11346002)(16586007)(54906003)(14444005)(6116002)(1076002)(3846002)(86362001)(26005)(16526019)(53936002)(6512007);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR04MB1198;H:asus.h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P3iecA42NOnjksc7wRDeFMOyWlp0mxZD3fGEtbiOsVKzsXZ8mUxYGV/KtI+cD6IcdcKdEI/KpjRA5YXHcQ/c8GZVYppA==;5:zO32Fma1dK8kT4MBJryTXcoSqb2ksCYjkSWvL0I/BVlqjXR+4pZJh0uz9ujX8Ao97l6pDaqy7QcN02gRgODJv0EnMeqUbsH3q9HY5dTmTY0UZTnsonkn2Y2tRiUyJ66vlKoR72oz4fdpNanFmuROMQUzMOewT8Gu3/EmphnwMME=;7:DjC00PLDUnBMvbGH6eh6PqeSCnPjK2RJar2W9QjUd1rwyCdI3/03Cffi6RwTasXkjmhl3PcYobzfEN2poUQojcL1TTeYGHwnDVdf5EiflmyXGbsqJVZk/zxPY85Dp/62jO+/A1Ru4bQsaufKVwimy1MXOqPvdtQKa6TXSaa/2k9hNKn9Zngw+YU9qTGoOh3QsjcTTBbjR0e2+z9bPdv/szVdWpYrMjmdKrBRV7pjNTDQ370r7AaXiBxrjhe9x7Bx SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;20:x8rmQRP9kVp/zJ/eqjDtUm5DXRA/6z4G4vBV5TQidbRBM8vQmtO7FhEbRYA86IHYkvZOn2tdA82jaxcAolPhLzjkeP5/SmBfF2wfWCg+EHBUFGZg2Uaw+yiyVQKagtuIygmHTHqWeBP/eTAcRL/1Bg7MkJg2DandelIF68suaIE= X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2018 19:42:09.8815 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7eef31ac-c1e9-4f5e-9732-08d5fe30328d X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB1198 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since it is possible to unbind a SCSI ULD and since unbinding removes the association between a request queue and struct device, the q->dev pointer has to be reset during unbind. Hence introduce a function in the block layer that clears request_queue.dev. Signed-off-by: Bart Van Assche Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: Ming Lei Cc: Jianchao Wang Cc: Hannes Reinecke Cc: Johannes Thumshirn Cc: Alan Stern --- block/blk-pm.c | 18 ++++++++++++++++++ drivers/scsi/sd.c | 9 ++++----- drivers/scsi/sr.c | 3 ++- include/linux/blk-pm.h | 2 ++ 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/block/blk-pm.c b/block/blk-pm.c index 9b636960d285..bf8532da952d 100644 --- a/block/blk-pm.c +++ b/block/blk-pm.c @@ -40,6 +40,24 @@ void blk_pm_runtime_init(struct request_queue *q, struct device *dev) } EXPORT_SYMBOL(blk_pm_runtime_init); +/** + * blk_pm_runtime_exit - runtime PM exit routine + * @q: the queue of the device + * + * This function should be called from the device_driver.remove() callback + * function to avoid that further calls to runtime power management functions + * occur. + */ +void blk_pm_runtime_exit(struct request_queue *q) +{ + if (!q->dev) + return; + + pm_runtime_get_sync(q->dev); + q->dev = NULL; +} +EXPORT_SYMBOL(blk_pm_runtime_exit); + /** * blk_pre_runtime_suspend - Pre runtime suspend check * @q: the queue of the device diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 69ab459abb98..5537762dfcfd 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -3420,12 +3420,11 @@ static int sd_probe(struct device *dev) **/ static int sd_remove(struct device *dev) { - struct scsi_disk *sdkp; - dev_t devt; + struct scsi_disk *sdkp = dev_get_drvdata(dev); + struct scsi_device *sdp = sdkp->device; + dev_t devt = disk_devt(sdkp->disk); - sdkp = dev_get_drvdata(dev); - devt = disk_devt(sdkp->disk); - scsi_autopm_get_device(sdkp->device); + blk_pm_runtime_exit(sdp->request_queue); async_synchronize_full_domain(&scsi_sd_pm_domain); async_synchronize_full_domain(&scsi_sd_probe_domain); diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index de4413e66eca..476987f7ed48 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -1002,8 +1002,9 @@ static void sr_kref_release(struct kref *kref) static int sr_remove(struct device *dev) { struct scsi_cd *cd = dev_get_drvdata(dev); + struct scsi_device *sdev = cd->device; - scsi_autopm_get_device(cd->device); + blk_pm_runtime_exit(sdev->request_queue); del_gendisk(cd->disk); dev_set_drvdata(dev, NULL); diff --git a/include/linux/blk-pm.h b/include/linux/blk-pm.h index b80c65aba249..6d654f41acbf 100644 --- a/include/linux/blk-pm.h +++ b/include/linux/blk-pm.h @@ -11,6 +11,7 @@ struct request_queue; */ #ifdef CONFIG_PM extern void blk_pm_runtime_init(struct request_queue *q, struct device *dev); +extern void blk_pm_runtime_exit(struct request_queue *q); extern int blk_pre_runtime_suspend(struct request_queue *q); extern void blk_post_runtime_suspend(struct request_queue *q, int err); extern void blk_pre_runtime_resume(struct request_queue *q); @@ -19,6 +20,7 @@ extern void blk_set_runtime_active(struct request_queue *q); #else static inline void blk_pm_runtime_init(struct request_queue *q, struct device *dev) {} +static inline void blk_pm_runtime_exit(struct request_queue *q) {} #endif #endif /* _BLK_PM_H_ */