Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp3368841lqp; Tue, 26 Mar 2024 07:27:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWo7mEZ8Xzej/BwycPjSdIt6KDtIX1w/rcS1yRuPbckr5T2TeiJZSHuP1p0dnI7ePLiseFoiSbPmgKToFWLOt+geIIyLoq9CLbLpArjpQ== X-Google-Smtp-Source: AGHT+IFm6okaCpWs0WvSRuWXDnz5Rh6Hj/+0rVoCtRGfaR1j3oNkiYNkCPZAvpgYlWHm6kSTsgvz X-Received: by 2002:a17:902:d68b:b0:1dc:a605:5435 with SMTP id v11-20020a170902d68b00b001dca6055435mr9274293ply.31.1711463263567; Tue, 26 Mar 2024 07:27:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711463263; cv=pass; d=google.com; s=arc-20160816; b=d+dRWDQOap/c5Od3NtseZ4EAUQHiGf05DUUBtgo8RTOdXGhxS5emjpAxPoKM13L98O R2lKkoqJcgN/xKcBijRYF0gsigV6LLsl1Ndu+HWgsZqOmy4ZEPQZeuUCMoZ8de6La6qF uQiAHw5jA4xVu26MksXptuNBN4LeYFqdRnUKp2BGyGD9z2xcDK8/wVZezRB9lN2HI+4r rlqpraQdv/lN+6Z4j++lYaJSlAgEhcef6AclqrkQNxxuGB/UszRgSMRQyJX63o8mf+ZH oSXl6yg4rWz0qYg8jPplEOcaNcp9gEEY/fu4YRBp7Mkno+TMI1a8BR2sFWT+tcejio7D JiXQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=XuI5Y48gxBaUyNDYDNzV0wWdK1Y/wauLqRKenBluhyA=; fh=0tIhEViLo7PUpyJI/8YvAfn7aU9qwVOIrJ6jkc06K5o=; b=QjbPlbx4eSCvjj0GYSUvajF65d60siMSGTdpn/EDiw5HGonpbJifkhI7p49yuKMue6 L3Jfr7LEIUJAnnL8EonSLE/N7RFQD1X7iGQOlzeph2qmtMjNVPvfckEx6AWFURAIFJew G2cCYYtatV77f0pP8sP87i46OMvteHNVLfx53ryE3q8KYeO1m//SOO0B9KPd1beDYZYC U+S6rWD8tVcVY70/mVwjqFs9+G7hUoxI7P4IFT3TuGN8kKw0qtaq3lbQpScdTCHKkFFC pCjJYqIcOkaEA7Y7SvXv7A53NOlvdym4h/C3WcUj3lc9lzkhMxoff6eLaPimBB2xWHsq VCeA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=W8zwX8+D; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-119173-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119173-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id n18-20020a170903111200b001e0f2ff9e91si1235174plh.235.2024.03.26.07.27.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 07:27:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-119173-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=W8zwX8+D; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-119173-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119173-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 45411302A0F for ; Tue, 26 Mar 2024 14:27:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 342C612DD97; Tue, 26 Mar 2024 14:27:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="W8zwX8+D" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4368512D765; Tue, 26 Mar 2024 14:27:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711463254; cv=none; b=I4wmqB6O1yz1HsIgEC1LiUQjdCHwW1pTyfLJHXmrZz/+pQHiOfZJh8ks5sLNqhceU5oGvN0YA1V+QC5Hs56s5SOGai31TyioDvNnCfZiesUK7o8X5cQGkHlgYKl34WNC+tdszLzOA3ElAaiNUr3nbnRrQEuFDXEp5+1pGcGdS+k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711463254; c=relaxed/simple; bh=LW9RMlhjXMwwswaA4XM355elpcokxVWRyHjYs7X4Luo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=G5Du8EGS4LTeb1ja9LkKUu3ODkXyyr9eVcPVPa8tdcLq3wbNWd84Pak4tq5OdiNnxZbZJ0J/jfBoigC1SRSP1M9l/IDRMHJ2itRpRy0+zvqaDMWLNulbbvgBi1FTALTYGZSZ6l1KlvtUYAmBD8Ehx3DlVRWEVk697CLwh6j04IE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=W8zwX8+D; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8EC5C433F1; Tue, 26 Mar 2024 14:27:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711463253; bh=LW9RMlhjXMwwswaA4XM355elpcokxVWRyHjYs7X4Luo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=W8zwX8+Dj6EWx5MT6Wn47Cd7patuQ8QPQ4ioHlq11Aze2rf+BuJMTHdGm9OiF5avM yQrZJiPxfUICNRrm7yGJHiTaZnuTzQIDMoVfJzUFFxibsv+r+Cng2BRyAmUglci+H0 Z+UOjIsmsH5t3wVD/MuyCAWshEzsjF6P8lWwEkVHkwTwRkavQ2o5nnLRFv2Rla6BVG sA+sb6pVYcXfOP4ya08e6gLkcYx+O16EZFOXef+vzMYNLQjmrjAxLn1cbmKGNJEC91 jXQn8o6fsxYKLMkBwy9zVGfZYfs2jrtEwuGEmPG8aeaMl032t5Op5OB/+mHirSrQSD TH6+rmekRv6DQ== Date: Tue, 26 Mar 2024 15:27:27 +0100 From: Niklas Cassel To: Manivannan Sadhasivam Cc: Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Kishon Vijay Abraham I , Thierry Reding , Jonathan Hunter , Jingoo Han , Gustavo Pimentel , linux-pci@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, mhi@lists.linux.dev, linux-tegra@vger.kernel.org Subject: Re: [PATCH 05/11] PCI: epf-{mhi/test}: Move DMA initialization to EPC init callback Message-ID: References: <20240314-pci-epf-rework-v1-0-6134e6c1d491@linaro.org> <20240314-pci-epf-rework-v1-5-6134e6c1d491@linaro.org> <20240326082636.GG9565@thinkpad> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Tue, Mar 26, 2024 at 12:05:42PM +0100, Niklas Cassel wrote: > On Tue, Mar 26, 2024 at 01:56:36PM +0530, Manivannan Sadhasivam wrote: > > On Fri, Mar 22, 2024 at 05:10:06PM +0100, Niklas Cassel wrote: > > > On Thu, Mar 14, 2024 at 08:53:44PM +0530, Manivannan Sadhasivam wrote: > > > > To maintain uniformity across EPF drivers, let's move the DMA > > > > initialization to EPC init callback. This will also allow us to deinit DMA > > > > during PERST# assert in the further commits. > > > > > > > > For EPC drivers without PERST#, DMA deinit will only happen during driver > > > > unbind. > > > > > > > > Signed-off-by: Manivannan Sadhasivam > > > > --- > > > > > > Reviewed-by: Niklas Cassel > > > > > > > > > For the record, I was debugging a problem related to EPF DMA recently > > > and was dumping the DMA mask for the struct device of the epf driver. > > > I was a bit confused to see it as 32-bits, even though the EPC driver > > > has it set to 64-bits. > > > > > > The current code works, because e.g., pci_epf_test_write(), etc, > > > does: > > > struct device *dma_dev = epf->epc->dev.parent; > > > dma_map_single(dma_dev, ...); > > > > > > but it also means that all EPF drivers will do this uglyness. > > > > > > > This ugliness is required as long as the dmaengine is associated only with the > > EPC. > > > > > > > > > > > However, if a EPF driver does e.g. > > > dma_alloc_coherent(), and sends in the struct *device for the EPF, > > > which is the most logical thing to do IMO, it will use the wrong DMA > > > mask. > > > > > > Perhaps EPF or EPC code should make sure that the struct *device > > > for the EPF will get the same DMA mask as epf->epc->dev.parent, > > > so that EPF driver developer can use the struct *epf when calling > > > e.g. dma_alloc_coherent(). > > > > > > > Makes sense. I think it can be done during bind() in the EPC core. Feel free to > > submit a patch if you like, otherwise I'll keep it in my todo list. > > So we still want to test: > -DMA API using the eDMA > -DMA API using the "dummy" memcpy dma-channel. > > However, it seems like both pci-epf-mhi.c and pci-epf-test.c > do either: > -Use DMA API > or > -Use memcpy_fromio()/memcpy_toio() instead of DMA API > > > To me, it seems like we should always be able to use > DMA API (using either a eDMA or "dummy" memcpy). > > I don't really see the need to have the path that does: > memcpy_fromio()/memcpy_toio(). > > I know that for DWC, when using memcpy (and this also > memcpy via DMA API), we need to map the address using > iATU first. > > But that could probably be done using another flag, > perhaps rename that flag FLAG_USE_DMA to NEEDS_MAP or > something. > (Such that we can change these drivers to only have a > code path that uses DMA API.) Looking at pci-epf-mhi.c, it seems to use names like: pci_epf_mhi_iatu_read() and pci_epf_mhi_edma_read(). This seems to be a very DWC focused naming. AFAICT, EPF drivers should work on any PCIe EP controller that implements the EPC API. Yes, I understand that it is only Qualcomm that uses this MHI interface/bus, but what is stopping Qualcomm from using a non-DWC based PCIe EP controller in an upcoming SoC? Surely that Qualcomm SoC could still implement the MHI interface/bus, so perhaps the naming in this EPF driver should use somewhat less "EPC vendor specific" function names? Kind regards, Niklas