From patchwork Tue Feb 6 17:27:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 197559 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1697620dyb; Tue, 6 Feb 2024 09:30:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IF1oM+6KtphQ0S2sVaWiBoKSbk/pikFmIgh0LxN6ZdW1wbeVo3co1ye7K3eTd8/uXhrA8tk X-Received: by 2002:ad4:5d67:0:b0:68c:7e26:63ca with SMTP id fn7-20020ad45d67000000b0068c7e2663camr3305969qvb.46.1707240600819; Tue, 06 Feb 2024 09:30:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707240600; cv=pass; d=google.com; s=arc-20160816; b=o4BRhafFO3b3WrOkUAkpyeppJdvWf8fiyAdBLx22xDFocgoSELjFXpQ9tN5Qzavcar LHW05i+9Uh2sMPKm5MvtmOlJW98qOF6Fo6+WA4YsENuZrIjMS1i5BuWo4FSZVSMLt9sZ HM6P9H5qUVrGSjXSYx5Lw06thsgXJ4Yhg13W/+gHaeNfwlra6PYOtXLZxuf9yyrZ2W+2 OL7hiRKV/IrhwjOyl/gE1C8wv6YLjUrXG2MirXS45XqVrOLxRdo1pH6l/majOdsz1rpO Y6kcC3XB8NL+D85v7Nu5gdQxdKgQMRvUH6Q5zEuvIIVcex+4dU3+kdmgEEDGrkagnh2+ z00A== ARC-Message-Signature: i=2; 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=jmVPFCNKCEoxyfP5fWPRoMeSPbEbmBVNboqHaLmwopU=; fh=e7Z8dKu3i2dq1SFtmTxnhODZWKTjAbotA7LL31aJqnQ=; b=d8Uh6HWgYwwziH7fiZ1DrXPlXYPPySW56KIhtLLQdny1EPtFDCfLdj+V8NU20psuhB yNlrDyWFLsEEUZrij3EFIrBawF/00CsT/24AJvqY1NsqX8SKgRc03tOsqu8MMQ4o5WFi w/0HFg3uZVbwsBGYzxtiKb8MwI1yRITua1nJmDBaQqJJeASz/H43UOCn992hXP/tNnT5 K73ea6Y+zhK2l9haNpp7+MfypgX9HbHclqERDChc8ZYcw8JJqJdeH1aU8XyBVI9n7eoj D7iGsplhPgtLMjXO1pmg2sD0dBaRDA4Xl1MW5oLP1xkwdezCyllR/07+F67zyw5IyJCf MkCA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=bj9f6nPN; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-55377-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55377-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev X-Forwarded-Encrypted: i=1; AJvYcCXKxLU5IFSfCqqE8Qvzrrk0i8MSHDjL9e+myOkUl36yvWYfwGuimwQVtZFbNZURDVYV5ssUJXFgrzT0UAPFZ0Dw025NiA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id y12-20020a056214016c00b006819bda2532si2725861qvs.234.2024.02.06.09.30.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 09:30:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55377-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=bj9f6nPN; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-55377-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55377-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 9A0F41C23204 for ; Tue, 6 Feb 2024 17:30:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 03B6417579; Tue, 6 Feb 2024 17:28:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="bj9f6nPN" Received: from out-186.mta1.migadu.com (out-186.mta1.migadu.com [95.215.58.186]) (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 BA14914A81 for ; Tue, 6 Feb 2024 17:28:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.186 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707240519; cv=none; b=Jt7es5nZUmGM2Fk52ClYRvhr5rFCy1olBEofL5q3fQfXVNAiqWwj5pgxgvezE/zOjtvLWXrwCCGtpbIzy1WmrA2dIgYlerxeqpt6qCs1cSa+N8rAicHp7S5w0qEvnUa7Es29VuU0Te6LUy2phdfj6v8105M23vmNGgs0exyeXdA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707240519; c=relaxed/simple; bh=ckxXDAMdL+HGgVVf2k5qWXyty13TiKMKkVY5UlvzvTM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SbbDI1Im5ikABZxPsTP1rZBWlSrdy8rCBoCZZzjme9RrpYahXZCfBcdKGz8a0M5MlBcH7Of/kdtL9vemlomlCOeKsU9bAQDLwJo7IR1VsLfeAM1fgVcH0APwGlRHmcA3iJUfZCzScqG2SE2gq6kYHP+oLYrL+NSEpRuJynHTr50= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=bj9f6nPN; arc=none smtp.client-ip=95.215.58.186 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1707240516; 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=jmVPFCNKCEoxyfP5fWPRoMeSPbEbmBVNboqHaLmwopU=; b=bj9f6nPNUnvNreGxSEJL4GRanUU7epVcP9jtGuoNULXnMXPcYRC8wNMLn1F/9NdkMVaYxx rsABrTZTT8ee69ohJDd7pIwPlD9xmEuQnkNVKaOW4GFfph5FtQCL9dcx2Rc6ilrBkL+lc7 W6tnQifptQj4MMRWcdDpGe/xKyH8moI= From: Sui Jingfeng To: Lucas Stach Cc: Russell King , Christian Gmeiner , David Airlie , Daniel Vetter , Maxime Ripard , Thomas Zimmermann , dri-devel@lists.freedesktop.org, etnaviv@lists.freedesktop.org, linux-kernel@vger.kernel.org, Sui Jingfeng Subject: [etnaviv-next v13 6/7] drm/etnaviv: Update the implement of etnaviv_create_platform_device() Date: Wed, 7 Feb 2024 01:27:58 +0800 Message-Id: <20240206172759.421737-7-sui.jingfeng@linux.dev> In-Reply-To: <20240206172759.421737-1-sui.jingfeng@linux.dev> References: <20240206172759.421737-1-sui.jingfeng@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790171520323662534 X-GMAIL-MSGID: 1790171520323662534 Because we need this function to create virtial child. Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/etnaviv/etnaviv_drv.c | 33 +++++++++++++++++++++++---- drivers/gpu/drm/etnaviv/etnaviv_drv.h | 9 ++++++++ 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c b/drivers/gpu/drm/etnaviv/etnaviv_drv.c index d5a5fcc30341..5f65f2dead44 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c @@ -670,16 +670,36 @@ static struct platform_driver etnaviv_platform_driver = { }, }; -static int etnaviv_create_platform_device(const char *name, - struct platform_device **ppdev) +int etnaviv_create_platform_device(struct device *parent, + const char *name, int id, + struct resource *pres, + void *data, + struct platform_device **ppdev) { struct platform_device *pdev; int ret; - pdev = platform_device_alloc(name, PLATFORM_DEVID_NONE); + pdev = platform_device_alloc(name, id); if (!pdev) return -ENOMEM; + pdev->dev.parent = parent; + + if (pres) { + ret = platform_device_add_resources(pdev, pres, 1); + if (ret) { + platform_device_put(pdev); + return ret; + } + } + + if (data) { + void *pdata = kmalloc(sizeof(void *), GFP_KERNEL); + + *(void **)pdata = data; + pdev->dev.platform_data = pdata; + } + ret = platform_device_add(pdev); if (ret) { platform_device_put(pdev); @@ -691,7 +711,7 @@ static int etnaviv_create_platform_device(const char *name, return 0; } -static void etnaviv_destroy_platform_device(struct platform_device **ppdev) +void etnaviv_destroy_platform_device(struct platform_device **ppdev) { struct platform_device *pdev = *ppdev; @@ -728,7 +748,10 @@ static int __init etnaviv_init(void) if (np) { of_node_put(np); - ret = etnaviv_create_platform_device("etnaviv", &etnaviv_drm); + ret = etnaviv_create_platform_device(NULL, "etnaviv", + PLATFORM_DEVID_NONE, + NULL, NULL, + &etnaviv_drm); if (ret) goto unregister_platform_driver; } diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.h b/drivers/gpu/drm/etnaviv/etnaviv_drv.h index 9c05f503747a..bd8ac64dbaf3 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.h +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.h @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -97,6 +98,14 @@ bool etnaviv_cmd_validate_one(struct etnaviv_gpu *gpu, u32 *stream, unsigned int size, struct drm_etnaviv_gem_submit_reloc *relocs, unsigned int reloc_size); +int etnaviv_create_platform_device(struct device *parent, + const char *name, int id, + struct resource *pres, + void *data, + struct platform_device **ppdev); + +void etnaviv_destroy_platform_device(struct platform_device **ppdev); + #ifdef CONFIG_DEBUG_FS void etnaviv_gem_describe_objects(struct etnaviv_drm_private *priv, struct seq_file *m);