linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Michal Suchánek" <msuchanek@suse.de>
To: Bart Van Assche <Bart.VanAssche@wdc.com>
Cc: "corbet@lwn.net" <corbet@lwn.net>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-ide@vger.kernel.org" <linux-ide@vger.kernel.org>,
	"keescook@chromium.org" <keescook@chromium.org>,
	"tglx@linutronix.de" <tglx@linutronix.de>,
	"martin.petersen@oracle.com" <martin.petersen@oracle.com>,
	"axboe@kernel.dk" <axboe@kernel.dk>,
	"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
	"kstewart@linuxfoundation.org" <kstewart@linuxfoundation.org>,
	"pombredanne@nexb.com" <pombredanne@nexb.com>,
	"bp@alien8.de" <bp@alien8.de>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"jejb@linux.vnet.ibm.com" <jejb@linux.vnet.ibm.com>,
	"christophe.jaillet@wanadoo.fr" <christophe.jaillet@wanadoo.fr>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
	"tim@cyberelk.net" <tim@cyberelk.net>
Subject: Re: [PATCH resend 3/6] cdrom: wait for tray to close
Date: Wed, 31 Jan 2018 19:20:27 +0100	[thread overview]
Message-ID: <20180131192027.070196c1@kitsune.suse.cz> (raw)
In-Reply-To: <1517245546.2687.17.camel@wdc.com>

On Mon, 29 Jan 2018 17:05:47 +0000
Bart Van Assche <Bart.VanAssche@wdc.com> 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

  reply	other threads:[~2018-01-31 18:20 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-14 15:13 [PATCH 0/6] Fix cdrom autoclose Michal Suchanek
2017-12-14 15:13 ` [PATCH 1/6] delay: add poll_event_interruptible Michal Suchanek
2017-12-14 15:13 ` [PATCH 2/6] cdrom: factor out common open_for_* code Michal Suchanek
2017-12-14 15:13 ` [PATCH 3/6] cdrom: wait for tray to close Michal Suchanek
2017-12-15 17:20   ` Michal Suchánek
2017-12-14 15:13 ` [PATCH 4/6] cdrom: introduce CDS_DRIVE_ERROR Michal Suchanek
2017-12-14 15:13 ` [PATCH 5/6] Documentetion: " Michal Suchanek
2017-12-14 15:13 ` [PATCH 6/6] cdrom: wait for drive to become ready Michal Suchanek
2018-01-26 16:58 ` [PATCH resend 0/6] Fix cdrom autoclose Michal Suchanek
2018-01-26 16:58   ` [PATCH resend 1/6] delay: add poll_event_interruptible Michal Suchanek
2018-01-29 17:00     ` Bart Van Assche
2018-01-26 16:58   ` [PATCH resend 2/6] cdrom: factor out common open_for_* code Michal Suchanek
2018-01-29 17:02     ` Bart Van Assche
2018-01-26 16:58   ` [PATCH resend 3/6] cdrom: wait for tray to close Michal Suchanek
2018-01-29 17:05     ` Bart Van Assche
2018-01-31 18:20       ` Michal Suchánek [this message]
2019-10-23 12:19       ` Michal Suchánek
2018-01-26 16:58   ` [PATCH resend 4/6] cdrom: introduce CDS_DRIVE_ERROR Michal Suchanek
2018-01-26 16:58   ` [PATCH resend 5/6] Documentetion: " Michal Suchanek
2018-01-26 16:58   ` [PATCH resend 6/6] cdrom: wait for drive to become ready Michal Suchanek
2018-01-29 17:11     ` Bart Van Assche
2018-01-26 20:04   ` [PATCH resend 0/6] Fix cdrom autoclose James Bottomley
2018-01-27 22:53     ` Michal Suchánek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180131192027.070196c1@kitsune.suse.cz \
    --to=msuchanek@suse.de \
    --cc=Bart.VanAssche@wdc.com \
    --cc=axboe@kernel.dk \
    --cc=bp@alien8.de \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=keescook@chromium.org \
    --cc=kstewart@linuxfoundation.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=pombredanne@nexb.com \
    --cc=tglx@linutronix.de \
    --cc=tim@cyberelk.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).