linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/8] lib/uuid: Introduce uuid_{be|le}_cmp_p{p}() helpers
@ 2017-04-21 14:46 Andy Shevchenko
  2017-04-21 14:46 ` [PATCH v1 2/8] ASoC: Intel: Skylake: Use recently introduced uuid_le_cmp_p{p}() Andy Shevchenko
                   ` (7 more replies)
  0 siblings, 8 replies; 19+ messages in thread
From: Andy Shevchenko @ 2017-04-21 14:46 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel, Arnd Bergmann, Mika Westerberg,
	alsa-devel, linux-input, kvm, devel, linux-efi, linux-acpi
  Cc: Andy Shevchenko, Liam Girdwood, Mark Brown, Vinod Koul,
	Srinivas Pandruvada, Benjamin Tissoires, Kirti Wankhede,
	Alex Williamson, K. Y. Srinivasan, Haiyang Zhang,
	Stephen Hemminger, Tomas Winkler, Matt Fleming, Ard Biesheuvel,
	Rafael J. Wysocki

New helpers take pointers to uuid_{be|le} as parameters.

When using them on a raw data we don't need to do an ugly dereference
and, in some cases, a type casting.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Vinod Koul <vinod.koul@intel.com>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: Kirti Wankhede <kwankhede@nvidia.com>
Cc: Alex Williamson <alex.williamson@redhat.com>
Cc: "K. Y. Srinivasan" <kys@microsoft.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Cc: Stephen Hemminger <sthemmin@microsoft.com>
Cc: Tomas Winkler <tomas.winkler@intel.com>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 include/linux/uuid.h | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/include/linux/uuid.h b/include/linux/uuid.h
index 4dff73a89758..45312cb5ac65 100644
--- a/include/linux/uuid.h
+++ b/include/linux/uuid.h
@@ -58,6 +58,26 @@ static inline int uuid_be_cmp(const uuid_be u1, const uuid_be u2)
 	return memcmp(&u1, &u2, sizeof(uuid_be));
 }
 
+static inline int uuid_le_cmp_p(const uuid_le *pu1, const uuid_le u2)
+{
+	return memcmp(pu1, &u2, sizeof(uuid_le));
+}
+
+static inline int uuid_be_cmp_p(const uuid_be *pu1, const uuid_be u2)
+{
+	return memcmp(pu1, &u2, sizeof(uuid_be));
+}
+
+static inline int uuid_le_cmp_pp(const uuid_le *pu1, const uuid_le *pu2)
+{
+	return memcmp(pu1, pu2, sizeof(uuid_le));
+}
+
+static inline int uuid_be_cmp_pp(const uuid_be *pu1, const uuid_be *pu2)
+{
+	return memcmp(pu1, pu2, sizeof(uuid_be));
+}
+
 void generate_random_uuid(unsigned char uuid[16]);
 
 extern void uuid_le_gen(uuid_le *u);
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v1 2/8] ASoC: Intel: Skylake: Use recently introduced uuid_le_cmp_p{p}()
  2017-04-21 14:46 [PATCH v1 1/8] lib/uuid: Introduce uuid_{be|le}_cmp_p{p}() helpers Andy Shevchenko
@ 2017-04-21 14:46 ` Andy Shevchenko
  2017-04-24  4:51   ` Vinod Koul
  2017-04-21 14:46 ` [PATCH v1 3/8] HID: intel_ish-hid: " Andy Shevchenko
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 19+ messages in thread
From: Andy Shevchenko @ 2017-04-21 14:46 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel, Arnd Bergmann, Mika Westerberg,
	alsa-devel, linux-input, kvm, devel, linux-efi, linux-acpi
  Cc: Andy Shevchenko, Liam Girdwood, Mark Brown, Vinod Koul

Recently introduced helpers take pointers to uuid_{be|le} instead of
reference.

Using them makes code less ugly.

Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 sound/soc/intel/skylake/skl-pcm.c       | 2 +-
 sound/soc/intel/skylake/skl-sst-utils.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c
index 600faad19bd4..4bf171985872 100644
--- a/sound/soc/intel/skylake/skl-pcm.c
+++ b/sound/soc/intel/skylake/skl-pcm.c
@@ -1207,7 +1207,7 @@ static int skl_get_module_info(struct skl *skl, struct skl_module_cfg *mconfig)
 	}
 
 	list_for_each_entry(module, &ctx->uuid_list, list) {
-		if (uuid_le_cmp(*uuid_mod, module->uuid) == 0) {
+		if (uuid_le_cmp_p(uuid_mod, module->uuid) == 0) {
 			mconfig->id.module_id = module->id;
 			mconfig->is_loadable = module->is_loadable;
 			return 0;
diff --git a/sound/soc/intel/skylake/skl-sst-utils.c b/sound/soc/intel/skylake/skl-sst-utils.c
index 6d5bff04bf65..67288580c743 100644
--- a/sound/soc/intel/skylake/skl-sst-utils.c
+++ b/sound/soc/intel/skylake/skl-sst-utils.c
@@ -189,7 +189,7 @@ int skl_get_pvt_id(struct skl_sst *ctx, uuid_le *uuid_mod, int instance_id)
 	int pvt_id;
 
 	list_for_each_entry(module, &ctx->uuid_list, list) {
-		if (uuid_le_cmp(*uuid_mod, module->uuid) == 0) {
+		if (uuid_le_cmp_p(uuid_mod, module->uuid) == 0) {
 
 			pvt_id = skl_pvtid_128(module);
 			if (pvt_id >= 0) {
@@ -218,7 +218,7 @@ int skl_put_pvt_id(struct skl_sst *ctx, uuid_le *uuid_mod, int *pvt_id)
 	struct uuid_module *module;
 
 	list_for_each_entry(module, &ctx->uuid_list, list) {
-		if (uuid_le_cmp(*uuid_mod, module->uuid) == 0) {
+		if (uuid_le_cmp_p(uuid_mod, module->uuid) == 0) {
 
 			if (*pvt_id != 0)
 				i = (*pvt_id) / 64;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v1 3/8] HID: intel_ish-hid: Use recently introduced uuid_le_cmp_p{p}()
  2017-04-21 14:46 [PATCH v1 1/8] lib/uuid: Introduce uuid_{be|le}_cmp_p{p}() helpers Andy Shevchenko
  2017-04-21 14:46 ` [PATCH v1 2/8] ASoC: Intel: Skylake: Use recently introduced uuid_le_cmp_p{p}() Andy Shevchenko
@ 2017-04-21 14:46 ` Andy Shevchenko
  2017-04-21 14:46 ` [PATCH v1 4/8] vfio-mdev: " Andy Shevchenko
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2017-04-21 14:46 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel, Arnd Bergmann, Mika Westerberg,
	alsa-devel, linux-input, kvm, devel, linux-efi, linux-acpi
  Cc: Andy Shevchenko, Srinivas Pandruvada, Benjamin Tissoires

Recently introduced helpers take pointers to uuid_{be|le} instead of
reference.

