Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1206429imm; Wed, 17 Oct 2018 15:29:17 -0700 (PDT) X-Google-Smtp-Source: ACcGV61xJuV9dqHx3P+d8uGjgSl3lfZRO71knOw/MTkrfVf8ZLdVrLeWdyQNhdyW7173clEB5P1H X-Received: by 2002:a63:1e5c:: with SMTP id p28-v6mr26442826pgm.376.1539815357143; Wed, 17 Oct 2018 15:29:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539815357; cv=none; d=google.com; s=arc-20160816; b=auB3XK0wIKW686NIGBO/WiRlg/VpoFRhxap7PZKcUisX0z55d5rQCVeVQx19e7/WeP yfI4NWE0J1nC/pXD9F0ujAnXic42H2XjQ5c1MhQQphQFQVilS7ydPG3F3ZSFdUuafq3M AyWl9MyvXogcO78prfOpOVOEkut9+5H6vA/uqJdiax+sCkIXbRgZ6c/yNtKpJEv8mQHF 5l+FvVQ0CmfGc3vsejv2sJ3flMM8umQJ9o10edBp6xOdwGPxp1EqnIrN362y/4k3XHK7 g1JKENhPSD+jL9+ot8MdljHyACacT7cZgu0+Qz8TbB4pNpVqyciwT9DbsGcM66ieDu/A iV+A== 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:dkim-signature; bh=25Db+dh7wgf2koM2VQEbaJnNv3gY7iwu8CdxZoCLtCg=; b=sWNxt/1Ib/vd8ylMyWwiK8EFJlfXc2133rM6lZJ0DHXG6DAW6bWc5WuZBQvo9C5rew hWss0XqNqjhHqL0WVC4lCM0cyyI3abWshIulXKBAdyzWToizJoLXiqoZR/g6v/55dUXL AJeQFuYhiL1JR+eqHidicqx6mwmPp8TpO40XkQH3oxtGT3qdkSZZr+DecJWEosaw8sG4 wO+vhTfBZTgEVJ7hgKWGptxsG0dEVk+52MLm17VUspjQaFTXBeLMfJQHe5t6Pk92oaC8 83cvaVQKgpymCjJUKaLhjoM51ytgyE9Jan4ox5wXI29rIiWvkrpXzMxQSuv18d8MxSP7 cSCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oWV7+TRy; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l10-v6si11829641plt.117.2018.10.17.15.29.01; Wed, 17 Oct 2018 15:29:17 -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; dkim=pass header.i=@kernel.org header.s=default header.b=oWV7+TRy; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727348AbeJRG0E (ORCPT + 99 others); Thu, 18 Oct 2018 02:26:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:54506 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727082AbeJRG0E (ORCPT ); Thu, 18 Oct 2018 02:26:04 -0400 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E634E2148E for ; Wed, 17 Oct 2018 22:28:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539815298; bh=eUtAxQX5B6s9EXG+bZeo9jcC0fcLQFiJpJeWFpt1tig=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=oWV7+TRyfyk4srjtLcNYzRxwLSsR4pupB3IwPu4CI0M4M2fXtkR1moyrc6iNvWaSE 1J9/EA/3Lnuzptax1tLSpOPxjYr52Hg4rdtSIG6B3aGy/Ajb//3A/vLaljKF7ylLdr o8IKhoo6EfcxqcOFDj8sE4i5/peqoLCa5rrkAoHA= Received: by mail-wr1-f51.google.com with SMTP id a13-v6so31432746wrt.5 for ; Wed, 17 Oct 2018 15:28:17 -0700 (PDT) X-Gm-Message-State: ABuFfojru1hNINI5P2+O69IVlhGKafcbrTWkLWDIDB77N0pqek0v60dn sry4NcGhcm0P4max4gHTm9zNkbEGEZ9jf82fGGzglg== X-Received: by 2002:a5d:4151:: with SMTP id c17-v6mr25332237wrq.61.1539815296159; Wed, 17 Oct 2018 15:28:16 -0700 (PDT) MIME-Version: 1.0 References: <20181016235120.138227-1-brendanhiggins@google.com> <20181016235120.138227-27-brendanhiggins@google.com> In-Reply-To: <20181016235120.138227-27-brendanhiggins@google.com> From: Rob Herring Date: Wed, 17 Oct 2018 17:28:04 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC v1 26/31] arch: um: added stubs for mock iomem for KUnit To: brendanhiggins@google.com Cc: Greg Kroah-Hartman , keescook@google.com, mcgrof@kernel.org, shuah@kernel.org, joel@jms.id.au, Michael Ellerman , Joe Perches , brakmo@fb.com, Steven Rostedt , Tim.Bird@sony.com, khilman@baylibre.com, Julia Lawall , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, Linux Kernel Mailing List , jdike@addtoit.com, richard@nod.at, linux-um@lists.infradead.org, Arnd Bergmann 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 Tue, Oct 16, 2018 at 6:54 PM Brendan Higgins wrote: > > This mocks out some iomem functions (functions like readl and writel), > for mocking hardware interfaces. > > Signed-off-by: Brendan Higgins > --- > arch/um/Kconfig.common | 8 +++++- > arch/um/Kconfig.um | 5 ++++ > arch/um/include/asm/Kbuild | 1 - > arch/um/include/asm/io-mock-shared.h | 33 +++++++++++++++++++++ > arch/um/include/asm/io-mock.h | 43 ++++++++++++++++++++++++++++ > arch/um/include/asm/io.h | 8 ++++++ > arch/um/kernel/Makefile | 1 + > arch/um/kernel/io-mock.c | 40 ++++++++++++++++++++++++++ > kunit/Kconfig | 1 + > 9 files changed, 138 insertions(+), 2 deletions(-) > create mode 100644 arch/um/include/asm/io-mock-shared.h > create mode 100644 arch/um/include/asm/io-mock.h > create mode 100644 arch/um/kernel/io-mock.c > > diff --git a/arch/um/Kconfig.common b/arch/um/Kconfig.common > index 07f84c842cc31..72e7efb74f7fd 100644 > --- a/arch/um/Kconfig.common > +++ b/arch/um/Kconfig.common > @@ -19,7 +19,13 @@ config MMU > default y > > config NO_IOMEM > - def_bool y > + bool > + default y if !KUNIT > + > +config HAS_IOMEM HAS_IOMEM is essentially a disable flag for lots of drivers on UML. Ignoring drivers, it doesn't really control a significant amount of code (albeit small amount of code you need for this series). As a driver disable, it does a poor job as lots of drivers aren't MMIO and aren't disabled. I think we should decouple these 2 things. Perhaps get rid of the driver disable part altogether. We already do 'depends on ARCH_FOO || COMPILE_TEST' for lots of drivers. Also, I wouldn't be surprised if turning on HAS_IOMEM causes UML randconfig failures. Arnd does lots of randconfig testing and might be willing to help check. > + bool "Turns on fake IOMEM support for KUnit" > + depends on KUNIT > + select MOCK_IOMEM > > config ISA > bool > diff --git a/arch/um/Kconfig.um b/arch/um/Kconfig.um > index 20da5a8ca9490..8d35e0e2c23d1 100644 > --- a/arch/um/Kconfig.um > +++ b/arch/um/Kconfig.um > @@ -122,3 +122,8 @@ config SECCOMP > defined by each seccomp mode. > > If unsure, say Y. > + > +config PLATFORM_MOCK > + bool "Enable a mock architecture used for unit testing." > + depends on KUNIT && OF > + default n > diff --git a/arch/um/include/asm/Kbuild b/arch/um/include/asm/Kbuild > index b10dde6cb793b..9fd2827ab76d1 100644 > --- a/arch/um/include/asm/Kbuild > +++ b/arch/um/include/asm/Kbuild > @@ -12,7 +12,6 @@ generic-y += ftrace.h > generic-y += futex.h > generic-y += hardirq.h > generic-y += hw_irq.h > -generic-y += io.h > generic-y += irq_regs.h > generic-y += irq_work.h > generic-y += kdebug.h > diff --git a/arch/um/include/asm/io-mock-shared.h b/arch/um/include/asm/io-mock-shared.h > new file mode 100644 > index 0000000000000..6baf59cb17a58 > --- /dev/null > +++ b/arch/um/include/asm/io-mock-shared.h > @@ -0,0 +1,33 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +#ifndef _ASM_UM_IO_MOCK_SHARED_H > +#define _ASM_UM_IO_MOCK_SHARED_H > + > +#define readb readb > +u8 readb(const volatile void __iomem *); What about all the other flavors of MMIO accessors like __raw_readb, readb_relaxed, etc.? readX/writeX is intended for PCI based drivers which doesn't seem to be what you are targeting in this series. I think it would be good if this capability was not just on UML. I could also imagine wanting to run tests on real h/w. Perhaps you just want to log and/or check i/o accesses. Or you need some dependencies in place rather than trying to fake everything (clocks, gpios, pinmux, irq, etc.). That being said, I'm not trying to add a bunch of things for you to do. Though maybe it makes sense to split this series some. How many of the patches are needed to convert the DT unittests for example? Rob