Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp429937rdb; Fri, 5 Jan 2024 15:15:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IFqRwjO1415vrhwZlp3CTQ7CUiLzpNEo7v4E8u1OuVCZAN9jGClwLgh3P+cwAuHowBb78Kj X-Received: by 2002:a05:6e02:3a84:b0:360:780c:d2ab with SMTP id cr4-20020a056e023a8400b00360780cd2abmr242189ilb.5.1704496548550; Fri, 05 Jan 2024 15:15:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704496548; cv=none; d=google.com; s=arc-20160816; b=a0tUlTcEx6+mdUF3JFC3xaJ9I9XnOIJJE2FavTiGew0a+HCRzJyAJg8I+y0fAD8yj5 ld2y7zFc/8SYwlhaKljfjHtaSMqeRBMEy3SFpV6IeP3WgcvgbTJNBSD00tx5LlwQUGqD EXx633JwByInJ1shsnxMVfatwd6tcZzzDFgxElPtB7h6r2RrVQAYzXCgv/LjUJRGrGRB 4PU9pUG7jNYYZYIWKNTV8/qTKyf5hr+IJXEewIwCysuWqYqTPjVVuC9EqThGNU5dDsxs 8jLffT+yNbMWZpg8a4Vel4n/zIEgfQX3D0xayB83uIIW/jOCqkF7PbiFuTxDNpAdp3yd rqrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=SR4FNZ1ZczSS8WEbs/1VXeRwzlcPX29OcKlDtIlAL20=; fh=RI0mNHrSGBk/0gJ3tsBPdYn+81ROXQTqubQc1unKFUU=; b=IAHsK6E0jdrgqfYnIykZ/9zWGnIP5tp+tiB3zlKpjDEVctxBAuCXwX8aYjTf28/tBb 3mB0qI8uAmWXxyvWCs+eg5y1jt2d+e98ia/uj+zJCC/f3VnjcJHE2oxpahfyr4qzvygb NIQbiSM9iBbgZ0/AjWDpXhrAdKMKVJECi4RlqN6SwSR4EBJBO/ROwql3KmjjLWrDBEa8 /m5iJGy6aZrYZY7pB3p8+g4CZLCfi/gxL78LQ2ldeedktUUiDDJoBAenFJ5HTCxBj35x pX1CO5VcImbfcX5vE9RXnM0erLeUI9zV9U2b7nOWPO+mlR3XcqfsmsxEVKN1+NRiDEhR wnJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NZuhBA3D; spf=pass (google.com: domain of linux-kernel+bounces-18411-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18411-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d21-20020a637355000000b005ce19c68671si2036610pgn.497.2024.01.05.15.15.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 15:15:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-18411-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NZuhBA3D; spf=pass (google.com: domain of linux-kernel+bounces-18411-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18411-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 230EC284D9E for ; Fri, 5 Jan 2024 23:15:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C3BBE360B8; Fri, 5 Jan 2024 23:15:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="NZuhBA3D" X-Original-To: linux-kernel@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 66EAB3609E for ; Fri, 5 Jan 2024 23:15:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704496539; 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; bh=SR4FNZ1ZczSS8WEbs/1VXeRwzlcPX29OcKlDtIlAL20=; b=NZuhBA3Dwmz863o/aVeDvECvZjJVkfTLZ1dF+aGMpatlSTz2aQPCmSSRijzzURBIawg5rN WzMob+psjTeO86VKQHLNH+eHx75GQbGzwtDviDNrHmmssXpSMRvrhQsg+iLIjTx973yFo4 Iore3UqB+/msIQZFTWA9h9x+ofr5GF4= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-426-jk3fZT5FMpesA5VcPa2h3w-1; Fri, 05 Jan 2024 18:15:38 -0500 X-MC-Unique: jk3fZT5FMpesA5VcPa2h3w-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-781e9899388so7407085a.3 for ; Fri, 05 Jan 2024 15:15:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704496537; x=1705101337; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=SR4FNZ1ZczSS8WEbs/1VXeRwzlcPX29OcKlDtIlAL20=; b=lzxynGycbnoV3Yg8U/grpkUpksWjGqsWJhCoQD/J6VurZHDBYGwZOQbm2FIHDOtkji GHfq11KHP6z5TxFGPZXXQHv06/mUN13TTH11nAQ5267C/VHWMV6hdNYco6vYmBCQKAdI /K598nzh+5vVZfHzXyMWIQYNxQylFZF1zltI7US9K8xHOJRlNmbX2ewS5lXeNBq1ElRg TZhwA6DDCyxVLicEiPb2ylu9kk0ulhiSTaqbb/Aim7xP06/ffan7vIa5eKMQ+G4qtOd6 0omnnj2GmU3fGF4qmcb+mzJaPxZjdHqktfTN4DZYhorht1epSugTPRX95olmIET9lf/c DWxw== X-Gm-Message-State: AOJu0YyzD5iqMtEEeqVs7NSIHinNXIv9ts7WzAxNqsdVV4bB6VxeX/VS MiblaPc1sYCxe89T3eNifjcMb7YJW1vS0QC3D2/ZNH7oTUfdVm8msBF+Ds9CP8IhnuVPFn+PzBp lCfDEivUP0fcdCv/cTtKxUzRxFZoccwQ= X-Received: by 2002:a05:620a:2016:b0:783:d29:70d6 with SMTP id c22-20020a05620a201600b007830d2970d6mr146626qka.20.1704496537578; Fri, 05 Jan 2024 15:15:37 -0800 (PST) X-Received: by 2002:a05:620a:2016:b0:783:d29:70d6 with SMTP id c22-20020a05620a201600b007830d2970d6mr146611qka.20.1704496537331; Fri, 05 Jan 2024 15:15:37 -0800 (PST) Received: from klayman.redhat.com (net-2-34-31-72.cust.vodafonedsl.it. [2.34.31.72]) by smtp.gmail.com with ESMTPSA id i9-20020a05620a0a0900b00781bd8b06f8sm935915qka.62.2024.01.05.15.15.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 15:15:36 -0800 (PST) From: Marco Pagani To: Moritz Fischer , Wu Hao , Xu Yilun , Tom Rix , Greg Kroah-Hartman Cc: Marco Pagani , linux-kernel@vger.kernel.org, linux-fpga@vger.kernel.org Subject: [RFC PATCH v4 0/1] fpga: improve protection against low-level control module unloading Date: Sat, 6 Jan 2024 00:15:25 +0100 Message-ID: <20240105231526.109247-1-marpagan@redhat.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This RFC proposes a solution to keep protecting the fpga manager against the unloading of the low-level control modules while addressing the limitations of the current implementation. Currently, the code assumes that the low-level module registers a driver for the parent device that is later used to take the module's refcount. This proposal removes this limitation by adding a module owner field to the fpga_manager struct that can be set while registering the manager. For more context, please refer to these threads: https://lore.kernel.org/linux-fpga/ZS6hhlvjUcqyv8zL@yilunxu-OptiPlex-7050 https://lore.kernel.org/linux-fpga/ZT9qENE9fE3Z0KCW@yilunxu-OptiPlex-7050 v4: - Use helper macros to set the owner module v3: - Improved locking v2: - Fixed protection against races during module removal Marco Pagani (1): fpga: add an owner and use it to take the low-level module's refcount drivers/fpga/fpga-mgr.c | 93 ++++++++++++++++++++++------------- include/linux/fpga/fpga-mgr.h | 80 +++++++++++++++++++++++++++--- 2 files changed, 134 insertions(+), 39 deletions(-) base-commit: 610a9b8f49fbcf1100716370d3b5f6f884a2835a -- 2.43.0