All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Jie Deng <jie.deng@intel.com>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: linux-i2c@vger.kernel.org,
	virtualization@lists.linux-foundation.org,
	linux-kernel@vger.kernel.org, mst@redhat.com, wsa@kernel.org,
	jasowang@redhat.com, wsa+renesas@sang-engineering.com,
	andriy.shevchenko@linux.intel.com, conghui.chen@intel.com,
	arnd@arndb.de, kblaiech@mellanox.com,
	jarkko.nikula@linux.intel.com, Sergey.Semin@baikalelectronics.ru,
	rppt@kernel.org, loic.poulain@linaro.org, tali.perry1@gmail.com,
	u.kleine-koenig@pengutronix.de, bjorn.andersson@linaro.org,
	yu1.wang@intel.com, shuo.a.liu@intel.com, stefanha@redhat.com,
	pbonzini@redhat.com
Subject: Re: [PATCH v10] i2c: virtio: add a virtio i2c frontend driver
Date: Wed, 24 Mar 2021 14:05:06 +0800	[thread overview]
Message-ID: <70908366-c270-848e-0be3-c85fec7958ec@intel.com> (raw)
In-Reply-To: <20210324042046.idkctj2t7cxi53jf@vireshk-i7>


On 2021/3/24 12:20, 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);
>> +	virtqueue_kick(vq);
> Coming back to this again, what is the expectation from the other side for this
> ? I mean there is no obvious relation between the *msgs* which we are going to
> transfer (from the other side's or host's point of view). When should the host
> OS call its virtqueue_kick() counterpart ?
>
> Lemme give an example for this. Lets say that we need to transfer 3 messages
> here in this routine. What we did was we prepared virtqueue for all 3 messages
> together and then called virtqueue_kick().
>
> Now if the other side (host) processes the first message and sends its reply
> (with virtqueue_kick() counterpart) before processing the other two messages,
> then it will end up calling virtio_i2c_msg_done() here. That will make us call
> virtio_i2c_complete_reqs(), while only the first messages is processed until
> now and so we will fail for the other two messages straight away.
>
> Should we send only 1 message from i2c-virtio linux driver and then wait for
> virtio_i2c_msg_done() to be called, before sending the next message to make sure
> it doesn't break ?


For simplicity, the original patch sent only 1 message to vq each time . 
I changed the way to send

a batch of requests in one time in order to improve efficiency according 
to Jason' suggestion.

As we discussed in the previous emails, the device can raise interrupt 
when some requests are still not completed

though this is not a good operation.  In this case, the remaining 
requests in the vq will be ignored and

the i2c_algorithm. master_xfer will return 1 for your example. I will 
clarify this in the specs.




WARNING: multiple messages have this Message-ID (diff)
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 14:05:06 +0800	[thread overview]
Message-ID: <70908366-c270-848e-0be3-c85fec7958ec@intel.com> (raw)
In-Reply-To: <20210324042046.idkctj2t7cxi53jf@vireshk-i7>


On 2021/3/24 12:20, 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);
>> +	virtqueue_kick(vq);
> Coming back to this again, what is the expectation from the other side for this
> ? I mean there is no obvious relation between the *msgs* which we are going to
> transfer (from the other side's or host's point of view). When should the host
> OS call its virtqueue_kick() counterpart ?
>
> Lemme give an example for this. Lets say that we need to transfer 3 messages
> here in this routine. What we did was we prepared virtqueue for all 3 messages
> together and then called virtqueue_kick().
>
> Now if the other side (host) processes the first message and sends its reply
> (with virtqueue_kick() counterpart) before processing the other two messages,
> then it will end up calling virtio_i2c_msg_done() here. That will make us call
> virtio_i2c_complete_reqs(), while only the first messages is processed until
> now and so we will fail for the other two messages straight away.
>
> Should we send only 1 message from i2c-virtio linux driver and then wait for
> virtio_i2c_msg_done() to be called, before sending the next message to make sure
> it doesn't break ?


For simplicity, the original patch sent only 1 message to vq each time . 
I changed the way to send

a batch of requests in one time in order to improve efficiency according 
to Jason' suggestion.

As we discussed in the previous emails, the device can raise interrupt 
when some requests are still not completed

though this is not a good operation.  In this case, the remaining 
requests in the vq will be ignored and

the i2c_algorithm. master_xfer will return 1 for your example. I will 
clarify this in the specs.



_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

  reply	other threads:[~2021-03-24  6:06 UTC|newest]

