Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752677AbdHKJQZ (ORCPT ); Fri, 11 Aug 2017 05:16:25 -0400 Received: from mail-io0-f180.google.com ([209.85.223.180]:33216 "EHLO mail-io0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751618AbdHKJQX (ORCPT ); Fri, 11 Aug 2017 05:16:23 -0400 MIME-Version: 1.0 In-Reply-To: <8e5e73575b3a70e0e60931698687471d@dk-develop.de> References: <20170731222452.22887-1-danilokrummrich@dk-develop.de> <20170807182207.348762301bf3d7f8509b1bf7@dk-develop.de> <8e5e73575b3a70e0e60931698687471d@dk-develop.de> From: Linus Walleij Date: Fri, 11 Aug 2017 11:16:20 +0200 Message-ID: Subject: Re: [PATCH] serio: PS2 gpio bit banging driver for the serio bus To: Danilo Krummrich , Russell King , Will Deacon , "linux-arm-kernel@lists.infradead.org" Cc: "linux-kernel@vger.kernel.org" , Linux Input , Dmitry Torokhov , "devicetree@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1837 Lines: 48 On Thu, Aug 10, 2017 at 4:38 PM, Danilo Krummrich wrote: > On 2017-08-07 18:22, Danilo Krummrich wrote: >>> >>> > +static int ps2_gpio_write(struct serio *serio, unsigned char val) >>> > +{ >>> > + struct ps2_gpio_data *drvdata = serio->port_data; >>> > + >>> > + drvdata->mode = PS2_MODE_TX; >>> > + drvdata->tx_byte = val; >>> > + /* Make sure ISR running on other CPU notice changes. */ >>> > + barrier(); >>> >>> This seems overengineered, is this really needed? >>> >>> If we have races like this, the error is likely elsewhere, and should be >>> fixed in the GPIO driver MMIO access or so. >>> >> Yes, seems it can be removed. I didn't saw any explicit barriers in the >> GPIO >> driver (I'm testing on bcm2835), but it seems MMIO operations on SMP archs >> does contain barriers. Not sure if all do. If some do not this barrier >> might >> be needed to ensure ISR on other CPU notice the correct mode and byte to >> send. >> > I couldn't find any guarantee that the mode and tx_byte change is implicitly > covered by a barrier in this case. E.g. the bcm2835 driver does not make > sure stores are completed before the particular interrupt is enabled, except by > the fact that writel on ARM contains a wmb(). But this is nothing to rely on. > (Please tell me if I miss something.) writel() should be guaranteeing that the values hit the hardware, wmb() is spelled out "write memory barrier" I don't see what you're after here. If you think writel() doesn't do its job on some platform, then fix writel() on that platform. We can't randomly sprinkle things like this all over the kernel it makes no sense. > Therefore I would like to keep this barrier and replace it with smp_wmb() if > you are fine with that. I do not think this is proper. Yours, Linus Walleij