Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp1255445rwb; Fri, 13 Jan 2023 09:45:54 -0800 (PST) X-Google-Smtp-Source: AMrXdXvYjs+fWiV4la4TJ6SzlWWlCiwR9byoPxftcoCq/rtrMb97k5t5Ta7O7cf9sa5RdeaIKPar X-Received: by 2002:a05:6a20:b213:b0:a7:8b3e:1207 with SMTP id eh19-20020a056a20b21300b000a78b3e1207mr11437479pzb.13.1673631954684; Fri, 13 Jan 2023 09:45:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673631954; cv=none; d=google.com; s=arc-20160816; b=n4vKXCv+yTRRpVTg2pViukjptS/ilSoxVa7OAEV1Tpcz9YjNfQI3ZW/yAstI4qyuOE Joag+RzcEesC6P8XdLmJAgyhKnGqxrOjoEVz0mWqebgSu89eNJARqi34KLNPPBDQiK/V 6JMS7YBaEB+P0TkDD2PsZwcJ6KMBe7u5BH9gdA1ID0FIpVUXQDucQ32KpPvUlpPqw8/a CA9oPcyI5l9pAwgRVXxsX4bWJGURkLWeIGeN+ucNmi0VVM+04dEpTiHjVAy7vp4HQ7PZ Zllw4wCrFFiHmYitUjK0gM6/XO95bCxeNsB87let3Jrm/tKsBc0qE8/2b39GsLb5mrCv WjMg== 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=d7bJelLGSWZmM7IXBZfGb6iRBR8TCuRpsPrdqslUK5E=; b=VV1Ifhy2+t85WwQgoWW1nL/R+7vT5KlQCDpafyedHa7o5grZKuVQsjALRGUDEsBV6A i+k/IJevXBmMFYwx/hab9hpJEbJKvgrcGTw/eVhs2WAlaKor3+5cx6zANXCqT7OjzJuS zpEeWaoRYUodE4tbGRQ3SNUiZj6FFF9O352GajPomXOXfue7yW5BJEZJcMH4F6Wq1E9T iA2kbjYEKDfngEi5SxdbZ6oxDTmTFPVRPBhPLOzvJJp+69pZuMd/zVpI9cn304pKySKj 9LHTkoPM+rJcJLksxuKyytjATTn4mLhAb54eCOU5zoHC8Wx27NQ+KHak0kbrY2VJ9WYc zQAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baikalelectronics.ru header.s=post header.b=v1Y4Zv1X; 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 f21-20020a63f115000000b00489c72b232fsi25289447pgi.707.2023.01.13.09.45.46; Fri, 13 Jan 2023 09:45:54 -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=v1Y4Zv1X; 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 S231133AbjAMRZm (ORCPT + 52 others); Fri, 13 Jan 2023 12:25:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231233AbjAMRXy (ORCPT ); Fri, 13 Jan 2023 12:23:54 -0500 Received: from post.baikalelectronics.com (post.baikalelectronics.com [213.79.110.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C34F9A4C73; Fri, 13 Jan 2023 09:14:43 -0800 (PST) Received: from post.baikalelectronics.com (localhost.localdomain [127.0.0.1]) by post.baikalelectronics.com (Proxmox) with ESMTP id 9A41AE0F30; Fri, 13 Jan 2023 20:14:38 +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=d7bJelLGSWZmM7IXBZfGb6iRBR8TCuRpsPrdqslUK5E=; b=v1Y4Zv1XgLQQ wxMzn5D0uXPjyNwJkp/fbevesPq7ksq6PhryOdRwg2DxVfs5h4yZftrKAw5eO1UD yWdWY4pahoZ1ThcOJQHMwhxAvJ9QSqi/gkky9BxnCPtrqp1dEegq+RDO3qIpi7lm 3r3iHcqg08tEgzvxyCuvgOCBvi/ImnE= Received: from mail.baikal.int (mail.baikal.int [192.168.51.25]) by post.baikalelectronics.com (Proxmox) with ESMTP id 71B8CE0F13; Fri, 13 Jan 2023 20:14:38 +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:38 +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 v9 25/27] PCI: dwc: Set coherent DMA-mask on MSI-address allocation Date: Fri, 13 Jan 2023 20:14:07 +0300 Message-ID: <20230113171409.30470-26-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 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 Reviewed-by: Robin Murphy --- 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.39.0