virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: Jie Deng <jie.deng@intel.com>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: mst@redhat.com, bjorn.andersson@linaro.org,
	wsa+renesas@sang-engineering.com, linux-i2c@vger.kernel.org,
	wsa@kernel.org, andriy.shevchenko@linux.intel.com,
	yu1.wang@intel.com, u.kleine-koenig@pengutronix.de,
	kblaiech@mellanox.com, virtualization@lists.linux-foundation.org,
	arnd@arndb.de, stefanha@redhat.com, tali.perry1@gmail.com,
	conghui.chen@intel.com, loic.poulain@linaro.org,
	linux-kernel@vger.kernel.org, Sergey.Semin@baikalelectronics.ru,
	jarkko.nikula@linux.intel.com, shuo.a.liu@intel.com,
	pbonzini@redhat.com, rppt@kernel.org
Subject: Re: [PATCH v10] i2c: virtio: add a virtio i2c frontend driver
Date: Wed, 24 Mar 2021 08:53:34 +0800	[thread overview]
Message-ID: <5a415dbe-8e3b-2731-cc52-19aeadda1a17@intel.com> (raw)
In-Reply-To: <20210323093839.n7cq7f5poebqdwit@vireshk-i7>


On 2021/3/23 17:38, Viresh Kumar wrote:
> On 23-03-21, 14:31, Viresh Kumar wrote:
>> On 23-03-21, 22:19, Jie Deng wrote:
>>> +static int virtio_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
>>> +{
>>> +	struct virtio_i2c *vi = i2c_get_adapdata(adap);
>>> +	struct virtqueue *vq = vi->vq;
>>> +	struct virtio_i2c_req *reqs;
>>> +	unsigned long time_left;
>>> +	int ret, nr;
>>> +
>>> +	reqs = kcalloc(num, sizeof(*reqs), GFP_KERNEL);
>>> +	if (!reqs)
>>> +		return -ENOMEM;
>>> +
>>> +	mutex_lock(&vi->lock);
>>> +
>>> +	ret = virtio_i2c_send_reqs(vq, reqs, msgs, num);
>>> +	if (ret == 0)
>>> +		goto err_unlock_free;
>>> +
>>> +	nr = ret;
>>> +	reinit_completion(&vi->completion);
>> I think I may have found a possible bug here. This reinit_completion() must
>> happen before we call virtio_i2c_send_reqs(). It is certainly possible (surely
>> in corner cases) that virtio_i2c_msg_done() may get called right after
>> virtio_i2c_send_reqs() and before we were able to call reinit_completion(). And
>> in that case we will never see the completion happen at all.
>>
>>> +	virtqueue_kick(vq);
> I may have misread this. Can the actually start before virtqueue_kick() is
> called ?


No. It starts when wait_for_completion_timeout is called.

So it should be fine here.


>   If not, then completion may be fine where it is.
>
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

  parent reply	other threads:[~2021-03-24  0:53 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-23 14:19 [PATCH v10] i2c: virtio: add a virtio i2c frontend driver Jie Deng
     [not found] ` <20210323072704.rgoelmq62fl2wjjf@vireshk-i7>
2021-03-23  8:33   ` Jie Deng
2021-03-23  9:27     ` Arnd Bergmann
2021-03-24  1:17       ` Jie Deng
     [not found]       ` <20210415064538.a4vf7egk6l3u6zfz@vireshk-i7>
2021-04-15  6:56         ` Jie Deng
     [not found]           ` <20210415072131.GA1006@kunai>
     [not found]             ` <20210415072431.apntpcwrk5hp6zg4@vireshk-i7>
     [not found]               ` <20210415072823.GB1006@kunai>
2021-04-15  8:15                 ` Jie Deng
     [not found]                   ` <20210415081828.GD1006@kunai>
2021-04-15  8:20                     ` Jie Deng
2021-05-27  6:49                     ` Jie Deng
2021-05-12  1:37             ` Jie Deng
     [not found] ` <20210323090108.ygx76exdgzudeeqi@vireshk-i7>
     [not found]   ` <20210323093839.n7cq7f5poebqdwit@vireshk-i7>
2021-03-24  0:53     ` Jie Deng [this message]
     [not found]       ` <20210324035225.skkllxexjl65gs6x@vireshk-i7>
2021-03-24  4:00         ` Jie Deng
     [not found] ` <20210324042046.idkctj2t7cxi53jf@vireshk-i7>
2021-03-24  6:05   ` Jie Deng
     [not found]     ` <20210324060907.nwilmghg2xcdz7nv@vireshk-i7>
2021-03-24  6:41       ` Jie Deng
2021-04-14  2:07 ` Jie Deng
     [not found]   ` <20210414035229.7uqfdcd6dy2ryg3s@vireshk-i7>
2021-04-15  6:25     ` Jie Deng
2021-04-15  3:51 ` Jason Wang
2021-04-15  6:17   ` Jie Deng
     [not found] ` <YNmK0MP5ffQpiipt@ninjato>
2021-06-28  9:01   ` Arnd Bergmann
     [not found]     ` <YNmVg3ZhshshlbSx@ninjato>
2021-06-28  9:51       ` Arnd Bergmann
     [not found]         ` <YNmg2IEpUlArZXPK@ninjato>
2021-06-28 11:50           ` Arnd Bergmann
     [not found]             ` <YNnjh3xxyaZZSo9N@ninjato>
2021-06-29  3:04               ` Jie Deng
     [not found]                 ` <YNraQMl3yJyZ6d5+@kunai>
2021-06-29  9:13                   ` Viresh Kumar
2021-06-29  4:10               ` Viresh Kumar
     [not found]                 ` <YNrZVho/98qgJS9N@kunai>
2021-06-29  8:52                   ` Viresh Kumar
     [not found]                 ` <YNyB/+fNK0u2bI6j@kunai>
2021-06-30 15:09                   ` Viresh Kumar
2021-06-29  3:03     ` Jie Deng
     [not found] ` <YNrw4rxihFLuqLtY@ninjato>
2021-06-29 10:16   ` Viresh Kumar
     [not found]     ` <YNr0uDx1fv+Gjd7m@ninjato>
2021-06-29 10:30       ` Viresh Kumar
     [not found]         ` <YNr5Jf3WDTH7U5b7@ninjato>
     [not found]           ` <YNr5ZRhT3qn+e9/m@ninjato>
2021-06-29 10:56             ` Viresh Kumar
     [not found]               ` <YNr/2E/T4FRjLOgy@ninjato>
2021-06-29 11:16                 ` Viresh Kumar
2021-07-05 12:18             ` Viresh Kumar
2021-07-06  1:50               ` Jie Deng
     [not found]               ` <YPmLoeLSPS1tfYUK@ninjato>
2021-07-23  2:28                 ` Viresh Kumar
2021-07-23  5:28                   ` Viresh Kumar
2021-06-30  6:45   ` Jie Deng
     [not found]     ` <YNwd/t3DMKSOrTAT@ninjato>
2021-06-30  7:51       ` Jie Deng
2021-06-30  7:55         ` Arnd Bergmann
2021-06-30  8:07           ` Andy Shevchenko
2021-06-30  8:29             ` Arnd Bergmann

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=5a415dbe-8e3b-2731-cc52-19aeadda1a17@intel.com \
    --to=jie.deng@intel.com \
    --cc=Sergey.Semin@baikalelectronics.ru \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=arnd@arndb.de \
    --cc=bjorn.andersson@linaro.org \
    --cc=conghui.chen@intel.com \
    --cc=jarkko.nikula@linux.intel.com \
    --cc=kblaiech@mellanox.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loic.poulain@linaro.org \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=rppt@kernel.org \
    --cc=shuo.a.liu@intel.com \
    --cc=stefanha@redhat.com \
    --cc=tali.perry1@gmail.com \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=viresh.kumar@linaro.org \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=wsa+renesas@sang-engineering.com \
    --cc=wsa@kernel.org \
    --cc=yu1.wang@intel.com \
    /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).