From: Jie Deng <jie.deng@intel.com>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: "Arnd Bergmann" <arnd@arndb.de>,
"Enrico Weigelt, metux IT consult" <lkml@metux.net>,
"Linux I2C" <linux-i2c@vger.kernel.org>,
virtualization@lists.linux-foundation.org,
"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Wolfram Sang" <wsa@kernel.org>,
"Jason Wang" <jasowang@redhat.com>,
"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,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>
Subject: Re: [PATCH v8] i2c: virtio: add a virtio i2c frontend driver
Date: Fri, 19 Mar 2021 14:29:50 +0800 [thread overview]
Message-ID: <834186be-71b1-a67c-8dee-b90527b459c8@intel.com> (raw)
In-Reply-To: <20210319054035.47tn747lkagpip6v@vireshk-i7>
On 2021/3/19 13:40, Viresh Kumar wrote:
> On 19-03-21, 13:31, Jie Deng wrote:
>> On 2021/3/19 11:54, Viresh Kumar wrote:
>>> On 18-03-21, 15:52, Arnd Bergmann wrote:
>>>> Allowing multiple virtio-i2c controllers in one system, and multiple i2c
>>>> devices attached to each controller is clearly something that has to work.
>>> Good.
>>>
>>>> I don't actually see a limitation though. Viresh, what is the problem
>>>> you see for having multiple controllers?
>>> I thought this would be a problem in that case as we are using the global
>>> virtio_adapter here.
>>>
>>> + vi->adap = &virtio_adapter;
>>> + i2c_set_adapdata(vi->adap, vi);
>>>
>>> Multiple calls to probe() will end up updating the same pointer inside adap.
>>>
>>> + vi->adap->dev.parent = &vdev->dev;
>>>
>>> Same here, overwrite.
>>>
>>> + /* Setup ACPI node for controlled devices which will be probed through ACPI */
>>> + ACPI_COMPANION_SET(&vi->adap->dev, ACPI_COMPANION(pdev));
>>> + vi->adap->timeout = HZ / 10;
>>>
>>> These may be fine, but still not ideal I believe.
>>>
>>> + ret = i2c_add_adapter(vi->adap);
>>> i
>>> This should be a problem as well, we must be adding this to some sort of list,
>>> doing some RPM stuff, etc ?
>>>
>>> Jie, the solution is to allocate memory for adap at runtime in probe and remove
>>> the virtio_adapter structure completely.
>>
>> If you want to support that. Then I think we don't need to change the
>> following at all.
>>
>>> + .algo = &virtio_algorithm,
>>> +
>>> + return ret;
>>> +
>>> + vi->adap = virtio_adapter;
>> This is strange, why are you allocating memory for adapter twice ?
>> Once for virtio_adapter and once for vi->adap ? Either fill the fields
>> directly for v->adap here and remove virtio_adapter or make vi->adap a
>> pointer.
> Yes, your previous version was partly okay but you don't need the
> virtio_algorithm structure to be allocated. There are only 4 fields you are
> updating here, just fill them directly in vi->adap.
>
> (FWIW, I also suggested the same when I said
> "Either fill the fields directly for v->adap here and remove virtio_adapter".
> )
>
> See how drivers/i2c/busses/i2c-versatile.c and most of the other drivers have
> done it.
I also see example drivers/i2c/busses/i2c-xiic.c. Some people might
think this way is more clearer than
updating each member in probe. Basically, I think it's just a matter of
personal preference which doesn't
solve any problems.
next prev parent reply other threads:[~2021-03-19 6:30 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-16 10:35 Jie Deng
2021-03-16 7:44 ` Viresh Kumar
2021-03-18 14:40 ` Enrico Weigelt, metux IT consult
2021-03-18 14:52 ` Arnd Bergmann
2021-03-19 3:54 ` Viresh Kumar
2021-03-19 5:31 ` Jie Deng
2021-03-19 5:40 ` Viresh Kumar
2021-03-19 6:29 ` Jie Deng [this message]
2021-03-19 6:35 ` Viresh Kumar
2021-03-19 6:56 ` Jie Deng
2021-03-19 8:27 ` Arnd Bergmann
2021-03-16 7:53 ` Viresh Kumar
2021-03-19 5:53 ` Viresh Kumar
2021-03-19 7:52 ` 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=834186be-71b1-a67c-8dee-b90527b459c8@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=lkml@metux.net \
--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
Powered by JetHome