From patchwork Fri Jan 5 17:22:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Stanner X-Patchwork-Id: 13512412 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8EF91C3DA6E for ; Fri, 5 Jan 2024 17:23:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=NVnUkQRNZol3DyRC1b7XuyzfqDbvEP6am3i05duLZp8=; b=dddX2rI9iveAZj DGRWC+DoaQgrbR/AnGHNTjfBnXT+9rklP1CV3pw5K9xSGb7967id1u+SIjNs9FJ4U7ctdjBfXJhIn uNOqnkheD90Wmv1yONhj3rYsu5VCYWiYY5xuzN3GaSKpqNoMWEjNe7ueWAyo9n3I5wFIN0dkHY4cF NgdKlGWKjVt8aRQbHo63uUUvrk0y/3XXhLN5AWEaC4lH0zb4bfrRh9CQ+ZhtguMbch2fcjb11HTn1 TQBrSEytYROf1p5hCjnWHoskioLcfBg+YL3Wiku80AAgF4WKIMj/CbsClDFFIxUi0V0hM+e5s3wIw h5jfEaG8lo//NleBVjSw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rLnuj-00HOye-3D; Fri, 05 Jan 2024 17:23:22 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rLnug-00HOxP-0H for linux-arm-kernel@lists.infradead.org; Fri, 05 Jan 2024 17:23:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704475396; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xBgR6EF/EirqUkTInXMLhcQ/iDbvWyd/X1PfgAKAIyE=; b=E7Q2h+cL5f8y7zwJ918pDc/3dv927i86dkEE+njEVnKb2tR3Vd8lvdYtIrFuyJXESX/Z/c cGnMVybqlVgAkr9+dhJDjfwENThCjGOpx+dpE7rkhDrkHaT1GW+G3npIFvC3SDqUm5vfHp Y2w+lOXz/uo4HZDFuPUPCqSq+90x5Oc= Received: from mail-vs1-f69.google.com (mail-vs1-f69.google.com [209.85.217.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-567-EZKV6PlENc6PoXDySI_1VQ-1; Fri, 05 Jan 2024 12:23:15 -0500 X-MC-Unique: EZKV6PlENc6PoXDySI_1VQ-1 Received: by mail-vs1-f69.google.com with SMTP id ada2fe7eead31-4670ca688easo169593137.1 for ; Fri, 05 Jan 2024 09:23:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704475395; x=1705080195; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xBgR6EF/EirqUkTInXMLhcQ/iDbvWyd/X1PfgAKAIyE=; b=kzsq1Sa66ZvoUQ/GIaXcwFz/BUHZ2XLtpWe9I0r8fZ7D0q5ymPc3P15jQ5MurjNbFw s01cyz6x5ZPG9H6+c4Z26SNgmQ5ZRXvU2CPguHja/X2nNBsouxRlp65DEo0Bj/pko+kC GDtykF4bOqC7/Ehjt8vb9fB/D9WJYfTHvcSZZvbE5bwCEqwtHDZDB36nIGmlYc9pY+Aq NDSzoqE4pq3B0azp6wDDMUmNt36sw5I+DJPpulV2/RT/f61ARPV8wiWdlYhEEBe0jkel rwZ5MB1yQwEMnW+YysUmQx4WvXDQZzq3mJ8/UFIc6tHU8uxDjAVCHJxkJf3P3t+1qDOZ 42Iw== X-Gm-Message-State: AOJu0Yw8ZAP3hFl+ajTvX7juXRueft1+Z0yzIemeUcVadEMDu7pCeyqU VQB/jt8qaad5tc4PUnavkwJWmgsxFyPnBsvQz4lT/uJ1fe2ZQ1JXCQiF2dr62eF7siO/9vJXO/y Qihqw3e1I7pcEwYtohtUd7phknm2mj/rYN8VZZ+/qvLM= X-Received: by 2002:a67:ecda:0:b0:467:55c5:588 with SMTP id i26-20020a67ecda000000b0046755c50588mr4120304vsp.3.1704475394717; Fri, 05 Jan 2024 09:23:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IGTkGeaWdrkvk9vkGZOM8wRaOT8a6juJhCYrGyYaDRBNcd8dZEL/Cbb4G38NHhLuk+2Ph/AUQ== X-Received: by 2002:a67:ecda:0:b0:467:55c5:588 with SMTP id i26-20020a67ecda000000b0046755c50588mr4120262vsp.3.1704475394262; Fri, 05 Jan 2024 09:23:14 -0800 (PST) Received: from pstanner-thinkpadt14sgen1.remote.csb ([2001:9e8:32d1:a900:227b:d2ff:fe26:2a7a]) by smtp.gmail.com with ESMTPSA id t22-20020ac865d6000000b004282c862fccsm884750qto.57.2024.01.05.09.23.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 09:23:13 -0800 (PST) From: Philipp Stanner To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Laurentiu Palcu , Lucas Stach , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Mark Brown , Takashi Iwai , David Gow , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, Philipp Stanner Subject: [PATCH 1/2] platform_device: add devres function region-reqs Date: Fri, 5 Jan 2024 18:22:18 +0100 Message-ID: <20240105172218.42457-3-pstanner@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240105172218.42457-2-pstanner@redhat.com> References: <20240105172218.42457-2-pstanner@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240105_092318_216214_6D065994 X-CRM114-Status: GOOD ( 18.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Some drivers want to use (request) a region exclusively but nevertheless create several mappings within that region. Currently, there is no managed devres function to request a region without mapping it. Add the function devm_platform_get_resource() Signed-off-by: Philipp Stanner --- drivers/base/platform.c | 37 +++++++++++++++++++++++++++++++++ include/linux/platform_device.h | 2 ++ 2 files changed, 39 insertions(+) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 10c577963418..243b9ec54d04 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -82,6 +82,43 @@ struct resource *platform_get_mem_or_io(struct platform_device *dev, } EXPORT_SYMBOL_GPL(platform_get_mem_or_io); +/** + * devm_platform_get_and_resource - get and request a resource + * + * @pdev: the platform device to get the resource from + * @type: resource type (either IORESOURCE_MEM or IORESOURCE_IO) + * @num: resource index + * @name: name to be associated with the request + * + * Return: a pointer to the resource on success, an ERR_PTR on failure. + * + * Gets a resource and requests it. Use this instead of + * devm_platform_ioremap_resource() only if you have to create several single + * mappings with devm_ioremap(). + */ +struct resource *devm_platform_get_resource(struct platform_device *pdev, + unsigned int type, unsigned int num, const char *name) +{ + struct resource *res; + + res = platform_get_resource(pdev, type, num); + if (!res) + return ERR_PTR(-EINVAL); + + if (type & IORESOURCE_MEM) + res = devm_request_mem_region(&pdev->dev, res->start, res->end, name); + else if (type & IORESOURCE_IO) + res = devm_request_region(&pdev->dev, res->start, res->end, name); + else + return ERR_PTR(-EINVAL); + + if (!res) + return ERR_PTR(-EBUSY); + + return res; +} +EXPORT_SYMBOL_GPL(devm_platform_get_resource); + #ifdef CONFIG_HAS_IOMEM /** * devm_platform_get_and_ioremap_resource - call devm_ioremap_resource() for a diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h index 7a41c72c1959..68e2857521f4 100644 --- a/include/linux/platform_device.h +++ b/include/linux/platform_device.h @@ -59,6 +59,8 @@ extern struct resource *platform_get_resource(struct platform_device *, unsigned int, unsigned int); extern struct resource *platform_get_mem_or_io(struct platform_device *, unsigned int); +extern struct resource *devm_platform_get_resource(struct platform_device *pdev, + unsigned int type, unsigned int num, const char *name); extern struct device * platform_find_device_by_driver(struct device *start, From patchwork Fri Jan 5 17:22:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Stanner X-Patchwork-Id: 13512413 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AEE4CC47079 for ; Fri, 5 Jan 2024 17:23:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CpkAUC8v+4K41iXK83aDRT4fsiWXwapXbpoAi0vIY5Q=; b=pjBBqFXaqCJO3H qfhLcbYyNeX8+B4yp0XC67pHlgnXgmnAnzqeNi7hUyUDa3Q7cHz1Cqdv3i5CsoaErJTPFoqIPhb+o joWHNoUOuMBQEwjg2mVVDeCjMq3crWBTzhTtBCM4uU9jXYIt9bYq+pJDzXfvKYFW1mDn1cXyT6KHV 2uHEhJvQNqpx48y4bjFaEM9TCutSxCGmmtUoY1W/nmf2F7wtwi94BAD7g0ajMXEuWpV0eSN9X3zrw LnZJPfIkmOgVUjSRNBe/1s3wokof5bXmXO9xm/s5O+ECYeKY7//eKjQWBAsV6iL9asKM75AyerL22 odLexnuogoiNXSWpSfIw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rLnum-00HOzt-0W; Fri, 05 Jan 2024 17:23:24 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rLnui-00HOyK-38 for linux-arm-kernel@lists.infradead.org; Fri, 05 Jan 2024 17:23:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704475400; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L2qUZvjVZIZkY/BqEpnbV7C2OUzTR+OzcQfnt1cm3UY=; b=A2jmmVr2rf7snD3BitqK26Mu1BRj40rc5DJXbVpAgTiQd2cffNwMxg7U0OKaVUFg4RB7N2 h0IZPLntiREqu0jwVtFFgoYA/5VV92des5JEiXuQ9J9aZtqiQQ7XS7IDLZfzMtj+DgkPrR Q5yWzid/LGVsNki/jgPY9GHmhcex680= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-389-0guiFllEPpKMgG9Xx6NCNA-1; Fri, 05 Jan 2024 12:23:18 -0500 X-MC-Unique: 0guiFllEPpKMgG9Xx6NCNA-1 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-4277052412cso2250911cf.0 for ; Fri, 05 Jan 2024 09:23:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704475398; x=1705080198; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L2qUZvjVZIZkY/BqEpnbV7C2OUzTR+OzcQfnt1cm3UY=; b=wS4rZ6U1hgm41OVXRMfYgU5FXX28ll0DuFLBvnJxSOpN9Zsbj3MItQ0+ME71Cw6xB7 1aGFfMJmVdAuFZ5hoswjQTE2agEOoB15LSOLRRLUrNnSMFXb2HavR90Yj12FDN6rgDx5 +kTR+KsdMzy4OmUW8eRdVp9cB1yhC0cHnyUVFTYVLPizDs3ZO+Uq//z83euQM1z6ojjj 3KfUdPg02xCV2VlbfiIU6t0rcyoWSpyNlJQhfDSfePov96ru9t/8bHQZNrBZ+Sgb+MlN E1u0Wqil7qmxNzwHYDyCNeQ/uh1ID+2N6+msgUYqqybX7xmQgcEg2I8/i36ESQ1Y1Mao ksaw== X-Gm-Message-State: AOJu0YyYJDK3lrX9t1YxMeeepMXHvEfkqPSgJCt7lEIkBYalVslJpAZe zvnTXPNaES7Oqx1//bLZdudbva+MXhr66GNWqee4hSH2rfAQ6hvb3At2Op3BEb6vg1RRrNr5cjt ZoX0tuJm1+Pz/ppq5I7PDDkrn2QC11E7NzSgXw/4UR50= X-Received: by 2002:a05:622a:50:b0:428:2650:f3e2 with SMTP id y16-20020a05622a005000b004282650f3e2mr5249589qtw.5.1704475397794; Fri, 05 Jan 2024 09:23:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IF532epDikfCQdMZTGaUEridQlW9l8yNvNyDw9n1OMG2UUu/mdbSu/2QfYbrZ833QqmwaxhCw== X-Received: by 2002:a05:622a:50:b0:428:2650:f3e2 with SMTP id y16-20020a05622a005000b004282650f3e2mr5249572qtw.5.1704475397552; Fri, 05 Jan 2024 09:23:17 -0800 (PST) Received: from pstanner-thinkpadt14sgen1.remote.csb ([2001:9e8:32d1:a900:227b:d2ff:fe26:2a7a]) by smtp.gmail.com with ESMTPSA id t22-20020ac865d6000000b004282c862fccsm884750qto.57.2024.01.05.09.23.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 09:23:17 -0800 (PST) From: Philipp Stanner To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Laurentiu Palcu , Lucas Stach , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Mark Brown , Takashi Iwai , David Gow , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, Philipp Stanner Subject: [PATCH 2/2] drm/dcss: request memory region Date: Fri, 5 Jan 2024 18:22:19 +0100 Message-ID: <20240105172218.42457-4-pstanner@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240105172218.42457-2-pstanner@redhat.com> References: <20240105172218.42457-2-pstanner@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240105_092321_077882_789A035D X-CRM114-Status: GOOD ( 14.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The driver's memory regions are currently just ioremap()ed, but not reserved through a request. That's not a bug, but having the request is a little more robust. Implement the region-request through the corresponding managed devres-function. Signed-off-by: Philipp Stanner --- drivers/gpu/drm/imx/dcss/dcss-dev.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/imx/dcss/dcss-dev.c b/drivers/gpu/drm/imx/dcss/dcss-dev.c index 4f3af0dfb344..efd3a998652d 100644 --- a/drivers/gpu/drm/imx/dcss/dcss-dev.c +++ b/drivers/gpu/drm/imx/dcss/dcss-dev.c @@ -177,10 +177,10 @@ struct dcss_dev *dcss_dev_create(struct device *dev, bool hdmi_output) return ERR_PTR(-ENODEV); } - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - dev_err(dev, "cannot get memory resource\n"); - return ERR_PTR(-EINVAL); + res = devm_platform_get_resource(pdev, IORESOURCE_MEM, 0, "dcss"); + if (IS_ERR(res)) { + dev_err(dev, "cannot get / request memory resource\n"); + return res; } dcss = kzalloc(sizeof(*dcss), GFP_KERNEL);