Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2871932lqt; Tue, 23 Apr 2024 04:27:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX/5shZvlmNDjh+kNjpuDVrEaOjj3czoIHfkOnGtqAz/tYp07k/Ov/GA/XPGDV6RinL4MaS8DA+w5gDVEqaiNkdKOP/Ajl4NXyrs7ljwQ== X-Google-Smtp-Source: AGHT+IE7Z1ZmOjByZpF00kUmBQSnnPefM/2E8WylI1jbkSvJ+lagrfjxyazUWxIpNqS4XkJCmwoC X-Received: by 2002:a17:906:30c8:b0:a52:5789:9c5d with SMTP id b8-20020a17090630c800b00a5257899c5dmr7442995ejb.39.1713871677244; Tue, 23 Apr 2024 04:27:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713871677; cv=pass; d=google.com; s=arc-20160816; b=X5Jplp3sHnFDKZmQlrCfijbl750H8rbz6PW4OXb5RuFz/RE8c5fsgc/TOq7E8TSfZp 5GZqHHjLQIPVkvQ42H+1NVn0y47YPL/mjY8+C7gAB6iZSlCWBW0ru109TwI1F1my8Kdz xvcd+fiWHBkhZ3ThNm4aa9oxiTlztDhhVpqMmFcqDKnXzxxjabzoU/6ZEVr3l1Hb9/vT dgk8obSk86nAWIlyGYkwP4NNrAgDzx+LxCg6GTOzAR4+PVf/27+1rAW56px2U4UYGaYH AImik/BAUElI59sC0aATT5tDlvUzYIUFY2sKg/27uw98MPChWBhjHONnOoumGjEs8yYT qDVg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=m1rrcRiDIr3CayrlizEi1iQQ75HHm28vO7ittm9kAHY=; fh=M+GoWv7yNDaWduij8M+I9tDlj0F8WMsyPpyYWITbvCg=; b=LCsnTQXfwql688MvAqC/xF1LzVPNkH7fPQ/wltDtHtWYag6TLVN2h2mhaL5azIRh3H 6wsxwvGJjI+S/HcsQV1JChTFgJnxS0BNQmt/VcfZvaaKw0DeVUAete/HfUArpIm7Ham6 N2xgxtqbZSOySWgRv+pE56BUj0wpWrM3bZE/k+pLLG6Inu0BTyYcVvDwIQ1AdNUTtolF dUJNkA4icdEEVd9O3YxEhf4IJfWFsERz8RdZafDWsIVcCouio8xf5nIHwCXZ7IRpTXGI AB8O0zhB9IXUmlyZ6/qt+zjRd1fv2LLdy3Azdaefu23KFBOcjyWmSlcoxKhLRXSDrHBc GYmw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TCmTUS8r; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-154616-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154616-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ox7-20020a170907100700b00a55b59421afsi2552542ejb.529.2024.04.23.04.27.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 04:27:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-154616-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TCmTUS8r; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-154616-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154616-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 am.mirrors.kernel.org (Postfix) with ESMTPS id C10011F23055 for ; Tue, 23 Apr 2024 07:44:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4540947F7A; Tue, 23 Apr 2024 07:44:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="TCmTUS8r" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (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 8E1091C698; Tue, 23 Apr 2024 07:44:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713858264; cv=none; b=XaRmYtH650PXhm0CLRgvAAbWdAbBCUn8IMsfLZKXb6SBPm724rGSTFP5ij5ZFrvRUEqDmyoyLXw0H3DJpyxA2Z/p3XQU2ANyflv3rpIcwM7f+O+yJwQeXkITOw7Q22RVP6SrXgZ3TaFjjiycblX4lp5rL1AFGOyUVMISMRQZZ9g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713858264; c=relaxed/simple; bh=JTZGZF6/n1PLTGlgTbj3EOnj4s2EN+2YlvWSFQvXm0I=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=apYGz93hnQ8Y3qTQOq/aUhtyK20xJbkvdzyNsl7aapXWTo2mcqYPqjxHJFQrPwHKbVbpqGZ37aw9/XV2qBmiaQQk8FgA9zQpppYw/DiazURrIFuJihHHu4tKlH++8fu8+6FKsLYo6xL55TQlAutg26jtHr6CrvjdCWxxr331Z0c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=TCmTUS8r; arc=none smtp.client-ip=198.175.65.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713858263; x=1745394263; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=JTZGZF6/n1PLTGlgTbj3EOnj4s2EN+2YlvWSFQvXm0I=; b=TCmTUS8rBC5uPOUuPq6J5Umz6LOPXIjqb/c6sNrJpipvEYVRku2usNkL xXyLiPXqaKJMQU1mXBaVaIgH+VJUNRIZmKDU5BHP4uSaq9N6Th2XFoGMD 2Yn5a/x3FfgTqv9rzPHIGqRwMVRK9W322NCd2AAogyuoA84XejIuzmm08 HtaK1mZpT1Mq4bMikXAIBrOiOQ9rlDUfphi2S8BwjEHXKhpNRmKLJfUXg wh+RFFyWUlgaWBDT5ytEVAvqF9vp6tv1FbEoUDyRRJ4yJaaQ9WGWoNcFK vVLGHwP/NevS+KBzGuXn9Yd2V4M9+oNo+Y78PelT7FYEM9QUawCeRPqO6 g==; X-CSE-ConnectionGUID: 8BnXEuTLRX+9Pu7W1KA6Hg== X-CSE-MsgGUID: X8zM3DoQTsa5DMqa86bfMQ== X-IronPort-AV: E=McAfee;i="6600,9927,11052"; a="9302929" X-IronPort-AV: E=Sophos;i="6.07,222,1708416000"; d="scan'208";a="9302929" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Apr 2024 00:44:22 -0700 X-CSE-ConnectionGUID: v6rtPzSbT92u0dSUKcm7Eg== X-CSE-MsgGUID: MJbMIjI4Tn6JrDefDets/g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,222,1708416000"; d="scan'208";a="47565057" Received: from yilunxu-optiplex-7050.sh.intel.com (HELO localhost) ([10.239.159.165]) by fmviesa002.fm.intel.com with ESMTP; 23 Apr 2024 00:44:18 -0700 Date: Tue, 23 Apr 2024 15:38:58 +0800 From: Xu Yilun To: Marco Pagani Cc: Moritz Fischer , Wu Hao , Xu Yilun , Tom Rix , Jonathan Corbet , Alan Tull , Greg Kroah-Hartman , Russ Weight , linux-fpga@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v6] fpga: region: add owner module and take its refcount Message-ID: References: <20240419083601.77403-1-marpagan@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240419083601.77403-1-marpagan@redhat.com> On Fri, Apr 19, 2024 at 10:35:59AM +0200, Marco Pagani wrote: > The current implementation of the fpga region assumes that the low-level > module registers a driver for the parent device and uses its owner pointer > to take the module's refcount. This approach is problematic since it can > lead to a null pointer dereference while attempting to get the region > during programming if the parent device does not have a driver. > > To address this problem, add a module owner pointer to the fpga_region > struct and use it to take the module's refcount. Modify the functions for > registering a region to take an additional owner module parameter and > rename them to avoid conflicts. Use the old function names for helper > macros that automatically set the module that registers the region as the > owner. This ensures compatibility with existing low-level control modules > and reduces the chances of registering a region without setting the owner. > > Also, update the documentation to keep it consistent with the new interface > for registering an fpga region. > > Fixes: 0fa20cdfcc1f ("fpga: fpga-region: device tree control for FPGA") > Suggested-by: Greg Kroah-Hartman > Suggested-by: Xu Yilun > Reviewed-by: Russ Weight > Signed-off-by: Marco Pagani > Acked-by: Xu Yilun Applied to for-next instead of v5