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: 171738 Delivered-To: patches@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp3595889ily; Mon, 19 Aug 2019 16:03:39 -0700 (PDT) X-Received: by 2002:a17:902:1a7:: with SMTP id b36mr24425318plb.115.1566255819794; Mon, 19 Aug 2019 16:03:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566255819; cv=none; d=google.com; s=arc-20160816; b=Z4jS90ZsD5cP5bU+TY/PmawTdqr1GA3BzGS56dKCJwn3Q/brxo+/wtrFi2PeBEnJz5 fXr6mHHtfKtkBU6ftZNLjaiVDRTy10YQhqa9WCXFxxTEsu5AK8vy67zePp3XtC0N8wql segIHlY8fzAacg4d7udSpVaRMs43fTAEb5RP2liWZ20UHa51p4JRXaKyw7SD03UMrxlw NfRmOEpxSmSnAnfNsHMyK+rYSrcCTWqunJYk7/ZegggI3RGAH5VPl+sWlto5JZnUuMr9 9L/N7DK6Ek5j2XrJhemAvINbRK5WbG+tfM161/IAPK17NHNYaYbpfoxmbp2xImWTcbBN 3YJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8Jq6l1FXpLUKi4y0ukkZjfUNLVxrsbhJoVkVUyhyG+Y=; b=Wq0oubtKlORejWzt5jKQQ1vW0LJjHGsDhm1bBVunxXi67tRfqKKK7cQyvI5/+KFVBb L00CfLEA3VotZ0BO+HvTvI5pBBsFuwshSi2GA+iRttd9fNpsIl5Og0QL+ZZyWAA77C5w oJYAfKWQ4dDbaN+lWEbECPmHbNdTtaKBMdkIDDTNVgSjF1aBHihCCIH4smnWIyB74Zax W0Zda/uIlr4kn6jhgL/3k6H4ngkBpc9hebjvVUbLEJnXpiqDtN8QjP0lh7klAgW7EK7S CSz6oTHe2HzUWL/u11WF4ae91OZslrr8LpJNYxP3fJ5HcYzfYcE55kTpsqzp2tgJ8q8i 2B8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KmcmVW5o; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id l10sor1797116pgp.54.2019.08.19.16.03.39 for (Google Transport Security); Mon, 19 Aug 2019 16:03:39 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KmcmVW5o; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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-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=Xg80Lh+okEZ7uFTzf8KakV/HSeY3UD/niW/QVUNvoFMkrqdT53WxlkqwqiySb7hati SFO+7J85PNcVyKzviAn6F/FQl4O7yyXAQGfU9Ub/QWW32QC4wo4236QgcEY7McbCnCZl H68mEKRcz9cPlqBcGCDiAiT5E0afjtrOVi6n+pNmv0QarxHa2+7TZ45Nfbrn7rAsgN/D eB5NH/R4nUvXMwIp/1os69JbIRAdI16rfqS52YMiHrxdf56uNeyY/6L7TAWo+j7GV9uN UIrxqwvNS2fCM8S2EiDbRgwMgtt6zWXxHjgltyzb9N5o7eyIA5EPeT3UWO6Mqiw0zIPv sIuQ== X-Gm-Message-State: APjAAAU/y0keWOeXhZrRbs1r/qvV2AXgbXe+s2uWAK9jXDo17IFodL4j l8Z9NxqQkNelWsZvCtd9HbSGefhI 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) Return-Path: 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 Cc: Xu YiPing , Rongrong Zou , Xinliang Liu , David Airlie , Daniel Vetter , dri-devel , Sam Ravnborg , John Stultz 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> 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(-) -- 2.17.1 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; }