Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 19 Feb 2010 18:07:51 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r204098 - stable/8/sys/dev/pci
Message-ID:  <201002191807.o1JI7pg6059635@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Fri Feb 19 18:07:51 2010
New Revision: 204098
URL: http://svn.freebsd.org/changeset/base/204098

Log:
  MFC r203528:
  Add pci_get|set_max_read_req() helper functions to control maximum PCIe
  read request size.

Modified:
  stable/8/sys/dev/pci/pci.c
  stable/8/sys/dev/pci/pcivar.h
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/netinet/   (props changed)

Modified: stable/8/sys/dev/pci/pci.c
==============================================================================
--- stable/8/sys/dev/pci/pci.c	Fri Feb 19 18:01:32 2010	(r204097)
+++ stable/8/sys/dev/pci/pci.c	Fri Feb 19 18:07:51 2010	(r204098)
@@ -1592,6 +1592,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/8/sys/dev/pci/pcivar.h
==============================================================================
--- stable/8/sys/dev/pci/pcivar.h	Fri Feb 19 18:01:32 2010	(r204097)
+++ stable/8/sys/dev/pci/pcivar.h	Fri Feb 19 18:07:51 2010	(r204098)
@@ -458,6 +458,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_ */
 
 /*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201002191807.o1JI7pg6059635>