Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp1251715rdb; Fri, 16 Feb 2024 09:35:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXM9kHFxlCxTiT2XFUzmtIMK8E9CJkZDxIsfhO1Q0ey6BUCuPzBME3z/oWSIn19J+HpwpoewajC4oM+ky34ypJWIOO0RRQAFWPkIiAd/Q== X-Google-Smtp-Source: AGHT+IGjIcpmTxX+rWmDv2hwYkBvFztzDfRYmhgin45EuAxe/t83xfxUMc+JhNei4NtJuQY/FpJU X-Received: by 2002:aa7:dada:0:b0:564:9bf:af07 with SMTP id x26-20020aa7dada000000b0056409bfaf07mr955424eds.31.1708104925430; Fri, 16 Feb 2024 09:35:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708104925; cv=pass; d=google.com; s=arc-20160816; b=OFXE2pvpM91AY6ICbxJcLJGNqRv1pp5JAEQgvUyMUQwpR3AdNtocOgHV5nQZp3RcBC mCrIk5gTZufaWaG9aR4174I/GX+qdPyJjIaIbS1i/YEAdcmbEKVmRMXwRG+XdknwOgWA vxue3BV9osupNGBvLkLJtVm1igd/SNIQwSY1Dnl+eeJaO8bm8oLOyhEMfE1QwU4HCEOS fl9hUTrO9En2zGlOOTkc9YdnejBKJx5fuK40EezlKA89xUjgKXju+QEJzfYhfUzwF9XU FQbdDvYEsjslDd0K0cChtmUNwJUahDr4jhl11rcUCibhyx3f+lyy6jBn43fs/01ZGaOJ 02gA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=8efIfXj3EDiKaREh1NVON3UM6rTKzHGcjeds+XSN7t8=; fh=dSUjDLRsY9CETqtLU6PxaSzKE4FyUextaYcOEc5KSBg=; b=O9+/xohQ/sefYbtJbo7r35aWy377wpXsAX6cUk41lCwzPE9x/KYjH5AqvboS9Kizl1 Cg84bqVkrOR4C4qNC3QehCjSiB3mzwHg+pKSH5nX6K8KjMlozMVVTWZ1jrEKX3RfjQoK E9ww4489LWFW65xPxuwjsjgVCbEP1rdGrGNzZPb7f5dlFW1epYvHQLylrpM9TyTQmX0u n10e0CoOU+r/De4WivuLXgt4zgV/pV7qn9cA4eKigR+9+hRDMd/zFp3Ae6kbQponnLtk L8iUtq68DdsZ2lcNTFzHLt06IEN+0fhGDg806IdNk3nj0f8SpI0dZnGd+TfZo/BRGLkt Ffwg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FBHDoMzD; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-69075-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69075-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id y24-20020aa7ccd8000000b0056391332f0bsi147468edt.174.2024.02.16.09.35.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 09:35:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69075-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FBHDoMzD; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-69075-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69075-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 09A0A1F22075 for ; Fri, 16 Feb 2024 17:35:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 69DBE130AD9; Fri, 16 Feb 2024 17:35:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="FBHDoMzD" Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 062FF131E52 for ; Fri, 16 Feb 2024 17:35:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708104905; cv=none; b=MBrO9bf2CLLa9TnSi5kotDLfm6PlpXcUtm8x6ZeYBORxjHFwP1HtAXpDDxFZCF9nJyyeSnNcn1omjawlo87QtHeRT2RPmt5rY1OXG1HaP9ojq86xpB+EnXZHUpYuswlMM8bNlIvq4SHZQ93r1Jq7SnN+9lTFONDh7/P7DlG9weY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708104905; c=relaxed/simple; bh=m8AOqRiSHCcO5mZcayvtN8wItwmC4U+br9OIM450sVs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=V7DKRJJ1KV6UauA4TMMjulxZDll+uSReIiEkAd8XIkKajCJ38w705L1j+JhRLzBuVLJ0vvdo2T3rk06gocAEGIICHc16jdTFINQyFFRiG75mAG54tuTWyjUxl9YvAwSnCu1tETvGxhEP4WAuJDTOkpA7AhVtx2iSzD+ZJvam3PI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=FBHDoMzD; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-1d934c8f8f7so23977925ad.2 for ; Fri, 16 Feb 2024 09:35:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708104903; x=1708709703; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=8efIfXj3EDiKaREh1NVON3UM6rTKzHGcjeds+XSN7t8=; b=FBHDoMzDAD1CPsX06sBmXhCQksFkKDaNL9zLIJ2JQUp3lUC8uDGLgS2b+o4/e2/d7P BeTqaY9WxVMS3q1Uhc4ORJLZTnNKUGYyC7+SM4eYQg6m4SRvgX89IpDhR5WuU+NciKM9 nmJ6xwfFlpjVe4GJaoEdj3IGpJi9nqE2xgt9RWSQrw1BUrMmLfKH1Wu90D05TLU7fWEQ 3yWzEr+ts59nsgdR5BTbcjHeuk6p4mBL96gsFy2dn5h6JT/zINBSLmXxhqvrpSqkKWZ/ F6inbWCC9mcEeYwrLTAB3A8AbcpHkw8Sj8Y8RJNH5ii/fCxONg59tAXCWFnNj6tgBdbw aoZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708104903; x=1708709703; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8efIfXj3EDiKaREh1NVON3UM6rTKzHGcjeds+XSN7t8=; b=lHZqAL//eIBmRR89XnNldbsVb7UzrCdTIXKcduU+RepI7CCbQJCxcG+zDWQu5VohaE m+RuFvymRLVf4P+1CvWGOklEhmW7k2wCeV8SwrLtGiUVSTixx4w5ipVHNadPUPxBWaHM lfzgzxxbjTZs084b21UZtsugrU2zrWLTXtwVO4wKU1Xw5xYb4J4I1GKoaqazWOob8IBo wsgPcBMDI8qlG28BgP6VS2Y33APxiFQSR3BdCITn3JCijEy2biMNRsUP+F7py9JGaFq6 zvL8t8F9F+3WOuJaR6ILFF2dSUMl3UK+/QOlab0IFTx30qKb+KICUEajdo6AOkPIneDW nS9g== X-Forwarded-Encrypted: i=1; AJvYcCWji2mEfMMLWpUeC3evO83+aoc5PZUv1bImGNDtQ7KQmMQjt2l/HccFfz8IgQE0dOHXo43jIxtl3rG26ozVikBO6B1QLF5vatGfZyUy X-Gm-Message-State: AOJu0YxPzbsPzTVgea9t4irniuLa+meqWCjss3yeOSB/eERDtDbIPjPP cstIpL4JU0dO0TAMF3Nn21aRGzNsIH9FgbSR6GPQM/PU0e4i4/T1Qsdqt0TOosHaKEvV+0r3WeQ = X-Received: by 2002:a17:902:784e:b0:1d8:cbca:8fdd with SMTP id e14-20020a170902784e00b001d8cbca8fddmr4808375pln.67.1708104903225; Fri, 16 Feb 2024 09:35:03 -0800 (PST) Received: from [127.0.1.1] ([120.138.12.48]) by smtp.gmail.com with ESMTPSA id v9-20020a170902b7c900b001db5241100fsm118592plz.183.2024.02.16.09.34.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 09:35:02 -0800 (PST) From: Manivannan Sadhasivam Date: Fri, 16 Feb 2024 23:04:40 +0530 Subject: [PATCH v2 1/5] PCI: dwc: Refactor dw_pcie_edma_find_chip() API 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="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240216-dw-hdma-v2-1-b42329003f43@linaro.org> References: <20240216-dw-hdma-v2-0-b42329003f43@linaro.org> In-Reply-To: <20240216-dw-hdma-v2-0-b42329003f43@linaro.org> To: Jingoo Han , Gustavo Pimentel , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Marek Vasut , Yoshihiro Shimoda , Kishon Vijay Abraham I Cc: Serge Semin , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org, mhi@lists.linux.dev, Manivannan Sadhasivam X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=2569; i=manivannan.sadhasivam@linaro.org; h=from:subject:message-id; bh=m8AOqRiSHCcO5mZcayvtN8wItwmC4U+br9OIM450sVs=; b=owEBbQGS/pANAwAKAVWfEeb+kc71AcsmYgBlz5y9jEZ2MRbDlRIXAc5qpjEUTe25c9uY3Tc10 XimLXNNSDmJATMEAAEKAB0WIQRnpUMqgUjL2KRYJ5dVnxHm/pHO9QUCZc+cvQAKCRBVnxHm/pHO 9WCIB/4h1XrbJ1DWyjTcM1TdQqqfBBN+Z+xZG3crirTEU5kZDMjdNtqocFqZeRGAFIt5i/hlpZu kplHDhsJEkzg+SX5kiNzDxQi31ohbsHNuSAE6w9rq5cFHUnskEGVaZQe2m4swo/DoQth1mmkBTf va7X+7V/pMxdJngff46zw/cTgD7ijo07T1OWTh7GHHZfZVmLYDfrBmkIIaaxI44hWkiAlfs9AFr NdeJA1V/r3iVv1n/NiXmyEq8B+v5Kiv5m5HwXkyKP0qEA7BLGRtuydpaNt3guQ/LHGBNY12g3V2 T4U32kGOxzkpF2ZjXdBGm0K5kjhldjuVtsVNMhYsJoJdEWoL X-Developer-Key: i=manivannan.sadhasivam@linaro.org; a=openpgp; fpr=C668AEC3C3188E4C611465E7488550E901166008 In order to add support for Hyper DMA (HDMA), let's refactor the existing dw_pcie_edma_find_chip() API by moving the common code to separate functions. No functional change. Suggested-by: Serge Semin Signed-off-by: Manivannan Sadhasivam --- drivers/pci/controller/dwc/pcie-designware.c | 40 +++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c index 250cf7f40b85..3a26dfc5368f 100644 --- a/drivers/pci/controller/dwc/pcie-designware.c +++ b/drivers/pci/controller/dwc/pcie-designware.c @@ -880,7 +880,17 @@ static struct dw_edma_plat_ops dw_pcie_edma_ops = { .irq_vector = dw_pcie_edma_irq_vector, }; -static int dw_pcie_edma_find_chip(struct dw_pcie *pci) +static void dw_pcie_edma_init_data(struct dw_pcie *pci) +{ + pci->edma.dev = pci->dev; + + if (!pci->edma.ops) + pci->edma.ops = &dw_pcie_edma_ops; + + pci->edma.flags |= DW_EDMA_CHIP_LOCAL; +} + +static int dw_pcie_edma_find_mf(struct dw_pcie *pci) { u32 val; @@ -902,8 +912,6 @@ static int dw_pcie_edma_find_chip(struct dw_pcie *pci) 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) { pci->edma.mf = EDMA_MF_EDMA_LEGACY; @@ -912,12 +920,17 @@ static int dw_pcie_edma_find_chip(struct dw_pcie *pci) return -ENODEV; } - pci->edma.dev = pci->dev; + return 0; +} - if (!pci->edma.ops) - pci->edma.ops = &dw_pcie_edma_ops; +static int dw_pcie_edma_find_channels(struct dw_pcie *pci) +{ + u32 val; - pci->edma.flags |= DW_EDMA_CHIP_LOCAL; + if (pci->edma.mf == EDMA_MF_EDMA_LEGACY) + val = dw_pcie_readl_dbi(pci, PCIE_DMA_VIEWPORT_BASE + PCIE_DMA_CTRL); + else + val = dw_pcie_readl_dma(pci, PCIE_DMA_CTRL); pci->edma.ll_wr_cnt = FIELD_GET(PCIE_DMA_NUM_WR_CHAN, val); pci->edma.ll_rd_cnt = FIELD_GET(PCIE_DMA_NUM_RD_CHAN, val); @@ -930,6 +943,19 @@ static int dw_pcie_edma_find_chip(struct dw_pcie *pci) return 0; } +static int dw_pcie_edma_find_chip(struct dw_pcie *pci) +{ + int ret; + + dw_pcie_edma_init_data(pci); + + ret = dw_pcie_edma_find_mf(pci); + if (ret) + return ret; + + return dw_pcie_edma_find_channels(pci); +} + static int dw_pcie_edma_irq_verify(struct dw_pcie *pci) { struct platform_device *pdev = to_platform_device(pci->dev); -- 2.25.1