Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2620551rdb; Wed, 4 Oct 2023 06:52:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHbOM43VxP5dYItGVyDR9o00edZ3ZYJYDDe7yhLw1ewJy2NmDaBdmF/b3LmQxPs2a3VA3zP X-Received: by 2002:a05:6a21:7892:b0:12c:2dc7:74bc with SMTP id bf18-20020a056a21789200b0012c2dc774bcmr2836481pzc.46.1696427556135; Wed, 04 Oct 2023 06:52:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696427556; cv=none; d=google.com; s=arc-20160816; b=B0D15pjXUuRk+wTl3wrUq+VkSFWnlshWaTNwBB1nRoW7BlMIQniftqRm66I0CHzMsI ysIPmPJF4pfwiNtOpaisvOOV7zaoWwKQWom91eByakTF1Ep4SHGgin6BLjehhiriXn/k yj8N+hKRS+4zrgzglel6tBHWgKUgBiGkLgqDYvMP+A67QadzqVxqaeYS61wWweG3F45e LtxI3pF8pY8kfsND179UsMpgdUPTvwidop1foPHUhie09XeFNGE3y44tsnDy6sOaQbbq QDM78trKmn/so8qiVa5ugVD6rvlzfCqftKr94V7sLJ6jh1tw3sSd+lHcnOT47hQiDQ2J yX1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=KcjfRyeZMHPf1SqYXPE394CsKwR0EDN9c34JKtA7meo=; fh=+lJW6f/tP5Dwo/ntK8PF80yL590VC4OrnXubZAmRo1I=; b=ERxmbNhbUWpS6p3miUeX4DREwKwl5v3BwgkuRPB9RurEoNAX2TCgaZHx4JISC8QFK/ AgEV+/2fSZbIjChkcOdhTsgIthgBEVG396p76XDRMkclnIBOXN3D5fd/Jfiu0fUaTYVe zWbZ0pVKAUT2WyjlIX87uXfymbdeZb4oVLXstQvphAsOlBjLN/kXmL2t4KYX48NaKQnM kJL31h/7v1bwdXO9/DKOfeIbv2BSCDwlIemVRzlOLhNqA3qICamyNazJfJvo8i9Wvldh kTUMFqTKlLZd3okwlyI3Aw/RzBhb+B1d6Hp/akSUzFKMtZcPcsSjdQsZzGgPqZJU1cSv gTAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cutebit.org header.s=mail header.b=b0bRMs56; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cutebit.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id g20-20020a056a0023d400b006935df301a3si3829316pfc.8.2023.10.04.06.52.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 06:52:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@cutebit.org header.s=mail header.b=b0bRMs56; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cutebit.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id EBD6481ADCE5; Wed, 4 Oct 2023 06:52:32 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233414AbjJDNw2 (ORCPT + 99 others); Wed, 4 Oct 2023 09:52:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232786AbjJDNw1 (ORCPT ); Wed, 4 Oct 2023 09:52:27 -0400 Received: from hutie.ust.cz (hutie.ust.cz [IPv6:2a03:3b40:fe:f0::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D706AD; Wed, 4 Oct 2023 06:52:22 -0700 (PDT) Content-Type: text/plain; charset=utf-8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cutebit.org; s=mail; t=1696427540; bh=KcjfRyeZMHPf1SqYXPE394CsKwR0EDN9c34JKtA7meo=; h=Subject:From:In-Reply-To:Date:Cc:References:To; b=b0bRMs56ZQdQhG8778vaNx6rLXBxkPB1rTVglaTKYCjHHrzRAtw4c/onwv9LZ4Mmv W6ZhdRJGOX5jbxUPqicRdFcwzHzZp4Wj/prtvmCw8nLpJko2JhWh/jYPfVADSmPgO6 jdM6Yf6kiLVU6gD4+dSAoCgYhmz1aJ3k//0+q7Ys= Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) Subject: Re: [PATCH v2 2/2] dmaengine: apple-sio: Add Apple SIO driver From: =?utf-8?Q?Martin_Povi=C5=A1er?= In-Reply-To: Date: Wed, 4 Oct 2023 15:52:09 +0200 Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , asahi@lists.linux.dev, dmaengine@vger.kernel.org, devicetree@vger.kernel.org, Linux Kernel Mailing List Content-Transfer-Encoding: quoted-printable Message-Id: References: <20230828170013.75820-1-povik+lin@cutebit.org> <20230828170013.75820-3-povik+lin@cutebit.org> <06444557-414A-4710-88A0-620975BB258A@cutebit.org> To: Vinod Koul X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 04 Oct 2023 06:52:33 -0700 (PDT) > On 4. 10. 2023, at 15:46, Vinod Koul wrote: >=20 > On 04-10-23, 15:32, Martin Povi=C5=A1er wrote: >=20 >>>> + * 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 >>>=20 >>> you meant SIO_MAX_INFLIGHT if not what is NINFLIGHT? >>=20 >> I mean the number is arbitrary, it doesn=E2=80=99t reflect any = coprocessor limit since >> I haven=E2=80=99t run the tests to figure one out. It's supposed to = be a small reasonable >> number. >=20 > 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=E2=80=99t know = what you would interpret to be the difference between NINFLIGHT and INFLIGHT, in my = book both would be the "number of inflight=E2=80=9D in the context here. >>>> +static int sio_device_config(struct dma_chan *chan, >>>> + struct dma_slave_config *config) >>>> +{ >>>> + struct sio_chan *siochan =3D to_sio_chan(chan); >>>> + struct sio_data *sio =3D siochan->host; >>>> + bool is_tx =3D sio_chan_direction(siochan->no) =3D=3D = DMA_MEM_TO_DEV; >>>> + struct sio_shmem_chan_config *cfg =3D sio->shmem; >>>> + int ret; >>>> + >>>> + switch (is_tx ? config->dst_addr_width : config->src_addr_width) = { >>>> + case DMA_SLAVE_BUSWIDTH_1_BYTE: >>>> + cfg->datashape =3D 0; >>>> + break; >>>> + case DMA_SLAVE_BUSWIDTH_2_BYTES: >>>> + cfg->datashape =3D 1; >>>> + break; >>>> + case DMA_SLAVE_BUSWIDTH_4_BYTES: >>>> + cfg->datashape =3D 2; >>>> + break; >>>> + default: >>>> + return -EINVAL; >>>> + } >>>> + >>>> + cfg->fifo =3D 0x800; >>>> + cfg->limit =3D 0x800; >>>> + cfg->threshold =3D 0x800; >>>> + dma_wmb(); >>>=20 >>> ?? >>=20 >> Again, shared memory >>=20 >>>> + >>>> + ret =3D sio_call(sio, FIELD_PREP(SIOMSG_TYPE, MSG_CONFIGURE) | >>>> + FIELD_PREP(SIOMSG_EP, siochan->no)); >>>=20 >>> this does not sound okay, can you explain why this call is here >>=20 >> We are sending the configuration to the coprocessor, it will NACK >> it if invalid, seems very fitting here. >=20 > 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 >=20 > 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 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. Martin > --=20 > ~Vinod >=20