From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 498DBC433E0 for ; Fri, 22 Jan 2021 11:07:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E382D235DD for ; Fri, 22 Jan 2021 11:07:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727867AbhAVLG7 (ORCPT ); Fri, 22 Jan 2021 06:06:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727142AbhAVJ1n (ORCPT ); Fri, 22 Jan 2021 04:27:43 -0500 Received: from mail-ua1-x930.google.com (mail-ua1-x930.google.com [IPv6:2607:f8b0:4864:20::930]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7150C0613D6 for ; Fri, 22 Jan 2021 01:27:02 -0800 (PST) Received: by mail-ua1-x930.google.com with SMTP id y21so1626520uag.2 for ; Fri, 22 Jan 2021 01:27:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=l1OaG7ryvioLgmZ8BmwevSwg84t2pSQg8vMbP0+UiP0=; b=FzdovL8pedW1EGTRQAn5/nzwscKjRd9z22SyVGPQQ9V1RYg2rGHC0PnaiCqw4mTrbZ xIkeDXRsHnyL3bgoPYVgbcPH1owFWTiHaMTCaz6Ltz5A9owQx3y7yZV8tYoAcBr0czFR yUEj0IIoSpbRwoElxpNolfOzbglz6y4y64VlKbHixYwIhnfPH9micI3AwPB4aInHABpH GY1R8+rI5lyU24Y+4h59p6x4/jDP2yrBmAyRhnaLhF1FdEERsj5wgZjtnTCr1yJVz+lf EBcvS6XVBQ9LNb3T1GwxcmKWrx+Ljh9+KdQa9fz/Qj5ncQtP68hmDLOyj4V13OyciKuy k5Yw== 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=l1OaG7ryvioLgmZ8BmwevSwg84t2pSQg8vMbP0+UiP0=; b=niKuXL29yPujCi4b9c7IUYUpAk1nVA866w7XbOinHh+OhS3dfMwJkFMvMpD/j2yLMR 4zTbSMCA94PfMzOkIKcqYUWakBnhhVwY9nyALFRVMD2oGN9320ql9GTxew1dDgaDtOGp kf+tcaqiY5N/9u5DUrK5/0YV2peSyBw2XjfHbyj5lGjJCmgvEHB/44m89K7hT2gnIqJ1 wN0AFjCIndh+s+MBvbNqzlq7gA0KAd9wMnMG9ew85HNwa6oBeSztz1dSbHdmzyMAX2Ix Ms28YcENDBKGeNtdQjk7xadoEI3OBXxPyhQ5c/ZZ+fHs9Vb9K+Q+r6MGT8ZKC8aqxusq kazg== X-Gm-Message-State: AOAM531iIUWKTYfYZraq6R2Kbb2e49LbHxyhQEhiquTNRYWRExTNnuBM NhuNGYVkxxl5i9PhmWIS0LZD3LHlLhXUQFPZnOvngg== X-Google-Smtp-Source: ABdhPJxGHo6L6iouAbCf6roRPrHn9HTCIERTtLiL2eNSzMh06D8wj3RxbBbFh+YdHQ3u3awZn2dTQI+JIdaaER7XuKg= X-Received: by 2002:ab0:768:: with SMTP id h95mr2544908uah.104.1611307621937; Fri, 22 Jan 2021 01:27:01 -0800 (PST) MIME-Version: 1.0 References: <20210122032334.3663056-1-andrew@aj.id.au> In-Reply-To: <20210122032334.3663056-1-andrew@aj.id.au> From: Ulf Hansson Date: Fri, 22 Jan 2021 10:26:25 +0100 Message-ID: Subject: Re: [PATCH] mmc: sdhci-of-aspeed: Fix kunit-related build error To: Andrew Jeffery Cc: "linux-mmc@vger.kernel.org" , Adrian Hunter , Joel Stanley , linux-aspeed , Linux ARM , Linux Kernel Mailing List , brendanhiggins@google.com, Randy Dunlap Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 22 Jan 2021 at 04:23, Andrew Jeffery wrote: > > Randy found that with the following Kconfig settings we have duplicate > definitions (e.g. __inittest()) in sdhci-of-aspeed due to competing > module_init()/module_exit() calls from kunit and driver the itself. > > ``` > CONFIG_MMC_SDHCI_OF_ASPEED=m > CONFIG_MMC_SDHCI_OF_ASPEED_TEST=y > ``` > > Conditionally open-code the kunit initialisation to avoid the error. > > Fixes: 7efa02a981d6 ("mmc: sdhci-of-aspeed: Add KUnit tests for phase calculations") > Reported-by: Randy Dunlap > Signed-off-by: Andrew Jeffery > --- > drivers/mmc/host/sdhci-of-aspeed-test.c | 9 ++++++++- > drivers/mmc/host/sdhci-of-aspeed.c | 27 ++++++++++++++++++++----- > 2 files changed, 30 insertions(+), 6 deletions(-) > > diff --git a/drivers/mmc/host/sdhci-of-aspeed-test.c b/drivers/mmc/host/sdhci-of-aspeed-test.c > index 34070605b28b..e5edda6c6e60 100644 > --- a/drivers/mmc/host/sdhci-of-aspeed-test.c > +++ b/drivers/mmc/host/sdhci-of-aspeed-test.c > @@ -95,4 +95,11 @@ static struct kunit_suite aspeed_sdhci_test_suite = { > .name = "sdhci-of-aspeed", > .test_cases = aspeed_sdhci_test_cases, > }; > -kunit_test_suite(aspeed_sdhci_test_suite); > + > +static struct kunit_suite *aspeed_sdhci_test_suite_array[] = { > + &aspeed_sdhci_test_suite, > + NULL, > +}; > + > +static struct kunit_suite **aspeed_sdhci_test_suites > + __used __section(".kunit_test_suites") = aspeed_sdhci_test_suite_array; > diff --git a/drivers/mmc/host/sdhci-of-aspeed.c b/drivers/mmc/host/sdhci-of-aspeed.c > index 3b0d381e1215..1446f23a2bfb 100644 > --- a/drivers/mmc/host/sdhci-of-aspeed.c > +++ b/drivers/mmc/host/sdhci-of-aspeed.c > @@ -556,6 +556,10 @@ static struct platform_driver aspeed_sdc_driver = { > .remove = aspeed_sdc_remove, > }; > > +#if defined(CONFIG_MMC_SDHCI_OF_ASPEED_TEST) > +#include "sdhci-of-aspeed-test.c" > +#endif > + > static int __init aspeed_sdc_init(void) > { > int rc; > @@ -566,7 +570,20 @@ static int __init aspeed_sdc_init(void) > > rc = platform_driver_register(&aspeed_sdc_driver); > if (rc < 0) > - platform_driver_unregister(&aspeed_sdhci_driver); > + goto cleanup_sdhci; > + > +#if defined(CONFIG_MMC_SDHCI_OF_ASPEED_TEST) I would like us to avoid #if defined" in code like this. Can you instead declare a function that you can stub in case CONFIG_MMC_SDHCI_OF_ASPEED_TEST is unset? > + rc = __kunit_test_suites_init(aspeed_sdhci_test_suites); > + if (rc < 0) { > + platform_driver_unregister(&aspeed_sdc_driver); > + goto cleanup_sdhci; > + } > +#endif > + > + return 0; > + > +cleanup_sdhci: > + platform_driver_unregister(&aspeed_sdhci_driver); > > return rc; > } > @@ -574,15 +591,15 @@ module_init(aspeed_sdc_init); > > static void __exit aspeed_sdc_exit(void) > { > +#if defined(CONFIG_MMC_SDHCI_OF_ASPEED_TEST) > + __kunit_test_suites_exit(aspeed_sdhci_test_suites); > +#endif > + > platform_driver_unregister(&aspeed_sdc_driver); > platform_driver_unregister(&aspeed_sdhci_driver); > } > module_exit(aspeed_sdc_exit); > > -#if defined(CONFIG_MMC_SDHCI_OF_ASPEED_TEST) > -#include "sdhci-of-aspeed-test.c" > -#endif > - > MODULE_DESCRIPTION("Driver for the ASPEED SD/SDIO/SDHCI Controllers"); > MODULE_AUTHOR("Ryan Chen "); > MODULE_AUTHOR("Andrew Jeffery "); > -- > 2.27.0 > Kind regards Uffe From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A664C433DB for ; Fri, 22 Jan 2021 09:28:48 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 31C7B222B6 for ; Fri, 22 Jan 2021 09:28:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 31C7B222B6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Zvzgv11CnY83guKkCq07P8hPqYZaKL7k/z+5XyzjJWE=; b=x5tGSeNnRrrCrruDRfWz4COqi XRCE+192VoyxlHuEWtyGUMUVqoX0TtP5v+tVWNN2dEGLK4ldI36eYkrIHWPcels6Vg6TADm8LETVs 7ExoLusvmTxwiZYvzaLWLJV2+vjx+gl8Vy6gMDXZ9gHJGm2LQ4oaLZ/2RYe5NpKu4VDN4fHg0wNCK ji+WpLleSb+/cP4BUw9eX7wIze1bDIgH/yJbNH7rafWW4mzl6op/K6+5y92Vtc1YFFzxOkqpiMZLQ 5Bmw7ZHKBKRKQiJPmRQNtRRXziTMezJjz+aBOd1Xv3j0pkAfzVXzv40mWnc7r2OD+VnVCHu8nbhaA mWGE+zL/A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l2sip-00044B-BZ; Fri, 22 Jan 2021 09:27:15 +0000 Received: from mail-ua1-x92a.google.com ([2607:f8b0:4864:20::92a]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l2sie-0003zY-BP for linux-arm-kernel@lists.infradead.org; Fri, 22 Jan 2021 09:27:06 +0000 Received: by mail-ua1-x92a.google.com with SMTP id k47so1630406uad.1 for ; Fri, 22 Jan 2021 01:27:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=l1OaG7ryvioLgmZ8BmwevSwg84t2pSQg8vMbP0+UiP0=; b=FzdovL8pedW1EGTRQAn5/nzwscKjRd9z22SyVGPQQ9V1RYg2rGHC0PnaiCqw4mTrbZ xIkeDXRsHnyL3bgoPYVgbcPH1owFWTiHaMTCaz6Ltz5A9owQx3y7yZV8tYoAcBr0czFR yUEj0IIoSpbRwoElxpNolfOzbglz6y4y64VlKbHixYwIhnfPH9micI3AwPB4aInHABpH GY1R8+rI5lyU24Y+4h59p6x4/jDP2yrBmAyRhnaLhF1FdEERsj5wgZjtnTCr1yJVz+lf EBcvS6XVBQ9LNb3T1GwxcmKWrx+Ljh9+KdQa9fz/Qj5ncQtP68hmDLOyj4V13OyciKuy k5Yw== 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=l1OaG7ryvioLgmZ8BmwevSwg84t2pSQg8vMbP0+UiP0=; b=EEu4BmcLo8l3sWHoIOU+vlWj4e0GkfcCwX2sISv8XzngUE2fpw6/cdopIFNcpG5312 1+TkJ3exnnRWsa09QvS/h9r6vvzB2EPLVUIiM+GI50aydqGJteZimbkDYm9MH7hQWWaL bValfe1x+jlvBh2VCiULEFH/Z4HtHLr6980VizNJBeZ5aI6nEIijBEbWdfYP7A8AbGbo 6HCRDdqNUpPM1Nqsx4tkPFdd7JDeGrouZMEAnY0hVDElKdljirRzBJdoRrMeN0d2jLgI vbI0+ibw3GbLOLw8XVtjYuyJGF9kcWoA4TJaxv8MmrxdmYL2G9o4AEyF8iim18A168GQ ZZug== X-Gm-Message-State: AOAM530aqv7cszV1sCIyVmOxEKoSFBMMVgo89R/iDAQcAMLK5EgBvQs2 MQRmn6zRNBbbY3uN/78zFrFzz/xeLIgfAbjUBTmMxQ== X-Google-Smtp-Source: ABdhPJxGHo6L6iouAbCf6roRPrHn9HTCIERTtLiL2eNSzMh06D8wj3RxbBbFh+YdHQ3u3awZn2dTQI+JIdaaER7XuKg= X-Received: by 2002:ab0:768:: with SMTP id h95mr2544908uah.104.1611307621937; Fri, 22 Jan 2021 01:27:01 -0800 (PST) MIME-Version: 1.0 References: <20210122032334.3663056-1-andrew@aj.id.au> In-Reply-To: <20210122032334.3663056-1-andrew@aj.id.au> From: Ulf Hansson Date: Fri, 22 Jan 2021 10:26:25 +0100 Message-ID: Subject: Re: [PATCH] mmc: sdhci-of-aspeed: Fix kunit-related build error To: Andrew Jeffery X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210122_042705_086196_F915596D X-CRM114-Status: GOOD ( 21.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-aspeed , brendanhiggins@google.com, Randy Dunlap , "linux-mmc@vger.kernel.org" , Linux Kernel Mailing List , Adrian Hunter , Joel Stanley , Linux ARM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, 22 Jan 2021 at 04:23, Andrew Jeffery wrote: > > Randy found that with the following Kconfig settings we have duplicate > definitions (e.g. __inittest()) in sdhci-of-aspeed due to competing > module_init()/module_exit() calls from kunit and driver the itself. > > ``` > CONFIG_MMC_SDHCI_OF_ASPEED=m > CONFIG_MMC_SDHCI_OF_ASPEED_TEST=y > ``` > > Conditionally open-code the kunit initialisation to avoid the error. > > Fixes: 7efa02a981d6 ("mmc: sdhci-of-aspeed: Add KUnit tests for phase calculations") > Reported-by: Randy Dunlap > Signed-off-by: Andrew Jeffery > --- > drivers/mmc/host/sdhci-of-aspeed-test.c | 9 ++++++++- > drivers/mmc/host/sdhci-of-aspeed.c | 27 ++++++++++++++++++++----- > 2 files changed, 30 insertions(+), 6 deletions(-) > > diff --git a/drivers/mmc/host/sdhci-of-aspeed-test.c b/drivers/mmc/host/sdhci-of-aspeed-test.c > index 34070605b28b..e5edda6c6e60 100644 > --- a/drivers/mmc/host/sdhci-of-aspeed-test.c > +++ b/drivers/mmc/host/sdhci-of-aspeed-test.c > @@ -95,4 +95,11 @@ static struct kunit_suite aspeed_sdhci_test_suite = { > .name = "sdhci-of-aspeed", > .test_cases = aspeed_sdhci_test_cases, > }; > -kunit_test_suite(aspeed_sdhci_test_suite); > + > +static struct kunit_suite *aspeed_sdhci_test_suite_array[] = { > + &aspeed_sdhci_test_suite, > + NULL, > +}; > + > +static struct kunit_suite **aspeed_sdhci_test_suites > + __used __section(".kunit_test_suites") = aspeed_sdhci_test_suite_array; > diff --git a/drivers/mmc/host/sdhci-of-aspeed.c b/drivers/mmc/host/sdhci-of-aspeed.c > index 3b0d381e1215..1446f23a2bfb 100644 > --- a/drivers/mmc/host/sdhci-of-aspeed.c > +++ b/drivers/mmc/host/sdhci-of-aspeed.c > @@ -556,6 +556,10 @@ static struct platform_driver aspeed_sdc_driver = { > .remove = aspeed_sdc_remove, > }; > > +#if defined(CONFIG_MMC_SDHCI_OF_ASPEED_TEST) > +#include "sdhci-of-aspeed-test.c" > +#endif > + > static int __init aspeed_sdc_init(void) > { > int rc; > @@ -566,7 +570,20 @@ static int __init aspeed_sdc_init(void) > > rc = platform_driver_register(&aspeed_sdc_driver); > if (rc < 0) > - platform_driver_unregister(&aspeed_sdhci_driver); > + goto cleanup_sdhci; > + > +#if defined(CONFIG_MMC_SDHCI_OF_ASPEED_TEST) I would like us to avoid #if defined" in code like this. Can you instead declare a function that you can stub in case CONFIG_MMC_SDHCI_OF_ASPEED_TEST is unset? > + rc = __kunit_test_suites_init(aspeed_sdhci_test_suites); > + if (rc < 0) { > + platform_driver_unregister(&aspeed_sdc_driver); > + goto cleanup_sdhci; > + } > +#endif > + > + return 0; > + > +cleanup_sdhci: > + platform_driver_unregister(&aspeed_sdhci_driver); > > return rc; > } > @@ -574,15 +591,15 @@ module_init(aspeed_sdc_init); > > static void __exit aspeed_sdc_exit(void) > { > +#if defined(CONFIG_MMC_SDHCI_OF_ASPEED_TEST) > + __kunit_test_suites_exit(aspeed_sdhci_test_suites); > +#endif > + > platform_driver_unregister(&aspeed_sdc_driver); > platform_driver_unregister(&aspeed_sdhci_driver); > } > module_exit(aspeed_sdc_exit); > > -#if defined(CONFIG_MMC_SDHCI_OF_ASPEED_TEST) > -#include "sdhci-of-aspeed-test.c" > -#endif > - > MODULE_DESCRIPTION("Driver for the ASPEED SD/SDIO/SDHCI Controllers"); > MODULE_AUTHOR("Ryan Chen "); > MODULE_AUTHOR("Andrew Jeffery "); > -- > 2.27.0 > Kind regards Uffe _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel