From patchwork Sat Jun 3 10:48:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 102818 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1583961vqr; Sat, 3 Jun 2023 03:50:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4ZOdq7GzxQ8V0MUrmPAPZrvN1r7nYONiVtV2622paaelrdee6S5TvpslYocXn8bl5XX5gU X-Received: by 2002:a81:8311:0:b0:565:c750:c5c6 with SMTP id t17-20020a818311000000b00565c750c5c6mr4021441ywf.6.1685789445774; Sat, 03 Jun 2023 03:50:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685789445; cv=none; d=google.com; s=arc-20160816; b=ypbEVk6xGxhcrlx9I8mZ446bJx+pPOxpZOn8AYKM3babIcSQzU87zsGTLYc+7g5vLV sX/dCatQw1FRPbl5jGTd49OtGatgZTmAio+DQt9uOPjQkrg/tO+22w3zUrRo0Jt3JNOd p0Y661Ke/eEK3jwCQd+YUOfjplfKFFv2xkGVN/aMJgtQSfCzO6f9m+Kw4P/pUdU9P4al 09mDE3w6YPgwjSWfoF1reDm79eV/ibFn30BPH4PFSLh0q9YHVMBrRNxTiy+G3o8ybQmY HpF4JP/pB8lTupaJ2DnzPJGc6EE6rND8+txftNPVIepzEBlKjQZDo3+bHG9K+BeHLVRv NXBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=7IBmtMqxEZwTCDlHz1coltEiy94XtJ3WZTC8w3cTahg=; b=SYF2jmdM9VvdZydBqFX9BzVlckd3EcWixQp/JvRB0XQuSwIpKWlK/RiFfa9eFvAVrS MkWWfkYsespKKCVEV64OvU0Qgz4sXM3NeTCmncFaZgvtZQiaWfNVa9E1AhxwEjRjyHgz iLMnuhp0Z/QLKKOIzusUK01y7Gh6cSRNJCRKq42YEybB02k4bJ+DHZdeV2YiTpboGCJb Msa3Ffu5DNzzL9/bxGX4MeSDDzIFQNJucvqpSOmIYSJIZ0oqRpoes4KpimQASe3HLwhe hS6Pwzl5JEUsA3uIKRyGo7I+Co5KaAdOo1LKsdrWUulDJ7Gy7KLBiTYGB64IMYLqVj2f jxPA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s16-20020aa78bd0000000b00655079704afsi707149pfd.119.2023.06.03.03.50.31; Sat, 03 Jun 2023 03:50:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236828AbjFCKs4 (ORCPT + 99 others); Sat, 3 Jun 2023 06:48:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236904AbjFCKsx (ORCPT ); Sat, 3 Jun 2023 06:48:53 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0EFA4F5 for ; Sat, 3 Jun 2023 03:48:51 -0700 (PDT) Received: from loongson.cn (unknown [10.20.42.43]) by gateway (Coremail) with SMTP id _____8AxiPGTGntk2+oDAA--.8556S3; Sat, 03 Jun 2023 18:48:51 +0800 (CST) Received: from openarena.loongson.cn (unknown [10.20.42.43]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Dx87SSGntkOjOHAA--.20866S3; Sat, 03 Jun 2023 18:48:50 +0800 (CST) From: Sui Jingfeng To: Lucas Stach , Christian Gmeiner , Daniel Vetter , Bjorn Helgaas Cc: linux-kernel@vger.kernel.org, etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, loongson-kernel@lists.loongnix.cn Subject: [PATCH v7 1/7] drm/etnaviv: add a dedicated function to register an irq handler Date: Sat, 3 Jun 2023 18:48:44 +0800 Message-Id: <20230603104850.3042011-2-suijingfeng@loongson.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230603104850.3042011-1-suijingfeng@loongson.cn> References: <20230603104850.3042011-1-suijingfeng@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8Dx87SSGntkOjOHAA--.20866S3 X-CM-SenderInfo: xvxlyxpqjiv03j6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBjvJXoW7AFWDWF4UGFykJr1DKF17ZFb_yoW8Zr48pF 47Ja4Ykr18Ca42g34fZF98ZF1akw1IqayIkwnrt3sak398Jrs8JryFkF1UXa4fAryrGay3 tF1YgFWUuF45urJanT9S1TB71UUUU0DqnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU bvxYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s 1l1IIY67AEw4v_JF0_JFyl8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM2 8EF7xvwVC2z280aVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gr1j6F4U JwAaw2AFwI0_GFv_Wryle2I262IYc4CY6c8Ij28IcVAaY2xG8wAqjxCEc2xF0cIa020Ex4 CE44I27wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_ZF0_GryDMcIj 6I8E87Iv67AKxVW8Jr0_Cr1UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrw ACjcxG6xCI17CEII8vrVW3JVW8Jr1lc7CjxVAaw2AFwI0_GFv_Wryl42xK82IYc2Ij64vI r41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1l4IxYO2xFxVAFwI0_GFv_Wrylx2IqxVAqx4xG67 AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIY rxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_tr0E3s1lIxAIcVC0I7IYx2IY6xkF7I0E14 v26r4UJVWxJr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r4U JVWxJr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x07 bgXdbUUUUU= X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767678353809057661?= X-GMAIL-MSGID: =?utf-8?q?1767678353809057661?= Because getting IRQ from a device is platform-dependent, PCI devices have different methods for getting an IRQ. This patch is a preparation patch to extend the driver for the PCI device support. Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 34 ++++++++++++++++++++------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c index de8c9894967c..636d3f39ddcb 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c @@ -1817,6 +1817,29 @@ static const struct of_device_id etnaviv_gpu_match[] = { }; MODULE_DEVICE_TABLE(of, etnaviv_gpu_match); +static int etnaviv_gpu_register_irq(struct etnaviv_gpu *gpu, int irq) +{ + struct device *dev = gpu->dev; + int err; + + if (irq < 0) { + dev_err(dev, "failed to get irq: %d\n", irq); + return irq; + } + + err = devm_request_irq(dev, irq, irq_handler, 0, dev_name(dev), gpu); + if (err) { + dev_err(dev, "failed to request IRQ %u: %d\n", irq, err); + return err; + } + + gpu->irq = irq; + + dev_info(dev, "IRQ handler registered, irq = %d\n", irq); + + return 0; +} + static int etnaviv_gpu_platform_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -1837,16 +1860,9 @@ static int etnaviv_gpu_platform_probe(struct platform_device *pdev) return PTR_ERR(gpu->mmio); /* Get Interrupt: */ - gpu->irq = platform_get_irq(pdev, 0); - if (gpu->irq < 0) - return gpu->irq; - - err = devm_request_irq(&pdev->dev, gpu->irq, irq_handler, 0, - dev_name(gpu->dev), gpu); - if (err) { - dev_err(dev, "failed to request IRQ%u: %d\n", gpu->irq, err); + err = etnaviv_gpu_register_irq(gpu, platform_get_irq(pdev, 0)); + if (err) return err; - } /* Get Clocks: */ gpu->clk_reg = devm_clk_get_optional(&pdev->dev, "reg");