Thread overview: 114+ 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
2021-03-23 14:19 ` Jie Deng
2021-03-23  7:27 ` Viresh Kumar
2021-03-23  8:33   ` Jie Deng
2021-03-23  8:33     ` Jie Deng
2021-03-23  8:37     ` Viresh Kumar
2021-03-23  9:27     ` Arnd Bergmann
2021-03-23  9:27       ` Arnd Bergmann
2021-03-24  1:17       ` Jie Deng
2021-03-24  1:17         ` Jie Deng
2021-03-24  4:00         ` Viresh Kumar
2021-04-15  6:45       ` Viresh Kumar
2021-04-15  6:56         ` Jie Deng
2021-04-15  6:56           ` Jie Deng
2021-04-15  7:15           ` Viresh Kumar
2021-04-15  7:21           ` Wolfram Sang
2021-04-15  7:24             ` Viresh Kumar
2021-04-15  7:28               ` Wolfram Sang
2021-04-15  7:37                 ` Viresh Kumar
2021-04-15  8:15                 ` Jie Deng
2021-04-15  8:15                   ` Jie Deng
2021-04-15  8:18                   ` Wolfram Sang
2021-04-15  8:20                     ` Jie Deng
2021-04-15  8:20                       ` Jie Deng
2021-05-27  6:49                     ` Jie Deng
2021-05-27  6:49                       ` Jie Deng
2021-05-12  1:37             ` Jie Deng
2021-05-12  1:37               ` Jie Deng
2021-03-23  9:01 ` Viresh Kumar
2021-03-23  9:38   ` Viresh Kumar
2021-03-24  0:53     ` Jie Deng
2021-03-24  0:53       ` Jie Deng
2021-03-24  3:52       ` Viresh Kumar
2021-03-24  4:00         ` Jie Deng
2021-03-24  4:00           ` Jie Deng
2021-03-24  4:02           ` Viresh Kumar
2021-03-24  4:20 ` Viresh Kumar
2021-03-24  6:05   ` Jie Deng [this message]
2021-03-24  6:05     ` Jie Deng
2021-03-24  6:09     ` Viresh Kumar
2021-03-24  6:41       ` Jie Deng
2021-03-24  6:41         ` Jie Deng
2021-03-24  6:44         ` Viresh Kumar
2021-04-14  2:07 ` Jie Deng
2021-04-14  2:07   ` Jie Deng
2021-04-14  3:52   ` Viresh Kumar
2021-04-15  6:25     ` Jie Deng
2021-04-15  6:25       ` Jie Deng
2021-04-15  3:51 ` Jason Wang
2021-04-15  3:51   ` Jason Wang
2021-04-15  6:17   ` Jie Deng
2021-04-15  6:17     ` Jie Deng
2021-06-28  8:39 ` Wolfram Sang
2021-06-28  9:01   ` Arnd Bergmann
2021-06-28  9:01     ` Arnd Bergmann
2021-06-28  9:25     ` Wolfram Sang
2021-06-28  9:51       ` Arnd Bergmann
2021-06-28  9:51         ` Arnd Bergmann
2021-06-28 10:13         ` Wolfram Sang
2021-06-28 11:50           ` Arnd Bergmann
2021-06-28 11:50             ` Arnd Bergmann
2021-06-28 14:58             ` Wolfram Sang
2021-06-29  3:04               ` Jie Deng
2021-06-29  3:04                 ` Jie Deng
2021-06-29  8:30                 ` Wolfram Sang
2021-06-29  9:13                   ` Viresh Kumar
2021-06-29  9:13                     ` Viresh Kumar
2021-06-29  9:36                     ` Wolfram Sang
2021-06-29  4:10               ` Viresh Kumar
2021-06-29  4:10                 ` Viresh Kumar
2021-06-29  8:27                 ` Wolfram Sang
2021-06-29  8:52                   ` Viresh Kumar
2021-06-29  8:52                     ` Viresh Kumar
2021-06-29  9:07                     ` Wolfram Sang
2021-06-30 14:38                 ` Wolfram Sang
2021-06-30 15:09                   ` Viresh Kumar
2021-06-30 15:09                     ` Viresh Kumar
2021-06-29  3:03     ` Jie Deng
2021-06-29  3:03       ` Jie Deng
2021-06-29 10:07 ` Wolfram Sang
2021-06-29 10:16   ` Viresh Kumar
2021-06-29 10:16     ` Viresh Kumar
2021-06-29 10:23     ` Wolfram Sang
2021-06-29 10:30       ` Viresh Kumar
2021-06-29 10:30         ` Viresh Kumar
2021-06-29 10:42         ` Wolfram Sang
2021-06-29 10:43           ` Wolfram Sang
2021-06-29 10:56             ` Viresh Kumar
2021-06-29 10:56               ` Viresh Kumar
2021-06-29 11:11               ` Wolfram Sang
2021-06-29 11:16                 ` Viresh Kumar
2021-06-29 11:16                   ` Viresh Kumar
2021-06-29 11:48                   ` Wolfram Sang
2021-07-05 12:18             ` Viresh Kumar
2021-07-05 12:18               ` Viresh Kumar
2021-07-06  1:50               ` Jie Deng
2021-07-06  1:50                 ` Jie Deng
2021-07-22 15:15               ` Wolfram Sang
2021-07-23  2:28                 ` Viresh Kumar
2021-07-23  2:28                   ` Viresh Kumar
2021-07-23  5:28                   ` Viresh Kumar
2021-07-23  5:28                     ` Viresh Kumar
2021-06-30  6:45   ` Jie Deng
2021-06-30  6:45     ` Jie Deng
2021-06-30  7:32     ` Wolfram Sang
2021-06-30  7:51       ` Jie Deng
2021-06-30  7:51         ` Jie Deng
2021-06-30  7:55         ` Arnd Bergmann
2021-06-30  7:55           ` Arnd Bergmann
2021-06-30  8:04           ` Wolfram Sang
2021-06-30  8:07           ` Andy Shevchenko
2021-06-30  8:07             ` Andy Shevchenko
2021-06-30  8:29             ` Arnd Bergmann
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=70908366-c270-848e-0be3-c85fec7958ec@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=jasowang@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.