From owner-svn-src-stable@FreeBSD.ORG Mon Mar 22 23:15:20 2010 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 32F0D106566B; Mon, 22 Mar 2010 23:15:20 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 074BA8FC15; Mon, 22 Mar 2010 23:15:20 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o2MNFJxU069476; Mon, 22 Mar 2010 23:15:19 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o2MNFJVk069473; Mon, 22 Mar 2010 23:15:19 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201003222315.o2MNFJVk069473@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 22 Mar 2010 23:15:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r205489 - stable/7/sys/dev/pci X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Mar 2010 23:15:20 -0000 Author: yongari Date: Mon Mar 22 23:15:19 2010 New Revision: 205489 URL: http://svn.freebsd.org/changeset/base/205489 Log: MFC r203528: Add pci_get|set_max_read_req() helper functions to control maximum PCIe read request size. Modified: stable/7/sys/dev/pci/pci.c stable/7/sys/dev/pci/pcivar.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/pci/pci.c ============================================================================== --- stable/7/sys/dev/pci/pci.c Mon Mar 22 23:04:12 2010 (r205488) +++ stable/7/sys/dev/pci/pci.c Mon Mar 22 23:15:19 2010 (r205489) @@ -1564,6 +1564,40 @@ pci_ht_map_msi(device_t dev, uint64_t ad } } +int +pci_get_max_read_req(device_t dev) +{ + int cap; + uint16_t val; + + if (pci_find_extcap(dev, PCIY_EXPRESS, &cap) != 0) + return (0); + val = pci_read_config(dev, cap + PCIR_EXPRESS_DEVICE_CTL, 2); + val &= PCIM_EXP_CTL_MAX_READ_REQUEST; + val >>= 12; + return (1 << (val + 7)); +} + +int +pci_set_max_read_req(device_t dev, int size) +{ + int cap; + uint16_t val; + + if (pci_find_extcap(dev, PCIY_EXPRESS, &cap) != 0) + return (0); + if (size < 128) + size = 128; + if (size > 4096) + size = 4096; + size = (1 << (fls(size) - 1)); + val = pci_read_config(dev, cap + PCIR_EXPRESS_DEVICE_CTL, 2); + val &= ~PCIM_EXP_CTL_MAX_READ_REQUEST; + val |= (fls(size) - 8) << 12; + pci_write_config(dev, cap + PCIR_EXPRESS_DEVICE_CTL, val, 2); + return (size); +} + /* * Support for MSI message signalled interrupts. */ Modified: stable/7/sys/dev/pci/pcivar.h ============================================================================== --- stable/7/sys/dev/pci/pcivar.h Mon Mar 22 23:04:12 2010 (r205488) +++ stable/7/sys/dev/pci/pcivar.h Mon Mar 22 23:15:19 2010 (r205489) @@ -465,6 +465,9 @@ int pci_msi_device_blacklisted(device_t void pci_ht_map_msi(device_t dev, uint64_t addr); +int pci_get_max_read_req(device_t dev); +int pci_set_max_read_req(device_t dev, int size); + #endif /* _SYS_BUS_H_ */ /*