Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp1712740lqb; Sun, 26 May 2024 13:47:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWhEB7NGXDW69i9k2jat5ZDq2mkfehrk5bRU7J0zRDjKjfym2Hq0wQee7j7i1pBgJsyg/afBIiB3xidl7K6blXemOTMwhxXoD+/8LLWng== X-Google-Smtp-Source: AGHT+IFpHEa3UYu4zSmGXnuHxhMoxsVYtBXbx0OLN4YHiGC2lo4n0GFEAi0xcmwK2XckM9f5rOiY X-Received: by 2002:a50:9f69:0:b0:578:614d:e0a2 with SMTP id 4fb4d7f45d1cf-578614dfa74mr4154755a12.25.1716756463743; Sun, 26 May 2024 13:47:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716756463; cv=pass; d=google.com; s=arc-20160816; b=LiRCfCvinoQrO7T4XSg/cCScsE7eJ5sdBjMN2wlO5tlay8+ciloYPaVlYLXNmKyH+Z H1T4A8Ltu1IO8+11cgRRNsCp9MYhfwjCg5Z4rIH04hKhtlVcgdwqXVA8ozW38HiHsYMT Y8bziacSNb2K6/qr5VCHrnRkj5NbI8bn18Zt1PALr6K7746DF//xKa1+gnvkvPaLj8ZB fEivOzBCTbXjL9+QS212DTp9o3GJent1WANf9TRX0U9uRozAOIuszBDJF4HJKp722KGJ vOSMh/P4q+FkcXisxriTs/wr7ruMDZp478YfalgCX7wCQBuU+5CgcCAUFwX5ox9G9kS7 glEg== 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=xUNdaUpczqWjYKFL6mjsCYM10st8i6fklZ84b9FNQNs=; fh=xI9JRZxVC9yN9fLN/QiyWKyC12VmecvMsUXukUiJbpE=; b=u9nUVWm2kf8pLSvfiXJv+kAb2HFXvPsvnZJ6SrU7bPXMroh/rLbR9VLYser5QyQ4E3 xV33PvI5fAovDXZgpUsyRzIH0R2cGL8Wp04P2XcLeHl1n6R834SoygLFS3JGy2TEg6nd eBuCimtR9vh/Vk9EwnFeIyRq4/JA8DnbxMEuth6Mbwhmu+opZSWm3jd2tfWoS0cDMGcX Fm3FLh1bePDw99s3Z/OFTY2a6Bf6cfU3y8nOASEIzlNeT/3NH1sLznQfzJyXy4Vpp4bT 7j+easK0Tho2isAZwhJIOQRj8UwOvF6naH1xnZLfpVSF7lriX3OGOeTworr1asAy2jOc 2oJw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B8EpIa2u; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-189868-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189868-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5785f890642si2770083a12.310.2024.05.26.13.47.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 May 2024 13:47:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-189868-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=@linaro.org header.s=google header.b=B8EpIa2u; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-189868-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189868-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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 424491F21152 for ; Sun, 26 May 2024 20:47:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 470BF139D05; Sun, 26 May 2024 20:47:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="B8EpIa2u" Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 93D511A2C26 for ; Sun, 26 May 2024 20:47:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716756455; cv=none; b=Xj4NVI6JmIsbMgFvoEjfsdaCgmMaI3VU6XIuP6dgTDJBtaBGU9FCNTQGPU9aXsWCYdEORVRDFcVPvnv5edn/+/NP4aWCgrQSxwSATxYrCWPBovvZPJATyXqaBmZ7LSfYaRCfVeJ+ojALLTz9lSzo2UtZV/u7bl8DtyYfQkJYe1A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716756455; c=relaxed/simple; bh=9x8Powgupa5Ch2WCzTKMefreAqfem88tbowpqqCuY38=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=DAC9fYtgWahn3cUhyN/htiZGPenucGsESfqK5F8VroYe/CMGa33H++Ma/gT4kLx4sj6LTUy+VXQfoKzny3wMp+3YANAFUMl8TWa6tSdoxUvy2vmvv4f1vnXHv7aoe6WNqDZVfQB38LcM1Z5rTrddb20WnDQoH45R+yquDkDLmjc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=B8EpIa2u; arc=none smtp.client-ip=209.85.208.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2e724bc46c4so82842361fa.2 for ; Sun, 26 May 2024 13:47:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1716756452; x=1717361252; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=xUNdaUpczqWjYKFL6mjsCYM10st8i6fklZ84b9FNQNs=; b=B8EpIa2u1azTHTw+BRhzrVlcX7ix8miejORHFu81FmWIrn1g9ZJy6UX2pNt2iLdPuY 9d2b1l+AzUwsxTm0vK645SalboMN1N7A3uZYOk7ANcSUMn2XZty7jGVH1Z/QOVSsAGxw lG4Y8jfywdt8X127qKec8Wy9lsHna1qnhh/8yBLsaBETVhNIf0/CSPHQre/dgKJZcp0N Dn5zInA3OkpHcrIErZjkuGuLgOLSfNydOWQNdDIM8/P6kgfFROfAqDU5e2N0itpsyZYP WoadnkS/FtloN159WswzogmuLXug1gczS4sGrIqCjlPtJwCc37WZoubii5+qP5CdmFkD cVAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716756452; x=1717361252; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=xUNdaUpczqWjYKFL6mjsCYM10st8i6fklZ84b9FNQNs=; b=u1X6Uxp/Rzkgu+tslfaszeSb4uG4mY7eftVtpCKn2f92xusXz9NH6ethXG0RKkq5Pm C6zuc0Gsa77/0zWKnnGCybfs/s7FYjl5eW+A+80pv2HKRyLF/pKEKhpc9wQaSTWA94K1 ZjSaBg0p4rB64lqMWZPWfF5o7PUVzceSrQ1SzuSVCNBrG09PDEXOSaGfb1/TlrtEnYrv Qd0wACIs2LgBliN6XutGs2Pn7FLmbrJENO4Q8Kf2HFRwqdHSMFbqi71E449HEos2ZFct 98vYAkURuJTpAsiWIhVJIxVczy7FtotP9lQIQiX8MaKnpAGkiJGXxsdsLM/iRxrowBgS MrYw== X-Forwarded-Encrypted: i=1; AJvYcCU7nRc6oNPJiW8V2NsisaxeS4ySWXySaF2Uny6CU+SUS+FMBTy9dDew+MjpUZiR/oG5wSBG2MAdx9j2kqljL+6XK37x1mwqtbVeequ2 X-Gm-Message-State: AOJu0YxLxtHX4j7DUdHbr4oMPeILDSxwYtza1Kh/Un+oHwn/S0Ja8AFl aWZgyP22XUPBnMPxRBwsyqrXY6y7WxW7QmBMMbskMCAvXln2WhP9XIIQt5qNM3s= X-Received: by 2002:a05:651c:2041:b0:2d3:4b73:7b40 with SMTP id 38308e7fff4ca-2e95b1cc4c6mr46374631fa.17.1716756451582; Sun, 26 May 2024 13:47:31 -0700 (PDT) Received: from eriador.lumag.spb.ru (dzdbxzyyyyyyyyyyyykxt-3.rev.dnainternet.fi. [2001:14ba:a0c3:3a00::227]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2e95bcc4962sm15862611fa.11.2024.05.26.13.47.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 May 2024 13:47:31 -0700 (PDT) Date: Sun, 26 May 2024 23:47:29 +0300 From: Dmitry Baryshkov To: Sui Jingfeng Cc: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Markus Elfring Subject: Re: [PATCH v2 1/3] drm/loongson: Add a helper for creating child devices Message-ID: References: <20240526195826.109008-1-sui.jingfeng@linux.dev> <20240526195826.109008-2-sui.jingfeng@linux.dev> 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: <20240526195826.109008-2-sui.jingfeng@linux.dev> On Mon, May 27, 2024 at 03:58:24AM +0800, Sui Jingfeng wrote: > In some display subsystems, the functionality of a PCIe device may too > complex to be managed by a single driver. A split of the functionality > into child devices can helpful to achieve better modularity. > > Another benefit is that we could migrate the dependency on exterinal > modules to a submodule level with the helper created. For example, it's > not uncommon that some exterinal module will return -EPROBE_DEFER to our > driver during probe time. KMS driver has to tear down everything when it > receives -EPROBE_DEFER, the problem is that it's completely not necessary > and rising cyclic dependency problems if not process correctly. > > Add the loongson_create_platform_device() function, which allows the KMS > driver to create sub-devices for it. The manually created decice acts as > agents for the principal part, migrate the potential issue to submodule. > > Signed-off-by: Sui Jingfeng > --- > drivers/gpu/drm/loongson/loongson_device.c | 42 ++++++++++++++++++++++ > drivers/gpu/drm/loongson/lsdc_drv.h | 6 ++++ > 2 files changed, 48 insertions(+) > > diff --git a/drivers/gpu/drm/loongson/loongson_device.c b/drivers/gpu/drm/loongson/loongson_device.c > index 9986c8a2a255..b268549d643e 100644 > --- a/drivers/gpu/drm/loongson/loongson_device.c > +++ b/drivers/gpu/drm/loongson/loongson_device.c > @@ -4,6 +4,7 @@ > */ > > #include > +#include > > #include "lsdc_drv.h" > > @@ -100,3 +101,44 @@ lsdc_device_probe(struct pci_dev *pdev, enum loongson_chip_id chip_id) > { > return __chip_id_desc_table[chip_id]; > } > + > +int loongson_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, 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); > + return ret; > + } Please use platform_device_register_resndata(). > + > + *ppdev = pdev; > + > + return 0; > +} > diff --git a/drivers/gpu/drm/loongson/lsdc_drv.h b/drivers/gpu/drm/loongson/lsdc_drv.h > index fbf2d760ef27..a2c6b496a69f 100644 > --- a/drivers/gpu/drm/loongson/lsdc_drv.h > +++ b/drivers/gpu/drm/loongson/lsdc_drv.h > @@ -47,6 +47,12 @@ enum loongson_chip_id { > const struct lsdc_desc * > lsdc_device_probe(struct pci_dev *pdev, enum loongson_chip_id chip); > > +int loongson_create_platform_device(struct device *parent, > + const char *name, int id, > + struct resource *pres, > + void *data, > + struct platform_device **ppdev); > + > struct lsdc_kms_funcs; > > /* DC specific */ > -- > 2.34.1 > -- With best wishes Dmitry