From patchwork Wed May 22 17:36:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 10956383 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 E6CD314C0 for ; Wed, 22 May 2019 17:37:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D92C028868 for ; Wed, 22 May 2019 17:37:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CDC1E28A8B; Wed, 22 May 2019 17:37:02 +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 0073A28868 for ; Wed, 22 May 2019 17:37:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1566489904; Wed, 22 May 2019 17:37:00 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by gabe.freedesktop.org (Postfix) with ESMTPS id 690D989C61 for ; Wed, 22 May 2019 17:36:59 +0000 (UTC) Received: by mail-qt1-x841.google.com with SMTP id i26so3356481qtr.10 for ; Wed, 22 May 2019 10:36:59 -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:mime-version :content-transfer-encoding; bh=AYiSIlwY7eZx42yq/yFRXslZFh/MVGXyDo26yWSMo7o=; b=N0C1O0l5sva8r1LHrIzqwp9rhsSvx8N23YZez9alTlnDwGBgrFH3bT02JTyMV157Q6 CYc9tvFMjOdfi16hADMx59liSRebv4xuz4Xd7KKYyR9RTD9JN76eGLfrvKfnS0bJp9gT F3sM/NFUq/UT363p4kHRJEgE5+aqVrfuZOakSssgLRNDI3Lkk/InWUUnRbOQZUna2KH5 VidENAwIBarrIbbBSmZz3qvmo1aKDkE7ivDphZ1NqSfcqkV3sB2wfMG1DvfvoT55v7s0 WplYqQxtvLNzHR7D+raAB05PE10qXxEaZeeqQSncVUZRivYsE5S+bH+ojSr5JcZgX9BL 8YUA== X-Gm-Message-State: APjAAAVCcFK10oTw6kelAplcKSbY9wR+BUGEK3Tww9v7sjPkPWjhPR9q n9C/ytB8zviT5vXjuf+BInKv4EFCRBE= X-Google-Smtp-Source: APXvYqySVLc8RxuM7HtrdaGFkR54894hlH1Xqo/SCO3BahDCmgyit80hoTs+BawDDwCys8EWkW7NLw== X-Received: by 2002:ac8:8fd:: with SMTP id y58mr77023926qth.375.1558546618411; Wed, 22 May 2019 10:36:58 -0700 (PDT) Received: from rosewood.cam.corp.google.com ([2620:0:1013:11:89c6:2139:5435:371d]) by smtp.gmail.com with ESMTPSA id w143sm10692969qka.22.2019.05.22.10.36.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 May 2019 10:36:57 -0700 (PDT) From: Sean Paul To: dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org Subject: [RESEND PATCH 1/5] drm/msm/a6xx: Avoid freeing gmu resources multiple times Date: Wed, 22 May 2019 13:36:40 -0400 Message-Id: <20190522173656.162006-1-sean@poorly.run> X-Mailer: git-send-email 2.21.0.1020.gf2820cf01a-goog MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=poorly.run; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=AYiSIlwY7eZx42yq/yFRXslZFh/MVGXyDo26yWSMo7o=; b=SrBINLg3y8oOnNpUKbA1YuWFLyA6h+N1Egt2ZPDFCv7VISdUgDKm1XBjTrTHNZWfPm C9cjC/OXMJ9fC2GoGz4FZtTr+fWOe+IRKfLhTK5CJnAX7DAzXA+V8v0U57PCvrC5lr4y 67EXllxIoOz0nX4jPmsGjXiYyqjiyPiY8cMJFNcywvBcfqBrPlQgDcWkoJbGW198Xc6y LfhSbk/uEaOOOxEnPKsi3MBbLploSMuBsLE/3L9OtdoIspbQdZB7rqzQYpBi8AyIQfn0 ImmsiMLq/3i1FP7fpX5sH1Z+EO/WvjFDX7VaN7qKR9h4je3dKiI+HSVoJnC0x85sbWvK J4hQ== 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: Sean Paul , Sean Paul , linux-arm-msm@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Sean Paul The driver checks for gmu->mmio as a sign that the device has been initialized, however there are failures in probe below the mmio init. If one of those is hit, mmio will be non-null but freed. In that case, a6xx_gmu_probe will return an error to a6xx_gpu_init which will in turn call a6xx_gmu_remove which checks gmu->mmio and tries to free resources for a second time. This causes a great boom. Fix this by adding an initialized member to gmu which is set on successful probe and cleared on removal. Signed-off-by: Sean Paul --- Resending as part of the set since some later patches depend on it drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 14 +++++++++----- drivers/gpu/drm/msm/adreno/a6xx_gmu.h | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c index 38e2cfa9cec7..aa84edb25d91 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c @@ -74,7 +74,7 @@ bool a6xx_gmu_sptprac_is_on(struct a6xx_gmu *gmu) u32 val; /* This can be called from gpu state code so make sure GMU is valid */ - if (IS_ERR_OR_NULL(gmu->mmio)) + if (!gmu->initialized) return false; val = gmu_read(gmu, REG_A6XX_GMU_SPTPRAC_PWR_CLK_STATUS); @@ -90,7 +90,7 @@ bool a6xx_gmu_gx_is_on(struct a6xx_gmu *gmu) u32 val; /* This can be called from gpu state code so make sure GMU is valid */ - if (IS_ERR_OR_NULL(gmu->mmio)) + if (!gmu->initialized) return false; val = gmu_read(gmu, REG_A6XX_GMU_SPTPRAC_PWR_CLK_STATUS); @@ -695,7 +695,7 @@ int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu) struct a6xx_gmu *gmu = &a6xx_gpu->gmu; int status, ret; - if (WARN(!gmu->mmio, "The GMU is not set up yet\n")) + if (WARN(!gmu->initialized, "The GMU is not set up yet\n")) return 0; gmu->hung = false; @@ -765,7 +765,7 @@ bool a6xx_gmu_isidle(struct a6xx_gmu *gmu) { u32 reg; - if (!gmu->mmio) + if (!gmu->initialized) return true; reg = gmu_read(gmu, REG_A6XX_GPU_GMU_AO_GPU_CX_BUSY_STATUS); @@ -1227,7 +1227,7 @@ void a6xx_gmu_remove(struct a6xx_gpu *a6xx_gpu) { struct a6xx_gmu *gmu = &a6xx_gpu->gmu; - if (IS_ERR_OR_NULL(gmu->mmio)) + if (!gmu->initialized) return; a6xx_gmu_stop(a6xx_gpu); @@ -1245,6 +1245,8 @@ void a6xx_gmu_remove(struct a6xx_gpu *a6xx_gpu) iommu_detach_device(gmu->domain, gmu->dev); iommu_domain_free(gmu->domain); + + gmu->initialized = false; } int a6xx_gmu_probe(struct a6xx_gpu *a6xx_gpu, struct device_node *node) @@ -1309,6 +1311,8 @@ int a6xx_gmu_probe(struct a6xx_gpu *a6xx_gpu, struct device_node *node) /* Set up the HFI queues */ a6xx_hfi_init(gmu); + gmu->initialized = true; + return 0; err: a6xx_gmu_memory_free(gmu, gmu->hfi); diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.h b/drivers/gpu/drm/msm/adreno/a6xx_gmu.h index bedd8e6a63aa..39a26dd63674 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.h +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.h @@ -75,6 +75,7 @@ struct a6xx_gmu { struct a6xx_hfi_queue queues[2]; + bool initialized; bool hung; }; From patchwork Wed May 22 17:36:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 10956387 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 8958713AD for ; Wed, 22 May 2019 17:37:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BA4128C02 for ; Wed, 22 May 2019 17:37:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7013C28C0A; Wed, 22 May 2019 17:37:10 +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 37CBF28C02 for ; Wed, 22 May 2019 17:37:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 77D2A89C6E; Wed, 22 May 2019 17:37:09 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by gabe.freedesktop.org (Postfix) with ESMTPS id 88E9B89C6E for ; Wed, 22 May 2019 17:37:07 +0000 (UTC) Received: by mail-qt1-x844.google.com with SMTP id j53so3357530qta.9 for ; Wed, 22 May 2019 10:37:07 -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:mime-version:content-transfer-encoding; bh=rfjKyX7zH6WdV+81p3MbZM1b4C1cPYdMHawe6tfVqAs=; b=njcfgpdozm0X7tXX1jMKR5/wyXOBSMVuSotqg/LHpzaIGlPWujYDQN2Ya8pf0hhjkR xvxEPIYVe5uhH4/0XsSjR/Cc5nfandS5tMJdCB/xhuPmxOoVl1GdakNMNcTj74w7T/M6 ziUBB/BbSroaiKPX/PDlqVE4rx7E+/l1SgbB93zL4XJMt90yvkF6TEOHO93LwDj186QB gVUNv7SPkD8E2NGBICVbUHBut3LqIsJSnHgyoyZ7/A9OoVM9l5JzcYiFmRZS0fr9rgvf dFX8IfTakIeYsFT47McsUVz+lj9krjueeVwlnEAfvxwfhTbgfVFxIxKCaeZVJoFleSto I5mA== X-Gm-Message-State: APjAAAUvcJW4y62EBVHbcw421j+9fNL7ptN2iob65959qx4HZ/xrq/N+ RTbVNxUTV2WnqV4+KkrJBLQKIKTssFo= X-Google-Smtp-Source: APXvYqy43UmlIKYjLNdnnXAJzeA14V/9hMBmSX0GlDxsmqTqZ6mvNCzd//FES5K73n/5R618j8mAGQ== X-Received: by 2002:ac8:38d1:: with SMTP id g17mr6085370qtc.281.1558546626606; Wed, 22 May 2019 10:37:06 -0700 (PDT) Received: from rosewood.cam.corp.google.com ([2620:0:1013:11:89c6:2139:5435:371d]) by smtp.gmail.com with ESMTPSA id w143sm10692969qka.22.2019.05.22.10.37.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 May 2019 10:37:06 -0700 (PDT) From: Sean Paul To: dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org Subject: [PATCH 2/5] drm/msm/a6xx: Remove duplicate irq disable from remove Date: Wed, 22 May 2019 13:36:41 -0400 Message-Id: <20190522173656.162006-2-sean@poorly.run> X-Mailer: git-send-email 2.21.0.1020.gf2820cf01a-goog In-Reply-To: <20190522173656.162006-1-sean@poorly.run> References: <20190522173656.162006-1-sean@poorly.run> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=poorly.run; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rfjKyX7zH6WdV+81p3MbZM1b4C1cPYdMHawe6tfVqAs=; b=VUhMOA1ELdO2stBmws9mvE7SyaFYOggjY0RgWmAQ6KDJRHFjsOThuqfVd1XAUr91yy JohAmFWN88/e3S4AweJBb/XTKZRNl0ObBTwmbTajcUlv06sxUIzX5Q9QZH6EWEyM6Bsj GiXK79bczQHpZeh9VeojG6UUWPJQTvTZuBqAhLAB/75k8D1WNeyBI//aRciFBUv1v5eG BsZ7DD5Q4beTX041a6b6G5VuE73PapMjm37tIELFnuufhzF1Isuq6VpMqG4DcbtP85Ql D0wHVA3lwsnCFBbv0gq2v0dV/aGm4A4FnPIKDXMxAmn9QGyIOSCyoC8JX7olSq78aZtM pxjg== 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: Sean Paul , Sean Paul , linux-arm-msm@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Sean Paul a6xx_gmu_stop() already calls this function via shutdown or force_stop, so it's not necessary to call it twice. This also knocks the irq depth count out of sync, so nice to avoid. Signed-off-by: Sean Paul --- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c index aa84edb25d91..742c8ff9a61c 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c @@ -1239,7 +1239,6 @@ void a6xx_gmu_remove(struct a6xx_gpu *a6xx_gpu) dev_pm_domain_detach(gmu->gxpd, false); } - a6xx_gmu_irq_disable(gmu); a6xx_gmu_memory_free(gmu, gmu->hfi); iommu_detach_device(gmu->domain, gmu->dev); From patchwork Wed May 22 17:36:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 10956391 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 2F89713AD for ; Wed, 22 May 2019 17:37:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2156128384 for ; Wed, 22 May 2019 17:37:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 15AF928A8B; Wed, 22 May 2019 17:37:15 +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 D0FCA28384 for ; Wed, 22 May 2019 17:37:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D5FA189C82; Wed, 22 May 2019 17:37:13 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7A2D289C83 for ; Wed, 22 May 2019 17:37:12 +0000 (UTC) Received: by mail-qt1-x843.google.com with SMTP id j53so3357879qta.9 for ; Wed, 22 May 2019 10:37:12 -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:mime-version:content-transfer-encoding; bh=tZML6VkciB7AuKKei7Kqbg+e3K02ODJFh5iugoLa3GU=; b=CGywsh2hn6i+sPuRpy9YVxdxumiL8POq6hoq4Ym986Eo54Il/hDr4lbu2UNfvi++Y9 +i3AzqH29NlR7CDDuBkIqcHUCSuUKPsmhWJvUtDz10OCi5IGEw58Yhz5my3jGTmG2kCU ltDKEKr3I5rkoRNlb0ik/e3sGUyubfwG3Gb+NdtFg2R7z401+uT/Xk7+F7Im1vl/kty9 tOarKVBom/B2HiYGfpUyjDdm4lLQ7mpTqQZ84leIJ9Rmi71viHKcRbnxt4OW68gVLQg1 oKG+ySVxGS1Y3m7O2+Vv5Q9wknB1MJwheVLk50HUoG73YMgCgDxvhNHuF37EhB5Tzn7d VIWA== X-Gm-Message-State: APjAAAXGwTvB98mxAGLBmcgyZUW/ORKqB1Q5xouEFOaa8XuX0Fu3dYnL 4u3VK/ClMfXhovx6xmJNvYX0P9AHY8s= X-Google-Smtp-Source: APXvYqwACFZKaEuG6C4xoOxKoLMhDaml3NRoW801dp1Y62ESCBRpNtQDuDaIvLMtGBgUu36tBg0bUg== X-Received: by 2002:a0c:8a8d:: with SMTP id 13mr40433344qvv.88.1558546631511; Wed, 22 May 2019 10:37:11 -0700 (PDT) Received: from rosewood.cam.corp.google.com ([2620:0:1013:11:89c6:2139:5435:371d]) by smtp.gmail.com with ESMTPSA id w143sm10692969qka.22.2019.05.22.10.37.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 May 2019 10:37:11 -0700 (PDT) From: Sean Paul To: dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org Subject: [PATCH 3/5] drm/msm/a6xx: Check for ERR or NULL before iounmap Date: Wed, 22 May 2019 13:36:42 -0400 Message-Id: <20190522173656.162006-3-sean@poorly.run> X-Mailer: git-send-email 2.21.0.1020.gf2820cf01a-goog In-Reply-To: <20190522173656.162006-1-sean@poorly.run> References: <20190522173656.162006-1-sean@poorly.run> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=poorly.run; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tZML6VkciB7AuKKei7Kqbg+e3K02ODJFh5iugoLa3GU=; b=ZqJTTf89H8OWeKKoOJtmynNFXV7rb0e8QnxtvOdBncJjlCKAjY5K6UH3wifhFNrxJv ZzgggAfAs3fPRzOXGjd4/ATy83o1+RXlJjPzYFGav7o4ceZ3ecFJgK212EbeR08ZP8Fp Gu6ydgPk2bHvWeCaGIfKaK1OTNwD3myVndjGq+fSg1zFMegrAbBGaJFsjntpcNc2GaMy 1JToWMTj5pmkBFLwKSuoWx6omWw3ELLOOG7g1giTX5hl6YuZebD24oCpGfMq886Le+EK EsmBH60VpYZauQbkPDSqVRjqvwuDHIzAME53Cxu34mLZI9yu0GStY03HJk+DEdPmS/dy 5gtg== 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: Sean Paul , Sean Paul , linux-arm-msm@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Sean Paul pdcptr and seqptr aren't necessarily valid, check them before trying to unmap them. Signed-off-by: Sean Paul --- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c index 742c8ff9a61c..7465423e9b71 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c @@ -504,8 +504,10 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu) wmb(); err: - devm_iounmap(gmu->dev, pdcptr); - devm_iounmap(gmu->dev, seqptr); + if (!IS_ERR_OR_NULL(pdcptr)) + devm_iounmap(gmu->dev, pdcptr); + if (!IS_ERR_OR_NULL(seqptr)) + devm_iounmap(gmu->dev, seqptr); } /* From patchwork Wed May 22 17:36:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 10956395 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 8A2526C5 for ; Wed, 22 May 2019 17:37:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 769B928384 for ; Wed, 22 May 2019 17:37:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6890028965; Wed, 22 May 2019 17:37:19 +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 14E8928965 for ; Wed, 22 May 2019 17:37:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 31D2F89C6A; Wed, 22 May 2019 17:37:18 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by gabe.freedesktop.org (Postfix) with ESMTPS id 45D7C89C89 for ; Wed, 22 May 2019 17:37:17 +0000 (UTC) Received: by mail-qk1-x744.google.com with SMTP id z128so2016442qkb.6 for ; Wed, 22 May 2019 10:37:17 -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:mime-version:content-transfer-encoding; bh=gk8hCemPy32k7hUtY7KZ+8tj1MeHqRPPVcMcbE5vdqY=; b=s1SSyVOoXLdEvpSDwWJuqweqD5gTQFn2C5QSuCRIp9ZvwxrxqWAbLJiboCJ2J+oChR vE/dzJX+Qv8k+MbK9PI0L7jUL9qSHInhJ+6Km2kN97pAC2xgEnoy+4ygPVhiPwb0asFz jKLmhO/7o5oW8MLzgfm8Gc5G0iVHzx2Yhz34lwGt84CFfOoNNhowIzBMB5Fo1Q1SLmlz MUM8cE83pbdXx23y8ZLxG71SCjbC63Eb9b2ME26ZN5mxoSW1w2K33bytCpqEH3OKCbaW 1ibZGfPiS150xrlwq1AAp4GFt/f/70HEcORzyCDDlHE3HC7m99UkP+qo9uj2lQ3hqknS GhfQ== X-Gm-Message-State: APjAAAWwRGKnACtOcF/MkyArqTLONLaUMh/mUbn9x+gYUXfdMB/PFwZz LxWJJbb8EGJp5mNc2WIsnO4OIl4H1Aw= X-Google-Smtp-Source: APXvYqyk3xYM0+FisGd+ENFvSX310SVFXTFYPEO8kL4f1+5+ec7XKzynwdsLr2Ork05bpL8KYQuAQw== X-Received: by 2002:a05:620a:1479:: with SMTP id j25mr69337992qkl.218.1558546636332; Wed, 22 May 2019 10:37:16 -0700 (PDT) Received: from rosewood.cam.corp.google.com ([2620:0:1013:11:89c6:2139:5435:371d]) by smtp.gmail.com with ESMTPSA id w143sm10692969qka.22.2019.05.22.10.37.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 May 2019 10:37:15 -0700 (PDT) From: Sean Paul To: dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org Subject: [PATCH 4/5] drm/msm/a6xx: Remove devm calls from gmu driver Date: Wed, 22 May 2019 13:36:43 -0400 Message-Id: <20190522173656.162006-4-sean@poorly.run> X-Mailer: git-send-email 2.21.0.1020.gf2820cf01a-goog In-Reply-To: <20190522173656.162006-1-sean@poorly.run> References: <20190522173656.162006-1-sean@poorly.run> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=poorly.run; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gk8hCemPy32k7hUtY7KZ+8tj1MeHqRPPVcMcbE5vdqY=; b=PoikOXUPL4Vn/ay3Aqg4ARP3Khyv1uCrxHmKF3RRaGGj9yQ8/XxJJNGO0/B9E0ceSm 20FqcBiRkDFxfeAYdLNX4ogwjQL7pzp6sP5yI7IQJms5faqfH3Y69MogbMEUheNciuYZ zbhsIM8oqLERNLol3ODglJ5p/jVydBOeMaKZOO2u5xgjIGe3xTr8jFiEhiJJk8KAo773 TgRoYvRtNbRRO1fAh9mXoLbAMASd7sMS8e+5MgzVviEoMVpuVCifFUtf7Uf0eEfnHrk9 weTXG1uVr+To8+xmm4Bd+YafzFKyMKolTWe/PnklRRQp1FKHtQQ7P1clfW7Mmo/Uk0qE Y1og== 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: Sean Paul , Sean Paul , linux-arm-msm@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Sean Paul The gmu driver is initalized and cleaned up with calls from the gpu driver. As such, the platform device stays valid after a6xx_gmu_remove is called and the device managed resources are not freed. In the case of gpu probe failures or unbind, these resources will remain managed. If the gpu bind is run again (eg: if there's a probe defer somewhere in msm), these resources will be initialized again for the same device, creating multiple references. In the case of irqs, this causes failures since the irqs are not shared (nor should they be). This patch removes all devm_* calls and manually cleans things up in gmu_remove. Signed-off-by: Sean Paul --- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c index 7465423e9b71..701b813fa38a 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c @@ -505,9 +505,9 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu) err: if (!IS_ERR_OR_NULL(pdcptr)) - devm_iounmap(gmu->dev, pdcptr); + iounmap(pdcptr); if (!IS_ERR_OR_NULL(seqptr)) - devm_iounmap(gmu->dev, seqptr); + iounmap(seqptr); } /* @@ -1197,7 +1197,7 @@ static void __iomem *a6xx_gmu_get_mmio(struct platform_device *pdev, return ERR_PTR(-EINVAL); } - ret = devm_ioremap(&pdev->dev, res->start, resource_size(res)); + ret = ioremap(res->start, resource_size(res)); if (!ret) { DRM_DEV_ERROR(&pdev->dev, "Unable to map the %s registers\n", name); return ERR_PTR(-EINVAL); @@ -1213,10 +1213,10 @@ static int a6xx_gmu_get_irq(struct a6xx_gmu *gmu, struct platform_device *pdev, irq = platform_get_irq_byname(pdev, name); - ret = devm_request_irq(&pdev->dev, irq, handler, IRQF_TRIGGER_HIGH, - name, gmu); + ret = request_irq(irq, handler, IRQF_TRIGGER_HIGH, name, gmu); if (ret) { - DRM_DEV_ERROR(&pdev->dev, "Unable to get interrupt %s\n", name); + DRM_DEV_ERROR(&pdev->dev, "Unable to get interrupt %s %d\n", + name, ret); return ret; } @@ -1241,12 +1241,18 @@ void a6xx_gmu_remove(struct a6xx_gpu *a6xx_gpu) dev_pm_domain_detach(gmu->gxpd, false); } + iounmap(gmu->mmio); + gmu->mmio = NULL; + a6xx_gmu_memory_free(gmu, gmu->hfi); iommu_detach_device(gmu->domain, gmu->dev); iommu_domain_free(gmu->domain); + free_irq(gmu->gmu_irq, gmu); + free_irq(gmu->hfi_irq, gmu); + gmu->initialized = false; } From patchwork Wed May 22 17:36:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 10956399 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 4E4F513AD for ; Wed, 22 May 2019 17:37:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4067428965 for ; Wed, 22 May 2019 17:37:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 351CE28A8B; Wed, 22 May 2019 17:37:23 +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 D91F928384 for ; Wed, 22 May 2019 17:37:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CF7D789C8F; Wed, 22 May 2019 17:37:21 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by gabe.freedesktop.org (Postfix) with ESMTPS id C9E5989C93 for ; Wed, 22 May 2019 17:37:20 +0000 (UTC) Received: by mail-qt1-x843.google.com with SMTP id f24so3353327qtk.11 for ; Wed, 22 May 2019 10:37:20 -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:mime-version:content-transfer-encoding; bh=xXxK1SdvMa5QM5LCKyWVp4e9t2vqNYcogqHpLSLLhIg=; b=DL7XdJgO+/2B90gE6ppTLSCf9UJNlF6nod139NwVzd9g2IaDgmws/XTfLZT5tbzrPk m4MbOLMSX7Ky4qcBOItXdtBaGrRBIqXpXQCpClYHIYfZAefxgREtxbD3CJSNQlwJHLRZ s81nNBrEqOE3zMOYwP7E/HmVwfalPwtAfvs83aU5h6oT2473Bgorvvjl7WyeAZkPlJev 4f5u95rHsvbgYGpYzNGBdXrA6G0yc/fGsiWsqB4voZEt4yQMvDm6cLkIpSQdC9ZmvV64 wgzobBJ5Yo+xUkuoV2nn4JyPYA446WoTwh0/+ioDd6a/l2uEEImoEJlgp/FFzut0RUuJ kZmQ== X-Gm-Message-State: APjAAAVtgXmNXWutyFZqO+Bymcz2VfSoEk5X61zO9ErHNshslqPvsud3 XyqBP5jEIPXFY2xxX4mqqRYE5ailEZw= X-Google-Smtp-Source: APXvYqy/u71X2vK71//eIydQ9D0SXgzfKKRGUI6ixkuJuEU3Fh6rhvDxQqu3U20I+iJYQX7kbjFjgA== X-Received: by 2002:a0c:9639:: with SMTP id 54mr56022780qvx.105.1558546639896; Wed, 22 May 2019 10:37:19 -0700 (PDT) Received: from rosewood.cam.corp.google.com ([2620:0:1013:11:89c6:2139:5435:371d]) by smtp.gmail.com with ESMTPSA id w143sm10692969qka.22.2019.05.22.10.37.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 May 2019 10:37:19 -0700 (PDT) From: Sean Paul To: dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org Subject: [PATCH 5/5] drm/msm/a6xx: Rename a6xx_gmu_probe to a6xx_gmu_init Date: Wed, 22 May 2019 13:36:44 -0400 Message-Id: <20190522173656.162006-5-sean@poorly.run> X-Mailer: git-send-email 2.21.0.1020.gf2820cf01a-goog In-Reply-To: <20190522173656.162006-1-sean@poorly.run> References: <20190522173656.162006-1-sean@poorly.run> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=poorly.run; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xXxK1SdvMa5QM5LCKyWVp4e9t2vqNYcogqHpLSLLhIg=; b=fYwz5Xn2gUyJ8TSsHmm2mYXLmdUcoer3oKLz0EdRFeyNzHUkmTz/MDnIp1x4eu9we9 D5sdfruQ69jaDbrbw0XZB/8H09QuDjotmkN1/zedx0Avo2WO+FX2rtBLBOEVQpF4hPHP UJjTRAPkuqGinXdu2hyOkQYpsHEOlsG6gh2ROj0DNNq2TvYpWmq73UJ9TOlYiFLo6wmj uDkIgLd8CvA9WhUWUC2pECn4CQQyn+1mCLPjbfCXPfaxvOoOWvhoXGIW9Cm2Sh1c7H3A dPWDMIVTgibXIqVhta/pM6A7E2v5bxMviAbomMdjkndOke/g8SgNNQpuO5eDoPQ7GQeN +tdQ== 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: Sean Paul , Sean Paul , linux-arm-msm@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Sean Paul This rename makes it more clear that everything initialized in the _init function must be cleaned up in a6xx_gmu_remove. This will hopefully dissuade people from using device managed resources (for reasons laid out in the previous patch). Signed-off-by: Sean Paul --- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 2 +- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 2 +- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c index 701b813fa38a..26f44a187eda 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c @@ -1256,7 +1256,7 @@ void a6xx_gmu_remove(struct a6xx_gpu *a6xx_gpu) gmu->initialized = false; } -int a6xx_gmu_probe(struct a6xx_gpu *a6xx_gpu, struct device_node *node) +int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node) { struct a6xx_gmu *gmu = &a6xx_gpu->gmu; struct platform_device *pdev = of_find_device_by_node(node); diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c index e74dce474250..1f9f4b0a9656 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c @@ -854,7 +854,7 @@ struct msm_gpu *a6xx_gpu_init(struct drm_device *dev) /* FIXME: How do we gracefully handle this? */ BUG_ON(!node); - ret = a6xx_gmu_probe(a6xx_gpu, node); + ret = a6xx_gmu_init(a6xx_gpu, node); if (ret) { a6xx_destroy(&(a6xx_gpu->base.base)); return ERR_PTR(ret); diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h index b46279eb18c5..64399554f2dd 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h @@ -53,7 +53,7 @@ bool a6xx_gmu_isidle(struct a6xx_gmu *gmu); int a6xx_gmu_set_oob(struct a6xx_gmu *gmu, enum a6xx_gmu_oob_state state); void a6xx_gmu_clear_oob(struct a6xx_gmu *gmu, enum a6xx_gmu_oob_state state); -int a6xx_gmu_probe(struct a6xx_gpu *a6xx_gpu, struct device_node *node); +int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node); void a6xx_gmu_remove(struct a6xx_gpu *a6xx_gpu); void a6xx_gmu_set_freq(struct msm_gpu *gpu, unsigned long freq);