All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vinod Koul <vkoul@kernel.org>
To: "Martin Povišer" <povik+lin@cutebit.org>
Cc: Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Conor Dooley <conor+dt@kernel.org>,
	asahi@lists.linux.dev, dmaengine@vger.kernel.org,
	devicetree@vger.kernel.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/2] dmaengine: apple-sio: Add Apple SIO driver
Date: Wed, 4 Oct 2023 19:31:29 +0530	[thread overview]
Message-ID: <ZR1wOT7Gat/BiOr4@matsya> (raw)
In-Reply-To: <C054722F-B1E0-4F4E-A45D-5F603738249C@cutebit.org>

On 04-10-23, 15:52, Martin Povišer wrote:
> 
> > On 4. 10. 2023, at 15:46, Vinod Koul <vkoul@kernel.org> wrote:
> > 
> > On 04-10-23, 15:32, Martin Povišer wrote:
> > 
> >>>> + * There are two kinds of 'transaction descriptors' in play here.
> >>>> + *
> >>>> + * There's the struct sio_tx, and the struct dma_async_tx_descriptor embedded
> >>>> + * inside, which jointly represent a transaction to the dmaengine subsystem.
> >>>> + * At this time we only support those transactions to be cyclic.
> >>>> + *
> >>>> + * Then there are the coprocessor descriptors, which is what the coprocessor
> >>>> + * knows and understands. These don't seem to have a cyclic regime, so we can't
> >>>> + * map the dmaengine transaction on an exact coprocessor counterpart. Instead
> >>>> + * we continually queue up many coprocessor descriptors to implement a cyclic
> >>>> + * transaction.
> >>>> + *
> >>>> + * The number below is the maximum of how far ahead (how many) coprocessor
> >>>> + * descriptors we should be queuing up, per channel, for a cyclic transaction.
> >>>> + * Basically it's a made-up number.
> >>>> + */
> >>>> +#define SIO_MAX_NINFLIGHT 4
> >>> 
> >>> you meant SIO_MAX_INFLIGHT if not what is NINFLIGHT?
> >> 
> >> I mean the number is arbitrary, it doesn’t reflect any coprocessor limit since
> >> I haven’t run the tests to figure one out. It's supposed to be a small reasonable
> >> number.
> > 
> > Sorry that was not my question. Should this macro be SIO_MAX_NINFLIGHT
> > or SIO_MAX_INFLIGHT..?
> 
> Yeah, I realized after I sent the reply, sorry. I don’t know what you would
> interpret to be the difference between NINFLIGHT and INFLIGHT, in my book
> both would be the "number of inflight” in the context here.

No worries, I wante to check that was on purpose, it is fine


> >>>> +static int sio_device_config(struct dma_chan *chan,
> >>>> +      struct dma_slave_config *config)
> >>>> +{
> >>>> + struct sio_chan *siochan = to_sio_chan(chan);
> >>>> + struct sio_data *sio = siochan->host;
> >>>> + bool is_tx = sio_chan_direction(siochan->no) == DMA_MEM_TO_DEV;
> >>>> + struct sio_shmem_chan_config *cfg = sio->shmem;
> >>>> + int ret;
> >>>> +
> >>>> + switch (is_tx ? config->dst_addr_width : config->src_addr_width) {
> >>>> + case DMA_SLAVE_BUSWIDTH_1_BYTE:
> >>>> + cfg->datashape = 0;
> >>>> + break;
> >>>> + case DMA_SLAVE_BUSWIDTH_2_BYTES:
> >>>> + cfg->datashape = 1;
> >>>> + break;
> >>>> + case DMA_SLAVE_BUSWIDTH_4_BYTES:
> >>>> + cfg->datashape = 2;
> >>>> + break;
> >>>> + default:
> >>>> + return -EINVAL;
> >>>> + }
> >>>> +
> >>>> + cfg->fifo = 0x800;
> >>>> + cfg->limit = 0x800;
> >>>> + cfg->threshold = 0x800;
> >>>> + dma_wmb();
> >>> 
> >>> ??
> >> 
> >> Again, shared memory
> >> 
> >>>> +
> >>>> + ret = sio_call(sio, FIELD_PREP(SIOMSG_TYPE, MSG_CONFIGURE) |
> >>>> +     FIELD_PREP(SIOMSG_EP, siochan->no));
> >>> 
> >>> this does not sound okay, can you explain why this call is here
> >> 
> >> We are sending the configuration to the coprocessor, it will NACK
> >> it if invalid, seems very fitting here.
> > 
> > I dont this so, purpose of the device_config() is to send peripheral
> > config to driver for use on the next descriptor which is submitted. So
> > sending to co-processor now (when we might even have a txn going on)
> > does not seem right
> > 
> > What would be the behaviour if already a txn is progressing on the
> > co-processor
> 
> I have no idea.
> 
> OK, though is that necessarily part of the dmaengine interface? I ask

Yes, the configuration is applied on next descriptor that is prepared

See: Documentation/driver-api/dmaengine/provider.rst
"  - This command should NOT perform synchronously, or on any
    currently queued transfers, but only on subsequent ones"

> because the other driver I have written (apple-admac.c) does basically
> the same, only it applies the new configuration in MMIO registers rather
> than sending it to a coprocessor, but the end result is the same:
> the configuration gets checked for validity, and applied right away.

That should be fixed too :-)

-- 
~Vinod

  reply	other threads:[~2023-10-04 14:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-28 17:00 [PATCH v2 0/2] Apple SIO driver Martin Povišer
2023-08-28 17:00 ` [PATCH v2 1/2] dt-bindings: dma: apple,sio: Add schema Martin Povišer
2023-08-28 17:00 ` [PATCH v2 2/2] dmaengine: apple-sio: Add Apple SIO driver Martin Povišer
2023-08-31 22:29   ` kernel test robot
2023-09-04  5:39   ` Neal Gompa
2023-10-04 13:12   ` Vinod Koul
2023-10-04 13:32     ` Martin Povišer
2023-10-04 13:41       ` Martin Povišer
2023-10-04 13:46       ` Vinod Koul
2023-10-04 13:52         ` Martin Povišer
2023-10-04 14:01           ` Vinod Koul [this message]
2023-09-04  5:45 ` [PATCH v2 0/2] " Neal Gompa

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=ZR1wOT7Gat/BiOr4@matsya \
    --to=vkoul@kernel.org \
    --cc=asahi@lists.linux.dev \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=povik+lin@cutebit.org \
    --cc=robh+dt@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 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.