Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2699702imu; Thu, 17 Jan 2019 20:25:07 -0800 (PST) X-Google-Smtp-Source: ALg8bN46J/67JDjiy19INa+TjKDzbIg4QS2pQByxg90E317TQSao+PTM0mi++SsqJo9ajVGQIIsn X-Received: by 2002:a63:a064:: with SMTP id u36mr16206831pgn.145.1547785507847; Thu, 17 Jan 2019 20:25:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547785507; cv=none; d=google.com; s=arc-20160816; b=bdH2vpNAT5yiNTd487OMVUQBDJHNMGN6TZ71bsGpXeg0W9uqWQG8xzp3jttNrLpme4 qWSHriCjmrJeJgE/sEMymqV02mDYbcC7W1Uj1uPMIq8/ypmO7prxhlh8AG3LvPpJt/EY T0sJXTqLi0lCatymkZFYXMpwePIUYqldJnLX9hTAHvo+yQ/2mRQM3SGFvJ2z3m2aEp+O l11P3OByr0tYDVII1YMLu3Q8nSOu90yfCa0vW3oTv3JjnQ72H3f3/biWr4UCwB8PXtAW 4ufNdViZAO9Iy10uxuyb/FFFQedZZ8Zd849nXiqnhGVmPquxQDYQvzuYnkue+x/tN9YE 08dA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=/jqvh7/0NjQjdCpoGQspuYu2IFibDkbh5kbwMcrLjXI=; b=Fesjem5QqhyZrF0hSQwCPJAOKWA4C+FhAwRzPhADCfbcZCz3gqyH2pBU33+nqI3vHQ ik2AdaiJnZHEcBp+O/abxWyq8DCFuYeOlFnb3j1J95u15Vd6vPkKw3zzTqR99FG5ygip nE3cqB6oVqtx7IWoyGCyxYiovSgZNgFNAuYq9TeLMvyttKQU/kz1YQYTWLN2QvmU1eU4 GOP+xoA3t8HkK3QSEzX6nAIqXeg4bc6CmwxFcuaucTraYXHw4LP5clpeFdT5aDg1mRiT giIhqihFgllxmA1wGp96PUG2vtznP/jA8uND6YFVPcPFY8/N6llhNnHPNuc0YBv5I5xv /p9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=VKM2b2nk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u22si3532984pgh.286.2019.01.17.20.24.52; Thu, 17 Jan 2019 20:25:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=VKM2b2nk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727125AbfAREXl (ORCPT + 99 others); Thu, 17 Jan 2019 23:23:41 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:40108 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727085AbfAREXj (ORCPT ); Thu, 17 Jan 2019 23:23:39 -0500 Received: by mail-pl1-f193.google.com with SMTP id u18so5753659plq.7 for ; Thu, 17 Jan 2019 20:23:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/jqvh7/0NjQjdCpoGQspuYu2IFibDkbh5kbwMcrLjXI=; b=VKM2b2nkX1xH83pwAMIxpfruj9iUZPkiiTK2G0hLM7JJlN9Gg/GA0pBqw5fNACHPQd +pyGZDshFmBVgucinblFcph9hAD7B0sziUo9XuQ/UzhRyMhVmB6Qt9Cv08leM+EtvZO6 x5tWvZCOYlw9CA700kdt49aaZ+gtIwWVCzfc0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/jqvh7/0NjQjdCpoGQspuYu2IFibDkbh5kbwMcrLjXI=; b=Yt5DAdQcWmxeRL9jIunITzckW/rMXJQEiVgo220gw/jhWynHjOOwEtycifCV14AMJw ZjeKj6y65uP30f6REX2jtLmuWvFz21PjaVfC1EvL3Yh0gEgN+9WtCCZEonyHgdKA8Nul Py7GIAxGAyvEoVnh5Li+G8E5wVu0X/Kq7ucu5VXnBG/Nw9uavosko/vMPhdSGGR58d7y o9qE86BFIPcEeAvgGnqN0ecmacPxq14aarp0Hp6JboZo0IFTKj0LpF386GSeS31GaTez C+ka4V2Drc2ATKbizh4HTKHa851V4ng5dM+XI5IadYymJ+FkxTkvm+MPvZMLZoeKrymj Ts1w== X-Gm-Message-State: AJcUukdGCeSda8f5JU2YDfbzF1tJj+k5jOTv+Y8aeZKhPW7+mcEMQTpF m14tDFHS66OiYH/If5Kg4a83Sg== X-Received: by 2002:a17:902:5601:: with SMTP id h1mr18131292pli.160.1547785418410; Thu, 17 Jan 2019 20:23:38 -0800 (PST) Received: from mannams-OptiPlex-7010.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id l19sm7339642pfi.71.2019.01.17.20.23.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 Jan 2019 20:23:37 -0800 (PST) From: Srinath Mannam To: Bjorn Helgaas , Lorenzo Pieralisi , Ray Jui , Scott Branden Cc: bcm-kernel-feedback-list@broadcom.com, linux-pci@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Srinath Mannam Subject: [PATCH 1/3] PCI: iproc: Add feature to set order mode Date: Fri, 18 Jan 2019 09:53:21 +0530 Message-Id: <1547785403-32268-2-git-send-email-srinath.mannam@broadcom.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1547785403-32268-1-git-send-email-srinath.mannam@broadcom.com> References: <1547785403-32268-1-git-send-email-srinath.mannam@broadcom.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Order mode in RX header of incoming pcie packets can be override to strict or loose order based on requirement. Sysfs entry is provided to set dynamic and default order modes of upstream traffic. To improve performance in few endpoints we required to modify the ordering attributes. Using this feature we can override order modes of RX packets at IPROC RC. Ex: In PCIe based NVMe SSD endpoints data read/writes from disk is using Queue pairs (submit/completion). After completion of block read/write, EP writes completion command to completion queue to notify RC. So that all data transfers before completion command write are not required to strict order except completion command. It means previous all packets before completion command write to RC should be written to memory and acknowledged. Signed-off-by: Srinath Mannam Reviewed-by: Ray Jui --- drivers/pci/controller/pcie-iproc.c | 128 ++++++++++++++++++++++++++++++++++++ drivers/pci/controller/pcie-iproc.h | 16 +++++ 2 files changed, 144 insertions(+) diff --git a/drivers/pci/controller/pcie-iproc.c b/drivers/pci/controller/pcie-iproc.c index c20fd6b..13ce80f 100644 --- a/drivers/pci/controller/pcie-iproc.c +++ b/drivers/pci/controller/pcie-iproc.c @@ -57,6 +57,9 @@ #define PCIE_DL_ACTIVE_SHIFT 2 #define PCIE_DL_ACTIVE BIT(PCIE_DL_ACTIVE_SHIFT) +#define MPS_MRRS_CFG_MPS_SHIFT 0 +#define MPS_MRRS_CFG_MRRS_SHIFT 16 + #define APB_ERR_EN_SHIFT 0 #define APB_ERR_EN BIT(APB_ERR_EN_SHIFT) @@ -91,6 +94,14 @@ #define IPROC_PCIE_REG_INVALID 0xffff +#define RO_FIELD(window) BIT((window) << 1) +#define RO_VALUE(window) BIT(((window) << 1) + 1) +/* All Windows are allowed */ +#define RO_ALL_WINDOW 0x33333333 +/* Wait on All Windows */ +#define RO_FIELD_ALL_WINDOW 0x11111111 +#define DYNAMIC_ORDER_MODE 0x5 + /** * iProc PCIe outbound mapping controller specific parameters * @@ -295,6 +306,15 @@ enum iproc_pcie_reg { /* enable APB error for unsupported requests */ IPROC_PCIE_APB_ERR_EN, + /* Ordering Mode configuration registers */ + IPROC_PCIE_ORDERING_CFG, + IPROC_PCIE_MPS_MRRS_CFG, + IPROC_PCIE_IMAP0_RO_CONTROL, + IPROC_PCIE_IMAP1_RO_CONTROL, + IPROC_PCIE_IMAP2_RO_CONTROL, + IPROC_PCIE_IMAP3_RO_CONTROL, + IPROC_PCIE_IMAP4_RO_CONTROL, + /* total number of core registers */ IPROC_PCIE_MAX_NUM_REG, }; @@ -352,6 +372,13 @@ static const u16 iproc_pcie_reg_paxb_v2[] = { [IPROC_PCIE_IMAP4] = 0xe70, [IPROC_PCIE_LINK_STATUS] = 0xf0c, [IPROC_PCIE_APB_ERR_EN] = 0xf40, + [IPROC_PCIE_ORDERING_CFG] = 0x2000, + [IPROC_PCIE_MPS_MRRS_CFG] = 0x2008, + [IPROC_PCIE_IMAP0_RO_CONTROL] = 0x201c, + [IPROC_PCIE_IMAP1_RO_CONTROL] = 0x2020, + [IPROC_PCIE_IMAP2_RO_CONTROL] = 0x2024, + [IPROC_PCIE_IMAP3_RO_CONTROL] = 0x2028, + [IPROC_PCIE_IMAP4_RO_CONTROL] = 0x202c, }; /* iProc PCIe PAXC v1 registers */ @@ -1401,6 +1428,97 @@ static int iproc_pcie_rev_init(struct iproc_pcie *pcie) return 0; } +static +ssize_t order_mode_show(struct device *dev, + struct device_attribute *attr, + char *buff) +{ + struct pci_host_bridge *host = to_pci_host_bridge(dev); + struct iproc_pcie *pcie = pci_host_bridge_priv(host); + + return sprintf(buff, "Current PAXB order configuration %d\n", + pcie->order_cfg); +} + +static void pcie_iproc_set_dynamic_order(struct iproc_pcie *pcie) +{ + u32 val = 0, mps; + + /* Set all IMAPs to relaxed order in dynamic order mode */ + iproc_pcie_write_reg(pcie, IPROC_PCIE_ORDERING_CFG, + DYNAMIC_ORDER_MODE); + iproc_pcie_write_reg(pcie, IPROC_PCIE_IMAP0_RO_CONTROL, + RO_ALL_WINDOW); + iproc_pcie_write_reg(pcie, IPROC_PCIE_IMAP1_RO_CONTROL, + RO_ALL_WINDOW); + iproc_pcie_write_reg(pcie, IPROC_PCIE_IMAP2_RO_CONTROL, + RO_ALL_WINDOW); + iproc_pcie_write_reg(pcie, IPROC_PCIE_IMAP3_RO_CONTROL, + RO_ALL_WINDOW); + iproc_pcie_write_reg(pcie, IPROC_PCIE_IMAP4_RO_CONTROL, + RO_ALL_WINDOW); + + /* PAXB MPS/MRRS settings configuration */ + iproc_pci_raw_config_read32(pcie, 0, IPROC_PCI_EXP_CAP + PCI_EXP_DEVCTL, + 2, &mps); + mps = (mps & PCI_EXP_DEVCTL_PAYLOAD) >> 5; + /* set MRRS to match system MPS */ + val |= (mps << MPS_MRRS_CFG_MRRS_SHIFT); + /* set MPS to 4096 bytes */ + val |= (0x5 << MPS_MRRS_CFG_MPS_SHIFT); + iproc_pcie_write_reg(pcie, IPROC_PCIE_MPS_MRRS_CFG, val); +} + +static +ssize_t order_mode_store(struct device *dev, + struct device_attribute *attr, + const char *buf, + size_t count) +{ + struct pci_host_bridge *host = to_pci_host_bridge(dev); + struct iproc_pcie *pcie = pci_host_bridge_priv(host); + unsigned long val, regval; + + if (kstrtoul(buf, 0, &val) < 0) + return -EINVAL; + + if (val > PAXB_ORDER_DEV_MEM_ONLY) { + dev_err(dev, "Invalid Value passed %lu\n", val); + dev_err(dev, "0: Everything in strict order\n"); + dev_err(dev, "1: Only IMAP2 in strict order\n"); + dev_err(dev, "2: Only device memory in strict order (MSI/MSIX)\n"); + return -EINVAL; + } + + if (val == pcie->order_cfg) + return count; + + switch (val) { + case PAXB_ORDER_IMAP2_ONLY: + pcie_iproc_set_dynamic_order(pcie); + regval = RO_ALL_WINDOW; + regval &= ~(RO_VALUE(0)); + /* Set IMAP2 to strict order */ + iproc_pcie_write_reg(pcie, IPROC_PCIE_IMAP2_RO_CONTROL, regval); + dev_info(dev, "RO_IMAP2 set to %#lx\n", regval); + break; + case PAXB_ORDER_DEV_MEM_ONLY: + pcie_iproc_set_dynamic_order(pcie); + /* Set IMAP0 to strict order */ + iproc_pcie_write_reg(pcie, IPROC_PCIE_IMAP0_RO_CONTROL, + RO_FIELD_ALL_WINDOW); + dev_info(dev, "RO_IMAP0 set to %#x\n", RO_FIELD_ALL_WINDOW); + break; + default: + iproc_pcie_write_reg(pcie, IPROC_PCIE_ORDERING_CFG, 0); + break; + } + pcie->order_cfg = val; + return count; +} + +static DEVICE_ATTR_RW(order_mode); + int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res) { struct device *dev; @@ -1484,6 +1602,11 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res) pci_bus_add_devices(host->bus); + if (pcie->type == IPROC_PCIE_PAXB_V2) { + ret = device_create_file(&host->dev, &dev_attr_order_mode); + if (ret < 0) + goto err_power_off_phy; + } return 0; err_power_off_phy: @@ -1496,6 +1619,11 @@ EXPORT_SYMBOL(iproc_pcie_setup); int iproc_pcie_remove(struct iproc_pcie *pcie) { + struct pci_host_bridge *host = pci_host_bridge_from_priv(pcie); + + if (pcie->type == IPROC_PCIE_PAXB_V2) + device_remove_file(&host->dev, &dev_attr_order_mode); + pci_stop_root_bus(pcie->root_bus); pci_remove_root_bus(pcie->root_bus); diff --git a/drivers/pci/controller/pcie-iproc.h b/drivers/pci/controller/pcie-iproc.h index 4f03ea5..6e100cd 100644 --- a/drivers/pci/controller/pcie-iproc.h +++ b/drivers/pci/controller/pcie-iproc.h @@ -24,6 +24,18 @@ enum iproc_pcie_type { }; /** + * PAXB Dynamic ordering modes + * PAXB_ORDER_EVERYTHING: Everything in strict order + * PAXB_ORDER_IMAP2_ONLY: Only IMAP2 memory window strict order + * PAXB_ORDER_DEV_MEM_ONLY: Only device memory (MSI/MSIX) is strict order + */ +enum paxb_order_cfg { + PAXB_ORDER_EVERYTHING, + PAXB_ORDER_IMAP2_ONLY, + PAXB_ORDER_DEV_MEM_ONLY, +}; + +/** * iProc PCIe outbound mapping * @axi_offset: offset from the AXI address to the internal address used by * the iProc PCIe core @@ -74,6 +86,8 @@ struct iproc_msi; * @ib: inbound mapping related parameters * @ib_map: outbound mapping region related parameters * + * @order_cfg: indicates current value of the order mode. + * * @need_msi_steer: indicates additional configuration of the iProc PCIe * controller is required to steer MSI writes to external interrupt controller * @msi: MSI data @@ -102,6 +116,8 @@ struct iproc_pcie { struct iproc_pcie_ib ib; const struct iproc_pcie_ib_map *ib_map; + enum paxb_order_cfg order_cfg; + bool need_msi_steer; struct iproc_msi *msi; }; -- 2.7.4