From patchwork Tue Oct 2 21:52:21 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: 10624111 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 05800112B for ; Tue, 2 Oct 2018 21:53:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC9F92842E for ; Tue, 2 Oct 2018 21:53:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E0581284C3; Tue, 2 Oct 2018 21:53:05 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 33F4D284BD for ; Tue, 2 Oct 2018 21:53:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727470AbeJCEib (ORCPT ); Wed, 3 Oct 2018 00:38:31 -0400 Received: from com-out001.mailprotect.be ([83.217.72.83]:39185 "EHLO com-out001.mailprotect.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727051AbeJCEib (ORCPT ); Wed, 3 Oct 2018 00:38:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mailprotect.be; s=mail; h=Content-Transfer-Encoding:MIME-Version:References :In-Reply-To:Message-Id:Date:Subject:Cc:To:From:reply-to:sender:bcc: content-type; bh=IoZ0yDI1tEkSO/mrhJt6EY8s3xGDytg/bJjAg57fecM=; b=qdP1zOV0A9NR +uCoWobgUg7nFhvyqRCbV6pLdmJGW/DEm/DhHpRgzZPsJ/GAfoAcRj9vlWhOrRxCtP0aRq6u1bodu S9ZuklVur3BaFouyDai5xDB2HwzN7er0sR9Ly5QCkuGdh9oBhHS+e9JcB+blunvoJBfwTFG8R9k8Q 98tH+yQ/uwy7punkP1lKUckvAscxDp5m5xWTlIRwybBCeWYsPIvYs0VmSjBprjBu9aNPNv8g2acfM 96mQhB+ysLj1wG2GjbLz1cTnizLl3HpfP4rr6z6rn8Jruq11TZ3IA6cz1jA6z9hlMmbN1C2c/CKLv DurDM48hGwIHQ7DNbDb4kA==; Received: from smtp-auth.mailprotect.be ([178.208.39.159]) by com-mpt-out001.mailprotect.be with esmtp (Exim 4.89) (envelope-from ) id 1g7Sb8-0005rg-Ao; Tue, 02 Oct 2018 23:52:55 +0200 Received: from desktop-bart.svl.corp.google.com (unknown [104.133.8.89]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-auth.mailprotect.be (Postfix) with ESMTPSA id CFA05C083F; Tue, 2 Oct 2018 23:52:37 +0200 (CEST) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: Greg Kroah-Hartman , linux-scsi@vger.kernel.org, Bart Van Assche , Lee Duncan , Hannes Reinecke , "Luis R . Rodriguez" , Johannes Thumshirn , Christoph Hellwig , Dan Williams Subject: [PATCH 1/3] sd: Rely on the driver core for asynchronous probing Date: Tue, 2 Oct 2018 14:52:21 -0700 Message-Id: <20181002215223.20453-2-bvanassche@acm.org> X-Mailer: git-send-email 2.19.0.605.g01d371f741-goog In-Reply-To: <20181002215223.20453-1-bvanassche@acm.org> References: <20181002215223.20453-1-bvanassche@acm.org> MIME-Version: 1.0 X-Originating-IP: 178.208.39.159 X-SpamExperts-Domain: mailprotect.be X-SpamExperts-Username: 178.208.39.128/27 Authentication-Results: mailprotect.be; auth=pass smtp.auth=178.208.39.128/27@mailprotect.be X-SpamExperts-Outgoing-Class: ham X-SpamExperts-Outgoing-Evidence: Combined (0.02) X-Recommended-Action: accept X-Filter-ID: EX5BVjFpneJeBchSMxfU5u4KKnDwIBXhdqCXmUce0ol602E9L7XzfQH6nu9C/Fh9KJzpNe6xgvOx q3u0UDjvO1tLifGj39bI0bcPyaJsYTYNm2CNnybH8Z43FgPbC84O3ZxZNfM5cTi57zK3AqpgNcoO PyblUynZwrqUCKNcljDHE/hYIs/aHNUuIwb7SjgQPO/eQCu9DiexVBKEhByP5hPU9BAZnc/6CQ8u a1Kug/vENTpIdjQa+bDLgV2pJpwZbf+d6jbd50mb3x+iLQGEQN7b2Qwpf+cSpB4glJ0StFqPbvZZ jgEC9TXuKwUltrytgQajdYLZBs+zl0KgirvswAIB0NPuvzJT3SoMSsr90J5jfrtmIc2rcurQoTex GeOaWX0rFUkZY1q9HWL493U67NGrS6shIra2wT1zD38ahxnSmjfFbNU8e1OC+I8UOz1LaDHS6EWk b+lOY31GMvsQCRiSseS9Z+zN0GFPZTKqcMpVr8eP+Wmp/y/AB2KysgGDDIUInf3bUsYMkexVuAzt 9i8/3bImoUNQxaBiRh+ELzQyy8zBCqPgxBTsX5U0EJrI+XFCcaxlnn5Bh6cz2w02feZFd0KZzJMv qaG6kv+Eofz8RMlTmXCaCY65NM6WG+LyQFBM8N0u16/t060gI+DwqomqCx/0p+FjaFg3Pr9LUs3J NoOpzWFnZHKQmAJ5pDYOitrIO34VOsVjKe3B18D+0JzQcybi/Bq9XEjnTw/vJFJ7Ea2lz3/HBrmn EJ1Tnk7CZyCgxZHINA6A5+7T9o6by8qImGMMpDIVsmDhn0vgT3DgH8zBUONR4WIY3+fLS9LjehIq UczFWeS6sE8e1b5/Utgqopo2358Leb1g46x7zKJM/chyQ5omY1b9UD1TqczzowsJ2ZYst9G+SIsZ 6ZwemLqxAMscC/7jvexe3kuEjJwHmFDqewO9xyOqCYO8P1aHuxjor5UwReHD5FcHVq9QgeVswkQE MDBDlsQ/lh0/HwOCGSmS3tEUeT+iAIucwxOrT7l+WPDExal/gfTKvDy//jA0XAoGECHs14pjPDDB gamWGPX0gawEUVFdc0MiGyqzTxHVCGNqcCz4LkbLwwqmTnSvb9lhfMTifrWWO6aeL/ecP2aXNQQm DC/BDdJwoSfSz/ebPtYZNS26ynq7o1B2EG7yGdUwA+FuRt3JzotZUg8nBy/PpUxgSFRPcWxJF+/b D2aQS4wqfZ3VTbQjI+ei5ZIwtV+bnbyOsdXtXElgqpUdf68W0InH/+bTMKNm38MHgLBpRNP/8fWa l4jpKHfTV6kmOUYRlYmbBA7+9eEYSXrC1A3JmhnAF3egdCRAe7jxMS+4ayUpOtEhdxekWDmK9g== X-Report-Abuse-To: spam@com-mpt-mgt001.mailprotect.be Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As explained during the LSF/MM session about increasing SCSI disk probing concurrency, the problems with the current probing approach are as follows: - The driver core is unaware of asynchronous SCSI LUN probing. wait_for_device_probe() waits for all asynchronous probes except asynchronous SCSI disk probes. - There is unnecessary serialization between sd_probe() and sd_remove(). This can lead to a deadlock. Hence this patch that modifies the sd driver such that it uses the driver core framework for asynchronous probing. The async domains and get_device()/put_device() pairs that became superfluous due to this change are removed. See also commit 3c31b52f96f7 ("scsi: async sd resume"). Signed-off-by: Bart Van Assche Cc: Lee Duncan Cc: Hannes Reinecke Cc: Luis R. Rodriguez Cc: Johannes Thumshirn Cc: Christoph Hellwig Cc: Greg Kroah-Hartman Cc: Dan Williams --- drivers/scsi/scsi.c | 14 -------------- drivers/scsi/scsi_pm.c | 22 ++-------------------- drivers/scsi/scsi_priv.h | 3 --- drivers/scsi/sd.c | 13 +++---------- 4 files changed, 5 insertions(+), 47 deletions(-) diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index fc1356d101b0..1205369ad44f 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -85,19 +85,6 @@ unsigned int scsi_logging_level; EXPORT_SYMBOL(scsi_logging_level); #endif -/* sd, scsi core and power management need to coordinate flushing async actions */ -ASYNC_DOMAIN(scsi_sd_probe_domain); -EXPORT_SYMBOL(scsi_sd_probe_domain); - -/* - * Separate domain (from scsi_sd_probe_domain) to maximize the benefit of - * asynchronous system resume operations. It is marked 'exclusive' to avoid - * being included in the async_synchronize_full() that is invoked by - * dpm_resume() - */ -ASYNC_DOMAIN_EXCLUSIVE(scsi_sd_pm_domain); -EXPORT_SYMBOL(scsi_sd_pm_domain); - /** * scsi_put_command - Free a scsi command block * @cmd: command block to free @@ -839,7 +826,6 @@ static void __exit exit_scsi(void) scsi_exit_devinfo(); scsi_exit_procfs(); scsi_exit_queue(); - async_unregister_domain(&scsi_sd_probe_domain); } subsys_initcall(init_scsi); diff --git a/drivers/scsi/scsi_pm.c b/drivers/scsi/scsi_pm.c index b44c1bb687a2..f229208bfef3 100644 --- a/drivers/scsi/scsi_pm.c +++ b/drivers/scsi/scsi_pm.c @@ -54,9 +54,6 @@ static int scsi_dev_type_suspend(struct device *dev, const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; int err; - /* flush pending in-flight resume operations, suspend is synchronous */ - async_synchronize_full_domain(&scsi_sd_pm_domain); - err = scsi_device_quiesce(to_scsi_device(dev)); if (err == 0) { err = cb(dev, pm); @@ -149,18 +146,7 @@ static int scsi_bus_resume_common(struct device *dev, if (scsi_is_sdev_device(dev) && pm_runtime_suspended(dev)) blk_set_runtime_active(to_scsi_device(dev)->request_queue); - if (fn) { - async_schedule_domain(fn, dev, &scsi_sd_pm_domain); - - /* - * If a user has disabled async probing a likely reason - * is due to a storage enclosure that does not inject - * staggered spin-ups. For safety, make resume - * synchronous as well in that case. - */ - if (strncmp(scsi_scan_type, "async", 5) != 0) - async_synchronize_full_domain(&scsi_sd_pm_domain); - } else { + if (!fn) { pm_runtime_disable(dev); pm_runtime_set_active(dev); pm_runtime_enable(dev); @@ -170,11 +156,7 @@ static int scsi_bus_resume_common(struct device *dev, static int scsi_bus_prepare(struct device *dev) { - if (scsi_is_sdev_device(dev)) { - /* sd probing uses async_schedule. Wait until it finishes. */ - async_synchronize_full_domain(&scsi_sd_probe_domain); - - } else if (scsi_is_host_device(dev)) { + if (scsi_is_host_device(dev)) { /* Wait until async scanning is finished */ scsi_complete_async_scans(); } diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h index 99f1db5e467e..b9fa363b4bbb 100644 --- a/drivers/scsi/scsi_priv.h +++ b/drivers/scsi/scsi_priv.h @@ -175,9 +175,6 @@ static inline int scsi_autopm_get_host(struct Scsi_Host *h) { return 0; } static inline void scsi_autopm_put_host(struct Scsi_Host *h) {} #endif /* CONFIG_PM */ -extern struct async_domain scsi_sd_pm_domain; -extern struct async_domain scsi_sd_probe_domain; - /* scsi_dh.c */ #ifdef CONFIG_SCSI_DH void scsi_dh_add_device(struct scsi_device *sdev); diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 4a57ffecc7e6..48a133a3aab8 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -559,6 +559,7 @@ static struct scsi_driver sd_template = { .name = "sd", .owner = THIS_MODULE, .probe = sd_probe, + .probe_type = PROBE_PREFER_ASYNCHRONOUS, .remove = sd_remove, .shutdown = sd_shutdown, .pm = &sd_pm_ops, @@ -3231,12 +3232,8 @@ static int sd_format_disk_name(char *prefix, int index, char *buf, int buflen) return 0; } -/* - * The asynchronous part of sd_probe - */ -static void sd_probe_async(void *data, async_cookie_t cookie) +static void sd_probe_part2(struct scsi_disk *sdkp) { - struct scsi_disk *sdkp = data; struct scsi_device *sdp; struct gendisk *gd; u32 index; @@ -3290,7 +3287,6 @@ static void sd_probe_async(void *data, async_cookie_t cookie) sd_printk(KERN_NOTICE, sdkp, "Attached SCSI %sdisk\n", sdp->removable ? "removable " : ""); scsi_autopm_put_device(sdp); - put_device(&sdkp->dev); } /** @@ -3382,8 +3378,7 @@ static int sd_probe(struct device *dev) get_device(dev); dev_set_drvdata(dev, sdkp); - get_device(&sdkp->dev); /* prevent release before async_schedule */ - async_schedule_domain(sd_probe_async, sdkp, &scsi_sd_probe_domain); + sd_probe_part2(sdkp); return 0; @@ -3418,8 +3413,6 @@ static int sd_remove(struct device *dev) devt = disk_devt(sdkp->disk); scsi_autopm_get_device(sdkp->device); - async_synchronize_full_domain(&scsi_sd_pm_domain); - async_synchronize_full_domain(&scsi_sd_probe_domain); device_del(&sdkp->dev); del_gendisk(sdkp->disk); sd_shutdown(dev); From patchwork Tue Oct 2 21:52:22 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: 10624113 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 A75CD112B for ; Tue, 2 Oct 2018 21:53:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9AC32284C3 for ; Tue, 2 Oct 2018 21:53:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D618284C4; Tue, 2 Oct 2018 21:53:06 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 17EA02842E for ; Tue, 2 Oct 2018 21:53:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727511AbeJCEic (ORCPT ); Wed, 3 Oct 2018 00:38:32 -0400 Received: from com-out001.mailprotect.be ([83.217.72.83]:43975 "EHLO com-out001.mailprotect.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726162AbeJCEib (ORCPT ); Wed, 3 Oct 2018 00:38:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mailprotect.be; s=mail; h=Content-Transfer-Encoding:MIME-Version:References :In-Reply-To:Message-Id:Date:Subject:Cc:To:From:reply-to:sender:bcc: content-type; bh=yCNwRnTUU+PXWQqeKlOoBbFWVIkG5hvD+CeEOa/+AME=; b=RZqGkfEznVvw JGWRZRCc78B0Tta1odLAcxm4f+ScGXfMLYjQmxlHVj8Pcm6eb2SsVv+V7B//ol92q9Q6BkYCLo9pu STrDWaTWycXU4xfPz0709gQHTBx6MzPpRnKPOeLrRMZSBKZmCqGMnAsZunpWn8YuQMx8mxgrtP5Xx BTPYquWH9GMgnsgrnh+0poKP4/tKUBH/wAEiY4PIIq/Ojk8IZUmVrvn0RLjmG1j9buI4q+jOSXtb+ 4hC12bvs/NN/AQj5pg1wvFSDXGfQWFaE0UuYJ4eaqFCbkI2E4mu3fRMBCkCf7ntZewhffmRu/to9D WN3mK3R+u8WBB/bhwnomQQ==; Received: from smtp-auth.mailprotect.be ([178.208.39.159]) by com-mpt-out001.mailprotect.be with esmtp (Exim 4.89) (envelope-from ) id 1g7Sb9-0005s2-MZ; Tue, 02 Oct 2018 23:52:56 +0200 Received: from desktop-bart.svl.corp.google.com (unknown [104.133.8.89]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-auth.mailprotect.be (Postfix) with ESMTPSA id 55768C08FC; Tue, 2 Oct 2018 23:52:40 +0200 (CEST) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: Greg Kroah-Hartman , linux-scsi@vger.kernel.org, Bart Van Assche , Lee Duncan , Hannes Reinecke , "Luis R . Rodriguez" , Johannes Thumshirn , Christoph Hellwig Subject: [PATCH 2/3] sd: Inline sd_probe_part2() Date: Tue, 2 Oct 2018 14:52:22 -0700 Message-Id: <20181002215223.20453-3-bvanassche@acm.org> X-Mailer: git-send-email 2.19.0.605.g01d371f741-goog In-Reply-To: <20181002215223.20453-1-bvanassche@acm.org> References: <20181002215223.20453-1-bvanassche@acm.org> MIME-Version: 1.0 X-Originating-IP: 178.208.39.159 X-SpamExperts-Domain: mailprotect.be X-SpamExperts-Username: 178.208.39.128/27 Authentication-Results: mailprotect.be; auth=pass smtp.auth=178.208.39.128/27@mailprotect.be X-SpamExperts-Outgoing-Class: ham X-SpamExperts-Outgoing-Evidence: Combined (0.03) X-Recommended-Action: accept X-Filter-ID: EX5BVjFpneJeBchSMxfU5ieSNIzJlEVl14BTMaMXkpt602E9L7XzfQH6nu9C/Fh9KJzpNe6xgvOx q3u0UDjvO1tLifGj39bI0bcPyaJsYTbBu5YFz4Jx0uq4149LpZwrkOR4/HajlzkVhakIw7Ig6cwd ucx0/hy6ghJki+KFMutdPFg736Hj4qCv9Wq9HmRLo3CYqeHmXS+8iJmp2wA0RYr53oorwUmj6U9o RHQGd3MYhv5ncN4aXTpV27LuhaKEJ0WYXEkavZ0SiS9W+onrEQcSH5+zf0CUeH8og9mFu6jSI9i6 mVSi/9/XpXGW1ju2Hp2CPzwbIONgnB65PTfUbNabA83L2bxWgLDcSJYE06EO+9AvCULu7v2wEBQm NVUBhVQzrifUJXmdKLiwkyJfcpzptsBSygmEGxdKaV71syZaa40DxZPJuLUk3zkVKd8pPJaf7i3w vxgaUQ1edo9GTkTpqUvIflo8smhAh+RmL8DQrQo5+sEgxwQHvcyA2kX0ycfPn82Vg1/La2h31XFV jHGsgWpTMzYkIviGj+iKd5fvZYYFy7zBFkwpn1jw15t9+3q8ix/gk0ncNNOp8G0HNaJBMNnyTIeK fUmiVfXF6aSshIp2TVapwrpjl0CBfPzmiSrlgXUe2FRrt3Q/saIuuxKN1jTioj2Vkh+jtBHn5QkU VgCEoGhSx+dc5wLN1Ls2Dm68l5/yZWpvNsat32R+M/xcb3XRuJkRyiZZ6HPi7yzMODodi5MLJiAv rVIiQFNhcJkH/XIBVIHRSdAUlc73GeHsTCU1tXES7goCkbhuJrdzIbhVr9Z3LIDH3wGQUZ4UlBHd 2wJ53rPs265wcrWXIr60yLzVihg3Po1XDUMMxmDEHaQQyEsw7lw15KLqrrJUZ9ZL+s9v8wLkvp69 3LknIAtAJHHBwuXpxJpVcXL1FXhDe2D6nYjUPvBPULo52BbY9qSf4fy7RZrSss1TmRNP+df05hmP GRjPPkl/w9cp3+jBRBZgCikvOAMF/4pY8933J6oZFkdmboZrJXcGZFXRxBmEWxN7wSYQOZhJUXhp E7Fh+eWLxUNB2EvXpmRb3Nspc/1r1ahBSpNG7qxOQB127abziDTOtQTjAmzp739EHWrDqcigOvSx dRnthmhn8Zn6IHsUgbZnPaZbS7o/lw0U/vv85zryNFx6XnviEN9buaDeNHk15VolAGHS5rCXQKDy V6n3MjFcR0EJCsIWrcCYM7I0q854skGDr1SFWz9TrEb+t+0tXG/ZiXpkIVPnC3hDyTcjq8HMRYhm G6FDb9wWn+NvPKHiEjTsbQQc4NYDfB8= X-Report-Abuse-To: spam@com-mpt-mgt001.mailprotect.be Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch does not change any functionality. Signed-off-by: Bart Van Assche Cc: Lee Duncan Cc: Hannes Reinecke Cc: Luis R. Rodriguez Cc: Johannes Thumshirn Cc: Christoph Hellwig Cc: Greg Kroah-Hartman --- drivers/scsi/sd.c | 101 ++++++++++++++++++++-------------------------- 1 file changed, 43 insertions(+), 58 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 48a133a3aab8..93732f1fb551 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -3232,63 +3232,6 @@ static int sd_format_disk_name(char *prefix, int index, char *buf, int buflen) return 0; } -static void sd_probe_part2(struct scsi_disk *sdkp) -{ - struct scsi_device *sdp; - struct gendisk *gd; - u32 index; - struct device *dev; - - sdp = sdkp->device; - gd = sdkp->disk; - index = sdkp->index; - dev = &sdp->sdev_gendev; - - gd->major = sd_major((index & 0xf0) >> 4); - gd->first_minor = ((index & 0xf) << 4) | (index & 0xfff00); - - gd->fops = &sd_fops; - gd->private_data = &sdkp->driver; - gd->queue = sdkp->device->request_queue; - - /* defaults, until the device tells us otherwise */ - sdp->sector_size = 512; - sdkp->capacity = 0; - sdkp->media_present = 1; - sdkp->write_prot = 0; - sdkp->cache_override = 0; - sdkp->WCE = 0; - sdkp->RCD = 0; - sdkp->ATO = 0; - sdkp->first_scan = 1; - sdkp->max_medium_access_timeouts = SD_MAX_MEDIUM_TIMEOUTS; - - sd_revalidate_disk(gd); - - gd->flags = GENHD_FL_EXT_DEVT; - if (sdp->removable) { - gd->flags |= GENHD_FL_REMOVABLE; - gd->events |= DISK_EVENT_MEDIA_CHANGE; - } - - blk_pm_runtime_init(sdp->request_queue, dev); - device_add_disk(dev, gd); - if (sdkp->capacity) - sd_dif_config_host(sdkp); - - sd_revalidate_disk(gd); - - if (sdkp->security) { - sdkp->opal_dev = init_opal_dev(sdp, &sd_sec_submit); - if (sdkp->opal_dev) - sd_printk(KERN_NOTICE, sdkp, "supports TCG Opal\n"); - } - - sd_printk(KERN_NOTICE, sdkp, "Attached SCSI %sdisk\n", - sdp->removable ? "removable " : ""); - scsi_autopm_put_device(sdp); -} - /** * sd_probe - called during driver initialization and whenever a * new scsi device is attached to the system. It is called once @@ -3378,7 +3321,49 @@ static int sd_probe(struct device *dev) get_device(dev); dev_set_drvdata(dev, sdkp); - sd_probe_part2(sdkp); + gd->major = sd_major((index & 0xf0) >> 4); + gd->first_minor = ((index & 0xf) << 4) | (index & 0xfff00); + + gd->fops = &sd_fops; + gd->private_data = &sdkp->driver; + gd->queue = sdkp->device->request_queue; + + /* defaults, until the device tells us otherwise */ + sdp->sector_size = 512; + sdkp->capacity = 0; + sdkp->media_present = 1; + sdkp->write_prot = 0; + sdkp->cache_override = 0; + sdkp->WCE = 0; + sdkp->RCD = 0; + sdkp->ATO = 0; + sdkp->first_scan = 1; + sdkp->max_medium_access_timeouts = SD_MAX_MEDIUM_TIMEOUTS; + + sd_revalidate_disk(gd); + + gd->flags = GENHD_FL_EXT_DEVT; + if (sdp->removable) { + gd->flags |= GENHD_FL_REMOVABLE; + gd->events |= DISK_EVENT_MEDIA_CHANGE; + } + + blk_pm_runtime_init(sdp->request_queue, dev); + device_add_disk(dev, gd); + if (sdkp->capacity) + sd_dif_config_host(sdkp); + + sd_revalidate_disk(gd); + + if (sdkp->security) { + sdkp->opal_dev = init_opal_dev(sdp, &sd_sec_submit); + if (sdkp->opal_dev) + sd_printk(KERN_NOTICE, sdkp, "supports TCG Opal\n"); + } + + sd_printk(KERN_NOTICE, sdkp, "Attached SCSI %sdisk\n", + sdp->removable ? "removable " : ""); + scsi_autopm_put_device(sdp); return 0; From patchwork Tue Oct 2 21:52:23 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: 10624115 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 BB548174E for ; Tue, 2 Oct 2018 21:53:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0C202842E for ; Tue, 2 Oct 2018 21:53:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A4E97284CE; Tue, 2 Oct 2018 21:53:06 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 3A27F284BD for ; Tue, 2 Oct 2018 21:53:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727645AbeJCEic (ORCPT ); Wed, 3 Oct 2018 00:38:32 -0400 Received: from com-out001.mailprotect.be ([83.217.72.83]:42019 "EHLO com-out001.mailprotect.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727120AbeJCEic (ORCPT ); Wed, 3 Oct 2018 00:38:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mailprotect.be; s=mail; h=Content-Transfer-Encoding:MIME-Version:References :In-Reply-To:Message-Id:Date:Subject:Cc:To:From:reply-to:sender:bcc: content-type; bh=tPtP90mAvqTXNilJ+IY9oaoanPkb5+qff4CcAN6UAYw=; b=u9yEku0riM/R RPsbuSGvv7uHcuacrCdkOi8mjcPLwl2OwKa0gYLYAa2s+NcFP85yjl+h6MNVJi4e4ckQcNPvnQBmO RhPNtyYqYreNcWWw9ZjcRORvQcZSL//VH8RIE1cM0G/iHM1qHuxqfLLRbxhnWX75ZqRk8ojQ+h5rN dWEDHhJ6BiCS/ZC9gvoLNovroKfGjKNXD7mE0GHgenFhJ2DZ5pYKit7r2DEILI/D2YAVH9mYlp2HY G/VQhfpJv/XerLAhscKmcDi9uwgcdi6MVJpe6IcNZJiXHdhmzv7iii1aYPHWJPHfXpLnFQ6w/FcqC j2HTpIYr46HwstkC5xkFng==; Received: from smtp-auth.mailprotect.be ([178.208.39.159]) by com-mpt-out001.mailprotect.be with esmtp (Exim 4.89) (envelope-from ) id 1g7SbA-0005sS-SL; Tue, 02 Oct 2018 23:52:57 +0200 Received: from desktop-bart.svl.corp.google.com (unknown [104.133.8.89]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-auth.mailprotect.be (Postfix) with ESMTPSA id CF50CC0993; Tue, 2 Oct 2018 23:52:42 +0200 (CEST) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" Cc: Greg Kroah-Hartman , linux-scsi@vger.kernel.org, Bart Van Assche , Dmitry Torokhov , Lee Duncan , Hannes Reinecke , "Luis R . Rodriguez" , Johannes Thumshirn , Christoph Hellwig Subject: [PATCH 3/3] __device_release_driver(): Do not wait for asynchronous probing Date: Tue, 2 Oct 2018 14:52:23 -0700 Message-Id: <20181002215223.20453-4-bvanassche@acm.org> X-Mailer: git-send-email 2.19.0.605.g01d371f741-goog In-Reply-To: <20181002215223.20453-1-bvanassche@acm.org> References: <20181002215223.20453-1-bvanassche@acm.org> MIME-Version: 1.0 X-Originating-IP: 178.208.39.159 X-SpamExperts-Domain: mailprotect.be X-SpamExperts-Username: 178.208.39.128/27 Authentication-Results: mailprotect.be; auth=pass smtp.auth=178.208.39.128/27@mailprotect.be X-SpamExperts-Outgoing-Class: ham X-SpamExperts-Outgoing-Evidence: Combined (0.10) X-Recommended-Action: accept X-Filter-ID: EX5BVjFpneJeBchSMxfU5v+dIcaiJjxNz7zPmthHez9602E9L7XzfQH6nu9C/Fh9KJzpNe6xgvOx q3u0UDjvO1tLifGj39bI0bcPyaJsYTaCQjdSsHpHMseLvUQlcpDDrIqJ/wLUx19wF/fxIORoJewh lZEvvn2u39DR6ZeNzaenSaG7VHjC82dfVIjfDwsu7F0C+NK/wP6emrQEJ4mnBHoBGkq9ZeygGIuq EWWFe6nouI7dxbuZk8vLuXoJeaU5/5KzUg+Sn2tF6yHMTQ3Cr381QvhbKVRCA7YJ/hutEh+eA1Rh ERa/RcGunIiZlUN5kwI4edySG+m3KfoEca33dWlvcl2FIgemOOES4PyD4YuOeINNvrqnumqdNL2j 8R2D6C0HENvu68rf9YWInWopYX8Cjtc/AM8Z2WBeJ4coXf5DOFwoskLzFowa7AUCGN/ZhIMtzuO3 O+FDnkg1vDC9jSTg127TqHZDxA/kZB41Rh+Y+jJ/epVKdcq5/jWq4wImcHohaDSdj88G1xD/5DwD ws2wWVbjHO/cpJpsYlvFhM88EEtin807fzyYSqzUT6AES8KWaecotq4zBypQ19eU2Ok4y6YDwTij uwPHJVDAZbVwEIQwpWnmd/Rv5auZkQm+GfRMt75iNz3/C8o9KhT3TCI//y6jO2DOGTu2o2VRUt6B k1gABXukuKLgxSuEH5ByPKqpjSsBOnMcoZ+a02xhOvhKYNn9sZbzFkJFGzpkPbgbNE9dFPkOdyDT LZ+/0cd3HX+vFtCJx//m0zCjZt/DB/Hkx5RhBiSYf/dDZx/qjNL22iM6OMIRw3JvhQ64u5fjKTjE Cb0PwpN4olPuA0AI90OUvPEZQSa0gxqHMi4keVUAoMMKBawL6fapf4z9fCjg7id0jk32JS/0VmWF 1IOrybyB3DBQoMdi9px0D4XNJOkrRpAwEh9tW1/OBrKjsFbYsC1Z9dw/UzpEuOsNmdOzL7dfmvow GnVnOL32nUz4qsqO65IPZufpEn5cU7JmBdUxA5lreQNG2aEZo8nURcWzPRmok11u89pTKgJ27pjs IdJuW1mwt9WjK+0BDexEqT40Hd/EA17matbkn+37ntACNv0a2ybDhkpebUyHJSBRX3b7MEP8gFgZ ENc7n8aQLzXjH2FPvgALNPBaSRFiTTtxz36m+UeFXprlCOm3BAEbJtAoNkzW5nRJkb05zVTmb0z1 jJ5x8X57VkM6Cv9mqpjneuTaEZWACCgDSxAx25jBV2JhD/iWD0V++qD0gbQQTy2MWvdekRpcWklT +39WHn3k1EiAZoPn2tuUxPLKnYUFY2O1M5lTrLO1ml98jiusZ8069jihx+Za/cV70jOJzN2r4A== X-Report-Abuse-To: spam@com-mpt-mgt001.mailprotect.be Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since __device_release_driver() is called with the device lock held and since the same device lock is obtained by the functions that perform asynchronous probing (driver_attach_async() and __device_attach_async_helper()), asynchronous probing is already serialized against __device_release_driver(). Remove the async_synchronize_full() call from __device_release_driver() to avoid that a deadlock is triggered. See also commit 765230b5f084 ("driver-core: add asynchronous probing support for drivers"). Signed-off-by: Bart Van Assche Cc: Dmitry Torokhov Cc: Lee Duncan Cc: Hannes Reinecke Cc: Luis R. Rodriguez Cc: Johannes Thumshirn Cc: Christoph Hellwig Cc: Greg Kroah-Hartman Acked-by: Dmitry Torokhov --- drivers/base/dd.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/base/dd.c b/drivers/base/dd.c index edfc9f0b1180..d6520de659bd 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -926,9 +926,6 @@ static void __device_release_driver(struct device *dev, struct device *parent) drv = dev->driver; if (drv) { - if (driver_allows_async_probing(drv)) - async_synchronize_full(); - while (device_links_busy(dev)) { device_unlock(dev); if (parent)