Received: by 10.223.176.5 with SMTP id f5csp1713160wra; Wed, 31 Jan 2018 10:22:41 -0800 (PST) X-Google-Smtp-Source: AH8x226J9Quchlfv59Ss2ulko9mVAUohL2EOaTKQjnVxtCr9LdR1qspXlOH2zxh+WNU7HJqbJmMR X-Received: by 2002:a17:902:d905:: with SMTP id c5-v6mr28735983plz.225.1517422960953; Wed, 31 Jan 2018 10:22:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517422960; cv=none; d=google.com; s=arc-20160816; b=W3PzM0suNSgqKd+SEXOy8Q39RN+2Y7diDsybeh4KhabT16wpEGADT4Z3QsvR5ba0Ry C86eU8naXgF+A/lyPx6y9TdZ5YCwBlb5U+pUyGyxum1Af4gF+Y3OX5hMzWSFAvf3sIIr zt4Y8Qv304QQQzK1F/9xA8lGBo2lYDdJIlbjxEx8vwFRgpjulTIVKtp/pOStTWYeOIzH c+HqFFFYTbEi3G1ucVmJBStKWLSIBjiZ80Nq1qiJiLNwD6EFeiyT94qoEJ2vZPw19w1m fKgRTQVSIP5YyUV2WlJ8mr8pfTnS0xBKNJAeqD6UPgJfGG26jD3oV0D6YLkUPm2b4UZe g3+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:arc-authentication-results; bh=jcUQELfA0vnR6/xBm/duqHGXduNIpBVc/1eAqzeZEYs=; b=O3ftKkQx+URF64mTuFRQSSS+L9/QF/R7V31jEloJyiiKqZVkF1CuQ1WyH0CWLzwDVK eLSqIG9+H5Mg3Ir9tMI33c2PrJANqFMI6WXkF+MjNIINiPUbWVnDSUBTPRluEnicSlDz 5JU9gVkmkyco4ZLleMVcWnZviTQ4f4aGTRX+DjI1bq7dFLbDUNtjXxpJ64mjKHPZuPM8 GpwFejs7yDbm/WAnhpS6hSN1qNhzMX3ry9P+Ylx3ONalGb67UUtERudqjjO9dKF9KkYo UuGQ+vDLVfX3sX1HZhYaSmcnrbMqNa20TnL2kernPn9T53Dh9lLPrba4D2mcw2K9MTfY sixQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 64si4280251pgc.62.2018.01.31.10.22.25; Wed, 31 Jan 2018 10:22:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753572AbeAaSUe (ORCPT + 99 others); Wed, 31 Jan 2018 13:20:34 -0500 Received: from mx2.suse.de ([195.135.220.15]:55621 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753339AbeAaSUc (ORCPT ); Wed, 31 Jan 2018 13:20:32 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 68056ACAD; Wed, 31 Jan 2018 18:20:30 +0000 (UTC) Date: Wed, 31 Jan 2018 19:20:27 +0100 From: Michal =?UTF-8?B?U3VjaMOhbmVr?= To: Bart Van Assche Cc: "corbet@lwn.net" , "linux-kernel@vger.kernel.org" , "linux-ide@vger.kernel.org" , "keescook@chromium.org" , "tglx@linutronix.de" , "martin.petersen@oracle.com" , "axboe@kernel.dk" , "linux-scsi@vger.kernel.org" , "kstewart@linuxfoundation.org" , "pombredanne@nexb.com" , "bp@alien8.de" , "gregkh@linuxfoundation.org" , "jejb@linux.vnet.ibm.com" , "christophe.jaillet@wanadoo.fr" , "davem@davemloft.net" , "linux-doc@vger.kernel.org" , "tim@cyberelk.net" Subject: Re: [PATCH resend 3/6] cdrom: wait for tray to close Message-ID: <20180131192027.070196c1@kitsune.suse.cz> In-Reply-To: <1517245546.2687.17.camel@wdc.com> References: <03915a2e64f50ec04ea6d8e6f80e36ecf16e4f0f.1516985620.git.msuchanek@suse.de> <1517245546.2687.17.camel@wdc.com> Organization: SUSE Linux X-Mailer: Claws Mail 3.15.1-dirty (GTK+ 2.24.31; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 29 Jan 2018 17:05:47 +0000 Bart Van Assche wrote: > On Fri, 2018-01-26 at 17:58 +0100, Michal Suchanek wrote: > > +static int cdrom_tray_close(struct cdrom_device_info *cdi) > > +{ > > + int ret; > > + > > + ret = cdi->ops->tray_move(cdi, 0); > > + if (ret || !cdi->ops->drive_status) > > + return ret; > > + > > + return poll_event_interruptible(CDS_TRAY_OPEN != > > + cdi->ops->drive_status(cdi, CDSL_CURRENT), > > 500); +} > > + > > static > > int open_for_common(struct cdrom_device_info *cdi, tracktype > > *tracks) { > > @@ -1048,7 +1062,9 @@ int open_for_common(struct cdrom_device_info > > *cdi, tracktype *tracks) if (CDROM_CAN(CDC_CLOSE_TRAY) && > > cdi->options & CDO_AUTO_CLOSE) { > > cd_dbg(CD_OPEN, "trying to close > > the tray\n"); > > - ret = cdo->tray_move(cdi, 0); > > + ret = cdrom_tray_close(cdi); > > + if (ret == -ERESTARTSYS) > > + return ret; > > if (ret) { > > cd_dbg(CD_OPEN, "bummer. > > tried to close the tray but failed.\n"); /* Ignore the error from > > the low @@ -2312,7 +2328,8 @@ static int > > cdrom_ioctl_closetray(struct cdrom_device_info *cdi) > > if (!CDROM_CAN(CDC_CLOSE_TRAY)) > > return -ENOSYS; > > - return cdi->ops->tray_move(cdi, 0); > > + > > + return cdrom_tray_close(cdi); > > } > > So this patch changes code that does not wait into code that > potentially waits forever? Sorry but I don't think that's ideal. > Please make sure that after a certain time (a few seconds?) the loop > finishes. The problem is that few seconds does not cut it. We are waiting for a mechanical tray or CD changer to move. On non-broken hardware the tray either closes or an error is reported within a few seconds. For the timeout to not race with the event we are waiting for it must be much longer, though. Also note that this code is only invoked when the user specifically requested that the tray gets closed automatically which is off by default. Thanks Michal