Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp226102rwb; Wed, 14 Dec 2022 16:30:10 -0800 (PST) X-Google-Smtp-Source: AA0mqf5YSOCMBY2HatRhseb9WdXRGKMA4EinqS4HNTxwQ1eILnKSEGcTlhOfPO3FK4iDC1DPjC8z X-Received: by 2002:a17:906:5053:b0:7c1:727f:7c70 with SMTP id e19-20020a170906505300b007c1727f7c70mr12674861ejk.46.1671064210082; Wed, 14 Dec 2022 16:30:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671064210; cv=none; d=google.com; s=arc-20160816; b=Bczs/3e0mDTs2XJtaY7X6fMNp4ROkdb4FE1cKgI7GhdVMeuF+z8qi+4wXDEyinFiwF w7bPjjPNBnozYShLhHmMb5i/P0uefJuZ65PHc/GKuvo2n8Xb6wmm28VIOLWuP+eGtNcn PLDtljZpRhhFDJACWbaPgOJ3lU9XyoUCFO9VcMJdGjceyl8DSQ3cS4jbbC1oCh0mxgFj 8aHpqrYWXwY+PiuSOkiDQ399QLP5U06BRkn9OWLyVB2alb63i2HO1mdhnV+80Slr2hTu IRPCRIMd7sCW7/f9NwUN9ilKQDHdU1MJkAJJWaw+8guPXXD+oi8NMpHF2HSHJekjY9y3 6dqA== 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=2P5zIEafAOu1EyjDFBiB1YmEXwVrq8QtBXlII/SZHN8=; b=SaqSIccc9eJpkfo4kXd674jsmQ3sgzgKjXmhQ45d9g/R0sBzg+S+YRzoQDTjU72AwK SdqQyO07yxItmKQcaqk6iJ607SACGjSfjq7IZlQwdXdCUmiinH1goheMHxEV6itL7BEs Tvh2AjhE6qtozIlndRZQIzJY8GKF9QnT+nveHQGnOyrm3TwvwqSYlYkO513vUK4X8y0b zv7rQHv8v1Q9WzfbcjriXd6lFQmi6WSNuMjb+wtdJZzUEHqWvoM38iKrFiiW473zT0k/ /ZK4SBPKIhRW28BYYjGikSvgrWUzz9K7ptHMr4PlJwldE9EHEBOpi10w1IopgeVa/VvP 6MTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baikalelectronics.ru header.s=post header.b=VQ9fVGAW; 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 qb11-20020a1709077e8b00b007c12aad4c05si12218797ejc.123.2022.12.14.16.29.51; Wed, 14 Dec 2022 16:30:10 -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=VQ9fVGAW; 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 S230149AbiLNXzV (ORCPT + 69 others); Wed, 14 Dec 2022 18:55:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229825AbiLNXx0 (ORCPT ); Wed, 14 Dec 2022 18:53:26 -0500 Received: from post.baikalelectronics.com (post.baikalelectronics.com [213.79.110.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9B5A7511F5; Wed, 14 Dec 2022 15:53:25 -0800 (PST) Received: from post.baikalelectronics.com (localhost.localdomain [127.0.0.1]) by post.baikalelectronics.com (Proxmox) with ESMTP id D056AE0ED5; Thu, 15 Dec 2022 02:53:24 +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=2P5zIEafAOu1EyjDFBiB1YmEXwVrq8QtBXlII/SZHN8=; b=VQ9fVGAWH9yI YIuNheh0n3mzDqpB1ud49IMFvAB1FxwL6IdXG13G5jZg/FGzxksWTsPbE7JaT+Ag TcEd0QWgIdEGomRl/91HhuI3KtTmKNAOd951fColo2l7JEublz5w9kV4381p0GaT A6I5F7cWbHDaGVJ8zUDw7O2okYFEB2Y= Received: from mail.baikal.int (mail.baikal.int [192.168.51.25]) by post.baikalelectronics.com (Proxmox) with ESMTP id C3FF5E0E6B; Thu, 15 Dec 2022 02:53:24 +0300 (MSK) Received: from localhost (10.8.30.6) by mail (192.168.51.25) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 15 Dec 2022 02:53: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 , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , caihuoqing , Yoshihiro Shimoda , , , Subject: [PATCH v7 23/25] PCI: dwc: Restore DMA-mask after MSI-data allocation Date: Thu, 15 Dec 2022 02:53:03 +0300 Message-ID: <20221214235305.31744-24-Sergey.Semin@baikalelectronics.ru> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221214235305.31744-1-Sergey.Semin@baikalelectronics.ru> References: <20221214235305.31744-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.8.30.6] 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 DW PCIe Root Ports and End-points can be equipped with the DW eDMA engine. In that case it is critical to have the platform device pre-initialized with a valid DMA-mask so the drivers using the eDMA-engine would be able to allocate the DMA-able buffers. The MSI-capable data requires to be allocated from the lowest 4GB region. Since that procedure implies the DMA-mask change we need to restore the mask set by the low-level drivers after the MSI-data allocation is done. Signed-off-by: Serge Semin --- Changelog v7: - This is a new patch added on v7 stage of the series. (@Robin) --- drivers/pci/controller/dwc/pcie-designware-host.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c index 5762bd306261..1a3dae1f6aa2 100644 --- a/drivers/pci/controller/dwc/pcie-designware-host.c +++ b/drivers/pci/controller/dwc/pcie-designware-host.c @@ -326,7 +326,7 @@ static int dw_pcie_msi_host_init(struct dw_pcie_rp *pp) struct dw_pcie *pci = to_dw_pcie_from_pp(pp); struct device *dev = pci->dev; struct platform_device *pdev = to_platform_device(dev); - u64 *msi_vaddr; + u64 *msi_vaddr, dma_mask; int ret; u32 ctrl, num_ctrls; @@ -366,6 +366,13 @@ static int dw_pcie_msi_host_init(struct dw_pcie_rp *pp) dw_chained_msi_isr, pp); } + /* + * Save and then restore the DMA-mask pre-set by the low-level drivers + * after allocating the MSI-capable region. The mask might be useful for + * the controllers with the embedded eDMA engine. + */ + dma_mask = dma_get_mask(dev); + ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32)); if (ret) dev_warn(dev, "Failed to set DMA mask to 32-bit. Devices with only 32-bit MSI support may not work properly\n"); @@ -378,6 +385,10 @@ static int dw_pcie_msi_host_init(struct dw_pcie_rp *pp) return -ENOMEM; } + ret = dma_set_mask_and_coherent(dev, dma_mask); + if (ret) + dev_warn(dev, "Failed to re-store DMA-mask\n"); + return 0; } -- 2.38.1