From patchwork Thu Aug 1 03:44:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 11070121 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 01E2813B1 for ; Thu, 1 Aug 2019 03:45:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E67DC283C3 for ; Thu, 1 Aug 2019 03:45:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DAE93283C8; Thu, 1 Aug 2019 03:45:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 76AE3283C3 for ; Thu, 1 Aug 2019 03:45:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 56B736E345; Thu, 1 Aug 2019 03:45:07 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by gabe.freedesktop.org (Postfix) with ESMTPS id EC1F16E345 for ; Thu, 1 Aug 2019 03:45:03 +0000 (UTC) Received: by mail-pf1-x441.google.com with SMTP id r7so33153846pfl.3 for ; Wed, 31 Jul 2019 20:45:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7V27YU7YMF+tZPi0O4Ugz3veVJN966k99LkEuw17xeY=; b=LieaWt+tesWCfKEhN+6YBl71snfDl3Mtp93WFHlIDtI+eip7OFOoL+ncHOdJBQpyyh 8SvK/1Nx54JbeGcu62VVj3DD5wN3SzR2wf6KE5JOzfG2XdviynFcOU4Vgrv9pdE4CtYY gFpjsdtFO2vvlCz/jKsds7STX8aJZvVLk220uvmpgoPUOaBrFDWafrtiKf6F8B1JZTGp /61ZbxmHl/1ibV6WcSA/nK/Iw0WyWA1YcSfbsJ/XCw90B1J6jCrHCWW423BDHpyuS5Om mVj+DGjdqwaN0iX4zLxZqA7CQyVZny3IGZpMUosPnzDNw5955EbkA0x3JvmR9SpOOluj ROMg== X-Gm-Message-State: APjAAAVOPIgj6myQtmFtBBb3bvyT7vims9uuS+YvCAIKeeyNp26YD8GE 6nuG2shlz40y5c06lkjEUgj/hw== X-Google-Smtp-Source: APXvYqwEhFxACC26/Eik5Mctv+bkSEzw74Z5kusBkQCvg6V/F07XrF+4u0xrAKRk3NaklKsj9Z8wrA== X-Received: by 2002:a63:a66:: with SMTP id z38mr21652140pgk.247.1564631100809; Wed, 31 Jul 2019 20:45:00 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id h70sm64775674pgc.36.2019.07.31.20.44.59 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 20:45:00 -0700 (PDT) From: John Stultz To: lkml Subject: [PATCH v3 10/26] drm: kirin: Move request irq handle in ade hw ctx alloc Date: Thu, 1 Aug 2019 03:44:23 +0000 Message-Id: <20190801034439.98227-11-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190801034439.98227-1-john.stultz@linaro.org> References: <20190801034439.98227-1-john.stultz@linaro.org> X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7V27YU7YMF+tZPi0O4Ugz3veVJN966k99LkEuw17xeY=; b=ql0l5+P+mf3WMVVy/yqVmjy+Oi65lqVK0DmdJ3uF8Nw4Wf5d0BwNFACRz3v7CkikjX Yd30hkInZkBXabP80PeIrme1yJ/Ip+O9cnqds2hbokZqg3RQNmjxWQl8Qbi4vmEIfqKK +F0amK2NQldKuKzSXexa/Nlj5Cgbu5FavZFzbN175XIAfRziR0JvosWELHfVqH8owdUc VMrKjDraq9FULY7g7KhFS9qzQOJ7XlP6lwLGP8knvtKBTv99kNZzmT9WmbcEfyB+6uLl Frv1ZK7q5RLYDrxqzNFNjCeURud/RAdSSsthXsdMdnbtscwgxnZzZ8M0c4NKTtzaWj5K jmww== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Xu YiPing , David Airlie , dri-devel , Rongrong Zou , Sam Ravnborg MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Xu YiPing As part of refactoring the kirin driver to better support different hardware revisions, this patch modifies the initialization routines so the devm_request_irq() function is called as part of the allocation function. This will be needed in the future when we will have different allocation functions to allocate hardware specific hw_ctx structures, which will setup the vblank irq differently. Cc: Rongrong Zou Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel Cc: Sam Ravnborg Reviewed-by: Sam Ravnborg Signed-off-by: Xu YiPing [jstultz: reworded commit message] Signed-off-by: John Stultz --- .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c index ddcfe0c42d7c..0e0fe1cb945f 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c @@ -54,6 +54,8 @@ struct ade_hw_ctx { struct reset_control *reset; bool power_on; int irq; + + struct drm_crtc *crtc; }; struct kirin_crtc { @@ -358,9 +360,9 @@ static void drm_underflow_wq(struct work_struct *work) static irqreturn_t ade_irq_handler(int irq, void *data) { - struct kirin_crtc *kcrtc = data; - struct ade_hw_ctx *ctx = kcrtc->hw_ctx; - struct drm_crtc *crtc = &kcrtc->base; + struct ade_hw_ctx *ctx = data; + struct drm_crtc *crtc = ctx->crtc; + struct kirin_crtc *kcrtc = to_kirin_crtc(crtc); void __iomem *base = ctx->base; u32 status; @@ -951,12 +953,14 @@ static int ade_plane_init(struct drm_device *dev, struct kirin_plane *kplane, return 0; } -static void *ade_hw_ctx_alloc(struct platform_device *pdev) +static void *ade_hw_ctx_alloc(struct platform_device *pdev, + struct drm_crtc *crtc) { struct resource *res; struct device *dev = &pdev->dev; struct device_node *np = pdev->dev.of_node; struct ade_hw_ctx *ctx = NULL; + int ret; ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); if (!ctx) { @@ -1006,6 +1010,14 @@ static void *ade_hw_ctx_alloc(struct platform_device *pdev) return ERR_PTR(-ENODEV); } + /* vblank irq init */ + ret = devm_request_irq(dev, ctx->irq, ade_irq_handler, + IRQF_SHARED, dev->driver->name, ctx); + if (ret) + return ERR_PTR(-EIO); + + ctx->crtc = crtc; + return ctx; } @@ -1027,7 +1039,7 @@ static int ade_drm_init(struct platform_device *pdev) } platform_set_drvdata(pdev, ade); - ctx = ade_hw_ctx_alloc(pdev); + ctx = ade_hw_ctx_alloc(pdev, &ade->crtc.base); if (IS_ERR(ctx)) { DRM_ERROR("failed to initialize kirin_priv hw ctx\n"); return -EINVAL; @@ -1059,15 +1071,8 @@ static int ade_drm_init(struct platform_device *pdev) if (ret) return ret; - /* vblank irq init */ - ret = devm_request_irq(dev->dev, ctx->irq, ade_irq_handler, - IRQF_SHARED, dev->driver->name, kcrtc); - INIT_WORK(&kcrtc->display_reset_wq, drm_underflow_wq); - if (ret) - return ret; - return 0; }