linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: Jie Deng <jie.deng@intel.com>, Arnd Bergmann <arnd@arndb.de>
Cc: "Linux I2C" <linux-i2c@vger.kernel.org>,
	virtualization@lists.linux-foundation.org,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Wolfram Sang" <wsa@kernel.org>,
	"Wolfram Sang" <wsa+renesas@sang-engineering.com>,
	"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
	conghui.chen@intel.com, kblaiech@mellanox.com,
	jarkko.nikula@linux.intel.com,
	"Sergey Semin" <Sergey.Semin@baikalelectronics.ru>,
	"Mike Rapoport" <rppt@kernel.org>,
	loic.poulain@linaro.org, "Tali Perry" <tali.perry1@gmail.com>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Bjorn Andersson" <bjorn.andersson@linaro.org>,
	yu1.wang@intel.com, shuo.a.liu@intel.com,
	"Viresh Kumar" <viresh.kumar@linaro.org>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>
Subject: Re: [PATCH v7] i2c: virtio: add a virtio i2c frontend driver
Date: Mon, 15 Mar 2021 11:13:05 +0800	[thread overview]
Message-ID: <503b88c9-1e82-a3a3-0536-d710ddc834a5@redhat.com> (raw)
In-Reply-To: <8070f03d-8233-636b-5ea9-395e723f7a2c@intel.com>


On 2021/3/15 9:14 上午, Jie Deng wrote:
>
> On 2021/3/12 16:58, Arnd Bergmann wrote:
>> On Fri, Mar 12, 2021 at 2:33 PM Jie Deng <jie.deng@intel.com> wrote:
>>
>>> +
>>> +/**
>>> + * struct virtio_i2c_req - the virtio I2C request structure
>>> + * @out_hdr: the OUT header of the virtio I2C message
>>> + * @buf: the buffer into which data is read, or from which it's 
>>> written
>>> + * @in_hdr: the IN header of the virtio I2C message
>>> + */
>>> +struct virtio_i2c_req {
>>> +       struct virtio_i2c_out_hdr out_hdr;
>>> +       uint8_t *buf;
>>> +       struct virtio_i2c_in_hdr in_hdr;
>>> +};
>> The simpler request structure clearly looks better than the previous 
>> version,
>> but I think I found another problem here, at least a theoretical one:
>>
>> When you map the headers into the DMA address space, they should
>> be in separate cache lines, to allow the DMA mapping interfaces to
>> perform cache management on each one without accidentally clobbering
>> another member.
>>
>> So far I think there is an assumption that virtio buffers are always
>> on cache-coherent devices, but if you ever have a virtio-i2c device
>> backend on a physical interconnect that is not cache coherent (e.g. a
>> microcontroller that shares the memory bus), this breaks down.
>>
>> You could avoid this by either allocating arrays of each type 
>> separately,
>> or by marking each member that you pass to the device as
>> ____cacheline_aligned.
>>
>>        Arnd
> The virtio devices are software emulated.


This is not correct. There're already a brunch hardware virtio devices.

Thanks


> The backend software may need to
> consider this since it may exchange data with physical devices. But I 
> don't think
> we need it for this interface, because no DMA operation is involved 
> between the
> frontend driver and backend driver.
>
> Regards,
>
> Jie
>
>


  reply	other threads:[~2021-03-15  3:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-12 13:33 [PATCH v7] i2c: virtio: add a virtio i2c frontend driver Jie Deng
2021-03-12  5:53 ` Jie Deng
2021-03-12  6:10 ` Viresh Kumar
2021-03-12  7:51   ` Jie Deng
2021-03-12  8:11     ` Viresh Kumar
2021-03-12  8:37       ` Jie Deng
2021-03-16  7:39       ` Viresh Kumar
2021-03-12  8:58 ` Arnd Bergmann
2021-03-15  1:14   ` Jie Deng
2021-03-15  3:13     ` Jason Wang [this message]
2021-03-15  5:52       ` Jie Deng
2021-03-15  7:52         ` Arnd Bergmann
2021-03-16  2:15           ` Jie Deng

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=503b88c9-1e82-a3a3-0536-d710ddc834a5@redhat.com \
    --to=jasowang@redhat.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=jie.deng@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).