All of lore.kernel.org
 help / color / mirror / Atom feed
From: <Durai.ManickamKR@microchip.com>
To: <jarkko.nikula@linux.intel.com>, <Frank.li@nxp.com>,
	<wsa+renesas@sang-engineering.com>
Cc: <linux-i3c@lists.infradead.org>, <devicetree@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <alexandre.belloni@bootlin.com>,
	<robh@kernel.org>, <krzk+dt@kernel.org>, <conor+dt@kernel.org>,
	<Balamanikandan.Gunasundar@microchip.com>,
	<Nicolas.Ferre@microchip.com>
Subject: Re: [PATCH 2/4] i3c: master: add Microchip SAMA7D65 I3C HCI master driver
Date: Thu, 18 Sep 2025 06:40:00 +0000	[thread overview]
Message-ID: <1a5dc012-eec2-40c5-90ea-bbff1ff713cd@microchip.com> (raw)
In-Reply-To: <c25bf384-a312-47a9-a27a-a943cbd33050@linux.intel.com>

Hi Jarkko, Conor, Frank & Wolfram,

 From the comments I received from you all, I got clarity like i should 
integrate the I3C changes specific to our SoC in the existing 
mipi-i3c-hci driver by using quirk or some board specific kernel config. 
I will resend the patch to mailing list with this approach in short for 
the review. Thanks for the support.

