[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YrDqz+x1IFKBRzom@iweiny-desk3>
Date: Mon, 20 Jun 2022 14:46:55 -0700
From: Ira Weiny <ira.weiny@...el.com>
To: "Zhuo, Qiuxu" <qiuxu.zhuo@...el.com>
CC: "Williams, Dan J" <dan.j.williams@...el.com>,
Bjorn Helgaas <bhelgaas@...gle.com>,
Jonathan Cameron <Jonathan.Cameron@...wei.com>,
"Lukas Wunner" <lukas@...ner.de>,
Davidlohr Bueso <dave@...olabs.net>,
"Schofield, Alison" <alison.schofield@...el.com>,
"Verma, Vishal L" <vishal.l.verma@...el.com>,
"Jiang, Dave" <dave.jiang@...el.com>,
"Ben Widawsky" <ben@...dawsk.net>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-cxl@...r.kernel.org" <linux-cxl@...r.kernel.org>,
"linux-pci@...r.kernel.org" <linux-pci@...r.kernel.org>
Subject: Re: [PATCH V10 3/9] PCI: Create PCI library functions in support of
DOE mailboxes.
On Mon, Jun 20, 2022 at 01:39:45AM -0700, Zhuo, Qiuxu wrote:
> > From: ira.weiny@...el.com <ira.weiny@...el.com>
> > Sent: Sunday, June 5, 2022 8:51 AM
> > ...
> > +static void retire_cur_task(struct pci_doe_mb *doe_mb) {
> > + spin_lock(&doe_mb->task_lock);
> > + doe_mb->cur_task = NULL;
> > + spin_unlock(&doe_mb->task_lock);
> > + wake_up_interruptible(&doe_mb->wq);
> > +}
> > +
> > +static void doe_statemachine_work(struct work_struct *work) {
> > + struct delayed_work *w = to_delayed_work(work);
> > + struct pci_doe_mb *doe_mb = container_of(w, struct pci_doe_mb,
> > + statemachine);
> > + struct pci_dev *pdev = doe_mb->pdev;
> > + int offset = doe_mb->cap_offset;
> > + enum pci_doe_state prev_state;
> > + struct pci_doe_task *task;
> > + u32 val;
> > + int rc;
> > +
> > + spin_lock(&doe_mb->task_lock);
> > + task = doe_mb->cur_task;
> > + spin_unlock(&doe_mb->task_lock);
>
> I don't think it needs the lock protection here.
> No matter "task" is !NULL or NULL, it is checked before it's used within this function.
No it does not.
However, Dan has suggested reworking the workqueue and I think it will
eliminate this. I kept the lock more as a marker of where cur_task was being
used even though it was not required. The fact that the rest of the function
goes on to use a local alias was suspicious but was covered by the workqueue
operation. I tried to explain that in the commit message but reworking as Dan
has suggested is better overall.
Thanks for the review!
Ira
Powered by blists - more mailing lists