diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-08-27 10:36:23 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-08-30 13:56:59 -0400 |
commit | 85580ea4f72ce08e4d9140a3bb22806185a0bba9 (patch) | |
tree | 47bda43b1f4c3f60afa17114df8f4f8081e2f2a2 /drivers/edac | |
parent | 28c2ce7c8b275a8e6950bacb2dbad70b36a2996b (diff) |
i7300_edac: pre-allocate a buffer used to prepare err messages
Instead of dynamically allocating a buffer for it where needed,
just allocate it once. As we'll use the same buffer also during
fatal and non-fatal errors, is is very risky to dynamically allocate
it during an error.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/edac')
-rw-r--r-- | drivers/edac/i7300_edac.c | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/drivers/edac/i7300_edac.c b/drivers/edac/i7300_edac.c index a4f47fda078d..4c239ce6986b 100644 --- a/drivers/edac/i7300_edac.c +++ b/drivers/edac/i7300_edac.c | |||
@@ -306,6 +306,9 @@ struct i7300_pvt { | |||
306 | 306 | ||
307 | /* DIMM information matrix, allocating architecture maximums */ | 307 | /* DIMM information matrix, allocating architecture maximums */ |
308 | struct i7300_dimm_info dimm_info[MAX_SLOTS][MAX_CHANNELS]; | 308 | struct i7300_dimm_info dimm_info[MAX_SLOTS][MAX_CHANNELS]; |
309 | |||
310 | /* Temporary buffer for use when preparing error messages */ | ||
311 | char *tmp_prt_buffer; | ||
309 | }; | 312 | }; |
310 | 313 | ||
311 | /* FIXME: Why do we need to have this static? */ | 314 | /* FIXME: Why do we need to have this static? */ |
@@ -611,17 +614,12 @@ static int decode_mtr(struct i7300_pvt *pvt, | |||
611 | static void print_dimm_size(struct i7300_pvt *pvt) | 614 | static void print_dimm_size(struct i7300_pvt *pvt) |
612 | { | 615 | { |
613 | struct i7300_dimm_info *dinfo; | 616 | struct i7300_dimm_info *dinfo; |
614 | char *p, *mem_buffer; | 617 | char *p; |
615 | int space, n; | 618 | int space, n; |
616 | int channel, slot; | 619 | int channel, slot; |
617 | 620 | ||
618 | space = PAGE_SIZE; | 621 | space = PAGE_SIZE; |
619 | mem_buffer = p = kmalloc(space, GFP_KERNEL); | 622 | p = pvt->tmp_prt_buffer; |
620 | if (p == NULL) { | ||
621 | i7300_printk(KERN_ERR, "MC: %s:%s() kmalloc() failed\n", | ||
622 | __FILE__, __func__); | ||
623 | return; | ||
624 | } | ||
625 | 623 | ||
626 | n = snprintf(p, space, " "); | 624 | n = snprintf(p, space, " "); |
627 | p += n; | 625 | p += n; |
@@ -631,15 +629,15 @@ static void print_dimm_size(struct i7300_pvt *pvt) | |||
631 | p += n; | 629 | p += n; |
632 | space -= n; | 630 | space -= n; |
633 | } | 631 | } |
634 | debugf2("%s\n", mem_buffer); | 632 | debugf2("%s\n", pvt->tmp_prt_buffer); |
635 | p = mem_buffer; | 633 | p = pvt->tmp_prt_buffer; |
636 | space = PAGE_SIZE; | 634 | space = PAGE_SIZE; |
637 | n = snprintf(p, space, "-------------------------------" | 635 | n = snprintf(p, space, "-------------------------------" |
638 | "------------------------------"); | 636 | "------------------------------"); |
639 | p += n; | 637 | p += n; |
640 | space -= n; | 638 | space -= n; |
641 | debugf2("%s\n", mem_buffer); | 639 | debugf2("%s\n", pvt->tmp_prt_buffer); |
642 | p = mem_buffer; | 640 | p = pvt->tmp_prt_buffer; |
643 | space = PAGE_SIZE; | 641 | space = PAGE_SIZE; |
644 | 642 | ||
645 | for (slot = 0; slot < MAX_SLOTS; slot++) { | 643 | for (slot = 0; slot < MAX_SLOTS; slot++) { |
@@ -654,8 +652,8 @@ static void print_dimm_size(struct i7300_pvt *pvt) | |||
654 | space -= n; | 652 | space -= n; |
655 | } | 653 | } |
656 | 654 | ||
657 | debugf2("%s\n", mem_buffer); | 655 | debugf2("%s\n", pvt->tmp_prt_buffer); |
658 | p = mem_buffer; | 656 | p = pvt->tmp_prt_buffer; |
659 | space = PAGE_SIZE; | 657 | space = PAGE_SIZE; |
660 | } | 658 | } |
661 | 659 | ||
@@ -663,11 +661,9 @@ static void print_dimm_size(struct i7300_pvt *pvt) | |||
663 | "------------------------------"); | 661 | "------------------------------"); |
664 | p += n; | 662 | p += n; |
665 | space -= n; | 663 | space -= n; |
666 | debugf2("%s\n", mem_buffer); | 664 | debugf2("%s\n", pvt->tmp_prt_buffer); |
667 | p = mem_buffer; | 665 | p = pvt->tmp_prt_buffer; |
668 | space = PAGE_SIZE; | 666 | space = PAGE_SIZE; |
669 | |||
670 | kfree(mem_buffer); | ||
671 | } | 667 | } |
672 | 668 | ||
673 | /* | 669 | /* |
@@ -978,6 +974,12 @@ static int i7300_probe1(struct pci_dev *pdev, int dev_idx) | |||
978 | pvt = mci->pvt_info; | 974 | pvt = mci->pvt_info; |
979 | pvt->pci_dev_16_0_fsb_ctlr = pdev; /* Record this device in our private */ | 975 | pvt->pci_dev_16_0_fsb_ctlr = pdev; /* Record this device in our private */ |
980 | 976 | ||
977 | pvt->tmp_prt_buffer = kmalloc(PAGE_SIZE, GFP_KERNEL); | ||
978 | if (!pvt->tmp_prt_buffer) { | ||
979 | edac_mc_free(mci); | ||
980 | return -ENOMEM; | ||
981 | } | ||
982 | |||
981 | /* 'get' the pci devices we want to reserve for our use */ | 983 | /* 'get' the pci devices we want to reserve for our use */ |
982 | if (i7300_get_devices(mci, dev_idx)) | 984 | if (i7300_get_devices(mci, dev_idx)) |
983 | goto fail0; | 985 | goto fail0; |
@@ -1038,6 +1040,7 @@ fail1: | |||
1038 | i7300_put_devices(mci); | 1040 | i7300_put_devices(mci); |
1039 | 1041 | ||
1040 | fail0: | 1042 | fail0: |
1043 | kfree(pvt->tmp_prt_buffer); | ||
1041 | edac_mc_free(mci); | 1044 | edac_mc_free(mci); |
1042 | return -ENODEV; | 1045 | return -ENODEV; |
1043 | } | 1046 | } |
@@ -1072,6 +1075,7 @@ static int __devinit i7300_init_one(struct pci_dev *pdev, | |||
1072 | static void __devexit i7300_remove_one(struct pci_dev *pdev) | 1075 | static void __devexit i7300_remove_one(struct pci_dev *pdev) |
1073 | { | 1076 | { |
1074 | struct mem_ctl_info *mci; | 1077 | struct mem_ctl_info *mci; |
1078 | char *tmp; | ||
1075 | 1079 | ||
1076 | debugf0(__FILE__ ": %s()\n", __func__); | 1080 | debugf0(__FILE__ ": %s()\n", __func__); |
1077 | 1081 | ||
@@ -1082,9 +1086,12 @@ static void __devexit i7300_remove_one(struct pci_dev *pdev) | |||
1082 | if (!mci) | 1086 | if (!mci) |
1083 | return; | 1087 | return; |
1084 | 1088 | ||
1089 | tmp = ((struct i7300_pvt *)mci->pvt_info)->tmp_prt_buffer; | ||
1090 | |||
1085 | /* retrieve references to resources, and free those resources */ | 1091 | /* retrieve references to resources, and free those resources */ |
1086 | i7300_put_devices(mci); | 1092 | i7300_put_devices(mci); |
1087 | 1093 | ||
1094 | kfree(tmp); | ||
1088 | edac_mc_free(mci); | 1095 | edac_mc_free(mci); |
1089 | } | 1096 | } |
1090 | 1097 | ||