Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp1255500rwb; Fri, 13 Jan 2023 09:45:56 -0800 (PST) X-Google-Smtp-Source: AMrXdXvQHnmX7289lfckIvtj0XQgC/tvu4Z+sNHkYzjRaaURLLuZOMCMMql1y8AVoRE6DNC8lscF X-Received: by 2002:a17:90a:4618:b0:229:2427:5326 with SMTP id w24-20020a17090a461800b0022924275326mr3789517pjg.31.1673631956736; Fri, 13 Jan 2023 09:45:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673631956; cv=none; d=google.com; s=arc-20160816; b=GINZSHsevd/T7tUmrcI+w62sXAr1z+e9V1z3iUquzoMzWJ0Q7DAy5kheBHL8vGVqWR X00sfkMJQ/iTOPcEo2tVUpexCPQaIbJGvgEyqiHWZQBpBw/Rdu4ryUFFFVLQ/bzinP5l /VCnfEbWgv4cuBuD26TFW9PsNfctrqOcgeReLCVRie3GBye0o5icS4cZFjf42r3esEgi jyiKRLh0qq0eGN1UoMKUqsQVDPIvfFHC/ZljeGE6YTo/H8HGaJgv8scGwODDwqYmnfMP aVzeCPuOLYFtLgyzeXGlSnBe2RSVX59TrD+YlvYAeVVTSJsX+EIrZkBMGbXH/aJjByb8 9xrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=EdENeH3TUyngHa7WBf9toVHVO+x1m2FiHcxZ2NrasqE=; b=rBqxeOM8dt8ma8K+RtSwBGAWRmpTnC1c5pkPggYlaYAR/skJ9/AJddAMbQ4esvJEPZ wLbmFNGfwt+2wPamZ3J467hPpp6wsBvDhs6blyT1RIlr2Z+hM5J4tzOoBkCUSSxWoxQl 51osDpJOwzYh25y9SeFWhH+ubz9ZdVGs6qwZWW3erb9OVD5QCRnjwSNpoZynhDGSNa1x yzhoxz39wStwLeHOj6wyCGVwdgYASvCRv7GAevlNSQNnSYy9sg7TnCD/FIZLNyOXmaX0 c2NGLc3ZFUFKpg9zqGJMs7/emj/VT01ylvk4N7iGI/Q2hQoS0Kon+gmweGBJQufhJVmr ewVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baikalelectronics.ru header.s=post header.b=lio6rfxC; 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=REJECT sp=REJECT dis=NONE) header.from=baikalelectronics.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mh11-20020a17090b4acb00b0022628568596si27671988pjb.36.2023.01.13.09.45.50; Fri, 13 Jan 2023 09:45:56 -0800 (PST) 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=@baikalelectronics.ru header.s=post header.b=lio6rfxC; 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=REJECT sp=REJECT dis=NONE) header.from=baikalelectronics.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229965AbjAMRYP (ORCPT + 51 others); Fri, 13 Jan 2023 12:24:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230201AbjAMRW6 (ORCPT ); Fri, 13 Jan 2023 12:22:58 -0500 Received: from post.baikalelectronics.com (post.baikalelectronics.com [213.79.110.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5B04CA183F; Fri, 13 Jan 2023 09:14:26 -0800 (PST) Received: from post.baikalelectronics.com (localhost.localdomain [127.0.0.1]) by post.baikalelectronics.com (Proxmox) with ESMTP id 11C40E0F23; Fri, 13 Jan 2023 20:14:25 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= baikalelectronics.ru; h=cc:cc:content-transfer-encoding :content-type:content-type:date:from:from:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=post; bh=EdENeH3TUyngHa7WBf9toVHVO+x1m2FiHcxZ2NrasqE=; b=lio6rfxCtAuH fTVKSOj1kdlEqVJYx9UA6C2ykaw6RfczwF8JPTAhnbmC95Kcm7bI7Jv9yBMQ6eDl tUUBvVgdJsm7ar8jo0AMEWRCbZzaDm+Qcdn/3jH9RtsjzqB4ID5BOzohqM/YFE6z 8KkFNJJvfeHdORmR22Yevb2L9OXmW+M= Received: from mail.baikal.int (mail.baikal.int [192.168.51.25]) by post.baikalelectronics.com (Proxmox) with ESMTP id DBBF8E0F13; Fri, 13 Jan 2023 20:14:24 +0300 (MSK) Received: from localhost (10.8.30.26) by mail (192.168.51.25) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 13 Jan 2023 20:14:24 +0300 From: Serge Semin To: Gustavo Pimentel , Vinod Koul , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Cai Huoqing , Robin Murphy , Jingoo Han , Frank Li , Manivannan Sadhasivam CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , caihuoqing , Yoshihiro Shimoda , , , , Gustavo Pimentel Subject: [PATCH v9 08/27] dmaengine: dw-edma: Add PCIe bus address getter to the remote EP glue-driver Date: Fri, 13 Jan 2023 20:13:50 +0300 Message-ID: <20230113171409.30470-9-Sergey.Semin@baikalelectronics.ru> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230113171409.30470-1-Sergey.Semin@baikalelectronics.ru> References: <20230113171409.30470-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.8.30.26] X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS 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 In general the Synopsys PCIe EndPoint IP prototype kit can be attached to a PCIe bus with any PCIe Host controller including to the one with distinctive from CPU address space. Due to that we need to make sure that the source and destination addresses of the DMA-slave devices are properly converted to the PCIe bus address space, otherwise the DMA transaction will not only work as expected, but may cause the memory corruption with subsequent system crash. Let's do that by introducing a new dw_edma_pcie_address() method defined in the dw-edma-pcie.c, which will perform the denoted translation by using the pcibios_resource_to_bus() method. Fixes: 41aaff2a2ac0 ("dmaengine: Add Synopsys eDMA IP PCIe glue-logic") Signed-off-by: Serge Semin Reviewed-by: Manivannan Sadhasivam Tested-by: Manivannan Sadhasivam Acked-by: Vinod Koul --- Note this patch depends on the patch "dmaengine: dw-edma: Add CPU to PCIe bus address translation" from this series. --- drivers/dma/dw-edma/dw-edma-pcie.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/dma/dw-edma/dw-edma-pcie.c b/drivers/dma/dw-edma/dw-edma-pcie.c index 04c95cba1244..f530bacfd716 100644 --- a/drivers/dma/dw-edma/dw-edma-pcie.c +++ b/drivers/dma/dw-edma/dw-edma-pcie.c @@ -95,8 +95,23 @@ static int dw_edma_pcie_irq_vector(struct device *dev, unsigned int nr) return pci_irq_vector(to_pci_dev(dev), nr); } +static u64 dw_edma_pcie_address(struct device *dev, phys_addr_t cpu_addr) +{ + struct pci_dev *pdev = to_pci_dev(dev); + struct pci_bus_region region; + struct resource res = { + .flags = IORESOURCE_MEM, + .start = cpu_addr, + .end = cpu_addr, + }; + + pcibios_resource_to_bus(pdev->bus, ®ion, &res); + return region.start; +} + static const struct dw_edma_core_ops dw_edma_pcie_core_ops = { .irq_vector = dw_edma_pcie_irq_vector, + .pci_address = dw_edma_pcie_address, }; static void dw_edma_pcie_get_vsec_dma_data(struct pci_dev *pdev, -- 2.39.0