linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Akhil R <akhilrajeev@nvidia.com>
To: Jonathan Hunter <jonathanh@nvidia.com>, Rob Herring <robh@kernel.org>
Cc: Laxman Dewangan <ldewangan@nvidia.com>,
	"vkoul@kernel.org" <vkoul@kernel.org>,
	"thierry.reding@gmail.com" <thierry.reding@gmail.com>,
	"p.zabel@pengutronix.de" <p.zabel@pengutronix.de>,
	"dmaengine@vger.kernel.org" <dmaengine@vger.kernel.org>,
	"linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"krzysztof.kozlowski+dt@linaro.org" 
	<krzysztof.kozlowski+dt@linaro.org>,
	"sfr@canb.auug.org.au" <sfr@canb.auug.org.au>
Subject: RE: [PATCH RESEND v2 3/3] dmaengine: tegra: Add support for dma-channel-mask
Date: Thu, 27 Oct 2022 10:13:00 +0000	[thread overview]
Message-ID: <SJ1PR12MB6339F181734DA0A05B4862AFC0339@SJ1PR12MB6339.namprd12.prod.outlook.com> (raw)
In-Reply-To: <76617e20-2a1d-baba-719d-bd8b32fa69be@nvidia.com>

> On 26/10/2022 05:44, Akhil R wrote:
> >> On Thu, Oct 20, 2022 at 02:03:22PM +0530, Akhil R wrote:
> >>> Add support for dma-channel-mask so that only the specified channels
> >>> are used. This helps to reserve some channels for the firmware.
> >>>
> >>> This was initially achieved by limiting the channel number to 31 in
> >>> the driver and adjusting the register address to skip channel0 which
> >>> was reserved for a firmware. Now, with this change, the driver can
> >>> align more to the actual hardware which has 32 channels.
> >>>
> >>> Signed-off-by: Akhil R <akhilrajeev@nvidia.com>
> >>> Reviewed-by: Jon Hunter <jonathanh@nvidia.com>
> >>> ---
> >>>   drivers/dma/tegra186-gpc-dma.c | 37 +++++++++++++++++++++++++++----
> ---
> >>>   1 file changed, 30 insertions(+), 7 deletions(-)
> >>>
> >>> diff --git a/drivers/dma/tegra186-gpc-dma.c b/drivers/dma/tegra186-gpc-
> >> dma.c
> >>> index fa9bda4a2bc6..1d1180db6d4e 100644
> >>> --- a/drivers/dma/tegra186-gpc-dma.c
> >>> +++ b/drivers/dma/tegra186-gpc-dma.c
> >>> @@ -161,7 +161,10 @@
> >>>   #define TEGRA_GPCDMA_BURST_COMPLETION_TIMEOUT        5000 /* 5
> >> msec */
> >>>
> >>>   /* Channel base address offset from GPCDMA base address */
> >>> -#define TEGRA_GPCDMA_CHANNEL_BASE_ADD_OFFSET 0x20000
> >>> +#define TEGRA_GPCDMA_CHANNEL_BASE_ADDR_OFFSET        0x10000
> >>> +
> >>> +/* Default channel mask reserving channel0 */
> >>> +#define TEGRA_GPCDMA_DEFAULT_CHANNEL_MASK    0xfffffffe
> >>>
> >>>   struct tegra_dma;
> >>>   struct tegra_dma_channel;
> >>> @@ -246,6 +249,7 @@ struct tegra_dma {
> >>>        const struct tegra_dma_chip_data *chip_data;
> >>>        unsigned long sid_m2d_reserved;
> >>>        unsigned long sid_d2m_reserved;
> >>> +     u32 chan_mask;
> >>>        void __iomem *base_addr;
> >>>        struct device *dev;
> >>>        struct dma_device dma_dev;
> >>> @@ -1288,7 +1292,7 @@ static struct dma_chan
> *tegra_dma_of_xlate(struct
> >> of_phandle_args *dma_spec,
> >>>   }
> >>>
> >>>   static const struct tegra_dma_chip_data tegra186_dma_chip_data = {
> >>> -     .nr_channels = 31,
> >>> +     .nr_channels = 32,
> >>
> >> This is an ABI break. A new kernel with an old DTB will use 32 channels
> >> instead of 31. You should leave this and use the dma-channel-mask to
> >> enable all 32 channels.
> >>
> > Hi Rob,
> >
> > If using an old DTB, tdma->chan_mask will be default to 0xfffffffe since it
> > would not have the dma-channel-mask property. The driver would still
> > use 31 channels even if it uses an old DTB. Shouldn't it prevent the
> > ABI break?
> 
> Unfortunately no. Yes for an old DTB without the dma-channel-mask
> property, we set the channel mask to 0xfffffffe, but this is not correct
> because it only has 31 interrupts/channels and not 32. So I think we
> will need to use of_irq_count() here.
>

Shall I put it in a way that only the used interrupts are mentioned in the DT?
With this I can revert the interrupt change in the DT and would not break
the ABI as well.

The code would look something like this.

int chan_count = 0;

if (of_irq_count(pdev->dev.of_node) != hweight_long(tdma->chan_mask)) {
        dev_err(&pdev->dev, "Interrupt count doesn't match with channels\n");
        return -EINVAL;
}

for (i = 0; i < cdata->nr_channels; i++) {
        struct tegra_dma_channel *tdc = &tdma->channels[i];
    
        /* Check for channel mask */
        if (!(tdma->chan_mask & BIT(i)))
            continue;

        tdc->irq = platform_get_irq(pdev, chan_count);
        chan_count++;
        if (tdc->irq < 0)
            return tdc->irq;
    ...
    ...
}

Regards,
Akhil

  reply	other threads:[~2022-10-27 10:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-20  8:33 [PATCH RESEND v2 0/3] Tegra GCPDMA: Add dma-channel-mask support Akhil R
2022-10-20  8:33 ` [PATCH RESEND v2 1/3] dt-bindings: dmaengine: Add dma-channel-mask to Tegra GPCDMA Akhil R
2022-10-27 13:38   ` Krzysztof Kozlowski
2022-10-20  8:33 ` [PATCH RESEND v2 2/3] arm64: tegra: Add dma-channel-mask in GPCDMA node Akhil R
2022-10-21  2:18   ` Rob Herring
2022-10-20  8:33 ` [PATCH RESEND v2 3/3] dmaengine: tegra: Add support for dma-channel-mask Akhil R
2022-10-21  2:16   ` Rob Herring
2022-10-26  4:44     ` Akhil R
2022-10-26  9:30       ` Jon Hunter
2022-10-27 10:13         ` Akhil R [this message]
2022-11-01 11:40           ` Thierry Reding
  -- strict thread matches above, loose matches on Subject: below --
2022-10-18 16:28 [PATCH RESEND v2 0/3] Tegra GCPDMA: Add dma-channel-mask support Akhil R
2022-10-18 16:28 ` [PATCH RESEND v2 3/3] dmaengine: tegra: Add support for dma-channel-mask Akhil R

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=SJ1PR12MB6339F181734DA0A05B4862AFC0339@SJ1PR12MB6339.namprd12.prod.outlook.com \
    --to=akhilrajeev@nvidia.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=jonathanh@nvidia.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=ldewangan@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=robh@kernel.org \
    --cc=sfr@canb.auug.org.au \
    --cc=thierry.reding@gmail.com \
    --cc=vkoul@kernel.org \
    /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).