From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 2D25C325701 for ; Tue, 16 Dec 2025 15:16:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765898180; cv=none; b=hGtmU55HysR50Zq05foQdLtvs4ztmYuAC1AxNQee9gRmBoe505d4VKtprQF0TcunQ2ctUnO6cGep3oVYtvjLd+1Gu4WulXhemS9nCHMmSpl5LV3/7TkpjXpiRe3NhfD9iUZzwUiCQbUY+tqYwhwA3cSY1Dcyg1j5qLjTAb6j60M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765898180; c=relaxed/simple; bh=xEiw3/MtFG45NReGwfEyl6N3nBoIQ4msAhJFoouzYLM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=doMMBOuUmLiN+byTcuWedlAArRKwps4y8pPifCLZegXsk6r0qmYD19BW49F8vBVmHB3eub4f6dCU6x6ZW0JhRJ9f+8QUEnZCPLH1o/Skw6pqG1/uXM3owpHLkQqZoAPl73u+n7avdbFpD7KuEosINqOkypaMTn41MXcqU1n/Aug= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dbKxuug3; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dbKxuug3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C493C4CEF1; Tue, 16 Dec 2025 15:16:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1765898179; bh=xEiw3/MtFG45NReGwfEyl6N3nBoIQ4msAhJFoouzYLM=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=dbKxuug3RAKTc3W76vBdxvAR0vjOHxLdW/+pEpARkhS7h30tPiGyPUt7Wp9D81uVn ZHZD6AYynCerAN4d+eJEs/B7hqzOkzmosNDKDnasGmznUfnrKhdYUMpcoCn1CAo/I/ b0WRZAXlxC3idC0Y7yDi63gj90/Ju8IE71rCMm1tS1K1JjkB53Bo8uY4dIo284cPcX u3YJMvJ8Qc36YSomrmnvI0oyOKsspgMxO0jjlQ6zVc6wGrL2IwUtjFabFvsMssSH9g ewLN/KCFPaEyVBB5x2PO6hgHlikJ1l2LPCsK8rpYEd0Oe04Eg0yMtY+AcQj2af0kUQ LB8L7hxCdkmKg== Message-ID: <7371981b-2220-4441-b349-57038a6320b7@kernel.org> Date: Tue, 16 Dec 2025 09:16:18 -0600 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH V1] accel/amdxdna: Remove amdxdna_flush() To: Lizhi Hou , ogabbay@kernel.org, quic_jhugo@quicinc.com, dri-devel@lists.freedesktop.org, maciej.falkowski@linux.intel.com Cc: linux-kernel@vger.kernel.org, max.zhen@amd.com, sonal.santan@amd.com References: <20251216031311.2033399-1-lizhi.hou@amd.com> Content-Language: en-US From: Mario Limonciello In-Reply-To: <20251216031311.2033399-1-lizhi.hou@amd.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 12/15/25 9:13 PM, Lizhi Hou wrote: > amdxdna_flush() was introduced to ensure that the device does not access > a process address space after it has been freed. However, this is no > longer necessary because the driver now increments the mm reference count > when a command is submitted and decrements it only after the command has > completed. This guarantees that the process address space remains valid > for the entire duration of command execution. Remove amdxdna_flush to > simplify the teardown path. > > Signed-off-by: Lizhi Hou Reviewed-by: Mario Limonciello (AMD) > --- > drivers/accel/amdxdna/amdxdna_pci_drv.c | 29 ++++++++++--------------- > 1 file changed, 11 insertions(+), 18 deletions(-) > > diff --git a/drivers/accel/amdxdna/amdxdna_pci_drv.c b/drivers/accel/amdxdna/amdxdna_pci_drv.c > index 1973ab67721b..fcf7e7869007 100644 > --- a/drivers/accel/amdxdna/amdxdna_pci_drv.c > +++ b/drivers/accel/amdxdna/amdxdna_pci_drv.c > @@ -105,43 +105,38 @@ static int amdxdna_drm_open(struct drm_device *ddev, struct drm_file *filp) > return ret; > } > > -static void amdxdna_drm_close(struct drm_device *ddev, struct drm_file *filp) > +static void amdxdna_client_cleanup(struct amdxdna_client *client) > { > - struct amdxdna_client *client = filp->driver_priv; > - struct amdxdna_dev *xdna = to_xdna_dev(ddev); > - > - XDNA_DBG(xdna, "closing pid %d", client->pid); > - > + list_del(&client->node); > + amdxdna_hwctx_remove_all(client); > xa_destroy(&client->hwctx_xa); > cleanup_srcu_struct(&client->hwctx_srcu); > mutex_destroy(&client->mm_lock); > + > if (client->dev_heap) > drm_gem_object_put(to_gobj(client->dev_heap)); > > iommu_sva_unbind_device(client->sva); > > - XDNA_DBG(xdna, "pid %d closed", client->pid); > kfree(client); > } > > -static int amdxdna_flush(struct file *f, fl_owner_t id) > +static void amdxdna_drm_close(struct drm_device *ddev, struct drm_file *filp) > { > - struct drm_file *filp = f->private_data; > struct amdxdna_client *client = filp->driver_priv; > - struct amdxdna_dev *xdna = client->xdna; > + struct amdxdna_dev *xdna = to_xdna_dev(ddev); > int idx; > > - XDNA_DBG(xdna, "PID %d flushing...", client->pid); > + XDNA_DBG(xdna, "closing pid %d", client->pid); > + > if (!drm_dev_enter(&xdna->ddev, &idx)) > - return 0; > + return; > > mutex_lock(&xdna->dev_lock); > - list_del_init(&client->node); > - amdxdna_hwctx_remove_all(client); > + amdxdna_client_cleanup(client); > mutex_unlock(&xdna->dev_lock); > > drm_dev_exit(idx); > - return 0; > } > > static int amdxdna_drm_get_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) > @@ -217,7 +212,6 @@ static const struct file_operations amdxdna_fops = { > .owner = THIS_MODULE, > .open = accel_open, > .release = drm_release, > - .flush = amdxdna_flush, > .unlocked_ioctl = drm_ioctl, > .compat_ioctl = drm_compat_ioctl, > .poll = drm_poll, > @@ -333,8 +327,7 @@ static void amdxdna_remove(struct pci_dev *pdev) > client = list_first_entry_or_null(&xdna->client_list, > struct amdxdna_client, node); > while (client) { > - list_del_init(&client->node); > - amdxdna_hwctx_remove_all(client); > + amdxdna_client_cleanup(client); > > client = list_first_entry_or_null(&xdna->client_list, > struct amdxdna_client, node);