From: Jie Deng <jie.deng@intel.com>
To: Arnd Bergmann <arnd@arndb.de>, Jason Wang <jasowang@redhat.com>
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 v6] i2c: virtio: add a virtio i2c frontend driver
Date: Thu, 11 Mar 2021 13:59:42 +0800 [thread overview]
Message-ID: <c6538bba-9217-d707-9a16-72b550c7f76f@intel.com> (raw)
In-Reply-To: <CAK8P3a04u9Xv15K06zrsOtzZF18+1wDpJbBHUU3wYwU--Hdz5A@mail.gmail.com>
On 2021/3/10 16:27, Arnd Bergmann wrote:
> On Wed, Mar 10, 2021 at 4:59 AM Jason Wang <jasowang@redhat.com> wrote:
>> On 2021/3/10 10:22 上午, Jie Deng wrote:
>>> On 2021/3/4 17:15, Jason Wang wrote:
>>>>
>>>>> + }
>>>>> +
>>>>> + if (msgs[i].flags & I2C_M_RD)
>>>>> + memcpy(msgs[i].buf, req->buf, msgs[i].len);
>>>>
>>>> Sorry if I had asked this before but any rason not to use msg[i].buf
>>>> directly?
>>>>
>>>>
>>> The msg[i].buf is passed by the I2C core. I just noticed that these
>>> bufs are not
>>> always allocated by kmalloc. They may come from the stack, which may
>>> cause
>>> the check "sg_init_one -> sg_set_buf -> virt_addr_valid" to fail.
>>> Therefore the
>>> msg[i].buf is not suitable for direct use here.
>> Right, stack is virtually mapped.
> Maybe there is (or should be) a way to let the i2c core code handle
> the bounce buffering in this case. This is surely not a problem that
> is unique to this driver, and I'm sure it has come up many times in
> the past.
>
> I see that there is a i2c_get_dma_safe_msg_buf() helper for this
> purpose, but it has to be called by the driver rather than the core,
> so the driver still needs to keep track of each address when it
> sends multiple i2c_msg at once, but maybe it can all be done
> inside the sg_table instead of yet another structure.
>
> At least this one avoids copying data that is marked with the
> I2C_M_DMA_SAFE flag.
>
> Arnd
Make sense. Thanks Arnd. I will try to use those helper functions.
Regards,
Jie
prev parent reply other threads:[~2021-03-11 6:00 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-04 1:59 [PATCH v6] i2c: virtio: add a virtio i2c frontend driver Jie Deng
2021-03-04 5:37 ` kernel test robot
2021-03-04 5:40 ` kernel test robot
2021-03-04 6:06 ` Viresh Kumar
2021-03-05 1:46 ` Jie Deng
2021-03-05 3:09 ` Viresh Kumar
2021-03-05 7:00 ` Jie Deng
2021-03-05 7:29 ` Viresh Kumar
2021-03-04 6:22 ` kernel test robot
2021-03-04 9:15 ` Jason Wang
2021-03-05 5:47 ` Jie Deng
2021-03-05 7:23 ` Jason Wang
2021-03-05 8:12 ` Jie Deng
2021-03-10 2:22 ` Jie Deng
2021-03-10 3:59 ` Jason Wang
2021-03-10 8:27 ` Arnd Bergmann
2021-03-11 5:59 ` Jie Deng [this message]
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=c6538bba-9217-d707-9a16-72b550c7f76f@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 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).