Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp3035447lqt; Tue, 23 Apr 2024 08:41:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWxygkTQQs4xr+LcFrNZ7AOZk2p9iYuiiE4OP5bdVzMTioFmKy/zd6OvSQh7T6xDQsBwMcpvkIqdA3QN35BV2l4ONpd47gu+Nx4tnBXLg== X-Google-Smtp-Source: AGHT+IG/KuPwr3WwKSucZzUSyOS2bFvveDkpFlmlQLhdmOoSC5sXRmuyqnMP5QLc2RVGo5n5jHei X-Received: by 2002:a50:9fce:0:b0:570:21b6:660 with SMTP id c72-20020a509fce000000b0057021b60660mr8489432edf.3.1713886906922; Tue, 23 Apr 2024 08:41:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713886906; cv=pass; d=google.com; s=arc-20160816; b=PeLzfx7f4oSpEcJarxRnbbY/emIGWATgplAONueUsCiknMzTWLWdXl9Kj//D46sSQV gGhvvTy0jKBMQzD+8vq+MKVSPiffPzZlGfP03qDTk+J8QwNOg7XRq3Vf4WTdYcm5Zs3T 2dWEgNOdVuXxmgBB5cqxJD3Idj2AKVYUUrdfOSCN/HU2R2vW9vQwxHUHNdiJyu6yueGl tUyHrh9B/57CN9CjRPU+2yk223Bk+fgJ//YzjMEja3z8AvsUZ+kVSrzDDPB6g7MaJh9u A6aUJYJaBf1/cLTt8ht4J/vXfptk8hj8lOZnzNQdHP3P0UdEqalx0iRXYoBPJCeroHof TP9A== 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=usSgojhHNtu0dcSyiEIe10RAJdc74Ppd2V3oaoyhGks=; fh=hufTE53hfdYUrZ4mmBMH4drBkXWAMeDbWPkkrvhuMQw=; b=zG/ZyE7F4jNtHaNciWOQJOmp1F7PaJMP2ndpj3Fw6t6WarDWY4Cy1sZAHKB6uCOnya 5NJtd+dKEF7Q7tgr4rD7PVn1t/7f30zakkyAQTVZ0MUdfIcU+hLVOq5lLFFAKzg4yd2t 299jUytOWDs9cB+zIPDwWh2JLFIEvsSTV3iLxE6Le4UhWwqnoh9MhxVfxg9p+zvdYPRF XZ8juXifw0GVEPcVSVcBkqxsr//z/rV9buSfKtnNDOfwRXFvVCLWsMFUUTGdzcz6PvO5 cBvWP7O1SXdkDrkgNf8Xz0UO0guQ4tJEK7e2shyr5h2NTUCBq0PQOwY+w98rnu5BUHn9 UW+Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UuQ45rdo; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-155492-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155492-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 v22-20020a50d596000000b0057022d7a57fsi7487564edi.275.2024.04.23.08.41.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 08:41:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-155492-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=UuQ45rdo; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-155492-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-155492-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 B15A71F22C72 for ; Tue, 23 Apr 2024 15:41:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8697513C909; Tue, 23 Apr 2024 15:41:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="UuQ45rdo" 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 1E94513BACF; Tue, 23 Apr 2024 15:41:33 +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=1713886895; cv=none; b=usJ3T7HR8hNES8S2yEvy3dah/Xl5CaIR0CI76mqvUP6qtZjg7iw8SH4ENqfmvHzIPPoxx9t2OBY285uLQ8Bg9qvicvgfRKe214yZj/12xNyyG7jrLkeZfSqOUhDhB2ieJM0UATbZnBssnG7k8jC65xbkOJykbLR4euyNkUAAj1Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713886895; c=relaxed/simple; bh=2zaohWkr4/ZzVOQ18CabMhpIgO+D+z5wejwVM49hizY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=U0Bt4CVgRn2cDBUznAgnCuZaHnYv9z340a9ISi0g6pG1gTo34xVxVSww3Mz2tNHPhGirzlNc1hye+wVpehvIoyXyT52mlDLeiarwRrqeXYftySnlWhK7DnPIk+712qUqxflwOp18uETFcIVS3JjF0FdROHdU4GsJe4YiliToRYc= 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=UuQ45rdo; 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=1713886894; x=1745422894; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=2zaohWkr4/ZzVOQ18CabMhpIgO+D+z5wejwVM49hizY=; b=UuQ45rdoKNvNYqQS85d/giJl9YJV+RjDf8+DrNB+c/vX3PHFa/46pVaG YYxX6t8W+neCClxD4fu8kiMRYx6m7kQlX3hg37kr2deJ3XHFQzO+fzf5F YgZOtvNp7qCLlZzldG/8ut6HYgIdKO+Li8Ihg1y+hHy51df0ANvan9Gqv ZcAfsTRJfXdwaU8v7TGEDqlY/80XBOhWQYO7vIDzyI+KFc/xe0u1cFhkN 5Ue1Dr0IvrdZdugpC7NH0bAZl9D+ZV7dC8wB5Jxmg8mJcV+19aCOnqJxt GBtrCJ/i0y7jQcFJme4CAbmFjzjx231Mm1++4QvYifz0AGpwl7McD2Uya A==; X-CSE-ConnectionGUID: GnVqRvyfRTWOKHps4alGEA== X-CSE-MsgGUID: UOhc6jXjTT6a8zCHIQUfoA== X-IronPort-AV: E=McAfee;i="6600,9927,11053"; a="9353066" X-IronPort-AV: E=Sophos;i="6.07,222,1708416000"; d="scan'208";a="9353066" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Apr 2024 08:41:25 -0700 X-CSE-ConnectionGUID: q0DIaQ9RQC6k9uzKEUrLqg== X-CSE-MsgGUID: vL5W4u/1Sp+NCad6M2FZ0w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,222,1708416000"; d="scan'208";a="24381468" Received: from yilunxu-optiplex-7050.sh.intel.com (HELO localhost) ([10.239.159.165]) by orviesa009.jf.intel.com with ESMTP; 23 Apr 2024 08:41:22 -0700 Date: Tue, 23 Apr 2024 23:36:02 +0800 From: Xu Yilun To: Peter Colberg Cc: Wu Hao , Tom Rix , Moritz Fischer , Xu Yilun , linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org, Russ Weight , Marco Pagani , Matthew Gerlach , Russ Weight Subject: Re: [RFC PATCH v2 9/9] fpga: dfl: fix kernel warning on port release/assign for SRIOV Message-ID: References: <20240409233942.828440-1-peter.colberg@intel.com> <20240409233942.828440-10-peter.colberg@intel.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: <20240409233942.828440-10-peter.colberg@intel.com> On Tue, Apr 09, 2024 at 07:39:42PM -0400, Peter Colberg wrote: > From: Xu Yilun > > DFL ports are registered as platform devices in PF mode. The port device > should be removed from the host when the user wants to configure the > port as a VF and pass through to a virtual machine. The FME device > ioctls DFL_FPGA_FME_PORT_RELEASE/ASSIGN are designed for this purpose. > > In the previous implementation, the port platform device is not completely > destroyed on port release: it is removed from the system by > platform_device_del(), but the platform device instance is retained. > When the port assign ioctl is called, the platform device is added back by > platform_device_add(), which conflicts with this comment of device_add(): > "Do not call this routine more than once for any device structure", and > will cause a kernel warning at runtime. > > This patch tries to completely unregister the port platform device on > release and registers a new one on assign. But the main work is to remove > the dependency on struct dfl_feature_platform_data for many internal DFL > APIs. This structure holds many DFL enumeration infos for feature devices. > Many DFL APIs are expected to work with these info even when the port > platform device is unregistered. But with the change the platform_data will > be freed in this case. So this patch introduces a new structure > dfl_feature_dev_data for these APIs, which acts similarly to the previous > dfl_feature_platform_data. The dfl_feature_platform_data then only needs a > pointer to dfl_feature_dev_data to make the feature device driver work. > > Signed-off-by: Xu Yilun > Signed-off-by: Russ Weight > Signed-off-by: Peter Colberg > --- > v2: > - Split monolithic patch into series at request of maintainer > - Substitute binfo->type for removed function feature_dev_id_type() in > parse_feature_irqs(). > - Return ERR_PTR(-ENOMEM) on !feature->params in > binfo_create_feature_dev_data(). > - Reorder cdev as first member of struct dfl_feature_platform_data > such that container_of() to obtain pdata evaluates to a no-op. > - Align kernel-doc function name for __dfl_fpga_cdev_find_port_data(). > --- > drivers/fpga/dfl-afu-main.c | 9 +- > drivers/fpga/dfl-fme-br.c | 24 +- > drivers/fpga/dfl-fme-main.c | 6 +- > drivers/fpga/dfl.c | 430 +++++++++++++++++------------------- > drivers/fpga/dfl.h | 86 +++++--- > 5 files changed, 281 insertions(+), 274 deletions(-) > > diff --git a/drivers/fpga/dfl-afu-main.c b/drivers/fpga/dfl-afu-main.c > index 42928cc7e42b..ead03b7aea70 100644 > --- a/drivers/fpga/dfl-afu-main.c > +++ b/drivers/fpga/dfl-afu-main.c > @@ -143,9 +143,8 @@ static int port_reset(struct platform_device *pdev) > return ret; > } > > -static int port_get_id(struct platform_device *pdev) > +static int port_get_id(struct dfl_feature_dev_data *fdata) > { > - struct dfl_feature_dev_data *fdata = to_dfl_feature_dev_data(&pdev->dev); > void __iomem *base; > > base = dfl_get_feature_ioaddr_by_id(fdata, PORT_FEATURE_ID_HEADER); > @@ -156,7 +155,8 @@ static int port_get_id(struct platform_device *pdev) > static ssize_t > id_show(struct device *dev, struct device_attribute *attr, char *buf) > { > - int id = port_get_id(to_platform_device(dev)); > + struct dfl_feature_dev_data *fdata = to_dfl_feature_dev_data(dev); > + int id = port_get_id(fdata); My quick idea is we go with these steps: 1. refactor struct dfl_feature_platform_data then replace all dev/pdev arguments with pdata when necessary. 2. factor out fdata from pdata, add fdata helpers. 3. massive pdata->fdata replacement. 4. delete all unused pdata helpers. Please check if it is possible. Thanks, Yilun