Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4414671ybp; Mon, 14 Oct 2019 04:22:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqxA/TJ2erCSJ0hvZSiF3P4o/CXffgYB/opJcgBaFK6B25BgUqTL5niF4KWQPuYAXziTdvce X-Received: by 2002:a17:906:8608:: with SMTP id o8mr28504938ejx.179.1571052159262; Mon, 14 Oct 2019 04:22:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571052159; cv=none; d=google.com; s=arc-20160816; b=ovmpckXSsXTK5EW1W1ffDdm4AW+JzAjJX6gK50FsKqb7o9GDbKH1o7sunmOeNOSFCx RAZlEeLAvx8wCGCJ+k2Pj290EVj0ISYOXEiwmrOBvsd/JOVhMhjdLAt1SvnllAq3cHOf Fe3DnpOv+E0lghr9TSm0bMVevMGcv6/Ptz/aWnFO4GF+tvyEkZROvZELWZDDAbmaf8Gg 6Jwm6ln1eWoZI7b0zHAcQInqgKFXJRA9OSxes6q6k52Sv/NadPTHAZ5WDNPk4cNwNU6E NUiCBB0niSNPL0FquOttIA+E9wah34w/D/yKSO+Jx+lMIu4Jo66sahq/CvwSNV/TztDY PiGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=cuFapTftEQf9u/dtPS/P5xJow9aqFFLyRZszruAo5Bc=; b=WBG4SlN9JL7q30lq+bYxF5waUdAD8VZTFD2QR0aaIWKv0h23AmAPkSWUCcu6bqc70S 82vE7zR/h9/aW+nGg2w7upksOmAArRMaS6vIZmOlIX6Ixb7TTfTb2/88UEn/WZtH9AzS Jwu+NYE6MUEIJ1rliTfFYBKRgaMVgSDK7VwDzA6KjVIakH4yMulhwLHlxoBGgqSzYHun EwGSSRDi6gp+8XZ/SKsgpa1vp5e164u3zVV+17KA97FfPlJWt4ySfbNHL6WpHi3UdCVg YDmPRpvikMYq29WHR35TpX+esCLoGyfBkgWc/93DSXkDnC4C9FFRdvWiowND+SjerR55 WSrA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gg10si10565210ejb.206.2019.10.14.04.22.16; Mon, 14 Oct 2019 04:22:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730102AbfJNLUF (ORCPT + 99 others); Mon, 14 Oct 2019 07:20:05 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:41188 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726351AbfJNLUE (ORCPT ); Mon, 14 Oct 2019 07:20:04 -0400 Received: by mail-qt1-f196.google.com with SMTP id v52so24860469qtb.8; Mon, 14 Oct 2019 04:20:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cuFapTftEQf9u/dtPS/P5xJow9aqFFLyRZszruAo5Bc=; b=NZgw5jMo//jkehV1fNc2bm9JlM/nvbrirCVtIl28BMK+2ilyzJCuJepsfCNxNtI9SJ P0uyysV3ProtLmtgYWKeWhLuKwWCQeRqc8TKSrnvoRFdzBOZx5j27j6zbN79Zs5gINJZ 48P4vOgGjx5g/IL7JM85qIUxCNfaV0Z52CN/EakcaYXBgFBAjgIWwgi1eIPUyJVL6khY O2HM4Psl5CTz4ry9N0glI5UA4yYFwrJ38SY8XdsSxAKi/ViywkWmUFEj0owAj2d3G/Gg rfkYPhjO9T7p+NEVzkwdrUm9JyzInFZQoMHF2OSEZDYemxV3ZX+ehykwSBHg/Zf3MC2q Vt2A== X-Gm-Message-State: APjAAAUz9H9zuJLOQe63H8AD5erhoiBiDHbo2kqjB443KX9sPo1W+vGs JDY9/kI+oqrH/yXg5rliUHNHXH1EGTQTljla7fc= X-Received: by 2002:a05:6214:1150:: with SMTP id b16mr30329224qvt.197.1571052003441; Mon, 14 Oct 2019 04:20:03 -0700 (PDT) MIME-Version: 1.0 References: <20191014061617.10296-1-daniel@0x0f.com> <20191014061617.10296-2-daniel@0x0f.com> In-Reply-To: <20191014061617.10296-2-daniel@0x0f.com> From: Arnd Bergmann Date: Mon, 14 Oct 2019 13:19:46 +0200 Message-ID: Subject: Re: [PATCH 2/4] ARM: mstar: Add machine for MStar infinity family SoCs To: Daniel Palmer Cc: Daniel Palmer , Rob Herring , Mark Rutland , Russell King , Maxime Ripard , Heiko Stuebner , Shawn Guo , Laurent Pinchart , Icenowy Zheng , Mauro Carvalho Chehab , "David S. Miller" , Greg Kroah-Hartman , Jonathan Cameron , "Paul E. McKenney" , Linus Walleij , Paul Burton , Andrew Morton , Mike Rapoport , Bartosz Golaszewski , Doug Anderson , Ard Biesheuvel , Benjamin Gaignard , Nick Desaulniers , Stefan Agner , Nicolas Pitre , Masahiro Yamada , Nathan Chancellor , =?UTF-8?Q?Andreas_F=C3=A4rber?= , Nathan Huckleberry , Linux ARM , DTML , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 14, 2019 at 8:21 AM Daniel Palmer wrote: > > Initial support for the MStar infinity/infinity3 series of Cortex A7 > based IP camera SoCs. > > These chips are interesting in that they contain a Cortex A7, > peripherals and system memory in a single tiny QFN package that > can be hand soldered allowing almost anyone to embed Linux > in their projects. > > Signed-off-by: Daniel Palmer > + > +static void __init infinity_map_io(void) > +{ > + iotable_init(infinity_io_desc, ARRAY_SIZE(infinity_io_desc)); > + miu_flush = (void __iomem *)(infinity_io_desc[0].virtual > + + INFINITY_L3BRIDGE_FLUSH); > + miu_status = (void __iomem *)(infinity_io_desc[0].virtual > + + INFINITY_L3BRIDGE_STATUS); > +} If you do this a little later in .init_machine, you can use a simple ioremap() rather than picking a hardcoded physical address. It looks like nothing uses the mapping before you set soc_mb anyway. > +static DEFINE_SPINLOCK(infinity_mb_lock); > + > +static void infinity_mb(void) > +{ > + unsigned long flags; > + > + spin_lock_irqsave(&infinity_mb_lock, flags); > + /* toggle the flush miu pipe fire bit */ > + writel_relaxed(0, miu_flush); > + writel_relaxed(INFINITY_L3BRIDGE_FLUSH_TRIGGER, miu_flush); > + while (!(readl_relaxed(miu_status) & INFINITY_L3BRIDGE_STATUS_DONE)) { > + /* wait for flush to complete */ > + } > + spin_unlock_irqrestore(&infinity_mb_lock, flags); > +} Wow, this is a heavy barrier. From your description it doesn't sound like there is anything to be done about it unfortunately. Two possible issues I see here: * It looks like it relies on CONFIG_ARM_HEAVY_BARRIER, but your Kconfig entry does not select that. In many configurations, CACHE_L2X0 would be set, but there is no need for yours on the Cortex-A7. * You might get into a deadlock if you get an FIQ (NMI) interrupt while holding the infinity_mb_lock, and then issue another memory barrier from that handler, so you might need to use local_irq_disable()+local_fiq_disable()+raw_spin_lock() here, making it even more expensive. Not sure if it matters in practice, as almost nothing uses fiq any more. OTOH, maybe the lock is not needed at all? AFAICT if the sequence gets interrupted by a handler that also calls mb(), you would still continue in the original thread while observing a full l3 barrier. ;-) Arnd