[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <7F0EB945-5BA2-4BE4-BB22-C0BFE028046E@antoniou-consulting.com>
Date: Fri, 27 Mar 2015 11:24:41 -0700
From: Pantelis Antoniou <panto@...oniou-consulting.com>
To: Rob Herring <robherring2@...il.com>
Cc: Grant Likely <grant.likely@...retlab.ca>,
Andrew Morton <akpm@...ux-foundation.org>,
Matt Porter <matt.porter@...aro.org>,
Koen Kooi <koen@...inion.thruhere.net>,
Guenter Roeck <linux@...ck-us.net>,
"devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-api@...r.kernel.org" <linux-api@...r.kernel.org>
Subject: Re: [PATCH 1/5] of: unittest: overlay: Keep track of created overlays
Hi Rob,
> On Mar 24, 2015, at 21:53 , Rob Herring <robherring2@...il.com> wrote:
>
> On Tue, Mar 17, 2015 at 3:30 PM, Pantelis Antoniou
> <pantelis.antoniou@...sulko.com> wrote:
>> During the course of the overlay selftests some of them remain
>> applied. While this does not pose a real problem, make sure you track
>> them and destroy them at the end of the test.
>
> This is going to need to be rebased on my tree as there has been some
> selftest->unitest renaming.
>
Ok, will do so first thing next week.
> Rob
>
Regards
— Pantelis
>>
>> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@...sulko.com>
>> ---
>> drivers/of/unittest.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 62 insertions(+)
>>
>> diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
>> index 4e60682..c711534 100644
>> --- a/drivers/of/unittest.c
>> +++ b/drivers/of/unittest.c
>> @@ -23,6 +23,8 @@
>> #include <linux/i2c.h>
>> #include <linux/i2c-mux.h>
>>
>> +#include <linux/bitops.h>
>> +
>> #include "of_private.h"
>>
>> static struct selftest_results {
>> @@ -1115,6 +1117,59 @@ static const char *overlay_path(int nr)
>>
>> static const char *bus_path = "/testcase-data/overlay-node/test-bus";
>>
>> +/* it is guaranteed that overlay ids are assigned in sequence */
>> +#define MAX_SELFTEST_OVERLAYS 256
>> +static unsigned long overlay_id_bits[BITS_TO_LONGS(MAX_SELFTEST_OVERLAYS)];
>> +static int overlay_first_id = -1;
>> +
>> +static void of_selftest_track_overlay(int id)
>> +{
>> + if (overlay_first_id < 0)
>> + overlay_first_id = id;
>> + id -= overlay_first_id;
>> +
>> + /* we shouldn't need that many */
>> + BUG_ON(id >= MAX_SELFTEST_OVERLAYS);
>> + overlay_id_bits[BIT_WORD(id)] |= BIT_MASK(id);
>> +}
>> +
>> +static void of_selftest_untrack_overlay(int id)
>> +{
>> + if (overlay_first_id < 0)
>> + return;
>> + id -= overlay_first_id;
>> + BUG_ON(id >= MAX_SELFTEST_OVERLAYS);
>> + overlay_id_bits[BIT_WORD(id)] &= ~BIT_MASK(id);
>> +}
>> +
>> +static void of_selftest_destroy_tracked_overlays(void)
>> +{
>> + int id, ret, defers;
>> +
>> + if (overlay_first_id < 0)
>> + return;
>> +
>> + /* try until no defers */
>> + do {
>> + defers = 0;
>> + /* remove in reverse order */
>> + for (id = MAX_SELFTEST_OVERLAYS - 1; id >= 0; id--) {
>> + if (!(overlay_id_bits[BIT_WORD(id)] & BIT_MASK(id)))
>> + continue;
>> +
>> + ret = of_overlay_destroy(id + overlay_first_id);
>> + if (ret != 0) {
>> + defers++;
>> + pr_warn("%s: overlay destroy failed for #%d\n",
>> + __func__, id + overlay_first_id);
>> + continue;
>> + }
>> +
>> + overlay_id_bits[BIT_WORD(id)] &= ~BIT_MASK(id);
>> + }
>> + } while (defers > 0);
>> +}
>> +
>> static int of_selftest_apply_overlay(int selftest_nr, int overlay_nr,
>> int *overlay_id)
>> {
>> @@ -1136,6 +1191,7 @@ static int of_selftest_apply_overlay(int selftest_nr, int overlay_nr,
>> goto out;
>> }
>> id = ret;
>> + of_selftest_track_overlay(id);
>>
>> ret = 0;
>>
>> @@ -1349,6 +1405,7 @@ static void of_selftest_overlay_6(void)
>> return;
>> }
>> ov_id[i] = ret;
>> + of_selftest_track_overlay(ov_id[i]);
>> }
>>
>> for (i = 0; i < 2; i++) {
>> @@ -1373,6 +1430,7 @@ static void of_selftest_overlay_6(void)
>> PDEV_OVERLAY));
>> return;
>> }
>> + of_selftest_untrack_overlay(ov_id[i]);
>> }
>>
>> for (i = 0; i < 2; i++) {
>> @@ -1417,6 +1475,7 @@ static void of_selftest_overlay_8(void)
>> return;
>> }
>> ov_id[i] = ret;
>> + of_selftest_track_overlay(ov_id[i]);
>> }
>>
>> /* now try to remove first overlay (it should fail) */
>> @@ -1439,6 +1498,7 @@ static void of_selftest_overlay_8(void)
>> PDEV_OVERLAY));
>> return;
>> }
>> + of_selftest_untrack_overlay(ov_id[i]);
>> }
>>
>> selftest(1, "overlay test %d passed\n", 8);
>> @@ -1861,6 +1921,8 @@ static void __init of_selftest_overlay(void)
>> of_selftest_overlay_i2c_cleanup();
>> #endif
>>
>> + of_selftest_destroy_tracked_overlays();
>> +
>> out:
>> of_node_put(bus_np);
>> }
>> --
>> 1.7.12
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists