diff mbox series

of: Add OF_DMA_DEFAULT_COHERENT & select it on powerpc

Message ID 20200126115247.13402-1-mpe@ellerman.id.au (mailing list archive)
State Accepted
Headers show
Series of: Add OF_DMA_DEFAULT_COHERENT & select it on powerpc | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch powerpc/merge (b43d1d8a77b5d5d82f8930aa5b101378df00ccca)
snowpatch_ozlabs/build-ppc64le success Build succeeded
snowpatch_ozlabs/build-ppc64be success Build succeeded
snowpatch_ozlabs/build-ppc64e success Build succeeded
snowpatch_ozlabs/build-pmac32 success Build succeeded
snowpatch_ozlabs/checkpatch success total: 0 errors, 0 warnings, 0 checks, 32 lines checked
snowpatch_ozlabs/needsstable success Patch is tagged for stable

Commit Message

Michael Ellerman Jan. 26, 2020, 11:52 a.m. UTC
There's an OF helper called of_dma_is_coherent(), which checks if a
device has a "dma-coherent" property to see if the device is coherent
for DMA.

But on some platforms devices are coherent by default, and on some
platforms it's not possible to update existing device trees to add the
"dma-coherent" property.

So add a Kconfig symbol to allow arch code to tell
of_dma_is_coherent() that devices are coherent by default, regardless
of the presence of the property.

Select that symbol on powerpc when NOT_COHERENT_CACHE is not set, ie.
when the system has a coherent cache.

Fixes: 92ea637edea3 ("of: introduce of_dma_is_coherent() helper")
Cc: stable@vger.kernel.org # v3.16+
Reported-by: Christian Zigotzky <chzigotzky@xenosoft.de>
Tested-by: Christian Zigotzky <chzigotzky@xenosoft.de>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/Kconfig | 1 +
 drivers/of/Kconfig   | 4 ++++
 drivers/of/address.c | 6 +++++-
 3 files changed, 10 insertions(+), 1 deletion(-)

Comments

Ulf Hansson Jan. 27, 2020, 7:22 a.m. UTC | #1
On Sun, 26 Jan 2020 at 12:53, Michael Ellerman <mpe@ellerman.id.au> wrote:
>
> There's an OF helper called of_dma_is_coherent(), which checks if a
> device has a "dma-coherent" property to see if the device is coherent
> for DMA.
>
> But on some platforms devices are coherent by default, and on some
> platforms it's not possible to update existing device trees to add the
> "dma-coherent" property.
>
> So add a Kconfig symbol to allow arch code to tell
> of_dma_is_coherent() that devices are coherent by default, regardless
> of the presence of the property.
>
> Select that symbol on powerpc when NOT_COHERENT_CACHE is not set, ie.
> when the system has a coherent cache.
>
> Fixes: 92ea637edea3 ("of: introduce of_dma_is_coherent() helper")
> Cc: stable@vger.kernel.org # v3.16+
> Reported-by: Christian Zigotzky <chzigotzky@xenosoft.de>
> Tested-by: Christian Zigotzky <chzigotzky@xenosoft.de>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

Thanks Michael for helping out fixing and this! The patch looks good to me.

Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>

Kind regards
Uffe

