From patchwork Tue Sep 26 16:39:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Pagani X-Patchwork-Id: 145000 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp2112107vqu; Tue, 26 Sep 2023 11:26:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEeY+7DGlNPDhp5iawJMxEKSNNJrkxtqD4E/QP/ZjDAQ9OfPJp3NMnh3EGKJ85kytf6WWH7 X-Received: by 2002:aa7:8886:0:b0:68c:1004:1feb with SMTP id z6-20020aa78886000000b0068c10041febmr13733064pfe.32.1695752814229; Tue, 26 Sep 2023 11:26:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695752814; cv=none; d=google.com; s=arc-20160816; b=Labrx6utcRpmQDFDc0U8QX3Sji2OUjN9FlSl8owDkb2paPy+osOTxnGJ59JX+k9L9o 1YzvEiJGW4yHvnzs/WigKHVkaN2gMinMfQYwJqtZbugF/FmBivqyj1IIwrRy/OEglwgN 2CCHZnRODV17ZlL38RPKwM7+Gk9qJ9dqspxSzj5ZY0/KXzW4iDb+/Ru5j60+oE6CIjQF ZQXvhGr4W692KoTtK1WQ/XR2knrbldXybKG4s/Bt9eMEzluxgd5jMLvcq4CFWzYR5od9 jzdshY4TMfxEGApObAJelXwOvUaeYX3t3SOBYfxsfSbCSPwYnqGZSnxUVmcx23Jat2eT 5fNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=av4Q5tr0bnozwSJldJa/tKMZzYdZGmoPuhbGkeCDqlg=; fh=vL6Moim7ujQ71QOBXYMaaPnG1N9WYgskJqrZSTruGY4=; b=Lk509njIoAXH6CsCnuEcFU1pZdDCuVELU5ZgQbgtuIYQHeG3U6CuOEaaRW90GhIxUA O0B0wynMKXZj5OVR5HLv63TbH5OkJydymi73NcSXvnxyE1lhPhyVb7gk2h997K1ydwmO OY5+X4lAXIDSBunr8b+0EgnBPtJb8m8Ph2PbJxgVxpKGc4oYeFE2VJ7kk4MGF0HPCRyc MIAL2MXUtFC2Q0HjM4yW9cVgIxsdRM1Z9+4tApOm581NvYA3YzrBJcFmsGJ+Uv0p6xJx bFHd9ah7wDAa35Aj65m/j5RZOerf2og9ZCA1+htyVYy8EPE9B3qv9iAgvag/S/IKi8+5 p+sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iqTAIiHu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id h63-20020a638342000000b00584b7f082bdsi2226966pge.449.2023.09.26.11.26.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 11:26:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iqTAIiHu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 83D56840B7FD; Tue, 26 Sep 2023 09:40:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235325AbjIZQkQ (ORCPT + 28 others); Tue, 26 Sep 2023 12:40:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235319AbjIZQkM (ORCPT ); Tue, 26 Sep 2023 12:40:12 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF99A13A for ; Tue, 26 Sep 2023 09:39:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695746365; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=av4Q5tr0bnozwSJldJa/tKMZzYdZGmoPuhbGkeCDqlg=; b=iqTAIiHu1L5lsyMuMYmLo9rlkzA14940/mL6uHrTALweAdGUiFBpyUscoySoYDu6TD1YZq 5/twkDvqivabkP23XEWqHJSpERcPjN//x4x9RgszEAry2aehAwx8IfovaFyvZIYjwf3oag xkGRQN3kRkN+Tm/FC3x2Bh2c05y/QLE= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-275-QQJJ75rdNhuIs1BMOT2tiQ-1; Tue, 26 Sep 2023 12:39:23 -0400 X-MC-Unique: QQJJ75rdNhuIs1BMOT2tiQ-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-32006e08483so7257776f8f.0 for ; Tue, 26 Sep 2023 09:39:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695746362; x=1696351162; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=av4Q5tr0bnozwSJldJa/tKMZzYdZGmoPuhbGkeCDqlg=; b=qBbcqzKNrFF0f/Xqwmg+1v2r22YWrun666/WejoyckccvjPuQTs1iYJO7d4MUyQpGb DvxrJo5aM9JS892yf1emryzA3hkovxAP112hG8L4amuPixnpUUWtZMbpyHzfPdGb07Ym iXwIwJtI8j5pWyiPX4NCwdqMQcT9KDzXuHgeeChj63GCgSYzdgoGRKE7Tep7CP9tHnN9 3BYSVWuCfOGzUhg0tTD9PbAN2QYHMCglW7kg4wt5hNCCOqpJDHrwQHMZrD2+7t0XnNl4 66r9j3YCD3+WmxgTbgHQsPUMEdqR9fD9kmkqUc2/Osyc3Wrg+jy9s8VFAcHjF700sEj8 QfXw== X-Gm-Message-State: AOJu0Yy2SimQBK557IRW/2tzY4t3HqmHfgf5DUvh3s6P082J+pQd3Rz+ Fjpt2ze9WERUolsyuElSumyaB45vMUGZsf5maWDsmQrektGK/RtauGTYFa/qS6PZLCW9XqfW504 jMFn31RiqSk2RUrILBOdAzNY= X-Received: by 2002:adf:f891:0:b0:320:66:cf67 with SMTP id u17-20020adff891000000b003200066cf67mr8551634wrp.18.1695746362264; Tue, 26 Sep 2023 09:39:22 -0700 (PDT) X-Received: by 2002:adf:f891:0:b0:320:66:cf67 with SMTP id u17-20020adff891000000b003200066cf67mr8551628wrp.18.1695746362039; Tue, 26 Sep 2023 09:39:22 -0700 (PDT) Received: from klayman.redhat.com (net-2-34-30-58.cust.vodafonedsl.it. [2.34.30.58]) by smtp.gmail.com with ESMTPSA id w10-20020adfde8a000000b0031fba0a746bsm15171803wrl.9.2023.09.26.09.39.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 09:39:21 -0700 (PDT) From: Marco Pagani To: Moritz Fischer , Wu Hao , Xu Yilun , Tom Rix Cc: Marco Pagani , linux-kernel@vger.kernel.org, linux-fpga@vger.kernel.org Subject: [PATCH 1/4] fpga: add helpers for the FPGA KUnit test suites. Date: Tue, 26 Sep 2023 18:39:08 +0200 Message-ID: <20230926163911.66114-2-marpagan@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230926163911.66114-1-marpagan@redhat.com> References: <20230926163911.66114-1-marpagan@redhat.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 26 Sep 2023 09:40:13 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778125703096826402 X-GMAIL-MSGID: 1778125703096826402 Add helpers to facilitate the registration of minimal platform drivers to support the parent platform devices used for testing. Signed-off-by: Marco Pagani --- drivers/fpga/tests/fpga-test-helpers.h | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 drivers/fpga/tests/fpga-test-helpers.h diff --git a/drivers/fpga/tests/fpga-test-helpers.h b/drivers/fpga/tests/fpga-test-helpers.h new file mode 100644 index 000000000000..fcad3249be68 --- /dev/null +++ b/drivers/fpga/tests/fpga-test-helpers.h @@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * KUnit test for the FPGA Manager + * + * Copyright (C) 2023 Red Hat, Inc. + * + * Author: Marco Pagani + */ + +#ifndef FPGA_KUNIT_HELPERS_ +#define FPGA_KUNIT_HELPERS_ + +#define TEST_PDEV_NAME "fpga-test-pdev" + +#define TEST_PLATFORM_DRIVER(__drv_name) \ + __TEST_PLATFORM_DRIVER(__drv_name, TEST_PDEV_NAME) +/* + * Helper macro for defining a minimal platform driver that can + * be registered to support the parent platform devices used for + * testing. + */ +#define __TEST_PLATFORM_DRIVER(__drv_name, __dev_name) \ +static struct platform_driver __drv_name = { \ + .driver = { \ + .name = __dev_name, \ + }, \ +} + +#endif /* FPGA_KUNIT_HELPERS_ */ From patchwork Tue Sep 26 16:39:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Pagani X-Patchwork-Id: 145018 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp2154912vqu; Tue, 26 Sep 2023 12:49:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG0wXonli01okg43Gs7ugdk/VnhtRQYrJlmAFyaNQMU5FbzxkB3wuw81xpDRPEm43tc5Ti+ X-Received: by 2002:a17:902:b284:b0:1c3:52ed:18f9 with SMTP id u4-20020a170902b28400b001c352ed18f9mr8283269plr.62.1695757774586; Tue, 26 Sep 2023 12:49:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695757774; cv=none; d=google.com; s=arc-20160816; b=MysEe2sl86/S5fFigQsUk1ofQgA+YJPqg22yGkS72/PjV+dcUT2fXtjw9tRuZ7RqRL LqypaWBUIC50BK0MCUz1VZNY24TERqUq0K0DSGPP/GOukaqk0Y+76CxyHpAmeEcINort WB6Q9XBVqRD3nJyX4kmWQP1feN/nSyoyFESFrxIgS5X7OVmR3RgCPQwkKtFrJmfGlu+h 9odmgkpfNadhOPccLvCntPe9yUv0Oty4k43ghjUgyMhQR4KIKmy+EqhrwiiH+1E06IG2 1CzoHyMkfSYflfa4QIGoB7wGBEnLKLM5CsVEjz9nejMMFoM23gYrwv7CQ6juKGT99p/a htsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6vekRvbFuhbc4qXIoy5r5sKVR277TKztySBeIjCszjQ=; fh=SVLtJx2RN624E9ZvR+iL8AVfiRfKB4Yg6A8iu4u1uGc=; b=05JkdediORqwIWuLsZaivMLFuAd07+50uoI4mRxoJLBsTo7FO9hHcV9Ujqw28ftwCP 3iRFwwAFBCvjreks6815BAcTghZOrTYSIQ2O+SiopRlvKj/2dOSYsKxyqLh03xMmfSMi WwbFI3IjCzjjeWt0E7bsLAr3UAzR76fstUcAUmgoIQl/rdq9FboJwyYBwB/29hK5qiLV ApiW+Su7ox0JBk9nFtnq/1LohSBtiEPlQXCydqR9DtYItSPQO/OOuZ5JkYp+VGFmL+Hk KTLf+8wFgfWuWIiFtfU/Ea2MpbXfnzjb/fyPcejzxSigIA1auA9QUV+EBgI9FCODNMG1 K3bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="i+qy6EO/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id c8-20020a170903234800b001c5d09c7b0bsi13935492plh.486.2023.09.26.12.49.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 12:49:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="i+qy6EO/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id D974281E5548; Tue, 26 Sep 2023 09:40:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235294AbjIZQkW (ORCPT + 28 others); Tue, 26 Sep 2023 12:40:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235346AbjIZQkR (ORCPT ); Tue, 26 Sep 2023 12:40:17 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08A1911F for ; Tue, 26 Sep 2023 09:39:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695746371; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6vekRvbFuhbc4qXIoy5r5sKVR277TKztySBeIjCszjQ=; b=i+qy6EO/DNqHHEPbjcoN+v0n6W2YgKM2ZAenGx0VbT52qDnWG+RRQD2b+ifaGzR/WX18oO fH+RGHMklzL16+vXkiF3PubNWfQYW0MHD/nwa3SR+kmEcR1Lgn0hAQ1AX24gCuvFmrOj96 sIdkKes9JMkz5kPjrY/swCVFXNT930k= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-550-y_o4KSOGPRqqJ5ZZ7ay0Og-1; Tue, 26 Sep 2023 12:39:29 -0400 X-MC-Unique: y_o4KSOGPRqqJ5ZZ7ay0Og-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-32329974dbdso3694685f8f.0 for ; Tue, 26 Sep 2023 09:39:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695746368; x=1696351168; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6vekRvbFuhbc4qXIoy5r5sKVR277TKztySBeIjCszjQ=; b=xFdRv2JT+mdvuI+9jpI759WgvuxPmXgUBjhPlGSsIT5iMgED8/MtToTjXYppeGWi0r SWxBDCqPmh7MVganBOiyEOvF+QgT7ayTV+Ftm8JLpGd0l/FFY1OTfyXGAfSzadJSMn8H 5o1uJRlI+CHt8zKB55HyC4HOfwFv+o86BrXObbMdhG113sSV3Yty3EFuhaoMx3q+Xlfh BY5XYxi1e22VXJ3gR3hgI86qgGZ1JHJA26HUrx+G9M+12Kun28jQqS1w34Vt67eBI7eG kJk5oK7Q5fIuObN0cAM78ggO/viVyCJslDOjY7aicHqapZB/5ScY7ul68T1nZO8b7t05 G43w== X-Gm-Message-State: AOJu0YyeUGVfCEDInMWKsgdLBm1ovyHyq7WTzuMFdRFwOnaHz/TboanD msWZalg7T2wRtLoaV4im27yLEYEhrzM1bwuXIEr3Ot/0hYAfDkMJpCacS9cX26Iau7nndL/g1xR vpC8KoaPReqU/9zU7OkBt/iw= X-Received: by 2002:a05:6000:1c7:b0:31f:bdfd:5d30 with SMTP id t7-20020a05600001c700b0031fbdfd5d30mr10927468wrx.57.1695746368815; Tue, 26 Sep 2023 09:39:28 -0700 (PDT) X-Received: by 2002:a05:6000:1c7:b0:31f:bdfd:5d30 with SMTP id t7-20020a05600001c700b0031fbdfd5d30mr10927453wrx.57.1695746368621; Tue, 26 Sep 2023 09:39:28 -0700 (PDT) Received: from klayman.redhat.com (net-2-34-30-58.cust.vodafonedsl.it. [2.34.30.58]) by smtp.gmail.com with ESMTPSA id w10-20020adfde8a000000b0031fba0a746bsm15171803wrl.9.2023.09.26.09.39.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 09:39:28 -0700 (PDT) From: Marco Pagani To: Moritz Fischer , Wu Hao , Xu Yilun , Tom Rix Cc: Marco Pagani , linux-kernel@vger.kernel.org, linux-fpga@vger.kernel.org, Jinjie Ruan Subject: [PATCH 2/4] fpga: add a platform driver to the FPGA Manager test suite Date: Tue, 26 Sep 2023 18:39:09 +0200 Message-ID: <20230926163911.66114-3-marpagan@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230926163911.66114-1-marpagan@redhat.com> References: <20230926163911.66114-1-marpagan@redhat.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 26 Sep 2023 09:40:41 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778130904045343358 X-GMAIL-MSGID: 1778130904045343358 Register a minimal platform driver associated with the parent platform device used for testing to prevent a null-ptr-deref when try_module_get() is called by fpga_mgr_get(). Fixes: ccbc1c302115 ("fpga: add an initial KUnit suite for the FPGA Manager") Reported-by: Jinjie Ruan Signed-off-by: Marco Pagani --- drivers/fpga/tests/fpga-mgr-test.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/fpga/tests/fpga-mgr-test.c b/drivers/fpga/tests/fpga-mgr-test.c index 6acec55b60ce..30de474d7def 100644 --- a/drivers/fpga/tests/fpga-mgr-test.c +++ b/drivers/fpga/tests/fpga-mgr-test.c @@ -14,6 +14,8 @@ #include #include +#include "fpga-test-helpers.h" + #define HEADER_FILL 'H' #define IMAGE_FILL 'P' #define IMAGE_BLOCK 1024 @@ -277,6 +279,18 @@ static void fpga_mgr_test_img_load_sgt(struct kunit *test) sg_free_table(ctx->img_info->sgt); } +TEST_PLATFORM_DRIVER(test_platform_driver); + +static int fpga_mgr_test_suite_init(struct kunit_suite *suite) +{ + return platform_driver_register(&test_platform_driver); +} + +static void fpga_mgr_test_suite_exit(struct kunit_suite *suite) +{ + platform_driver_unregister(&test_platform_driver); +} + static int fpga_mgr_test_init(struct kunit *test) { struct mgr_ctx *ctx; @@ -284,7 +298,7 @@ static int fpga_mgr_test_init(struct kunit *test) ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); - ctx->pdev = platform_device_register_simple("mgr_pdev", PLATFORM_DEVID_AUTO, NULL, 0); + ctx->pdev = platform_device_register_simple(TEST_PDEV_NAME, PLATFORM_DEVID_AUTO, NULL, 0); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx->pdev); ctx->mgr = devm_fpga_mgr_register(&ctx->pdev->dev, "Fake FPGA Manager", &fake_mgr_ops, @@ -317,6 +331,8 @@ static struct kunit_case fpga_mgr_test_cases[] = { static struct kunit_suite fpga_mgr_suite = { .name = "fpga_mgr", + .suite_init = fpga_mgr_test_suite_init, + .suite_exit = fpga_mgr_test_suite_exit, .init = fpga_mgr_test_init, .exit = fpga_mgr_test_exit, .test_cases = fpga_mgr_test_cases, From patchwork Tue Sep 26 16:39:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Pagani X-Patchwork-Id: 145058 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp2228419vqu; Tue, 26 Sep 2023 15:22:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFr2tCZpXkazClYTnZJFqaQZq76Ph2wlg1SMUE5eiuicz4oFUx+Jko2GG6ZdwAlupwJ3sIa X-Received: by 2002:a05:6a20:1008:b0:14d:2b8d:d62f with SMTP id gs8-20020a056a20100800b0014d2b8dd62fmr191065pzc.47.1695766923722; Tue, 26 Sep 2023 15:22:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695766923; cv=none; d=google.com; s=arc-20160816; b=Lol6IndQw25lvtmgePNNJZzViV4WYraDDmpFkQJ925y0rONkSOqqXvAu6V/nALcwww V2OqwOeZjZnqtVqr+9g8Rs0WCaMM4HUayJedfXDOMcaue1f4Hly8L6Dz97Qqi2ddScG1 VKKMaUMw7HYhLA/81+8r+y9jqvg32McF5u38S0k4KN1F0bCrJRqfABNmiLPNdRkGtixH GkR6Ia/A1Xo9AYDhVslUf4xPYKaLrJiFdzxEHqPVaLuWuWgWXseZAz7B3iKh0nqwC7WP iwPQzXItdSwzYqpxkahRF2J3f/gJy80aaiqabnhdXiAjmEMJq6HavdDBTs+CQ2GYK+qV WEig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bU5dbp4PmbcRGMxxeBcidbIs/vd32ofMq8iILiK+4+o=; fh=SVLtJx2RN624E9ZvR+iL8AVfiRfKB4Yg6A8iu4u1uGc=; b=gTT9iZfwSvVdAzaoou1Q6ub/Ap9b3rySQxX0hw/oO1NimpHdiIMPbUdNHlKEsPoPFO SMhLIjdhn2JcUfw9Z+W+B5Efg7W1egfpDDGi1TPwmGQF4Tj99B/UL6d1vOl88XNrqtwB /Kj0IefvBDezPmmoL3+o2QMCru2oqgU2/iFcHaQB5lKDGlxuBrTlKvZlviL0gdkGAhUA jsFbb5GnJdPslDQT0hUfwgkZFTw82vTtXg1NR2qIN0z9IKPFqP2/t6H2W8zZvNKM08io evQ1Mgq0RP8QWb4YKjDDTpGOAzLvshOE2HC6et9gRDYdGjr24iT9woCTo2VRRFd+lqif T/8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ARFByj3p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id k12-20020a170902c40c00b001bbc61fedafsi15011744plk.422.2023.09.26.15.22.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 15:22:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ARFByj3p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id E797681C7AB3; Tue, 26 Sep 2023 09:40:26 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235330AbjIZQk2 (ORCPT + 28 others); Tue, 26 Sep 2023 12:40:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235275AbjIZQkY (ORCPT ); Tue, 26 Sep 2023 12:40:24 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1760BBF for ; Tue, 26 Sep 2023 09:39:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695746377; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bU5dbp4PmbcRGMxxeBcidbIs/vd32ofMq8iILiK+4+o=; b=ARFByj3pfgy0AiNK5oJAen2kPF2j/FX1q5YlaHDVS+HZraaCEijScvwrp1ld/IwWLdXvSm Psk9dQdO7pV2hM+mumRPDKdcB5LGU7gmVgpwYkFZYSgmlO4cbqtvrd7tUAbUBmxjay0foG PvlkJhPod502MdIbEwRQgKiknvezpvk= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-331-5iiAPVJmMaOMeNLyWTZ79A-1; Tue, 26 Sep 2023 12:39:36 -0400 X-MC-Unique: 5iiAPVJmMaOMeNLyWTZ79A-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4054743df06so69287955e9.3 for ; Tue, 26 Sep 2023 09:39:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695746375; x=1696351175; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bU5dbp4PmbcRGMxxeBcidbIs/vd32ofMq8iILiK+4+o=; b=PqHOjkzPmQshVyFTLOR7otdGFIb6D35xZgU5FShOIgv0SDT2PyzYTd9q/aMWrD1nRN FKW869kskNvV0wt12vcdxHc4E8PSYHknFUmaA4ZV7ziFQlb8XNw/OMrh71SQihHPg95u XmuFWowNunWDswRKJXpU8+1GGFR4u878lTsRUqjAsVup3y9uFi767IrDH3+t9r5SQsr7 JS3XS9EnNQ/p6YiQQuROnISfYXIUkayzMfopO2G1EDJ0oEjocgCpJUMNCeLIiXG7XEoN nh3Pxpz47H087zNUveKM/netHti64wF95YcSXbr7PlNH8RHz5aWIPgZt6MObOofZN9/O iHHA== X-Gm-Message-State: AOJu0Yw5mM470bXbNhAiJJnXlS3Ya/6eMMf0PleF0+os6ThwDVE+6F/4 zMvDMclamQDnlsbZUMFcSeJmdGVv6kCcusgzBy78TM4MuasIZGo7I95Cq769wWy6r77mbIqcAIR W0r85YRJ5PNh/xsSxyvpFEMQ= X-Received: by 2002:a5d:4a12:0:b0:319:5a7c:6418 with SMTP id m18-20020a5d4a12000000b003195a7c6418mr10305779wrq.43.1695746375047; Tue, 26 Sep 2023 09:39:35 -0700 (PDT) X-Received: by 2002:a5d:4a12:0:b0:319:5a7c:6418 with SMTP id m18-20020a5d4a12000000b003195a7c6418mr10305767wrq.43.1695746374845; Tue, 26 Sep 2023 09:39:34 -0700 (PDT) Received: from klayman.redhat.com (net-2-34-30-58.cust.vodafonedsl.it. [2.34.30.58]) by smtp.gmail.com with ESMTPSA id w10-20020adfde8a000000b0031fba0a746bsm15171803wrl.9.2023.09.26.09.39.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 09:39:34 -0700 (PDT) From: Marco Pagani To: Moritz Fischer , Wu Hao , Xu Yilun , Tom Rix Cc: Marco Pagani , linux-kernel@vger.kernel.org, linux-fpga@vger.kernel.org, Jinjie Ruan Subject: [PATCH 3/4] fpga: add a platform driver to the FPGA Bridge test suite Date: Tue, 26 Sep 2023 18:39:10 +0200 Message-ID: <20230926163911.66114-4-marpagan@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230926163911.66114-1-marpagan@redhat.com> References: <20230926163911.66114-1-marpagan@redhat.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 26 Sep 2023 09:40:27 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778140497750762941 X-GMAIL-MSGID: 1778140497750762941 Register a minimal platform driver associated with the parent platform device used for testing to prevent a null-ptr-deref when try_module_get() is called by __fpga_bridge_get(). Fixes: 9e6823481e5f ("fpga: add an initial KUnit suite for the FPGA Bridge") Reported-by: Jinjie Ruan Signed-off-by: Marco Pagani --- drivers/fpga/tests/fpga-bridge-test.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/fpga/tests/fpga-bridge-test.c b/drivers/fpga/tests/fpga-bridge-test.c index 1d258002cdd7..4bd4ecaa7e90 100644 --- a/drivers/fpga/tests/fpga-bridge-test.c +++ b/drivers/fpga/tests/fpga-bridge-test.c @@ -13,6 +13,8 @@ #include #include +#include "fpga-test-helpers.h" + struct bridge_stats { bool enable; }; @@ -53,7 +55,7 @@ static struct bridge_ctx *register_test_bridge(struct kunit *test) ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); - ctx->pdev = platform_device_register_simple("bridge_pdev", PLATFORM_DEVID_AUTO, NULL, 0); + ctx->pdev = platform_device_register_simple(TEST_PDEV_NAME, PLATFORM_DEVID_AUTO, NULL, 0); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx->pdev); ctx->bridge = fpga_bridge_register(&ctx->pdev->dev, "Fake FPGA bridge", &fake_bridge_ops, @@ -144,6 +146,18 @@ static void fpga_bridge_test_get_put_list(struct kunit *test) unregister_test_bridge(ctx_1); } +TEST_PLATFORM_DRIVER(test_platform_driver); + +static int fpga_bridge_test_suite_init(struct kunit_suite *suite) +{ + return platform_driver_register(&test_platform_driver); +} + +static void fpga_bridge_test_suite_exit(struct kunit_suite *suite) +{ + platform_driver_unregister(&test_platform_driver); +} + static int fpga_bridge_test_init(struct kunit *test) { test->priv = register_test_bridge(test); @@ -165,6 +179,8 @@ static struct kunit_case fpga_bridge_test_cases[] = { static struct kunit_suite fpga_bridge_suite = { .name = "fpga_bridge", + .suite_init = fpga_bridge_test_suite_init, + .suite_exit = fpga_bridge_test_suite_exit, .init = fpga_bridge_test_init, .exit = fpga_bridge_test_exit, .test_cases = fpga_bridge_test_cases, From patchwork Tue Sep 26 16:39:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Pagani X-Patchwork-Id: 144974 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp2050446vqu; Tue, 26 Sep 2023 09:41:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGKmkMcTny4cpiW4TohZCGV+/UZ95d9wxrgK+hHzDWRqymWmNzun+TSY6+ZzDIcr7qnUBEV X-Received: by 2002:a05:6870:3510:b0:1c8:c37d:5e65 with SMTP id k16-20020a056870351000b001c8c37d5e65mr12355232oah.11.1695746468614; Tue, 26 Sep 2023 09:41:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695746468; cv=none; d=google.com; s=arc-20160816; b=rsJE+Mpgp1K5n+WN5clYaxw1APQP8K41BLuRbOz9ViYPDE2Nu5oUdGjb50nliad3Ni AObq/fkdYl/b6nd2OtUy/0Q0qksmhfzPFs81mOoeulIa58HXT1rGoDzOY91NTcYPq9fq /BQX30fgg8RANXLuNOT6kNxSSvZZwgOhSpKmG4iyH14ssasSD+NjRaj6JZiloWByLcR4 OP/CxgE8z5ddvC7k+RHoLOFCZnRcXb24AfLWRp9ULjePFqbhGLBYCxzW8aQjZUqjOegf 8n70vxtM7CAzSqtIRstBBcL2NrWypcSaycBJ/yhO9LQogzR08lM65/zkgEdBTWIrrmxK bYvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4eFMXkTSJCSP/LuqcR7rWb5lOePf6Wh6Ne6wvaIuhIA=; fh=SVLtJx2RN624E9ZvR+iL8AVfiRfKB4Yg6A8iu4u1uGc=; b=T9ffQJRwahyMhAQId/X7XZWt/2NayLVZ036HOBEzs2DUJZcomlX0rd4x4RhjR+RYzx jCq/YRhiawiV7Oia0/zdalxuY0ffOZ/LR8Xs5evLnJj0bIeKIYmQKaTGduSVtEDB+BEa Hr9/gQiJ8QHAJGAz6vE4aQoJ0deWR4far8WroY5oqKHdVQRPb1j7Jmy4hQ6ug/vagG2c MLgjzlY5d85L+h5vM1DJ/pUVM/DtAFhRDAH3gvb3xJ2pntBhacVhrr/8QuXyDxfTHue2 VZQLNBUGQkH2ckwm6XcjANT4KYQvn09K0waaCi0BfhNwn3sSvMPA2klJh9uKFTG+/vu8 TSQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=P+ZAMRc8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id s69-20020a637748000000b00578b63123desi1892678pgc.789.2023.09.26.09.41.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 09:41:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=P+ZAMRc8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 03DEB81E5543; Tue, 26 Sep 2023 09:40:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235350AbjIZQkk (ORCPT + 28 others); Tue, 26 Sep 2023 12:40:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235275AbjIZQkj (ORCPT ); Tue, 26 Sep 2023 12:40:39 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39B62193 for ; Tue, 26 Sep 2023 09:39:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695746384; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4eFMXkTSJCSP/LuqcR7rWb5lOePf6Wh6Ne6wvaIuhIA=; b=P+ZAMRc8CIz9Q844RmioNuKPEncTqojKhzez+aiCV6dOwJSwDn2dEUzzKJtppGaUoaubsn AwmOikOgd9q96oLgyjkyrwMUnYZogMLUp8cA0HiYc7IQPw3u0yzm2S78D/tqjZXCQlXFrX v2ofllA0SCQbweQ/y1wio+6N3SFZCec= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-16-3Oa9ITgwNcG9VWGOncgRRw-1; Tue, 26 Sep 2023 12:39:42 -0400 X-MC-Unique: 3Oa9ITgwNcG9VWGOncgRRw-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-32337a3929aso1415866f8f.1 for ; Tue, 26 Sep 2023 09:39:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695746381; x=1696351181; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4eFMXkTSJCSP/LuqcR7rWb5lOePf6Wh6Ne6wvaIuhIA=; b=qxOrNydS5dE4TSfjs7q574r319udZu4Mdn3wMQBEi3e6xqwjo+0UcrF+F3xUJOWKPP rHIZqH/DIDlAWXWSkfY4GHB78SzjpRDzYzW3dKy8mZptkpc4xbJlhbmAh9+5fJgfFGX7 ymc3SU517n8yZC2/iYRSTAWIM+DjhCR60HK0gQkaGY9+mLE5KpD6z84T9qv9z/fBnN0j 0kwSBOajye27G+ZranpWxR1zk5EFESSuJD4hDTq+TZnH3GN73v0wQPJqgfmFIS0z8TAd W6fmXl5z6j/uvbxnOH9M5T1/Y5tPa7bB3iNXXRwA/HCm/inLJq53umoCcz6/6aahwCUB L8+Q== X-Gm-Message-State: AOJu0Yyy6+Pko/Ht3A2LXqwK2NxwUMOclK1y50wwJNVfvJLNwLxzFlgo gyOBfMjRYtnJOOnCXY5dGok0tL+RVqVkdc9fxmW/Mg5tRRhT2pDmRLlD2FuNx6cBw4/24lPCK53 T4mUtgoTyWvjo9eP2gLHMj80= X-Received: by 2002:a5d:56c9:0:b0:31f:fe07:fdde with SMTP id m9-20020a5d56c9000000b0031ffe07fddemr9729678wrw.12.1695746380835; Tue, 26 Sep 2023 09:39:40 -0700 (PDT) X-Received: by 2002:a5d:56c9:0:b0:31f:fe07:fdde with SMTP id m9-20020a5d56c9000000b0031ffe07fddemr9729663wrw.12.1695746380594; Tue, 26 Sep 2023 09:39:40 -0700 (PDT) Received: from klayman.redhat.com (net-2-34-30-58.cust.vodafonedsl.it. [2.34.30.58]) by smtp.gmail.com with ESMTPSA id w10-20020adfde8a000000b0031fba0a746bsm15171803wrl.9.2023.09.26.09.39.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 09:39:40 -0700 (PDT) From: Marco Pagani To: Moritz Fischer , Wu Hao , Xu Yilun , Tom Rix Cc: Marco Pagani , linux-kernel@vger.kernel.org, linux-fpga@vger.kernel.org, Jinjie Ruan Subject: [PATCH 4/4] fpga: add a platform driver to the FPGA Region test suite Date: Tue, 26 Sep 2023 18:39:11 +0200 Message-ID: <20230926163911.66114-5-marpagan@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230926163911.66114-1-marpagan@redhat.com> References: <20230926163911.66114-1-marpagan@redhat.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 26 Sep 2023 09:40:54 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778119049132471129 X-GMAIL-MSGID: 1778119049132471129 Register a minimal platform driver associated with the parent platform device used for testing to prevent a null-ptr-deref when try_module_get() is called by fpga_region_get(). Also, fix a typo in the suite's name. Fixes: 64a5f972c93d ("fpga: add an initial KUnit suite for the FPGA Region") Reported-by: Jinjie Ruan Signed-off-by: Marco Pagani --- drivers/fpga/tests/fpga-region-test.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/drivers/fpga/tests/fpga-region-test.c b/drivers/fpga/tests/fpga-region-test.c index 9f9d50ee7871..5ff688b394f9 100644 --- a/drivers/fpga/tests/fpga-region-test.c +++ b/drivers/fpga/tests/fpga-region-test.c @@ -15,6 +15,8 @@ #include #include +#include "fpga-test-helpers.h" + struct mgr_stats { u32 write_count; }; @@ -132,6 +134,18 @@ static void fpga_region_test_program_fpga(struct kunit *test) fpga_image_info_free(img_info); } +TEST_PLATFORM_DRIVER(test_platform_driver); + +static int fpga_region_test_suite_init(struct kunit_suite *suite) +{ + return platform_driver_register(&test_platform_driver); +} + +static void fpga_region_test_suite_exit(struct kunit_suite *suite) +{ + platform_driver_unregister(&test_platform_driver); +} + /* * The configuration used in this test suite uses a single bridge to * limit the code under test to a single unit. The functions used by the @@ -146,14 +160,15 @@ static int fpga_region_test_init(struct kunit *test) ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); - ctx->mgr_pdev = platform_device_register_simple("mgr_pdev", PLATFORM_DEVID_AUTO, NULL, 0); + ctx->mgr_pdev = platform_device_register_simple(TEST_PDEV_NAME, PLATFORM_DEVID_AUTO, + NULL, 0); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx->mgr_pdev); ctx->mgr = devm_fpga_mgr_register(&ctx->mgr_pdev->dev, "Fake FPGA Manager", &fake_mgr_ops, &ctx->mgr_stats); KUNIT_ASSERT_FALSE(test, IS_ERR_OR_NULL(ctx->mgr)); - ctx->bridge_pdev = platform_device_register_simple("bridge_pdev", PLATFORM_DEVID_AUTO, + ctx->bridge_pdev = platform_device_register_simple(TEST_PDEV_NAME, PLATFORM_DEVID_AUTO, NULL, 0); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx->bridge_pdev); @@ -163,7 +178,7 @@ static int fpga_region_test_init(struct kunit *test) ctx->bridge_stats.enable = true; - ctx->region_pdev = platform_device_register_simple("region_pdev", PLATFORM_DEVID_AUTO, + ctx->region_pdev = platform_device_register_simple(TEST_PDEV_NAME, PLATFORM_DEVID_AUTO, NULL, 0); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx->region_pdev); @@ -195,12 +210,13 @@ static void fpga_region_test_exit(struct kunit *test) static struct kunit_case fpga_region_test_cases[] = { KUNIT_CASE(fpga_region_test_class_find), KUNIT_CASE(fpga_region_test_program_fpga), - {} }; static struct kunit_suite fpga_region_suite = { - .name = "fpga_mgr", + .name = "fpga_region", + .suite_init = fpga_region_test_suite_init, + .suite_exit = fpga_region_test_suite_exit, .init = fpga_region_test_init, .exit = fpga_region_test_exit, .test_cases = fpga_region_test_cases,