[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6477c29121ae3_168e29438@dwillia2-xfh.jf.intel.com.notmuch>
Date: Wed, 31 May 2023 14:56:33 -0700
From: Dan Williams <dan.j.williams@...el.com>
To: "Verma, Vishal L" <vishal.l.verma@...el.com>,
"Williams, Dan J" <dan.j.williams@...el.com>,
"Schofield, Alison" <alison.schofield@...el.com>,
"Jiang, Dave" <dave.jiang@...el.com>,
"bwidawsk@...nel.org" <bwidawsk@...nel.org>,
"Weiny, Ira" <ira.weiny@...el.com>
CC: "linux-cxl@...r.kernel.org" <linux-cxl@...r.kernel.org>,
"dave@...olabs.net" <dave@...olabs.net>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"Weight, Russell H" <russell.h.weight@...el.com>
Subject: Re: [PATCH 3/4] cxl: add a firmware update mechanism using the sysfs
firmware loader
Verma, Vishal L wrote:
> On Mon, 2023-05-22 at 20:21 -0700, Dan Williams wrote:
> > Vishal Verma wrote:
>
> <snip>
> Everything else not addressed here sounds good and I've made those
> changes.
>
> > >
> > > + remaining = size - cur_size;
> > > + size_in = cur_size + sizeof(*transfer);
> > > +
> > > + mutex_lock(&cxlds->fw.fw_mutex);
> >
> > What is this lock protecting? I.e. will the fw_loader really try to send
> > multiple overlapping firmware update attempts?
>
> The lock is just to provide predictable points at which a cancel
> request may be intercepted. The loader won't try overlapping firmware
> transfer requests, but the ->cancel request comes from user space, and
> could happen while there is a transfer in progress. With the lock, the
> cancel will only be 'processed' after the current chunk's transfer is
> done.
So right now cancel is only considered at certain points within either
the ->write() or ->poll_complete() callbacks. The firmware upload core
is guaranteeing that ->prepare(), ->write() and ->poll_complete() never
overlap for a given session, and that if any of those return an error
the upload session is terminated.
While the lock does flush in flight ->write() and ->prepare() it does
nothing to enforce when the cancellation is processed. It will still be
the case that the next invocation of ->write() or ->poll_complete() will
consider the cancel state before doing the next step.
I am failing to see what the lock is protecting. The other usage is for
checking that ->prepare() has completed before ->write() is invoked, but
again that is enforced by the firmware uploader workqueue.
I think the lock and the clear_to_send bit can be eliminated. Clear to
send is implied by ->prepare() succeeding. Convert cancel to an atomic
flag where cxl_fw_cancel() does:
set_bit(CXL_FW_CANCEL, &cxlds->fw.state);
...and cxl_fw_write() and cxl_fw_poll_complete() can just do:
if (test_and_clear_bit(CXL_FW_CANCEL, &cxlds->fw.state))
do_cancel();
Powered by blists - more mailing lists