From patchwork Thu May 7 08:06:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikulas Patocka X-Patchwork-Id: 1284992 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-rtc-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=i0Tqevem; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49HmJL1fQxz9sRY for ; Thu, 7 May 2020 18:06:42 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726572AbgEGIGm (ORCPT ); Thu, 7 May 2020 04:06:42 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:29870 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725923AbgEGIGl (ORCPT ); Thu, 7 May 2020 04:06:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588838799; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0pq3sPmnPLWktWKmL9trmUErhIVrOceVLU8JpOR9zNw=; b=i0TqevemABguKj7CoD8P8XJQXhcj8xtB+utITI/TUwNkrHwM6qJoh+hPCbjATON/dL09+H ohCefUnWZd3Dsw9Aif8XT0UTTpwLrpgOTaAZhc3Inrey6jWeUS9Bd4Dka7dtt9Zo0qi6PH 8OcR0X6IPhA3mklXlrMETjcknpGkUyQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-202-zfNgLzaTMruc6IiFlrlqpA-1; Thu, 07 May 2020 04:06:34 -0400 X-MC-Unique: zfNgLzaTMruc6IiFlrlqpA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 696E21005510; Thu, 7 May 2020 08:06:32 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (file01.intranet.prod.int.rdu2.redhat.com [10.11.5.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2FFB55D9C5; Thu, 7 May 2020 08:06:32 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (localhost [127.0.0.1]) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4) with ESMTP id 04786VCA005131; Thu, 7 May 2020 04:06:31 -0400 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id 04786Vmt005127; Thu, 7 May 2020 04:06:31 -0400 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Thu, 7 May 2020 04:06:31 -0400 (EDT) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: Arnd Bergmann cc: Richard Henderson , Ivan Kokshaysky , Matt Turner , Greg Kroah-Hartman , alpha , Sinan Kaya , linux-serial@vger.kernel.org, linux-rtc@vger.kernel.org Subject: [PATCH 1/2 v3] alpha: add a delay to inb_p, inb_w and inb_l In-Reply-To: Message-ID: References: User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Sender: linux-rtc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rtc@vger.kernel.org On Wed, 6 May 2020, Mikulas Patocka wrote: > > > On Wed, 6 May 2020, Arnd Bergmann wrote: > > > On Wed, May 6, 2020 at 1:21 PM Mikulas Patocka wrote: > > > > > /* > > > * The yet supported machines all access the RTC index register via > > > * an ISA port access but the way to access the date register differs ... > > > + * > > > + * The ISA bus on Alpha Avanti doesn't like back-to-back accesses, > > > + * we need to add a small delay. > > > */ > > > #define CMOS_READ(addr) ({ \ > > > outb_p((addr),RTC_PORT(0)); \ > > > +udelay(2); \ > > > inb_p(RTC_PORT(1)); \ > > > > > > The inb_p() / outb_p() functions are meant to already have a delay in them, > > maybe we should just add it there for alpha? > > > > Arnd > > Yes, that is possible too - it fixes the real time clock hang for me. > > > -#define inb_p inb > -#define inw_p inw > -#define inl_p inl > +#define inb_p(x) (ndelay(300), inb(x)) > +#define inw_p(x) (ndelay(300), inw(x)) > +#define inl_p(x) (ndelay(300), inl(x)) > #define outb_p outb > #define outw_p outw > #define outl_p outl 300ns was too low. We need at least 1400ns to fix the hang reliably. Mikulas From: Mikulas Patocka The patch 92d7223a74235054f2aa7227d207d9c57f84dca0 ("alpha: io: reorder barriers to guarantee writeX() and iowriteX() ordering #2") broke boot on the Alpha Avanti platform. The patch changes timing between accesses to the ISA bus, in particular, it reduces the time between "write" access and a subsequent "read" access. This causes lock-up when accessing the real time clock and serial ports. This patch fixes the real time clock by adding a small delay to the inb_p, inw_p and inl_p macros. Signed-off-by: Mikulas Patocka Fixes: 92d7223a7423 ("alpha: io: reorder barriers to guarantee writeX() and iowriteX() ordering #2") Cc: stable@vger.kernel.org # v4.17+ --- arch/alpha/include/asm/io.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) Index: linux-stable/arch/alpha/include/asm/io.h =================================================================== --- linux-stable.orig/arch/alpha/include/asm/io.h 2020-05-07 09:54:52.000000000 +0200 +++ linux-stable/arch/alpha/include/asm/io.h 2020-05-07 09:54:52.000000000 +0200 @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -481,9 +482,9 @@ extern inline void writeq(u64 b, volatil #define iowrite16be(v,p) iowrite16(cpu_to_be16(v), (p)) #define iowrite32be(v,p) iowrite32(cpu_to_be32(v), (p)) -#define inb_p inb -#define inw_p inw -#define inl_p inl +#define inb_p(x) (ndelay(1400), inb(x)) +#define inw_p(x) (ndelay(1400), inw(x)) +#define inl_p(x) (ndelay(1400), inl(x)) #define outb_p outb #define outw_p outw #define outl_p outl