> ---
>  arch/powerpc/Kconfig | 1 +
>  drivers/of/Kconfig   | 4 ++++
>  drivers/of/address.c | 6 +++++-
>  3 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index 1ec34e16ed65..19f5aa8ac9a3 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -238,6 +238,7 @@ config PPC
>         select NEED_DMA_MAP_STATE               if PPC64 || NOT_COHERENT_CACHE
>         select NEED_SG_DMA_LENGTH
>         select OF
> +       select OF_DMA_DEFAULT_COHERENT          if !NOT_COHERENT_CACHE
>         select OF_EARLY_FLATTREE
>         select OLD_SIGACTION                    if PPC32
>         select OLD_SIGSUSPEND
> diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
> index 37c2ccbefecd..d91618641be6 100644
> --- a/drivers/of/Kconfig
> +++ b/drivers/of/Kconfig
> @@ -103,4 +103,8 @@ config OF_OVERLAY
>  config OF_NUMA
>         bool
>
> +config OF_DMA_DEFAULT_COHERENT
> +       # arches should select this if DMA is coherent by default for OF devices
> +       bool
> +
>  endif # OF
> diff --git a/drivers/of/address.c b/drivers/of/address.c
> index 99c1b8058559..e8a39c3ec4d4 100644
> --- a/drivers/of/address.c
> +++ b/drivers/of/address.c
> @@ -995,12 +995,16 @@ int of_dma_get_range(struct device_node *np, u64 *dma_addr, u64 *paddr, u64 *siz
>   * @np:        device node
>   *
>   * It returns true if "dma-coherent" property was found
> - * for this device in DT.
> + * for this device in the DT, or if DMA is coherent by
> + * default for OF devices on the current platform.
>   */
>  bool of_dma_is_coherent(struct device_node *np)
>  {
>         struct device_node *node = of_node_get(np);
>
> +       if (IS_ENABLED(CONFIG_OF_DMA_DEFAULT_COHERENT))
> +               return true;
> +
>         while (node) {
>                 if (of_property_read_bool(node, "dma-coherent")) {
>                         of_node_put(node);
> --
> 2.21.1
>
Frank Rowand Jan. 27, 2020, 5:30 p.m. UTC | #2
+ Frank (me)

On 1/26/20 5:52 AM, Michael Ellerman wrote:
> There's an OF helper called of_dma_is_coherent(), which checks if a
> device has a "dma-coherent" property to see if the device is coherent
> for DMA.
> 
> But on some platforms devices are coherent by default, and on some
> platforms it's not possible to update existing device trees to add the
> "dma-coherent" property.
> 
> So add a Kconfig symbol to allow arch code to tell
> of_dma_is_coherent() that devices are coherent by default, regardless
> of the presence of the property.
> 
> Select that symbol on powerpc when NOT_COHERENT_CACHE is not set, ie.
> when the system has a coherent cache.
> 
> Fixes: 92ea637edea3 ("of: introduce of_dma_is_coherent() helper")
> Cc: stable@vger.kernel.org # v3.16+
> Reported-by: Christian Zigotzky <chzigotzky@xenosoft.de>
> Tested-by: Christian Zigotzky <chzigotzky@xenosoft.de>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> ---
>  arch/powerpc/Kconfig | 1 +
>  drivers/of/Kconfig   | 4 ++++
>  drivers/of/address.c | 6 +++++-
>  3 files changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index 1ec34e16ed65..19f5aa8ac9a3 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -238,6 +238,7 @@ config PPC
>  	select NEED_DMA_MAP_STATE		if PPC64 || NOT_COHERENT_CACHE
>  	select NEED_SG_DMA_LENGTH
>  	select OF
> +	select OF_DMA_DEFAULT_COHERENT		if !NOT_COHERENT_CACHE
>  	select OF_EARLY_FLATTREE
>  	select OLD_SIGACTION			if PPC32
>  	select OLD_SIGSUSPEND
> diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
> index 37c2ccbefecd..d91618641be6 100644
> --- a/drivers/of/Kconfig
> +++ b/drivers/of/Kconfig
> @@ -103,4 +103,8 @@ config OF_OVERLAY
>  config OF_NUMA
>  	bool
>  
> +config OF_DMA_DEFAULT_COHERENT
> +	# arches should select this if DMA is coherent by default for OF devices
> +	bool
> +
>  endif # OF
> diff --git a/drivers/of/address.c b/drivers/of/address.c
> index 99c1b8058559..e8a39c3ec4d4 100644
> --- a/drivers/of/address.c
> +++ b/drivers/of/address.c
> @@ -995,12 +995,16 @@ int of_dma_get_range(struct device_node *np, u64 *dma_addr, u64 *paddr, u64 *siz
>   * @np:	device node
>   *
>   * It returns true if "dma-coherent" property was found
> - * for this device in DT.
> + * for this device in the DT, or if DMA is coherent by
> + * default for OF devices on the current platform.
>   */
>  bool of_dma_is_coherent(struct device_node *np)
>  {
>  	struct device_node *node = of_node_get(np);
>  
> +	if (IS_ENABLED(CONFIG_OF_DMA_DEFAULT_COHERENT))
> +		return true;
> +
>  	while (node) {
>  		if (of_property_read_bool(node, "dma-coherent")) {
>  			of_node_put(node);
>
Rob Herring Jan. 28, 2020, 2:26 p.m. UTC | #3
On Sun, 26 Jan 2020 22:52:47 +1100, Michael Ellerman wrote:
> There's an OF helper called of_dma_is_coherent(), which checks if a
> device has a "dma-coherent" property to see if the device is coherent
> for DMA.
> 
> But on some platforms devices are coherent by default, and on some
> platforms it's not possible to update existing device trees to add the
> "dma-coherent" property.
> 
> So add a Kconfig symbol to allow arch code to tell
> of_dma_is_coherent() that devices are coherent by default, regardless
> of the presence of the property.
> 
> Select that symbol on powerpc when NOT_COHERENT_CACHE is not set, ie.
> when the system has a coherent cache.
> 
> Fixes: 92ea637edea3 ("of: introduce of_dma_is_coherent() helper")
> Cc: stable@vger.kernel.org # v3.16+
> Reported-by: Christian Zigotzky <chzigotzky@xenosoft.de>
> Tested-by: Christian Zigotzky <chzigotzky@xenosoft.de>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> ---
>  arch/powerpc/Kconfig | 1 +
>  drivers/of/Kconfig   | 4 ++++
>  drivers/of/address.c | 6 +++++-
>  3 files changed, 10 insertions(+), 1 deletion(-)
> 

Applied, thanks.

Rob
Michael Ellerman Jan. 31, 2020, 10:40 a.m. UTC | #4
Ulf Hansson <ulf.hansson@linaro.org> writes:
> On Sun, 26 Jan 2020 at 12:53, Michael Ellerman <mpe@ellerman.id.au> wrote:
>> There's an OF helper called of_dma_is_coherent(), which checks if a
>> device has a "dma-coherent" property to see if the device is coherent
>> for DMA.
>>
>> But on some platforms devices are coherent by default, and on some
>> platforms it's not possible to update existing device trees to add the
>> "dma-coherent" property.
>>
>> So add a Kconfig symbol to allow arch code to tell
>> of_dma_is_coherent() that devices are coherent by default, regardless
>> of the presence of the property.
>>
>> Select that symbol on powerpc when NOT_COHERENT_CACHE is not set, ie.
>> when the system has a coherent cache.
>>
>> Fixes: 92ea637edea3 ("of: introduce of_dma_is_coherent() helper")
>> Cc: stable@vger.kernel.org # v3.16+
>> Reported-by: Christian Zigotzky <chzigotzky@xenosoft.de>
>> Tested-by: Christian Zigotzky <chzigotzky@xenosoft.de>
>> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
>
> Thanks Michael for helping out fixing and this! The patch looks good to me.
>
> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>

Thanks for the review.

cheers
Michael Ellerman Jan. 31, 2020, 10:40 a.m. UTC | #5
Rob Herring <robh@kernel.org> writes:
> On Sun, 26 Jan 2020 22:52:47 +1100, Michael Ellerman wrote:
>> There's an OF helper called of_dma_is_coherent(), which checks if a
>> device has a "dma-coherent" property to see if the device is coherent
>> for DMA.
>> 
>> But on some platforms devices are coherent by default, and on some
>> platforms it's not possible to update existing device trees to add the
>> "dma-coherent" property.
>> 
>> So add a Kconfig symbol to allow arch code to tell
>> of_dma_is_coherent() that devices are coherent by default, regardless
>> of the presence of the property.
>> 
>> Select that symbol on powerpc when NOT_COHERENT_CACHE is not set, ie.
>> when the system has a coherent cache.
>> 
>> Fixes: 92ea637edea3 ("of: introduce of_dma_is_coherent() helper")
>> Cc: stable@vger.kernel.org # v3.16+
>> Reported-by: Christian Zigotzky <chzigotzky@xenosoft.de>
>> Tested-by: Christian Zigotzky <chzigotzky@xenosoft.de>
>> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
>> ---
>>  arch/powerpc/Kconfig | 1 +
>>  drivers/of/Kconfig   | 4 ++++
>>  drivers/of/address.c | 6 +++++-
>>  3 files changed, 10 insertions(+), 1 deletion(-)
>> 
>
> Applied, thanks.

Thanks.

cheers
Christian Zigotzky Feb. 2, 2020, 12:08 a.m. UTC | #6
Hello,

We regularly compile and test Linux kernels every day during the merge 
window. Since Thuesday we have very high CPU loads because of the avahi 
daemon on our desktop Linux systems (Ubuntu, Debian etc).

Error message: avahi-daemon[2410]: ioctl(): Inappropriate ioctl for device

Could you please test the latest Git kernel?

It is possible to deactivate the avahi daemon with the following lines 
in the file "/etc/avahi/avahi-daemon.conf":

use-ipv4=no
use-ipv6=no

But this is only a temporary solution.

Thanks,
Christian
Randy Dunlap Feb. 2, 2020, 4:37 a.m. UTC | #7
[might be network related, so adding netdev mailing list]

On 2/1/20 4:08 PM, Christian Zigotzky wrote:
> Hello,
> 
> We regularly compile and test Linux kernels every day during the merge window. Since Thuesday we have very high CPU loads because of the avahi daemon on our desktop Linux systems (Ubuntu, Debian etc).
> 
> Error message: avahi-daemon[2410]: ioctl(): Inappropriate ioctl for device
> 
> Could you please test the latest Git kernel?
> 
> It is possible to deactivate the avahi daemon with the following lines in the file "/etc/avahi/avahi-daemon.conf":
> 
> use-ipv4=no
> use-ipv6=no
> 
> But this is only a temporary solution.
> 
> Thanks,
> Christian
Christophe Leroy Feb. 2, 2020, 8:19 a.m. UTC | #8
Hello,

Le 02/02/2020 à 01:08, Christian Zigotzky a écrit :
> Hello,
> 
> We regularly compile and test Linux kernels every day during the merge 
> window. Since Thuesday we have very high CPU loads because of the avahi 
> daemon on our desktop Linux systems (Ubuntu, Debian etc).
> 
> Error message: avahi-daemon[2410]: ioctl(): Inappropriate ioctl for device

Do you know which ioctl, on which device ?
Can you take a trace of running avahi-daemon with 'strace' ?

Can you bisect ?

Christophe
Christian Zigotzky Feb. 2, 2020, 3:02 p.m. UTC | #9
On 02 February 2020 at 09:19 am, Christophe Leroy wrote:
> Hello,
>
> Le 02/02/2020 à 01:08, Christian Zigotzky a écrit :
>> Hello,
>>
>> We regularly compile and test Linux kernels every day during the 
>> merge window. Since Thuesday we have very high CPU loads because of 
>> the avahi daemon on our desktop Linux systems (Ubuntu, Debian etc).
>>
>> Error message: avahi-daemon[2410]: ioctl(): Inappropriate ioctl for 
>> device
>
> Do you know which ioctl, on which device ?
> Can you take a trace of running avahi-daemon with 'strace' ?
>
> Can you bisect ?
>
> Christophe
Hi Christophe,
Hi All,

I figured out that the avahi-daemon has a problem with the IPv6 address 
of a network interface since the Git kernel from Thursday. (Log attached)
This generates high CPU usage because the avahi-daemon tries to access 
the IPv6 address again and again and thereby it produces a lot of log 
messages.

We figured out that the networking updates aren't responsible for this 
issue because we created a test kernel on Wednesday. The issue is 
somewhere in the commits from Wednesday night to Thursday (CET).

Please compile the latest Git kernel and test it with a desktop linux 
distribution for example Ubuntu. In my point of view there are many 
desktop machines affected. Many server systems don't use the avahi 
daemon so they aren't affected.

It's possible to deactivate the access to the IPv6 address with the 
following line in the file "/etc/avahi/avahi-daemon.conf":

use-ipv6=no

After a reboot the CPU usage is normal again. This is only a temporary 
solution.

Unfortunately I don't have the time for bisecting next week. I have a 
lot of other work to do. In my point of view it is very important that 
you also compile the latest Git kernels. Then you will see the issue and 
then you have a better possibility to fix the issue.

Thanks,
Christian
Kernel 5.5.0: journalctl | grep -i avahi
Feb 02 13:57:05 DC1 systemd[1]: Listening on Avahi mDNS/DNS-SD Stack Activation Socket.
Feb 02 13:57:05 DC1 systemd[1]: Starting Avahi mDNS/DNS-SD Stack...
Feb 02 13:57:05 DC1 avahi-daemon[4314]: Found user 'avahi' (UID 112) and group 'avahi' (GID 122).
Feb 02 13:57:05 DC1 avahi-daemon[4314]: Successfully dropped root privileges.
Feb 02 13:57:05 DC1 avahi-daemon[4314]: avahi-daemon 0.6.32-rc starting up.
Feb 02 13:57:06 DC1 systemd[1]: Started Avahi DNS Configuration Daemon.
Feb 02 13:57:06 DC1 avahi-daemon[4314]: Successfully called chroot().
Feb 02 13:57:06 DC1 avahi-daemon[4314]: Successfully dropped remaining capabilities.
Feb 02 13:57:06 DC1 avahi-daemon[4314]: No service file found in /etc/avahi/services.
Feb 02 13:57:06 DC1 avahi-daemon[4314]: Network interface enumeration completed.
Feb 02 13:57:06 DC1 avahi-daemon[4314]: Server startup complete. Host name is DC1.local. Local service cookie is 3202921551.
Feb 02 13:57:06 DC1 avahi-daemon[4314]: Failed to parse address 'localhost', ignoring.
Feb 02 13:57:06 DC1 avahi-dnsconfd[4487]: Successfully connected to Avahi daemon.
Feb 02 13:57:06 DC1 systemd[1]: Started Avahi mDNS/DNS-SD Stack.
Feb 02 13:57:07 DC1 root[4749]: /etc/dhcp/dhclient-enter-hooks.d/avahi-autoipd returned non-zero exit status 1
Feb 02 13:57:07 DC1 avahi-daemon[4314]: Joining mDNS multicast group on interface enP4096p4s4.IPv4 with address 192.168.178.47.
Feb 02 13:57:07 DC1 avahi-daemon[4314]: New relevant interface enP4096p4s4.IPv4 for mDNS.
Feb 02 13:57:07 DC1 avahi-daemon[4314]: Registering new address record for 192.168.178.47 on enP4096p4s4.IPv4.
Feb 02 13:57:09 DC1 avahi-daemon[4314]: Joining mDNS multicast group on interface enP4096p4s4.IPv6 with address fe80::250:fcff:fecb:5181.
Feb 02 13:57:09 DC1 avahi-daemon[4314]: New relevant interface enP4096p4s4.IPv6 for mDNS.
Feb 02 13:57:09 DC1 avahi-daemon[4314]: Registering new address record for fe80::250:fcff:fecb:5181 on enP4096p4s4.*.
Feb 02 13:57:10 DC1 avahi-daemon[4314]: Leaving mDNS multicast group on interface enP4096p4s4.IPv6 with address fe80::250:fcff:fecb:5181.
Feb 02 13:57:10 DC1 avahi-daemon[4314]: Joining mDNS multicast group on interface enP4096p4s4.IPv6 with address 2a02:8109:89c0:ebfc:250:fcff:fecb:5181.
Feb 02 13:57:10 DC1 avahi-daemon[4314]: Registering new address record for 2a02:8109:89c0:ebfc:250:fcff:fecb:5181 on enP4096p4s4.*.
Feb 02 13:57:10 DC1 avahi-daemon[4314]: Withdrawing address record for fe80::250:fcff:fecb:5181 on enP4096p4s4.


------


Latest Git kernel (5.6): journalctl | grep -i avahi

Feb 02 14:04:04 DC1 systemd[1]: Listening on Avahi mDNS/DNS-SD Stack Activation Socket.
Feb 02 14:04:05 DC1 systemd[1]: Started Avahi DNS Configuration Daemon.
Feb 02 14:04:05 DC1 systemd[1]: Starting Avahi mDNS/DNS-SD Stack...
Feb 02 14:04:05 DC1 avahi-daemon[4573]: Found user 'avahi' (UID 112) and group 'avahi' (GID 122).
Feb 02 14:04:05 DC1 avahi-daemon[4573]: Successfully dropped root privileges.
Feb 02 14:04:05 DC1 avahi-daemon[4573]: avahi-daemon 0.6.32-rc starting up.
Feb 02 14:04:05 DC1 avahi-daemon[4573]: Successfully called chroot().
Feb 02 14:04:05 DC1 avahi-daemon[4573]: Successfully dropped remaining capabilities.
Feb 02 14:04:05 DC1 avahi-daemon[4573]: No service file found in /etc/avahi/services.
Feb 02 14:04:05 DC1 avahi-daemon[4573]: Network interface enumeration completed.
Feb 02 14:04:05 DC1 avahi-daemon[4573]: Server startup complete. Host name is DC1.local. Local service cookie is 285370789.
Feb 02 14:04:05 DC1 avahi-daemon[4573]: Failed to parse address 'localhost', ignoring.
Feb 02 14:04:05 DC1 avahi-dnsconfd[4425]: Successfully connected to Avahi daemon.
Feb 02 14:04:05 DC1 root[4642]: /etc/dhcp/dhclient-enter-hooks.d/avahi-autoipd returned non-zero exit status 1
Feb 02 14:04:06 DC1 systemd[1]: Started Avahi mDNS/DNS-SD Stack.
Feb 02 14:04:06 DC1 avahi-daemon[4573]: Joining mDNS multicast group on interface enP4096p4s4.IPv4 with address 192.168.178.47.
Feb 02 14:04:06 DC1 avahi-daemon[4573]: New relevant interface enP4096p4s4.IPv4 for mDNS.
Feb 02 14:04:06 DC1 avahi-daemon[4573]: Registering new address record for 192.168.178.47 on enP4096p4s4.IPv4.
Feb 02 14:04:08 DC1 avahi-daemon[4573]: Joining mDNS multicast group on interface enP4096p4s4.IPv6 with address fe80::250:fcff:fecb:5181.
Feb 02 14:04:08 DC1 avahi-daemon[4573]: New relevant interface enP4096p4s4.IPv6 for mDNS.
Feb 02 14:04:08 DC1 avahi-daemon[4573]: Registering new address record for fe80::250:fcff:fecb:5181 on enP4096p4s4.*.
Feb 02 14:04:08 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:08 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:08 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:08 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
...
Feb 02 14:04:08 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:08 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:08 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:08 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:08 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:08 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:08 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:08 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:08 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:08 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:08 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:08 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:08 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:09 DC1 avahi-daemon[4573]: Leaving mDNS multicast group on interface enP4096p4s4.IPv6 with address fe80::250:fcff:fecb:5181.
Feb 02 14:04:09 DC1 avahi-daemon[4573]: Joining mDNS multicast group on interface enP4096p4s4.IPv6 with address 2a02:8109:89c0:ebfc:250:fcff:fecb:5181.
Feb 02 14:04:09 DC1 avahi-daemon[4573]: Registering new address record for 2a02:8109:89c0:ebfc:250:fcff:fecb:5181 on enP4096p4s4.*.
Feb 02 14:04:09 DC1 avahi-daemon[4573]: Withdrawing address record for fe80::250:fcff:fecb:5181 on enP4096p4s4.
Feb 02 14:04:28 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:28 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:28 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:28 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:28 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:28 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
...
Feb 02 14:04:29 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:29 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:29 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:35 DC1 systemd-journald[2489]: Suppressed 513915 messages from /system.slice/avahi-daemon.service
Feb 02 14:04:35 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:35 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:04:35 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device


------


Latest Git kernel (5.6): systemctl status avahi-daemon
● avahi-daemon.service - Avahi mDNS/DNS-SD Stack
   Loaded: loaded (/lib/systemd/system/avahi-daemon.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2020-02-02 14:04:06 CET; 11min ago
 Main PID: 4573 (avahi-daemon)
   Status: "avahi-daemon 0.6.32-rc starting up."
   CGroup: /system.slice/avahi-daemon.service
           ├─4573 avahi-daemon: running [DC1.local]
           └─4581 avahi-daemon: chroot helper

Feb 02 14:15:34 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:15:34 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:15:34 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:15:34 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:15:34 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:15:34 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:15:34 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:15:34 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:15:34 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device
Feb 02 14:15:34 DC1 avahi-daemon[4573]: ioctl(): Inappropriate ioctl for device


------
Jakub Kicinski Feb. 3, 2020, 5:53 p.m. UTC | #10
On Sun, 2 Feb 2020 16:02:18 +0100, Christian Zigotzky wrote:
> On 02 February 2020 at 09:19 am, Christophe Leroy wrote:
> > Hello,
> >
> > Le 02/02/2020 à 01:08, Christian Zigotzky a écrit :  
> >> Hello,
> >>
> >> We regularly compile and test Linux kernels every day during the 
> >> merge window. Since Thuesday we have very high CPU loads because of 
> >> the avahi daemon on our desktop Linux systems (Ubuntu, Debian etc).
> >>
> >> Error message: avahi-daemon[2410]: ioctl(): Inappropriate ioctl for 
> >> device  
> >
> > Do you know which ioctl, on which device ?
> > Can you take a trace of running avahi-daemon with 'strace' ?
> >
> > Can you bisect ?
> >
> > Christophe  
> Hi Christophe,
> Hi All,
> 
> I figured out that the avahi-daemon has a problem with the IPv6 address 
> of a network interface since the Git kernel from Thursday. (Log attached)
> This generates high CPU usage because the avahi-daemon tries to access 
> the IPv6 address again and again and thereby it produces a lot of log 
> messages.
> 
> We figured out that the networking updates aren't responsible for this 
> issue because we created a test kernel on Wednesday. The issue is 
> somewhere in the commits from Wednesday night to Thursday (CET).

FWIW Thursday is when the latest networking pull came in, so could well
be networking related..

> Please compile the latest Git kernel and test it with a desktop linux 
> distribution for example Ubuntu. In my point of view there are many 
> desktop machines affected. Many server systems don't use the avahi 
> daemon so they aren't affected.
> 
> It's possible to deactivate the access to the IPv6 address with the 
> following line in the file "/etc/avahi/avahi-daemon.conf":
> 
> use-ipv6=no
> 
> After a reboot the CPU usage is normal again. This is only a temporary 
> solution.
> 
> Unfortunately I don't have the time for bisecting next week. I have a 
> lot of other work to do. In my point of view it is very important that 
> you also compile the latest Git kernels. Then you will see the issue and 
> then you have a better possibility to fix the issue.
Christian Zigotzky Feb. 5, 2020, 1:03 p.m. UTC | #11
On 03 February 2020 at 6:53 pm, Jakub Kicinski wrote:
> On Sun, 2 Feb 2020 16:02:18 +0100, Christian Zigotzky wrote:
>> On 02 February 2020 at 09:19 am, Christophe Leroy wrote:
>>> Hello,
>>>
>>> Le 02/02/2020 à 01:08, Christian Zigotzky a écrit :
>>>> Hello,
>>>>
>>>> We regularly compile and test Linux kernels every day during the
>>>> merge window. Since Thursday we have very high CPU loads because of
>>>> the avahi daemon on our desktop Linux systems (Ubuntu, Debian etc).
>>>>
>>>> Error message: avahi-daemon[2410]: ioctl(): Inappropriate ioctl for
>>>> device
>>> Do you know which ioctl, on which device ?
>>> Can you take a trace of running avahi-daemon with 'strace' ?
>>>
>>> Can you bisect ?
>>>
>>> Christophe
>> Hi Christophe,
>> Hi All,
>>
>> I figured out that the avahi-daemon has a problem with the IPv6 address
>> of a network interface since the Git kernel from Thursday. (Log attached)
>> This generates high CPU usage because the avahi-daemon tries to access
>> the IPv6 address again and again and thereby it produces a lot of log
>> messages.
>>
>> We figured out that the networking updates aren't responsible for this
>> issue because we created a test kernel on Wednesday. The issue is
>> somewhere in the commits from Wednesday night to Thursday (CET).
> FWIW Thursday is when the latest networking pull came in, so could well
> be networking related..
>
>> Please compile the latest Git kernel and test it with a desktop linux
>> distribution for example Ubuntu. In my point of view there are many
>> desktop machines affected. Many server systems don't use the avahi
>> daemon so they aren't affected.
>>
>> It's possible to deactivate the access to the IPv6 address with the
>> following line in the file "/etc/avahi/avahi-daemon.conf":
>>
>> use-ipv6=no
>>
>> After a reboot the CPU usage is normal again. This is only a temporary
>> solution.
>>
>> Unfortunately I don't have the time for bisecting next week. I have a
>> lot of other work to do. In my point of view it is very important that
>> you also compile the latest Git kernels. Then you will see the issue and
>> then you have a better possibility to fix the issue.
Hi All,

The issue still exist in the latest Git kernel. It's a PowerPC issue. I 
compiled the latest Git kernel on a PC today and there aren't any issues 
with the avahi daemon. Another Power Mac user reported the same issue on 
his G5. I tested with the AmigaOne X1000 and X5000 in the last days.

I bisected today but I think the result isn't correct because it founds 
the other problem with ordering of PCSCSI definition in esp_rev enum. I 
don't know how to bisect if there is another issue at the same time. 
Maybe "git bisect skip"?

2086faae3c55a652cfbd369e18ecdb703aacc493 is the first bad commit
commit 2086faae3c55a652cfbd369e18ecdb703aacc493
Author: Kars de Jong <jongk@linux-m68k.org>
Date:   Tue Nov 19 21:20:20 2019 +0100

     scsi: esp_scsi: Correct ordering of PCSCSI definition in esp_rev enum

     The order of the definitions in the esp_rev enum is important. The 
values
     are used in comparisons for chip features.

     Add a comment to the enum explaining this.

     Also, the actual values for the enum fields are irrelevant, so 
remove the
     explicit values (suggested by Geert Uytterhoeven). This makes 
adding a new
     field in the middle of the enum easier.

     Finally, move the PCSCSI definition to the right place in the enum. 
In its
     previous location, at the end of the enum, the wrong values are 
written to
     the CONFIG3 register when used with FAST-SCSI targets.

     Link: 
https://lore.kernel.org/r/20191119202021.28720-2-jongk@linux-m68k.org
     Signed-off-by: Kars de Jong <jongk@linux-m68k.org>
     Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

:040000 040000 cdc128596e33fb60406b5de9b17b79623c187c1a 
48ceab06439f95285e8b30181e75f9a68c25fcb5 M    drivers

Cheers,
Christian
Christian Zigotzky Feb. 5, 2020, 2:36 p.m. UTC | #12
Kernel 5.5 PowerPC is also affected.

— Christian

Christian Zigotzky wrote:

Hi All,

The issue with the avahi-daemon still exist in the latest Git kernel. It's a PowerPC issue. I compiled the latest Git kernel on a PC today and there aren't any issues with the avahi daemon. Another Power Mac user reported the same issue on his G5. I tested with the AmigaOne X1000 and X5000 in the last days.

I bisected today but I think the result isn't correct because it found the other problem with ordering of PCSCSI definition in esp_rev enum. I don't know how to bisect if there is another issue at the same time. Maybe "git bisect skip"?

2086faae3c55a652cfbd369e18ecdb703aacc493 is the first bad commit
commit 2086faae3c55a652cfbd369e18ecdb703aacc493
Author: Kars de Jong <jongk@linux-m68k.org>
Date:   Tue Nov 19 21:20:20 2019 +0100

    scsi: esp_scsi: Correct ordering of PCSCSI definition in esp_rev enum

    The order of the definitions in the esp_rev enum is important. The values
    are used in comparisons for chip features.

    Add a comment to the enum explaining this.

    Also, the actual values for the enum fields are irrelevant, so remove the
    explicit values (suggested by Geert Uytterhoeven). This makes adding a new
    field in the middle of the enum easier.

    Finally, move the PCSCSI definition to the right place in the enum. In its
    previous location, at the end of the enum, the wrong values are written to
    the CONFIG3 register when used with FAST-SCSI targets.

    Link: https://lore.kernel.org/r/20191119202021.28720-2-jongk@linux-m68k.org
    Signed-off-by: Kars de Jong <jongk@linux-m68k.org>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

:040000 040000 cdc128596e33fb60406b5de9b17b79623c187c1a 48ceab06439f95285e8b30181e75f9a68c25fcb5 M    drivers
Michael Ellerman Feb. 6, 2020, 4:35 a.m. UTC | #13
Christian Zigotzky <chzigotzky@xenosoft.de> writes:
> Kernel 5.5 PowerPC is also affected.

I don't know what you mean by that. What sha are you talking about?

I have a system with avahi running and everything's fine.

  # grep use- /etc/avahi/avahi-daemon.conf 
  use-ipv4=yes
  use-ipv6=yes
  
  # systemctl status -l --no-pager avahi-daemon
  ● avahi-daemon.service - Avahi mDNS/DNS-SD Stack
     Loaded: loaded (/lib/systemd/system/avahi-daemon.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2020-02-06 14:55:34 AEDT; 38min ago
   Main PID: 1884 (avahi-daemon)
     Status: "avahi-daemon 0.7 starting up."
     CGroup: /system.slice/avahi-daemon.service
             ├─1884 avahi-daemon: running [mpe-ubuntu-le.local]
             └─1888 avahi-daemon: chroot helper
  
  Feb 06 14:55:34 mpe-ubuntu-le avahi-daemon[1884]: Registering new address record for fe80::5054:ff:fe66:2a19 on eth0.*.
  Feb 06 14:55:34 mpe-ubuntu-le avahi-daemon[1884]: Registering new address record for 10.61.141.81 on eth0.IPv4.
  Feb 06 14:55:34 mpe-ubuntu-le avahi-daemon[1884]: Registering new address record for ::1 on lo.*.
  Feb 06 14:55:34 mpe-ubuntu-le avahi-daemon[1884]: Registering new address record for 127.0.0.1 on lo.IPv4.
  Feb 06 14:55:34 mpe-ubuntu-le systemd[1]: Started Avahi mDNS/DNS-SD Stack.
  Feb 06 14:55:35 mpe-ubuntu-le avahi-daemon[1884]: Server startup complete. Host name is mpe-ubuntu-le.local. Local service cookie is 3972418141.
  Feb 06 14:55:38 mpe-ubuntu-le avahi-daemon[1884]: Leaving mDNS multicast group on interface eth0.IPv6 with address fe80::5054:ff:fe66:2a19.
  Feb 06 14:55:38 mpe-ubuntu-le avahi-daemon[1884]: Joining mDNS multicast group on interface eth0.IPv6 with address fd69:d75f:b8b5:61:5054:ff:fe66:2a19.
  Feb 06 14:55:38 mpe-ubuntu-le avahi-daemon[1884]: Registering new address record for fd69:d75f:b8b5:61:5054:ff:fe66:2a19 on eth0.*.
  Feb 06 14:55:38 mpe-ubuntu-le avahi-daemon[1884]: Withdrawing address record for fe80::5054:ff:fe66:2a19 on eth0.
  
  # uname -r
  5.5.0-gcc-8.2.0


The key question is what ioctl is it complaining about. You should be
able to find that via strace.

cheers

> Christian Zigotzky wrote:
>
> Hi All,
>
> The issue with the avahi-daemon still exist in the latest Git kernel. It's a PowerPC issue. I compiled the latest Git kernel on a PC today and there aren't any issues with the avahi daemon. Another Power Mac user reported the same issue on his G5. I tested with the AmigaOne X1000 and X5000 in the last days.
>
> I bisected today but I think the result isn't correct because it found the other problem with ordering of PCSCSI definition in esp_rev enum. I don't know how to bisect if there is another issue at the same time. Maybe "git bisect skip"?
>
> 2086faae3c55a652cfbd369e18ecdb703aacc493 is the first bad commit
> commit 2086faae3c55a652cfbd369e18ecdb703aacc493
> Author: Kars de Jong <jongk@linux-m68k.org>
> Date:   Tue Nov 19 21:20:20 2019 +0100
>
>     scsi: esp_scsi: Correct ordering of PCSCSI definition in esp_rev enum
>
>     The order of the definitions in the esp_rev enum is important. The values
>     are used in comparisons for chip features.
>
>     Add a comment to the enum explaining this.
>
>     Also, the actual values for the enum fields are irrelevant, so remove the
>     explicit values (suggested by Geert Uytterhoeven). This makes adding a new
>     field in the middle of the enum easier.
>
>     Finally, move the PCSCSI definition to the right place in the enum. In its
>     previous location, at the end of the enum, the wrong values are written to
>     the CONFIG3 register when used with FAST-SCSI targets.
>
>     Link: https://lore.kernel.org/r/20191119202021.28720-2-jongk@linux-m68k.org
>     Signed-off-by: Kars de Jong <jongk@linux-m68k.org>
>     Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
>
> :040000 040000 cdc128596e33fb60406b5de9b17b79623c187c1a 48ceab06439f95285e8b30181e75f9a68c25fcb5 M    drivers
Christian Zigotzky Feb. 6, 2020, 2:28 p.m. UTC | #14
On 06 February 2020 at 05:35 am, Michael Ellerman wrote:
> Christian Zigotzky <chzigotzky@xenosoft.de> writes:
>> Kernel 5.5 PowerPC is also affected.
> I don't know what you mean by that. What sha are you talking about?
>
> I have a system with avahi running and everything's fine.
>
>    # grep use- /etc/avahi/avahi-daemon.conf
>    use-ipv4=yes
>    use-ipv6=yes
>    
>    # systemctl status -l --no-pager avahi-daemon
>    ● avahi-daemon.service - Avahi mDNS/DNS-SD Stack
>       Loaded: loaded (/lib/systemd/system/avahi-daemon.service; enabled; vendor preset: enabled)
>       Active: active (running) since Thu 2020-02-06 14:55:34 AEDT; 38min ago
>     Main PID: 1884 (avahi-daemon)
>       Status: "avahi-daemon 0.7 starting up."
>       CGroup: /system.slice/avahi-daemon.service
>               ├─1884 avahi-daemon: running [mpe-ubuntu-le.local]
>               └─1888 avahi-daemon: chroot helper
>    
>    Feb 06 14:55:34 mpe-ubuntu-le avahi-daemon[1884]: Registering new address record for fe80::5054:ff:fe66:2a19 on eth0.*.
>    Feb 06 14:55:34 mpe-ubuntu-le avahi-daemon[1884]: Registering new address record for 10.61.141.81 on eth0.IPv4.
>    Feb 06 14:55:34 mpe-ubuntu-le avahi-daemon[1884]: Registering new address record for ::1 on lo.*.
>    Feb 06 14:55:34 mpe-ubuntu-le avahi-daemon[1884]: Registering new address record for 127.0.0.1 on lo.IPv4.
>    Feb 06 14:55:34 mpe-ubuntu-le systemd[1]: Started Avahi mDNS/DNS-SD Stack.
>    Feb 06 14:55:35 mpe-ubuntu-le avahi-daemon[1884]: Server startup complete. Host name is mpe-ubuntu-le.local. Local service cookie is 3972418141.
>    Feb 06 14:55:38 mpe-ubuntu-le avahi-daemon[1884]: Leaving mDNS multicast group on interface eth0.IPv6 with address fe80::5054:ff:fe66:2a19.
>    Feb 06 14:55:38 mpe-ubuntu-le avahi-daemon[1884]: Joining mDNS multicast group on interface eth0.IPv6 with address fd69:d75f:b8b5:61:5054:ff:fe66:2a19.
>    Feb 06 14:55:38 mpe-ubuntu-le avahi-daemon[1884]: Registering new address record for fd69:d75f:b8b5:61:5054:ff:fe66:2a19 on eth0.*.
>    Feb 06 14:55:38 mpe-ubuntu-le avahi-daemon[1884]: Withdrawing address record for fe80::5054:ff:fe66:2a19 on eth0.
>    
>    # uname -r
>    5.5.0-gcc-8.2.0
>
>
> The key question is what ioctl is it complaining about. You should be
> able to find that via strace.
>
> cheers
>
Hello Michael,

Sorry it isn't true that the kernel 5.5 is also affected. A Power Mac G5 
user told me that but this isn't correct. I compiled and tested the 
stable kernel 5.5.1 and 5.5.2 today and both kernels don't have the 
issue with the avahi daemon.
Could you please also test the latest Git kernel?

strace /usr/sbin/avahi-daemon

...
poll([{fd=4, events=POLLIN}, {fd=16, events=POLLIN}, {fd=15, 
events=POLLIN}, {fd=14, events=POLLIN}, {fd=13, events=POLLIN}, {fd=12, 
events=POLLIN}, {fd=11, events=POLLIN}, {fd=10, events=POLLIN}, {fd=9, 
events=POLLIN}, {fd=8, events=POLLIN}, {fd=6, events=POLLIN}], 11, 65) = 
2 ([{fd=12, revents=POLLIN}, {fd=9, revents=POLLIN}])
ioctl(12, FIONREAD, 0xffba6f24)         = -1 ENOTTY (Inappropriate ioctl 
for device)
write(2, "ioctl(): Inappropriate ioctl for"..., 39ioctl(): Inappropriate 
ioctl for device) = 39
write(2, "\n", 1
)                       = 1
...

Thanks,
Christian
Michael Ellerman Feb. 8, 2020, 12:36 p.m. UTC | #15
Christian Zigotzky <chzigotzky@xenosoft.de> writes:
> On 06 February 2020 at 05:35 am, Michael Ellerman wrote:
>> Christian Zigotzky <chzigotzky@xenosoft.de> writes:
>>> Kernel 5.5 PowerPC is also affected.
>> I don't know what you mean by that. What sha are you talking about?
>>
>> I have a system with avahi running and everything's fine.
>>
>>    # grep use- /etc/avahi/avahi-daemon.conf
>>    use-ipv4=yes
>>    use-ipv6=yes
>>    
>>    # systemctl status -l --no-pager avahi-daemon
>>    ● avahi-daemon.service - Avahi mDNS/DNS-SD Stack
>>       Loaded: loaded (/lib/systemd/system/avahi-daemon.service; enabled; vendor preset: enabled)
>>       Active: active (running) since Thu 2020-02-06 14:55:34 AEDT; 38min ago
>>     Main PID: 1884 (avahi-daemon)
>>       Status: "avahi-daemon 0.7 starting up."
>>       CGroup: /system.slice/avahi-daemon.service
>>               ├─1884 avahi-daemon: running [mpe-ubuntu-le.local]
>>               └─1888 avahi-daemon: chroot helper
>>    
>>    Feb 06 14:55:34 mpe-ubuntu-le avahi-daemon[1884]: Registering new address record for fe80::5054:ff:fe66:2a19 on eth0.*.
>>    Feb 06 14:55:34 mpe-ubuntu-le avahi-daemon[1884]: Registering new address record for 10.61.141.81 on eth0.IPv4.
>>    Feb 06 14:55:34 mpe-ubuntu-le avahi-daemon[1884]: Registering new address record for ::1 on lo.*.
>>    Feb 06 14:55:34 mpe-ubuntu-le avahi-daemon[1884]: Registering new address record for 127.0.0.1 on lo.IPv4.
>>    Feb 06 14:55:34 mpe-ubuntu-le systemd[1]: Started Avahi mDNS/DNS-SD Stack.
>>    Feb 06 14:55:35 mpe-ubuntu-le avahi-daemon[1884]: Server startup complete. Host name is mpe-ubuntu-le.local. Local service cookie is 3972418141.
>>    Feb 06 14:55:38 mpe-ubuntu-le avahi-daemon[1884]: Leaving mDNS multicast group on interface eth0.IPv6 with address fe80::5054:ff:fe66:2a19.
>>    Feb 06 14:55:38 mpe-ubuntu-le avahi-daemon[1884]: Joining mDNS multicast group on interface eth0.IPv6 with address fd69:d75f:b8b5:61:5054:ff:fe66:2a19.
>>    Feb 06 14:55:38 mpe-ubuntu-le avahi-daemon[1884]: Registering new address record for fd69:d75f:b8b5:61:5054:ff:fe66:2a19 on eth0.*.
>>    Feb 06 14:55:38 mpe-ubuntu-le avahi-daemon[1884]: Withdrawing address record for fe80::5054:ff:fe66:2a19 on eth0.
>>    
>>    # uname -r
>>    5.5.0-gcc-8.2.0
>>
>>
>> The key question is what ioctl is it complaining about. You should be
>> able to find that via strace.
>>
>> cheers
>>
> Hello Michael,
>
> Sorry it isn't true that the kernel 5.5 is also affected. A Power Mac G5 
> user told me that but this isn't correct. I compiled and tested the 
> stable kernel 5.5.1 and 5.5.2 today and both kernels don't have the 
> issue with the avahi daemon.

OK good to know.

> Could you please also test the latest Git kernel?

That's literally all I ever do.

The problem here is you didn't tell me you were running a big endian
distro, which uses compat mode.

In hindsight I should have thought of that.

Now that I know that, I can reproduce the bug:

  Feb 08 23:31:12 mpe-ubuntu-be avahi-daemon[24819]: ioctl(): Inappropriate ioctl for device
  Feb 08 23:31:12 mpe-ubuntu-be avahi-daemon[24819]: ioctl(): Inappropriate ioctl for device
  Feb 08 23:31:12 mpe-ubuntu-be avahi-daemon[24819]: ioctl(): Inappropriate ioctl for device
  Feb 08 23:31:12 mpe-ubuntu-be avahi-daemon[24819]: ioctl(): Inappropriate ioctl for device


But it seems you've already identified the problem commit, thanks for
bisecting.

I'm sure Arnd will be able to fix it now that you've identified the
problematic commit.

cheers


> strace /usr/sbin/avahi-daemon
>
> ...
> poll([{fd=4, events=POLLIN}, {fd=16, events=POLLIN}, {fd=15, 
> events=POLLIN}, {fd=14, events=POLLIN}, {fd=13, events=POLLIN}, {fd=12, 
> events=POLLIN}, {fd=11, events=POLLIN}, {fd=10, events=POLLIN}, {fd=9, 
> events=POLLIN}, {fd=8, events=POLLIN}, {fd=6, events=POLLIN}], 11, 65) = 
> 2 ([{fd=12, revents=POLLIN}, {fd=9, revents=POLLIN}])
> ioctl(12, FIONREAD, 0xffba6f24)         = -1 ENOTTY (Inappropriate ioctl 
> for device)
> write(2, "ioctl(): Inappropriate ioctl for"..., 39ioctl(): Inappropriate 
> ioctl for device) = 39
> write(2, "\n", 1
> )                       = 1
> ...
>
> Thanks,
> Christian
diff mbox series

Patch

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 1ec34e16ed65..19f5aa8ac9a3 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -238,6 +238,7 @@  config PPC
 	select NEED_DMA_MAP_STATE		if PPC64 || NOT_COHERENT_CACHE
 	select NEED_SG_DMA_LENGTH
 	select OF
+	select OF_DMA_DEFAULT_COHERENT		if !NOT_COHERENT_CACHE
 	select OF_EARLY_FLATTREE
 	select OLD_SIGACTION			if PPC32
 	select OLD_SIGSUSPEND
diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
index 37c2ccbefecd..d91618641be6 100644
--- a/drivers/of/Kconfig
+++ b/drivers/of/Kconfig
@@ -103,4 +103,8 @@  config OF_OVERLAY
 config OF_NUMA
 	bool
 
+config OF_DMA_DEFAULT_COHERENT
+	# arches should select this if DMA is coherent by default for OF devices
+	bool
+
 endif # OF
diff --git a/drivers/of/address.c b/drivers/of/address.c
index 99c1b8058559..e8a39c3ec4d4 100644
--- a/drivers/of/address.c
+++ b/drivers/of/address.c
@@ -995,12 +995,16 @@  int of_dma_get_range(struct device_node *np, u64 *dma_addr, u64 *paddr, u64 *siz
  * @np:	device node
  *
  * It returns true if "dma-coherent" property was found
- * for this device in DT.
+ * for this device in the DT, or if DMA is coherent by
+ * default for OF devices on the current platform.
  */
 bool of_dma_is_coherent(struct device_node *np)
 {
 	struct device_node *node = of_node_get(np);
 
+	if (IS_ENABLED(CONFIG_OF_DMA_DEFAULT_COHERENT))
+		return true;
+
 	while (node) {
 		if (of_property_read_bool(node, "dma-coherent")) {
 			of_node_put(node);