Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp958277rwe; Wed, 24 Aug 2022 12:03:48 -0700 (PDT) X-Google-Smtp-Source: AA6agR6ZRJ2X3HlGHkCat92CnKiIiM+pzooeGCm1DlmxaFfzqJEX3Bwg4Byl9+tpCMNPii8hgA6u X-Received: by 2002:a17:907:971e:b0:731:48b3:6fb7 with SMTP id jg30-20020a170907971e00b0073148b36fb7mr219392ejc.267.1661367828254; Wed, 24 Aug 2022 12:03:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661367828; cv=none; d=google.com; s=arc-20160816; b=iOaRDmRifHBNR0EdWOEoQ9L/HjRgOrpw7MKMQ6VUxPNYf151LycR4n3zlNeQsHsjT0 Zf0rU13F52eHFxkHdCiapZAOEfaWtS8zb+p7onPBeO2Oki5dc/JsQiD6lkltvQ1Lj/Wt /jQfN5k0Ap08cSowLv44Xiq8V2x3Jf140Wucj15IY5BTh1sGEVqYn4/9LhkU/1j/Mumw gOt7WTX5X5yEcPh6WEs66y5ce/igiw6Nu2sE4jqXjIfH9p0g4b8A4xS4HxkO19TD+9Os 3xaIzRJK1PfEQlRQsvPdQqDidQ+x8pbGUYmUGgWuL/36nLdI/oZEUEG6NWe7s0wnBMHh NuvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=0lbGMmFuLLALNWNwg1IFLsjuEsYjoBL8hbke8mOWVoI=; b=QUICA+j0HfqB/bMYhd1p6zZgCmRudnIMfFsFs4js9yj1xTZnoknpCclYZ7bkxMZ+tx J6uXlI/LLNi/Te0AnEckmr4JGmHOiQhUda7P9WhSZSLMQow9D+vNsG0jj85CPbFx5z0H O6bTuML2vbpIzeROfLhVt/oqJu/dcTN19aKofJcL/RFLEVgZrv6e9r/useLA8oUumw8+ oGLykF6OSIStuuW6AdjBH7Nql6YyoWywuqKslLSK5JgNPXtYfe2fPpIC4N40bwcTdLRV 1W27MIrKP433eIrUCnAe0UOnyB9VLcKyau59maXCXHIcbKyeXlANgbg2qA1awQ5D8K9x qt5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Aofr0GgW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id he8-20020a1709073d8800b0072b193ac94bsi2992776ejc.627.2022.08.24.12.03.20; Wed, 24 Aug 2022 12:03:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Aofr0GgW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239381AbiHXSN2 (ORCPT + 99 others); Wed, 24 Aug 2022 14:13:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239717AbiHXSN0 (ORCPT ); Wed, 24 Aug 2022 14:13:26 -0400 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BCE86D57D; Wed, 24 Aug 2022 11:13:24 -0700 (PDT) Received: by mail-lj1-x229.google.com with SMTP id bn9so9629728ljb.6; Wed, 24 Aug 2022 11:13:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc; bh=0lbGMmFuLLALNWNwg1IFLsjuEsYjoBL8hbke8mOWVoI=; b=Aofr0GgWtsbO+tksHCUzbtLNRJML9u9bqdG1Q/NKZHzU2wpBZVi53bbaV2j8B2n+cd jYV8RwOFAtTzcotGJLVc2rM8x9xAsK+NBzfbQhrPJQD9U88qDGWY9URxnZ4pc6HPEkj+ ZB/oZn0OcB9GDiABotSVaIPA56PZny2gjpsD3tH3GtvO3fBxm2QB3AjmhoRCCTaZjENk 6w9c3to/qfJueaxivE0IYILzyLjAezRwccVbMyec4PFC/nayKsdmAKnj0dUH76gTai66 L3Td55qhlBs/lFvhf8LR7/QQhKWiXkoQ8vidIdn1hZ8gNqNVxeu2gWcoVlPkOsBHvXIN c78w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc; bh=0lbGMmFuLLALNWNwg1IFLsjuEsYjoBL8hbke8mOWVoI=; b=rvugMedwu3mWn7ok+4hpQ/fAEYhcfFIEPUsVXspWTVekxYD1zFFltNZmIkNkqjWgOz pe1QJ5FifuBw4ZqW2nCcwEYNTfyiMWqkg4tKmmjQAkGyPFH+HYq5vPLZ5tsdibHrFJLc mDVEDii29ScP8yZ1exc08I1JbOAabDV47BgUHe3u+kibpPeU85jZ2a4XzFs8PGnKAwdT Ix7OUDJJ6kea7xb7hmdOhI6ouO0C/AdAuaD41YoP4qMqQqRaNgsXrORSJBMu7GyPJXWo yZkkSL+Tx5WwfXu2XXAv+E5BykccmC20cGh52T55lId4Z2p0T+9IuXvvF4mcUWbt+09S wQLQ== X-Gm-Message-State: ACgBeo1Xly0W76d5X1NgrDqDPy+7EPyA2qIjzfoqqq6LWCUrYQhlCkHp VFkKkTmlBnYorczBWIvD9nA= X-Received: by 2002:a2e:a78f:0:b0:25f:dedf:efb8 with SMTP id c15-20020a2ea78f000000b0025fdedfefb8mr93629ljf.317.1661364802678; Wed, 24 Aug 2022 11:13:22 -0700 (PDT) Received: from mobilestation ([95.79.140.178]) by smtp.gmail.com with ESMTPSA id o13-20020ac24e8d000000b00492f37e428asm31397lfr.172.2022.08.24.11.13.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Aug 2022 11:13:22 -0700 (PDT) Date: Wed, 24 Aug 2022 21:13:19 +0300 From: Serge Semin To: Bjorn Helgaas Cc: Serge Semin , Gustavo Pimentel , Vinod Koul , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Jingoo Han , Frank Li , Manivannan Sadhasivam , Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Alexey Malahov , Pavel Parkhomenko , linux-pci@vger.kernel.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH RESEND v5 24/24] PCI: dwc: Add DW eDMA engine support Message-ID: <20220824181319.wkj4256a5jp2xjlp@mobilestation> References: <20220822185332.26149-25-Sergey.Semin@baikalelectronics.ru> <20220824165118.GA2785269@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220824165118.GA2785269@bhelgaas> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 24, 2022 at 11:51:18AM -0500, Bjorn Helgaas wrote: > On Mon, Aug 22, 2022 at 09:53:32PM +0300, Serge Semin wrote: > > Since the DW eDMA driver now supports eDMA controllers embedded into the > > locally accessible DW PCIe Root Ports and Endpoints, we can use the > > updated interface to register DW eDMA as DMA engine device if it's > > available. In order to successfully do that the DW PCIe core driver need > > to perform some preparations first. First of all it needs to find out the > > eDMA controller CSRs base address, whether they are accessible over the > > Port Logic or iATU unrolled space. Afterwards it can try to auto-detect > > the eDMA controller availability and number of it's read/write channels. > > s/it's// Ok. > > > If none was found the procedure will just silently halt with no error > > returned. Secondly the platform is supposed to provide either combined or > > per-channel IRQ signals. If no valid IRQs set is found the procedure will > > also halt with no error returned so to be backward compatible with the > > platforms where DW PCIe controllers have eDMA embedded but lack of the > > IRQs defined for them. Finally before actually probing the eDMA device we > > need to allocate LLP items buffers. After that the DW eDMA can be > > registered. If registration is successful the info-message regarding the > > number of detected Read/Write eDMA channels will be printed to the system > > log in the similar way as it's done for the iATU settings. > > s/in the similar way as it's done/as is done/ Ok > > > +static int dw_pcie_edma_find_chip(struct dw_pcie *pci) > > +{ > > + u32 val; > > + > > + val = dw_pcie_readl_dbi(pci, PCIE_DMA_VIEWPORT_BASE + PCIE_DMA_CTRL); > > + if (val == 0xFFFFFFFF && pci->edma.reg_base) { > > + pci->edma.mf = EDMA_MF_EDMA_UNROLL; > > + > > + val = dw_pcie_readl_dma(pci, PCIE_DMA_CTRL); > > + } else if (val != 0xFFFFFFFF) { > > Consider PCI_POSSIBLE_ERROR() as an annotation about the meaning of > 0xFFFFFFFF and something to grep for. In this case FFs don't mean an error but a special value, which indicates that the eDMA is mapped via the unrolled CSRs space. The similar approach has been implemented for the iATU legacy/unroll setup auto-detection. So I don't see much reasons to have it grepped, so as to have a macro-based parametrization since the special value will unluckily change while having the explicit literal utilized gives a better understanding of the way the algorithm works. > > > + pci->edma.mf = EDMA_MF_EDMA_LEGACY; > > + > > + pci->edma.reg_base = pci->dbi_base + PCIE_DMA_VIEWPORT_BASE; > > + } else { > > + return -ENODEV; > > + } > > > + * eDMA CSRs. DW PCIe IP-core v4.70a and older had the eDMA registers accessible > > + * over the Port Logic registers space. Afterwords the unrolled mapping was > > s/Afterwords/Afterwards/ Ok. -Sergey > > > + * introduced so eDMA and iATU could be accessed via a dedicated registers > > + * space.