From patchwork Mon Aug 19 23:03:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 11102311 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AD31B1399 for ; Mon, 19 Aug 2019 23:03:51 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 96ED222CEC for ; Mon, 19 Aug 2019 23:03:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 96ED222CEC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 77AB16E47E; Mon, 19 Aug 2019 23:03:47 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0EEA16E45B for ; Mon, 19 Aug 2019 23:03:40 +0000 (UTC) Received: by mail-pf1-x443.google.com with SMTP id i30so2076129pfk.9 for ; Mon, 19 Aug 2019 16:03:40 -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=8Jq6l1FXpLUKi4y0ukkZjfUNLVxrsbhJoVkVUyhyG+Y=; b=NpIuI6NmlMo3tHpF92oM4oIEcG4aXPFcGLQtJVxAHVwIuaeab8DJcukfDe/cu0dGuH 34PfGOvDec0MM03pEgpbHCbyDStmSj2uyh87wQFI/jfnuVWH373yTvhsnW1QlAG2cnJI 9sy1lIbvDNZy03jTHPrIhq/cEmSS4vtGBNfyetrURNFQEksWaMlYw6aNjxkYsCpQ3/4h Me5XcSOtWrIVMvc0eZfwVww0zY2p23AmInpPibnrZzlCrZU6jPzMh9PqABC5FWEfwHYA uTDangGSgD1LcTCaMFvugyrifZrK+GO1Sik/rJj9Kx+wmuFO0PkqyUUfpaLYuPC+wjyL yarw== X-Gm-Message-State: APjAAAU/xd2c0Ap0PkQ9SWnJwyP4QwFDuBJ/RdR+17D55vRl71ir08p1 ctr4pqkwnaZ0An6MDZVBuSqzEg== X-Google-Smtp-Source: APXvYqyssV7Yl36O/h3piEFBGll2PogOEaA6fDHOBNyofENn2V/AyPUh8Qfxll3ZysECErjqMdjx/Q== X-Received: by 2002:a65:50c8:: with SMTP id s8mr21967673pgp.339.1566255818787; Mon, 19 Aug 2019 16:03:38 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id j15sm17256509pfr.146.2019.08.19.16.03.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2019 16:03:37 -0700 (PDT) From: John Stultz To: lkml Subject: [PATCH v4 09/25] drm: kirin: Move request irq handle in ade hw ctx alloc Date: Mon, 19 Aug 2019 23:03:05 +0000 Message-Id: <20190819230321.56480-10-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190819230321.56480-1-john.stultz@linaro.org> References: <20190819230321.56480-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=8Jq6l1FXpLUKi4y0ukkZjfUNLVxrsbhJoVkVUyhyG+Y=; b=KmcmVW5o6nlWHLv5N441j5ii+RJTTMgVMXvLq2wCJoJXBsnG12O8XAireGrEqi1Hq/ lFRMcr9k0p3AOU6lVpGDyqJfbp68NIA4/9RgeypfClUu2WoJUcW2cH8R4BC8tNsv1IXh jPhS+KP/uNOeu5VaEVIyRJiq3mcGqT0PLX5hKUSI3+jHDkkf+vw805WswK7LltHxitRB Xa5Z00HvWzZZW9ruhK5uz6MD695mc1zN7+U0PnEkiJDYBmdjJyQs2GOSSfIphnE6oqK6 dmMFMWXT4BPaOy6bLDV0tPUqTfB8/LSuBO25NVUfEZzmpwSIyFWA+Mhx1ddaDgDE3/1o wrYg== 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 , Xinliang Liu , Rongrong Zou , Sam Ravnborg MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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: Xinliang Liu Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel Cc: Sam Ravnborg Acked-by: Xinliang Liu 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 ecb507985fea..8f50115a22d8 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; }