Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5989E7F for ; Wed, 14 Jun 2023 18:04:59 +0000 (UTC) Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-662f0feafb2so5166839b3a.1 for ; Wed, 14 Jun 2023 11:04:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686765899; x=1689357899; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Bfg7Pd8Qi4XV2mpEzR1AaDAP2KYNRF3glqHqxSDiUr8=; b=RwnZ0mqftyxMzJZlqHxbwnEo2xUqEe603uSP6lZsI2DYcTikrmplx5qIYc5X1IiJUZ we4J4Sw+iejdpIl7cOun9c6oZGzMwGlvujGjlJMje/LoOoxqedREw9ngbjQl4YEAouKp CI4ZlFpS2ch30qou9kP3PnGKnqtgmLBIIyKt1ih1t0FJ/DwvThtk2HZaJ9HwJrZ4wrPH fdDFjNtGqspMqh9mlsx3sa44y7s8zgJk1mOnUc7bbYBeC6XuvWCiywWRPjnr7wDtEnZ+ vWW1dt9jq7Y/I3mBX3hMuDTFqavmAW6KDdY+FbazTD6spY+ruHxbSw+9jkrLGTzVszQO ktRQ== X-Gm-Message-State: AC+VfDwfV0NVm1KW97isGe8XE6tDsQDPxdo2QCQnb8XjJOwMRzTJ2NfL 8xh/70oGedtim47M4s2x7x0= X-Google-Smtp-Source: ACHHUZ508hquoDPA8b1+rAI5xOdbxD25gvcdJEa+YPdfH/GWCtVoyJJzwmdFY/bbOKj3msllkxqV3A== X-Received: by 2002:a05:6a20:4424:b0:11a:ce33:563a with SMTP id ce36-20020a056a20442400b0011ace33563amr3161528pzb.15.1686765898436; Wed, 14 Jun 2023 11:04:58 -0700 (PDT) Received: from [192.168.51.14] ([98.51.102.78]) by smtp.gmail.com with ESMTPSA id a12-20020aa780cc000000b0063d24fcc2besm1595325pfn.125.2023.06.14.11.04.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 14 Jun 2023 11:04:57 -0700 (PDT) Message-ID: <3f85cb4a-8b14-623f-eb4e-40baab1ed888@acm.org> Date: Wed, 14 Jun 2023 11:04:55 -0700 Precedence: bulk X-Mailing-List: regressions@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: 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: Alan Stern , Damien Le Moal Cc: Hannes Reinecke , Joe Breuer , Bagas Sanjaya , Pavel Machek , "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 , 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> <37ed36f0-6f72-115c-85fb-62ef5ad72e76@suse.de> <859f0eda-4984-4489-9851-c9f6ec454a88@rowland.harvard.edu> From: Bart Van Assche In-Reply-To: <859f0eda-4984-4489-9851-c9f6ec454a88@rowland.harvard.edu> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 6/14/23 07:26, Alan Stern wrote: > On Wed, Jun 14, 2023 at 04:35:50PM +0900, Damien Le Moal wrote: >> Or... Why the heck scsi_rescan_device() is calling device_lock() ? This >> is the only place in scsi code I can see that takes this lock. I suspect >> this is to serialize either rescans, or serialize with resume, or both. >> For serializing rescans, we can use another lock. For serializing with >> PM, we should wait for PM transitions... >> Something is not right here. > > Here's what commit e27829dc92e5 ("scsi: serialize ->rescan against > ->remove", written by Christoph Hellwig) says: > > Lock the device embedded in the scsi_device to protect against > concurrent calls to ->remove. > > That's the commit which added the device_lock() call. Even if scsi_rescan_device() would use another mechanism for serialization against sd_remove() and sr_remove(), we still need to solve the issue that the ATA code calls scsi_rescan_device() before resuming has finished. scsi_rescan_device() issues I/O. Issuing I/O to a device is not allowed before that device has been resumed. Thanks, Bart.