aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel
diff options
context:
space:
mode:
authorMark Langsdorf <mark.langsdorf@amd.com>2009-04-09 09:18:49 -0400
committerIngo Molnar <mingo@elte.hu>2009-04-10 08:21:53 -0400
commitf8b201fc7110c3673437254e8ba02451461ece0b (patch)
tree9d8e6521403d67a15b8b4bd4ce1cf39a32b3f1bc /arch/x86/kernel
parentafd9fceec55225d33be878927056a548c2eef26c (diff)
x86: cacheinfo: replace sysfs interface for cache_disable feature
Impact: replace sysfs attribute Current interface violates against "one-value-per-sysfs-attribute rule". This patch replaces current attribute with two attributes -- one for each L3 Cache Index Disable register. Signed-off-by: Mark Langsdorf <mark.langsdorf@amd.com> Signed-off-by: Andreas Herrmann <andreas.herrmann3@amd.com> Cc: Andrew Morton <akpm@linux-foundation.org> LKML-Reference: <20090409131849.GJ31527@alberich.amd.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel')
-rw-r--r--arch/x86/kernel/cpu/intel_cacheinfo.c90
1 files changed, 45 insertions, 45 deletions
diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
index 0cde07153697..fc28291e40ba 100644
--- a/arch/x86/kernel/cpu/intel_cacheinfo.c
+++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
@@ -697,73 +697,69 @@ static ssize_t show_type(struct _cpuid4_info *this_leaf, char *buf)
697#define to_object(k) container_of(k, struct _index_kobject, kobj) 697#define to_object(k) container_of(k, struct _index_kobject, kobj)
698#define to_attr(a) container_of(a, struct _cache_attr, attr) 698#define to_attr(a) container_of(a, struct _cache_attr, attr)
699 699
700static ssize_t show_cache_disable(struct _cpuid4_info *this_leaf, char *buf) 700static ssize_t show_cache_disable(struct _cpuid4_info *this_leaf, char *buf,
701 unsigned int index)
701{ 702{
702 const struct cpumask *mask = to_cpumask(this_leaf->shared_cpu_map); 703 int cpu = cpumask_first(to_cpumask(this_leaf->shared_cpu_map));
703 int node = cpu_to_node(cpumask_first(mask)); 704 int node = cpu_to_node(cpu);
704 struct pci_dev *dev = NULL; 705 struct pci_dev *dev = node_to_k8_nb_misc(node);
705 ssize_t ret = 0; 706 unsigned int reg = 0;
706 int i;
707 707
708 if (!this_leaf->can_disable) 708 if (!this_leaf->can_disable)
709 return sprintf(buf, "Feature not enabled\n");
710
711 dev = node_to_k8_nb_misc(node);
712 if (!dev) {
713 printk(KERN_ERR "Attempting AMD northbridge operation on a system with no northbridge\n");
714 return -EINVAL; 709 return -EINVAL;
715 }
716 710
717 for (i = 0; i < 2; i++) { 711 if (!dev)
718 unsigned int reg; 712 return -EINVAL;
719 713
720 pci_read_config_dword(dev, 0x1BC + i * 4, &reg); 714 pci_read_config_dword(dev, 0x1BC + index * 4, &reg);
715 return sprintf(buf, "%x\n", reg);
716}
721 717
722 ret += sprintf(buf, "%sEntry: %d\n", buf, i); 718#define SHOW_CACHE_DISABLE(index) \
723 ret += sprintf(buf, "%sReads: %s\tNew Entries: %s\n", 719static ssize_t \
724 buf, 720show_cache_disable_##index(struct _cpuid4_info *this_leaf, char *buf) \
725 reg & 0x80000000 ? "Disabled" : "Allowed", 721{ \
726 reg & 0x40000000 ? "Disabled" : "Allowed"); 722 return show_cache_disable(this_leaf, buf, index); \
727 ret += sprintf(buf, "%sSubCache: %x\tIndex: %x\n",
728 buf, (reg & 0x30000) >> 16, reg & 0xfff);
729 }
730 return ret;
731} 723}
724SHOW_CACHE_DISABLE(0)
725SHOW_CACHE_DISABLE(1)
732 726
733static ssize_t 727static ssize_t store_cache_disable(struct _cpuid4_info *this_leaf,
734store_cache_disable(struct _cpuid4_info *this_leaf, const char *buf, 728 const char *buf, size_t count, unsigned int index)
735 size_t count)
736{ 729{
737 const struct cpumask *mask = to_cpumask(this_leaf->shared_cpu_map); 730 int cpu = cpumask_first(to_cpumask(this_leaf->shared_cpu_map));
738 int node = cpu_to_node(cpumask_first(mask)); 731 int node = cpu_to_node(cpu);
739 struct pci_dev *dev = NULL; 732 struct pci_dev *dev = node_to_k8_nb_misc(node);
740 unsigned int ret, index, val; 733 unsigned long val = 0;
741 734
742 if (!this_leaf->can_disable) 735 if (!this_leaf->can_disable)
743 return -EINVAL; 736 return -EINVAL;
744 737
745 if (strlen(buf) > 15) 738 if (!capable(CAP_SYS_ADMIN))
746 return -EINVAL; 739 return -EPERM;
747 740
748 ret = sscanf(buf, "%x %x", &index, &val); 741 if (!dev)
749 if (ret != 2)
750 return -EINVAL;
751 if (index > 1)
752 return -EINVAL; 742 return -EINVAL;
753 743
754 val |= 0xc0000000; 744 if (strict_strtoul(buf, 10, &val) < 0)
755 dev = node_to_k8_nb_misc(node);
756 if (!dev) {
757 printk(KERN_ERR "Attempting AMD northbridge operation on a system with no northbridge\n");
758 return -EINVAL; 745 return -EINVAL;
759 }
760 746
747 val |= 0xc0000000;
761 pci_write_config_dword(dev, 0x1BC + index * 4, val & ~0x40000000); 748 pci_write_config_dword(dev, 0x1BC + index * 4, val & ~0x40000000);
762 wbinvd(); 749 wbinvd();
763 pci_write_config_dword(dev, 0x1BC + index * 4, val); 750 pci_write_config_dword(dev, 0x1BC + index * 4, val);
751 return count;
752}
764 753
765 return 1; 754#define STORE_CACHE_DISABLE(index) \
755static ssize_t \
756store_cache_disable_##index(struct _cpuid4_info *this_leaf, \
757 const char *buf, size_t count) \
758{ \
759 return store_cache_disable(this_leaf, buf, count, index); \
766} 760}
761STORE_CACHE_DISABLE(0)
762STORE_CACHE_DISABLE(1)
767 763
768struct _cache_attr { 764struct _cache_attr {
769 struct attribute attr; 765 struct attribute attr;
@@ -785,7 +781,10 @@ define_one_ro(size);
785define_one_ro(shared_cpu_map); 781define_one_ro(shared_cpu_map);
786define_one_ro(shared_cpu_list); 782define_one_ro(shared_cpu_list);
787 783
788static struct _cache_attr cache_disable = __ATTR(cache_disable, 0644, show_cache_disable, store_cache_disable); 784static struct _cache_attr cache_disable_0 = __ATTR(cache_disable_0, 0644,
785 show_cache_disable_0, store_cache_disable_0);
786static struct _cache_attr cache_disable_1 = __ATTR(cache_disable_1, 0644,
787 show_cache_disable_1, store_cache_disable_1);
789 788
790static struct attribute * default_attrs[] = { 789static struct attribute * default_attrs[] = {
791 &type.attr, 790 &type.attr,
@@ -797,7 +796,8 @@ static struct attribute * default_attrs[] = {
797 &size.attr, 796 &size.attr,
798 &shared_cpu_map.attr, 797 &shared_cpu_map.attr,
799 &shared_cpu_list.attr, 798 &shared_cpu_list.attr,
800 &cache_disable.attr, 799 &cache_disable_0.attr,
800 &cache_disable_1.attr,
801 NULL 801 NULL
802}; 802};
803 803