From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753203AbdGFSry (ORCPT ); Thu, 6 Jul 2017 14:47:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:50870 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753179AbdGFSrr (ORCPT ); Thu, 6 Jul 2017 14:47:47 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9246522B54 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=atull@kernel.org From: Alan Tull To: Moritz Fischer Cc: Alan Tull , linux-kernel@vger.kernel.org, linux-fpga@vger.kernel.org Subject: [PATCH v3 09/16] fpga: region: fix slow warning with more than one overlay Date: Thu, 6 Jul 2017 13:47:09 -0500 Message-Id: <20170706184716.3179-10-atull@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170706184716.3179-1-atull@kernel.org> References: <20170706184716.3179-1-atull@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When DT overlays are applied, each FPGA region keeps track of the fpga image info as region->info. This pointer is assigned only if an overlay causes the FPGA to be programmed. As it stands, this pointer can be overwritten, causing a slow warning later when overlays are removed. This patch fixes this by changing the allowed behaviour. If a region has received an overlay that programmed the FPGA, reject other overlays that try to program the FPGA. To reprogram the FPGA, first remove the overlay. This makes sense as removing the overlay also removes the devices cleanly. Note that overlays that make DT changes without reprogramming the FPGA are exempt from this restriction. Signed-off-by: Alan Tull --- drivers/fpga/fpga-region.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/fpga/fpga-region.c b/drivers/fpga/fpga-region.c index 0c72381..07491ad 100644 --- a/drivers/fpga/fpga-region.c +++ b/drivers/fpga/fpga-region.c @@ -355,6 +355,11 @@ static int fpga_region_notify_pre_apply(struct fpga_region *region, const char *firmware_name; int ret; + if (region->info) { + dev_err(dev, "Region already has overlay applied.\n"); + return -EINVAL; + } + /* * Reject overlay if child FPGA Regions added in the overlay have * firmware-name property (would mean that an FPGA region that has -- 2.7.4