From patchwork Fri Sep 29 15:20:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Pagani X-Patchwork-Id: 146713 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp4239314vqu; Fri, 29 Sep 2023 11:48:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGprmvuJjK5nNSHGsKL4anjOuehCbv2xzqQn4Zu1T3U2TRau/EFLDFHP9qaIyKmSdx0xUeq X-Received: by 2002:a17:903:22c7:b0:1bf:3c10:1d70 with SMTP id y7-20020a17090322c700b001bf3c101d70mr5847348plg.6.1696013303176; Fri, 29 Sep 2023 11:48:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696013303; cv=none; d=google.com; s=arc-20160816; b=CR4u20tooiSBz7KomsI3MnFO2ARjYlu/wY2Lnx3HQGx8WzOwzia40kRSb6SoVqclWp IJ91dnDuIbNZauoqwH73uTn8V7THQN1TPuSXjG55VfcClVVsZyPEGseudSOsfMWwrmeh mYW+yH3hLEzUQtxdj6CwpahDSMIhKqUmLrgRbWjruCuUngQBb+hDoGSVjRuoJj1Mvorn 2SWCSM1+Y/1Hi+UrGMm/REwDAW/AIcepgGTUeSO9NzJqKWkmuzvhKdtDmAMPdpu0KGdj GPW6Mmku2FcXrCgaW1O9gcY4fRsJg09ayc6qZvIP0MLGMO3EYAvmwzZjfcdysoL+3Uzk 5TRg== 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=0DUH2bfyE6C8uTlVJHwvrkC7QPYIHAMcvQVh1UrVCss=; fh=vL6Moim7ujQ71QOBXYMaaPnG1N9WYgskJqrZSTruGY4=; b=eoFGxbWEpyhWWAKXMJGtlG0QtTAVVx1Mbaxj0Oh7farPY/9YkEMOJeJ2IXgnAkoTKZ ZyuJIw8b1C+YzpFaoa71KBtbvGX8kYGPuHPieaM1+VG2iVeOxEEbMQiFpTtDj96gu62Z HLzPRzmoXHV1DkF46QXG5zydgjU1GZq9XaqFfiBe6Kadt8CMgogk1CHAzl1102zGeJ5a 5PZ6J6Io3Z/m9l4I5Q+BhJ8/RmVVYYe390At2LXxJH3tA2F+a/w22B2p4ZMheZzm71pF 0jRyArt9Fose+gJxNPpPz9jwPazLVdUjbnLyLixr0GIhubf6yvQm7kv+cM/+t46GWDoH ppKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HeM1+WIo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id t7-20020a1709027fc700b001c72c258f82si6267530plb.99.2023.09.29.11.48.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 11:48:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HeM1+WIo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 9CF6A8077549; Fri, 29 Sep 2023 08:22:19 -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 S233608AbjI2PWN (ORCPT + 20 others); Fri, 29 Sep 2023 11:22:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233556AbjI2PWK (ORCPT ); Fri, 29 Sep 2023 11:22:10 -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 97E1FDD for ; Fri, 29 Sep 2023 08:21:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696000879; 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=0DUH2bfyE6C8uTlVJHwvrkC7QPYIHAMcvQVh1UrVCss=; b=HeM1+WIosXRa2nsxhpl3wUxVclD9nCovhiDx/W46O/en/eeWmLhFXlOQYHDKtw47iV9oob lmPCELMMTVgkDyQ4XxFthSMUz9dXMg4H5li6IMs3psaqzOUOFT7M786fiPeViCAWKOsw76 WF3jvdnvTdWGdEzIr25cwaMb/wZE8Zc= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-571-nkowmXDEN-SdAGwCAHYSpw-1; Fri, 29 Sep 2023 11:21:18 -0400 X-MC-Unique: nkowmXDEN-SdAGwCAHYSpw-1 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-4180b3a5119so185010141cf.1 for ; Fri, 29 Sep 2023 08:21:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696000878; x=1696605678; 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=0DUH2bfyE6C8uTlVJHwvrkC7QPYIHAMcvQVh1UrVCss=; b=srqCD+sPuz1iIFqLlCTihApYRg93y7NxH97GF9QDJEyc/drpDQVTEUY2j8xSL5k/DF tjX3h0s7JqeWHAF2uYpv07cX8Dse5cDUl+V/eiXuovax6OWilmuOzz3rR8S31MHdgNGh xVwdIOLjOCcfUiU4Xpd6zrbikpL6NdBpoIh2VpHELm91IlBrKUIbjDEJvgxU68h856ay OIn3uqwcxI+wQJ/6gTEYXnG4ewbMIaAYEVAXzD/7ipp4xvI+R5GwVI+BwdyZ/yqQQ0VP N01H3oeEJY7kJBoADzJAiQTRNNj7H55AjpSSRyxINlr4udrVS9SAFrXmGRFkVajiT6tb Ci0A== X-Gm-Message-State: AOJu0Yx9oTn0zhZyoVFglle1WGSJy1QDRo8I6OpMJqSq2Yh5YN+JSw/6 ip2RNcsfYb/P3Nref2UZE660bZHFVJHFYH4Nihti16M3b1e6wo1H/0a5SI2xuGATb7refl9lnhX mnHXAhoBWASSjw/rDn33ytjM= X-Received: by 2002:a05:622a:118e:b0:418:11ab:1c00 with SMTP id m14-20020a05622a118e00b0041811ab1c00mr5502844qtk.49.1696000878151; Fri, 29 Sep 2023 08:21:18 -0700 (PDT) X-Received: by 2002:a05:622a:118e:b0:418:11ab:1c00 with SMTP id m14-20020a05622a118e00b0041811ab1c00mr5502823qtk.49.1696000877846; Fri, 29 Sep 2023 08:21:17 -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 bq14-20020a05622a1c0e00b00419801b1094sm287053qtb.13.2023.09.29.08.21.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 08:21:17 -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 v2 1/4] fpga: add helpers for the FPGA KUnit test suites. Date: Fri, 29 Sep 2023 17:20:54 +0200 Message-ID: <20230929152057.85047-2-marpagan@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230929152057.85047-1-marpagan@redhat.com> References: <20230929152057.85047-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]); Fri, 29 Sep 2023 08:22:19 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778398845028003692 X-GMAIL-MSGID: 1778398845028003692 Add helpers to facilitate the registration of minimal platform drivers to support 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..6a28ed30bf71 --- /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_H +#define _FPGA_KUNIT_HELPERS_H + +#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_H */ From patchwork Fri Sep 29 15:20:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Pagani X-Patchwork-Id: 146738 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6359:6f87:b0:13f:353d:d1ed with SMTP id tl7csp3518788rwb; Fri, 29 Sep 2023 12:34:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE7DSrdrCEg1O5t1LuMelxFUp8l6rfsig1EmI1gJVfr3uMTKd+0hJcnI2ojoOYneLnyXCCX X-Received: by 2002:a05:6a20:1054:b0:161:2df0:eadf with SMTP id gt20-20020a056a20105400b001612df0eadfmr4676973pzc.24.1696016057570; Fri, 29 Sep 2023 12:34:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696016057; cv=none; d=google.com; s=arc-20160816; b=SNg8ubqYCyjQDtwhELaWrXJ3dVxRgduBUWoKNFnKg+UpcZf1zopCJxXoRjYtLWsXdy oR8o/sVfuhxvCF6ObDXXowJHfV0rRwb0IHO675bKerlyRvJj6T3gFbhNmhaQxHKqVmYN b3pHc6fDzOjxTIvQ3IkZ0n/Kk+eI++lkkHHD4Xb0wAcWcDFg5mS/nGp5Bk9cc85Uzrue OLAQSHCZuHildUXw+LtJWlklE71aEqvb+yRg6z/YDA8Sv+IqYHjXcNwujNMvsLxg2nbD itQge8ELn6BYkhLbUgwOkua12sjj2A35fwy7l0cpuYnoIBo6iW1lwxVcd312/3Z24I6T dfYA== 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=q37BM/rssmUKJGAALYZfMw8l6eKZfoGn+6QnbPLuY9sAhwjvCg5y41IK57c3ObCJV3 03pJJ2utFnckJIBRQ6UaTGJjDHrRKcv44a751FjgelEchQiL1ihfBGwoOsMKnpsrm2ql 3UoA0XcTZzVXXVJ+M0UZDUXGADI7ivjLU8qgNd5DM1W33x0sopvQ6fY76dfxMzXIuYP9 w0Rvd1p70FCeQ6TGP+626sciq4zfLHqm5o374hPkCfS5UAwUk+mT/3gNLXR8SuVTNXtq hq6dCrH/tWOrCbKXFNiZLz7OOrt1RuFugM1YLSACP5Kc0uwKQNrDHk7MHkcAb329770M 2gzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YkO6UYGv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id k6-20020a6568c6000000b0055fd1bfacafsi21666027pgt.755.2023.09.29.12.34.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 12:34:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YkO6UYGv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id 3029381BC492; Fri, 29 Sep 2023 08:22:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233536AbjI2PWM (ORCPT + 20 others); Fri, 29 Sep 2023 11:22:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233552AbjI2PWK (ORCPT ); Fri, 29 Sep 2023 11:22:10 -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 0873BBF for ; Fri, 29 Sep 2023 08:21:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696000887; 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=YkO6UYGvOvLZwYAx7VHjqVQwFsXVSv6MHDfjtM4zzUYTOcYv3FsJnyLRbB02+zOPCjVMPb 9aKReMMi4K3YIENzitwUOand7FwcwjEjqyHMSrchuhxRL3wEqOXjDtYuXL2vAyFc4Q7o+e 41mN5JqCtiG544uEiF7bMAsJiVBqmTA= Received: from mail-vk1-f197.google.com (mail-vk1-f197.google.com [209.85.221.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-594-bU7GacFBPjuewLPxMfOhIg-1; Fri, 29 Sep 2023 11:21:25 -0400 X-MC-Unique: bU7GacFBPjuewLPxMfOhIg-1 Received: by mail-vk1-f197.google.com with SMTP id 71dfb90a1353d-49093c3acacso8104711e0c.0 for ; Fri, 29 Sep 2023 08:21:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696000885; x=1696605685; 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=CSAkSuahnSPYyamZoqCZ66t7Ue4+bNf+ZjWB22XeYDIdjI9kTMG4D/pTH+YeMDum/e Di0DCGNwlIqKq02g2IN1iglWfE573ITcWDi4h+HghzDyQuNt/HcPmYI2cAgxj30d8fSI Co4knmiimSgxrtUXmyn9c/U+epPwGM426D3klzYBxwjRiqMz3XQkoE72rGFHSr9NUZ+j qbBepmhkv7mwZTw8LtWIEwRxa3b1K8XQSNE/RLQ0eSRwDNyx1ErSx1Kau0mLvTz3bQuZ j9tsVY9kAkpab8y/Isebqmq15HaHncJkr/LSv6jRJLTmKbyWdknYlmderiWtNBMg3UTq EtoA== X-Gm-Message-State: AOJu0YzgCSyrJPJ+/4pGKclkExOQ1HWjhSFGKA6N60IIqumifgokeLPV nrJNTbXU0uSbm52sKuPQ4OaUkhanTzsqDm6iZjoN9UTC6aL2+F+FA76xuR0W64IzzTAtCGcX+7x Ro54xa/DciFQCwVeObG8BTxs= X-Received: by 2002:a05:6122:32cd:b0:49c:37a1:2358 with SMTP id ck13-20020a05612232cd00b0049c37a12358mr4322982vkb.14.1696000885103; Fri, 29 Sep 2023 08:21:25 -0700 (PDT) X-Received: by 2002:a05:6122:32cd:b0:49c:37a1:2358 with SMTP id ck13-20020a05612232cd00b0049c37a12358mr4322964vkb.14.1696000884850; Fri, 29 Sep 2023 08:21:24 -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 bq14-20020a05622a1c0e00b00419801b1094sm287053qtb.13.2023.09.29.08.21.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 08:21:24 -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 v2 2/4] fpga: add a platform driver to the FPGA Manager test suite Date: Fri, 29 Sep 2023 17:20:55 +0200 Message-ID: <20230929152057.85047-3-marpagan@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230929152057.85047-1-marpagan@redhat.com> References: <20230929152057.85047-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 agentk.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 (agentk.vger.email [0.0.0.0]); Fri, 29 Sep 2023 08:22:46 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778401733737868129 X-GMAIL-MSGID: 1778401733737868129 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 Fri Sep 29 15:20:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Pagani X-Patchwork-Id: 146847 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp142106vqb; Fri, 29 Sep 2023 18:32:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFpQHaP10b0PX9oylotxtoOrQ5vPj6E4qYTK6sSb7PD8mrArfG9YRYGW+Yv6k1zXWT1lClP X-Received: by 2002:a05:6870:912c:b0:1c8:bae6:527d with SMTP id o44-20020a056870912c00b001c8bae6527dmr6563489oae.55.1696037578982; Fri, 29 Sep 2023 18:32:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696037578; cv=none; d=google.com; s=arc-20160816; b=IcT0YDJEHWCyA1qc4qLzcHvXjlUop7sXNmR/iqRWhm/08vftTvujt0pcjBhUJeAw8G yNV1TIUKRB/hUpqJUkG1yNYaQQT4kDb9rUXPEnWIKQsjUgN0/bXZf+p6O+RJo/TfRvYn kM+O18MxyfhtScs14vohZeitAJ3fbDRdlxYvwzms4bBZj4qVCMpIT2I4PE/Rt2wtSL1P VgFcg9BbNL3JVleRoG1XWELS2GjCBO9c4X4P0bPZKytVWj5c7cqrWRgqB5nq1aTr3zjY EZ5QZrK5C9FyElisdDjCqTMR0WUeaqKr/z3+m4ddv8V9QmJNCTwB3lDvZz0Hi3CIeXn5 POZA== 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=KTsqmyUUpLDQRbhT2jm3o5i1J+KPHsOHpynlQDpGzJKRJdT8brN2Ri+LVLfNQgYZOf uLaehY3jwzOpaNNQS3L1BuqUhhzgBl9Ai/REjXy8ifIV09/xO7ETwURBwU9CkllmM1Hw dZSFDXxNCSIauiIIN9cF5J1PgSoBp689DlzmidW3aaawyrKOd0T4w44Dj6zD+QJg4WK1 WbBXRqFMbR+yALznn3JhGQ9dBuCR1OvZpeQvxPddnrAj68XMnFRLLcSlVA0SjfQ4Xc8b 3BBXW3prLlLUOtoKFWgaa5weWEcyCxKPqI/sKAO4IPsifkTu39l+ay/1A1B3MypbTWGg oz6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=G06tgh5G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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. [23.128.96.34]) by mx.google.com with ESMTPS id z1-20020a63c041000000b005789f552066si22035714pgi.335.2023.09.29.18.32.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 18:32:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=G06tgh5G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 BC24A80259D5; Fri, 29 Sep 2023 08:22:30 -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 S233676AbjI2PWW (ORCPT + 20 others); Fri, 29 Sep 2023 11:22:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233601AbjI2PWO (ORCPT ); Fri, 29 Sep 2023 11:22:14 -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 5BD4F1A7 for ; Fri, 29 Sep 2023 08:21:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696000894; 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=G06tgh5GOcgTz7fETM26pHVPdaWaKTJ096RYjAAu9GehTvDcosihwahGUcTHOrWouiLZs4 N3Yh51eJ2wkf35bWc8o/g35StgYcoIsh6qf+Lp2S47aL61+jkgvbjzGwpcb1LUI5QNnZaI 7Cg1vTr+h7yBWySflrEPW2hrBX/QhbA= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-664-7OVtCUmGO227bbUWFmYzgg-1; Fri, 29 Sep 2023 11:21:33 -0400 X-MC-Unique: 7OVtCUmGO227bbUWFmYzgg-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-774335cb98cso1890768685a.2 for ; Fri, 29 Sep 2023 08:21:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696000892; x=1696605692; 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=Srps9/miEO3+CN1q/KpFAnp803g2edVr46HlFLZsxKsWbUicg1Pw/OSKk//aZB5l7W lck8amLZup2y/XhmwLomdNcmlGyTp4GWcybcWnyKRnn7V9mQnu7MCRlYtUN5WWa2d2s9 6ZxlZn87Uc5Cbi6LOBmbMyvgTWtebVvTdQlEEuj+1BxDyQ447bYisK7obJgp5TKzJU4c mwkFITDqkSTC0PQAUBP9NV5Wf33XUYlSF60kZP5+yXA2wpLcUfIHEhydzRPCj3gVyvEe nP62248ygykNlaE4Qe5WYOkBLI9eMfqCiKQz49LrExlqPNHTt4cR89s7P06Juwh+1AUq EQJA== X-Gm-Message-State: AOJu0YwmgBkviSc9I2ZfGzZGh+uAGw9WoDIfcDID6/bfisl9OwgTES/X l7HWbmWqQFh9Z5YviU2I3o77eaZjoYvON6PJedjFfooVJOgO/Dx2VEGdvbE9rMwK/YYyU5vKpS5 YuvyRltOswEymSxaAqcE6g8w= X-Received: by 2002:ac8:5892:0:b0:412:1899:76d0 with SMTP id t18-20020ac85892000000b00412189976d0mr5347711qta.63.1696000892716; Fri, 29 Sep 2023 08:21:32 -0700 (PDT) X-Received: by 2002:ac8:5892:0:b0:412:1899:76d0 with SMTP id t18-20020ac85892000000b00412189976d0mr5347689qta.63.1696000892501; Fri, 29 Sep 2023 08:21:32 -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 bq14-20020a05622a1c0e00b00419801b1094sm287053qtb.13.2023.09.29.08.21.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 08:21:32 -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 v2 3/4] fpga: add a platform driver to the FPGA Bridge test suite Date: Fri, 29 Sep 2023 17:20:56 +0200 Message-ID: <20230929152057.85047-4-marpagan@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230929152057.85047-1-marpagan@redhat.com> References: <20230929152057.85047-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_H3,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 (howler.vger.email [0.0.0.0]); Fri, 29 Sep 2023 08:22:30 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778424300221494067 X-GMAIL-MSGID: 1778424300221494067 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 Fri Sep 29 15:20:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marco Pagani X-Patchwork-Id: 146702 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp4222871vqu; Fri, 29 Sep 2023 11:16:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEYThyGjGgCwKqzJYMX3XWnAbRw0flfecW4/a0WA5VLl/36hRMji/ZhtObg4KxqCxCQr/8y X-Received: by 2002:aca:d03:0:b0:3af:6584:9844 with SMTP id 3-20020aca0d03000000b003af65849844mr4547304oin.11.1696011360559; Fri, 29 Sep 2023 11:16:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696011360; cv=none; d=google.com; s=arc-20160816; b=S0laQFSlt3IeLvWUh22+cUjKJsjCJwW2OfYpJJa4i0usdEH/qYDEUTI6A81B9CZAJ+ LnQJ366OdHqbnHRJdm2O0yLSfDCwvY5VK+F79lclWcvPe9FuhNjUW0n7MiOwIYedStM0 5xzPvqab136UI2+XRhoBg8CrOfFlZ3PjIc38s+JuiIRgcEGr/pLGO1bBpBm0X0QRw8eK +NiROEhbobpiOckHHRk2/tk2WFRY0OFWX+Atwyh0QJwfgAdaKp50zAALwMwwBUhPWHGn PAbXBT2quN7mEqizHBWMvPtohoDWFXvDjRjfN4nZ40VLkKe9/YRTqtj6iIRgK8XYBKmb Un5A== 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=cJIcIMET3Z5JR5bAolDY+54zqhRGPslJqRKaay4ORO9B42FXHp6v5f9zy7aWLgL9yz aFgh2ewT7srR7XPyUGZO6gZ/eBtHYCsTmEvHX4iuv8NgtMMu2tJn5mG7QBroUBJ1UZBT bPYVDFeqlOuelDcXzMTHg7pW1vxPp4nqFykPcsgMeAOhiAByMBj/ZqcRkxSwVrIXr5jS 3YObmsnftcvBngI4jOJMsB4g+4QNPdslM9q/hDJ9m75Ur9g0rg7CaUIXtfvlMb/MRkvy r9Du+XFDuRQhXMufD2Hlfn0kl+zXC/LqmzEIMvo+EOsDG7aLFSb1N5ts++o0R9azwMl3 CEuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CCP+LNWc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id g18-20020a631112000000b00578b9064636si21395910pgl.242.2023.09.29.11.16.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 11:16:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CCP+LNWc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id 565AC82C7B68; Fri, 29 Sep 2023 08:23:07 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233645AbjI2PWj (ORCPT + 20 others); Fri, 29 Sep 2023 11:22:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233647AbjI2PWd (ORCPT ); Fri, 29 Sep 2023 11:22:33 -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 356D01AE for ; Fri, 29 Sep 2023 08:21:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696000905; 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=CCP+LNWcuUxPspuhkm3z/pccUJFLnv4ybLoHBPorBBoxATx1n4DzDrDviAOzboKWsSsDUQ r0/3a5qM43qDTxMn2HADU+SvLkoXS9zIwpK8+uoSOIEAeKtCHk3UmNEa4b8g1yV18vXrsZ JFuQbmQkFqmC9aK/E1PnmBZPQjVs1vA= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-128-IRYcF7uRMPO9KGexSBqlog-1; Fri, 29 Sep 2023 11:21:44 -0400 X-MC-Unique: IRYcF7uRMPO9KGexSBqlog-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-65b0249818dso181670056d6.1 for ; Fri, 29 Sep 2023 08:21:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696000903; x=1696605703; 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=hcevS+HV4J7G7kOXpIPJiiYhzoeJ6IUmOSQaeyp6ACPWjL6SuYnybfOkYALvzSuR+2 ypDlnhKug/CtyrlvlZ8dtjwE+ex30j4QliIMet4YGc3TZtqx2qNPPR6VoEc/5gnX6ZWJ LDpZZX6+T0YjhfibXRQkJOiHbKDL3y3X0RRERnqZX3z+Zmi3gWPs2ONiCjlGnTlrRr+Y RmodCxn/CgK+7trvNU/CgGqL1pJwyhXnacuC2GmodKtuEUQJxqnqO8RaOQAmSdMpzkvj ITrVixMnl2EIl2Ogi+xwXF/kgxt2EHnvmzQnxSAoONIb024IWhf4ADT0+wCRPJvb09Cm qTFg== X-Gm-Message-State: AOJu0YxKeTeFob1UgjnziWPakYAWDqN8ZuE2PHCkVE6W/0YxhBEIgFpX OU4yfkCglJepS7Q7UDSydoGzk/5Tft0fQkVcz4eRPk8WBH9e0U/mhWnCM5dPUjP2YVlVoQ7yn5/ 1sadwm0tRn7LKo5IPM6i1LuM= X-Received: by 2002:ac8:5e0d:0:b0:412:1e4c:e858 with SMTP id h13-20020ac85e0d000000b004121e4ce858mr5611985qtx.36.1696000903601; Fri, 29 Sep 2023 08:21:43 -0700 (PDT) X-Received: by 2002:ac8:5e0d:0:b0:412:1e4c:e858 with SMTP id h13-20020ac85e0d000000b004121e4ce858mr5611964qtx.36.1696000903357; Fri, 29 Sep 2023 08:21:43 -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 bq14-20020a05622a1c0e00b00419801b1094sm287053qtb.13.2023.09.29.08.21.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 08:21:43 -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 v2 4/4] fpga: add a platform driver to the FPGA Region test suite Date: Fri, 29 Sep 2023 17:20:57 +0200 Message-ID: <20230929152057.85047-5-marpagan@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230929152057.85047-1-marpagan@redhat.com> References: <20230929152057.85047-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 morse.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 (morse.vger.email [0.0.0.0]); Fri, 29 Sep 2023 08:23:07 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778396808433721445 X-GMAIL-MSGID: 1778396808433721445 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,