Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4903084rwl; Mon, 10 Apr 2023 19:45:52 -0700 (PDT) X-Google-Smtp-Source: AKy350YKmHnEf7U4ZUzpjRJTlO7I1H3BRjdyEdOCHEve66hWALXFc6bjB/bGg+qhaejVlCPq2j+m X-Received: by 2002:a17:906:2e85:b0:94d:a2c2:9aeb with SMTP id o5-20020a1709062e8500b0094da2c29aebmr2169097eji.49.1681181152361; Mon, 10 Apr 2023 19:45:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681181152; cv=none; d=google.com; s=arc-20160816; b=EX3NaVALmfs2Lv0vMdQFp/idttpB72tdz0vqcQRIgEZlL0nPww+ChANdQCVZXrrtNJ YT+k5xhtvRRI+peLz9x4unMGkSj8/g5Vdr0kv1lrCN11TGy8hFQRU4ebVpJDKac8hSdS ShPUALYYretbG5tkKWCIkyMtZexWiNy7jonrKutk8VDWct9Ohs75Or97UigkDxVDKzwL qkwk95SdJ6zwFsZffz9RGlPc4DHhAln7VcZdLneKjZRDKaSKYoJTbMkHmQspEgsFaG44 zDJlRPvBp5FE7CQOJStmvpTV9MtrkAPIHkLxGOxXQKxk6DVyS7DB5Q2FFjCTKJ16GaVT Bq0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ryXtbfRI/jstwh7DoB7ytVR8A4UxPsGFr890Bq2wcsw=; b=T75u5RwP+VXUV0UQT3LJYYY7rB5jZCrq4y1y4m5CZ+FIDdnDg40CkzG4f23KBTx67Z MtFohxQYowD062javXjcQp7xKsFsvgzR3SSIemQlL00rT+OPf+VdLfedNXW7G0bZfflQ qMRi29L8LzYxeRgvEWeYbyne3QZ/do7RrNhEnkGeb16RMpCHqbZK8UzkabxeR0oIKv4h 3spPcRW4hTgawHUNuWGbepNmBuMVPMnNcSGPW7mAdmeWy33WIg9MONpc8eeeBRYEoj+P S2njgeRX1ujP2H9KLQSEnbmQtfCFpchQueerIS+/tL8TbYKXSBiHnqC4LyyezMzzdLSb OB9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Fs5DzYjP; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nc34-20020a1709071c2200b0094e154108b6si1051944ejc.376.2023.04.10.19.45.27; Mon, 10 Apr 2023 19:45:52 -0700 (PDT) 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=@gmail.com header.s=20210112 header.b=Fs5DzYjP; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229843AbjDKCgi (ORCPT + 99 others); Mon, 10 Apr 2023 22:36:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229690AbjDKCgg (ORCPT ); Mon, 10 Apr 2023 22:36:36 -0400 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D90626B2; Mon, 10 Apr 2023 19:36:35 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id h12so3662402lfj.8; Mon, 10 Apr 2023 19:36:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1681180594; x=1683772594; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ryXtbfRI/jstwh7DoB7ytVR8A4UxPsGFr890Bq2wcsw=; b=Fs5DzYjPDnocAKCDNiD3JWo3tpGPaB3GrE9UZJokrnPBHpaBE/07CH2AXiTOaJ/OQS 7NOQJvU1xuuZ9bzqbVyy6Pv9NdV76x+Fw/rAI/2zlSjeTtUJK4RWJWdibP+9kLbR0T04 iMxP4WoV7Ar4HjbHrVcIP+DalirmK4amqrHdEjT7dP8RF02PVLhcRDlBP1tegOgmNYuw KfahlM37LQTuFX8TXxaCVdC9C+hMqFlz5E+GCqOK9jUo0OoWEK4bnKVkVYsMr2OhmUp/ 0SWO8yaU9driTfWmAraoXak4vl2vLNIi8s0YjX4ToOecI7DMya+e8U0EL1wv6gSAQHiG 8OjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681180594; x=1683772594; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ryXtbfRI/jstwh7DoB7ytVR8A4UxPsGFr890Bq2wcsw=; b=3hViuPDZl2zo1eFKQ09fjC5nYMAwsK15eHyAduHrAwswv2VQf3CWAtw/OXCEfE6aU/ i35H0gy002veoW9s4B8CLA2lHhIbbPFbNRUD8ioYuHsHj1jzckatdXn1CAk0PaKiYfcA KZbcK9eMTTT+fwtKsU++R1zcHFl39aRY4CwpwFyBzlVlOln64b7CUdiz9edMFO6/lT27 TsN14DwbRQQUN7BSu340z538iPTLHC6coknoXfwAeeKdA6EF+FPhdSIZopGrPydASBBN 9oRfvFWW4Bpu0eXB5/tPVKm2uPRiNgxTzKltuRKt8BB+yve/hS6vHtfZeeOW+ikkEg0I rTuA== X-Gm-Message-State: AAQBX9fp3lNk8FVcpvz0VHtm3vPSUKscDEvxhF7BMIdPCxeKP8b0gM76 G8pjyd9aLwnz0Uj9k1li7f4= X-Received: by 2002:a19:f617:0:b0:4eb:982:adf with SMTP id x23-20020a19f617000000b004eb09820adfmr2942231lfe.26.1681180593693; Mon, 10 Apr 2023 19:36:33 -0700 (PDT) Received: from mobilestation ([95.79.140.35]) by smtp.gmail.com with ESMTPSA id b7-20020ac24107000000b004e9b307d2c8sm2331899lfi.238.2023.04.10.19.36.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Apr 2023 19:36:33 -0700 (PDT) Date: Tue, 11 Apr 2023 05:36:31 +0300 From: Serge Semin To: Lorenzo Pieralisi Cc: Hongxing Zhu , Bjorn Helgaas , "l.stach@pengutronix.de" , "bhelgaas@google.com" , "linux-pci@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "kernel@pengutronix.de" , dl-linux-imx , Serge Semin Subject: Re: [PATCH v2] PCI: imx6: Save and restore MSI control of RC in suspend and resume Message-ID: <20230411023631.3g7oom3mj6sp27k4@mobilestation> References: <20230317222436.GA1978818@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 On Wed, Apr 05, 2023 at 05:55:48PM +0200, Lorenzo Pieralisi wrote: > [+Cc Sergey] > Hi Lorenzo [nip] > > > > > > That's because a PCI root complex is not a PCI device (and this is not an MSI > > > capability, which lives in PCI config space). > > > > > > I will reword it (and the commit log with it) and merge it in the coming weeks for > > > v6.4 > > Hi Lorenzo: > > Thanks a lot for your kindly help. > > I am getting back to this since I am still not convinced and I want to > understand this once for all. > > We do use dw_pcie_find_capability() in most DWC drivers to find and > peek/poke at eg PCI express capability of the *Root port* (?), > > eg dw_pcie_wait_for_link() > > so I assume that for iMX6 dw_pcie_find_capability() does just the same, > which would mean that we are poking the "Message Control" field of the > Root port MSI capability. Absolutely right. Besides of the standard PCIe config space which is filled with the various PCIe capability registers, the DW PCIe Root Port has the "Port Logic" CSR space with the DW PCIe-specific settings: GENx Link control and lanes tuning stuff, iMSI-Rx engine, iATU/eDMA, etc. Some of the capabilities are utilized by their direct functionality (like the PCI Express capability) meanwhile some are left unused even though they can be activated during the IP-core synthesize stage. I don't know why the HW designers left them being optionally enabled and then available for some setups, DW PCIe RC HW-manual doesn't have their functionality description. The MSI capability is one of such PCIe capabilities. It's described in the DW PCIe RC registers space HW-manual and the DW PCIe RC IP-core parameters, but the rest of the manual text has nothing about it. Also note even though the DW PCIe RC HW-manual has _RC_ in the name it actually describes the PCIe Root Port with the attention remark: "The Synopsys PCI Express IP does not implement a full root complex." So from what I can see there can be several reasons of such configuration: 1. It simplifies the dual-mode device design for the HW-engineers. Though IMO Synopsys at least should have dropped the unused capabilities from the RP HW-manual. 2. Synopsys may imply that these capabilities can be used somehow for the vendor-specific true Root Complex designs. Though they don't specifically say about that. Instead there is a note: "To implement a full root complex, you must add your application logic (connected to the application client interface or AXI interface) and other support logic (including clock and reset generation)." > > Either that (which would mean that iMX6 has a HW bug because the RP > Message Control field does not control the delivery of MSIs from > endpoints but just for the root port itself ) I wouldn't call it a HW bug seeing the MSI capability registers are actually unused by the RP controllers. So it looks more like the iMX6-specific feature. See a short explanation in the commit 75cb8d20c112 ("PCI: imx: Enable MSI from downstream components"). Normally MSI event delivery to the CPU doesn't depend on the actual MSI capability CSRs state in DW PCIe RPs. Instead the MSI is configured via the Port Logic iMSI-RX registers. That's what is done in the DW PCIe host driver (see pcie-designware-host.c). > or all DWC controllers > modelled the root complex MMIO space as a set of PCI/PCIe capabilities > that are NOT necessarily mappable to PCI specifications defined ones. Basically you are right though as I noted above Synopsys doesn't provide a complete RC solution. It's just a single RP with the MMIO (DBI) CSRs looking as the PCIe TYPE1 config space. -Serge(y) > > Can anyone please shed some light on this ? I don't have DWC HW, we need > to know before merging this code. > > Thanks, > Lorenzo > > > > > Best Regards > > Richard Zhu > > > > > > Thanks, > > > Lorenzo > > > > > > > + * > > > > + * The MSI_EN bit of MSI control register contained in this MSI-CAP > > > > + * is used control the MSI delivery of MSI interrupts from components > > > > + * below the Root Port. > > > > + * > > > > + * Find it by PCI_CAP_ID_MSI here, and assert the MSI_EN bit to > > > allow > > > > + * the MSI delivery below the Root Port, if the PCI MSI is enabled. > > > > + */ > > > > if (pci_msi_enabled()) { > > > > offset = dw_pcie_find_capability(pci, PCI_CAP_ID_MSI); > > > > dw_pcie_dbi_ro_wr_en(pci); Best Regards Richard Zhu > > > > > > > > > > Bjorn >