From patchwork Tue Sep 12 15:11:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Gmeiner X-Patchwork-Id: 9949407 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 71074603F3 for ; Tue, 12 Sep 2017 15:13:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 637D2286EF for ; Tue, 12 Sep 2017 15:13:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 586D528F5C; Tue, 12 Sep 2017 15:13:08 +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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID 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 C082E28FBE for ; Tue, 12 Sep 2017 15:13:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EAD5D6E688; Tue, 12 Sep 2017 15:12:56 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x242.google.com (mail-wr0-x242.google.com [IPv6:2a00:1450:400c:c0c::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id D24D46E686; Tue, 12 Sep 2017 15:12:55 +0000 (UTC) Received: by mail-wr0-x242.google.com with SMTP id b9so6406359wra.0; Tue, 12 Sep 2017 08:12:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=QmvZlBqqdIfN3nk0I+PqeNO/y3pTtMtYQ4MMucmO1Co=; b=YhIm1XdK0QUNQs6R4TPwxVwTWeR2vCZT4IV4PMfs3TBludVXSe5rVRF4dwNfnoSawr 5CtJ3MOuttuFtAbaVIRsCIZF7LSPZE0QAwrb+rW+3hwwShRxrJRcHJM8DeI+6qX5bQqZ QcuJMqxI1C4MRfiJkqASzhDhbM4dl2yXKvALJsW0mPHw7MkhhIIHgfQCQgnMdqKnJFph LLMs5n7M+q+F9gqEKXXGP++oUCVEQZVDcYvgIhgMVlhwjccwN7JBTOBmIpf+gnk8ZJVo 5qEeEbhmYDAeX5JHoGmBC9iSKMLRCu3DKyxXRbUVDBLQySxdDZz1k55Zt/aWTeQZJ+q6 UyXw== 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=QmvZlBqqdIfN3nk0I+PqeNO/y3pTtMtYQ4MMucmO1Co=; b=I3BA7v20E3VZHBwhTrwZt+jkakRxLs1yHnxjvkiBE2YO4AeGrGlf+5QhxycExV0uRJ kGThsP+rGaKrGFqkXtI6kmoVTAePsxvv0JUYMMFwiIL2Q3dP09KIu2E6cMSMg3Oc2Lqd 1Uql327r52xM+hs+y8MGusS1bu45qu2k7iR8qRufNd4Q3lmlmNhYYSi3aJ2xbSOnINns OXBqAJJCK2XjqbdcPb4R4YqQbwt4qVoZ4rMDDncXqfDoDehKlo6F/aWpGw3Wf98j9EZw 5nKcDdJuglk0/ahqYy4DoPndnDq3HcwJRXBtbPKBl3llo5dyTCmYb+oHdMfzHT4Kju/1 eRHA== X-Gm-Message-State: AHPjjUg/KJdwevCYrFTRvUtzmsMGJfZ/q51DO0RMMK/Lpxwvi5RAmf/y xW8q3hzv3wXcaRV4 X-Google-Smtp-Source: ADKCNb7u679AXtoXSGO1vliJp4xm6lTDJe4NZFF8g+pksKuizwHtA9b3wyWYKxdiSRlk0YkfsjoGWg== X-Received: by 10.223.195.87 with SMTP id e23mr14597301wrg.77.1505229174253; Tue, 12 Sep 2017 08:12:54 -0700 (PDT) Received: from localhost.localdomain (91-115-35-97.adsl.highway.telekom.at. [91.115.35.97]) by smtp.gmail.com with ESMTPSA id 110sm6593819wra.39.2017.09.12.08.12.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Sep 2017 08:12:53 -0700 (PDT) From: Christian Gmeiner To: dri-devel@lists.freedesktop.org Subject: [PATCH V4 07/23] drm/etnaviv: add performance monitor request validation Date: Tue, 12 Sep 2017 17:11:39 +0200 Message-Id: <20170912151155.4603-8-christian.gmeiner@gmail.com> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170912151155.4603-1-christian.gmeiner@gmail.com> References: <20170912151155.4603-1-christian.gmeiner@gmail.com> Cc: linux+etnaviv@armlinux.org.uk, etnaviv@lists.freedesktop.org, cphealy@gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Check if the selected domain and signal combination exists. Signed-off-by: Christian Gmeiner Reviewed-by: Lucas Stach --- drivers/gpu/drm/etnaviv/etnaviv_perfmon.c | 15 +++++++++++++++ drivers/gpu/drm/etnaviv/etnaviv_perfmon.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/drivers/gpu/drm/etnaviv/etnaviv_perfmon.c b/drivers/gpu/drm/etnaviv/etnaviv_perfmon.c index 5bc015194791..3ecedeed87bd 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_perfmon.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_perfmon.c @@ -83,3 +83,18 @@ int etnaviv_pm_query_sig(struct etnaviv_gpu *gpu, return 0; } + +int etnaviv_pm_req_validate(const struct drm_etnaviv_gem_submit_pmr *r) +{ + const struct etnaviv_pm_domain *dom; + + if (r->domain >= ARRAY_SIZE(doms)) + return -EINVAL; + + dom = &doms[r->domain]; + + if (r->signal > dom->nr_signals) + return -EINVAL; + + return 0; +} diff --git a/drivers/gpu/drm/etnaviv/etnaviv_perfmon.h b/drivers/gpu/drm/etnaviv/etnaviv_perfmon.h index 4b2b518cfd16..f20b69c942fc 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_perfmon.h +++ b/drivers/gpu/drm/etnaviv/etnaviv_perfmon.h @@ -40,4 +40,6 @@ int etnaviv_pm_query_dom(struct etnaviv_gpu *gpu, int etnaviv_pm_query_sig(struct etnaviv_gpu *gpu, struct drm_etnaviv_pm_signal *signal); +int etnaviv_pm_req_validate(const struct drm_etnaviv_gem_submit_pmr *r); + #endif /* __ETNAVIV_PERFMON_H__ */