From: zhuyinbo <zhuyinbo@loongson.cn>
To: Mark Brown <broonie@kernel.org>
Cc: Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
linux-spi@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, Jianmin Lv <lvjianmin@loongson.cn>,
wanghongliang@loongson.cn, Liu Peibao <liupeibao@loongson.cn>,
loongson-kernel@lists.loongnix.cn, zhuyinbo@loongson.cn
Subject: Re: [PATCH v2 2/2] spi: loongson: add bus driver for the loongson spi controller
Date: Sat, 18 Mar 2023 14:07:16 +0800 [thread overview]
Message-ID: <9b7aff76-eff4-3b82-d7af-a723fbf21a32@loongson.cn> (raw)
In-Reply-To: <68b6034f-8305-4854-a4c9-962be988ade7@sirena.org.uk>
在 2023/3/18 上午12:26, Mark Brown 写道:
> On Fri, Mar 17, 2023 at 04:29:50PM +0800, Yinbo Zhu wrote:
>
>> +static int loongson_spi_update_state(struct loongson_spi *loongson_spi,
>> + struct spi_device *spi, struct spi_transfer *t)
>> +{
> ...
>
>> + loongson_spi->hz = hz;
>> + loongson_spi->spcr = div_tmp & 3;
>> + loongson_spi->sper = (div_tmp >> 2) & 3;
>> + val = loongson_spi_read_reg(loongson_spi, LOONGSON_SPI_SPCR_REG);
> This is writing to general chip registers, apparently not per chip
> select ones.
The loongson_spi_update_state was only be called in setup or transfer_one, and I will also
add a spin lock in tranfser_one.
>
>> +static int loongson_spi_setup(struct spi_device *spi)
>> +{
>> + struct loongson_spi *loongson_spi;
>> + spin_lock(&loongson_spi->lock);
>> + loongson_spi_update_state(loongson_spi, spi, NULL);
> As IIRC I mentioned last time setup() might be called while other
> transfers are happening and therefore shouldn't affect parallel
> operations on other devices.
I think add spin_lock in transfer_one interface that should be to fix
this issue, Do you think so?
loongson_spi_transfer_one(struct spi_controller *ctrl, struct spi_dev
{
struct loongson_spi *loongson_spi =
spi_master_get_devdata(spi->master);
+ spin_lock(&loongson_spi->lock);
loongson_spi_update_state(loongson_spi, spi, xfer);
+ spin_unlock(&loongson_spi->lock);
>
>> +static const struct of_device_id loongson_spi_id_table[] = {
>> + { .compatible = "loongson,ls2k-spi", },
>> + { }
>> +};
>> +MODULE_DEVICE_TABLE(of, loongson_spi_id_table);
>> +
>> +static struct platform_driver loongson_spi_driver = {
>> + .probe = loongson_spi_platform_probe,
>> + .driver = {
>> + .name = "loongson-spi",
>> + .owner = THIS_MODULE,
>> + .bus = &platform_bus_type,
>> + .pm = &loongson_spi_dev_pm_ops,
>> + .of_match_table = loongson_spi_id_table,
>> + },
>> +};
>> +
>> +#ifdef CONFIG_PCI
>> +static int loongson_spi_pci_register(struct pci_dev *pdev,
>> + const struct pci_device_id *ent)
> Again as I said last time the two buses should probably be separate
> modules.
>
> Otherwise this looks fine.
okay, I will do it.
next prev parent reply other threads:[~2023-03-18 6:07 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-17 8:29 [PATCH v2 0/2] spi: loongson: add bus driver for the loongson spi Yinbo Zhu
2023-03-17 8:29 ` [PATCH v2 1/2] dt-bindings: spi: add " Yinbo Zhu
2023-03-17 9:15 ` Krzysztof Kozlowski
2023-03-17 10:00 ` zhuyinbo
2023-03-17 15:51 ` Krzysztof Kozlowski
2023-03-17 15:51 ` Krzysztof Kozlowski
2023-03-17 16:14 ` Mark Brown
2023-03-18 1:38 ` zhuyinbo
2023-03-18 1:18 ` zhuyinbo
2023-03-17 14:55 ` Rob Herring
2023-03-18 1:16 ` zhuyinbo
2023-03-17 8:29 ` [PATCH v2 2/2] spi: loongson: add bus driver for the loongson spi controller Yinbo Zhu
2023-03-17 16:26 ` Mark Brown
2023-03-18 6:07 ` zhuyinbo [this message]
2023-03-20 12:52 ` Mark Brown
2023-03-21 2:54 ` zhuyinbo
2023-03-21 12:08 ` Mark Brown
2023-03-23 12:46 ` zhuyinbo
2023-03-23 13:59 ` Mark Brown
2023-03-24 3:32 ` zhuyinbo
2023-03-17 18:07 ` kernel test robot
2023-03-18 2:51 ` zhuyinbo
2023-03-18 3:21 ` kernel test robot
2023-03-18 7:10 ` zhuyinbo
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=9b7aff76-eff4-3b82-d7af-a723fbf21a32@loongson.cn \
--to=zhuyinbo@loongson.cn \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=liupeibao@loongson.cn \
--cc=loongson-kernel@lists.loongnix.cn \
--cc=lvjianmin@loongson.cn \
--cc=robh+dt@kernel.org \
--cc=wanghongliang@loongson.cn \
/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).