From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5A06EB64D8 for ; Wed, 14 Jun 2023 06:57:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231246AbjFNG5S (ORCPT ); Wed, 14 Jun 2023 02:57:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229943AbjFNG5Q (ORCPT ); Wed, 14 Jun 2023 02:57:16 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B1B91984; Tue, 13 Jun 2023 23:57:15 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 227072188D; Wed, 14 Jun 2023 06:57:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1686725834; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bWmUJHf0Ey81BHg4FfOq6OnR1lg1RZH8qrzAxru/q4U=; b=Ae78GTKgCZZmGqmGNhaYT00kHkTw7C22ZCo648dDhJ5Hznq86Qcl4UTSqguQZZMN1B5u2+ fQVBGbjxDDMK3J4Kzj8D6BBud5Y3rlLwToB8VxsOCRc7c/N6CwY8KWxXUaXM7B2YMc+n2m zamjj2L8XPwxE1yYbor492aRMNRvVtg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1686725834; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bWmUJHf0Ey81BHg4FfOq6OnR1lg1RZH8qrzAxru/q4U=; b=IhtnPGz1B/nlr8hDByMU5YnbQ+jLtCqO6A1zC0rheblThcV4vMvhPDAZGiCZqV2PEaAj7a eyODkgpoYD5GMNDQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id F30541357F; Wed, 14 Jun 2023 06:57:12 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id TXZdOshkiWS9DAAAMHmgww (envelope-from ); Wed, 14 Jun 2023 06:57:12 +0000 Message-ID: <37ed36f0-6f72-115c-85fb-62ef5ad72e76@suse.de> Date: Wed, 14 Jun 2023 08:57:12 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: Fwd: Waking up from resume locks up on sr device Content-Language: en-US To: Damien Le Moal , Joe Breuer , Bart Van Assche , Bagas Sanjaya , Pavel Machek Cc: "Rafael J. Wysocki" , Len Brown , Greg Kroah-Hartman , Kees Cook , Tony Luck , "Guilherme G. Piccoli" , Thorsten Leemhuis , "James E.J. Bottomley" , "Martin K. Petersen" , Phillip Potter , Linux Power Management , Linux Kernel Mailing List , Linux Hardening , Linux Regressions , Linux SCSI , Alan Stern , Dan Williams , Hannes Reinecke , Adrian Hunter , Martin Kepplinger , Kai-Heng Feng References: <2d1fdf6d-682c-a18d-2260-5c5ee7097f7d@gmail.com> <5513e29d-955a-f795-21d6-ec02a2e2e128@gmail.com> <07d6e2e7-a50a-8cf4-5c5d-200551bd6687@gmail.com> <02e4f87a-80e8-dc5d-0d6e-46939f2c74ac@acm.org> <84f1c51c-86f9-04b3-0cd1-f685ebee7592@kernel.org> From: Hannes Reinecke In-Reply-To: <84f1c51c-86f9-04b3-0cd1-f685ebee7592@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org On 6/14/23 06:49, Damien Le Moal wrote: > On 6/11/23 18:05, Joe Breuer wrote: >> I'm the reporter of this issue. >> >> I just tried this patch against 6.3.4, and it completely fixes my >> suspend/resume issue. >> >> The optical drive stays usable after resume, even suspending/resuming >> during playback of CDDA content works flawlessly and playback resumes >> seamlessly after system resume. >> >> So, from my perspective: Good one! > > In place of Bart's fix, could you please try this patch ? > > diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c > index b80e68000dd3..a81eb4f882ab 100644 > --- a/drivers/ata/libata-eh.c > +++ b/drivers/ata/libata-eh.c > @@ -4006,9 +4006,32 @@ static void ata_eh_handle_port_resume(struct > ata_port *ap) > /* tell ACPI that we're resuming */ > ata_acpi_on_resume(ap); > > - /* update the flags */ > spin_lock_irqsave(ap->lock, flags); > + > + /* Update the flags */ > ap->pflags &= ~(ATA_PFLAG_PM_PENDING | ATA_PFLAG_SUSPENDED); > + > + /* > + * Resuming the port will trigger a rescan of the ATA device(s) > + * connected to it. Before scheduling the rescan, make sure that > + * the associated scsi device(s) are fully resumed as well. > + */ > + ata_for_each_link(link, ap, HOST_FIRST) { > + ata_for_each_dev(dev, link, ENABLED) { > + struct scsi_device *sdev = dev->sdev; > + > + if (!sdev) > + continue; > + if (scsi_device_get(sdev)) > + continue; > + > + spin_unlock_irqrestore(ap->lock, flags); > + device_pm_wait_for_dev(&ap->tdev, > + &sdev->sdev_gendev); > + scsi_device_put(sdev); > + spin_lock_irqsave(ap->lock, flags); > + } > + } > spin_unlock_irqrestore(ap->lock, flags); > } > #endif /* CONFIG_PM */ > > Thanks ! > Well; not sure if that'll work out. The whole reason why we initial a rescan is that we need to check if the ports are still connected, and whether the devices react. So we can't iterate the ports here as this is the very thing which gets checked during EH. We really should claim resume to be finished as soon as we can talk with the HBA, and kick off EH asynchronously to let it finish the job after resume has completed. Cheers, Hannes -- Dr. Hannes Reinecke Kernel Storage Architect hare@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman