Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp984135rdb; Fri, 19 Jan 2024 05:02:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IHBhu0iFSjGpWIcndgyU5m2Eeh3++J2nTQIUTN5rBiGRPZXuFU6BzIDt2xeOpk3NfX4B6rL X-Received: by 2002:a05:6214:21c7:b0:681:562d:e474 with SMTP id d7-20020a05621421c700b00681562de474mr1615620qvh.53.1705669324700; Fri, 19 Jan 2024 05:02:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705669324; cv=pass; d=google.com; s=arc-20160816; b=JHalIwiwYFHb3z2j11MVEUiec7k2cMlHUgUqOQN7a37qT5aiKdy3kL85nec+Vu9dLs 47XIurEuVYSVDBAzo/OD3tgPn5+nxwjkcfJRxWZgQ8o5uOyjlO+BCHJcr/i1jABMFuzQ 9dBZWtP+wWVNqIjrm1fqIRtkn9b6Y2bAXwEW9S78UYikajcXhP9VYKB+C52K/FgTf74k +258OvunAp35vAdACYsy9DL/+F4sGz9QzG0g0GNcrVoaPXLsPL+KQevAkZ/YC55iI1kB 2W/JdqImqc3vR3WWWxFrTsVRDXV2SSAM7/W/64IyIqayDN/Ug8mt9Pc2pLkblZ+nEzdj 3Fsw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=J5N0eH+XorUHi+CvGk/WwzsrjWyuz4FCQ2eZXs4R5nY=; fh=A9BXgcrlMZ5z9wYoTmuXIwTqeYf3DKZIOMrQtykU1fI=; b=Mv/nwyapdR3XWVlO3iIJXJSmQghxrmhAi/gmJqHS2GLC2uBKfQAdL9pq2giA092FUb 0nXs1a09wBb9SL+WH4A4LK44yM0cejFnBY0keG9dxVKtdagxK23ghoqPrLuVLvxXlpAJ 91gfyv8HCdrxaA63RUBPTrOI8XviFjUs6yv6c3Pfa50J4Frp8qQQbNuiV9CAORO2Zcox 1YC94vGxbSnD2cIbIr62011TbGV1wnLDfpM3Uuu4SeCKIOxACAYMQgkiLkO6+CsrGpaD vM1iHdanlt96vNgntEp9IoNxgwgosuKWUvalQ84uzvEQpEoriI8Wt1cZ+jw0XhYPUFa0 eniw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=chlwqT5n; arc=pass (i=1 spf=pass spfdomain=qualcomm.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-31160-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31160-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id e5-20020a0ce3c5000000b006827afab142si1547381qvl.372.2024.01.19.05.02.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jan 2024 05:02:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-31160-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=chlwqT5n; arc=pass (i=1 spf=pass spfdomain=qualcomm.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-31160-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31160-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 241BB1C226BD for ; Fri, 19 Jan 2024 13:02:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 832AD53E2B; Fri, 19 Jan 2024 13:01:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="chlwqT5n" Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 2046A52F86; Fri, 19 Jan 2024 13:00:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705669260; cv=none; b=iB2nmH0SSZ0pwZBPcZSJiStmvwEThanOLpJy6d4x9c1cSWuOnKDMD/3x4Fozs/DrSRqgncgfAJu6l67TB0jNq3l1GRBFuCZJYFQ31dTZ6t9ByaE6smpX9glnMbvAU72+ZKqJmyyNDZ8t20ukepONkPI+6sYh3LxElYgY6wg6nSo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705669260; c=relaxed/simple; bh=EerfizSXmr8ySSTQG3Ek8cTyqeYJTbG6H8QUFJ+dUbc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=dwpLCOz/f7dLawmjcu/GJHbnaMaMKdniV4eNpJ52H8rkV8eN34hswRKpMyeW6RvoNm5WRA7raFXMDGsEgU/2ft2sq1pF6v+L69tK5+BxC/Il9Fp+6/6rTAwnys2MIUcUBhtWPVB2Bs9J80C3OZYWhqnhun/L8Xjb/JgGdaj0WU0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=qualcomm.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=chlwqT5n; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=qualcomm.com Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40JCRWRX021492; Fri, 19 Jan 2024 13:00:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= qcppdkim1; bh=J5N0eH+XorUHi+CvGk/WwzsrjWyuz4FCQ2eZXs4R5nY=; b=ch lwqT5nOSWEWRJwPAFnbuTrHhaRl7l9q+E5zsdLBei1bYES4dpzq0is7VpLxwOiwc fVeaPlli/Ix157Tc0v/tvnr9baWTAN7N1uhzUt4HC07lc5Ru2YCRUdrAhzV62m+H 5gxKk7AHTMfGm9WudeqFPsadude9nT1xV4pEr9lFF4nVPL2tn2eYnDcDdxdtMQyo dvJFe0+cWlptKAhAxhE9nzoe1zOytYvB2FuzW4GrRUrwtOha9l9Qw6l4OOZTtziy WM5FKtijvB1vhn5Wjr+5V2SnE3mwq1T/6Kpfm7xNHnhKmqbaO8yr0kshUXrOM3CR LJJKmBw5tL+TYPD30C5A== Received: from apblrppmta01.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vqh2k90tv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 19 Jan 2024 13:00:43 +0000 (GMT) Received: from pps.filterd (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 40JD0eMr023790; Fri, 19 Jan 2024 13:00:40 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTPS id 3vkkkmtgrw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 19 Jan 2024 13:00:40 +0000 Received: from APBLRPPMTA01.qualcomm.com (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 40JD0dLE023785; Fri, 19 Jan 2024 13:00:39 GMT Received: from hu-sgudaval-hyd.qualcomm.com (hu-msarkar-hyd.qualcomm.com [10.213.111.194]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTP id 40JD0dlN023784; Fri, 19 Jan 2024 13:00:39 +0000 Received: by hu-sgudaval-hyd.qualcomm.com (Postfix, from userid 3891782) id 3BC35273A; Fri, 19 Jan 2024 18:30:38 +0530 (+0530) From: Mrinmay Sarkar To: vkoul@kernel.org, jingoohan1@gmail.com, conor+dt@kernel.org, konrad.dybcio@linaro.org, manivannan.sadhasivam@linaro.org, robh+dt@kernel.org Cc: quic_shazhuss@quicinc.com, quic_nitegupt@quicinc.com, quic_ramkri@quicinc.com, quic_nayiluri@quicinc.com, dmitry.baryshkov@linaro.org, quic_krichai@quicinc.com, quic_vbadigan@quicinc.com, quic_parass@quicinc.com, quic_schintav@quicinc.com, quic_shijjose@quicinc.com, Mrinmay Sarkar , Gustavo Pimentel , Serge Semin , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Kishon Vijay Abraham I , dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-arm-msm@vger.kernel.org, mhi@lists.linux.dev Subject: [PATCH v1 3/6] PCI: dwc: Add HDMA support Date: Fri, 19 Jan 2024 18:30:19 +0530 Message-Id: <1705669223-5655-4-git-send-email-quic_msarkar@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1705669223-5655-1-git-send-email-quic_msarkar@quicinc.com> References: <1705669223-5655-1-git-send-email-quic_msarkar@quicinc.com> X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: z69Q7pBn-mgOoTOjfxot1-qCLdMS5U1p X-Proofpoint-ORIG-GUID: z69Q7pBn-mgOoTOjfxot1-qCLdMS5U1p X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-19_07,2024-01-19_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 adultscore=0 clxscore=1015 impostorscore=0 phishscore=0 mlxlogscore=803 mlxscore=0 suspectscore=0 bulkscore=0 malwarescore=0 priorityscore=1501 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2401190066 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: From: Manivannan Sadhasivam Hyper DMA (HDMA) is already supported by the dw-edma dmaengine driver. Unlike it's predecessor Embedded DMA (eDMA), HDMA supports only the unrolled mapping format. So the platform drivers need to provide a valid base address of the CSRs. Also, there is no standard way to auto detect the number of available read/write channels in a platform. So the platform drivers has to provide that information as well. For adding HDMA support, the mapping format set by the platform drivers is used to detect whether eDMA or HDMA is being used, since we cannot auto detect it in a sane way. Signed-off-by: Manivannan Sadhasivam Signed-off-by: Mrinmay Sarkar --- drivers/pci/controller/dwc/pcie-designware.c | 55 ++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 8 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c index 96575b8..07a1f2d 100644 --- a/drivers/pci/controller/dwc/pcie-designware.c +++ b/drivers/pci/controller/dwc/pcie-designware.c @@ -880,7 +880,29 @@ 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 int dw_pcie_find_hdma(struct dw_pcie *pci) +{ + /* + * Since HDMA supports only unrolled mapping, platform drivers need to + * provide a valid base address. + */ + if (!pci->edma.reg_base) + return -ENODEV; + + /* + * Since there is no standard way to detect the number of read/write + * HDMA channels, platform drivers are expected to provide the channel + * count. Let's also do a sanity check of them to make sure that the + * counts are within the limit specified by the spec. + */ + if (!pci->edma.ll_wr_cnt || pci->edma.ll_wr_cnt > dw_edma_get_max_wr_ch(pci->edma.mf) || + !pci->edma.ll_rd_cnt || pci->edma.ll_rd_cnt > dw_edma_get_max_rd_ch(pci->edma.mf)) + return -EINVAL; + + return 0; +} + +static int dw_pcie_find_edma(struct dw_pcie *pci) { u32 val; @@ -912,13 +934,6 @@ static int dw_pcie_edma_find_chip(struct dw_pcie *pci) return -ENODEV; } - pci->edma.dev = pci->dev; - - if (!pci->edma.ops) - pci->edma.ops = &dw_pcie_edma_ops; - - pci->edma.flags |= DW_EDMA_CHIP_LOCAL; - 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 +945,30 @@ 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; + + if (pci->edma.mf == EDMA_MF_HDMA_NATIVE) { + ret = dw_pcie_find_hdma(pci); + if (ret) + return ret; + } else { + ret = dw_pcie_find_edma(pci); + if (ret) + return ret; + } + + pci->edma.dev = pci->dev; + + if (!pci->edma.ops) + pci->edma.ops = &dw_pcie_edma_ops; + + pci->edma.flags |= DW_EDMA_CHIP_LOCAL; + + return 0; +} + static int dw_pcie_edma_irq_verify(struct dw_pcie *pci) { struct platform_device *pdev = to_platform_device(pci->dev); -- 2.7.4