On 10/09/25 14:31, Jarkko Nikula wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know 
> the content is safe
>
> Hi
>
> On 9/10/25 9:12 AM, Durai.ManickamKR@microchip.com wrote:
>> On 10/09/25 02:48, Frank Li wrote:
>>> EXTERNAL EMAIL: Do not click links or open attachments unless you 
>>> know the content is safe
>>>
>>> On Tue, Sep 09, 2025 at 04:43:31PM +0530, Durai Manickam KR wrote:
>>>> Add support for microchip SAMA7D65 I3C HCI master only IP. This
>>>> hardware is an instance of the MIPI I3C HCI Controller implementing
>>>> version 1.0 specification. This driver adds platform-specific
>>>> support for SAMA7D65 SoC.
>>
>> Hi Frank,
>>
>> We have integrated the I3C HCI IP from synopsys. But the IP which we
>> integrated into our SAMA7D65 SoC does not support DMA feature, Endianess
>> check and few other interrupt status. So we have to introduce a
>> microchip SoC specific macro to modify this driver. So we have below 2
>> approaches,
>>
> I'd try to avoid creating a copy driver for the same base IP as much as
> possible.
>
> MIPI I3C HCI driver supports both PIO and DMA. Not sure are there
> implementations where IP is synthezied to support both but for example
> AMD platform with ACPI ID AMDI5017 is PIO only and Intel is DMA only.
>
> I have two concrete examples below showing how difficult is to keep sync
> changes and one sidenote about unneeded code for your HW.
>
>>>> +static void mchp_hci_dat_v1_set_dynamic_addr(struct mchp_i3c_hci 
>>>> *hci,
>>>> +                                        unsigned int dat_idx, u8 
>>>> address)
>>>> +{
>>>> +        u32 dat_w0;
>>>> +
>>>> +        dat_w0 = dat_w0_read(dat_idx);
>>>> +        dat_w0 &= ~(DAT_0_DYNAMIC_ADDRESS | DAT_0_DYNADDR_PARITY);
>>>> +        dat_w0 |= FIELD_PREP(DAT_0_DYNAMIC_ADDRESS, address) |
>>>> +                  (dynaddr_parity(address) ? DAT_0_DYNADDR_PARITY 
>>>> : 0);
>>>> +        dat_w0_write(dat_idx, dat_w0);
>>>> +}
>
> This code calculates the parity wrong. See commit e55905a3f33c ("i3c:
> mipi-i3c-hci: use parity8 helper instead of open coding it").
>
> If I recall correctly this becomes visible with the 3rd or 4th device on
> the bus and therefore was for long unnoticed.
>
>>>> +static int mchp_i3c_hci_alloc_safe_xfer_buf(struct mchp_i3c_hci *hci,
>>>> +                                    struct mchp_hci_xfer *xfer)
>>>> +{
>>>> +     if (hci->io == &mchp_mipi_i3c_hci_pio ||
>>>> +         xfer->data == NULL || !is_vmalloc_addr(xfer->data))
>>>> +             return 0;
>>>> +     if (xfer->rnw)
>>>> +             xfer->bounce_buf = kzalloc(xfer->data_len, GFP_KERNEL);
>>>> +     else
>>>> +             xfer->bounce_buf = kmemdup(xfer->data,
>>>> +                                        xfer->data_len, GFP_KERNEL);
>>>> +
>>>> +     return xfer->bounce_buf == NULL ? -ENOMEM : 0;
>>>> +}
>>>> +
>>>> +static void mchp_i3c_hci_free_safe_xfer_buf(struct mchp_i3c_hci *hci,
>>>> +                                    struct mchp_hci_xfer *xfer)
>>>> +{
>>>> +     if (hci->io == &mchp_mipi_i3c_hci_pio || xfer->bounce_buf == 
>>>> NULL)
>>>> +     return;
>>>> +     if (xfer->rnw)
>>>> +             memcpy(xfer->data, xfer->bounce_buf, xfer->data_len);
>>>> +
>>>> +     kfree(xfer->bounce_buf);
>>>> +}
>
> Sidenote, these bounce buf stuff are complete unneeded if your HW
> supports only PIO transfers.
>
>>>> +static int mchp_i3c_hci_attach_i3c_dev(struct i3c_dev_desc *dev)
>>>> +{
>>>> +     struct i3c_master_controller *m = i3c_dev_get_master(dev);
>>>> +     struct mchp_i3c_hci *hci = to_i3c_hci(m);
>>>> +     struct mchp_i3c_hci_dev_data *dev_data;
>>>> +     int ret;
>>>> +
>>>> +     dev_data = kzalloc(sizeof(*dev_data), GFP_KERNEL);
>>>> +     if (!dev_data)
>>>> +             return -ENOMEM;
>>>> +     if (hci->cmd == &mchp_mipi_i3c_hci_cmd_v1) {
>>>> +             ret = mchp_mipi_i3c_hci_dat_v1.alloc_entry(hci);
>>>> +             if (ret < 0) {
>>>> +                     kfree(dev_data);
>>>> +                     return ret;
>>>> +             }
>>>> +             mchp_mipi_i3c_hci_dat_v1.set_dynamic_addr(hci, ret, 
>>>> dev->info.dyn_addr);
>>>> +             dev_data->dat_idx = ret;
>>>> +     }
>>>> +     i3c_dev_set_master_data(dev, dev_data);
>>>> +     return 0;
>>>> +}
>
> See commit 2b50719dd92f ("i3c: mipi-i3c-hci: Support SETDASA CCC").
>

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

WARNING: multiple messages have this Message-ID (diff)
From: <Durai.ManickamKR@microchip.com>
To: <jarkko.nikula@linux.intel.com>, <Frank.li@nxp.com>,
	<wsa+renesas@sang-engineering.com>
Cc: <linux-i3c@lists.infradead.org>, <devicetree@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <alexandre.belloni@bootlin.com>,
	<robh@kernel.org>, <krzk+dt@kernel.org>, <conor+dt@kernel.org>,
	<Balamanikandan.Gunasundar@microchip.com>,
	<Nicolas.Ferre@microchip.com>
Subject: Re: [PATCH 2/4] i3c: master: add Microchip SAMA7D65 I3C HCI master driver
Date: Thu, 18 Sep 2025 06:40:00 +0000	[thread overview]
Message-ID: <1a5dc012-eec2-40c5-90ea-bbff1ff713cd@microchip.com> (raw)
In-Reply-To: <c25bf384-a312-47a9-a27a-a943cbd33050@linux.intel.com>

Hi Jarkko, Conor, Frank & Wolfram,

 From the comments I received from you all, I got clarity like i should 
integrate the I3C changes specific to our SoC in the existing 
mipi-i3c-hci driver by using quirk or some board specific kernel config. 
I will resend the patch to mailing list with this approach in short for 
the review. Thanks for the support.

On 10/09/25 14:31, Jarkko Nikula wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know 
> the content is safe
>
> Hi
>
> On 9/10/25 9:12 AM, Durai.ManickamKR@microchip.com wrote:
>> On 10/09/25 02:48, Frank Li wrote:
>>> EXTERNAL EMAIL: Do not click links or open attachments unless you 
>>> know the content is safe
>>>
>>> On Tue, Sep 09, 2025 at 04:43:31PM +0530, Durai Manickam KR wrote:
>>>> Add support for microchip SAMA7D65 I3C HCI master only IP. This
>>>> hardware is an instance of the MIPI I3C HCI Controller implementing
>>>> version 1.0 specification. This driver adds platform-specific
>>>> support for SAMA7D65 SoC.
>>
>> Hi Frank,
>>
>> We have integrated the I3C HCI IP from synopsys. But the IP which we
>> integrated into our SAMA7D65 SoC does not support DMA feature, Endianess
>> check and few other interrupt status. So we have to introduce a
>> microchip SoC specific macro to modify this driver. So we have below 2
>> approaches,
>>
> I'd try to avoid creating a copy driver for the same base IP as much as
> possible.
>
> MIPI I3C HCI driver supports both PIO and DMA. Not sure are there
> implementations where IP is synthezied to support both but for example
> AMD platform with ACPI ID AMDI5017 is PIO only and Intel is DMA only.
>
> I have two concrete examples below showing how difficult is to keep sync
> changes and one sidenote about unneeded code for your HW.
>
>>>> +static void mchp_hci_dat_v1_set_dynamic_addr(struct mchp_i3c_hci 
>>>> *hci,
>>>> +                                        unsigned int dat_idx, u8 
>>>> address)
>>>> +{
>>>> +        u32 dat_w0;
>>>> +
>>>> +        dat_w0 = dat_w0_read(dat_idx);
>>>> +        dat_w0 &= ~(DAT_0_DYNAMIC_ADDRESS | DAT_0_DYNADDR_PARITY);
>>>> +        dat_w0 |= FIELD_PREP(DAT_0_DYNAMIC_ADDRESS, address) |
>>>> +                  (dynaddr_parity(address) ? DAT_0_DYNADDR_PARITY 
>>>> : 0);
>>>> +        dat_w0_write(dat_idx, dat_w0);
>>>> +}
>
> This code calculates the parity wrong. See commit e55905a3f33c ("i3c:
> mipi-i3c-hci: use parity8 helper instead of open coding it").
>
> If I recall correctly this becomes visible with the 3rd or 4th device on
> the bus and therefore was for long unnoticed.
>
>>>> +static int mchp_i3c_hci_alloc_safe_xfer_buf(struct mchp_i3c_hci *hci,
>>>> +                                    struct mchp_hci_xfer *xfer)
>>>> +{
>>>> +     if (hci->io == &mchp_mipi_i3c_hci_pio ||
>>>> +         xfer->data == NULL || !is_vmalloc_addr(xfer->data))
>>>> +             return 0;
>>>> +     if (xfer->rnw)
>>>> +             xfer->bounce_buf = kzalloc(xfer->data_len, GFP_KERNEL);
>>>> +     else
>>>> +             xfer->bounce_buf = kmemdup(xfer->data,
>>>> +                                        xfer->data_len, GFP_KERNEL);
>>>> +
>>>> +     return xfer->bounce_buf == NULL ? -ENOMEM : 0;
>>>> +}
>>>> +
>>>> +static void mchp_i3c_hci_free_safe_xfer_buf(struct mchp_i3c_hci *hci,
>>>> +                                    struct mchp_hci_xfer *xfer)
>>>> +{
>>>> +     if (hci->io == &mchp_mipi_i3c_hci_pio || xfer->bounce_buf == 
>>>> NULL)
>>>> +     return;
>>>> +     if (xfer->rnw)
>>>> +             memcpy(xfer->data, xfer->bounce_buf, xfer->data_len);
>>>> +
>>>> +     kfree(xfer->bounce_buf);
>>>> +}
>
> Sidenote, these bounce buf stuff are complete unneeded if your HW
> supports only PIO transfers.
>
>>>> +static int mchp_i3c_hci_attach_i3c_dev(struct i3c_dev_desc *dev)
>>>> +{
>>>> +     struct i3c_master_controller *m = i3c_dev_get_master(dev);
>>>> +     struct mchp_i3c_hci *hci = to_i3c_hci(m);
>>>> +     struct mchp_i3c_hci_dev_data *dev_data;
>>>> +     int ret;
>>>> +
>>>> +     dev_data = kzalloc(sizeof(*dev_data), GFP_KERNEL);
>>>> +     if (!dev_data)
>>>> +             return -ENOMEM;
>>>> +     if (hci->cmd == &mchp_mipi_i3c_hci_cmd_v1) {
>>>> +             ret = mchp_mipi_i3c_hci_dat_v1.alloc_entry(hci);
>>>> +             if (ret < 0) {
>>>> +                     kfree(dev_data);
>>>> +                     return ret;
>>>> +             }
>>>> +             mchp_mipi_i3c_hci_dat_v1.set_dynamic_addr(hci, ret, 
>>>> dev->info.dyn_addr);
>>>> +             dev_data->dat_idx = ret;
>>>> +     }
>>>> +     i3c_dev_set_master_data(dev, dev_data);
>>>> +     return 0;
>>>> +}
>
> See commit 2b50719dd92f ("i3c: mipi-i3c-hci: Support SETDASA CCC").
>


  reply	other threads:[~2025-09-18  6:40 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-09 11:13 [PATCH 0/4] Add Microchip I3C controller Durai Manickam KR
2025-09-09 11:13 ` Durai Manickam KR
2025-09-09 11:13 ` [PATCH 1/4] clk: at91: sama7d65: add peripheral clock for I3C Durai Manickam KR
2025-09-09 11:13   ` Durai Manickam KR
2025-09-09 11:19   ` Durai.ManickamKR
2025-09-09 11:19     ` Durai.ManickamKR
2025-09-09 11:13 ` [PATCH 2/4] i3c: master: add Microchip SAMA7D65 I3C HCI master driver Durai Manickam KR
2025-09-09 11:13   ` Durai Manickam KR
2025-09-09 21:18   ` Frank Li
2025-09-09 21:18     ` Frank Li
2025-09-10  6:12     ` Durai.ManickamKR
2025-09-10  6:12       ` Durai.ManickamKR
2025-09-10  6:53       ` Wolfram Sang
2025-09-10  6:53         ` Wolfram Sang
2025-09-10  9:01       ` Jarkko Nikula
2025-09-10  9:01         ` Jarkko Nikula
2025-09-18  6:40         ` Durai.ManickamKR [this message]
2025-09-18  6:40           ` Durai.ManickamKR
2025-09-10 16:16       ` Frank Li
2025-09-10 16:16         ` Frank Li
2025-09-10  5:57   ` kernel test robot
2025-09-10  5:57     ` kernel test robot
2025-09-10  6:19     ` Durai.ManickamKR
2025-09-10  6:19       ` Durai.ManickamKR
2025-09-09 11:13 ` [PATCH 3/4] ARM: configs: at91: sama7: Add SAMA7D65 I3C HCI master Durai Manickam KR
2025-09-09 11:13   ` Durai Manickam KR
2025-09-09 11:13 ` [PATCH 4/4] ARM: dts: microchip: add I3C controller Durai Manickam KR
2025-09-09 11:13   ` Durai Manickam KR
2025-09-09 19:46 ` [PATCH 0/4] Add Microchip " Conor Dooley
2025-09-09 19:46   ` Conor Dooley
2025-09-10  6:14   ` Durai.ManickamKR
2025-09-10  6:14     ` Durai.ManickamKR
2025-09-10 17:54     ` Conor Dooley
2025-09-10 17:54       ` Conor Dooley

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=1a5dc012-eec2-40c5-90ea-bbff1ff713cd@microchip.com \
    --to=durai.manickamkr@microchip.com \
    --cc=Balamanikandan.Gunasundar@microchip.com \
    --cc=Frank.li@nxp.com \
    --cc=Nicolas.Ferre@microchip.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jarkko.nikula@linux.intel.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-i3c@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=wsa+renesas@sang-engineering.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.