blob: 29bde50410e862be1205b14c41a39e056d37ee1e [file] [log] [blame]
From 2270e68a5295327d3501ac69ea241aaed7546d09 Mon Sep 17 00:00:00 2001
From: Alan Tull <atull@kernel.org>
Date: Wed, 15 Nov 2017 14:20:18 -0600
Subject: [PATCH 1667/1795] fpga: region: fix slow warning with more than one
overlay
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 <atull@kernel.org>
Acked-by: Moritz Fischer <mdf@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit ed81f5fc3c35c22d0fc62813cfa4e11b6aea0a64)
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
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 a921c3c035db..93e7ce9bc6e3 100644
--- a/drivers/fpga/fpga-region.c
+++ b/drivers/fpga/fpga-region.c
@@ -362,6 +362,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.19.0