-
Notifications
You must be signed in to change notification settings - Fork 862
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allwinner: linux: Add upstream fixes
- Loading branch information
Showing
4 changed files
with
545 additions
and
0 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
...s/Allwinner/patches/linux/0061-arm64-dts-allwinner-Fix-SD-card-CD-GPIO-for-SOPine-s.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
From 3dd4ce4185df6798dcdcc3669bddb35899d7d5e1 Mon Sep 17 00:00:00 2001 | ||
From: Andre Przywara <andre.przywara@arm.com> | ||
Date: Tue, 16 Mar 2021 14:42:19 +0000 | ||
Subject: [PATCH] arm64: dts: allwinner: Fix SD card CD GPIO for SOPine systems | ||
|
||
Commit 941432d00768 ("arm64: dts: allwinner: Drop non-removable from | ||
SoPine/LTS SD card") enabled the card detect GPIO for the SOPine module, | ||
along the way with the Pine64-LTS, which share the same base .dtsi. | ||
|
||
However while both boards indeed have a working CD GPIO on PF6, the | ||
polarity is different: the SOPine modules uses a "push-pull" socket, | ||
which has an active-high switch, while the Pine64-LTS use the more | ||
traditional push-push socket and the common active-low switch. | ||
|
||
Fix the polarity in the sopine.dtsi, and overwrite it in the LTS | ||
board .dts, to make the SD card work again on systems using SOPine | ||
modules. | ||
|
||
Fixes: 941432d00768 ("arm64: dts: allwinner: Drop non-removable from SoPine/LTS SD card") | ||
Reported-by: Ashley <contact@victorianfox.com> | ||
Signed-off-by: Andre Przywara <andre.przywara@arm.com> | ||
Signed-off-by: Maxime Ripard <maxime@cerno.tech> | ||
Link: https://lore.kernel.org/r/20210316144219.5973-1-andre.przywara@arm.com | ||
--- | ||
arch/arm64/boot/dts/allwinner/sun50i-a64-pine64-lts.dts | 4 ++++ | ||
arch/arm64/boot/dts/allwinner/sun50i-a64-sopine.dtsi | 2 +- | ||
2 files changed, 5 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64-lts.dts b/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64-lts.dts | ||
index 437ffe3628a5..e79ce49e7e6a 100644 | ||
--- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64-lts.dts | ||
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64-lts.dts | ||
@@ -19,3 +19,7 @@ led { | ||
}; | ||
}; | ||
}; | ||
+ | ||
+&mmc0 { | ||
+ cd-gpios = <&pio 5 6 GPIO_ACTIVE_LOW>; /* PF6 push-push switch */ | ||
+}; | ||
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-sopine.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64-sopine.dtsi | ||
index 3402cec87035..df62044ff7a7 100644 | ||
--- a/arch/arm64/boot/dts/allwinner/sun50i-a64-sopine.dtsi | ||
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-sopine.dtsi | ||
@@ -34,7 +34,7 @@ &mmc0 { | ||
vmmc-supply = <®_dcdc1>; | ||
disable-wp; | ||
bus-width = <4>; | ||
- cd-gpios = <&pio 5 6 GPIO_ACTIVE_LOW>; /* PF6 */ | ||
+ cd-gpios = <&pio 5 6 GPIO_ACTIVE_HIGH>; /* PF6 push-pull switch */ | ||
status = "okay"; | ||
}; | ||
|
||
-- | ||
2.31.1 | ||
|
48 changes: 48 additions & 0 deletions
48
...winner/patches/linux/0062-arm64-dts-allwinner-Revert-SD-card-CD-GPIO-for-Pine64-LTS.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
From: Andre Przywara <andre.przywara@arm.com> | ||
Subject: [PATCH v2] arm64: dts: allwinner: Revert SD card CD GPIO for | ||
Pine64-LTS | ||
Date: Wed, 14 Apr 2021 11:47:40 +0100 | ||
|
||
Commit 941432d00768 ("arm64: dts: allwinner: Drop non-removable from | ||
SoPine/LTS SD card") enabled the card detect GPIO for the SOPine module, | ||
along the way with the Pine64-LTS, which share the same base .dtsi. | ||
|
||
This was based on the observation that the Pine64-LTS has as "push-push" | ||
SD card socket, and that the schematic mentions the card detect GPIO. | ||
|
||
After having received two reports about failing SD card access with that | ||
patch, some more research and polls on that subject revealed that there | ||
are at least two different versions of the Pine64-LTS out there: | ||
- On some boards (including mine) the card detect pin is "stuck" at | ||
high, regardless of an microSD card being inserted or not. | ||
- On other boards the card-detect is working, but is active-high, by | ||
virtue of an explicit inverter circuit, as shown in the schematic. | ||
|
||
To cover all versions of the board out there, and don't take any chances, | ||
let's revert the introduction of the active-low CD GPIO, but let's use | ||
the broken-cd property for the Pine64-LTS this time. That should avoid | ||
regressions and should work for everyone, even allowing SD card changes | ||
now. | ||
The SOPine card detect has proven to be working, so let's keep that | ||
GPIO in place. | ||
|
||
Fixes: 941432d00768 ("arm64: dts: allwinner: Drop non-removable from SoPine/LTS SD card") | ||
Reported-by: Michael Weiser <michael.weiser@gmx.de> | ||
Reported-by: Daniel Kulesz <kuleszdl@posteo.org> | ||
Suggested-by: Chen-Yu Tsai <wens@csie.org> | ||
Signed-off-by: Andre Przywara <andre.przywara@arm.com> | ||
--- | ||
arch/arm64/boot/dts/allwinner/sun50i-a64-pine64-lts.dts | 2 +- | ||
1 file changed, 1 insertion(+), 1 deletion(-) | ||
|
||
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64-lts.dts b/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64-lts.dts | ||
index e79ce49e7e6a..596a25907432 100644 | ||
--- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64-lts.dts | ||
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64-lts.dts | ||
@@ -21,5 +21,5 @@ | ||
}; | ||
|
||
&mmc0 { | ||
- cd-gpios = <&pio 5 6 GPIO_ACTIVE_LOW>; /* PF6 push-push switch */ | ||
+ broken-cd; /* card detect is broken on *some* boards */ | ||
}; |
109 changes: 109 additions & 0 deletions
109
...s/Allwinner/patches/linux/0063-media-v4l2-ctrls.c-fix-race-condition-in-hdl-request.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
From be7e8af98f3af729aa9f08b1053f9533a5cceb91 Mon Sep 17 00:00:00 2001 | ||
From: Hans Verkuil <hverkuil-cisco@xs4all.nl> | ||
Date: Sat, 27 Mar 2021 12:27:40 +0100 | ||
Subject: [PATCH] media: v4l2-ctrls.c: fix race condition in hdl->requests list | ||
|
||
When a request is re-inited it will release all control handler | ||
objects that are still in the request. It does that by unbinding | ||
and putting all those objects. When the object is unbound the | ||
obj->req pointer is set to NULL, and the object's unbind op is | ||
called. When the object it put the object's release op is called | ||
to free the memory. | ||
|
||
For a request object that contains a control handler that means | ||
that v4l2_ctrl_handler_free() is called in the release op. | ||
|
||
A control handler used in a request has a pointer to the main | ||
control handler that is created by the driver and contains the | ||
current state of all controls. If the device is unbound (due to | ||
rmmod or a forced unbind), then that main handler is freed, again | ||
by calling v4l2_ctrl_handler_free(), and any outstanding request | ||
objects that refer to that main handler have to be unbound and put | ||
as well. | ||
|
||
It does that by this test: | ||
|
||
if (!hdl->req_obj.req && !list_empty(&hdl->requests)) { | ||
|
||
I.e. the handler has no pointer to a request, so is the main | ||
handler, and one or more request objects refer to this main | ||
handler. | ||
|
||
However, this test is wrong since hdl->req_obj.req is actually | ||
NULL when re-initing a request (the object unbind will set req to | ||
NULL), and the only reason this seemingly worked is that the | ||
requests list is typically empty since the request's unbind op | ||
will remove the handler from the requests list. | ||
|
||
But if another thread is at the same time adding a new control | ||
to a request, then there is a race condition where one thread | ||
is removing a control handler object from the requests list and | ||
another thread is adding one. The result is that hdl->requests | ||
is no longer empty and the code thinks that a main handler is | ||
being freed instead of a control handler that is part of a request. | ||
|
||
There are two bugs here: first the test for hdl->req_obj.req: this | ||
should be hdl->req_obj.ops since only the main control handler will | ||
have a NULL pointer there. | ||
|
||
The second is that adding or deleting request objects from the | ||
requests list of the main handler isn't protected by taking the | ||
main handler's lock. | ||
|
||
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> | ||
Reported-by: John Cox <jc@kynesim.co.uk> | ||
Fixes: 6fa6f831f095 ("media: v4l2-ctrls: add core request support") | ||
Tested-by: John Cox <jc@kynesim.co.uk> | ||
Reported-by: John Cox <jc@kynesim.co.uk> | ||
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> | ||
--- | ||
drivers/media/v4l2-core/v4l2-ctrls.c | 17 ++++++++++++++--- | ||
1 file changed, 14 insertions(+), 3 deletions(-) | ||
|
||
diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c | ||
index e7fcbaeec0ae..c7bcc5c25771 100644 | ||
--- a/drivers/media/v4l2-core/v4l2-ctrls.c | ||
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c | ||
@@ -2650,7 +2650,15 @@ void v4l2_ctrl_handler_free(struct v4l2_ctrl_handler *hdl) | ||
if (hdl == NULL || hdl->buckets == NULL) | ||
return; | ||
|
||
- if (!hdl->req_obj.req && !list_empty(&hdl->requests)) { | ||
+ /* | ||
+ * If the main handler is freed and it is used by handler objects in | ||
+ * outstanding requests, then unbind and put those objects before | ||
+ * freeing the main handler. | ||
+ * | ||
+ * The main handler can be identified by having a NULL ops pointer in | ||
+ * the request object. | ||
+ */ | ||
+ if (!hdl->req_obj.ops && !list_empty(&hdl->requests)) { | ||
struct v4l2_ctrl_handler *req, *next_req; | ||
|
||
list_for_each_entry_safe(req, next_req, &hdl->requests, requests) { | ||
@@ -3730,8 +3738,8 @@ static void v4l2_ctrl_request_unbind(struct media_request_object *obj) | ||
container_of(obj, struct v4l2_ctrl_handler, req_obj); | ||
struct v4l2_ctrl_handler *main_hdl = obj->priv; | ||
|
||
+ mutex_lock(main_hdl->lock); | ||
list_del_init(&hdl->requests); | ||
- mutex_lock(main_hdl->lock); | ||
if (hdl->request_is_queued) { | ||
list_del_init(&hdl->requests_queued); | ||
hdl->request_is_queued = false; | ||
@@ -3790,8 +3798,11 @@ static int v4l2_ctrl_request_bind(struct media_request *req, | ||
if (!ret) { | ||
ret = media_request_object_bind(req, &req_ops, | ||
from, false, &hdl->req_obj); | ||
- if (!ret) | ||
+ if (!ret) { | ||
+ mutex_lock(from->lock); | ||
list_add_tail(&hdl->requests, &from->requests); | ||
+ mutex_unlock(from->lock); | ||
+ } | ||
} | ||
return ret; | ||
} | ||
-- | ||
2.31.1 | ||
|
Oops, something went wrong.