LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Mark Salyzyn <Mark_Salyzyn@adaptec.com>
To: Chandru <chandru@in.ibm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Muli Ben-Yehuda <muli@il.ibm.com>
Subject: Re: [RFC] [Patch] calgary iommu: Use the first kernel's tce tables in kdump
Date: Sat, 21 Jun 2008 08:25:55 -0400	[thread overview]
Message-ID: <D1EF71A1-B2F3-4BBD-9FE7-E560CFD1F492@adaptec.com> (raw)
In-Reply-To: <200806211741.43703.chandru@in.ibm.com>

ACK (as a JAFO, though). I feel this patch was a long time coming!  
Thanks!

Sincerely -- Mark Salyzyn

On Jun 21, 2008, at 8:11 AM, Chandru wrote:

> kdump kernel fails to boot with calgary iommu and aacraid driver on  
> a x366
> box. The ongoing dma's of aacraid from the first kernel continue to  
> exist
> until the driver is loaded in the kdump kernel. Calgary is  
> initialized prior
> to aacraid and creation of new tce tables causes wrong dma's to  
> occur. Here
> we try to get the tce tables of the first kernel in kdump kernel and  
> use
> them. While in the kdump kernel we do not allocate new tce tables  
> but instead
> read the base address register contents of calgary iommu and use the  
> tables
> that the registers point to. With these changes the kdump kernel and  
> hence
> aacraid now boots normally.
>
> Signed-off-by: Chandru Siddalingappa <chandru@in.ibm.com>
> ---
>
> arch/x86/kernel/pci-calgary_64.c |   91 ++++++++++++++++++++++++++---
> include/linux/crash_dump.h       |    8 ++
> 2 files changed, 92 insertions(+), 7 deletions(-)
>
>>> Hello Andrew,
>>>
>>> Could you pls consider the attached patch for inclusion in mainline.
>>
>> I can sort-of work out what the patch does from the above quote,  
>> but it
>> would be nice to have a proper changelog description from yourself  
>> rather
>> than having me try to write it, please.
>> The patch was badly wordwrapped.  Please fix your email client for  
>> the next
>> version.
> Sorry for the much delayed response on this mail. The patch was  
> tested with
> linux-2.6.26-rc6.  Pls consider it for inclusion.
> Thanks,
>
>
>
> diff -Naurp linux-2.6.26-rc6-orig/arch/x86/kernel/pci-calgary_64.c
> linux-2.6.26-rc6/arch/x86/kernel/pci-calgary_64.c
> --- linux-2.6.26-rc6-orig/arch/x86/kernel/pci-calgary_64.c       
> 2008-06-21
> 13:59:08.000000000 +0530
> +++ linux-2.6.26-rc6/arch/x86/kernel/pci-calgary_64.c   2008-06-21
> 13:59:45.000000000 +0530
> @@ -36,6 +36,7 @@
> #include <linux/delay.h>
> #include <linux/scatterlist.h>
> #include <linux/iommu-helper.h>
> +#include <linux/crash_dump.h>
> #include <asm/gart.h>
> #include <asm/calgary.h>
> #include <asm/tce.h>
> @@ -167,6 +168,8 @@ static void calgary_dump_error_regs(stru
> static void calioc2_handle_quirks(struct iommu_table *tbl, struct  
> pci_dev
> *dev);
> static void calioc2_tce_cache_blast(struct iommu_table *tbl);
> static void calioc2_dump_error_regs(struct iommu_table *tbl);
> +static void calgary_init_bitmap_from_tce_table(struct iommu_table  
> *tbl);
> +static void get_tce_space_from_tar(void);
>
> static struct cal_chipset_ops calgary_chip_ops = {
>        .handle_quirks = calgary_handle_quirks,
> @@ -830,7 +833,11 @@ static int __init calgary_setup_tar(stru
>
>        tbl = pci_iommu(dev->bus);
>        tbl->it_base = (unsigned long)bus_info[dev->bus- 
> >number].tce_space;
> -       tce_free(tbl, 0, tbl->it_size);
> +
> +       if (is_kdump_kernel())
> +               calgary_init_bitmap_from_tce_table(tbl);
> +       else
> +               tce_free(tbl, 0, tbl->it_size);
>
>        if (is_calgary(dev->device))
>                tbl->chip_ops = &calgary_chip_ops;
> @@ -1206,9 +1213,14 @@ static int __init calgary_init(void)
>        struct calgary_bus_info *info;
>
>        ret = calgary_locate_bbars();
> +
>        if (ret)
>                return ret;
>
> +       /* Purely for kdump kernel case  */
> +       if (is_kdump_kernel())
> +               get_tce_space_from_tar();
> +
>        do {
>                dev = pci_get_device(PCI_VENDOR_ID_IBM, PCI_ANY_ID,  
> dev);
>                if (!dev)
> @@ -1256,6 +1268,24 @@ error:
>        return ret;
> }
>
> +
> +/*
> + * calgary_init_bitmap_from_tce_table():
> + * Funtion for kdump case. In the second/kdump kernel initialize
> + * the bitmap based on the tce table entries obtained from first  
> kernel
> + */
> +static void calgary_init_bitmap_from_tce_table(struct iommu_table  
> *tbl)
> +{
> +       u64 *tp;
> +       unsigned int index;
> +       tp = ((u64 *)tbl->it_base);
> +       for (index = 0 ; index < tbl->it_size; index++) {
> +       if (*tp != 0x0)
> +               set_bit(index, tbl->it_map);
> +               tp++;
> +       }
> +}
> +
> static inline int __init determine_tce_table_size(u64 ram)
> {
>        int ret;
> @@ -1318,6 +1348,8 @@ static int __init build_detail_arrays(vo
>        return 0;
> }
>
> +
> +
> static int __init calgary_bus_has_devices(int bus, unsigned short  
> pci_dev)
> {
>        int dev;
> @@ -1339,12 +1371,50 @@ static int __init calgary_bus_has_device
>        return (val != 0xffffffff);
> }
>
> +/*
> + * get_tce_space_from_tar():
> + * Function for kdump case. Get the tce tables from first kernel
> + * by reading the contents of the base adress register of calgary  
> iommu
> + */
> +static void get_tce_space_from_tar()
> +{
> +       int bus;
> +       void __iomem *target;
> +       unsigned long tce_space;
> +
> +       for (bus = 0; bus < MAX_PHB_BUS_NUM; bus++) {
> +               struct calgary_bus_info *info = &bus_info[bus];
> +               unsigned short pci_device;
> +               u32 val;
> +
> +               val = read_pci_config(bus, 0, 0, 0);
> +               pci_device = (val & 0xFFFF0000) >> 16;
> +
> +               if (!is_cal_pci_dev(pci_device))
> +                       continue;
> +               if (info->translation_disabled)
> +                       continue;
> +
> +               if (calgary_bus_has_devices(bus, pci_device) ||
> +                       translate_empty_slots) {
> +                       target = calgary_reg(bus_info[bus].bbar,
> +                               tar_offset(bus));
> +                       tce_space = be64_to_cpu(readq(target));
> +                       tce_space = tce_space & TAR_SW_BITS;
> +
> +                       tce_space = tce_space &  
> (~specified_table_size);
> +                       info->tce_space = (u64 *)__va(tce_space);
> +               }
> +       }
> +       return;
> +}
> +
> void __init detect_calgary(void)
> {
>        int bus;
>        void *tbl;
>        int calgary_found = 0;
> -       unsigned long ptr;
> +       unsigned long ptr, max_pfn;
>        unsigned int offset, prev_offset;
>        int ret;
>
> @@ -1394,7 +1464,8 @@ void __init detect_calgary(void)
>                return;
>        }
>
> -       specified_table_size = determine_tce_table_size(end_pfn *  
> PAGE_SIZE);
> +       max_pfn = is_kdump_kernel() ? saved_max_pfn : end_pfn ;
> +       specified_table_size = determine_tce_table_size(max_pfn *  
> PAGE_SIZE);
>
>        for (bus = 0; bus < MAX_PHB_BUS_NUM; bus++) {
>                struct calgary_bus_info *info = &bus_info[bus];
> @@ -1412,10 +1483,16 @@ void __init detect_calgary(void)
>
>                if (calgary_bus_has_devices(bus, pci_device) ||
>                    translate_empty_slots) {
> -                       tbl = alloc_tce_table();
> -                       if (!tbl)
> -                               goto cleanup;
> -                       info->tce_space = tbl;
> +                       /*
> +                        * If it is kdump kernel, find and use tce  
> tables
> +                        * from first kernel, else allocate tce  
> tables here
> +                        */
> +                       if (!is_kdump_kernel()) {
> +                               tbl = alloc_tce_table();
> +                               if (!tbl)
> +                                       goto cleanup;
> +                               info->tce_space = tbl;
> +                       }
>                        calgary_found = 1;
>                }
>        }
> diff -Naurp linux-2.6.26-rc6-orig/include/linux/crash_dump.h
> linux-2.6.26-rc6/include/linux/crash_dump.h
> --- linux-2.6.26-rc6-orig/include/linux/crash_dump.h    2008-06-21
> 13:59:18.000000000 +0530
> +++ linux-2.6.26-rc6/include/linux/crash_dump.h 2008-06-21  
> 14:00:42.000000000
> +0530
> @@ -22,5 +22,13 @@ extern struct proc_dir_entry *proc_vmcor
>
> #define vmcore_elf_check_arch(x) (elf_check_arch(x) ||
> vmcore_elf_check_arch_cross(x))
>
> +static inline int is_kdump_kernel(void)
> +{
> +       return (elfcorehdr_addr != ELFCORE_ADDR_MAX) ? 1 : 0 ;
> +}
> +#else /* !CONFIG_CRASH_DUMP */
> +static inline int is_kdump_kernel(void) { return 0; }
> #endif /* CONFIG_CRASH_DUMP */
> +
> +extern unsigned long saved_max_pfn;
> #endif /* LINUX_CRASHDUMP_H */
> --
> To unsubscribe from this list: send the line "unsubscribe linux- 
> kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/


  reply	other threads:[~2008-06-21 12:26 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-09 20:40 chandru
2007-10-09 21:06 ` Muli Ben-Yehuda
2007-10-10  5:30   ` Vivek Goyal
2007-10-14  5:41     ` Muli Ben-Yehuda
2007-10-15  6:29       ` Vivek Goyal
2007-12-24  5:15         ` Chandru
2008-03-10 13:20           ` Chandru
2008-03-10 16:09             ` Andrew Morton
2008-06-21 12:11               ` Chandru
2008-06-21 12:25                 ` Mark Salyzyn [this message]
2008-06-23 19:29                 ` Muli Ben-Yehuda
2008-07-15  8:45                   ` Chandru
2008-07-15 10:52                     ` Muli Ben-Yehuda
2008-07-17 23:14                     ` Andrew Morton
2008-07-20  9:42                       ` Muli Ben-Yehuda
2008-03-11 13:29             ` Vivek Goyal
2008-03-12  5:08               ` Chandru
2008-03-12  9:58                 ` Muli Ben-Yehuda
2008-03-12 18:08                   ` Vivek Goyal
2008-03-13 15:49                     ` Muli Ben-Yehuda
2007-10-10  5:37 ` Vivek Goyal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D1EF71A1-B2F3-4BBD-9FE7-E560CFD1F492@adaptec.com \
    --to=mark_salyzyn@adaptec.com \
    --cc=akpm@linux-foundation.org \
    --cc=chandru@in.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=muli@il.ibm.com \
    --subject='Re: [RFC] [Patch] calgary iommu: Use the first kernel'\''s tce tables in kdump' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).