Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp2708851rwj; Mon, 19 Dec 2022 07:58:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXtMjeIpHCtxsbuxwm74JOG0VM5w2sFyqymbI6+fgN0XnOleF1XVrpT8MkU544VjmHLaGRFR X-Received: by 2002:a17:902:e84c:b0:191:d98:7d7e with SMTP id t12-20020a170902e84c00b001910d987d7emr14677004plg.22.1671465497464; Mon, 19 Dec 2022 07:58:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671465497; cv=none; d=google.com; s=arc-20160816; b=pG9pFGz5DkoBVEnyEASUloY8X+v3TO6THtJfPifxmiTqYhvX6WqRYADm9gIStCavkl qDzOt6WyFwgCKQj/znuBzlA9imYLDw/0FyXyGtN2cTzQro1sxQi5P48ebAE3+C7zRR01 FMiZa+40qCSgZf7YbBjZjERwyNrv9NHHUMq7ea28rrHy1OzwjQ8u4lndN6wKJ4vzWsA2 act4Qjm8fSwtJqjvP0NK0HlJqGVGFvk2jNbq7fyT26yEu/00kmRU+MMe/XPACanY4kLC WOBkogsXiAHs3HrcplyJGFVLn9eyF23730yVDhp9VNjsc7+jEHeV3kmYNfxgmApA7bAR 5Vsg== 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=vuyhOpYNrdoe/gaMvhO2CJK7UJ9/diTNg13E3xchg9A=; b=vrZmiIPSkLEZ+p3cu1MggU189v4HYRo5uEpqZ6YKPg3gTgjqtmb+xq2EuHeLc1vsbI TV+9qY+LsHr7JpcnCixozNjX4e/w9liZpC8U5Rn82HEVv1u64tXBGhtWT7RUX1ofsWtI /ZJypzGYwv/UMT3Thew+zxFBHlopI5g7oqwJoCl0geQH48SyAf75lMaQQAhjkCJUu3KS p46i4SQKae2D+hoEgSflqH4tJWfKF7qifguqorMX8/sBGKE0QcRavcKz9AfqXjfAjNEh 5c0m0AtRJ/fsMTxPLhVczRkN3iY4GQ/J5d0qWXa6qduJFdAPTb96wPuzs/b52unhgGgf HYPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baikalelectronics.ru header.s=post header.b=dkS05lJc; 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 l6-20020a17090270c600b00189d6969658si10225704plt.342.2022.12.19.07.58.08; Mon, 19 Dec 2022 07:58:17 -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=dkS05lJc; 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 S232248AbiLSOuC (ORCPT + 71 others); Mon, 19 Dec 2022 09:50:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232073AbiLSOr3 (ORCPT ); Mon, 19 Dec 2022 09:47:29 -0500 Received: from post.baikalelectronics.com (post.baikalelectronics.com [213.79.110.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AEB47F6E; Mon, 19 Dec 2022 06:47:19 -0800 (PST) Received: from post.baikalelectronics.com (localhost.localdomain [127.0.0.1]) by post.baikalelectronics.com (Proxmox) with ESMTP id 50B13E0EB3; Mon, 19 Dec 2022 17:47:19 +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=vuyhOpYNrdoe/gaMvhO2CJK7UJ9/diTNg13E3xchg9A=; b=dkS05lJcDSQp 4Im7It3h3pN1Zm417Q/7BxIc6z3s9yJQ3CNkfBotp7bVT4Y9hNIEGyXi9QIj/AFz 5cicqdnCFSNW9hjhMT3VFpf1Yzct1VRe/AM0mzWBKCeSI9yk1YbWStrlraUwfz68 Cvv6fwsKYFxtfaX2SlDirVb7wsu9bXE= Received: from mail.baikal.int (mail.baikal.int [192.168.51.25]) by post.baikalelectronics.com (Proxmox) with ESMTP id 41207E0E70; Mon, 19 Dec 2022 17:47:19 +0300 (MSK) Received: from localhost (10.8.30.14) by mail (192.168.51.25) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 19 Dec 2022 17:47:18 +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 v8 24/26] PCI: dwc: Set coherent DMA-mask on MSI-address allocation Date: Mon, 19 Dec 2022 17:46:55 +0300 Message-ID: <20221219144658.26620-25-Sergey.Semin@baikalelectronics.ru> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219144658.26620-1-Sergey.Semin@baikalelectronics.ru> References: <20221219144658.26620-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.8.30.14] 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 The MSI target address requires to be reserved within the lowest 4GB memory in order to support the PCIe peripherals with no 64-bit MSI TLPs support. Since the allocation is done from the DMA-coherent memory let's modify the allocation procedure to setting the coherent DMA-mask only and avoiding the streaming DMA-mask modification. Thus at least the streaming DMA operations would work with no artificial limitations. It will be specifically useful for the eDMA-capable controllers so the corresponding DMA-engine clients would map the DMA buffers with no need in the SWIOTLB intervention for the buffers allocated above the 4GB memory region. While at it let's add a brief comment about the reason of having the MSI target address allocated from the DMA-coherent memory limited with the 4GB upper bound. Signed-off-by: Serge Semin --- Changelog v8: - This is a new patch added on v8 stage of the series. (@Robin, @Christoph) --- drivers/pci/controller/dwc/pcie-designware-host.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c index 3ab6ae3712c4..e10608af39b4 100644 --- a/drivers/pci/controller/dwc/pcie-designware-host.c +++ b/drivers/pci/controller/dwc/pcie-designware-host.c @@ -366,7 +366,16 @@ static int dw_pcie_msi_host_init(struct dw_pcie_rp *pp) dw_chained_msi_isr, pp); } - ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32)); + /* + * Even though the iMSI-RX Module supports 64-bit addresses some + * peripheral PCIe devices may lack the 64-bit messages support. In + * order not to miss MSI TLPs from those devices the MSI target address + * has to be reserved within the lowest 4GB. + * Note until there is a better alternative found the reservation is + * done by allocating from the artificially limited DMA-coherent + * memory. + */ + ret = dma_set_coherent_mask(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"); -- 2.38.1