Using them makes code less ugly.

Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/hid/intel-ish-hid/ishtp/bus.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/hid/intel-ish-hid/ishtp/bus.c b/drivers/hid/intel-ish-hid/ishtp/bus.c
index 5f382fedc2ab..165e21b7ee9f 100644
--- a/drivers/hid/intel-ish-hid/ishtp/bus.c
+++ b/drivers/hid/intel-ish-hid/ishtp/bus.c
@@ -138,8 +138,7 @@ int ishtp_fw_cl_by_uuid(struct ishtp_device *dev, const uuid_le *uuid)
 	int i, res = -ENOENT;
 
 	for (i = 0; i < dev->fw_clients_num; ++i) {
-		if (uuid_le_cmp(*uuid, dev->fw_clients[i].props.protocol_name)
-				== 0) {
+		if (!uuid_le_cmp_p(uuid, dev->fw_clients[i].props.protocol_name)) {
 			res = i;
 			break;
 		}
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v1 4/8] vfio-mdev: Use recently introduced uuid_le_cmp_p{p}()
  2017-04-21 14:46 [PATCH v1 1/8] lib/uuid: Introduce uuid_{be|le}_cmp_p{p}() helpers Andy Shevchenko
  2017-04-21 14:46 ` [PATCH v1 2/8] ASoC: Intel: Skylake: Use recently introduced uuid_le_cmp_p{p}() Andy Shevchenko
  2017-04-21 14:46 ` [PATCH v1 3/8] HID: intel_ish-hid: " Andy Shevchenko
@ 2017-04-21 14:46 ` Andy Shevchenko
  2017-04-21 14:46 ` [PATCH v1 5/8] vmbus: Use recently introduced uuid_le_cmp_p{p}() helpers Andy Shevchenko
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2017-04-21 14:46 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel, Arnd Bergmann, Mika Westerberg,
	alsa-devel, linux-input, kvm, devel, linux-efi, linux-acpi
  Cc: Andy Shevchenko, Kirti Wankhede, Alex Williamson

Recently introduced helpers take pointers to uuid_{be|le} instead of
reference.

Using them makes code less ugly.

Cc: Kirti Wankhede <kwankhede@nvidia.com>
Cc: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/vfio/mdev/mdev_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c
index 126991046eb7..82de886855d8 100644
--- a/drivers/vfio/mdev/mdev_core.c
+++ b/drivers/vfio/mdev/mdev_core.c
@@ -75,7 +75,7 @@ static int _find_mdev_device(struct device *dev, void *data)
 
 	mdev = to_mdev_device(dev);
 
-	if (uuid_le_cmp(mdev->uuid, *(uuid_le *)data) == 0)
+	if (uuid_le_cmp_p(data, mdev->uuid) == 0)
 		return 1;
 
 	return 0;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v1 5/8] vmbus: Use recently introduced uuid_le_cmp_p{p}() helpers
  2017-04-21 14:46 [PATCH v1 1/8] lib/uuid: Introduce uuid_{be|le}_cmp_p{p}() helpers Andy Shevchenko
                   ` (2 preceding siblings ...)
  2017-04-21 14:46 ` [PATCH v1 4/8] vfio-mdev: " Andy Shevchenko
@ 2017-04-21 14:46 ` Andy Shevchenko
  2017-04-21 14:46 ` [PATCH v1 6/8] mei: " Andy Shevchenko
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2017-04-21 14:46 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel, Arnd Bergmann, Mika Westerberg,
	alsa-devel, linux-input, kvm, devel, linux-efi, linux-acpi
  Cc: Andy Shevchenko, K. Y. Srinivasan, Haiyang Zhang, Stephen Hemminger

Recently introduced helpers take pointers to uuid_{be|le} instead of
reference.

Using them makes code less ugly.

Cc: "K. Y. Srinivasan" <kys@microsoft.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Cc: Stephen Hemminger <sthemmin@microsoft.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/hv/channel_mgmt.c | 10 +++++-----
 drivers/hv/vmbus_drv.c    |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index 735f9363f2e4..01570c50ed04 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -176,7 +176,7 @@ static bool is_unsupported_vmbus_devs(const uuid_le *guid)
 	int i;
 
 	for (i = 0; i < ARRAY_SIZE(vmbus_unsupported_devs); i++)
-		if (!uuid_le_cmp(*guid, vmbus_unsupported_devs[i].guid))
+		if (!uuid_le_cmp_p(guid, vmbus_unsupported_devs[i].guid))
 			return true;
 	return false;
 }
@@ -190,7 +190,7 @@ static u16 hv_get_dev_type(const struct vmbus_channel *channel)
 		return HV_UNKNOWN;
 
 	for (i = HV_IDE; i < HV_UNKNOWN; i++) {
-		if (!uuid_le_cmp(*guid, vmbus_devs[i].guid))
+		if (!uuid_le_cmp_p(guid, vmbus_devs[i].guid))
 			return i;
 	}
 	pr_info("Unknown GUID: %pUl\n", guid);
@@ -456,9 +456,9 @@ static void vmbus_process_offer(struct vmbus_channel *newchannel)
 
 	list_for_each_entry(channel, &vmbus_connection.chn_list, listentry) {
 		if (!uuid_le_cmp(channel->offermsg.offer.if_type,
-			newchannel->offermsg.offer.if_type) &&
-			!uuid_le_cmp(channel->offermsg.offer.if_instance,
-				newchannel->offermsg.offer.if_instance)) {
+				 newchannel->offermsg.offer.if_type) &&
+		    !uuid_le_cmp(channel->offermsg.offer.if_instance,
+				 newchannel->offermsg.offer.if_instance)) {
 			fnew = false;
 			break;
 		}
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 0087b49095eb..b41a2be778f6 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -557,7 +557,7 @@ static const struct hv_vmbus_device_id *hv_vmbus_get_id(struct hv_driver *drv,
 	/* Look at the dynamic ids first, before the static ones */
 	spin_lock(&drv->dynids.lock);
 	list_for_each_entry(dynid, &drv->dynids.list, node) {
-		if (!uuid_le_cmp(dynid->id.guid, *guid)) {
+		if (!uuid_le_cmp_p(guid, dynid->id.guid)) {
 			id = &dynid->id;
 			break;
 		}
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v1 6/8] mei: Use recently introduced uuid_le_cmp_p{p}() helpers
  2017-04-21 14:46 [PATCH v1 1/8] lib/uuid: Introduce uuid_{be|le}_cmp_p{p}() helpers Andy Shevchenko
                   ` (3 preceding siblings ...)
  2017-04-21 14:46 ` [PATCH v1 5/8] vmbus: Use recently introduced uuid_le_cmp_p{p}() helpers Andy Shevchenko
@ 2017-04-21 14:46 ` Andy Shevchenko
  2017-04-21 14:46 ` [PATCH v1 7/8] efi: " Andy Shevchenko
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2017-04-21 14:46 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel, Arnd Bergmann, Mika Westerberg,
	alsa-devel, linux-input, kvm, devel, linux-efi, linux-acpi
  Cc: Andy Shevchenko, Tomas Winkler

Recently introduced helpers take pointers to uuid_{be|le} instead of
reference.

Using them makes code less ugly.

Cc: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/misc/mei/bus-fixup.c | 2 +-
 drivers/misc/mei/bus.c       | 2 +-
 drivers/misc/mei/client.c    | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/misc/mei/bus-fixup.c b/drivers/misc/mei/bus-fixup.c
index 0208c4b027c5..de0fcd98d162 100644
--- a/drivers/misc/mei/bus-fixup.c
+++ b/drivers/misc/mei/bus-fixup.c
@@ -416,7 +416,7 @@ void mei_cl_bus_dev_fixup(struct mei_cl_device *cldev)
 
 		f = &mei_fixups[i];
 		if (uuid_le_cmp(f->uuid, MEI_UUID_ANY) == 0 ||
-		    uuid_le_cmp(f->uuid, *uuid) == 0)
+		    uuid_le_cmp_p(uuid, f->uuid) == 0)
 			f->hook(cldev);
 	}
 }
diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c
index d1928fdd0f43..e15549f71891 100644
--- a/drivers/misc/mei/bus.c
+++ b/drivers/misc/mei/bus.c
@@ -615,7 +615,7 @@ struct mei_cl_device_id *mei_cl_device_find(struct mei_cl_device *cldev,
 
 	id = cldrv->id_table;
 	while (uuid_le_cmp(NULL_UUID_LE, id->uuid)) {
-		if (!uuid_le_cmp(*uuid, id->uuid)) {
+		if (!uuid_le_cmp_p(uuid, id->uuid)) {
 			match = true;
 
 			if (cldev->name[0])
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
index be64969d986a..590accb369bd 100644
--- a/drivers/misc/mei/client.c
+++ b/drivers/misc/mei/client.c
@@ -148,7 +148,7 @@ static struct mei_me_client *__mei_me_cl_by_uuid(struct mei_device *dev,
 
 	list_for_each_entry(me_cl, &dev->me_clients, list) {
 		pn = &me_cl->props.protocol_name;
-		if (uuid_le_cmp(*uuid, *pn) == 0)
+		if (uuid_le_cmp_pp(uuid, pn) == 0)
 			return mei_me_cl_get(me_cl);
 	}
 
@@ -228,7 +228,7 @@ static struct mei_me_client *__mei_me_cl_by_uuid_id(struct mei_device *dev,
 
 	list_for_each_entry(me_cl, &dev->me_clients, list) {
 		pn = &me_cl->props.protocol_name;
-		if (uuid_le_cmp(*uuid, *pn) == 0 &&
+		if (uuid_le_cmp_pp(uuid, pn) == 0 &&
 		    me_cl->client_id == client_id)
 			return mei_me_cl_get(me_cl);
 	}
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v1 7/8] efi: Use recently introduced uuid_le_cmp_p{p}() helpers
  2017-04-21 14:46 [PATCH v1 1/8] lib/uuid: Introduce uuid_{be|le}_cmp_p{p}() helpers Andy Shevchenko
                   ` (4 preceding siblings ...)
  2017-04-21 14:46 ` [PATCH v1 6/8] mei: " Andy Shevchenko
@ 2017-04-21 14:46 ` Andy Shevchenko
  2017-04-21 14:46 ` [PATCH v1 8/8] ACPI: " Andy Shevchenko
  2017-04-23 10:29 ` [PATCH v1 1/8] lib/uuid: Introduce uuid_{be|le}_cmp_p{p}() helpers Winkler, Tomas
  7 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2017-04-21 14:46 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel, Arnd Bergmann, Mika Westerberg,
	alsa-devel, linux-input, kvm, devel, linux-efi, linux-acpi
  Cc: Andy Shevchenko, Matt Fleming, Ard Biesheuvel

Recently introduced helpers take pointers to uuid_{be|le} instead of
reference.

Using them makes code less ugly.

Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/firmware/efi/cper.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/firmware/efi/cper.c b/drivers/firmware/efi/cper.c
index d42537425438..7735b0f0ea90 100644
--- a/drivers/firmware/efi/cper.c
+++ b/drivers/firmware/efi/cper.c
@@ -402,14 +402,14 @@ static void cper_estatus_print_section(
 		printk("%s""fru_text: %.20s\n", pfx, gdata->fru_text);
 
 	snprintf(newpfx, sizeof(newpfx), "%s%s", pfx, INDENT_SP);
-	if (!uuid_le_cmp(*sec_type, CPER_SEC_PROC_GENERIC)) {
+	if (!uuid_le_cmp_p(sec_type, CPER_SEC_PROC_GENERIC)) {
 		struct cper_sec_proc_generic *proc_err = (void *)(gdata + 1);
 		printk("%s""section_type: general processor error\n", newpfx);
 		if (gdata->error_data_length >= sizeof(*proc_err))
 			cper_print_proc_generic(newpfx, proc_err);
 		else
 			goto err_section_too_small;
-	} else if (!uuid_le_cmp(*sec_type, CPER_SEC_PLATFORM_MEM)) {
+	} else if (!uuid_le_cmp_p(sec_type, CPER_SEC_PLATFORM_MEM)) {
 		struct cper_sec_mem_err *mem_err = (void *)(gdata + 1);
 		printk("%s""section_type: memory error\n", newpfx);
 		if (gdata->error_data_length >=
@@ -418,7 +418,7 @@ static void cper_estatus_print_section(
 				       gdata->error_data_length);
 		else
 			goto err_section_too_small;
-	} else if (!uuid_le_cmp(*sec_type, CPER_SEC_PCIE)) {
+	} else if (!uuid_le_cmp_p(sec_type, CPER_SEC_PCIE)) {
 		struct cper_sec_pcie *pcie = (void *)(gdata + 1);
 		printk("%s""section_type: PCIe error\n", newpfx);
 		if (gdata->error_data_length >= sizeof(*pcie))
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v1 8/8] ACPI: Use recently introduced uuid_le_cmp_p{p}() helpers
  2017-04-21 14:46 [PATCH v1 1/8] lib/uuid: Introduce uuid_{be|le}_cmp_p{p}() helpers Andy Shevchenko
                   ` (5 preceding siblings ...)
  2017-04-21 14:46 ` [PATCH v1 7/8] efi: " Andy Shevchenko
@ 2017-04-21 14:46 ` Andy Shevchenko
  2017-04-21 21:22   ` Rafael J. Wysocki
  2017-04-23 10:29 ` [PATCH v1 1/8] lib/uuid: Introduce uuid_{be|le}_cmp_p{p}() helpers Winkler, Tomas
  7 siblings, 1 reply; 19+ messages in thread
From: Andy Shevchenko @ 2017-04-21 14:46 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel, Arnd Bergmann, Mika Westerberg,
	alsa-devel, linux-input, kvm, devel, linux-efi, linux-acpi
  Cc: Andy Shevchenko, Rafael J. Wysocki

Recently introduced helpers take pointers to uuid_{be|le} instead of
reference.

Using them makes code less ugly.

Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/acpi/acpi_extlog.c | 2 +-
 drivers/acpi/apei/ghes.c   | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/acpi_extlog.c b/drivers/acpi/acpi_extlog.c
index 502ea4dc2080..45e299aefda7 100644
--- a/drivers/acpi/acpi_extlog.c
+++ b/drivers/acpi/acpi_extlog.c
@@ -169,7 +169,7 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,
 	if (gdata->validation_bits & CPER_SEC_VALID_FRU_TEXT)
 		fru_text = gdata->fru_text;
 	sec_type = (uuid_le *)gdata->section_type;
-	if (!uuid_le_cmp(*sec_type, CPER_SEC_PLATFORM_MEM)) {
+	if (!uuid_le_cmp_p(sec_type, CPER_SEC_PLATFORM_MEM)) {
 		struct cper_sec_mem_err *mem = (void *)(gdata + 1);
 		if (gdata->error_data_length >= sizeof(*mem))
 			trace_extlog_mem_event(mem, err_seq, fru_id, fru_text,
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index d0855c09f32f..f2a7ee26d45f 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -431,12 +431,13 @@ static void ghes_do_proc(struct ghes *ghes,
 {
 	int sev, sec_sev;
 	struct acpi_hest_generic_data *gdata;
+	uuid_le *sec_type;
 
 	sev = ghes_severity(estatus->error_severity);
 	apei_estatus_for_each_section(estatus, gdata) {
+		sec_type = (uuid_le *)gdata->section_type;
 		sec_sev = ghes_severity(gdata->error_severity);
-		if (!uuid_le_cmp(*(uuid_le *)gdata->section_type,
-				 CPER_SEC_PLATFORM_MEM)) {
+		if (!uuid_le_cmp_p(sec_type, CPER_SEC_PLATFORM_MEM)) {
 			struct cper_sec_mem_err *mem_err;
 			mem_err = (struct cper_sec_mem_err *)(gdata+1);
 			ghes_edac_report_mem_error(ghes, sev, mem_err);
@@ -445,8 +446,7 @@ static void ghes_do_proc(struct ghes *ghes,
 			ghes_handle_memory_failure(gdata, sev);
 		}
 #ifdef CONFIG_ACPI_APEI_PCIEAER
-		else if (!uuid_le_cmp(*(uuid_le *)gdata->section_type,
-				      CPER_SEC_PCIE)) {
+		else if (!uuid_le_cmp_p(sec_type, CPER_SEC_PCIE)) {
 			struct cper_sec_pcie *pcie_err;
 			pcie_err = (struct cper_sec_pcie *)(gdata+1);
 			if (sev == GHES_SEV_RECOVERABLE &&
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH v1 8/8] ACPI: Use recently introduced uuid_le_cmp_p{p}() helpers
  2017-04-21 14:46 ` [PATCH v1 8/8] ACPI: " Andy Shevchenko
@ 2017-04-21 21:22   ` Rafael J. Wysocki
  2017-04-27 12:46     ` Borislav Petkov
  0 siblings, 1 reply; 19+ messages in thread
From: Rafael J. Wysocki @ 2017-04-21 21:22 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Andrew Morton, linux-kernel, Arnd Bergmann, Mika Westerberg,
	alsa-devel, linux-input, kvm, devel, linux-efi, linux-acpi,
	Borislav Petkov

On Friday, April 21, 2017 05:46:45 PM Andy Shevchenko wrote:
> Recently introduced helpers take pointers to uuid_{be|le} instead of
> reference.
> 
> Using them makes code less ugly.
> 
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/acpi/acpi_extlog.c | 2 +-
>  drivers/acpi/apei/ghes.c   | 8 ++++----
>  2 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/acpi/acpi_extlog.c b/drivers/acpi/acpi_extlog.c
> index 502ea4dc2080..45e299aefda7 100644
> --- a/drivers/acpi/acpi_extlog.c
> +++ b/drivers/acpi/acpi_extlog.c
> @@ -169,7 +169,7 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,
>  	if (gdata->validation_bits & CPER_SEC_VALID_FRU_TEXT)
>  		fru_text = gdata->fru_text;
>  	sec_type = (uuid_le *)gdata->section_type;
> -	if (!uuid_le_cmp(*sec_type, CPER_SEC_PLATFORM_MEM)) {
> +	if (!uuid_le_cmp_p(sec_type, CPER_SEC_PLATFORM_MEM)) {
>  		struct cper_sec_mem_err *mem = (void *)(gdata + 1);
>  		if (gdata->error_data_length >= sizeof(*mem))
>  			trace_extlog_mem_event(mem, err_seq, fru_id, fru_text,

ACK for this one.

> diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
> index d0855c09f32f..f2a7ee26d45f 100644
> --- a/drivers/acpi/apei/ghes.c
> +++ b/drivers/acpi/apei/ghes.c
> @@ -431,12 +431,13 @@ static void ghes_do_proc(struct ghes *ghes,
>  {
>  	int sev, sec_sev;
>  	struct acpi_hest_generic_data *gdata;
> +	uuid_le *sec_type;
>  
>  	sev = ghes_severity(estatus->error_severity);
>  	apei_estatus_for_each_section(estatus, gdata) {
> +		sec_type = (uuid_le *)gdata->section_type;
>  		sec_sev = ghes_severity(gdata->error_severity);
> -		if (!uuid_le_cmp(*(uuid_le *)gdata->section_type,
> -				 CPER_SEC_PLATFORM_MEM)) {
> +		if (!uuid_le_cmp_p(sec_type, CPER_SEC_PLATFORM_MEM)) {
>  			struct cper_sec_mem_err *mem_err;
>  			mem_err = (struct cper_sec_mem_err *)(gdata+1);
>  			ghes_edac_report_mem_error(ghes, sev, mem_err);
> @@ -445,8 +446,7 @@ static void ghes_do_proc(struct ghes *ghes,
>  			ghes_handle_memory_failure(gdata, sev);
>  		}
>  #ifdef CONFIG_ACPI_APEI_PCIEAER
> -		else if (!uuid_le_cmp(*(uuid_le *)gdata->section_type,
> -				      CPER_SEC_PCIE)) {
> +		else if (!uuid_le_cmp_p(sec_type, CPER_SEC_PCIE)) {
>  			struct cper_sec_pcie *pcie_err;
>  			pcie_err = (struct cper_sec_pcie *)(gdata+1);
>  			if (sev == GHES_SEV_RECOVERABLE &&
> 

But this one is for Boris.

Thanks,
Rafael

^ permalink raw reply	[flat|nested] 19+ messages in thread

* RE: [PATCH v1 1/8] lib/uuid: Introduce uuid_{be|le}_cmp_p{p}() helpers
  2017-04-21 14:46 [PATCH v1 1/8] lib/uuid: Introduce uuid_{be|le}_cmp_p{p}() helpers Andy Shevchenko
                   ` (6 preceding siblings ...)
  2017-04-21 14:46 ` [PATCH v1 8/8] ACPI: " Andy Shevchenko
@ 2017-04-23 10:29 ` Winkler, Tomas
  2017-04-23 12:42   ` Andy Shevchenko
  2017-04-24 10:44   ` Lukas Wunner
  7 siblings, 2 replies; 19+ messages in thread
From: Winkler, Tomas @ 2017-04-23 10:29 UTC (permalink / raw)
  To: Andy Shevchenko, Andrew Morton, linux-kernel, Arnd Bergmann,
	Mika Westerberg, alsa-devel, linux-input, kvm, devel, linux-efi,
	linux-acpi
  Cc: Liam Girdwood, Mark Brown, Koul, Vinod, Srinivas Pandruvada,
	Benjamin Tissoires, Kirti Wankhede, Alex Williamson,
	K. Y. Srinivasan, Haiyang Zhang, Stephen Hemminger, Matt Fleming,
	Ard Biesheuvel, Rafael J. Wysocki

> New helpers take pointers to uuid_{be|le} as parameters.
> 
> When using them on a raw data we don't need to do an ugly dereference and,
> in some cases, a type casting.
> 
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Liam Girdwood <lgirdwood@gmail.com>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Vinod Koul <vinod.koul@intel.com>
> Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
> Cc: Kirti Wankhede <kwankhede@nvidia.com>
> Cc: Alex Williamson <alex.williamson@redhat.com>
> Cc: "K. Y. Srinivasan" <kys@microsoft.com>
> Cc: Haiyang Zhang <haiyangz@microsoft.com>
> Cc: Stephen Hemminger <sthemmin@microsoft.com>
> Cc: Tomas Winkler <tomas.winkler@intel.com>
> Cc: Matt Fleming <matt@codeblueprint.co.uk>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  include/linux/uuid.h | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/include/linux/uuid.h b/include/linux/uuid.h index
> 4dff73a89758..45312cb5ac65 100644
> --- a/include/linux/uuid.h
> +++ b/include/linux/uuid.h
> @@ -58,6 +58,26 @@ static inline int uuid_be_cmp(const uuid_be u1, const
> uuid_be u2)
>  	return memcmp(&u1, &u2, sizeof(uuid_be));  }
> 
> +static inline int uuid_le_cmp_p(const uuid_le *pu1, const uuid_le u2) {
> +	return memcmp(pu1, &u2, sizeof(uuid_le)); }
> +
> +static inline int uuid_be_cmp_p(const uuid_be *pu1, const uuid_be u2) {
> +	return memcmp(pu1, &u2, sizeof(uuid_be)); }
> +
> +static inline int uuid_le_cmp_pp(const uuid_le *pu1, const uuid_le
> +*pu2) {
> +	return memcmp(pu1, pu2, sizeof(uuid_le)); }
> +
> +static inline int uuid_be_cmp_pp(const uuid_be *pu1, const uuid_be
> +*pu2) {
> +	return memcmp(pu1, pu2, sizeof(uuid_be)); }
> +
>  void generate_random_uuid(unsigned char uuid[16]);
> 
>  extern void uuid_le_gen(uuid_le *u);

I think this going overboard, the _pp types  are just enough. 
Tomas

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v1 1/8] lib/uuid: Introduce uuid_{be|le}_cmp_p{p}() helpers
  2017-04-23 10:29 ` [PATCH v1 1/8] lib/uuid: Introduce uuid_{be|le}_cmp_p{p}() helpers Winkler, Tomas
@ 2017-04-23 12:42   ` Andy Shevchenko
  2017-04-23 20:20     ` Winkler, Tomas
  2017-04-24 10:44   ` Lukas Wunner
  1 sibling, 1 reply; 19+ messages in thread
From: Andy Shevchenko @ 2017-04-23 12:42 UTC (permalink / raw)
  To: Winkler, Tomas
  Cc: Andy Shevchenko, Andrew Morton, linux-kernel, Arnd Bergmann,
	Mika Westerberg, alsa-devel, linux-input, kvm, devel, linux-efi,
	linux-acpi, Liam Girdwood, Mark Brown, Koul, Vinod,
	Srinivas Pandruvada, Benjamin Tissoires, Kirti Wankhede,
	Alex Williamson, K. Y. Srinivasan, Haiyang Zhang,
	Stephen Hemminger, Matt Fleming, Ard Biesheuvel,
	Rafael J. Wysocki

On Sun, Apr 23, 2017 at 1:29 PM, Winkler, Tomas <tomas.winkler@intel.com> wrote:
>> New helpers take pointers to uuid_{be|le} as parameters.
>>
>> When using them on a raw data we don't need to do an ugly dereference and,
>> in some cases, a type casting.

> I think this going overboard, the _pp types  are just enough.
I looked at existing users and there are cases like
#define XXX_UUID UUID_...(a, b, c, ...)

uuid_.*_cmp(value, XXX_UUID)

For _pp variant if would be _cmp_pp(value, &XXX_UUID) which is
slightly worse than for _p variant.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v1 1/8] lib/uuid: Introduce uuid_{be|le}_cmp_p{p}() helpers
  2017-04-23 12:42   ` Andy Shevchenko
@ 2017-04-23 20:20     ` Winkler, Tomas
  2017-04-24  8:53       ` Andy Shevchenko
  0 siblings, 1 reply; 19+ messages in thread
From: Winkler, Tomas @ 2017-04-23 20:20 UTC (permalink / raw)
  To: andy.shevchenko
  Cc: kvm, linux-kernel, alex.williamson, Koul, Vinod, devel,
	kwankhede, kys, ard.biesheuvel, matt, broonie, akpm, rjw,
	sthemmin, srinivas.pandruvada, mika.westerberg, linux-efi,
	lgirdwood, linux-input, benjamin.tissoires, arnd,
	andriy.shevchenko, alsa-devel, haiyangz, linux-acpi

On Sun, 2017-04-23 at 15:42 +0300, Andy Shevchenko wrote:
> On Sun, Apr 23, 2017 at 1:29 PM, Winkler, Tomas <tomas.winkler@intel.
> com> wrote:
> > > New helpers take pointers to uuid_{be|le} as parameters.
> > > 
> > > When using them on a raw data we don't need to do an ugly
> > > dereference and,
> > > in some cases, a type casting.
> > I think this going overboard, the _pp types  are just enough.
> 
> I looked at existing users and there are cases like
> #define XXX_UUID UUID_...(a, b, c, ...)
> 
> uuid_.*_cmp(value, XXX_UUID)
> 
> For _pp variant if would be _cmp_pp(value, &XXX_UUID) which is
> slightly worse than for _p variant.


Maybe it's worth to actually replace the defines with variables than to
create an interface with all the permutations.

Tomas

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v1 2/8] ASoC: Intel: Skylake: Use recently introduced uuid_le_cmp_p{p}()
  2017-04-21 14:46 ` [PATCH v1 2/8] ASoC: Intel: Skylake: Use recently introduced uuid_le_cmp_p{p}() Andy Shevchenko
@ 2017-04-24  4:51   ` Vinod Koul
  2017-04-24  8:50     ` Andy Shevchenko
  0 siblings, 1 reply; 19+ messages in thread
From: Vinod Koul @ 2017-04-24  4:51 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Andrew Morton, linux-kernel, Arnd Bergmann, Mika Westerberg,
	alsa-devel, linux-input, kvm, devel, linux-efi, linux-acpi,
	Liam Girdwood, Mark Brown

On Fri, Apr 21, 2017 at 05:46:39PM +0300, Andy Shevchenko wrote:
> Recently introduced helpers take pointers to uuid_{be|le} instead of
> reference.

Are they in linus's tree, if not it introduces dependency, so we might want
to defer after merge window

> 
> Using them makes code less ugly.

How so..?

> 
> Cc: Liam Girdwood <lgirdwood@gmail.com>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Vinod Koul <vinod.koul@intel.com>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  sound/soc/intel/skylake/skl-pcm.c       | 2 +-
>  sound/soc/intel/skylake/skl-sst-utils.c | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c
> index 600faad19bd4..4bf171985872 100644
> --- a/sound/soc/intel/skylake/skl-pcm.c
> +++ b/sound/soc/intel/skylake/skl-pcm.c
> @@ -1207,7 +1207,7 @@ static int skl_get_module_info(struct skl *skl, struct skl_module_cfg *mconfig)
>  	}
>  
>  	list_for_each_entry(module, &ctx->uuid_list, list) {
> -		if (uuid_le_cmp(*uuid_mod, module->uuid) == 0) {
> +		if (uuid_le_cmp_p(uuid_mod, module->uuid) == 0) {
>  			mconfig->id.module_id = module->id;
>  			mconfig->is_loadable = module->is_loadable;
>  			return 0;
> diff --git a/sound/soc/intel/skylake/skl-sst-utils.c b/sound/soc/intel/skylake/skl-sst-utils.c
> index 6d5bff04bf65..67288580c743 100644
> --- a/sound/soc/intel/skylake/skl-sst-utils.c
> +++ b/sound/soc/intel/skylake/skl-sst-utils.c
> @@ -189,7 +189,7 @@ int skl_get_pvt_id(struct skl_sst *ctx, uuid_le *uuid_mod, int instance_id)
>  	int pvt_id;
>  
>  	list_for_each_entry(module, &ctx->uuid_list, list) {
> -		if (uuid_le_cmp(*uuid_mod, module->uuid) == 0) {
> +		if (uuid_le_cmp_p(uuid_mod, module->uuid) == 0) {
>  
>  			pvt_id = skl_pvtid_128(module);
>  			if (pvt_id >= 0) {
> @@ -218,7 +218,7 @@ int skl_put_pvt_id(struct skl_sst *ctx, uuid_le *uuid_mod, int *pvt_id)
>  	struct uuid_module *module;
>  
>  	list_for_each_entry(module, &ctx->uuid_list, list) {
> -		if (uuid_le_cmp(*uuid_mod, module->uuid) == 0) {
> +		if (uuid_le_cmp_p(uuid_mod, module->uuid) == 0) {
>  
>  			if (*pvt_id != 0)
>  				i = (*pvt_id) / 64;
> -- 
> 2.11.0
> 

-- 
~Vinod

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v1 2/8] ASoC: Intel: Skylake: Use recently introduced uuid_le_cmp_p{p}()
  2017-04-24  4:51   ` Vinod Koul
@ 2017-04-24  8:50     ` Andy Shevchenko
  0 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2017-04-24  8:50 UTC (permalink / raw)
  To: Vinod Koul
  Cc: Andrew Morton, linux-kernel, Arnd Bergmann, Mika Westerberg,
	alsa-devel, linux-input, kvm, devel, linux-efi, linux-acpi,
	Liam Girdwood, Mark Brown

On Mon, 2017-04-24 at 10:21 +0530, Vinod Koul wrote:
> On Fri, Apr 21, 2017 at 05:46:39PM +0300, Andy Shevchenko wrote:
> > Recently introduced helpers take pointers to uuid_{be|le} instead of
> > reference.
> 
> Are they in linus's tree, if not it introduces dependency, so we might
> want
> to defer after merge window

You are Cc'ed to patch 1 which brings them.

> > 
> > Using them makes code less ugly.
> 
> How so..?

Consider below example.

- if (uuid_le_cmp(*uuid_mod, module->uuid) == 0) {
+ if (uuid_le_cmp_p(uuid_mod, module->uuid) == 0) {

There are two points:
1) caller don't need to dereference pointers to its values;
2) this allow compiler to not copy the data (though clever compiler
might optimize that).

> 
> > 
> > Cc: Liam Girdwood <lgirdwood@gmail.com>
> > Cc: Mark Brown <broonie@kernel.org>
> > Cc: Vinod Koul <vinod.koul@intel.com>
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > ---
> >  sound/soc/intel/skylake/skl-pcm.c       | 2 +-
> >  sound/soc/intel/skylake/skl-sst-utils.c | 4 ++--
> >  2 files changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/sound/soc/intel/skylake/skl-pcm.c
> > b/sound/soc/intel/skylake/skl-pcm.c
> > index 600faad19bd4..4bf171985872 100644
> > --- a/sound/soc/intel/skylake/skl-pcm.c
> > +++ b/sound/soc/intel/skylake/skl-pcm.c
> > @@ -1207,7 +1207,7 @@ static int skl_get_module_info(struct skl
> > *skl, struct skl_module_cfg *mconfig)
> >  	}
> >  
> >  	list_for_each_entry(module, &ctx->uuid_list, list) {
> > -		if (uuid_le_cmp(*uuid_mod, module->uuid) == 0) {
> > +		if (uuid_le_cmp_p(uuid_mod, module->uuid) == 0) {
> >  			mconfig->id.module_id = module->id;
> >  			mconfig->is_loadable = module->is_loadable;
> >  			return 0;
> > diff --git a/sound/soc/intel/skylake/skl-sst-utils.c
> > b/sound/soc/intel/skylake/skl-sst-utils.c
> > index 6d5bff04bf65..67288580c743 100644
> > --- a/sound/soc/intel/skylake/skl-sst-utils.c
> > +++ b/sound/soc/intel/skylake/skl-sst-utils.c
> > @@ -189,7 +189,7 @@ int skl_get_pvt_id(struct skl_sst *ctx, uuid_le
> > *uuid_mod, int instance_id)
> >  	int pvt_id;
> >  
> >  	list_for_each_entry(module, &ctx->uuid_list, list) {
> > -		if (uuid_le_cmp(*uuid_mod, module->uuid) == 0) {
> > +		if (uuid_le_cmp_p(uuid_mod, module->uuid) == 0) {
> >  
> >  			pvt_id = skl_pvtid_128(module);
> >  			if (pvt_id >= 0) {
> > @@ -218,7 +218,7 @@ int skl_put_pvt_id(struct skl_sst *ctx, uuid_le
> > *uuid_mod, int *pvt_id)
> >  	struct uuid_module *module;
> >  
> >  	list_for_each_entry(module, &ctx->uuid_list, list) {
> > -		if (uuid_le_cmp(*uuid_mod, module->uuid) == 0) {
> > +		if (uuid_le_cmp_p(uuid_mod, module->uuid) == 0) {
> >  
> >  			if (*pvt_id != 0)
> >  				i = (*pvt_id) / 64;
> > -- 
> > 2.11.0
> > 
> 
> 

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v1 1/8] lib/uuid: Introduce uuid_{be|le}_cmp_p{p}() helpers
  2017-04-23 20:20     ` Winkler, Tomas
@ 2017-04-24  8:53       ` Andy Shevchenko
  0 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2017-04-24  8:53 UTC (permalink / raw)
  To: Winkler, Tomas, andy.shevchenko
  Cc: kvm, linux-kernel, alex.williamson, Koul, Vinod, devel,
	kwankhede, kys, ard.biesheuvel, matt, broonie, akpm, rjw,
	sthemmin, srinivas.pandruvada, mika.westerberg, linux-efi,
	lgirdwood, linux-input, benjamin.tissoires, arnd, alsa-devel,
	haiyangz, linux-acpi

On Sun, 2017-04-23 at 20:20 +0000, Winkler, Tomas wrote:
> On Sun, 2017-04-23 at 15:42 +0300, Andy Shevchenko wrote:
> > On Sun, Apr 23, 2017 at 1:29 PM, Winkler, Tomas <tomas.winkler@intel
> > .
> > com> wrote:
> > > > New helpers take pointers to uuid_{be|le} as parameters.
> > > > 
> > > > When using them on a raw data we don't need to do an ugly
> > > > dereference and,
> > > > in some cases, a type casting.
> > > 
> > > I think this going overboard, the _pp types  are just enough.
> > 
> > I looked at existing users and there are cases like
> > #define XXX_UUID UUID_...(a, b, c, ...)
> > 
> > uuid_.*_cmp(value, XXX_UUID)
> > 
> > For _pp variant if would be _cmp_pp(value, &XXX_UUID) which is
> > slightly worse than for _p variant.
> 
> 
> Maybe it's worth to actually replace the defines with variables than
> to
> create an interface with all the permutations.

Maybe. I didn't estimate the number of users that would be in a scope.

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v1 1/8] lib/uuid: Introduce uuid_{be|le}_cmp_p{p}() helpers
  2017-04-23 10:29 ` [PATCH v1 1/8] lib/uuid: Introduce uuid_{be|le}_cmp_p{p}() helpers Winkler, Tomas
  2017-04-23 12:42   ` Andy Shevchenko
@ 2017-04-24 10:44   ` Lukas Wunner
  1 sibling, 0 replies; 19+ messages in thread
From: Lukas Wunner @ 2017-04-24 10:44 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Winkler, Tomas, Andrew Morton, linux-kernel, Arnd Bergmann,
	Mika Westerberg, alsa-devel, linux-input, kvm, devel, linux-efi,
	linux-acpi, Liam Girdwood, Mark Brown, Koul, Vinod,
	Srinivas Pandruvada, Benjamin Tissoires, Kirti Wankhede,
	Alex Williamson, K. Y. Srinivasan, Haiyang Zhang,
	Stephen Hemminger, Matt Fleming, Ard Biesheuvel,
	Rafael J. Wysocki

> New helpers take pointers to uuid_{be|le} as parameters.
> 
> When using them on a raw data we don't need to do an ugly dereference and,
> in some cases, a type casting.
> 
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Liam Girdwood <lgirdwood@gmail.com>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Vinod Koul <vinod.koul@intel.com>
> Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
> Cc: Kirti Wankhede <kwankhede@nvidia.com>
> Cc: Alex Williamson <alex.williamson@redhat.com>
> Cc: "K. Y. Srinivasan" <kys@microsoft.com>
> Cc: Haiyang Zhang <haiyangz@microsoft.com>
> Cc: Stephen Hemminger <sthemmin@microsoft.com>
> Cc: Tomas Winkler <tomas.winkler@intel.com>
> Cc: Matt Fleming <matt@codeblueprint.co.uk>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  include/linux/uuid.h | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/include/linux/uuid.h b/include/linux/uuid.h index
> 4dff73a89758..45312cb5ac65 100644
> --- a/include/linux/uuid.h
> +++ b/include/linux/uuid.h
> @@ -58,6 +58,26 @@ static inline int uuid_be_cmp(const uuid_be u1, const
> uuid_be u2)
>  	return memcmp(&u1, &u2, sizeof(uuid_be));  }
> 
> +static inline int uuid_le_cmp_p(const uuid_le *pu1, const uuid_le u2) {
> +	return memcmp(pu1, &u2, sizeof(uuid_le)); }
> +
> +static inline int uuid_be_cmp_p(const uuid_be *pu1, const uuid_be u2) {
> +	return memcmp(pu1, &u2, sizeof(uuid_be)); }
> +
> +static inline int uuid_le_cmp_pp(const uuid_le *pu1, const uuid_le
> +*pu2) {
> +	return memcmp(pu1, pu2, sizeof(uuid_le)); }
> +
> +static inline int uuid_be_cmp_pp(const uuid_be *pu1, const uuid_be
> +*pu2) {
> +	return memcmp(pu1, pu2, sizeof(uuid_be)); }
> +
>  void generate_random_uuid(unsigned char uuid[16]);
> 
>  extern void uuid_le_gen(uuid_le *u);

There's a bug in gcc wherein constant compound literals are generated
on the stack at runtime, rather than stored in rodata.  The bug occurs
if the compound literal is passed by reference.  It does not manifest
itself when passing by value:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68725

Hence this patch is unfortunately counterproductive if the UUIDs are
declared const.

FWIW I've posted a series back in January to constify UUIDs as much as
possible, but I got some objections and lacked the time so far to
address them.  In fact I'm thinking that gcc needs to be fixed first,
then we can focus on improving the kernel side of things:

https://www.spinics.net/lists/linux-efi/msg10093.html

Best regards,

Lukas

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v1 8/8] ACPI: Use recently introduced uuid_le_cmp_p{p}() helpers
  2017-04-21 21:22   ` Rafael J. Wysocki
@ 2017-04-27 12:46     ` Borislav Petkov
  2017-04-27 13:09       ` Andy Shevchenko
  0 siblings, 1 reply; 19+ messages in thread
From: Borislav Petkov @ 2017-04-27 12:46 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Andy Shevchenko, Andrew Morton, linux-kernel, Arnd Bergmann,
	Mika Westerberg, alsa-devel, linux-input, kvm, devel, linux-efi,
	linux-acpi

On Fri, Apr 21, 2017 at 11:22:31PM +0200, Rafael J. Wysocki wrote:
> >  #ifdef CONFIG_ACPI_APEI_PCIEAER
> > -		else if (!uuid_le_cmp(*(uuid_le *)gdata->section_type,
> > -				      CPER_SEC_PCIE)) {
> > +		else if (!uuid_le_cmp_p(sec_type, CPER_SEC_PCIE)) {
> >  			struct cper_sec_pcie *pcie_err;
> >  			pcie_err = (struct cper_sec_pcie *)(gdata+1);
> >  			if (sev == GHES_SEV_RECOVERABLE &&
> > 
> 
> But this one is for Boris.

I don't see anything wrong with it upon a brief inspection.

What could be improved here, though, is if the whole uuid_* types
handling be changed so that gcc doesn't generate yucky code. Because
here's what it does now, regardless of this patch:

        .file 16 "./include/linux/uuid.h"
        .loc 16 63 0
        leaq    16(%rsp), %rsi  #,
        movl    $16, %edx       #,
        movq    %r15, %rdi      # gdata,
        movb    $84, 16(%rsp)   #, MEM[(struct  *)&u2]
        movb    $-23, 17(%rsp)  #, MEM[(struct  *)&u2 + 1B]
        movb    $-107, 18(%rsp) #, MEM[(struct  *)&u2 + 2B]
        movb    $-39, 19(%rsp)  #, MEM[(struct  *)&u2 + 3B]
        movb    $-63, 20(%rsp)  #, MEM[(struct  *)&u2 + 4B]
        movb    $-69, 21(%rsp)  #, MEM[(struct  *)&u2 + 5B]
        movb    $15, 22(%rsp)   #, MEM[(struct  *)&u2 + 6B]
        movb    $67, 23(%rsp)   #, MEM[(struct  *)&u2 + 7B]
        movb    $-83, 24(%rsp)  #, MEM[(struct  *)&u2 + 8B]
        movb    $-111, 25(%rsp) #, MEM[(struct  *)&u2 + 9B]
        movb    $-76, 26(%rsp)  #, MEM[(struct  *)&u2 + 10B]
        movb    $77, 27(%rsp)   #, MEM[(struct  *)&u2 + 11B]
        movb    $-53, 28(%rsp)  #, MEM[(struct  *)&u2 + 12B]
        movb    $60, 29(%rsp)   #, MEM[(struct  *)&u2 + 13B]
        movb    $111, 30(%rsp)  #, MEM[(struct  *)&u2 + 14B]
        movb    $53, 31(%rsp)   #, MEM[(struct  *)&u2 + 15B]
        call    memcmp  #

So it is basically building that UUID byte by byte before calling
memcmp.

And I'm wondering if those 16-byte arrays could be replaced with

typedef struct {
        u64 a, b;
} u128;

from the crypto code.

And whether the code generated by gcc would look much saner. Because the
CPU can handle two qwords much better/faster than 16 u8s.

Anyway, in case someone feels bored...

-- 
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v1 8/8] ACPI: Use recently introduced uuid_le_cmp_p{p}() helpers
  2017-04-27 12:46     ` Borislav Petkov
@ 2017-04-27 13:09       ` Andy Shevchenko
  2017-04-27 15:00         ` Borislav Petkov
  0 siblings, 1 reply; 19+ messages in thread
From: Andy Shevchenko @ 2017-04-27 13:09 UTC (permalink / raw)
  To: Borislav Petkov, Rafael J. Wysocki, Lukas Wunner
  Cc: Andrew Morton, linux-kernel, Arnd Bergmann, Mika Westerberg,
	alsa-devel, linux-input, kvm, devel, linux-efi, linux-acpi

On Thu, 2017-04-27 at 14:46 +0200, Borislav Petkov wrote:
> On Fri, Apr 21, 2017 at 11:22:31PM +0200, Rafael J. Wysocki wrote:
> > >  #ifdef CONFIG_ACPI_APEI_PCIEAER
> > > -		else if (!uuid_le_cmp(*(uuid_le *)gdata-
> > > >section_type,
> > > -				      CPER_SEC_PCIE)) {
> > > +		else if (!uuid_le_cmp_p(sec_type, CPER_SEC_PCIE))
> > > {
> > >  			struct cper_sec_pcie *pcie_err;
> > >  			pcie_err = (struct cper_sec_pcie
> > > *)(gdata+1);
> > >  			if (sev == GHES_SEV_RECOVERABLE &&
> > > 
> > 
> > But this one is for Boris.
> 
> I don't see anything wrong with it upon a brief inspection.

Lukas pointed to this:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68725

> 
> What could be improved here, though, is if the whole uuid_* types
> handling be changed so that gcc doesn't generate yucky code. Because
> here's what it does now, regardless of this patch:
> 
>         .file 16 "./include/linux/uuid.h"
>         .loc 16 63 0
>         leaq    16(%rsp), %rsi  #,
>         movl    $16, %edx       #,
>         movq    %r15, %rdi      # gdata,
>         movb    $84, 16(%rsp)   #, MEM[(struct  *)&u2]
>         movb    $-23, 17(%rsp)  #, MEM[(struct  *)&u2 + 1B]
>         movb    $-107, 18(%rsp) #, MEM[(struct  *)&u2 + 2B]
>         movb    $-39, 19(%rsp)  #, MEM[(struct  *)&u2 + 3B]
>         movb    $-63, 20(%rsp)  #, MEM[(struct  *)&u2 + 4B]
>         movb    $-69, 21(%rsp)  #, MEM[(struct  *)&u2 + 5B]
>         movb    $15, 22(%rsp)   #, MEM[(struct  *)&u2 + 6B]
>         movb    $67, 23(%rsp)   #, MEM[(struct  *)&u2 + 7B]
>         movb    $-83, 24(%rsp)  #, MEM[(struct  *)&u2 + 8B]
>         movb    $-111, 25(%rsp) #, MEM[(struct  *)&u2 + 9B]
>         movb    $-76, 26(%rsp)  #, MEM[(struct  *)&u2 + 10B]
>         movb    $77, 27(%rsp)   #, MEM[(struct  *)&u2 + 11B]
>         movb    $-53, 28(%rsp)  #, MEM[(struct  *)&u2 + 12B]
>         movb    $60, 29(%rsp)   #, MEM[(struct  *)&u2 + 13B]
>         movb    $111, 30(%rsp)  #, MEM[(struct  *)&u2 + 14B]
>         movb    $53, 31(%rsp)   #, MEM[(struct  *)&u2 + 15B]
>         call    memcmp  #
> 
> So it is basically building that UUID byte by byte before calling
> memcmp.
> 
> And I'm wondering if those 16-byte arrays could be replaced with
> 
> typedef struct {
>         u64 a, b;
> } u128;
> 
> from the crypto code.
> 
> And whether the code generated by gcc would look much saner. Because
> the
> CPU can handle two qwords much better/faster than 16 u8s.
> 
> Anyway, in case someone feels bored...
> 
> -- 
> Regards/Gruss,
>     Boris.
> 
> SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton,
> HRB 21284 (AG Nürnberg)

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v1 8/8] ACPI: Use recently introduced uuid_le_cmp_p{p}() helpers
  2017-04-27 13:09       ` Andy Shevchenko
@ 2017-04-27 15:00         ` Borislav Petkov
  0 siblings, 0 replies; 19+ messages in thread
From: Borislav Petkov @ 2017-04-27 15:00 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Rafael J. Wysocki, Lukas Wunner, Andrew Morton, linux-kernel,
	Arnd Bergmann, Mika Westerberg, alsa-devel, linux-input, kvm,
	devel, linux-efi, linux-acpi

On Thu, Apr 27, 2017 at 04:09:56PM +0300, Andy Shevchenko wrote:
> Lukas pointed to this:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68725

Yap, the same thing.

Thanks.

-- 
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2017-04-27 15:00 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-21 14:46 [PATCH v1 1/8] lib/uuid: Introduce uuid_{be|le}_cmp_p{p}() helpers Andy Shevchenko
2017-04-21 14:46 ` [PATCH v1 2/8] ASoC: Intel: Skylake: Use recently introduced uuid_le_cmp_p{p}() Andy Shevchenko
2017-04-24  4:51   ` Vinod Koul
2017-04-24  8:50     ` Andy Shevchenko
2017-04-21 14:46 ` [PATCH v1 3/8] HID: intel_ish-hid: " Andy Shevchenko
2017-04-21 14:46 ` [PATCH v1 4/8] vfio-mdev: " Andy Shevchenko
2017-04-21 14:46 ` [PATCH v1 5/8] vmbus: Use recently introduced uuid_le_cmp_p{p}() helpers Andy Shevchenko
2017-04-21 14:46 ` [PATCH v1 6/8] mei: " Andy Shevchenko
2017-04-21 14:46 ` [PATCH v1 7/8] efi: " Andy Shevchenko
2017-04-21 14:46 ` [PATCH v1 8/8] ACPI: " Andy Shevchenko
2017-04-21 21:22   ` Rafael J. Wysocki
2017-04-27 12:46     ` Borislav Petkov
2017-04-27 13:09       ` Andy Shevchenko
2017-04-27 15:00         ` Borislav Petkov
2017-04-23 10:29 ` [PATCH v1 1/8] lib/uuid: Introduce uuid_{be|le}_cmp_p{p}() helpers Winkler, Tomas
2017-04-23 12:42   ` Andy Shevchenko
2017-04-23 20:20     ` Winkler, Tomas
2017-04-24  8:53       ` Andy Shevchenko
2017-04-24 10:44   ` Lukas Wunner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).