diff mbox

libata:fix kernel panic when hotplug

Message ID 1465976574-18318-1-git-send-email-dingxiang@huawei.com
State Not Applicable
Delegated to: David Miller
Headers show

Commit Message

DingXiang June 15, 2016, 7:42 a.m. UTC
In normal condition,if we use sas protocol and hotplug a sata disk on a port,
the sas driver will send event "PORTE_BYTES_DMAED" and call function "sas_porte_bytes_dmaed".
But if a sata disk is run io and unplug it,then plug a new sata disk,this operation may cause
a kernel panic like this:
[ 2366.923208] Unable to handle kernel NULL pointer dereference at virtual address 000007b8
[ 2366.949253] pgd = ffffffc00121d000
[ 2366.971164] [000007b8] *pgd=00000027df893003, *pud=00000027df893003, *pmd=00000027df894003, *pte=006000006d000707
[ 2367.022822] Internal error: Oops: 96000005 [#1] SMP
[ 2367.048490] Modules linked in: dm_mirror(E) dm_region_hash(E) dm_log(E) dm_mod(E) crc32_arm64(E) aes_ce_blk(E) ablk_helper(E) cryptd(E) aes_ce_cipher(E) ghash_ce(E) sha2_ce(E) sha1_ce(E) ses(E) enclosure(E) shpchp(E) marvell(E)
[ 2367.144808] CPU: 16 PID: 710 Comm: kworker/16:1 Tainted: G            E   4.1.23-next.aarch64 #1
[ 2367.180161] Hardware name: Huawei Taishan 2280 /BC11SPCC, BIOS 1.28 05/14/2016
[ 2367.213305] Workqueue: events ata_scsi_hotplug
[ 2367.244296] task: ffffffe7db9b5e00 ti: ffffffe7db1a0000 task.ti: ffffffe7db1a0000
[ 2367.279949] PC is at sas_find_dev_by_rphy+0x48/0x118
[ 2367.312045] LR is at sas_find_dev_by_rphy+0x40/0x118
[ 2367.341970] pc : [<ffffffc00065c3b0>] lr : [<ffffffc00065c3a8>] pstate: 00000145
...
[ 2368.766334] Call trace:
[ 2368.781712] [<ffffffc00065c3b0>] sas_find_dev_by_rphy+0x48/0x118
[ 2368.800394] [<ffffffc00065c4a8>] sas_target_alloc+0x28/0x98
[ 2368.817975] [<ffffffc00063e920>] scsi_alloc_target+0x248/0x308
[ 2368.835570] [<ffffffc000640080>] __scsi_add_device+0xb8/0x160
[ 2368.853034] [<ffffffc0006e52d8>] ata_scsi_scan_host+0x190/0x230
[ 2368.871614] [<ffffffc0006e54b0>] ata_scsi_hotplug+0xc8/0xe8
[ 2368.889152] [<ffffffc0000da75c>] process_one_work+0x164/0x438
[ 2368.908003] [<ffffffc0000dab74>] worker_thread+0x144/0x4b0
[ 2368.924613] [<ffffffc0000e0ffc>] kthread+0xfc/0x110
[ 2368.940923] Code: aa1303e0 97ff5deb 34ffff80 d1082273 (f943de76)

This because "dev_to_shost" in "sas_find_dev_by_rphy" return a NULL point,and SHOST_TO_SAS_HA used it,so kernel panic happed.

why dev_to_shost return a NULL point?
  Because in "__scsi_add_device" ,struct device *parent = &shost->shost_gendev,and in "scsi_alloc_target", "*parent" is
assigned to "starget->dev.parent",then "sas_target_alloc" will get "struct sas_rphy" according "starget->dev.parent",
and  in "sas_find_dev_by_rphy" , we will get "struct Scsi_Host *shost" acording "rphy->dev.parent",we will find that 
rphy->dev.parent = shost->shost_gendev.parent, and shost_gendev.parent is "ap->tdev",there is no parent any more,so "dev_to_shost"
return a NULL point.

when the panic will happen?
  When libata is handling error,and add hotplug_task to workqueue,
if a new sata disk pluged at the same time,the libata hotplug task will run and panic will happen.

In fact,we don't need libata to deal with hotplug in sas enviroment.So we can't run ata hotplug task when ata port is sas host.

Signed-off-by:Dingxiang <dingxiang@huawei.com>
Signed-off-by:Chenqilin <chenqilin2@huawei.com>
---
 drivers/ata/libata-eh.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

Comments

kernel test robot June 15, 2016, 8:22 a.m. UTC | #1
Hi,

[auto build test ERROR on tj-libata/for-next]
[also build test ERROR on v4.7-rc3 next-20160615]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/DingXiang/libata-fix-kernel-panic-when-hotplug/20160615-154255
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tj/libata for-next
config: sparc64-allyesconfig (attached as .config)
compiler: sparc64-linux-gnu-gcc (Debian 5.3.1-8) 5.3.1 20160205
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=sparc64 

All error/warnings (new ones prefixed by >>):

   In file included from include/linux/linkage.h:6:0,
                    from include/linux/kernel.h:6,
                    from drivers/ata/libata-eh.c:35:
   drivers/ata/libata-eh.c: In function 'ata_scsi_port_error_handler':
>> include/linux/export.h:57:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     extern typeof(sym) sym;     \
     ^
   include/linux/export.h:94:25: note: in expansion of macro '___EXPORT_SYMBOL'
    #define __EXPORT_SYMBOL ___EXPORT_SYMBOL
                            ^
   include/linux/export.h:101:2: note: in expansion of macro '__EXPORT_SYMBOL'
     __EXPORT_SYMBOL(sym, "_gpl")
     ^
>> drivers/ata/libata-eh.c:836:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
    EXPORT_SYMBOL_GPL(ata_scsi_port_error_handler);
    ^
   include/linux/export.h:63:25: warning: '__used__' attribute ignored [-Wattributes]
     __visible const struct kernel_symbol __ksymtab_##sym \
                            ^
   include/linux/export.h:94:25: note: in expansion of macro '___EXPORT_SYMBOL'
    #define __EXPORT_SYMBOL ___EXPORT_SYMBOL
                            ^
   include/linux/export.h:101:2: note: in expansion of macro '__EXPORT_SYMBOL'
     __EXPORT_SYMBOL(sym, "_gpl")
     ^
>> drivers/ata/libata-eh.c:836:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
    EXPORT_SYMBOL_GPL(ata_scsi_port_error_handler);
    ^
   include/linux/export.h:63:39: error: section attribute cannot be specified for local variables
     __visible const struct kernel_symbol __ksymtab_##sym \
                                          ^
   include/linux/export.h:94:25: note: in expansion of macro '___EXPORT_SYMBOL'
    #define __EXPORT_SYMBOL ___EXPORT_SYMBOL
                            ^
   include/linux/export.h:101:2: note: in expansion of macro '__EXPORT_SYMBOL'
     __EXPORT_SYMBOL(sym, "_gpl")
     ^
>> drivers/ata/libata-eh.c:836:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
    EXPORT_SYMBOL_GPL(ata_scsi_port_error_handler);
    ^
   include/linux/export.h:63:25: warning: 'externally_visible' attribute have effect only on public objects [-Wattributes]
     __visible const struct kernel_symbol __ksymtab_##sym \
                            ^
   include/linux/export.h:94:25: note: in expansion of macro '___EXPORT_SYMBOL'
    #define __EXPORT_SYMBOL ___EXPORT_SYMBOL
                            ^
   include/linux/export.h:101:2: note: in expansion of macro '__EXPORT_SYMBOL'
     __EXPORT_SYMBOL(sym, "_gpl")
     ^
>> drivers/ata/libata-eh.c:836:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
    EXPORT_SYMBOL_GPL(ata_scsi_port_error_handler);
    ^
>> include/linux/export.h:63:39: error: declaration of '__ksymtab_ata_scsi_port_error_handler' with no linkage follows extern declaration
     __visible const struct kernel_symbol __ksymtab_##sym \
                                          ^
   include/linux/export.h:94:25: note: in expansion of macro '___EXPORT_SYMBOL'
    #define __EXPORT_SYMBOL ___EXPORT_SYMBOL
                            ^
   include/linux/export.h:101:2: note: in expansion of macro '__EXPORT_SYMBOL'
     __EXPORT_SYMBOL(sym, "_gpl")
     ^
>> drivers/ata/libata-eh.c:836:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
    EXPORT_SYMBOL_GPL(ata_scsi_port_error_handler);
    ^
   include/linux/export.h:62:36: note: previous declaration of '__ksymtab_ata_scsi_port_error_handler' was here
     extern const struct kernel_symbol __ksymtab_##sym; \
                                       ^
   include/linux/export.h:94:25: note: in expansion of macro '___EXPORT_SYMBOL'
    #define __EXPORT_SYMBOL ___EXPORT_SYMBOL
                            ^
   include/linux/export.h:101:2: note: in expansion of macro '__EXPORT_SYMBOL'
     __EXPORT_SYMBOL(sym, "_gpl")
     ^
>> drivers/ata/libata-eh.c:836:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
    EXPORT_SYMBOL_GPL(ata_scsi_port_error_handler);
    ^
>> drivers/ata/libata-eh.c:871:19: error: non-static declaration of 'ata_port_wait_eh' follows static declaration
    EXPORT_SYMBOL_GPL(ata_port_wait_eh);
                      ^
   include/linux/export.h:57:21: note: in definition of macro '___EXPORT_SYMBOL'
     extern typeof(sym) sym;     \
                        ^
   drivers/ata/libata-eh.c:871:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
    EXPORT_SYMBOL_GPL(ata_port_wait_eh);
    ^
   drivers/ata/libata-eh.c:847:6: note: previous definition of 'ata_port_wait_eh' was here
    void ata_port_wait_eh(struct ata_port *ap)
         ^
   In file included from include/linux/linkage.h:6:0,
                    from include/linux/kernel.h:6,
                    from drivers/ata/libata-eh.c:35:
   include/linux/export.h:63:25: warning: '__used__' attribute ignored [-Wattributes]
     __visible const struct kernel_symbol __ksymtab_##sym \
                            ^
   include/linux/export.h:94:25: note: in expansion of macro '___EXPORT_SYMBOL'
    #define __EXPORT_SYMBOL ___EXPORT_SYMBOL
                            ^
   include/linux/export.h:101:2: note: in expansion of macro '__EXPORT_SYMBOL'
     __EXPORT_SYMBOL(sym, "_gpl")
     ^
   drivers/ata/libata-eh.c:871:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
    EXPORT_SYMBOL_GPL(ata_port_wait_eh);
    ^
   include/linux/export.h:63:39: error: section attribute cannot be specified for local variables
     __visible const struct kernel_symbol __ksymtab_##sym \
                                          ^
   include/linux/export.h:94:25: note: in expansion of macro '___EXPORT_SYMBOL'
    #define __EXPORT_SYMBOL ___EXPORT_SYMBOL
                            ^
   include/linux/export.h:101:2: note: in expansion of macro '__EXPORT_SYMBOL'
     __EXPORT_SYMBOL(sym, "_gpl")
     ^
   drivers/ata/libata-eh.c:871:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
    EXPORT_SYMBOL_GPL(ata_port_wait_eh);
    ^
   include/linux/export.h:63:25: warning: 'externally_visible' attribute have effect only on public objects [-Wattributes]
     __visible const struct kernel_symbol __ksymtab_##sym \
                            ^
   include/linux/export.h:94:25: note: in expansion of macro '___EXPORT_SYMBOL'
    #define __EXPORT_SYMBOL ___EXPORT_SYMBOL
                            ^
   include/linux/export.h:101:2: note: in expansion of macro '__EXPORT_SYMBOL'
     __EXPORT_SYMBOL(sym, "_gpl")
     ^
   drivers/ata/libata-eh.c:871:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
    EXPORT_SYMBOL_GPL(ata_port_wait_eh);
    ^
>> include/linux/export.h:63:39: error: declaration of '__ksymtab_ata_port_wait_eh' with no linkage follows extern declaration
     __visible const struct kernel_symbol __ksymtab_##sym \
                                          ^
   include/linux/export.h:94:25: note: in expansion of macro '___EXPORT_SYMBOL'
    #define __EXPORT_SYMBOL ___EXPORT_SYMBOL
                            ^
   include/linux/export.h:101:2: note: in expansion of macro '__EXPORT_SYMBOL'
     __EXPORT_SYMBOL(sym, "_gpl")
     ^
   drivers/ata/libata-eh.c:871:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
    EXPORT_SYMBOL_GPL(ata_port_wait_eh);
    ^
   include/linux/export.h:62:36: note: previous declaration of '__ksymtab_ata_port_wait_eh' was here
     extern const struct kernel_symbol __ksymtab_##sym; \
                                       ^
   include/linux/export.h:94:25: note: in expansion of macro '___EXPORT_SYMBOL'
    #define __EXPORT_SYMBOL ___EXPORT_SYMBOL
                            ^
   include/linux/export.h:101:2: note: in expansion of macro '__EXPORT_SYMBOL'
     __EXPORT_SYMBOL(sym, "_gpl")
     ^
   drivers/ata/libata-eh.c:871:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
    EXPORT_SYMBOL_GPL(ata_port_wait_eh);
    ^
>> drivers/ata/libata-eh.c:873:12: error: invalid storage class for function 'ata_eh_nr_in_flight'
    static int ata_eh_nr_in_flight(struct ata_port *ap)
               ^
>> drivers/ata/libata-eh.c:937:13: error: invalid storage class for function 'ata_eh_set_pending'
    static void ata_eh_set_pending(struct ata_port *ap, int fastdrain)
                ^
   In file included from include/linux/linkage.h:6:0,
                    from include/linux/kernel.h:6,
                    from drivers/ata/libata-eh.c:35:
>> drivers/ata/libata-eh.c:1012:19: error: non-static declaration of 'ata_std_sched_eh' follows static declaration
    EXPORT_SYMBOL_GPL(ata_std_sched_eh);
                      ^
   include/linux/export.h:57:21: note: in definition of macro '___EXPORT_SYMBOL'
     extern typeof(sym) sym;     \
                        ^
   drivers/ata/libata-eh.c:1012:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
    EXPORT_SYMBOL_GPL(ata_std_sched_eh);
    ^
   drivers/ata/libata-eh.c:1000:6: note: previous definition of 'ata_std_sched_eh' was here
    void ata_std_sched_eh(struct ata_port *ap)
         ^
   In file included from include/linux/linkage.h:6:0,
                    from include/linux/kernel.h:6,
                    from drivers/ata/libata-eh.c:35:
   include/linux/export.h:63:25: warning: '__used__' attribute ignored [-Wattributes]
     __visible const struct kernel_symbol __ksymtab_##sym \
                            ^
   include/linux/export.h:94:25: note: in expansion of macro '___EXPORT_SYMBOL'
    #define __EXPORT_SYMBOL ___EXPORT_SYMBOL
                            ^
   include/linux/export.h:101:2: note: in expansion of macro '__EXPORT_SYMBOL'
     __EXPORT_SYMBOL(sym, "_gpl")
     ^
   drivers/ata/libata-eh.c:1012:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
    EXPORT_SYMBOL_GPL(ata_std_sched_eh);
    ^
   include/linux/export.h:63:39: error: section attribute cannot be specified for local variables
     __visible const struct kernel_symbol __ksymtab_##sym \
                                          ^
   include/linux/export.h:94:25: note: in expansion of macro '___EXPORT_SYMBOL'
    #define __EXPORT_SYMBOL ___EXPORT_SYMBOL
                            ^
   include/linux/export.h:101:2: note: in expansion of macro '__EXPORT_SYMBOL'
     __EXPORT_SYMBOL(sym, "_gpl")
     ^
   drivers/ata/libata-eh.c:1012:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
    EXPORT_SYMBOL_GPL(ata_std_sched_eh);
    ^
   include/linux/export.h:63:25: warning: 'externally_visible' attribute have effect only on public objects [-Wattributes]
     __visible const struct kernel_symbol __ksymtab_##sym \
                            ^
   include/linux/export.h:94:25: note: in expansion of macro '___EXPORT_SYMBOL'
    #define __EXPORT_SYMBOL ___EXPORT_SYMBOL
                            ^
   include/linux/export.h:101:2: note: in expansion of macro '__EXPORT_SYMBOL'
     __EXPORT_SYMBOL(sym, "_gpl")
     ^
   drivers/ata/libata-eh.c:1012:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
    EXPORT_SYMBOL_GPL(ata_std_sched_eh);
    ^
>> include/linux/export.h:63:39: error: declaration of '__ksymtab_ata_std_sched_eh' with no linkage follows extern declaration
     __visible const struct kernel_symbol __ksymtab_##sym \
                                          ^
   include/linux/export.h:94:25: note: in expansion of macro '___EXPORT_SYMBOL'
    #define __EXPORT_SYMBOL ___EXPORT_SYMBOL
                            ^
   include/linux/export.h:101:2: note: in expansion of macro '__EXPORT_SYMBOL'
     __EXPORT_SYMBOL(sym, "_gpl")
     ^
   drivers/ata/libata-eh.c:1012:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
    EXPORT_SYMBOL_GPL(ata_std_sched_eh);
    ^
   include/linux/export.h:62:36: note: previous declaration of '__ksymtab_ata_std_sched_eh' was here
     extern const struct kernel_symbol __ksymtab_##sym; \
                                       ^
   include/linux/export.h:94:25: note: in expansion of macro '___EXPORT_SYMBOL'
    #define __EXPORT_SYMBOL ___EXPORT_SYMBOL
                            ^
   include/linux/export.h:101:2: note: in expansion of macro '__EXPORT_SYMBOL'
     __EXPORT_SYMBOL(sym, "_gpl")
     ^
   drivers/ata/libata-eh.c:1012:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
    EXPORT_SYMBOL_GPL(ata_std_sched_eh);
    ^
>> drivers/ata/libata-eh.c:1032:15: error: non-static declaration of 'ata_std_end_eh' follows static declaration
    EXPORT_SYMBOL(ata_std_end_eh);
                  ^
   include/linux/export.h:57:21: note: in definition of macro '___EXPORT_SYMBOL'
     extern typeof(sym) sym;     \
                        ^
>> drivers/ata/libata-eh.c:1032:1: note: in expansion of macro 'EXPORT_SYMBOL'
    EXPORT_SYMBOL(ata_std_end_eh);
    ^
   drivers/ata/libata-eh.c:1026:6: note: previous definition of 'ata_std_end_eh' was here
    void ata_std_end_eh(struct ata_port *ap)
         ^
   In file included from include/linux/linkage.h:6:0,
                    from include/linux/kernel.h:6,
                    from drivers/ata/libata-eh.c:35:
   include/linux/export.h:63:25: warning: '__used__' attribute ignored [-Wattributes]
     __visible const struct kernel_symbol __ksymtab_##sym \
                            ^
   include/linux/export.h:94:25: note: in expansion of macro '___EXPORT_SYMBOL'
    #define __EXPORT_SYMBOL ___EXPORT_SYMBOL
                            ^
   include/linux/export.h:98:2: note: in expansion of macro '__EXPORT_SYMBOL'
     __EXPORT_SYMBOL(sym, "")
     ^
>> drivers/ata/libata-eh.c:1032:1: note: in expansion of macro 'EXPORT_SYMBOL'
    EXPORT_SYMBOL(ata_std_end_eh);
    ^
   include/linux/export.h:63:39: error: section attribute cannot be specified for local variables
     __visible const struct kernel_symbol __ksymtab_##sym \
                                          ^
   include/linux/export.h:94:25: note: in expansion of macro '___EXPORT_SYMBOL'
    #define __EXPORT_SYMBOL ___EXPORT_SYMBOL
                            ^
   include/linux/export.h:98:2: note: in expansion of macro '__EXPORT_SYMBOL'
     __EXPORT_SYMBOL(sym, "")
     ^
>> drivers/ata/libata-eh.c:1032:1: note: in expansion of macro 'EXPORT_SYMBOL'
    EXPORT_SYMBOL(ata_std_end_eh);
    ^
   include/linux/export.h:63:25: warning: 'externally_visible' attribute have effect only on public objects [-Wattributes]
     __visible const struct kernel_symbol __ksymtab_##sym \
                            ^
   include/linux/export.h:94:25: note: in expansion of macro '___EXPORT_SYMBOL'
    #define __EXPORT_SYMBOL ___EXPORT_SYMBOL
                            ^
   include/linux/export.h:98:2: note: in expansion of macro '__EXPORT_SYMBOL'
     __EXPORT_SYMBOL(sym, "")
     ^
>> drivers/ata/libata-eh.c:1032:1: note: in expansion of macro 'EXPORT_SYMBOL'
    EXPORT_SYMBOL(ata_std_end_eh);
    ^
>> include/linux/export.h:63:39: error: declaration of '__ksymtab_ata_std_end_eh' with no linkage follows extern declaration
     __visible const struct kernel_symbol __ksymtab_##sym \
                                          ^
   include/linux/export.h:94:25: note: in expansion of macro '___EXPORT_SYMBOL'
    #define __EXPORT_SYMBOL ___EXPORT_SYMBOL
                            ^
   include/linux/export.h:98:2: note: in expansion of macro '__EXPORT_SYMBOL'
     __EXPORT_SYMBOL(sym, "")
     ^

vim +/__ksymtab_ata_scsi_port_error_handler +63 include/linux/export.h

f5016932 Paul Gortmaker 2011-05-23  51  #else
f5016932 Paul Gortmaker 2011-05-23  52  #define __CRC_SYMBOL(sym, sec)
f5016932 Paul Gortmaker 2011-05-23  53  #endif
f5016932 Paul Gortmaker 2011-05-23  54  
f5016932 Paul Gortmaker 2011-05-23  55  /* For every exported symbol, place a struct in the __ksymtab section */
f2355416 Nicolas Pitre  2016-01-22  56  #define ___EXPORT_SYMBOL(sym, sec)				\
f5016932 Paul Gortmaker 2011-05-23 @57  	extern typeof(sym) sym;					\
f5016932 Paul Gortmaker 2011-05-23  58  	__CRC_SYMBOL(sym, sec)					\
f5016932 Paul Gortmaker 2011-05-23  59  	static const char __kstrtab_##sym[]			\
f5016932 Paul Gortmaker 2011-05-23  60  	__attribute__((section("__ksymtab_strings"), aligned(1))) \
b92021b0 Rusty Russell  2013-03-15  61  	= VMLINUX_SYMBOL_STR(sym);				\
7b4ec8dd Johannes Berg  2014-01-16  62  	extern const struct kernel_symbol __ksymtab_##sym;	\
e0f244c6 Andi Kleen     2013-10-23 @63  	__visible const struct kernel_symbol __ksymtab_##sym	\
f5016932 Paul Gortmaker 2011-05-23  64  	__used							\
f5016932 Paul Gortmaker 2011-05-23  65  	__attribute__((section("___ksymtab" sec "+" #sym), unused))	\
f5016932 Paul Gortmaker 2011-05-23  66  	= { (unsigned long)&sym, __kstrtab_##sym }
f5016932 Paul Gortmaker 2011-05-23  67  
c1a95fda Nicolas Pitre  2016-01-22  68  #if defined(__KSYM_DEPS__)
c1a95fda Nicolas Pitre  2016-01-22  69  
c1a95fda Nicolas Pitre  2016-01-22  70  /*
c1a95fda Nicolas Pitre  2016-01-22  71   * For fine grained build dependencies, we want to tell the build system
c1a95fda Nicolas Pitre  2016-01-22  72   * about each possible exported symbol even if they're not actually exported.
c1a95fda Nicolas Pitre  2016-01-22  73   * We use a string pattern that is unlikely to be valid code that the build
c1a95fda Nicolas Pitre  2016-01-22  74   * system filters out from the preprocessor output (see ksym_dep_filter
c1a95fda Nicolas Pitre  2016-01-22  75   * in scripts/Kbuild.include).
c1a95fda Nicolas Pitre  2016-01-22  76   */
c1a95fda Nicolas Pitre  2016-01-22  77  #define __EXPORT_SYMBOL(sym, sec)	=== __KSYM_##sym ===
c1a95fda Nicolas Pitre  2016-01-22  78  
c1a95fda Nicolas Pitre  2016-01-22  79  #elif defined(CONFIG_TRIM_UNUSED_KSYMS)
f2355416 Nicolas Pitre  2016-01-22  80  
f2355416 Nicolas Pitre  2016-01-22  81  #include <linux/kconfig.h>
f2355416 Nicolas Pitre  2016-01-22  82  #include <generated/autoksyms.h>
f2355416 Nicolas Pitre  2016-01-22  83  
f2355416 Nicolas Pitre  2016-01-22  84  #define __EXPORT_SYMBOL(sym, sec)				\
f2355416 Nicolas Pitre  2016-01-22  85  	__cond_export_sym(sym, sec, config_enabled(__KSYM_##sym))
f2355416 Nicolas Pitre  2016-01-22  86  #define __cond_export_sym(sym, sec, conf)			\
f2355416 Nicolas Pitre  2016-01-22  87  	___cond_export_sym(sym, sec, conf)
f2355416 Nicolas Pitre  2016-01-22  88  #define ___cond_export_sym(sym, sec, enabled)			\
f2355416 Nicolas Pitre  2016-01-22  89  	__cond_export_sym_##enabled(sym, sec)
f2355416 Nicolas Pitre  2016-01-22  90  #define __cond_export_sym_1(sym, sec) ___EXPORT_SYMBOL(sym, sec)
f2355416 Nicolas Pitre  2016-01-22  91  #define __cond_export_sym_0(sym, sec) /* nothing */
f2355416 Nicolas Pitre  2016-01-22  92  
f2355416 Nicolas Pitre  2016-01-22  93  #else
f2355416 Nicolas Pitre  2016-01-22 @94  #define __EXPORT_SYMBOL ___EXPORT_SYMBOL
f2355416 Nicolas Pitre  2016-01-22  95  #endif
f2355416 Nicolas Pitre  2016-01-22  96  
f5016932 Paul Gortmaker 2011-05-23  97  #define EXPORT_SYMBOL(sym)					\

:::::: The code at line 63 was first introduced by commit
:::::: e0f244c63fc9d192dfd399cc2677bbdca61994b1 asmlinkage, module: Make ksymtab and kcrctab symbols and __this_module __visible

:::::: TO: Andi Kleen <ak@linux.intel.com>
:::::: CC: Rusty Russell <rusty@rustcorp.com.au>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kernel test robot June 15, 2016, 8:24 a.m. UTC | #2
Hi,

[auto build test ERROR on tj-libata/for-next]
[also build test ERROR on v4.7-rc3 next-20160615]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/DingXiang/libata-fix-kernel-panic-when-hotplug/20160615-154255
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tj/libata for-next
config: tile-allyesconfig (attached as .config)
compiler: tilegx-linux-gcc (GCC) 4.6.2
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=tile 

All error/warnings (new ones prefixed by >>):

   drivers/ata/libata-eh.c: In function 'ata_scsi_port_error_handler':
>> drivers/ata/libata-eh.c:836:1: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
>> drivers/ata/libata-eh.c:836:1: warning: '__used__' attribute ignored [-Wattributes]
>> drivers/ata/libata-eh.c:836:1: error: section attribute cannot be specified for local variables
>> drivers/ata/libata-eh.c:836:1: warning: 'externally_visible' attribute have effect only on public objects [-Wattributes]
>> drivers/ata/libata-eh.c:836:1: error: declaration of '__ksymtab_ata_scsi_port_error_handler' with no linkage follows extern declaration
   drivers/ata/libata-eh.c:836:1: note: previous declaration of '__ksymtab_ata_scsi_port_error_handler' was here
   drivers/ata/libata-eh.c:871:1: error: non-static declaration of 'ata_port_wait_eh' follows static declaration
   drivers/ata/libata-eh.c:847:6: note: previous definition of 'ata_port_wait_eh' was here
   drivers/ata/libata-eh.c:871:1: warning: '__used__' attribute ignored [-Wattributes]
   drivers/ata/libata-eh.c:871:1: error: section attribute cannot be specified for local variables
   drivers/ata/libata-eh.c:871:1: warning: 'externally_visible' attribute have effect only on public objects [-Wattributes]
>> drivers/ata/libata-eh.c:871:1: error: declaration of '__ksymtab_ata_port_wait_eh' with no linkage follows extern declaration
   drivers/ata/libata-eh.c:871:1: note: previous declaration of '__ksymtab_ata_port_wait_eh' was here
   drivers/ata/libata-eh.c:873:12: error: invalid storage class for function 'ata_eh_nr_in_flight'
   drivers/ata/libata-eh.c:937:13: error: invalid storage class for function 'ata_eh_set_pending'
   drivers/ata/libata-eh.c:1012:1: error: non-static declaration of 'ata_std_sched_eh' follows static declaration
   drivers/ata/libata-eh.c:1000:6: note: previous definition of 'ata_std_sched_eh' was here
   drivers/ata/libata-eh.c:1012:1: warning: '__used__' attribute ignored [-Wattributes]
   drivers/ata/libata-eh.c:1012:1: error: section attribute cannot be specified for local variables
   drivers/ata/libata-eh.c:1012:1: warning: 'externally_visible' attribute have effect only on public objects [-Wattributes]
>> drivers/ata/libata-eh.c:1012:1: error: declaration of '__ksymtab_ata_std_sched_eh' with no linkage follows extern declaration
   drivers/ata/libata-eh.c:1012:1: note: previous declaration of '__ksymtab_ata_std_sched_eh' was here
   drivers/ata/libata-eh.c:1032:1: error: non-static declaration of 'ata_std_end_eh' follows static declaration
   drivers/ata/libata-eh.c:1026:6: note: previous definition of 'ata_std_end_eh' was here
   drivers/ata/libata-eh.c:1032:1: warning: '__used__' attribute ignored [-Wattributes]
   drivers/ata/libata-eh.c:1032:1: error: section attribute cannot be specified for local variables
   drivers/ata/libata-eh.c:1032:1: warning: 'externally_visible' attribute have effect only on public objects [-Wattributes]
>> drivers/ata/libata-eh.c:1032:1: error: declaration of '__ksymtab_ata_std_end_eh' with no linkage follows extern declaration
   drivers/ata/libata-eh.c:1032:1: note: previous declaration of '__ksymtab_ata_std_end_eh' was here
   drivers/ata/libata-eh.c:1051:12: error: invalid storage class for function 'ata_do_link_abort'
   drivers/ata/libata-eh.c:1128:13: error: invalid storage class for function '__ata_port_freeze'
   drivers/ata/libata-eh.c:1288:13: error: invalid storage class for function 'ata_eh_scsidone'
   drivers/ata/libata-eh.c:1293:13: error: invalid storage class for function '__ata_eh_qc_complete'
   drivers/ata/libata-eh.c:1471:20: error: invalid storage class for function 'ata_err_string'
   drivers/ata/libata-eh.c:1571:12: error: invalid storage class for function 'ata_eh_read_log_10h'
   drivers/ata/libata-eh.c:1654:13: error: invalid storage class for function 'ata_eh_request_sense'
   drivers/ata/libata-eh.c:1756:13: error: invalid storage class for function 'ata_eh_analyze_serror'
   drivers/ata/libata-eh.c:1885:21: error: invalid storage class for function 'ata_eh_analyze_tf'
   drivers/ata/libata-eh.c:1957:12: error: invalid storage class for function 'ata_eh_categorize_error'
   drivers/ata/libata-eh.c:1991:12: error: invalid storage class for function 'speed_down_verdict_cb'
   drivers/ata/libata-eh.c:2063:21: error: invalid storage class for function 'ata_eh_speed_down_verdict'
   drivers/ata/libata-eh.c:2123:21: error: invalid storage class for function 'ata_eh_speed_down'
   drivers/ata/libata-eh.c:2208:19: error: invalid storage class for function 'ata_eh_worth_retry'
   drivers/ata/libata-eh.c:2230:13: error: invalid storage class for function 'ata_eh_link_autopsy'
   drivers/ata/libata-eh.c:2506:1: error: non-static declaration of 'ata_get_cmd_descript' follows static declaration
   drivers/ata/libata-eh.c:2396:13: note: previous definition of 'ata_get_cmd_descript' was here
   drivers/ata/libata-eh.c:2506:1: warning: '__used__' attribute ignored [-Wattributes]
   drivers/ata/libata-eh.c:2506:1: error: section attribute cannot be specified for local variables
   drivers/ata/libata-eh.c:2506:1: warning: 'externally_visible' attribute have effect only on public objects [-Wattributes]
>> drivers/ata/libata-eh.c:2506:1: error: declaration of '__ksymtab_ata_get_cmd_descript' with no linkage follows extern declaration
   drivers/ata/libata-eh.c:2506:1: note: previous declaration of '__ksymtab_ata_get_cmd_descript' was here
   drivers/ata/libata-eh.c:2517:13: error: invalid storage class for function 'ata_eh_link_report'
   drivers/ata/libata-eh.c:2703:12: error: invalid storage class for function 'ata_do_reset'
   drivers/ata/libata-eh.c:2716:12: error: invalid storage class for function 'ata_eh_followup_srst_needed'
   drivers/ata/libata-eh.c:3117:20: error: invalid storage class for function 'ata_eh_pull_park_action'
   drivers/ata/libata-eh.c:3163:13: error: invalid storage class for function 'ata_eh_park_issue_cmd'
   drivers/ata/libata-eh.c:3191:12: error: invalid storage class for function 'ata_eh_revalidate_and_attach'
   drivers/ata/libata-eh.c:3386:12: error: invalid storage class for function 'atapi_eh_clear_ua'
   drivers/ata/libata-eh.c:3437:12: error: invalid storage class for function 'ata_eh_maybe_retry_flush'
   drivers/ata/libata-eh.c:3513:12: error: invalid storage class for function 'ata_eh_set_lpm'
   drivers/ata/libata-eh.c:3639:12: error: invalid storage class for function 'ata_link_nr_vacant'
   drivers/ata/libata-eh.c:3650:12: error: invalid storage class for function 'ata_eh_skip_recovery'
   drivers/ata/libata-eh.c:3683:12: error: invalid storage class for function 'ata_count_probe_trials_cb'
   drivers/ata/libata-eh.c:3697:12: error: invalid storage class for function 'ata_eh_schedule_probe'
   drivers/ata/libata-eh.c:3746:12: error: invalid storage class for function 'ata_eh_handle_dev_fail'
   drivers/ata/libata-eh.c:4140:1: error: expected declaration or statement at end of input
   drivers/ata/libata-eh.c: At top level:
   drivers/ata/libata-eh.c:166:13: warning: '__ata_port_freeze' used but never defined [enabled by default]

vim +836 drivers/ata/libata-eh.c

c6cf9e99d drivers/scsi/libata-eh.c Tejun Heo       2006-05-31   830  	/* tell wait_eh that we're done */
b51e9e5db drivers/scsi/libata-eh.c Tejun Heo       2006-06-29   831  	ap->pflags &= ~ATA_PFLAG_EH_IN_PROGRESS;
c6cf9e99d drivers/scsi/libata-eh.c Tejun Heo       2006-05-31   832  	wake_up_all(&ap->eh_wait_q);
c6cf9e99d drivers/scsi/libata-eh.c Tejun Heo       2006-05-31   833  
e30349d27 drivers/scsi/libata-eh.c Tejun Heo       2006-07-03   834  	spin_unlock_irqrestore(ap->lock, flags);
ece1d6361 drivers/scsi/libata-eh.c Tejun Heo       2006-04-02   835  }
0e0b494ca drivers/ata/libata-eh.c  James Bottomley 2011-01-23  @836  EXPORT_SYMBOL_GPL(ata_scsi_port_error_handler);
ece1d6361 drivers/scsi/libata-eh.c Tejun Heo       2006-04-02   837  
ece1d6361 drivers/scsi/libata-eh.c Tejun Heo       2006-04-02   838  /**
c6cf9e99d drivers/scsi/libata-eh.c Tejun Heo       2006-05-31   839   *	ata_port_wait_eh - Wait for the currently pending EH to complete
c6cf9e99d drivers/scsi/libata-eh.c Tejun Heo       2006-05-31   840   *	@ap: Port to wait EH for
c6cf9e99d drivers/scsi/libata-eh.c Tejun Heo       2006-05-31   841   *
c6cf9e99d drivers/scsi/libata-eh.c Tejun Heo       2006-05-31   842   *	Wait until the currently pending EH is complete.
c6cf9e99d drivers/scsi/libata-eh.c Tejun Heo       2006-05-31   843   *
c6cf9e99d drivers/scsi/libata-eh.c Tejun Heo       2006-05-31   844   *	LOCKING:
c6cf9e99d drivers/scsi/libata-eh.c Tejun Heo       2006-05-31   845   *	Kernel thread context (may sleep).
c6cf9e99d drivers/scsi/libata-eh.c Tejun Heo       2006-05-31   846   */
c6cf9e99d drivers/scsi/libata-eh.c Tejun Heo       2006-05-31   847  void ata_port_wait_eh(struct ata_port *ap)
c6cf9e99d drivers/scsi/libata-eh.c Tejun Heo       2006-05-31   848  {
c6cf9e99d drivers/scsi/libata-eh.c Tejun Heo       2006-05-31   849  	unsigned long flags;
c6cf9e99d drivers/scsi/libata-eh.c Tejun Heo       2006-05-31   850  	DEFINE_WAIT(wait);
c6cf9e99d drivers/scsi/libata-eh.c Tejun Heo       2006-05-31   851  
c6cf9e99d drivers/scsi/libata-eh.c Tejun Heo       2006-05-31   852   retry:
ba6a13083 drivers/scsi/libata-eh.c Jeff Garzik     2006-06-22   853  	spin_lock_irqsave(ap->lock, flags);
c6cf9e99d drivers/scsi/libata-eh.c Tejun Heo       2006-05-31   854  
b51e9e5db drivers/scsi/libata-eh.c Tejun Heo       2006-06-29   855  	while (ap->pflags & (ATA_PFLAG_EH_PENDING | ATA_PFLAG_EH_IN_PROGRESS)) {
c6cf9e99d drivers/scsi/libata-eh.c Tejun Heo       2006-05-31   856  		prepare_to_wait(&ap->eh_wait_q, &wait, TASK_UNINTERRUPTIBLE);
ba6a13083 drivers/scsi/libata-eh.c Jeff Garzik     2006-06-22   857  		spin_unlock_irqrestore(ap->lock, flags);
c6cf9e99d drivers/scsi/libata-eh.c Tejun Heo       2006-05-31   858  		schedule();
ba6a13083 drivers/scsi/libata-eh.c Jeff Garzik     2006-06-22   859  		spin_lock_irqsave(ap->lock, flags);
c6cf9e99d drivers/scsi/libata-eh.c Tejun Heo       2006-05-31   860  	}
0a1b622ef drivers/scsi/libata-eh.c Tejun Heo       2006-06-11   861  	finish_wait(&ap->eh_wait_q, &wait);
c6cf9e99d drivers/scsi/libata-eh.c Tejun Heo       2006-05-31   862  
ba6a13083 drivers/scsi/libata-eh.c Jeff Garzik     2006-06-22   863  	spin_unlock_irqrestore(ap->lock, flags);
c6cf9e99d drivers/scsi/libata-eh.c Tejun Heo       2006-05-31   864  
c6cf9e99d drivers/scsi/libata-eh.c Tejun Heo       2006-05-31   865  	/* make sure SCSI EH is complete */
cca3974e4 drivers/ata/libata-eh.c  Jeff Garzik     2006-08-24   866  	if (scsi_host_in_recovery(ap->scsi_host)) {
97750cebb drivers/ata/libata-eh.c  Tejun Heo       2010-09-06   867  		ata_msleep(ap, 10);
c6cf9e99d drivers/scsi/libata-eh.c Tejun Heo       2006-05-31   868  		goto retry;
c6cf9e99d drivers/scsi/libata-eh.c Tejun Heo       2006-05-31   869  	}
c6cf9e99d drivers/scsi/libata-eh.c Tejun Heo       2006-05-31   870  }
81c757bc6 drivers/ata/libata-eh.c  Dan Williams    2011-12-02  @871  EXPORT_SYMBOL_GPL(ata_port_wait_eh);
c6cf9e99d drivers/scsi/libata-eh.c Tejun Heo       2006-05-31   872  
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   873  static int ata_eh_nr_in_flight(struct ata_port *ap)
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   874  {
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   875  	unsigned int tag;
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   876  	int nr = 0;
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   877  
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   878  	/* count only non-internal commands */
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   879  	for (tag = 0; tag < ATA_MAX_QUEUE - 1; tag++)
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   880  		if (ata_qc_from_tag(ap, tag))
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   881  			nr++;
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   882  
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   883  	return nr;
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   884  }
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   885  
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   886  void ata_eh_fastdrain_timerfn(unsigned long arg)
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   887  {
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   888  	struct ata_port *ap = (void *)arg;
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   889  	unsigned long flags;
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   890  	int cnt;
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   891  
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   892  	spin_lock_irqsave(ap->lock, flags);
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   893  
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   894  	cnt = ata_eh_nr_in_flight(ap);
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   895  
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   896  	/* are we done? */
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   897  	if (!cnt)
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   898  		goto out_unlock;
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   899  
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   900  	if (cnt == ap->fastdrain_cnt) {
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   901  		unsigned int tag;
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   902  
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   903  		/* No progress during the last interval, tag all
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   904  		 * in-flight qcs as timed out and freeze the port.
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   905  		 */
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   906  		for (tag = 0; tag < ATA_MAX_QUEUE - 1; tag++) {
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   907  			struct ata_queued_cmd *qc = ata_qc_from_tag(ap, tag);
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   908  			if (qc)
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   909  				qc->err_mask |= AC_ERR_TIMEOUT;
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   910  		}
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   911  
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   912  		ata_port_freeze(ap);
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   913  	} else {
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   914  		/* some qcs have finished, give it another chance */
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   915  		ap->fastdrain_cnt = cnt;
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   916  		ap->fastdrain_timer.expires =
341c2c958 drivers/ata/libata-eh.c  Tejun Heo       2008-05-20   917  			ata_deadline(jiffies, ATA_EH_FASTDRAIN_INTERVAL);
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   918  		add_timer(&ap->fastdrain_timer);
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   919  	}
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   920  
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   921   out_unlock:
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   922  	spin_unlock_irqrestore(ap->lock, flags);
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   923  }
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   924  
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   925  /**
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   926   *	ata_eh_set_pending - set ATA_PFLAG_EH_PENDING and activate fast drain
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   927   *	@ap: target ATA port
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   928   *	@fastdrain: activate fast drain
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   929   *
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   930   *	Set ATA_PFLAG_EH_PENDING and activate fast drain if @fastdrain
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   931   *	is non-zero and EH wasn't pending before.  Fast drain ensures
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   932   *	that EH kicks in in timely manner.
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   933   *
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   934   *	LOCKING:
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   935   *	spin_lock_irqsave(host lock)
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   936   */
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   937  static void ata_eh_set_pending(struct ata_port *ap, int fastdrain)
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   938  {
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   939  	int cnt;
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   940  
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   941  	/* already scheduled? */
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   942  	if (ap->pflags & ATA_PFLAG_EH_PENDING)
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   943  		return;
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   944  
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   945  	ap->pflags |= ATA_PFLAG_EH_PENDING;
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   946  
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   947  	if (!fastdrain)
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   948  		return;
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   949  
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   950  	/* do we have in-flight qcs? */
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   951  	cnt = ata_eh_nr_in_flight(ap);
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   952  	if (!cnt)
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   953  		return;
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   954  
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   955  	/* activate fast drain */
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   956  	ap->fastdrain_cnt = cnt;
341c2c958 drivers/ata/libata-eh.c  Tejun Heo       2008-05-20   957  	ap->fastdrain_timer.expires =
341c2c958 drivers/ata/libata-eh.c  Tejun Heo       2008-05-20   958  		ata_deadline(jiffies, ATA_EH_FASTDRAIN_INTERVAL);
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   959  	add_timer(&ap->fastdrain_timer);
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   960  }
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   961  
f686bcb80 drivers/scsi/libata-eh.c Tejun Heo       2006-05-15   962  /**
f686bcb80 drivers/scsi/libata-eh.c Tejun Heo       2006-05-15   963   *	ata_qc_schedule_eh - schedule qc for error handling
f686bcb80 drivers/scsi/libata-eh.c Tejun Heo       2006-05-15   964   *	@qc: command to schedule error handling for
f686bcb80 drivers/scsi/libata-eh.c Tejun Heo       2006-05-15   965   *
f686bcb80 drivers/scsi/libata-eh.c Tejun Heo       2006-05-15   966   *	Schedule error handling for @qc.  EH will kick in as soon as
f686bcb80 drivers/scsi/libata-eh.c Tejun Heo       2006-05-15   967   *	other commands are drained.
f686bcb80 drivers/scsi/libata-eh.c Tejun Heo       2006-05-15   968   *
f686bcb80 drivers/scsi/libata-eh.c Tejun Heo       2006-05-15   969   *	LOCKING:
cca3974e4 drivers/ata/libata-eh.c  Jeff Garzik     2006-08-24   970   *	spin_lock_irqsave(host lock)
f686bcb80 drivers/scsi/libata-eh.c Tejun Heo       2006-05-15   971   */
f686bcb80 drivers/scsi/libata-eh.c Tejun Heo       2006-05-15   972  void ata_qc_schedule_eh(struct ata_queued_cmd *qc)
f686bcb80 drivers/scsi/libata-eh.c Tejun Heo       2006-05-15   973  {
f686bcb80 drivers/scsi/libata-eh.c Tejun Heo       2006-05-15   974  	struct ata_port *ap = qc->ap;
fa41efdae drivers/ata/libata-eh.c  Tejun Heo       2010-04-15   975  	struct request_queue *q = qc->scsicmd->device->request_queue;
fa41efdae drivers/ata/libata-eh.c  Tejun Heo       2010-04-15   976  	unsigned long flags;
f686bcb80 drivers/scsi/libata-eh.c Tejun Heo       2006-05-15   977  
f686bcb80 drivers/scsi/libata-eh.c Tejun Heo       2006-05-15   978  	WARN_ON(!ap->ops->error_handler);
f686bcb80 drivers/scsi/libata-eh.c Tejun Heo       2006-05-15   979  
f686bcb80 drivers/scsi/libata-eh.c Tejun Heo       2006-05-15   980  	qc->flags |= ATA_QCFLAG_FAILED;
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16   981  	ata_eh_set_pending(ap, 1);
f686bcb80 drivers/scsi/libata-eh.c Tejun Heo       2006-05-15   982  
f686bcb80 drivers/scsi/libata-eh.c Tejun Heo       2006-05-15   983  	/* The following will fail if timeout has already expired.
f686bcb80 drivers/scsi/libata-eh.c Tejun Heo       2006-05-15   984  	 * ata_scsi_error() takes care of such scmds on EH entry.
f686bcb80 drivers/scsi/libata-eh.c Tejun Heo       2006-05-15   985  	 * Note that ATA_QCFLAG_FAILED is unconditionally set after
f686bcb80 drivers/scsi/libata-eh.c Tejun Heo       2006-05-15   986  	 * this function completes.
f686bcb80 drivers/scsi/libata-eh.c Tejun Heo       2006-05-15   987  	 */
fa41efdae drivers/ata/libata-eh.c  Tejun Heo       2010-04-15   988  	spin_lock_irqsave(q->queue_lock, flags);
242f9dcb8 drivers/ata/libata-eh.c  Jens Axboe      2008-09-14   989  	blk_abort_request(qc->scsicmd->request);
fa41efdae drivers/ata/libata-eh.c  Tejun Heo       2010-04-15   990  	spin_unlock_irqrestore(q->queue_lock, flags);
f686bcb80 drivers/scsi/libata-eh.c Tejun Heo       2006-05-15   991  }
f686bcb80 drivers/scsi/libata-eh.c Tejun Heo       2006-05-15   992  
7b70fc039 drivers/scsi/libata-eh.c Tejun Heo       2006-05-15   993  /**
e4a9c3732 drivers/ata/libata-eh.c  Dan Williams    2012-06-21   994   * ata_std_sched_eh - non-libsas ata_ports issue eh with this common routine
7b70fc039 drivers/scsi/libata-eh.c Tejun Heo       2006-05-15   995   * @ap: ATA port to schedule EH for
7b70fc039 drivers/scsi/libata-eh.c Tejun Heo       2006-05-15   996   *
e4a9c3732 drivers/ata/libata-eh.c  Dan Williams    2012-06-21   997   *	LOCKING: inherited from ata_port_schedule_eh
cca3974e4 drivers/ata/libata-eh.c  Jeff Garzik     2006-08-24   998   *	spin_lock_irqsave(host lock)
7b70fc039 drivers/scsi/libata-eh.c Tejun Heo       2006-05-15   999   */
e4a9c3732 drivers/ata/libata-eh.c  Dan Williams    2012-06-21  1000  void ata_std_sched_eh(struct ata_port *ap)
7b70fc039 drivers/scsi/libata-eh.c Tejun Heo       2006-05-15  1001  {
7b70fc039 drivers/scsi/libata-eh.c Tejun Heo       2006-05-15  1002  	WARN_ON(!ap->ops->error_handler);
7b70fc039 drivers/scsi/libata-eh.c Tejun Heo       2006-05-15  1003  
f4d6d0046 drivers/ata/libata-eh.c  Tejun Heo       2007-05-01  1004  	if (ap->pflags & ATA_PFLAG_INITIALIZING)
f4d6d0046 drivers/ata/libata-eh.c  Tejun Heo       2007-05-01  1005  		return;
f4d6d0046 drivers/ata/libata-eh.c  Tejun Heo       2007-05-01  1006  
5ddf24c5e drivers/ata/libata-eh.c  Tejun Heo       2007-07-16  1007  	ata_eh_set_pending(ap, 1);
cca3974e4 drivers/ata/libata-eh.c  Jeff Garzik     2006-08-24  1008  	scsi_schedule_eh(ap->scsi_host);
7b70fc039 drivers/scsi/libata-eh.c Tejun Heo       2006-05-15  1009  
7b70fc039 drivers/scsi/libata-eh.c Tejun Heo       2006-05-15  1010  	DPRINTK("port EH scheduled\n");
7b70fc039 drivers/scsi/libata-eh.c Tejun Heo       2006-05-15  1011  }
e4a9c3732 drivers/ata/libata-eh.c  Dan Williams    2012-06-21 @1012  EXPORT_SYMBOL_GPL(ata_std_sched_eh);
e4a9c3732 drivers/ata/libata-eh.c  Dan Williams    2012-06-21  1013  
e4a9c3732 drivers/ata/libata-eh.c  Dan Williams    2012-06-21  1014  /**
e4a9c3732 drivers/ata/libata-eh.c  Dan Williams    2012-06-21  1015   * ata_std_end_eh - non-libsas ata_ports complete eh with this common routine
e4a9c3732 drivers/ata/libata-eh.c  Dan Williams    2012-06-21  1016   * @ap: ATA port to end EH for
e4a9c3732 drivers/ata/libata-eh.c  Dan Williams    2012-06-21  1017   *
e4a9c3732 drivers/ata/libata-eh.c  Dan Williams    2012-06-21  1018   * In the libata object model there is a 1:1 mapping of ata_port to
e4a9c3732 drivers/ata/libata-eh.c  Dan Williams    2012-06-21  1019   * shost, so host fields can be directly manipulated under ap->lock, in
e4a9c3732 drivers/ata/libata-eh.c  Dan Williams    2012-06-21  1020   * the libsas case we need to hold a lock at the ha->level to coordinate
e4a9c3732 drivers/ata/libata-eh.c  Dan Williams    2012-06-21  1021   * these events.
e4a9c3732 drivers/ata/libata-eh.c  Dan Williams    2012-06-21  1022   *
e4a9c3732 drivers/ata/libata-eh.c  Dan Williams    2012-06-21  1023   *	LOCKING:
e4a9c3732 drivers/ata/libata-eh.c  Dan Williams    2012-06-21  1024   *	spin_lock_irqsave(host lock)
e4a9c3732 drivers/ata/libata-eh.c  Dan Williams    2012-06-21  1025   */
e4a9c3732 drivers/ata/libata-eh.c  Dan Williams    2012-06-21  1026  void ata_std_end_eh(struct ata_port *ap)
e4a9c3732 drivers/ata/libata-eh.c  Dan Williams    2012-06-21  1027  {
e4a9c3732 drivers/ata/libata-eh.c  Dan Williams    2012-06-21  1028  	struct Scsi_Host *host = ap->scsi_host;
e4a9c3732 drivers/ata/libata-eh.c  Dan Williams    2012-06-21  1029  
e4a9c3732 drivers/ata/libata-eh.c  Dan Williams    2012-06-21  1030  	host->host_eh_scheduled = 0;
e4a9c3732 drivers/ata/libata-eh.c  Dan Williams    2012-06-21  1031  }
e4a9c3732 drivers/ata/libata-eh.c  Dan Williams    2012-06-21 @1032  EXPORT_SYMBOL(ata_std_end_eh);
e4a9c3732 drivers/ata/libata-eh.c  Dan Williams    2012-06-21  1033  
e4a9c3732 drivers/ata/libata-eh.c  Dan Williams    2012-06-21  1034  
e4a9c3732 drivers/ata/libata-eh.c  Dan Williams    2012-06-21  1035  /**

:::::: The code at line 836 was first introduced by commit
:::::: 0e0b494ca8c54a7297d0cc549405091019b3b77e libata: separate error handler into usable components

:::::: TO: James Bottomley <James.Bottomley@suse.de>
:::::: CC: Jeff Garzik <jgarzik@redhat.com>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 961acc7..74c5ecf 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -816,8 +816,11 @@  void ata_scsi_port_error_handler(struct Scsi_Host *host, struct ata_port *ap)
 
 	if (ap->pflags & ATA_PFLAG_LOADING)
 		ap->pflags &= ~ATA_PFLAG_LOADING;
-	else if (ap->pflags & ATA_PFLAG_SCSI_HOTPLUG)
-		schedule_delayed_work(&ap->hotplug_task, 0);
+	else if (ap->pflags & ATA_PFLAG_SCSI_HOTPLUG){
+		if(ap->flags & ATA_FLAG_SAS_HOST)
+			ap->pflags &= ~ATA_PFLAG_SCSI_HOTPLUG;
+		else
+			schedule_delayed_work(&ap->hotplug_task, 0);
 
 	if (ap->pflags & ATA_PFLAG_RECOVERED)
 		ata_port_info(ap, "EH complete\n");