* Re: [RESEND PATCH v4 4/4] powerpc/papr_scm: Document papr_scm sysfs event format entries
From: Dan Williams @ 2021-09-08 1:03 UTC (permalink / raw)
To: Kajol Jain
Cc: Linux NVDIMM, Santosh Sivaraj, maddy, Weiny, Ira, rnsastry,
Peter Zijlstra, Linux Kernel Mailing List, atrajeev,
Aneesh Kumar K.V, Vishal L Verma, Vaibhav Jain, Thomas Gleixner,
linuxppc-dev
In-Reply-To: <20210903050914.273525-5-kjain@linux.ibm.com>
On Thu, Sep 2, 2021 at 10:11 PM Kajol Jain <kjain@linux.ibm.com> wrote:
>
> Details is added for the event, cpumask and format attributes
> in the ABI documentation.
>
> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> Reviewed-by: Madhavan Srinivasan <maddy@linux.ibm.com>
> Tested-by: Nageswara R Sastry <rnsastry@linux.ibm.com>
> Signed-off-by: Kajol Jain <kjain@linux.ibm.com>
> ---
> Documentation/ABI/testing/sysfs-bus-papr-pmem | 31 +++++++++++++++++++
> 1 file changed, 31 insertions(+)
>
> diff --git a/Documentation/ABI/testing/sysfs-bus-papr-pmem b/Documentation/ABI/testing/sysfs-bus-papr-pmem
> index 95254cec92bf..4d86252448f8 100644
> --- a/Documentation/ABI/testing/sysfs-bus-papr-pmem
> +++ b/Documentation/ABI/testing/sysfs-bus-papr-pmem
> @@ -61,3 +61,34 @@ Description:
> * "CchRHCnt" : Cache Read Hit Count
> * "CchWHCnt" : Cache Write Hit Count
> * "FastWCnt" : Fast Write Count
> +
> +What: /sys/devices/nmemX/format
> +Date: June 2021
> +Contact: linuxppc-dev <linuxppc-dev@lists.ozlabs.org>, nvdimm@lists.linux.dev,
> +Description: (RO) Attribute group to describe the magic bits
> + that go into perf_event_attr.config for a particular pmu.
> + (See ABI/testing/sysfs-bus-event_source-devices-format).
> +
> + Each attribute under this group defines a bit range of the
> + perf_event_attr.config. Supported attribute is listed
> + below::
> +
> + event = "config:0-4" - event ID
> +
> + For example::
> + noopstat = "event=0x1"
> +
> +What: /sys/devices/nmemX/events
That's not a valid sysfs path. Did you mean /sys/bus/nd/devices/nmemX?
> +Date: June 2021
> +Contact: linuxppc-dev <linuxppc-dev@lists.ozlabs.org>, nvdimm@lists.linux.dev,
> +Description: (RO) Attribute group to describe performance monitoring
> + events specific to papr-scm. Each attribute in this group describes
> + a single performance monitoring event supported by this nvdimm pmu.
> + The name of the file is the name of the event.
> + (See ABI/testing/sysfs-bus-event_source-devices-events).
Given these events are in the generic namespace the ABI documentation
should be generic as well. So I think move these entries to
Documentation/ABI/testing/sysfs-bus-nvdimm directly.
You can still mention papr-scm, but I would expect something like:
What: /sys/bus/nd/devices/nmemX/events
Date: September 2021
KernelVersion: 5.16
Contact: Kajol Jain <kjain@linux.ibm.com>
Description:
(RO) Attribute group to describe performance monitoring events
for the nvdimm memory device. Each attribute in this group
describes a single performance monitoring event supported by
this nvdimm pmu. The name of the file is the name of the event.
(See ABI/testing/sysfs-bus-event_source-devices-events). A
listing of the events supported by a given nvdimm provider type
can be found in Documentation/driver-api/nvdimm/$provider, for
example: Documentation/driver-api/nvdimm/papr-scm.
> +
> +What: /sys/devices/nmemX/cpumask
> +Date: June 2021
> +Contact: linuxppc-dev <linuxppc-dev@lists.ozlabs.org>, nvdimm@lists.linux.dev,
> +Description: (RO) This sysfs file exposes the cpumask which is designated to make
> + HCALLs to retrieve nvdimm pmu event counter data.
Seems this one would be provider generic, so no need to refer to PPC
specific concepts like HCALLs.
^ permalink raw reply
* Re: [PATCH] pci/hotplug/pnv-php: Remove probable double put
From: Oliver O'Halloran @ 2021-09-07 23:17 UTC (permalink / raw)
To: Tyrel Datwyler
Cc: Linux Kernel Mailing List, Paul Mackerras, Xu Wang, linux-pci,
Bjorn Helgaas, linuxppc-dev
In-Reply-To: <0fa7ddfa-cd65-583e-a83f-4cbcd4e7337f@linux.ibm.com>
On Wed, Sep 8, 2021 at 8:02 AM Tyrel Datwyler <tyreld@linux.ibm.com> wrote:
>
> On 9/7/21 1:59 AM, Xu Wang wrote:
> > Device node iterators put the previous value of the index variable,
> > so an explicit put causes a double put.
> >
> > Signed-off-by: Xu Wang <vulab@iscas.ac.cn>
> > ---
> > drivers/pci/hotplug/pnv_php.c | 1 -
> > 1 file changed, 1 deletion(-)
> >
> > diff --git a/drivers/pci/hotplug/pnv_php.c b/drivers/pci/hotplug/pnv_php.c
> > index 04565162a449..ed4d1a2c3f22 100644
> > --- a/drivers/pci/hotplug/pnv_php.c
> > +++ b/drivers/pci/hotplug/pnv_php.c
> > @@ -158,7 +158,6 @@ static void pnv_php_detach_device_nodes(struct device_node *parent)
> > for_each_child_of_node(parent, dn) {
> > pnv_php_detach_device_nodes(dn);
> >
> > - of_node_put(dn);
> > of_detach_node(dn);
>
> Are you sure this is a double put? This looks to me like its meant to drive tear
> down of the device by putting a long term reference and not the short term get
> that is part of the iterator.
Yeah, the put is there is to drop the initial ref so the node can be
released. It might be worth adding a comment.
^ permalink raw reply
* Re: [PATCH] pci/hotplug/pnv-php: Remove probable double put
From: Tyrel Datwyler @ 2021-09-07 22:01 UTC (permalink / raw)
To: Xu Wang, mpe, benh, paulus, bhelgaas
Cc: linux-pci, linuxppc-dev, linux-kernel
In-Reply-To: <20210907085946.21694-1-vulab@iscas.ac.cn>
On 9/7/21 1:59 AM, Xu Wang wrote:
> Device node iterators put the previous value of the index variable,
> so an explicit put causes a double put.
>
> Signed-off-by: Xu Wang <vulab@iscas.ac.cn>
> ---
> drivers/pci/hotplug/pnv_php.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/drivers/pci/hotplug/pnv_php.c b/drivers/pci/hotplug/pnv_php.c
> index 04565162a449..ed4d1a2c3f22 100644
> --- a/drivers/pci/hotplug/pnv_php.c
> +++ b/drivers/pci/hotplug/pnv_php.c
> @@ -158,7 +158,6 @@ static void pnv_php_detach_device_nodes(struct device_node *parent)
> for_each_child_of_node(parent, dn) {
> pnv_php_detach_device_nodes(dn);
>
> - of_node_put(dn);
> of_detach_node(dn);
Are you sure this is a double put? This looks to me like its meant to drive tear
down of the device by putting a long term reference and not the short term get
that is part of the iterator.
-Tyrel
> }
> }
>
^ permalink raw reply
* Re: [RESEND PATCH v4 1/4] drivers/nvdimm: Add nvdimm pmu structure
From: Dan Williams @ 2021-09-07 21:59 UTC (permalink / raw)
To: Kajol Jain
Cc: Linux NVDIMM, Santosh Sivaraj, maddy, Weiny, Ira, rnsastry,
Peter Zijlstra, Linux Kernel Mailing List, atrajeev,
Aneesh Kumar K.V, Vishal L Verma, Vaibhav Jain, Thomas Gleixner,
linuxppc-dev
In-Reply-To: <20210903050914.273525-2-kjain@linux.ibm.com>
Hi Kajol,
Apologies for the delay in responding to this series, some comments below:
On Thu, Sep 2, 2021 at 10:10 PM Kajol Jain <kjain@linux.ibm.com> wrote:
>
> A structure is added, called nvdimm_pmu, for performance
> stats reporting support of nvdimm devices. It can be used to add
> nvdimm pmu data such as supported events and pmu event functions
> like event_init/add/read/del with cpu hotplug support.
>
> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> Reviewed-by: Madhavan Srinivasan <maddy@linux.ibm.com>
> Tested-by: Nageswara R Sastry <rnsastry@linux.ibm.com>
> Signed-off-by: Kajol Jain <kjain@linux.ibm.com>
> ---
> include/linux/nd.h | 43 +++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 43 insertions(+)
>
> diff --git a/include/linux/nd.h b/include/linux/nd.h
> index ee9ad76afbba..712499cf7335 100644
> --- a/include/linux/nd.h
> +++ b/include/linux/nd.h
> @@ -8,6 +8,8 @@
> #include <linux/ndctl.h>
> #include <linux/device.h>
> #include <linux/badblocks.h>
> +#include <linux/platform_device.h>
> +#include <linux/perf_event.h>
>
> enum nvdimm_event {
> NVDIMM_REVALIDATE_POISON,
> @@ -23,6 +25,47 @@ enum nvdimm_claim_class {
> NVDIMM_CCLASS_UNKNOWN,
> };
>
> +/* Event attribute array index */
> +#define NVDIMM_PMU_FORMAT_ATTR 0
> +#define NVDIMM_PMU_EVENT_ATTR 1
> +#define NVDIMM_PMU_CPUMASK_ATTR 2
> +#define NVDIMM_PMU_NULL_ATTR 3
> +
> +/**
> + * struct nvdimm_pmu - data structure for nvdimm perf driver
> + *
> + * @name: name of the nvdimm pmu device.
> + * @pmu: pmu data structure for nvdimm performance stats.
> + * @dev: nvdimm device pointer.
> + * @functions(event_init/add/del/read): platform specific pmu functions.
This is not valid kernel-doc:
include/linux/nd.h:67: warning: Function parameter or member
'event_init' not described in 'nvdimm_pmu'
include/linux/nd.h:67: warning: Function parameter or member 'add' not
described in 'nvdimm_pmu'
include/linux/nd.h:67: warning: Function parameter or member 'del' not
described in 'nvdimm_pmu'
include/linux/nd.h:67: warning: Function parameter or member 'read'
not described in 'nvdimm_pmu'
...but I think rather than fixing those up 'struct nvdimm_pmu' should be pruned.
It's not clear to me that it is worth the effort to describe these
details to the nvdimm core which is just going to turn around and call
the pmu core. I'd just as soon have the driver call the pmu core
directly, optionally passing in attributes and callbacks that come
from the nvdimm core and/or the nvdimm provider.
Otherwise it's also not clear which of these structure members are
used at runtime vs purely used as temporary storage to pass parameters
to the pmu core.
> + * @attr_groups: data structure for events, formats and cpumask
> + * @cpu: designated cpu for counter access.
> + * @node: node for cpu hotplug notifier link.
> + * @cpuhp_state: state for cpu hotplug notification.
> + * @arch_cpumask: cpumask to get designated cpu for counter access.
> + */
> +struct nvdimm_pmu {
> + const char *name;
> + struct pmu pmu;
> + struct device *dev;
> + int (*event_init)(struct perf_event *event);
> + int (*add)(struct perf_event *event, int flags);
> + void (*del)(struct perf_event *event, int flags);
> + void (*read)(struct perf_event *event);
> + /*
> + * Attribute groups for the nvdimm pmu. Index 0 used for
> + * format attribute, index 1 used for event attribute,
> + * index 2 used for cpusmask attribute and index 3 kept as NULL.
> + */
> + const struct attribute_group *attr_groups[4];
Following from above, I'd rather this was organized as static
attributes with an is_visible() helper for the groups for any dynamic
aspects. That mirrors the behavior of nvdimm_create() and allows for
device drivers to compose the attribute groups from a core set and /
or a provider specific set.
> + int cpu;
> + struct hlist_node node;
> + enum cpuhp_state cpuhp_state;
> +
> + /* cpumask provided by arch/platform specific code */
> + struct cpumask arch_cpumask;
> +};
> +
> struct nd_device_driver {
> struct device_driver drv;
> unsigned long type;
> --
> 2.26.2
>
^ permalink raw reply
* RE: [PATCH v3] ftrace: Cleanup ftrace_dyn_arch_init()
From: LEROY Christophe @ 2021-09-07 15:55 UTC (permalink / raw)
To: Weizhao Ouyang, Steven Rostedt, Ingo Molnar
Cc: Rich Felker, linux-ia64@vger.kernel.org, linux-sh@vger.kernel.org,
Catalin Marinas, linux-kernel@vger.kernel.org,
James E.J. Bottomley, Guo Ren, H. Peter Anvin,
sparclinux@vger.kernel.org, linux-riscv@lists.infradead.org,
Vincent Chen, Will Deacon, linux-s390@vger.kernel.org,
Yoshinori Sato, Helge Deller, x86@kernel.org, Russell King,
linux-csky@vger.kernel.org, Christian Borntraeger, Albert Ou,
Vasily Gorbik, Heiko Carstens, Borislav Petkov, Greentime Hu,
Paul Walmsley, Thomas Gleixner,
linux-arm-kernel@lists.infradead.org, Michal Simek,
Thomas Bogendoerfer, Nick Hu, linux-parisc@vger.kernel.org,
linux-mips@vger.kernel.org, Palmer Dabbelt, Paul Mackerras,
linuxppc-dev@lists.ozlabs.org, David S. Miller
In-Reply-To: <20210907100524.1454928-1-o451686892@gmail.com>
> -----Message d'origine-----
> De : Linuxppc-dev <linuxppc-dev-
> bounces+christophe.leroy=csgroup.eu@lists.ozlabs.org> De la part de Weizhao
> Ouyang
>
> Most of ARCHs use empty ftrace_dyn_arch_init(), introduce a weak common
> ftrace_dyn_arch_init() to cleanup them.
>
> Signed-off-by: Weizhao Ouyang <o451686892@gmail.com>
> Acked-by: Heiko Carstens <hca@linux.ibm.com> (s390)
> Acked-by: Helge Deller <deller@gmx.de> (parisc)
>
> ---
> Changes in v3:
> -- fix unrecognized opcode on PowerPC
>
> Changes in v2:
> -- correct CONFIG_DYNAMIC_FTRACE on PowerPC
> -- add Acked-by tag
>
> ---
> arch/arm/kernel/ftrace.c | 5 -----
> arch/arm64/kernel/ftrace.c | 5 -----
> arch/csky/kernel/ftrace.c | 5 -----
> arch/ia64/kernel/ftrace.c | 6 ------
> arch/microblaze/kernel/ftrace.c | 5 -----
> arch/mips/include/asm/ftrace.h | 2 ++
> arch/nds32/kernel/ftrace.c | 5 -----
> arch/parisc/kernel/ftrace.c | 5 -----
> arch/powerpc/include/asm/ftrace.h | 4 ++++
> arch/riscv/kernel/ftrace.c | 5 -----
> arch/s390/kernel/ftrace.c | 5 -----
> arch/sh/kernel/ftrace.c | 5 -----
> arch/sparc/kernel/ftrace.c | 5 -----
> arch/x86/kernel/ftrace.c | 5 -----
> include/linux/ftrace.h | 1 -
> kernel/trace/ftrace.c | 5 +++++
> 16 files changed, 11 insertions(+), 62 deletions(-)
>
> diff --git a/arch/mips/include/asm/ftrace.h b/arch/mips/include/asm/ftrace.h
> index b463f2aa5a61..ed013e767390 100644
> --- a/arch/mips/include/asm/ftrace.h
> +++ b/arch/mips/include/asm/ftrace.h
> @@ -76,6 +76,8 @@ do { \
>
>
> #ifdef CONFIG_DYNAMIC_FTRACE
> +int __init ftrace_dyn_arch_init(void);
> +
Why ?
> static inline unsigned long ftrace_call_adjust(unsigned long addr)
> {
> return addr;
> diff --git a/arch/powerpc/include/asm/ftrace.h
> b/arch/powerpc/include/asm/ftrace.h
> index debe8c4f7062..b05c43f13a4d 100644
> --- a/arch/powerpc/include/asm/ftrace.h
> +++ b/arch/powerpc/include/asm/ftrace.h
> @@ -126,6 +126,10 @@ static inline void this_cpu_enable_ftrace(void) { }
> static inline void this_cpu_set_ftrace_enabled(u8 ftrace_enabled) { }
> static inline u8 this_cpu_get_ftrace_enabled(void) { return 1; }
> #endif /* CONFIG_PPC64 */
> +
> +#ifdef CONFIG_DYNAMIC_FTRACE
> +int __init ftrace_dyn_arch_init(void);
> +#endif /* CONFIG_DYNAMIC_FTRACE */
Why ?
> #endif /* !__ASSEMBLY__ */
>
> #endif /* _ASM_POWERPC_FTRACE */
> diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
> index 832e65f06754..f1eca123d89d 100644
> --- a/include/linux/ftrace.h
> +++ b/include/linux/ftrace.h
> @@ -573,7 +573,6 @@ ftrace_set_early_filter(struct ftrace_ops *ops, char
> *buf, int enable);
>
> /* defined in arch */
> extern int ftrace_ip_converted(unsigned long ip);
> -extern int ftrace_dyn_arch_init(void);
Why removing that ?
Have you tried to build kernel/trace/ftrace.o with C=2 ? It will likely tell you that the function is not declared and that it should be static
We could eventually consider that in the past, this generic declaration was unrelevant because the definitions where in the arch specific sections.
Now that you are implementing a generic weak version of this function, it would make sense to have a generic declaration as well.
I really don't see the point in duplicating the declaration of the function in the arch specific headers.
> extern void ftrace_replace_code(int enable);
> extern int ftrace_update_ftrace_func(ftrace_func_t func);
> extern void ftrace_caller(void);
Christophe
CS Group - Document Interne
^ permalink raw reply
* Re: [PATCH 1/5] KVM: rseq: Update rseq when processing NOTIFY_RESUME on xfer to KVM guest
From: Sean Christopherson @ 2021-09-07 14:38 UTC (permalink / raw)
To: Paolo Bonzini
Cc: KVM list, Peter Zijlstra, linux-kernel, Will Deacon, Guo Ren,
linux-kselftest, Ben Gardon, shuah, linux-s390, Shakeel Butt, gor,
Russell King, ARM Linux, linux-csky, Christian Borntraeger,
Ingo Molnar, Catalin Marinas, linux-mips, Boqun Feng, paulmck,
Heiko Carstens, rostedt, Mathieu Desnoyers, Andy Lutomirski,
Thomas Gleixner, Peter Foley, linux-arm-kernel,
Thomas Bogendoerfer, Oleg Nesterov, Paul Mackerras, linuxppc-dev
In-Reply-To: <425456d3-4772-2a1b-9cf3-a5b750b95c2e@redhat.com>
On Mon, Sep 06, 2021, Paolo Bonzini wrote:
> On 20/08/21 20:51, Mathieu Desnoyers wrote:
> > > Ah, or is it the case that rseq_cs is non-NULL if and only if userspace is in an
> > > rseq critical section, and because syscalls in critical sections are illegal, by
> > > definition clearing rseq_cs is a nop unless userspace is misbehaving.
> > Not quite, as I described above. But we want it to stay set so the CONFIG_DEBUG_RSEQ
> > code executed when returning from ioctl to userspace will be able to validate that
> > it is not nested within a rseq critical section.
> >
> > > If that's true, what about explicitly checking that at NOTIFY_RESUME? Or is it
> > > not worth the extra code to detect an error that will likely be caught anyways?
> > The error will indeed already be caught on return from ioctl to userspace, so I
> > don't see any added value in duplicating this check.
>
> Sean, can you send a v2 (even for this patch only would be okay)?
Made it all the way to v3 while you were out :-)
https://lkml.kernel.org/r/20210901203030.1292304-1-seanjc@google.com
^ permalink raw reply
* Re: [PATCH] powerpc/mce: Fix access error in mce handler
From: Ganesh @ 2021-09-07 8:11 UTC (permalink / raw)
To: Michael Ellerman, linuxppc-dev; +Cc: mahesh, npiggin
In-Reply-To: <87y289natb.fsf@mpe.ellerman.id.au>
[-- Attachment #1: Type: text/plain, Size: 4846 bytes --]
On 9/6/21 6:03 PM, Michael Ellerman wrote:
> Ganesh Goudar <ganeshgr@linux.ibm.com> writes:
>> We queue an irq work for deferred processing of mce event
>> in realmode mce handler, where translation is disabled.
>> Queuing of the work may result in accessing memory outside
>> RMO region, such access needs the translation to be enabled
>> for an LPAR running with hash mmu else the kernel crashes.
>>
>> So enable the translation before queuing the work.
>>
>> Without this change following trace is seen on injecting machine
>> check error in an LPAR running with hash mmu.
> What type of error are you injecting?
SLB multihit in kernel mode.
>
>> Oops: Kernel access of bad area, sig: 11 [#1]
>> LE PAGE_SIZE=64K MMU=Hash SMP NR_CPUS=2048 NUMA pSeries
>> CPU: 5 PID: 1883 Comm: insmod Tainted: G OE 5.14.0-mce+ #137
>> NIP: c000000000735d60 LR: c000000000318640 CTR: 0000000000000000
>> REGS: c00000001ebff9a0 TRAP: 0300 Tainted: G OE (5.14.0-mce+)
>> MSR: 8000000000001003 <SF,ME,RI,LE> CR: 28008228 XER: 00000001
>> CFAR: c00000000031863c DAR: c00000027fa8fe08 DSISR: 40000000 IRQMASK: 0
>> GPR00: c0000000003186d0 c00000001ebffc40 c000000001b0df00 c0000000016337e8
>> GPR04: c0000000016337e8 c00000027fa8fe08 0000000000000023 c0000000016337f0
>> GPR08: 0000000000000023 c0000000012ffe08 0000000000000000 c008000001460240
>> GPR12: 0000000000000000 c00000001ec9a900 c00000002ac4bd00 0000000000000000
>> GPR16: 00000000000005a0 c0080000006b0000 c0080000006b05a0 c000000000ff3068
>> GPR20: c00000002ac4bbc0 0000000000000001 c00000002ac4bbc0 c008000001490298
>> GPR24: c008000001490108 c000000001636198 c008000001470090 c008000001470058
>> GPR28: 0000000000000510 c008000001000000 c008000008000019 0000000000000019
>> NIP [c000000000735d60] llist_add_batch+0x0/0x40
>> LR [c000000000318640] __irq_work_queue_local+0x70/0xc0
>> Call Trace:
>> [c00000001ebffc40] [c00000001ebffc0c] 0xc00000001ebffc0c (unreliable)
>> [c00000001ebffc60] [c0000000003186d0] irq_work_queue+0x40/0x70
>> [c00000001ebffc80] [c00000000004425c] machine_check_queue_event+0xbc/0xd0
>> [c00000001ebffcf0] [c00000000000838c] machine_check_early_common+0x16c/0x1f4
>>
>> Fixes: 74c3354bc1d89 ("powerpc/pseries/mce: restore msr before returning from handler")
> Please explain in more detail why that commit caused this breakage.
After enabling translation in mce_handle_error() we used to leave it enabled to avoid
crashing here, but now with this commit we are restoring the MSR to disable translation.
Missed to mention it in commit log, I will add it.
>
>> diff --git a/arch/powerpc/kernel/mce.c b/arch/powerpc/kernel/mce.c
>> index 47a683cd00d2..9d1e39d42e3e 100644
>> --- a/arch/powerpc/kernel/mce.c
>> +++ b/arch/powerpc/kernel/mce.c
>> @@ -249,6 +249,7 @@ void machine_check_queue_event(void)
>> {
>> int index;
>> struct machine_check_event evt;
>> + unsigned long msr;
>>
>> if (!get_mce_event(&evt, MCE_EVENT_RELEASE))
>> return;
>> @@ -262,8 +263,19 @@ void machine_check_queue_event(void)
>> memcpy(&local_paca->mce_info->mce_event_queue[index],
>> &evt, sizeof(evt));
>>
>> - /* Queue irq work to process this event later. */
>> - irq_work_queue(&mce_event_process_work);
>> + /* Queue irq work to process this event later. Before
>> + * queuing the work enable translation for non radix LPAR,
>> + * as irq_work_queue may try to access memory outside RMO
>> + * region.
>> + */
>> + if (!radix_enabled() && firmware_has_feature(FW_FEATURE_LPAR)) {
>> + msr = mfmsr();
>> + mtmsr(msr | MSR_IR | MSR_DR);
>> + irq_work_queue(&mce_event_process_work);
>> + mtmsr(msr);
>> + } else {
>> + irq_work_queue(&mce_event_process_work);
>> + }
>> }
> We already went to virtual mode and queued (different) irq work in
> arch/powerpc/platforms/pseries/ras.c:mce_handle_error()
>
> We also called save_mce_event() which also might have queued irq work,
> via machine_check_ue_event().
>
> So it really feels like something about the design is wrong if we have
> to go to virtual mode again and queue more irq work here.
>
> I guess we can probably merge this as a backportable fix, doing anything
> else would be a bigger change.
I agree.
>
> Looking at ras.c there's the comment:
>
> * Enable translation as we will be accessing per-cpu variables
> * in save_mce_event() which may fall outside RMO region, also
>
> But AFAICS it's only irq_work_queue() that touches anything percpu?
Yeah, we left the comment unchanged after doing some modifications around it,
It needs to be updated, ill send a separate patch for it.
>
> So maybe we should just not be using irq_work_queue(). It's a pretty
> thin wrapper around set_dec(1), perhaps we just need to hand-roll some
> real-mode friendly way of doing that.
You mean, have separate queue and run the work from timer handler?
>
> cheers
[-- Attachment #2: Type: text/html, Size: 6284 bytes --]
^ permalink raw reply
* Re: [PATCH 0/5] s390/pci: automatic error recovery
From: Niklas Schnelle @ 2021-09-07 12:21 UTC (permalink / raw)
To: Oliver O'Halloran
Cc: linux-s390, Pierre Morel, Matthew Rosato,
Linux Kernel Mailing List, Bjorn Helgaas, Linas Vepstas,
linuxppc-dev
In-Reply-To: <e739c2919f97e277849a1bc1324a20df6a7d59eb.camel@linux.ibm.com>
On Tue, 2021-09-07 at 10:45 +0200, Niklas Schnelle wrote:
> On Tue, 2021-09-07 at 12:04 +1000, Oliver O'Halloran wrote:
> > On Mon, Sep 6, 2021 at 7:49 PM Niklas Schnelle <schnelle@linux.ibm.com> wrote:
> > > Patch 3 I already sent separately resulting in the discussion below but without
> > > a final conclusion.
> > >
> > > https://lore.kernel.org/lkml/20210720150145.640727-1-schnelle@linux.ibm.com/
> > >
> > > I believe even though there were some doubts about the use of
> > > pci_dev_is_added() by arch code the existing uses as well as the use in the
> > > final patch of this series warrant this export.
> >
> > The use of pci_dev_is_added() in arch/powerpc was because in the past
> > pci_bus_add_device() could be called before pci_device_add(). That was
> > fixed a while ago so It should be safe to remove those calls now.
>
> Hmm, ok that confirms Bjorns suspicion and explains how it came to be.
> I can certainly sent a patch for that. This would then leave only the
> existing use in s390 which I added because of a dead lock prevention
> and explained here:
> https://lore.kernel.org/lkml/87d15d5eead35c9eaa667958d057cf4a81a8bf13.camel@linux.ibm.com/
>
> Plus the need to use it in the recovery code of this series. I think in
> the EEH code the need for a similar check is alleviated by the checks
> in the beginning of
> arch/powerpc/kernel/eeh_driver.c:eeh_handle_normal_event() especially
> eeh_slot_presence_check() which checks presence via the hotplug slot.
> I guess we could use our own state tracking in a similar way but felt
> like pci_dev_is_added() is the more logical choice.
Looking into this again, I think we actually can't easily track this
state ourselves outside struct pci_dev. The reason for this is that
when e.g. arch/s390/pci/pci_sysfs.c:recover_store() removes the struct
pci_dev and scans it again the new struct pci_dev re-uses the same
struct zpci_dev because from a platform point of view the PCI device
was never removed but only disabled and re-enabled. Thus we can only
distinguish the stale struct pci_dev by looking at things stored in
struct pci_dev itself.
That said, I think for the recovery case we might be able to drop the
pci_dev_is_added() and rely on pdev->driver != NULL which we check
anyway and that should catch any PCI device that was already removed.
^ permalink raw reply
* Re: [PATCH] pci/hotplug/pnv-php: Remove probable double put
From: Bjorn Helgaas @ 2021-09-07 11:24 UTC (permalink / raw)
To: Xu Wang; +Cc: linux-kernel, paulus, linux-pci, bhelgaas, linuxppc-dev
In-Reply-To: <20210907085946.21694-1-vulab@iscas.ac.cn>
Make your subject line follow the previous convention.
Figure out if this is a "probable" or a real double put. If it's a
real double put, we should fix it. If it's only "probable," that
means we don't understand the problem yet.
On Tue, Sep 07, 2021 at 08:59:46AM +0000, Xu Wang wrote:
> Device node iterators put the previous value of the index variable,
> so an explicit put causes a double put.
>
> Signed-off-by: Xu Wang <vulab@iscas.ac.cn>
> ---
> drivers/pci/hotplug/pnv_php.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/drivers/pci/hotplug/pnv_php.c b/drivers/pci/hotplug/pnv_php.c
> index 04565162a449..ed4d1a2c3f22 100644
> --- a/drivers/pci/hotplug/pnv_php.c
> +++ b/drivers/pci/hotplug/pnv_php.c
> @@ -158,7 +158,6 @@ static void pnv_php_detach_device_nodes(struct device_node *parent)
> for_each_child_of_node(parent, dn) {
> pnv_php_detach_device_nodes(dn);
>
> - of_node_put(dn);
> of_detach_node(dn);
> }
> }
> --
> 2.17.1
>
^ permalink raw reply
* [PATCH 3/9] xen/x86: make "earlyprintk=xen" work better for PVH Dom0
From: Jan Beulich @ 2021-09-07 10:09 UTC (permalink / raw)
To: Juergen Gross, Boris Ostrovsky
Cc: xen-devel@lists.xenproject.org, Stefano Stabellini,
linuxppc-dev@lists.ozlabs.org, lkml
In-Reply-To: <4efa804e-3250-227f-00c7-347581366cd4@suse.com>
The xen_hvm_early_write() path better wouldn't be taken in this case;
while port 0xE9 can be used, the hypercall path is quite a bit more
efficient. Put that first, as it may also work for DomU-s (see also
xen_raw_console_write()).
While there also bail from the function when the first
domU_write_console() failed - later ones aren't going to succeed.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/drivers/tty/hvc/hvc_xen.c
+++ b/drivers/tty/hvc/hvc_xen.c
@@ -632,17 +632,16 @@ static void xenboot_write_console(struct
unsigned int linelen, off = 0;
const char *pos;
+ if (dom0_write_console(0, string, len) >= 0)
+ return;
+
if (!xen_pv_domain()) {
xen_hvm_early_write(0, string, len);
return;
}
- dom0_write_console(0, string, len);
-
- if (xen_initial_domain())
+ if (domU_write_console(0, "(early) ", 8) < 0)
return;
-
- domU_write_console(0, "(early) ", 8);
while (off < len && NULL != (pos = strchr(string+off, '\n'))) {
linelen = pos-string+off;
if (off + linelen > len)
^ permalink raw reply
* [PATCH 5/9] xen/x86: make "earlyprintk=xen" work for HVM/PVH DomU
From: Jan Beulich @ 2021-09-07 10:10 UTC (permalink / raw)
To: Juergen Gross, Boris Ostrovsky
Cc: xen-devel@lists.xenproject.org, Stefano Stabellini,
linuxppc-dev@lists.ozlabs.org, lkml
In-Reply-To: <4efa804e-3250-227f-00c7-347581366cd4@suse.com>
xenboot_write_console() is dealing with these quite fine so I don't see
why xenboot_console_setup() would return -ENOENT in this case.
Adjust documentation accordingly.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -1266,7 +1266,7 @@
The VGA and EFI output is eventually overwritten by
the real console.
- The xen output can only be used by Xen PV guests.
+ The xen option can only be used in Xen domains.
The sclp output can only be used on s390.
--- a/drivers/tty/hvc/hvc_xen.c
+++ b/drivers/tty/hvc/hvc_xen.c
@@ -618,10 +618,8 @@ static int __init xenboot_console_setup(
{
static struct xencons_info xenboot;
- if (xen_initial_domain())
+ if (xen_initial_domain() || !xen_pv_domain())
return 0;
- if (!xen_pv_domain())
- return -ENODEV;
return xencons_info_pv_init(&xenboot, 0);
}
^ permalink raw reply
* [PATCH v3] ftrace: Cleanup ftrace_dyn_arch_init()
From: Weizhao Ouyang @ 2021-09-07 10:05 UTC (permalink / raw)
To: Steven Rostedt, Ingo Molnar
Cc: Rich Felker, linux-ia64, linux-sh, linux-mips,
James E.J. Bottomley, Guo Ren, H. Peter Anvin, sparclinux,
linux-riscv, Vincent Chen, Will Deacon, linux-s390,
Yoshinori Sato, Helge Deller, x86, Russell King, linux-csky,
Christian Borntraeger, Catalin Marinas, Albert Ou, Weizhao Ouyang,
Vasily Gorbik, Heiko Carstens, Borislav Petkov, Greentime Hu,
Paul Walmsley, Thomas Gleixner, linux-arm-kernel, Michal Simek,
Thomas Bogendoerfer, linux-parisc, Nick Hu, linux-kernel,
Palmer Dabbelt, Paul Mackerras, linuxppc-dev, David S. Miller
Most of ARCHs use empty ftrace_dyn_arch_init(), introduce a weak common
ftrace_dyn_arch_init() to cleanup them.
Signed-off-by: Weizhao Ouyang <o451686892@gmail.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com> (s390)
Acked-by: Helge Deller <deller@gmx.de> (parisc)
---
Changes in v3:
-- fix unrecognized opcode on PowerPC
Changes in v2:
-- correct CONFIG_DYNAMIC_FTRACE on PowerPC
-- add Acked-by tag
---
arch/arm/kernel/ftrace.c | 5 -----
arch/arm64/kernel/ftrace.c | 5 -----
arch/csky/kernel/ftrace.c | 5 -----
arch/ia64/kernel/ftrace.c | 6 ------
arch/microblaze/kernel/ftrace.c | 5 -----
arch/mips/include/asm/ftrace.h | 2 ++
arch/nds32/kernel/ftrace.c | 5 -----
arch/parisc/kernel/ftrace.c | 5 -----
arch/powerpc/include/asm/ftrace.h | 4 ++++
arch/riscv/kernel/ftrace.c | 5 -----
arch/s390/kernel/ftrace.c | 5 -----
arch/sh/kernel/ftrace.c | 5 -----
arch/sparc/kernel/ftrace.c | 5 -----
arch/x86/kernel/ftrace.c | 5 -----
include/linux/ftrace.h | 1 -
kernel/trace/ftrace.c | 5 +++++
16 files changed, 11 insertions(+), 62 deletions(-)
diff --git a/arch/arm/kernel/ftrace.c b/arch/arm/kernel/ftrace.c
index 3c83b5d29697..a006585e1c09 100644
--- a/arch/arm/kernel/ftrace.c
+++ b/arch/arm/kernel/ftrace.c
@@ -193,11 +193,6 @@ int ftrace_make_nop(struct module *mod,
return ret;
}
-
-int __init ftrace_dyn_arch_init(void)
-{
- return 0;
-}
#endif /* CONFIG_DYNAMIC_FTRACE */
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
diff --git a/arch/arm64/kernel/ftrace.c b/arch/arm64/kernel/ftrace.c
index 7f467bd9db7a..fc62dfe73f93 100644
--- a/arch/arm64/kernel/ftrace.c
+++ b/arch/arm64/kernel/ftrace.c
@@ -236,11 +236,6 @@ void arch_ftrace_update_code(int command)
command |= FTRACE_MAY_SLEEP;
ftrace_modify_all_code(command);
}
-
-int __init ftrace_dyn_arch_init(void)
-{
- return 0;
-}
#endif /* CONFIG_DYNAMIC_FTRACE */
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
diff --git a/arch/csky/kernel/ftrace.c b/arch/csky/kernel/ftrace.c
index b4a7ec1517ff..50bfcf129078 100644
--- a/arch/csky/kernel/ftrace.c
+++ b/arch/csky/kernel/ftrace.c
@@ -133,11 +133,6 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
(unsigned long)func, true, true);
return ret;
}
-
-int __init ftrace_dyn_arch_init(void)
-{
- return 0;
-}
#endif /* CONFIG_DYNAMIC_FTRACE */
#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
diff --git a/arch/ia64/kernel/ftrace.c b/arch/ia64/kernel/ftrace.c
index b2ab2d58fb30..d6360fd404ab 100644
--- a/arch/ia64/kernel/ftrace.c
+++ b/arch/ia64/kernel/ftrace.c
@@ -194,9 +194,3 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
flush_icache_range(addr, addr + 16);
return 0;
}
-
-/* run from kstop_machine */
-int __init ftrace_dyn_arch_init(void)
-{
- return 0;
-}
diff --git a/arch/microblaze/kernel/ftrace.c b/arch/microblaze/kernel/ftrace.c
index 224eea40e1ee..188749d62709 100644
--- a/arch/microblaze/kernel/ftrace.c
+++ b/arch/microblaze/kernel/ftrace.c
@@ -163,11 +163,6 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
return ret;
}
-int __init ftrace_dyn_arch_init(void)
-{
- return 0;
-}
-
int ftrace_update_ftrace_func(ftrace_func_t func)
{
unsigned long ip = (unsigned long)(&ftrace_call);
diff --git a/arch/mips/include/asm/ftrace.h b/arch/mips/include/asm/ftrace.h
index b463f2aa5a61..ed013e767390 100644
--- a/arch/mips/include/asm/ftrace.h
+++ b/arch/mips/include/asm/ftrace.h
@@ -76,6 +76,8 @@ do { \
#ifdef CONFIG_DYNAMIC_FTRACE
+int __init ftrace_dyn_arch_init(void);
+
static inline unsigned long ftrace_call_adjust(unsigned long addr)
{
return addr;
diff --git a/arch/nds32/kernel/ftrace.c b/arch/nds32/kernel/ftrace.c
index 0e23e3a8df6b..f0ef4842d191 100644
--- a/arch/nds32/kernel/ftrace.c
+++ b/arch/nds32/kernel/ftrace.c
@@ -84,11 +84,6 @@ void _ftrace_caller(unsigned long parent_ip)
/* restore all state needed by the compiler epilogue */
}
-int __init ftrace_dyn_arch_init(void)
-{
- return 0;
-}
-
static unsigned long gen_sethi_insn(unsigned long addr)
{
unsigned long opcode = 0x46000000;
diff --git a/arch/parisc/kernel/ftrace.c b/arch/parisc/kernel/ftrace.c
index 0a1e75af5382..01581f715737 100644
--- a/arch/parisc/kernel/ftrace.c
+++ b/arch/parisc/kernel/ftrace.c
@@ -94,11 +94,6 @@ int ftrace_disable_ftrace_graph_caller(void)
#endif
#ifdef CONFIG_DYNAMIC_FTRACE
-
-int __init ftrace_dyn_arch_init(void)
-{
- return 0;
-}
int ftrace_update_ftrace_func(ftrace_func_t func)
{
return 0;
diff --git a/arch/powerpc/include/asm/ftrace.h b/arch/powerpc/include/asm/ftrace.h
index debe8c4f7062..b05c43f13a4d 100644
--- a/arch/powerpc/include/asm/ftrace.h
+++ b/arch/powerpc/include/asm/ftrace.h
@@ -126,6 +126,10 @@ static inline void this_cpu_enable_ftrace(void) { }
static inline void this_cpu_set_ftrace_enabled(u8 ftrace_enabled) { }
static inline u8 this_cpu_get_ftrace_enabled(void) { return 1; }
#endif /* CONFIG_PPC64 */
+
+#ifdef CONFIG_DYNAMIC_FTRACE
+int __init ftrace_dyn_arch_init(void);
+#endif /* CONFIG_DYNAMIC_FTRACE */
#endif /* !__ASSEMBLY__ */
#endif /* _ASM_POWERPC_FTRACE */
diff --git a/arch/riscv/kernel/ftrace.c b/arch/riscv/kernel/ftrace.c
index 7f1e5203de88..4716f4cdc038 100644
--- a/arch/riscv/kernel/ftrace.c
+++ b/arch/riscv/kernel/ftrace.c
@@ -154,11 +154,6 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
return ret;
}
-
-int __init ftrace_dyn_arch_init(void)
-{
- return 0;
-}
#endif
#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
diff --git a/arch/s390/kernel/ftrace.c b/arch/s390/kernel/ftrace.c
index 0a464d328467..3fd80397ff52 100644
--- a/arch/s390/kernel/ftrace.c
+++ b/arch/s390/kernel/ftrace.c
@@ -262,11 +262,6 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
return 0;
}
-int __init ftrace_dyn_arch_init(void)
-{
- return 0;
-}
-
void arch_ftrace_update_code(int command)
{
if (ftrace_shared_hotpatch_trampoline(NULL))
diff --git a/arch/sh/kernel/ftrace.c b/arch/sh/kernel/ftrace.c
index 295c43315bbe..930001bb8c6a 100644
--- a/arch/sh/kernel/ftrace.c
+++ b/arch/sh/kernel/ftrace.c
@@ -252,11 +252,6 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
return ftrace_modify_code(rec->ip, old, new);
}
-
-int __init ftrace_dyn_arch_init(void)
-{
- return 0;
-}
#endif /* CONFIG_DYNAMIC_FTRACE */
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
diff --git a/arch/sparc/kernel/ftrace.c b/arch/sparc/kernel/ftrace.c
index 684b84ce397f..eaead3da8e03 100644
--- a/arch/sparc/kernel/ftrace.c
+++ b/arch/sparc/kernel/ftrace.c
@@ -82,11 +82,6 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
new = ftrace_call_replace(ip, (unsigned long)func);
return ftrace_modify_code(ip, old, new);
}
-
-int __init ftrace_dyn_arch_init(void)
-{
- return 0;
-}
#endif
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
index 1b3ce3b4a2a2..23d221a9a3cd 100644
--- a/arch/x86/kernel/ftrace.c
+++ b/arch/x86/kernel/ftrace.c
@@ -252,11 +252,6 @@ void arch_ftrace_update_code(int command)
ftrace_modify_all_code(command);
}
-int __init ftrace_dyn_arch_init(void)
-{
- return 0;
-}
-
/* Currently only x86_64 supports dynamic trampolines */
#ifdef CONFIG_X86_64
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index 832e65f06754..f1eca123d89d 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -573,7 +573,6 @@ ftrace_set_early_filter(struct ftrace_ops *ops, char *buf, int enable);
/* defined in arch */
extern int ftrace_ip_converted(unsigned long ip);
-extern int ftrace_dyn_arch_init(void);
extern void ftrace_replace_code(int enable);
extern int ftrace_update_ftrace_func(ftrace_func_t func);
extern void ftrace_caller(void);
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 7efbc8aaf7f6..4c090323198d 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -6846,6 +6846,11 @@ void __init ftrace_free_init_mem(void)
ftrace_free_mem(NULL, start, end);
}
+int __init __weak ftrace_dyn_arch_init(void)
+{
+ return 0;
+}
+
void __init ftrace_init(void)
{
extern unsigned long __start_mcount_loc[];
--
2.30.2
^ permalink raw reply related
* [PATCH] pci/hotplug/pnv-php: Remove probable double put
From: Xu Wang @ 2021-09-07 8:59 UTC (permalink / raw)
To: mpe, benh, paulus, bhelgaas; +Cc: linux-pci, linuxppc-dev, linux-kernel
Device node iterators put the previous value of the index variable,
so an explicit put causes a double put.
Signed-off-by: Xu Wang <vulab@iscas.ac.cn>
---
drivers/pci/hotplug/pnv_php.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/pci/hotplug/pnv_php.c b/drivers/pci/hotplug/pnv_php.c
index 04565162a449..ed4d1a2c3f22 100644
--- a/drivers/pci/hotplug/pnv_php.c
+++ b/drivers/pci/hotplug/pnv_php.c
@@ -158,7 +158,6 @@ static void pnv_php_detach_device_nodes(struct device_node *parent)
for_each_child_of_node(parent, dn) {
pnv_php_detach_device_nodes(dn);
- of_node_put(dn);
of_detach_node(dn);
}
}
--
2.17.1
^ permalink raw reply related
* Re: [PATCH 0/5] s390/pci: automatic error recovery
From: Niklas Schnelle @ 2021-09-07 8:45 UTC (permalink / raw)
To: Oliver O'Halloran
Cc: linux-s390, Pierre Morel, Matthew Rosato,
Linux Kernel Mailing List, Bjorn Helgaas, Linas Vepstas,
linuxppc-dev
In-Reply-To: <CAOSf1CFyuf9FaeSNparj+7W0mKTPvtcM8vxjHDSFsNDC6k_7xQ@mail.gmail.com>
On Tue, 2021-09-07 at 12:04 +1000, Oliver O'Halloran wrote:
> On Mon, Sep 6, 2021 at 7:49 PM Niklas Schnelle <schnelle@linux.ibm.com> wrote:
> > Patch 3 I already sent separately resulting in the discussion below but without
> > a final conclusion.
> >
> > https://lore.kernel.org/lkml/20210720150145.640727-1-schnelle@linux.ibm.com/
> >
> > I believe even though there were some doubts about the use of
> > pci_dev_is_added() by arch code the existing uses as well as the use in the
> > final patch of this series warrant this export.
>
> The use of pci_dev_is_added() in arch/powerpc was because in the past
> pci_bus_add_device() could be called before pci_device_add(). That was
> fixed a while ago so It should be safe to remove those calls now.
Hmm, ok that confirms Bjorns suspicion and explains how it came to be.
I can certainly sent a patch for that. This would then leave only the
existing use in s390 which I added because of a dead lock prevention
and explained here:
https://lore.kernel.org/lkml/87d15d5eead35c9eaa667958d057cf4a81a8bf13.camel@linux.ibm.com/
Plus the need to use it in the recovery code of this series. I think in
the EEH code the need for a similar check is alleviated by the checks
in the beginning of
arch/powerpc/kernel/eeh_driver.c:eeh_handle_normal_event() especially
eeh_slot_presence_check() which checks presence via the hotplug slot.
I guess we could use our own state tracking in a similar way but felt
like pci_dev_is_added() is the more logical choice.
>
> > Patch 4 "PCI: Export pci_dev_lock()" is basically an extension to commit
> > e3a9b1212b9d ("PCI: Export pci_dev_trylock() and pci_dev_unlock()") which
> > already exported pci_dev_trylock(). In the final patch we make use of
> > pci_dev_lock() to wait for any other exclusive uses of the pdev to be finished
> > before starting recovery.
>
> Hmm, I noticed the EEH
> (arch/powerpc/kernel/eeh_driver.c:eeh_pe_report_edev()) and the
> generic PCIe error recovery code (see
> drivers/pci/pcie/err.c:report_error_detected()) only call
> device_lock() before entering the driver's error handling callbacks. I
> wonder if they should be using pci_dev_lock() instead. The only real
> difference is that pci_dev_lock() will also block user space from
> accessing the device's config space while error recovery is in
> progress which seems sensible enough.
I agree that sounds reasonable.
^ permalink raw reply
* Re: [PATCH 3/5] PCI: Move pci_dev_is/assign_added() to pci.h
From: Niklas Schnelle @ 2021-09-07 8:14 UTC (permalink / raw)
To: Andy Shevchenko, kernel test robot
Cc: linux-s390, kbuild-all, Pierre Morel, Matthew Rosato,
Linux Kernel Mailing List, Bjorn Helgaas, Oliver O'Halloran,
Linas Vepstas, open list:LINUX FOR POWERPC PA SEMI PWRFICIENT
In-Reply-To: <CAHp75VeiWH0MoAchctDES7zLk4Q9NwODu=O2y-NYOsu3SBeimg@mail.gmail.com>
On Tue, 2021-09-07 at 10:51 +0300, Andy Shevchenko wrote:
> On Tue, Sep 7, 2021 at 3:26 AM kernel test robot <lkp@intel.com> wrote:
> > Hi Niklas,
> >
> > I love your patch! Yet something to improve:
> >
> > [auto build test ERROR on s390/features]
> > [also build test ERROR on next-20210906]
> > [cannot apply to pci/next powerpc/next v5.14]
> > [If your patch is applied to the wrong git tree, kindly drop us a note.
> > And when submitting patch, we suggest to use '--base' as documented in
> > https://git-scm.com/docs/git-format-patch]
> >
> > url: https://github.com/0day-ci/linux/commits/Niklas-Schnelle/s390-pci-automatic-error-recovery/20210906-175309
> > base: https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git features
> > config: i386-allyesconfig (attached as .config)
> > compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
> > reproduce (this is a W=1 build):
> > # https://github.com/0day-ci/linux/commit/404ed8c00a612e7ae31c50557c80c6726c464863
> > git remote add linux-review https://github.com/0day-ci/linux
> > git fetch --no-tags linux-review Niklas-Schnelle/s390-pci-automatic-error-recovery/20210906-175309
> > git checkout 404ed8c00a612e7ae31c50557c80c6726c464863
> > # save the attached .config to linux build tree
> > make W=1 ARCH=i386
> >
> > If you fix the issue, kindly add following tag as appropriate
> > Reported-by: kernel test robot <lkp@intel.com>
> >
> > All errors (new ones prefixed by >>):
>
> Obviously drivers/pci/pci.h is not only for the above.
>
> When play with headers always do two test builds: allyesconfig and allmodconfig.
You're right and additionally have to built on some other architectures
as well because allyesconfig and allmodconfig both run through fine on
s390.
I'll look into it but at first glance it looks like I was over reaching
removing the include from drivers/pci/hotplug/acpiphp_glue.c in
addition it's not even the same kind of awkward relative include from
drivers into arch code. Sorry about that.
>
^ permalink raw reply
* Re: [PATCH 3/5] PCI: Move pci_dev_is/assign_added() to pci.h
From: Andy Shevchenko @ 2021-09-07 7:51 UTC (permalink / raw)
To: kernel test robot
Cc: linux-s390, kbuild-all, Pierre Morel, Matthew Rosato,
Niklas Schnelle, Linux Kernel Mailing List, Bjorn Helgaas,
Oliver O'Halloran, Linas Vepstas,
open list:LINUX FOR POWERPC PA SEMI PWRFICIENT
In-Reply-To: <202109070818.aHlo0OT9-lkp@intel.com>
On Tue, Sep 7, 2021 at 3:26 AM kernel test robot <lkp@intel.com> wrote:
>
> Hi Niklas,
>
> I love your patch! Yet something to improve:
>
> [auto build test ERROR on s390/features]
> [also build test ERROR on next-20210906]
> [cannot apply to pci/next powerpc/next v5.14]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch]
>
> url: https://github.com/0day-ci/linux/commits/Niklas-Schnelle/s390-pci-automatic-error-recovery/20210906-175309
> base: https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git features
> config: i386-allyesconfig (attached as .config)
> compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
> reproduce (this is a W=1 build):
> # https://github.com/0day-ci/linux/commit/404ed8c00a612e7ae31c50557c80c6726c464863
> git remote add linux-review https://github.com/0day-ci/linux
> git fetch --no-tags linux-review Niklas-Schnelle/s390-pci-automatic-error-recovery/20210906-175309
> git checkout 404ed8c00a612e7ae31c50557c80c6726c464863
> # save the attached .config to linux build tree
> make W=1 ARCH=i386
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
> All errors (new ones prefixed by >>):
Obviously drivers/pci/pci.h is not only for the above.
When play with headers always do two test builds: allyesconfig and allmodconfig.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply
* Re: [PATCH 0/5] s390/pci: automatic error recovery
From: Niklas Schnelle @ 2021-09-07 7:49 UTC (permalink / raw)
To: linasvepstas
Cc: linux-s390, Pierre Morel, Matthew Rosato,
linux-kernel@vger.kernel.org, Oliver O'Halloran,
Bjorn Helgaas, linuxppc-dev
In-Reply-To: <CAHrUA34TK6U4TB34FHejott9TdFvSgAedOpmro-Uj2ZwnvzecQ@mail.gmail.com>
On Mon, 2021-09-06 at 21:05 -0500, Linas Vepstas wrote:
> On Mon, Sep 6, 2021 at 4:49 AM Niklas Schnelle <schnelle@linux.ibm.com>
> wrote:
>
> > I believe we might be the first
> > implementation of PCI device recovery in a virtualized setting requiring
> > us to
> > coordinate the device reset with the hypervisor platform by issuing a
> > disable
> > and re-enable to the platform as well as starting the recovery following
> > a platform event.
> >
>
> I recall none of the details, but SRIOV is a standardized system for
> sharing a PCI device across multiple virtual machines. It has detailed info
> on what the hypervisor must do, and what the local OS instance must do to
> accomplish this.
Yes and in fact on s390 we make heavy use of SR-IOV.
> It's part of the PCI standard, and its more than a decade
> old now, maybe two. Being a part of the PCI standard, it was interoperable
> with error recovery, to the best of my recollection.
Maybe I worded things with a bit too much sensationalism and it might
even be that POWER supports error recovery also with virtualization,
though I'm not sure how far that goes.
I believe you are right in that SR-IOV supports the error recovery,
after all this patch set also has to work together with SRIOV enabled
devices. At least on s390 though until this patch set the error
recovery performed by the hypervisor stopped in the hypervisor.
The missing part added by this patch set is coordinating with device
drivers in Linux to determine where use of a recovered device can pick
up after the PCIe level error recovery is done.
As for virtualization this coordination of course needs to cross the
hypervisor/guest boundary and at least for KVM+QEMU I know for a fact
that reporting a PCI error to the guest is currently just a stub that
actually completely stops the guest, so you definitely don't get smooth
error recovery there yet.
> At the time it was
> introduced, it got pushed very aggressively. The x86 hypervisor vendors
> were aiming at the heart of zseries, and were militant about it.
And yet we're still here, use SR-IOV ourselves and even support Linux +
KVM as a hypervisor you can use just the same on a mainframe, an x86,
POWER, or ARM system.
>
> -- Linas
>
^ permalink raw reply
* Re: [PATCH 0/5] s390/pci: automatic error recovery
From: Linas Vepstas @ 2021-09-07 2:05 UTC (permalink / raw)
To: Niklas Schnelle
Cc: linux-s390, Pierre Morel, Matthew Rosato,
linux-kernel@vger.kernel.org, Oliver O'Halloran,
Bjorn Helgaas, linuxppc-dev
In-Reply-To: <20210906094927.524106-1-schnelle@linux.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 1062 bytes --]
On Mon, Sep 6, 2021 at 4:49 AM Niklas Schnelle <schnelle@linux.ibm.com>
wrote:
> I believe we might be the first
> implementation of PCI device recovery in a virtualized setting requiring
> us to
> coordinate the device reset with the hypervisor platform by issuing a
> disable
> and re-enable to the platform as well as starting the recovery following
> a platform event.
>
I recall none of the details, but SRIOV is a standardized system for
sharing a PCI device across multiple virtual machines. It has detailed info
on what the hypervisor must do, and what the local OS instance must do to
accomplish this. It's part of the PCI standard, and its more than a decade
old now, maybe two. Being a part of the PCI standard, it was interoperable
with error recovery, to the best of my recollection. At the time it was
introduced, it got pushed very aggressively. The x86 hypervisor vendors
were aiming at the heart of zseries, and were militant about it.
-- Linas
--
Patrick: Are they laughing at us?
Sponge Bob: No, Patrick, they are laughing next to us.
[-- Attachment #2: Type: text/html, Size: 1607 bytes --]
^ permalink raw reply
* Re: [PATCH for-5.15 0/5] ASoC: fsl: register platform component before registering cpu dai
From: Shengjiu Wang @ 2021-09-07 2:43 UTC (permalink / raw)
To: Mark Brown
Cc: alsa-devel, Timur Tabi, Xiubo Li, Fabio Estevam, Shengjiu Wang,
Takashi Iwai, linux-kernel, Nicolin Chen, linuxppc-dev
In-Reply-To: <20210906114701.GC4309@sirena.org.uk>
Hi Mark
On Mon, Sep 6, 2021 at 7:48 PM Mark Brown <broonie@kernel.org> wrote:
>
> On Fri, Sep 03, 2021 at 06:30:01PM +0800, Shengjiu Wang wrote:
>
> > There is no defer probe when adding platform component to
> > snd_soc_pcm_runtime(rtd), the code is in snd_soc_add_pcm_runtime()
>
> ...
>
> > So if the platform component is not ready at that time, then the
> > sound card still registered successfully, but platform component
> > is empty, the sound card can't be used.
>
> This sounds like a bug which should be fixed there?
It is hard.
In cpu dai driver we always register two components, one is for
cpu dai, another is for platform, so for sound card platform and
cpu share the same node.
/* Find PLATFORM from registered PLATFORMs */
for_each_link_platforms(dai_link, i, platform) {
for_each_component(component) {
if (!snd_soc_is_matching_component(platform, component))
continue;
snd_soc_rtd_add_component(rtd, component);
}
}
Above code in snd_soc_add_pcm_runtime() checks components
for the platform, because there are two components for the node,
the first one is the component of cpu dai, which is added by
registering dai, it is already added in the beginning, so it is
duplicated, but the second one (which is for platform) is not ready,
then issue happens.
It is hard to add conditions here for defer probe. And maybe
some drivers need the same components for cpu and platform.
Do you have any suggestions?
(The easy way is to fix in each drivers:))
Best Regards
Wang Shengjiu
^ permalink raw reply
* Re: [PATCH 0/5] s390/pci: automatic error recovery
From: Oliver O'Halloran @ 2021-09-07 2:04 UTC (permalink / raw)
To: Niklas Schnelle
Cc: linux-s390, Pierre Morel, Matthew Rosato,
Linux Kernel Mailing List, Bjorn Helgaas, Linas Vepstas,
linuxppc-dev
In-Reply-To: <20210906094927.524106-1-schnelle@linux.ibm.com>
On Mon, Sep 6, 2021 at 7:49 PM Niklas Schnelle <schnelle@linux.ibm.com> wrote:
>
> Patch 3 I already sent separately resulting in the discussion below but without
> a final conclusion.
>
> https://lore.kernel.org/lkml/20210720150145.640727-1-schnelle@linux.ibm.com/
>
> I believe even though there were some doubts about the use of
> pci_dev_is_added() by arch code the existing uses as well as the use in the
> final patch of this series warrant this export.
The use of pci_dev_is_added() in arch/powerpc was because in the past
pci_bus_add_device() could be called before pci_device_add(). That was
fixed a while ago so It should be safe to remove those calls now.
> Patch 4 "PCI: Export pci_dev_lock()" is basically an extension to commit
> e3a9b1212b9d ("PCI: Export pci_dev_trylock() and pci_dev_unlock()") which
> already exported pci_dev_trylock(). In the final patch we make use of
> pci_dev_lock() to wait for any other exclusive uses of the pdev to be finished
> before starting recovery.
Hmm, I noticed the EEH
(arch/powerpc/kernel/eeh_driver.c:eeh_pe_report_edev()) and the
generic PCIe error recovery code (see
drivers/pci/pcie/err.c:report_error_detected()) only call
device_lock() before entering the driver's error handling callbacks. I
wonder if they should be using pci_dev_lock() instead. The only real
difference is that pci_dev_lock() will also block user space from
accessing the device's config space while error recovery is in
progress which seems sensible enough.
^ permalink raw reply
* Re: [PATCH 3/5] PCI: Move pci_dev_is/assign_added() to pci.h
From: kernel test robot @ 2021-09-07 0:25 UTC (permalink / raw)
To: Niklas Schnelle, Bjorn Helgaas
Cc: linux-s390, kbuild-all, Pierre Morel, Matthew Rosato,
linux-kernel, Oliver O'Halloran, Linas Vepstas, linuxppc-dev
In-Reply-To: <20210906094927.524106-4-schnelle@linux.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 27718 bytes --]
Hi Niklas,
I love your patch! Yet something to improve:
[auto build test ERROR on s390/features]
[also build test ERROR on next-20210906]
[cannot apply to pci/next powerpc/next v5.14]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Niklas-Schnelle/s390-pci-automatic-error-recovery/20210906-175309
base: https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git features
config: i386-allyesconfig (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
# https://github.com/0day-ci/linux/commit/404ed8c00a612e7ae31c50557c80c6726c464863
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Niklas-Schnelle/s390-pci-automatic-error-recovery/20210906-175309
git checkout 404ed8c00a612e7ae31c50557c80c6726c464863
# save the attached .config to linux build tree
make W=1 ARCH=i386
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
drivers/pci/hotplug/acpiphp_glue.c: In function 'acpiphp_add_context':
>> drivers/pci/hotplug/acpiphp_glue.c:330:6: error: implicit declaration of function 'pci_bus_read_dev_vendor_id' [-Werror=implicit-function-declaration]
330 | if (pci_bus_read_dev_vendor_id(pbus, PCI_DEVFN(device, function),
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/pci/hotplug/acpiphp_glue.c: In function 'enable_slot':
>> drivers/pci/hotplug/acpiphp_glue.c:505:6: error: implicit declaration of function '__pci_bus_size_bridges'; did you mean 'pci_bus_size_bridges'? [-Werror=implicit-function-declaration]
505 | __pci_bus_size_bridges(dev->subordinate,
| ^~~~~~~~~~~~~~~~~~~~~~
| pci_bus_size_bridges
>> drivers/pci/hotplug/acpiphp_glue.c:510:3: error: implicit declaration of function '__pci_bus_assign_resources'; did you mean 'pci_bus_assign_resources'? [-Werror=implicit-function-declaration]
510 | __pci_bus_assign_resources(bus, &add_list, NULL);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
| pci_bus_assign_resources
drivers/pci/hotplug/acpiphp_glue.c: In function 'trim_stale_devices':
>> drivers/pci/hotplug/acpiphp_glue.c:660:3: error: implicit declaration of function 'pci_dev_set_disconnected' [-Werror=implicit-function-declaration]
660 | pci_dev_set_disconnected(dev, NULL);
| ^~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/pci/hotplug/acpiphp_glue.c:661:7: error: implicit declaration of function 'pci_has_subordinate' [-Werror=implicit-function-declaration]
661 | if (pci_has_subordinate(dev))
| ^~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +/pci_bus_read_dev_vendor_id +330 drivers/pci/hotplug/acpiphp_glue.c
4e8662bbd680c5 Kristen Accardi 2006-06-28 217
3799c5a032aefb Rafael J. Wysocki 2014-02-16 218 /**
3799c5a032aefb Rafael J. Wysocki 2014-02-16 219 * acpiphp_add_context - Add ACPIPHP context to an ACPI device object.
3799c5a032aefb Rafael J. Wysocki 2014-02-16 220 * @handle: ACPI handle of the object to add a context to.
3799c5a032aefb Rafael J. Wysocki 2014-02-16 221 * @lvl: Not used.
3799c5a032aefb Rafael J. Wysocki 2014-02-16 222 * @data: The object's parent ACPIPHP bridge.
3799c5a032aefb Rafael J. Wysocki 2014-02-16 223 * @rv: Not used.
3799c5a032aefb Rafael J. Wysocki 2014-02-16 224 */
3799c5a032aefb Rafael J. Wysocki 2014-02-16 225 static acpi_status acpiphp_add_context(acpi_handle handle, u32 lvl, void *data,
cb7b8cedf6c88b Rafael J. Wysocki 2013-07-13 226 void **rv)
^1da177e4c3f41 Linus Torvalds 2005-04-16 227 {
cb7b8cedf6c88b Rafael J. Wysocki 2013-07-13 228 struct acpiphp_bridge *bridge = data;
cb7b8cedf6c88b Rafael J. Wysocki 2013-07-13 229 struct acpiphp_context *context;
bbcbfc0eed6220 Rafael J. Wysocki 2014-02-04 230 struct acpi_device *adev;
^1da177e4c3f41 Linus Torvalds 2005-04-16 231 struct acpiphp_slot *slot;
^1da177e4c3f41 Linus Torvalds 2005-04-16 232 struct acpiphp_func *newfunc;
^1da177e4c3f41 Linus Torvalds 2005-04-16 233 acpi_status status = AE_OK;
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 234 unsigned long long adr;
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 235 int device, function;
e8c331e963c58b Kenji Kaneshige 2008-12-17 236 struct pci_bus *pbus = bridge->pci_bus;
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 237 struct pci_dev *pdev = bridge->pci_dev;
3b63aaa70e1ccc Jiang Liu 2013-04-12 238 u32 val;
^1da177e4c3f41 Linus Torvalds 2005-04-16 239
dfb117b3e50c52 Bjorn Helgaas 2012-06-20 240 status = acpi_evaluate_integer(handle, "_ADR", NULL, &adr);
dfb117b3e50c52 Bjorn Helgaas 2012-06-20 241 if (ACPI_FAILURE(status)) {
f26ca1d699e8b5 Toshi Kani 2013-11-27 242 if (status != AE_NOT_FOUND)
f26ca1d699e8b5 Toshi Kani 2013-11-27 243 acpi_handle_warn(handle,
f26ca1d699e8b5 Toshi Kani 2013-11-27 244 "can't evaluate _ADR (%#x)\n", status);
dfb117b3e50c52 Bjorn Helgaas 2012-06-20 245 return AE_OK;
dfb117b3e50c52 Bjorn Helgaas 2012-06-20 246 }
bbcbfc0eed6220 Rafael J. Wysocki 2014-02-04 247 if (acpi_bus_get_device(handle, &adev))
bbcbfc0eed6220 Rafael J. Wysocki 2014-02-04 248 return AE_OK;
dfb117b3e50c52 Bjorn Helgaas 2012-06-20 249
dfb117b3e50c52 Bjorn Helgaas 2012-06-20 250 device = (adr >> 16) & 0xffff;
dfb117b3e50c52 Bjorn Helgaas 2012-06-20 251 function = adr & 0xffff;
dfb117b3e50c52 Bjorn Helgaas 2012-06-20 252
e525506fcb67a9 Rafael J. Wysocki 2014-02-04 253 acpi_lock_hp_context();
bbcbfc0eed6220 Rafael J. Wysocki 2014-02-04 254 context = acpiphp_init_context(adev);
cb7b8cedf6c88b Rafael J. Wysocki 2013-07-13 255 if (!context) {
e525506fcb67a9 Rafael J. Wysocki 2014-02-04 256 acpi_unlock_hp_context();
cb7b8cedf6c88b Rafael J. Wysocki 2013-07-13 257 acpi_handle_err(handle, "No hotplug context\n");
cb7b8cedf6c88b Rafael J. Wysocki 2013-07-13 258 return AE_NOT_EXIST;
cb7b8cedf6c88b Rafael J. Wysocki 2013-07-13 259 }
bd4674dfc5fc70 Rafael J. Wysocki 2013-07-13 260 newfunc = &context->func;
bd4674dfc5fc70 Rafael J. Wysocki 2013-07-13 261 newfunc->function = function;
bda46dbb6626c9 Rafael J. Wysocki 2013-07-13 262 newfunc->parent = bridge;
edf5bf34d40804 Rafael J. Wysocki 2014-02-21 263 acpi_unlock_hp_context();
cb7b8cedf6c88b Rafael J. Wysocki 2013-07-13 264
edf5bf34d40804 Rafael J. Wysocki 2014-02-21 265 /*
edf5bf34d40804 Rafael J. Wysocki 2014-02-21 266 * If this is a dock device, its _EJ0 should be executed by the dock
edf5bf34d40804 Rafael J. Wysocki 2014-02-21 267 * notify handler after calling _DCK.
edf5bf34d40804 Rafael J. Wysocki 2014-02-21 268 */
edf5bf34d40804 Rafael J. Wysocki 2014-02-21 269 if (!is_dock_device(adev) && acpi_has_method(handle, "_EJ0"))
^1da177e4c3f41 Linus Torvalds 2005-04-16 270 newfunc->flags = FUNC_HAS_EJ0;
^1da177e4c3f41 Linus Torvalds 2005-04-16 271
ecd046da57d332 Jiang Liu 2013-06-29 272 if (acpi_has_method(handle, "_STA"))
^1da177e4c3f41 Linus Torvalds 2005-04-16 273 newfunc->flags |= FUNC_HAS_STA;
^1da177e4c3f41 Linus Torvalds 2005-04-16 274
^1da177e4c3f41 Linus Torvalds 2005-04-16 275 /* search for objects that share the same slot */
ad41dd9dd0c8ca Yijing Wang 2013-04-12 276 list_for_each_entry(slot, &bridge->slots, node)
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 277 if (slot->device == device)
ac372338b75064 Rafael J. Wysocki 2013-07-13 278 goto slot_found;
^1da177e4c3f41 Linus Torvalds 2005-04-16 279
f5afe8064f3087 Eric Sesterhenn 2006-02-28 280 slot = kzalloc(sizeof(struct acpiphp_slot), GFP_KERNEL);
^1da177e4c3f41 Linus Torvalds 2005-04-16 281 if (!slot) {
e525506fcb67a9 Rafael J. Wysocki 2014-02-04 282 acpi_lock_hp_context();
146fc68a4bdd78 Rafael J. Wysocki 2014-02-04 283 acpiphp_put_context(context);
e525506fcb67a9 Rafael J. Wysocki 2014-02-04 284 acpi_unlock_hp_context();
146fc68a4bdd78 Rafael J. Wysocki 2014-02-04 285 return AE_NO_MEMORY;
^1da177e4c3f41 Linus Torvalds 2005-04-16 286 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 287
bda46dbb6626c9 Rafael J. Wysocki 2013-07-13 288 slot->bus = bridge->pci_bus;
^1da177e4c3f41 Linus Torvalds 2005-04-16 289 slot->device = device;
^1da177e4c3f41 Linus Torvalds 2005-04-16 290 INIT_LIST_HEAD(&slot->funcs);
^1da177e4c3f41 Linus Torvalds 2005-04-16 291
ad41dd9dd0c8ca Yijing Wang 2013-04-12 292 list_add_tail(&slot->node, &bridge->slots);
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 293
cc6254e00eb676 Rafael J. Wysocki 2014-02-16 294 /*
cc6254e00eb676 Rafael J. Wysocki 2014-02-16 295 * Expose slots to user space for functions that have _EJ0 or _RMV or
cc6254e00eb676 Rafael J. Wysocki 2014-02-16 296 * are located in dock stations. Do not expose them for devices handled
84c8b58ed3addf Mika Westerberg 2018-05-29 297 * by the native PCIe hotplug (PCIeHP) or standard PCI hotplug
84c8b58ed3addf Mika Westerberg 2018-05-29 298 * (SHPCHP), because that code is supposed to expose slots to user
84c8b58ed3addf Mika Westerberg 2018-05-29 299 * space in those cases.
cc6254e00eb676 Rafael J. Wysocki 2014-02-16 300 */
3b52b21fa1f44c Rafael J. Wysocki 2014-02-21 301 if ((acpi_pci_check_ejectable(pbus, handle) || is_dock_device(adev))
84c8b58ed3addf Mika Westerberg 2018-05-29 302 && !(pdev && hotplug_is_native(pdev))) {
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 303 unsigned long long sun;
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 304 int retval;
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 305
^1da177e4c3f41 Linus Torvalds 2005-04-16 306 bridge->nr_slots++;
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 307 status = acpi_evaluate_integer(handle, "_SUN", NULL, &sun);
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 308 if (ACPI_FAILURE(status))
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 309 sun = bridge->nr_slots;
^1da177e4c3f41 Linus Torvalds 2005-04-16 310
bd950799d9510c Lan Tianyu 2013-09-24 311 pr_debug("found ACPI PCI Hotplug slot %llu at PCI %04x:%02x:%02x\n",
7342798d0ab850 Rafael J. Wysocki 2013-07-13 312 sun, pci_domain_nr(pbus), pbus->number, device);
ac372338b75064 Rafael J. Wysocki 2013-07-13 313
7342798d0ab850 Rafael J. Wysocki 2013-07-13 314 retval = acpiphp_register_hotplug_slot(slot, sun);
e27da381417038 MUNEDA Takahiro 2006-02-23 315 if (retval) {
1aaac07112f040 Rafael J. Wysocki 2013-08-17 316 slot->slot = NULL;
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 317 bridge->nr_slots--;
f46753c5e354b8 Alex Chiang 2008-06-10 318 if (retval == -EBUSY)
227f06470502c4 Ryan Desfosses 2014-04-18 319 pr_warn("Slot %llu already registered by another hotplug driver\n", sun);
f46753c5e354b8 Alex Chiang 2008-06-10 320 else
227f06470502c4 Ryan Desfosses 2014-04-18 321 pr_warn("acpiphp_register_hotplug_slot failed (err code = 0x%x)\n", retval);
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 322 }
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 323 /* Even if the slot registration fails, we can still use it. */
e27da381417038 MUNEDA Takahiro 2006-02-23 324 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 325
ac372338b75064 Rafael J. Wysocki 2013-07-13 326 slot_found:
^1da177e4c3f41 Linus Torvalds 2005-04-16 327 newfunc->slot = slot;
^1da177e4c3f41 Linus Torvalds 2005-04-16 328 list_add_tail(&newfunc->sibling, &slot->funcs);
^1da177e4c3f41 Linus Torvalds 2005-04-16 329
3b63aaa70e1ccc Jiang Liu 2013-04-12 @330 if (pci_bus_read_dev_vendor_id(pbus, PCI_DEVFN(device, function),
3b63aaa70e1ccc Jiang Liu 2013-04-12 331 &val, 60*1000))
bc805a55392a7c Rafael J. Wysocki 2013-07-13 332 slot->flags |= SLOT_ENABLED;
^1da177e4c3f41 Linus Torvalds 2005-04-16 333
2e862c51904ddd Rafael J. Wysocki 2013-07-13 334 return AE_OK;
^1da177e4c3f41 Linus Torvalds 2005-04-16 335 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 336
364d5094a43ff2 Rajesh Shah 2005-04-28 337 static void cleanup_bridge(struct acpiphp_bridge *bridge)
^1da177e4c3f41 Linus Torvalds 2005-04-16 338 {
3d54a3160fb6ba Jiang Liu 2013-04-12 339 struct acpiphp_slot *slot;
3d54a3160fb6ba Jiang Liu 2013-04-12 340 struct acpiphp_func *func;
42f49a6ae5dca9 Rajesh Shah 2005-04-28 341
3d54a3160fb6ba Jiang Liu 2013-04-12 342 list_for_each_entry(slot, &bridge->slots, node) {
3d54a3160fb6ba Jiang Liu 2013-04-12 343 list_for_each_entry(func, &slot->funcs, sibling) {
1a699476e25814 Rafael J. Wysocki 2014-02-06 344 struct acpi_device *adev = func_to_acpi_device(func);
5a3bc573ae32a7 Rafael J. Wysocki 2013-07-13 345
1a699476e25814 Rafael J. Wysocki 2014-02-06 346 acpi_lock_hp_context();
be27b3dcb02335 Rafael J. Wysocki 2014-02-21 347 adev->hp->notify = NULL;
edf5bf34d40804 Rafael J. Wysocki 2014-02-21 348 adev->hp->fixup = NULL;
1a699476e25814 Rafael J. Wysocki 2014-02-06 349 acpi_unlock_hp_context();
42f49a6ae5dca9 Rajesh Shah 2005-04-28 350 }
9217a984671e8a Rafael J. Wysocki 2014-01-10 351 slot->flags |= SLOT_IS_GOING_AWAY;
1aaac07112f040 Rafael J. Wysocki 2013-08-17 352 if (slot->slot)
e27da381417038 MUNEDA Takahiro 2006-02-23 353 acpiphp_unregister_hotplug_slot(slot);
42f49a6ae5dca9 Rajesh Shah 2005-04-28 354 }
42f49a6ae5dca9 Rajesh Shah 2005-04-28 355
3d54a3160fb6ba Jiang Liu 2013-04-12 356 mutex_lock(&bridge_mutex);
42f49a6ae5dca9 Rajesh Shah 2005-04-28 357 list_del(&bridge->list);
3d54a3160fb6ba Jiang Liu 2013-04-12 358 mutex_unlock(&bridge_mutex);
9217a984671e8a Rafael J. Wysocki 2014-01-10 359
e525506fcb67a9 Rafael J. Wysocki 2014-02-04 360 acpi_lock_hp_context();
9217a984671e8a Rafael J. Wysocki 2014-01-10 361 bridge->is_going_away = true;
e525506fcb67a9 Rafael J. Wysocki 2014-02-04 362 acpi_unlock_hp_context();
^1da177e4c3f41 Linus Torvalds 2005-04-16 363 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 364
15a1ae74879925 Kristen Accardi 2006-02-23 365 /**
26e6c66e47fe7f Randy Dunlap 2007-11-28 366 * acpiphp_max_busnr - return the highest reserved bus number under the given bus.
15a1ae74879925 Kristen Accardi 2006-02-23 367 * @bus: bus to start search with
15a1ae74879925 Kristen Accardi 2006-02-23 368 */
15a1ae74879925 Kristen Accardi 2006-02-23 369 static unsigned char acpiphp_max_busnr(struct pci_bus *bus)
15a1ae74879925 Kristen Accardi 2006-02-23 370 {
c6f0d5adc21e2d Yijing Wang 2014-02-13 371 struct pci_bus *tmp;
15a1ae74879925 Kristen Accardi 2006-02-23 372 unsigned char max, n;
15a1ae74879925 Kristen Accardi 2006-02-23 373
15a1ae74879925 Kristen Accardi 2006-02-23 374 /*
15a1ae74879925 Kristen Accardi 2006-02-23 375 * pci_bus_max_busnr will return the highest
15a1ae74879925 Kristen Accardi 2006-02-23 376 * reserved busnr for all these children.
15a1ae74879925 Kristen Accardi 2006-02-23 377 * that is equivalent to the bus->subordinate
15a1ae74879925 Kristen Accardi 2006-02-23 378 * value. We don't want to use the parent's
15a1ae74879925 Kristen Accardi 2006-02-23 379 * bus->subordinate value because it could have
15a1ae74879925 Kristen Accardi 2006-02-23 380 * padding in it.
15a1ae74879925 Kristen Accardi 2006-02-23 381 */
b918c62e086b21 Yinghai Lu 2012-05-17 382 max = bus->busn_res.start;
15a1ae74879925 Kristen Accardi 2006-02-23 383
c6f0d5adc21e2d Yijing Wang 2014-02-13 384 list_for_each_entry(tmp, &bus->children, node) {
c6f0d5adc21e2d Yijing Wang 2014-02-13 385 n = pci_bus_max_busnr(tmp);
15a1ae74879925 Kristen Accardi 2006-02-23 386 if (n > max)
15a1ae74879925 Kristen Accardi 2006-02-23 387 max = n;
15a1ae74879925 Kristen Accardi 2006-02-23 388 }
15a1ae74879925 Kristen Accardi 2006-02-23 389 return max;
15a1ae74879925 Kristen Accardi 2006-02-23 390 }
15a1ae74879925 Kristen Accardi 2006-02-23 391
d06070509147c9 Shaohua Li 2010-02-25 392 static void acpiphp_set_acpi_region(struct acpiphp_slot *slot)
d06070509147c9 Shaohua Li 2010-02-25 393 {
d06070509147c9 Shaohua Li 2010-02-25 394 struct acpiphp_func *func;
d06070509147c9 Shaohua Li 2010-02-25 395
d06070509147c9 Shaohua Li 2010-02-25 396 list_for_each_entry(func, &slot->funcs, sibling) {
d06070509147c9 Shaohua Li 2010-02-25 397 /* _REG is optional, we don't care about if there is failure */
6dd10c47e91239 Hans de Goede 2020-05-07 398 acpi_evaluate_reg(func_to_handle(func),
6dd10c47e91239 Hans de Goede 2020-05-07 399 ACPI_ADR_SPACE_PCI_CONFIG,
6dd10c47e91239 Hans de Goede 2020-05-07 400 ACPI_REG_CONNECT);
d06070509147c9 Shaohua Li 2010-02-25 401 }
d06070509147c9 Shaohua Li 2010-02-25 402 }
d06070509147c9 Shaohua Li 2010-02-25 403
1f96a965e30d09 Yinghai Lu 2013-01-21 404 static void check_hotplug_bridge(struct acpiphp_slot *slot, struct pci_dev *dev)
1f96a965e30d09 Yinghai Lu 2013-01-21 405 {
1f96a965e30d09 Yinghai Lu 2013-01-21 406 struct acpiphp_func *func;
1f96a965e30d09 Yinghai Lu 2013-01-21 407
1f96a965e30d09 Yinghai Lu 2013-01-21 408 /* quirk, or pcie could set it already */
1f96a965e30d09 Yinghai Lu 2013-01-21 409 if (dev->is_hotplug_bridge)
1f96a965e30d09 Yinghai Lu 2013-01-21 410 return;
1f96a965e30d09 Yinghai Lu 2013-01-21 411
1f96a965e30d09 Yinghai Lu 2013-01-21 412 list_for_each_entry(func, &slot->funcs, sibling) {
1f96a965e30d09 Yinghai Lu 2013-01-21 413 if (PCI_FUNC(dev->devfn) == func->function) {
1f96a965e30d09 Yinghai Lu 2013-01-21 414 dev->is_hotplug_bridge = 1;
1f96a965e30d09 Yinghai Lu 2013-01-21 415 break;
1f96a965e30d09 Yinghai Lu 2013-01-21 416 }
1f96a965e30d09 Yinghai Lu 2013-01-21 417 }
1f96a965e30d09 Yinghai Lu 2013-01-21 418 }
3b63aaa70e1ccc Jiang Liu 2013-04-12 419
a47d8c8e72a5fa Rafael J. Wysocki 2013-09-08 420 static int acpiphp_rescan_slot(struct acpiphp_slot *slot)
a47d8c8e72a5fa Rafael J. Wysocki 2013-09-08 421 {
a47d8c8e72a5fa Rafael J. Wysocki 2013-09-08 422 struct acpiphp_func *func;
a47d8c8e72a5fa Rafael J. Wysocki 2013-09-08 423
b6708fbf98ac01 Rafael J. Wysocki 2014-02-04 424 list_for_each_entry(func, &slot->funcs, sibling) {
b6708fbf98ac01 Rafael J. Wysocki 2014-02-04 425 struct acpi_device *adev = func_to_acpi_device(func);
a47d8c8e72a5fa Rafael J. Wysocki 2013-09-08 426
b6708fbf98ac01 Rafael J. Wysocki 2014-02-04 427 acpi_bus_scan(adev->handle);
b6708fbf98ac01 Rafael J. Wysocki 2014-02-04 428 if (acpi_device_enumerated(adev))
b6708fbf98ac01 Rafael J. Wysocki 2014-02-04 429 acpi_device_set_power(adev, ACPI_STATE_D0);
b6708fbf98ac01 Rafael J. Wysocki 2014-02-04 430 }
a47d8c8e72a5fa Rafael J. Wysocki 2013-09-08 431 return pci_scan_slot(slot->bus, PCI_DEVFN(slot->device, 0));
a47d8c8e72a5fa Rafael J. Wysocki 2013-09-08 432 }
a47d8c8e72a5fa Rafael J. Wysocki 2013-09-08 433
84c8b58ed3addf Mika Westerberg 2018-05-29 434 static void acpiphp_native_scan_bridge(struct pci_dev *bridge)
84c8b58ed3addf Mika Westerberg 2018-05-29 435 {
84c8b58ed3addf Mika Westerberg 2018-05-29 436 struct pci_bus *bus = bridge->subordinate;
84c8b58ed3addf Mika Westerberg 2018-05-29 437 struct pci_dev *dev;
84c8b58ed3addf Mika Westerberg 2018-05-29 438 int max;
84c8b58ed3addf Mika Westerberg 2018-05-29 439
84c8b58ed3addf Mika Westerberg 2018-05-29 440 if (!bus)
84c8b58ed3addf Mika Westerberg 2018-05-29 441 return;
84c8b58ed3addf Mika Westerberg 2018-05-29 442
84c8b58ed3addf Mika Westerberg 2018-05-29 443 max = bus->busn_res.start;
84c8b58ed3addf Mika Westerberg 2018-05-29 444 /* Scan already configured non-hotplug bridges */
84c8b58ed3addf Mika Westerberg 2018-05-29 445 for_each_pci_bridge(dev, bus) {
84c8b58ed3addf Mika Westerberg 2018-05-29 446 if (!hotplug_is_native(dev))
84c8b58ed3addf Mika Westerberg 2018-05-29 447 max = pci_scan_bridge(bus, dev, max, 0);
84c8b58ed3addf Mika Westerberg 2018-05-29 448 }
84c8b58ed3addf Mika Westerberg 2018-05-29 449
84c8b58ed3addf Mika Westerberg 2018-05-29 450 /* Scan non-hotplug bridges that need to be reconfigured */
84c8b58ed3addf Mika Westerberg 2018-05-29 451 for_each_pci_bridge(dev, bus) {
77adf9355304f8 Mika Westerberg 2019-10-30 452 if (hotplug_is_native(dev))
77adf9355304f8 Mika Westerberg 2019-10-30 453 continue;
77adf9355304f8 Mika Westerberg 2019-10-30 454
84c8b58ed3addf Mika Westerberg 2018-05-29 455 max = pci_scan_bridge(bus, dev, max, 1);
77adf9355304f8 Mika Westerberg 2019-10-30 456 if (dev->subordinate) {
77adf9355304f8 Mika Westerberg 2019-10-30 457 pcibios_resource_survey_bus(dev->subordinate);
77adf9355304f8 Mika Westerberg 2019-10-30 458 pci_bus_size_bridges(dev->subordinate);
77adf9355304f8 Mika Westerberg 2019-10-30 459 pci_bus_assign_resources(dev->subordinate);
77adf9355304f8 Mika Westerberg 2019-10-30 460 }
84c8b58ed3addf Mika Westerberg 2018-05-29 461 }
84c8b58ed3addf Mika Westerberg 2018-05-29 462 }
84c8b58ed3addf Mika Westerberg 2018-05-29 463
^1da177e4c3f41 Linus Torvalds 2005-04-16 464 /**
a1d0abcea84573 Rafael J. Wysocki 2013-07-13 465 * enable_slot - enable, configure a slot
^1da177e4c3f41 Linus Torvalds 2005-04-16 466 * @slot: slot to be enabled
f188b99f0b2d33 Mika Westerberg 2018-09-26 467 * @bridge: true if enable is for the whole bridge (not a single slot)
^1da177e4c3f41 Linus Torvalds 2005-04-16 468 *
^1da177e4c3f41 Linus Torvalds 2005-04-16 469 * This function should be called per *physical slot*,
^1da177e4c3f41 Linus Torvalds 2005-04-16 470 * not per each slot object in ACPI namespace.
^1da177e4c3f41 Linus Torvalds 2005-04-16 471 */
f188b99f0b2d33 Mika Westerberg 2018-09-26 472 static void enable_slot(struct acpiphp_slot *slot, bool bridge)
^1da177e4c3f41 Linus Torvalds 2005-04-16 473 {
^1da177e4c3f41 Linus Torvalds 2005-04-16 474 struct pci_dev *dev;
bda46dbb6626c9 Rafael J. Wysocki 2013-07-13 475 struct pci_bus *bus = slot->bus;
^1da177e4c3f41 Linus Torvalds 2005-04-16 476 struct acpiphp_func *func;
84c8b58ed3addf Mika Westerberg 2018-05-29 477
f188b99f0b2d33 Mika Westerberg 2018-09-26 478 if (bridge && bus->self && hotplug_is_native(bus->self)) {
84c8b58ed3addf Mika Westerberg 2018-05-29 479 /*
84c8b58ed3addf Mika Westerberg 2018-05-29 480 * If native hotplug is used, it will take care of hotplug
84c8b58ed3addf Mika Westerberg 2018-05-29 481 * slot management and resource allocation for hotplug
84c8b58ed3addf Mika Westerberg 2018-05-29 482 * bridges. However, ACPI hotplug may still be used for
84c8b58ed3addf Mika Westerberg 2018-05-29 483 * non-hotplug bridges to bring in additional devices such
84c8b58ed3addf Mika Westerberg 2018-05-29 484 * as a Thunderbolt host controller.
84c8b58ed3addf Mika Westerberg 2018-05-29 485 */
84c8b58ed3addf Mika Westerberg 2018-05-29 486 for_each_pci_bridge(dev, bus) {
84c8b58ed3addf Mika Westerberg 2018-05-29 487 if (PCI_SLOT(dev->devfn) == slot->device)
84c8b58ed3addf Mika Westerberg 2018-05-29 488 acpiphp_native_scan_bridge(dev);
84c8b58ed3addf Mika Westerberg 2018-05-29 489 }
84c8b58ed3addf Mika Westerberg 2018-05-29 490 } else {
d66ecb7220a70e Jiang Liu 2013-06-23 491 LIST_HEAD(add_list);
84c8b58ed3addf Mika Westerberg 2018-05-29 492 int max, pass;
^1da177e4c3f41 Linus Torvalds 2005-04-16 493
ab1225901da2d4 Mika Westerberg 2013-10-30 494 acpiphp_rescan_slot(slot);
15a1ae74879925 Kristen Accardi 2006-02-23 495 max = acpiphp_max_busnr(bus);
42f49a6ae5dca9 Rajesh Shah 2005-04-28 496 for (pass = 0; pass < 2; pass++) {
24a0c654d7d606 Andy Shevchenko 2017-10-20 497 for_each_pci_bridge(dev, bus) {
42f49a6ae5dca9 Rajesh Shah 2005-04-28 498 if (PCI_SLOT(dev->devfn) != slot->device)
42f49a6ae5dca9 Rajesh Shah 2005-04-28 499 continue;
a1d0abcea84573 Rafael J. Wysocki 2013-07-13 500
42f49a6ae5dca9 Rajesh Shah 2005-04-28 501 max = pci_scan_bridge(bus, dev, max, pass);
1f96a965e30d09 Yinghai Lu 2013-01-21 502 if (pass && dev->subordinate) {
1f96a965e30d09 Yinghai Lu 2013-01-21 503 check_hotplug_bridge(slot, dev);
d66ecb7220a70e Jiang Liu 2013-06-23 504 pcibios_resource_survey_bus(dev->subordinate);
84c8b58ed3addf Mika Westerberg 2018-05-29 @505 __pci_bus_size_bridges(dev->subordinate,
84c8b58ed3addf Mika Westerberg 2018-05-29 506 &add_list);
c64b5eead93f9d Kristen Accardi 2005-12-14 507 }
42f49a6ae5dca9 Rajesh Shah 2005-04-28 508 }
1f96a965e30d09 Yinghai Lu 2013-01-21 509 }
d66ecb7220a70e Jiang Liu 2013-06-23 @510 __pci_bus_assign_resources(bus, &add_list, NULL);
84c8b58ed3addf Mika Westerberg 2018-05-29 511 }
2dc41281b1d117 Rafael J. Wysocki 2013-09-06 512
8e5dce35221850 Kristen Accardi 2005-10-18 513 acpiphp_sanitize_bus(bus);
81ee57326c9ca6 Bjorn Helgaas 2014-08-28 514 pcie_bus_configure_settings(bus);
d06070509147c9 Shaohua Li 2010-02-25 515 acpiphp_set_acpi_region(slot);
69643e4829c5cd Ian Campbell 2011-05-11 516
69643e4829c5cd Ian Campbell 2011-05-11 517 list_for_each_entry(dev, &bus->devices, bus_list) {
69643e4829c5cd Ian Campbell 2011-05-11 518 /* Assume that newly added devices are powered on already. */
44bda4b7d26e9f Hari Vyas 2018-07-03 519 if (!pci_dev_is_added(dev))
69643e4829c5cd Ian Campbell 2011-05-11 520 dev->current_state = PCI_D0;
69643e4829c5cd Ian Campbell 2011-05-11 521 }
69643e4829c5cd Ian Campbell 2011-05-11 522
42f49a6ae5dca9 Rajesh Shah 2005-04-28 523 pci_bus_add_devices(bus);
42f49a6ae5dca9 Rajesh Shah 2005-04-28 524
f382a086f3129e Amos Kong 2011-11-25 525 slot->flags |= SLOT_ENABLED;
58c08628c4fe66 Alex Chiang 2009-10-26 526 list_for_each_entry(func, &slot->funcs, sibling) {
9d911d7903926a Alex Chiang 2009-05-21 527 dev = pci_get_slot(bus, PCI_DEVFN(slot->device,
^1da177e4c3f41 Linus Torvalds 2005-04-16 528 func->function));
f382a086f3129e Amos Kong 2011-11-25 529 if (!dev) {
f382a086f3129e Amos Kong 2011-11-25 530 /* Do not set SLOT_ENABLED flag if some funcs
f382a086f3129e Amos Kong 2011-11-25 531 are not added. */
9337a493623d59 Mika Westerberg 2018-05-24 532 slot->flags &= ~SLOT_ENABLED;
551bcb75b3d9f2 MUNEDA Takahiro 2006-03-22 533 continue;
f382a086f3129e Amos Kong 2011-11-25 534 }
3bbfd319034ddc Feilong Lin 2021-03-25 535 pci_dev_put(dev);
^1da177e4c3f41 Linus Torvalds 2005-04-16 536 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 537 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 538
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 65111 bytes --]
^ permalink raw reply
* Re: [PATCH 3/5] PCI: Move pci_dev_is/assign_added() to pci.h
From: kernel test robot @ 2021-09-07 0:22 UTC (permalink / raw)
To: Niklas Schnelle, Bjorn Helgaas
Cc: linux-s390, kbuild-all, Pierre Morel, Matthew Rosato, llvm,
linux-kernel, Oliver O'Halloran, Linas Vepstas, linuxppc-dev
In-Reply-To: <20210906094927.524106-4-schnelle@linux.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 28550 bytes --]
Hi Niklas,
I love your patch! Yet something to improve:
[auto build test ERROR on s390/features]
[also build test ERROR on next-20210906]
[cannot apply to pci/next powerpc/next v5.14]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Niklas-Schnelle/s390-pci-automatic-error-recovery/20210906-175309
base: https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git features
config: i386-randconfig-a016-20210906 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 6fe2beba7d2a41964af658c8c59dd172683ef739)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/404ed8c00a612e7ae31c50557c80c6726c464863
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Niklas-Schnelle/s390-pci-automatic-error-recovery/20210906-175309
git checkout 404ed8c00a612e7ae31c50557c80c6726c464863
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=i386
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
>> drivers/pci/hotplug/acpiphp_glue.c:330:6: error: implicit declaration of function 'pci_bus_read_dev_vendor_id' [-Werror,-Wimplicit-function-declaration]
if (pci_bus_read_dev_vendor_id(pbus, PCI_DEVFN(device, function),
^
>> drivers/pci/hotplug/acpiphp_glue.c:505:6: error: implicit declaration of function '__pci_bus_size_bridges' [-Werror,-Wimplicit-function-declaration]
__pci_bus_size_bridges(dev->subordinate,
^
drivers/pci/hotplug/acpiphp_glue.c:505:6: note: did you mean 'pci_bus_size_bridges'?
include/linux/pci.h:1336:6: note: 'pci_bus_size_bridges' declared here
void pci_bus_size_bridges(struct pci_bus *bus);
^
>> drivers/pci/hotplug/acpiphp_glue.c:510:3: error: implicit declaration of function '__pci_bus_assign_resources' [-Werror,-Wimplicit-function-declaration]
__pci_bus_assign_resources(bus, &add_list, NULL);
^
drivers/pci/hotplug/acpiphp_glue.c:510:3: note: did you mean 'pci_bus_assign_resources'?
include/linux/pci.h:1334:6: note: 'pci_bus_assign_resources' declared here
void pci_bus_assign_resources(const struct pci_bus *bus);
^
drivers/pci/hotplug/acpiphp_glue.c:604:8: error: implicit declaration of function 'pci_bus_read_dev_vendor_id' [-Werror,-Wimplicit-function-declaration]
if (pci_bus_read_dev_vendor_id(slot->bus,
^
drivers/pci/hotplug/acpiphp_glue.c:619:7: error: implicit declaration of function 'pci_bus_read_dev_vendor_id' [-Werror,-Wimplicit-function-declaration]
if (pci_bus_read_dev_vendor_id(slot->bus,
^
>> drivers/pci/hotplug/acpiphp_glue.c:660:3: error: implicit declaration of function 'pci_dev_set_disconnected' [-Werror,-Wimplicit-function-declaration]
pci_dev_set_disconnected(dev, NULL);
^
>> drivers/pci/hotplug/acpiphp_glue.c:661:7: error: implicit declaration of function 'pci_has_subordinate' [-Werror,-Wimplicit-function-declaration]
if (pci_has_subordinate(dev))
^
7 errors generated.
vim +/pci_bus_read_dev_vendor_id +330 drivers/pci/hotplug/acpiphp_glue.c
4e8662bbd680c5 Kristen Accardi 2006-06-28 217
3799c5a032aefb Rafael J. Wysocki 2014-02-16 218 /**
3799c5a032aefb Rafael J. Wysocki 2014-02-16 219 * acpiphp_add_context - Add ACPIPHP context to an ACPI device object.
3799c5a032aefb Rafael J. Wysocki 2014-02-16 220 * @handle: ACPI handle of the object to add a context to.
3799c5a032aefb Rafael J. Wysocki 2014-02-16 221 * @lvl: Not used.
3799c5a032aefb Rafael J. Wysocki 2014-02-16 222 * @data: The object's parent ACPIPHP bridge.
3799c5a032aefb Rafael J. Wysocki 2014-02-16 223 * @rv: Not used.
3799c5a032aefb Rafael J. Wysocki 2014-02-16 224 */
3799c5a032aefb Rafael J. Wysocki 2014-02-16 225 static acpi_status acpiphp_add_context(acpi_handle handle, u32 lvl, void *data,
cb7b8cedf6c88b Rafael J. Wysocki 2013-07-13 226 void **rv)
^1da177e4c3f41 Linus Torvalds 2005-04-16 227 {
cb7b8cedf6c88b Rafael J. Wysocki 2013-07-13 228 struct acpiphp_bridge *bridge = data;
cb7b8cedf6c88b Rafael J. Wysocki 2013-07-13 229 struct acpiphp_context *context;
bbcbfc0eed6220 Rafael J. Wysocki 2014-02-04 230 struct acpi_device *adev;
^1da177e4c3f41 Linus Torvalds 2005-04-16 231 struct acpiphp_slot *slot;
^1da177e4c3f41 Linus Torvalds 2005-04-16 232 struct acpiphp_func *newfunc;
^1da177e4c3f41 Linus Torvalds 2005-04-16 233 acpi_status status = AE_OK;
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 234 unsigned long long adr;
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 235 int device, function;
e8c331e963c58b Kenji Kaneshige 2008-12-17 236 struct pci_bus *pbus = bridge->pci_bus;
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 237 struct pci_dev *pdev = bridge->pci_dev;
3b63aaa70e1ccc Jiang Liu 2013-04-12 238 u32 val;
^1da177e4c3f41 Linus Torvalds 2005-04-16 239
dfb117b3e50c52 Bjorn Helgaas 2012-06-20 240 status = acpi_evaluate_integer(handle, "_ADR", NULL, &adr);
dfb117b3e50c52 Bjorn Helgaas 2012-06-20 241 if (ACPI_FAILURE(status)) {
f26ca1d699e8b5 Toshi Kani 2013-11-27 242 if (status != AE_NOT_FOUND)
f26ca1d699e8b5 Toshi Kani 2013-11-27 243 acpi_handle_warn(handle,
f26ca1d699e8b5 Toshi Kani 2013-11-27 244 "can't evaluate _ADR (%#x)\n", status);
dfb117b3e50c52 Bjorn Helgaas 2012-06-20 245 return AE_OK;
dfb117b3e50c52 Bjorn Helgaas 2012-06-20 246 }
bbcbfc0eed6220 Rafael J. Wysocki 2014-02-04 247 if (acpi_bus_get_device(handle, &adev))
bbcbfc0eed6220 Rafael J. Wysocki 2014-02-04 248 return AE_OK;
dfb117b3e50c52 Bjorn Helgaas 2012-06-20 249
dfb117b3e50c52 Bjorn Helgaas 2012-06-20 250 device = (adr >> 16) & 0xffff;
dfb117b3e50c52 Bjorn Helgaas 2012-06-20 251 function = adr & 0xffff;
dfb117b3e50c52 Bjorn Helgaas 2012-06-20 252
e525506fcb67a9 Rafael J. Wysocki 2014-02-04 253 acpi_lock_hp_context();
bbcbfc0eed6220 Rafael J. Wysocki 2014-02-04 254 context = acpiphp_init_context(adev);
cb7b8cedf6c88b Rafael J. Wysocki 2013-07-13 255 if (!context) {
e525506fcb67a9 Rafael J. Wysocki 2014-02-04 256 acpi_unlock_hp_context();
cb7b8cedf6c88b Rafael J. Wysocki 2013-07-13 257 acpi_handle_err(handle, "No hotplug context\n");
cb7b8cedf6c88b Rafael J. Wysocki 2013-07-13 258 return AE_NOT_EXIST;
cb7b8cedf6c88b Rafael J. Wysocki 2013-07-13 259 }
bd4674dfc5fc70 Rafael J. Wysocki 2013-07-13 260 newfunc = &context->func;
bd4674dfc5fc70 Rafael J. Wysocki 2013-07-13 261 newfunc->function = function;
bda46dbb6626c9 Rafael J. Wysocki 2013-07-13 262 newfunc->parent = bridge;
edf5bf34d40804 Rafael J. Wysocki 2014-02-21 263 acpi_unlock_hp_context();
cb7b8cedf6c88b Rafael J. Wysocki 2013-07-13 264
edf5bf34d40804 Rafael J. Wysocki 2014-02-21 265 /*
edf5bf34d40804 Rafael J. Wysocki 2014-02-21 266 * If this is a dock device, its _EJ0 should be executed by the dock
edf5bf34d40804 Rafael J. Wysocki 2014-02-21 267 * notify handler after calling _DCK.
edf5bf34d40804 Rafael J. Wysocki 2014-02-21 268 */
edf5bf34d40804 Rafael J. Wysocki 2014-02-21 269 if (!is_dock_device(adev) && acpi_has_method(handle, "_EJ0"))
^1da177e4c3f41 Linus Torvalds 2005-04-16 270 newfunc->flags = FUNC_HAS_EJ0;
^1da177e4c3f41 Linus Torvalds 2005-04-16 271
ecd046da57d332 Jiang Liu 2013-06-29 272 if (acpi_has_method(handle, "_STA"))
^1da177e4c3f41 Linus Torvalds 2005-04-16 273 newfunc->flags |= FUNC_HAS_STA;
^1da177e4c3f41 Linus Torvalds 2005-04-16 274
^1da177e4c3f41 Linus Torvalds 2005-04-16 275 /* search for objects that share the same slot */
ad41dd9dd0c8ca Yijing Wang 2013-04-12 276 list_for_each_entry(slot, &bridge->slots, node)
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 277 if (slot->device == device)
ac372338b75064 Rafael J. Wysocki 2013-07-13 278 goto slot_found;
^1da177e4c3f41 Linus Torvalds 2005-04-16 279
f5afe8064f3087 Eric Sesterhenn 2006-02-28 280 slot = kzalloc(sizeof(struct acpiphp_slot), GFP_KERNEL);
^1da177e4c3f41 Linus Torvalds 2005-04-16 281 if (!slot) {
e525506fcb67a9 Rafael J. Wysocki 2014-02-04 282 acpi_lock_hp_context();
146fc68a4bdd78 Rafael J. Wysocki 2014-02-04 283 acpiphp_put_context(context);
e525506fcb67a9 Rafael J. Wysocki 2014-02-04 284 acpi_unlock_hp_context();
146fc68a4bdd78 Rafael J. Wysocki 2014-02-04 285 return AE_NO_MEMORY;
^1da177e4c3f41 Linus Torvalds 2005-04-16 286 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 287
bda46dbb6626c9 Rafael J. Wysocki 2013-07-13 288 slot->bus = bridge->pci_bus;
^1da177e4c3f41 Linus Torvalds 2005-04-16 289 slot->device = device;
^1da177e4c3f41 Linus Torvalds 2005-04-16 290 INIT_LIST_HEAD(&slot->funcs);
^1da177e4c3f41 Linus Torvalds 2005-04-16 291
ad41dd9dd0c8ca Yijing Wang 2013-04-12 292 list_add_tail(&slot->node, &bridge->slots);
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 293
cc6254e00eb676 Rafael J. Wysocki 2014-02-16 294 /*
cc6254e00eb676 Rafael J. Wysocki 2014-02-16 295 * Expose slots to user space for functions that have _EJ0 or _RMV or
cc6254e00eb676 Rafael J. Wysocki 2014-02-16 296 * are located in dock stations. Do not expose them for devices handled
84c8b58ed3addf Mika Westerberg 2018-05-29 297 * by the native PCIe hotplug (PCIeHP) or standard PCI hotplug
84c8b58ed3addf Mika Westerberg 2018-05-29 298 * (SHPCHP), because that code is supposed to expose slots to user
84c8b58ed3addf Mika Westerberg 2018-05-29 299 * space in those cases.
cc6254e00eb676 Rafael J. Wysocki 2014-02-16 300 */
3b52b21fa1f44c Rafael J. Wysocki 2014-02-21 301 if ((acpi_pci_check_ejectable(pbus, handle) || is_dock_device(adev))
84c8b58ed3addf Mika Westerberg 2018-05-29 302 && !(pdev && hotplug_is_native(pdev))) {
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 303 unsigned long long sun;
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 304 int retval;
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 305
^1da177e4c3f41 Linus Torvalds 2005-04-16 306 bridge->nr_slots++;
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 307 status = acpi_evaluate_integer(handle, "_SUN", NULL, &sun);
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 308 if (ACPI_FAILURE(status))
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 309 sun = bridge->nr_slots;
^1da177e4c3f41 Linus Torvalds 2005-04-16 310
bd950799d9510c Lan Tianyu 2013-09-24 311 pr_debug("found ACPI PCI Hotplug slot %llu at PCI %04x:%02x:%02x\n",
7342798d0ab850 Rafael J. Wysocki 2013-07-13 312 sun, pci_domain_nr(pbus), pbus->number, device);
ac372338b75064 Rafael J. Wysocki 2013-07-13 313
7342798d0ab850 Rafael J. Wysocki 2013-07-13 314 retval = acpiphp_register_hotplug_slot(slot, sun);
e27da381417038 MUNEDA Takahiro 2006-02-23 315 if (retval) {
1aaac07112f040 Rafael J. Wysocki 2013-08-17 316 slot->slot = NULL;
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 317 bridge->nr_slots--;
f46753c5e354b8 Alex Chiang 2008-06-10 318 if (retval == -EBUSY)
227f06470502c4 Ryan Desfosses 2014-04-18 319 pr_warn("Slot %llu already registered by another hotplug driver\n", sun);
f46753c5e354b8 Alex Chiang 2008-06-10 320 else
227f06470502c4 Ryan Desfosses 2014-04-18 321 pr_warn("acpiphp_register_hotplug_slot failed (err code = 0x%x)\n", retval);
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 322 }
bbd34fcdd1b201 Rafael J. Wysocki 2013-07-13 323 /* Even if the slot registration fails, we can still use it. */
e27da381417038 MUNEDA Takahiro 2006-02-23 324 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 325
ac372338b75064 Rafael J. Wysocki 2013-07-13 326 slot_found:
^1da177e4c3f41 Linus Torvalds 2005-04-16 327 newfunc->slot = slot;
^1da177e4c3f41 Linus Torvalds 2005-04-16 328 list_add_tail(&newfunc->sibling, &slot->funcs);
^1da177e4c3f41 Linus Torvalds 2005-04-16 329
3b63aaa70e1ccc Jiang Liu 2013-04-12 @330 if (pci_bus_read_dev_vendor_id(pbus, PCI_DEVFN(device, function),
3b63aaa70e1ccc Jiang Liu 2013-04-12 331 &val, 60*1000))
bc805a55392a7c Rafael J. Wysocki 2013-07-13 332 slot->flags |= SLOT_ENABLED;
^1da177e4c3f41 Linus Torvalds 2005-04-16 333
2e862c51904ddd Rafael J. Wysocki 2013-07-13 334 return AE_OK;
^1da177e4c3f41 Linus Torvalds 2005-04-16 335 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 336
364d5094a43ff2 Rajesh Shah 2005-04-28 337 static void cleanup_bridge(struct acpiphp_bridge *bridge)
^1da177e4c3f41 Linus Torvalds 2005-04-16 338 {
3d54a3160fb6ba Jiang Liu 2013-04-12 339 struct acpiphp_slot *slot;
3d54a3160fb6ba Jiang Liu 2013-04-12 340 struct acpiphp_func *func;
42f49a6ae5dca9 Rajesh Shah 2005-04-28 341
3d54a3160fb6ba Jiang Liu 2013-04-12 342 list_for_each_entry(slot, &bridge->slots, node) {
3d54a3160fb6ba Jiang Liu 2013-04-12 343 list_for_each_entry(func, &slot->funcs, sibling) {
1a699476e25814 Rafael J. Wysocki 2014-02-06 344 struct acpi_device *adev = func_to_acpi_device(func);
5a3bc573ae32a7 Rafael J. Wysocki 2013-07-13 345
1a699476e25814 Rafael J. Wysocki 2014-02-06 346 acpi_lock_hp_context();
be27b3dcb02335 Rafael J. Wysocki 2014-02-21 347 adev->hp->notify = NULL;
edf5bf34d40804 Rafael J. Wysocki 2014-02-21 348 adev->hp->fixup = NULL;
1a699476e25814 Rafael J. Wysocki 2014-02-06 349 acpi_unlock_hp_context();
42f49a6ae5dca9 Rajesh Shah 2005-04-28 350 }
9217a984671e8a Rafael J. Wysocki 2014-01-10 351 slot->flags |= SLOT_IS_GOING_AWAY;
1aaac07112f040 Rafael J. Wysocki 2013-08-17 352 if (slot->slot)
e27da381417038 MUNEDA Takahiro 2006-02-23 353 acpiphp_unregister_hotplug_slot(slot);
42f49a6ae5dca9 Rajesh Shah 2005-04-28 354 }
42f49a6ae5dca9 Rajesh Shah 2005-04-28 355
3d54a3160fb6ba Jiang Liu 2013-04-12 356 mutex_lock(&bridge_mutex);
42f49a6ae5dca9 Rajesh Shah 2005-04-28 357 list_del(&bridge->list);
3d54a3160fb6ba Jiang Liu 2013-04-12 358 mutex_unlock(&bridge_mutex);
9217a984671e8a Rafael J. Wysocki 2014-01-10 359
e525506fcb67a9 Rafael J. Wysocki 2014-02-04 360 acpi_lock_hp_context();
9217a984671e8a Rafael J. Wysocki 2014-01-10 361 bridge->is_going_away = true;
e525506fcb67a9 Rafael J. Wysocki 2014-02-04 362 acpi_unlock_hp_context();
^1da177e4c3f41 Linus Torvalds 2005-04-16 363 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 364
15a1ae74879925 Kristen Accardi 2006-02-23 365 /**
26e6c66e47fe7f Randy Dunlap 2007-11-28 366 * acpiphp_max_busnr - return the highest reserved bus number under the given bus.
15a1ae74879925 Kristen Accardi 2006-02-23 367 * @bus: bus to start search with
15a1ae74879925 Kristen Accardi 2006-02-23 368 */
15a1ae74879925 Kristen Accardi 2006-02-23 369 static unsigned char acpiphp_max_busnr(struct pci_bus *bus)
15a1ae74879925 Kristen Accardi 2006-02-23 370 {
c6f0d5adc21e2d Yijing Wang 2014-02-13 371 struct pci_bus *tmp;
15a1ae74879925 Kristen Accardi 2006-02-23 372 unsigned char max, n;
15a1ae74879925 Kristen Accardi 2006-02-23 373
15a1ae74879925 Kristen Accardi 2006-02-23 374 /*
15a1ae74879925 Kristen Accardi 2006-02-23 375 * pci_bus_max_busnr will return the highest
15a1ae74879925 Kristen Accardi 2006-02-23 376 * reserved busnr for all these children.
15a1ae74879925 Kristen Accardi 2006-02-23 377 * that is equivalent to the bus->subordinate
15a1ae74879925 Kristen Accardi 2006-02-23 378 * value. We don't want to use the parent's
15a1ae74879925 Kristen Accardi 2006-02-23 379 * bus->subordinate value because it could have
15a1ae74879925 Kristen Accardi 2006-02-23 380 * padding in it.
15a1ae74879925 Kristen Accardi 2006-02-23 381 */
b918c62e086b21 Yinghai Lu 2012-05-17 382 max = bus->busn_res.start;
15a1ae74879925 Kristen Accardi 2006-02-23 383
c6f0d5adc21e2d Yijing Wang 2014-02-13 384 list_for_each_entry(tmp, &bus->children, node) {
c6f0d5adc21e2d Yijing Wang 2014-02-13 385 n = pci_bus_max_busnr(tmp);
15a1ae74879925 Kristen Accardi 2006-02-23 386 if (n > max)
15a1ae74879925 Kristen Accardi 2006-02-23 387 max = n;
15a1ae74879925 Kristen Accardi 2006-02-23 388 }
15a1ae74879925 Kristen Accardi 2006-02-23 389 return max;
15a1ae74879925 Kristen Accardi 2006-02-23 390 }
15a1ae74879925 Kristen Accardi 2006-02-23 391
d06070509147c9 Shaohua Li 2010-02-25 392 static void acpiphp_set_acpi_region(struct acpiphp_slot *slot)
d06070509147c9 Shaohua Li 2010-02-25 393 {
d06070509147c9 Shaohua Li 2010-02-25 394 struct acpiphp_func *func;
d06070509147c9 Shaohua Li 2010-02-25 395
d06070509147c9 Shaohua Li 2010-02-25 396 list_for_each_entry(func, &slot->funcs, sibling) {
d06070509147c9 Shaohua Li 2010-02-25 397 /* _REG is optional, we don't care about if there is failure */
6dd10c47e91239 Hans de Goede 2020-05-07 398 acpi_evaluate_reg(func_to_handle(func),
6dd10c47e91239 Hans de Goede 2020-05-07 399 ACPI_ADR_SPACE_PCI_CONFIG,
6dd10c47e91239 Hans de Goede 2020-05-07 400 ACPI_REG_CONNECT);
d06070509147c9 Shaohua Li 2010-02-25 401 }
d06070509147c9 Shaohua Li 2010-02-25 402 }
d06070509147c9 Shaohua Li 2010-02-25 403
1f96a965e30d09 Yinghai Lu 2013-01-21 404 static void check_hotplug_bridge(struct acpiphp_slot *slot, struct pci_dev *dev)
1f96a965e30d09 Yinghai Lu 2013-01-21 405 {
1f96a965e30d09 Yinghai Lu 2013-01-21 406 struct acpiphp_func *func;
1f96a965e30d09 Yinghai Lu 2013-01-21 407
1f96a965e30d09 Yinghai Lu 2013-01-21 408 /* quirk, or pcie could set it already */
1f96a965e30d09 Yinghai Lu 2013-01-21 409 if (dev->is_hotplug_bridge)
1f96a965e30d09 Yinghai Lu 2013-01-21 410 return;
1f96a965e30d09 Yinghai Lu 2013-01-21 411
1f96a965e30d09 Yinghai Lu 2013-01-21 412 list_for_each_entry(func, &slot->funcs, sibling) {
1f96a965e30d09 Yinghai Lu 2013-01-21 413 if (PCI_FUNC(dev->devfn) == func->function) {
1f96a965e30d09 Yinghai Lu 2013-01-21 414 dev->is_hotplug_bridge = 1;
1f96a965e30d09 Yinghai Lu 2013-01-21 415 break;
1f96a965e30d09 Yinghai Lu 2013-01-21 416 }
1f96a965e30d09 Yinghai Lu 2013-01-21 417 }
1f96a965e30d09 Yinghai Lu 2013-01-21 418 }
3b63aaa70e1ccc Jiang Liu 2013-04-12 419
a47d8c8e72a5fa Rafael J. Wysocki 2013-09-08 420 static int acpiphp_rescan_slot(struct acpiphp_slot *slot)
a47d8c8e72a5fa Rafael J. Wysocki 2013-09-08 421 {
a47d8c8e72a5fa Rafael J. Wysocki 2013-09-08 422 struct acpiphp_func *func;
a47d8c8e72a5fa Rafael J. Wysocki 2013-09-08 423
b6708fbf98ac01 Rafael J. Wysocki 2014-02-04 424 list_for_each_entry(func, &slot->funcs, sibling) {
b6708fbf98ac01 Rafael J. Wysocki 2014-02-04 425 struct acpi_device *adev = func_to_acpi_device(func);
a47d8c8e72a5fa Rafael J. Wysocki 2013-09-08 426
b6708fbf98ac01 Rafael J. Wysocki 2014-02-04 427 acpi_bus_scan(adev->handle);
b6708fbf98ac01 Rafael J. Wysocki 2014-02-04 428 if (acpi_device_enumerated(adev))
b6708fbf98ac01 Rafael J. Wysocki 2014-02-04 429 acpi_device_set_power(adev, ACPI_STATE_D0);
b6708fbf98ac01 Rafael J. Wysocki 2014-02-04 430 }
a47d8c8e72a5fa Rafael J. Wysocki 2013-09-08 431 return pci_scan_slot(slot->bus, PCI_DEVFN(slot->device, 0));
a47d8c8e72a5fa Rafael J. Wysocki 2013-09-08 432 }
a47d8c8e72a5fa Rafael J. Wysocki 2013-09-08 433
84c8b58ed3addf Mika Westerberg 2018-05-29 434 static void acpiphp_native_scan_bridge(struct pci_dev *bridge)
84c8b58ed3addf Mika Westerberg 2018-05-29 435 {
84c8b58ed3addf Mika Westerberg 2018-05-29 436 struct pci_bus *bus = bridge->subordinate;
84c8b58ed3addf Mika Westerberg 2018-05-29 437 struct pci_dev *dev;
84c8b58ed3addf Mika Westerberg 2018-05-29 438 int max;
84c8b58ed3addf Mika Westerberg 2018-05-29 439
84c8b58ed3addf Mika Westerberg 2018-05-29 440 if (!bus)
84c8b58ed3addf Mika Westerberg 2018-05-29 441 return;
84c8b58ed3addf Mika Westerberg 2018-05-29 442
84c8b58ed3addf Mika Westerberg 2018-05-29 443 max = bus->busn_res.start;
84c8b58ed3addf Mika Westerberg 2018-05-29 444 /* Scan already configured non-hotplug bridges */
84c8b58ed3addf Mika Westerberg 2018-05-29 445 for_each_pci_bridge(dev, bus) {
84c8b58ed3addf Mika Westerberg 2018-05-29 446 if (!hotplug_is_native(dev))
84c8b58ed3addf Mika Westerberg 2018-05-29 447 max = pci_scan_bridge(bus, dev, max, 0);
84c8b58ed3addf Mika Westerberg 2018-05-29 448 }
84c8b58ed3addf Mika Westerberg 2018-05-29 449
84c8b58ed3addf Mika Westerberg 2018-05-29 450 /* Scan non-hotplug bridges that need to be reconfigured */
84c8b58ed3addf Mika Westerberg 2018-05-29 451 for_each_pci_bridge(dev, bus) {
77adf9355304f8 Mika Westerberg 2019-10-30 452 if (hotplug_is_native(dev))
77adf9355304f8 Mika Westerberg 2019-10-30 453 continue;
77adf9355304f8 Mika Westerberg 2019-10-30 454
84c8b58ed3addf Mika Westerberg 2018-05-29 455 max = pci_scan_bridge(bus, dev, max, 1);
77adf9355304f8 Mika Westerberg 2019-10-30 456 if (dev->subordinate) {
77adf9355304f8 Mika Westerberg 2019-10-30 457 pcibios_resource_survey_bus(dev->subordinate);
77adf9355304f8 Mika Westerberg 2019-10-30 458 pci_bus_size_bridges(dev->subordinate);
77adf9355304f8 Mika Westerberg 2019-10-30 459 pci_bus_assign_resources(dev->subordinate);
77adf9355304f8 Mika Westerberg 2019-10-30 460 }
84c8b58ed3addf Mika Westerberg 2018-05-29 461 }
84c8b58ed3addf Mika Westerberg 2018-05-29 462 }
84c8b58ed3addf Mika Westerberg 2018-05-29 463
^1da177e4c3f41 Linus Torvalds 2005-04-16 464 /**
a1d0abcea84573 Rafael J. Wysocki 2013-07-13 465 * enable_slot - enable, configure a slot
^1da177e4c3f41 Linus Torvalds 2005-04-16 466 * @slot: slot to be enabled
f188b99f0b2d33 Mika Westerberg 2018-09-26 467 * @bridge: true if enable is for the whole bridge (not a single slot)
^1da177e4c3f41 Linus Torvalds 2005-04-16 468 *
^1da177e4c3f41 Linus Torvalds 2005-04-16 469 * This function should be called per *physical slot*,
^1da177e4c3f41 Linus Torvalds 2005-04-16 470 * not per each slot object in ACPI namespace.
^1da177e4c3f41 Linus Torvalds 2005-04-16 471 */
f188b99f0b2d33 Mika Westerberg 2018-09-26 472 static void enable_slot(struct acpiphp_slot *slot, bool bridge)
^1da177e4c3f41 Linus Torvalds 2005-04-16 473 {
^1da177e4c3f41 Linus Torvalds 2005-04-16 474 struct pci_dev *dev;
bda46dbb6626c9 Rafael J. Wysocki 2013-07-13 475 struct pci_bus *bus = slot->bus;
^1da177e4c3f41 Linus Torvalds 2005-04-16 476 struct acpiphp_func *func;
84c8b58ed3addf Mika Westerberg 2018-05-29 477
f188b99f0b2d33 Mika Westerberg 2018-09-26 478 if (bridge && bus->self && hotplug_is_native(bus->self)) {
84c8b58ed3addf Mika Westerberg 2018-05-29 479 /*
84c8b58ed3addf Mika Westerberg 2018-05-29 480 * If native hotplug is used, it will take care of hotplug
84c8b58ed3addf Mika Westerberg 2018-05-29 481 * slot management and resource allocation for hotplug
84c8b58ed3addf Mika Westerberg 2018-05-29 482 * bridges. However, ACPI hotplug may still be used for
84c8b58ed3addf Mika Westerberg 2018-05-29 483 * non-hotplug bridges to bring in additional devices such
84c8b58ed3addf Mika Westerberg 2018-05-29 484 * as a Thunderbolt host controller.
84c8b58ed3addf Mika Westerberg 2018-05-29 485 */
84c8b58ed3addf Mika Westerberg 2018-05-29 486 for_each_pci_bridge(dev, bus) {
84c8b58ed3addf Mika Westerberg 2018-05-29 487 if (PCI_SLOT(dev->devfn) == slot->device)
84c8b58ed3addf Mika Westerberg 2018-05-29 488 acpiphp_native_scan_bridge(dev);
84c8b58ed3addf Mika Westerberg 2018-05-29 489 }
84c8b58ed3addf Mika Westerberg 2018-05-29 490 } else {
d66ecb7220a70e Jiang Liu 2013-06-23 491 LIST_HEAD(add_list);
84c8b58ed3addf Mika Westerberg 2018-05-29 492 int max, pass;
^1da177e4c3f41 Linus Torvalds 2005-04-16 493
ab1225901da2d4 Mika Westerberg 2013-10-30 494 acpiphp_rescan_slot(slot);
15a1ae74879925 Kristen Accardi 2006-02-23 495 max = acpiphp_max_busnr(bus);
42f49a6ae5dca9 Rajesh Shah 2005-04-28 496 for (pass = 0; pass < 2; pass++) {
24a0c654d7d606 Andy Shevchenko 2017-10-20 497 for_each_pci_bridge(dev, bus) {
42f49a6ae5dca9 Rajesh Shah 2005-04-28 498 if (PCI_SLOT(dev->devfn) != slot->device)
42f49a6ae5dca9 Rajesh Shah 2005-04-28 499 continue;
a1d0abcea84573 Rafael J. Wysocki 2013-07-13 500
42f49a6ae5dca9 Rajesh Shah 2005-04-28 501 max = pci_scan_bridge(bus, dev, max, pass);
1f96a965e30d09 Yinghai Lu 2013-01-21 502 if (pass && dev->subordinate) {
1f96a965e30d09 Yinghai Lu 2013-01-21 503 check_hotplug_bridge(slot, dev);
d66ecb7220a70e Jiang Liu 2013-06-23 504 pcibios_resource_survey_bus(dev->subordinate);
84c8b58ed3addf Mika Westerberg 2018-05-29 @505 __pci_bus_size_bridges(dev->subordinate,
84c8b58ed3addf Mika Westerberg 2018-05-29 506 &add_list);
c64b5eead93f9d Kristen Accardi 2005-12-14 507 }
42f49a6ae5dca9 Rajesh Shah 2005-04-28 508 }
1f96a965e30d09 Yinghai Lu 2013-01-21 509 }
d66ecb7220a70e Jiang Liu 2013-06-23 @510 __pci_bus_assign_resources(bus, &add_list, NULL);
84c8b58ed3addf Mika Westerberg 2018-05-29 511 }
2dc41281b1d117 Rafael J. Wysocki 2013-09-06 512
8e5dce35221850 Kristen Accardi 2005-10-18 513 acpiphp_sanitize_bus(bus);
81ee57326c9ca6 Bjorn Helgaas 2014-08-28 514 pcie_bus_configure_settings(bus);
d06070509147c9 Shaohua Li 2010-02-25 515 acpiphp_set_acpi_region(slot);
69643e4829c5cd Ian Campbell 2011-05-11 516
69643e4829c5cd Ian Campbell 2011-05-11 517 list_for_each_entry(dev, &bus->devices, bus_list) {
69643e4829c5cd Ian Campbell 2011-05-11 518 /* Assume that newly added devices are powered on already. */
44bda4b7d26e9f Hari Vyas 2018-07-03 519 if (!pci_dev_is_added(dev))
69643e4829c5cd Ian Campbell 2011-05-11 520 dev->current_state = PCI_D0;
69643e4829c5cd Ian Campbell 2011-05-11 521 }
69643e4829c5cd Ian Campbell 2011-05-11 522
42f49a6ae5dca9 Rajesh Shah 2005-04-28 523 pci_bus_add_devices(bus);
42f49a6ae5dca9 Rajesh Shah 2005-04-28 524
f382a086f3129e Amos Kong 2011-11-25 525 slot->flags |= SLOT_ENABLED;
58c08628c4fe66 Alex Chiang 2009-10-26 526 list_for_each_entry(func, &slot->funcs, sibling) {
9d911d7903926a Alex Chiang 2009-05-21 527 dev = pci_get_slot(bus, PCI_DEVFN(slot->device,
^1da177e4c3f41 Linus Torvalds 2005-04-16 528 func->function));
f382a086f3129e Amos Kong 2011-11-25 529 if (!dev) {
f382a086f3129e Amos Kong 2011-11-25 530 /* Do not set SLOT_ENABLED flag if some funcs
f382a086f3129e Amos Kong 2011-11-25 531 are not added. */
9337a493623d59 Mika Westerberg 2018-05-24 532 slot->flags &= ~SLOT_ENABLED;
551bcb75b3d9f2 MUNEDA Takahiro 2006-03-22 533 continue;
f382a086f3129e Amos Kong 2011-11-25 534 }
3bbfd319034ddc Feilong Lin 2021-03-25 535 pci_dev_put(dev);
^1da177e4c3f41 Linus Torvalds 2005-04-16 536 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 537 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 538
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 42097 bytes --]
^ permalink raw reply
* Re: [PATCH v2] ftrace: Cleanup ftrace_dyn_arch_init()
From: Helge Deller @ 2021-09-06 20:36 UTC (permalink / raw)
To: Weizhao Ouyang, Steven Rostedt, Ingo Molnar
Cc: Rich Felker, linux-ia64, linux-sh, linux-mips,
James E.J. Bottomley, Guo Ren, H. Peter Anvin, sparclinux,
linux-riscv, Vincent Chen, Will Deacon, linux-s390,
Yoshinori Sato, x86, Russell King, linux-csky,
Christian Borntraeger, Catalin Marinas, Albert Ou, Vasily Gorbik,
Heiko Carstens, Borislav Petkov, Greentime Hu, Paul Walmsley,
Thomas Gleixner, linux-arm-kernel, Michal Simek,
Thomas Bogendoerfer, linux-parisc, Nick Hu, linux-kernel,
Palmer Dabbelt, Paul Mackerras, linuxppc-dev, David S. Miller
In-Reply-To: <20210906111626.1259867-1-o451686892@gmail.com>
On 9/6/21 1:16 PM, Weizhao Ouyang wrote:
> Most of ARCHs use empty ftrace_dyn_arch_init(), introduce a weak common
> ftrace_dyn_arch_init() to cleanup them.
>
> Signed-off-by: Weizhao Ouyang <o451686892@gmail.com>
> Acked-by: Heiko Carstens <hca@linux.ibm.com> (s390)
Acked-by: Helge Deller <deller@gmx.de> # parisc
Thanks,
Helge
> ---
>
> Changes in v2:
> -- correct CONFIG_DYNAMIC_FTRACE on PowerPC
> -- add Acked-by tag
>
> ---
> arch/arm/kernel/ftrace.c | 5 -----
> arch/arm64/kernel/ftrace.c | 5 -----
> arch/csky/kernel/ftrace.c | 5 -----
> arch/ia64/kernel/ftrace.c | 6 ------
> arch/microblaze/kernel/ftrace.c | 5 -----
> arch/mips/include/asm/ftrace.h | 2 ++
> arch/nds32/kernel/ftrace.c | 5 -----
> arch/parisc/kernel/ftrace.c | 5 -----
> arch/powerpc/include/asm/ftrace.h | 4 ++++
> arch/riscv/kernel/ftrace.c | 5 -----
> arch/s390/kernel/ftrace.c | 5 -----
> arch/sh/kernel/ftrace.c | 5 -----
> arch/sparc/kernel/ftrace.c | 5 -----
> arch/x86/kernel/ftrace.c | 5 -----
> include/linux/ftrace.h | 1 -
> kernel/trace/ftrace.c | 5 +++++
> 16 files changed, 11 insertions(+), 62 deletions(-)
>
> diff --git a/arch/arm/kernel/ftrace.c b/arch/arm/kernel/ftrace.c
> index 3c83b5d29697..a006585e1c09 100644
> --- a/arch/arm/kernel/ftrace.c
> +++ b/arch/arm/kernel/ftrace.c
> @@ -193,11 +193,6 @@ int ftrace_make_nop(struct module *mod,
>
> return ret;
> }
> -
> -int __init ftrace_dyn_arch_init(void)
> -{
> - return 0;
> -}
> #endif /* CONFIG_DYNAMIC_FTRACE */
>
> #ifdef CONFIG_FUNCTION_GRAPH_TRACER
> diff --git a/arch/arm64/kernel/ftrace.c b/arch/arm64/kernel/ftrace.c
> index 7f467bd9db7a..fc62dfe73f93 100644
> --- a/arch/arm64/kernel/ftrace.c
> +++ b/arch/arm64/kernel/ftrace.c
> @@ -236,11 +236,6 @@ void arch_ftrace_update_code(int command)
> command |= FTRACE_MAY_SLEEP;
> ftrace_modify_all_code(command);
> }
> -
> -int __init ftrace_dyn_arch_init(void)
> -{
> - return 0;
> -}
> #endif /* CONFIG_DYNAMIC_FTRACE */
>
> #ifdef CONFIG_FUNCTION_GRAPH_TRACER
> diff --git a/arch/csky/kernel/ftrace.c b/arch/csky/kernel/ftrace.c
> index b4a7ec1517ff..50bfcf129078 100644
> --- a/arch/csky/kernel/ftrace.c
> +++ b/arch/csky/kernel/ftrace.c
> @@ -133,11 +133,6 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
> (unsigned long)func, true, true);
> return ret;
> }
> -
> -int __init ftrace_dyn_arch_init(void)
> -{
> - return 0;
> -}
> #endif /* CONFIG_DYNAMIC_FTRACE */
>
> #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
> diff --git a/arch/ia64/kernel/ftrace.c b/arch/ia64/kernel/ftrace.c
> index b2ab2d58fb30..d6360fd404ab 100644
> --- a/arch/ia64/kernel/ftrace.c
> +++ b/arch/ia64/kernel/ftrace.c
> @@ -194,9 +194,3 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
> flush_icache_range(addr, addr + 16);
> return 0;
> }
> -
> -/* run from kstop_machine */
> -int __init ftrace_dyn_arch_init(void)
> -{
> - return 0;
> -}
> diff --git a/arch/microblaze/kernel/ftrace.c b/arch/microblaze/kernel/ftrace.c
> index 224eea40e1ee..188749d62709 100644
> --- a/arch/microblaze/kernel/ftrace.c
> +++ b/arch/microblaze/kernel/ftrace.c
> @@ -163,11 +163,6 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
> return ret;
> }
>
> -int __init ftrace_dyn_arch_init(void)
> -{
> - return 0;
> -}
> -
> int ftrace_update_ftrace_func(ftrace_func_t func)
> {
> unsigned long ip = (unsigned long)(&ftrace_call);
> diff --git a/arch/mips/include/asm/ftrace.h b/arch/mips/include/asm/ftrace.h
> index b463f2aa5a61..ed013e767390 100644
> --- a/arch/mips/include/asm/ftrace.h
> +++ b/arch/mips/include/asm/ftrace.h
> @@ -76,6 +76,8 @@ do { \
>
>
> #ifdef CONFIG_DYNAMIC_FTRACE
> +int __init ftrace_dyn_arch_init(void);
> +
> static inline unsigned long ftrace_call_adjust(unsigned long addr)
> {
> return addr;
> diff --git a/arch/nds32/kernel/ftrace.c b/arch/nds32/kernel/ftrace.c
> index 0e23e3a8df6b..f0ef4842d191 100644
> --- a/arch/nds32/kernel/ftrace.c
> +++ b/arch/nds32/kernel/ftrace.c
> @@ -84,11 +84,6 @@ void _ftrace_caller(unsigned long parent_ip)
> /* restore all state needed by the compiler epilogue */
> }
>
> -int __init ftrace_dyn_arch_init(void)
> -{
> - return 0;
> -}
> -
> static unsigned long gen_sethi_insn(unsigned long addr)
> {
> unsigned long opcode = 0x46000000;
> diff --git a/arch/parisc/kernel/ftrace.c b/arch/parisc/kernel/ftrace.c
> index 0a1e75af5382..01581f715737 100644
> --- a/arch/parisc/kernel/ftrace.c
> +++ b/arch/parisc/kernel/ftrace.c
> @@ -94,11 +94,6 @@ int ftrace_disable_ftrace_graph_caller(void)
> #endif
>
> #ifdef CONFIG_DYNAMIC_FTRACE
> -
> -int __init ftrace_dyn_arch_init(void)
> -{
> - return 0;
> -}
> int ftrace_update_ftrace_func(ftrace_func_t func)
> {
> return 0;
> diff --git a/arch/powerpc/include/asm/ftrace.h b/arch/powerpc/include/asm/ftrace.h
> index debe8c4f7062..d59f67c0225f 100644
> --- a/arch/powerpc/include/asm/ftrace.h
> +++ b/arch/powerpc/include/asm/ftrace.h
> @@ -61,6 +61,10 @@ struct dyn_arch_ftrace {
> };
> #endif /* __ASSEMBLY__ */
>
> +#ifdef CONFIG_DYNAMIC_FTRACE
> +int __init ftrace_dyn_arch_init(void);
> +#endif /* CONFIG_DYNAMIC_FTRACE */
> +
> #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
> #define ARCH_SUPPORTS_FTRACE_OPS 1
> #endif
> diff --git a/arch/riscv/kernel/ftrace.c b/arch/riscv/kernel/ftrace.c
> index 7f1e5203de88..4716f4cdc038 100644
> --- a/arch/riscv/kernel/ftrace.c
> +++ b/arch/riscv/kernel/ftrace.c
> @@ -154,11 +154,6 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
>
> return ret;
> }
> -
> -int __init ftrace_dyn_arch_init(void)
> -{
> - return 0;
> -}
> #endif
>
> #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
> diff --git a/arch/s390/kernel/ftrace.c b/arch/s390/kernel/ftrace.c
> index 0a464d328467..3fd80397ff52 100644
> --- a/arch/s390/kernel/ftrace.c
> +++ b/arch/s390/kernel/ftrace.c
> @@ -262,11 +262,6 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
> return 0;
> }
>
> -int __init ftrace_dyn_arch_init(void)
> -{
> - return 0;
> -}
> -
> void arch_ftrace_update_code(int command)
> {
> if (ftrace_shared_hotpatch_trampoline(NULL))
> diff --git a/arch/sh/kernel/ftrace.c b/arch/sh/kernel/ftrace.c
> index 295c43315bbe..930001bb8c6a 100644
> --- a/arch/sh/kernel/ftrace.c
> +++ b/arch/sh/kernel/ftrace.c
> @@ -252,11 +252,6 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
>
> return ftrace_modify_code(rec->ip, old, new);
> }
> -
> -int __init ftrace_dyn_arch_init(void)
> -{
> - return 0;
> -}
> #endif /* CONFIG_DYNAMIC_FTRACE */
>
> #ifdef CONFIG_FUNCTION_GRAPH_TRACER
> diff --git a/arch/sparc/kernel/ftrace.c b/arch/sparc/kernel/ftrace.c
> index 684b84ce397f..eaead3da8e03 100644
> --- a/arch/sparc/kernel/ftrace.c
> +++ b/arch/sparc/kernel/ftrace.c
> @@ -82,11 +82,6 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
> new = ftrace_call_replace(ip, (unsigned long)func);
> return ftrace_modify_code(ip, old, new);
> }
> -
> -int __init ftrace_dyn_arch_init(void)
> -{
> - return 0;
> -}
> #endif
>
> #ifdef CONFIG_FUNCTION_GRAPH_TRACER
> diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
> index 1b3ce3b4a2a2..23d221a9a3cd 100644
> --- a/arch/x86/kernel/ftrace.c
> +++ b/arch/x86/kernel/ftrace.c
> @@ -252,11 +252,6 @@ void arch_ftrace_update_code(int command)
> ftrace_modify_all_code(command);
> }
>
> -int __init ftrace_dyn_arch_init(void)
> -{
> - return 0;
> -}
> -
> /* Currently only x86_64 supports dynamic trampolines */
> #ifdef CONFIG_X86_64
>
> diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
> index 832e65f06754..f1eca123d89d 100644
> --- a/include/linux/ftrace.h
> +++ b/include/linux/ftrace.h
> @@ -573,7 +573,6 @@ ftrace_set_early_filter(struct ftrace_ops *ops, char *buf, int enable);
>
> /* defined in arch */
> extern int ftrace_ip_converted(unsigned long ip);
> -extern int ftrace_dyn_arch_init(void);
> extern void ftrace_replace_code(int enable);
> extern int ftrace_update_ftrace_func(ftrace_func_t func);
> extern void ftrace_caller(void);
> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> index 7efbc8aaf7f6..4c090323198d 100644
> --- a/kernel/trace/ftrace.c
> +++ b/kernel/trace/ftrace.c
> @@ -6846,6 +6846,11 @@ void __init ftrace_free_init_mem(void)
> ftrace_free_mem(NULL, start, end);
> }
>
> +int __init __weak ftrace_dyn_arch_init(void)
> +{
> + return 0;
> +}
> +
> void __init ftrace_init(void)
> {
> extern unsigned long __start_mcount_loc[];
>
^ permalink raw reply
* Re: [PATCH v2] ftrace: Cleanup ftrace_dyn_arch_init()
From: Weizhao Ouyang @ 2021-09-06 14:57 UTC (permalink / raw)
To: Michael Ellerman, Steven Rostedt, Ingo Molnar
Cc: Rich Felker, linux-ia64, linux-sh, Catalin Marinas, linux-mips,
James E.J. Bottomley, Guo Ren, H. Peter Anvin, sparclinux,
linux-riscv, Vincent Chen, Will Deacon, linux-s390,
Yoshinori Sato, Helge Deller, x86, Russell King, linux-csky,
Christian Borntraeger, Albert Ou, Vasily Gorbik, Heiko Carstens,
Borislav Petkov, Greentime Hu, Paul Walmsley, Thomas Gleixner,
linux-arm-kernel, Michal Simek, Thomas Bogendoerfer, linux-parisc,
Nick Hu, linux-kernel, Palmer Dabbelt, Paul Mackerras,
linuxppc-dev, David S. Miller
In-Reply-To: <87v93dn5qh.fsf@mpe.ellerman.id.au>
On 2021/9/6 22:22, Michael Ellerman wrote:
> Weizhao Ouyang <o451686892@gmail.com> writes:
>> Most of ARCHs use empty ftrace_dyn_arch_init(), introduce a weak common
>> ftrace_dyn_arch_init() to cleanup them.
>>
>> Signed-off-by: Weizhao Ouyang <o451686892@gmail.com>
>> Acked-by: Heiko Carstens <hca@linux.ibm.com> (s390)
>>
>> ---
>>
>> Changes in v2:
>> -- correct CONFIG_DYNAMIC_FTRACE on PowerPC
>> -- add Acked-by tag
>> diff --git a/arch/powerpc/include/asm/ftrace.h b/arch/powerpc/include/asm/ftrace.h
>> index debe8c4f7062..d59f67c0225f 100644
>> --- a/arch/powerpc/include/asm/ftrace.h
>> +++ b/arch/powerpc/include/asm/ftrace.h
>> @@ -61,6 +61,10 @@ struct dyn_arch_ftrace {
>> };
>> #endif /* __ASSEMBLY__ */
>>
>> +#ifdef CONFIG_DYNAMIC_FTRACE
>> +int __init ftrace_dyn_arch_init(void);
>> +#endif /* CONFIG_DYNAMIC_FTRACE */
>> +
>> #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
>> #define ARCH_SUPPORTS_FTRACE_OPS 1
>> #endif
> That breaks the build for powerpc:
>
> /linux/arch/powerpc/include/asm/ftrace.h: Assembler messages:
> /linux/arch/powerpc/include/asm/ftrace.h:65: Error: unrecognized opcode: `int'
> make[4]: *** [/linux/scripts/Makefile.build:352: arch/powerpc/kernel/trace/ftrace_64.o] Error 1
> make[3]: *** [/linux/scripts/Makefile.build:514: arch/powerpc/kernel/trace] Error 2
> make[2]: *** [/linux/scripts/Makefile.build:514: arch/powerpc/kernel] Error 2
> make[1]: *** [/linux/Makefile:1861: arch/powerpc] Error 2
> make[1]: *** Waiting for unfinished jobs....
>
> It needs to be inside an #ifndef __ASSEMBLY__ section.
>
> cheers
Thanks for reply, I'll fix it up.
^ permalink raw reply
* Re: [PATCH v2] ftrace: Cleanup ftrace_dyn_arch_init()
From: Michael Ellerman @ 2021-09-06 14:22 UTC (permalink / raw)
To: Weizhao Ouyang, Steven Rostedt, Ingo Molnar
Cc: Rich Felker, linux-ia64, linux-sh, Catalin Marinas, linux-mips,
James E.J. Bottomley, Guo Ren, H. Peter Anvin, sparclinux,
linux-riscv, Vincent Chen, Will Deacon, linux-s390,
Yoshinori Sato, Helge Deller, x86, Russell King, linux-csky,
Christian Borntraeger, Albert Ou, Weizhao Ouyang, Vasily Gorbik,
Heiko Carstens, Borislav Petkov, Greentime Hu, Paul Walmsley,
Thomas Gleixner, linux-arm-kernel, Michal Simek,
Thomas Bogendoerfer, linux-parisc, Nick Hu, linux-kernel,
Palmer Dabbelt, Paul Mackerras, linuxppc-dev, David S. Miller
In-Reply-To: <20210906111626.1259867-1-o451686892@gmail.com>
Weizhao Ouyang <o451686892@gmail.com> writes:
> Most of ARCHs use empty ftrace_dyn_arch_init(), introduce a weak common
> ftrace_dyn_arch_init() to cleanup them.
>
> Signed-off-by: Weizhao Ouyang <o451686892@gmail.com>
> Acked-by: Heiko Carstens <hca@linux.ibm.com> (s390)
>
> ---
>
> Changes in v2:
> -- correct CONFIG_DYNAMIC_FTRACE on PowerPC
> -- add Acked-by tag
> diff --git a/arch/powerpc/include/asm/ftrace.h b/arch/powerpc/include/asm/ftrace.h
> index debe8c4f7062..d59f67c0225f 100644
> --- a/arch/powerpc/include/asm/ftrace.h
> +++ b/arch/powerpc/include/asm/ftrace.h
> @@ -61,6 +61,10 @@ struct dyn_arch_ftrace {
> };
> #endif /* __ASSEMBLY__ */
>
> +#ifdef CONFIG_DYNAMIC_FTRACE
> +int __init ftrace_dyn_arch_init(void);
> +#endif /* CONFIG_DYNAMIC_FTRACE */
> +
> #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
> #define ARCH_SUPPORTS_FTRACE_OPS 1
> #endif
That breaks the build for powerpc:
/linux/arch/powerpc/include/asm/ftrace.h: Assembler messages:
/linux/arch/powerpc/include/asm/ftrace.h:65: Error: unrecognized opcode: `int'
make[4]: *** [/linux/scripts/Makefile.build:352: arch/powerpc/kernel/trace/ftrace_64.o] Error 1
make[3]: *** [/linux/scripts/Makefile.build:514: arch/powerpc/kernel/trace] Error 2
make[2]: *** [/linux/scripts/Makefile.build:514: arch/powerpc/kernel] Error 2
make[1]: *** [/linux/Makefile:1861: arch/powerpc] Error 2
make[1]: *** Waiting for unfinished jobs....
It needs to be inside an #ifndef __ASSEMBLY__ section.
cheers
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox