diff for duplicates of <20210729205013.GW8018@packtop> diff --git a/a/1.txt b/N1/1.txt index 7e773e1..16b134b 100644 --- a/a/1.txt +++ b/N1/1.txt @@ -11,12 +11,12 @@ On Thu, Jul 29, 2021 at 01:55:19PM CDT, Winiarska, Iwona wrote: >> > Signed-off-by: Iwona Winiarska <iwona.winiarska@intel.com> >> > Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> >> > --- ->> > drivers/peci/Makefile?? |?? 2 +- ->> > drivers/peci/core.c???? |? 13 ++++- ->> > drivers/peci/device.c?? | 111 ++++++++++++++++++++++++++++++++++++++++ ->> > drivers/peci/internal.h |? 15 ++++++ ->> > drivers/peci/request.c? |? 74 +++++++++++++++++++++++++++ ->> > drivers/peci/sysfs.c??? |? 34 ++++++++++++ +>> > drivers/peci/Makefile | 2 +- +>> > drivers/peci/core.c | 13 ++++- +>> > drivers/peci/device.c | 111 ++++++++++++++++++++++++++++++++++++++++ +>> > drivers/peci/internal.h | 15 ++++++ +>> > drivers/peci/request.c | 74 +++++++++++++++++++++++++++ +>> > drivers/peci/sysfs.c | 34 ++++++++++++ >> > 6 files changed, 246 insertions(+), 3 deletions(-) >> > create mode 100644 drivers/peci/device.c >> > create mode 100644 drivers/peci/request.c @@ -42,28 +42,28 @@ On Thu, Jul 29, 2021 at 01:55:19PM CDT, Winiarska, Iwona wrote: >> > >> > int peci_controller_scan_devices(struct peci_controller *controller) >> > { ->> > -???????/* Just a stub, no support for actual devices yet */ ->> > +???????int ret; ->> > +???????u8 addr; +>> > - /* Just a stub, no support for actual devices yet */ +>> > + int ret; +>> > + u8 addr; >> > + ->> > +???????for (addr = PECI_BASE_ADDR; addr < PECI_BASE_ADDR + +>> > + for (addr = PECI_BASE_ADDR; addr < PECI_BASE_ADDR + >> > PECI_DEVICE_NUM_MAX; addr++) { ->> > +???????????????ret = peci_device_create(controller, addr); ->> > +???????????????if (ret) ->> > +???????????????????????return ret; ->> > +???????} +>> > + ret = peci_device_create(controller, addr); +>> > + if (ret) +>> > + return ret; +>> > + } >> > + ->> > ????????return 0; +>> > return 0; >> > } >> > >> > @@ -106,7 +114,8 @@ EXPORT_SYMBOL_NS_GPL(peci_controller_add, PECI); >> > >> > static int _unregister(struct device *dev, void *dummy) >> > { ->> > -???????/* Just a stub, no support for actual devices yet */ ->> > +???????peci_device_destroy(to_peci_device(dev)); +>> > - /* Just a stub, no support for actual devices yet */ +>> > + peci_device_destroy(to_peci_device(dev)); >> > + ->> > ????????return 0; +>> > return 0; >> > } >> > >> > diff --git a/drivers/peci/device.c b/drivers/peci/device.c @@ -82,12 +82,12 @@ On Thu, Jul 29, 2021 at 01:55:19PM CDT, Winiarska, Iwona wrote: >> > + >> > +static int peci_detect(struct peci_controller *controller, u8 addr) >> > +{ ->> > +???????struct peci_request *req; ->> > +???????int ret; +>> > + struct peci_request *req; +>> > + int ret; >> > + ->> > +???????req = peci_request_alloc(NULL, 0, 0); ->> > +???????if (!req) ->> > +???????????????return -ENOMEM; +>> > + req = peci_request_alloc(NULL, 0, 0); +>> > + if (!req) +>> > + return -ENOMEM; >> > + >> >> Might be worth a brief comment here noting that an empty request happens @@ -105,45 +105,45 @@ PECI_CMD_PING' or anything), so I was hoping for something that would just make that slightly more explicit. >> ->> > +???????mutex_lock(&controller->bus_lock); ->> > +???????ret = controller->xfer(controller, addr, req); ->> > +???????mutex_unlock(&controller->bus_lock); +>> > + mutex_lock(&controller->bus_lock); +>> > + ret = controller->xfer(controller, addr, req); +>> > + mutex_unlock(&controller->bus_lock); >> > + ->> > +???????peci_request_free(req); +>> > + peci_request_free(req); >> > + ->> > +???????return ret; +>> > + return ret; >> > +} >> > + >> > +static bool peci_addr_valid(u8 addr) >> > +{ ->> > +???????return addr >= PECI_BASE_ADDR && addr < PECI_BASE_ADDR + +>> > + return addr >= PECI_BASE_ADDR && addr < PECI_BASE_ADDR + >> > PECI_DEVICE_NUM_MAX; >> > +} >> > + >> > +static int peci_dev_exists(struct device *dev, void *data) >> > +{ ->> > +???????struct peci_device *device = to_peci_device(dev); ->> > +???????u8 *addr = data; +>> > + struct peci_device *device = to_peci_device(dev); +>> > + u8 *addr = data; >> > + ->> > +???????if (device->addr == *addr) ->> > +???????????????return -EBUSY; +>> > + if (device->addr == *addr) +>> > + return -EBUSY; >> > + ->> > +???????return 0; +>> > + return 0; >> > +} >> > + >> > +int peci_device_create(struct peci_controller *controller, u8 addr) >> > +{ ->> > +???????struct peci_device *device; ->> > +???????int ret; +>> > + struct peci_device *device; +>> > + int ret; >> > + ->> > +???????if (WARN_ON(!peci_addr_valid(addr))) ->> > +???????????????return -EINVAL; +>> > + if (WARN_ON(!peci_addr_valid(addr))) +>> > + return -EINVAL; >> >> Wondering about the necessity of this check (and the peci_addr_valid() >> function) -- as of the end of this patch series, there's only one caller >> of peci_device_create(), and it's peci_controller_scan_devices() looping >> from PECI_BASE_ADDR to PECI_BASE_ADDR + PECI_DEVICE_NUM_MAX, so ->> checking that the address is in that range seems a bit redundant.? Do we +>> checking that the address is in that range seems a bit redundant. Do we >> anticipate that we might gain additional callers in the future that >> could run a non-zero risk of passing a bad address? > @@ -152,25 +152,25 @@ just make that slightly more explicit. > >> >> > + ->> > +???????/* Check if we have already detected this device before. */ ->> > +???????ret = device_for_each_child(&controller->dev, &addr, +>> > + /* Check if we have already detected this device before. */ +>> > + ret = device_for_each_child(&controller->dev, &addr, >> > peci_dev_exists); ->> > +???????if (ret) ->> > +???????????????return 0; ->> > + ->> > +???????ret = peci_detect(controller, addr); ->> > +???????if (ret) { ->> > +???????????????/* ->> > +??????????????? * Device not present or host state doesn't allow successful ->> > +??????????????? * detection at this time. ->> > +??????????????? */ ->> > +???????????????if (ret == -EIO || ret == -ETIMEDOUT) ->> > +???????????????????????return 0; +>> > + if (ret) +>> > + return 0; +>> > + +>> > + ret = peci_detect(controller, addr); +>> > + if (ret) { +>> > + /* +>> > + * Device not present or host state doesn't allow successful +>> > + * detection at this time. +>> > + */ +>> > + if (ret == -EIO || ret == -ETIMEDOUT) +>> > + return 0; >> ->> Do we really want to be ignoring EIO here?? From a look at +>> Do we really want to be ignoring EIO here? From a look at >> aspeed_peci_xfer(), it looks like the only path that would produce that >> is the non-timeout, non-CMD_DONE case, which I guess happens on ->> contention or FCS errors and such.? Should we maybe have some automatic +>> contention or FCS errors and such. Should we maybe have some automatic >> (limited) retry loop for cases like those? > >Yes, we want to ignore EIO here. @@ -179,53 +179,53 @@ just make that slightly more explicit. > >> >> > + ->> > +???????????????return ret; ->> > +???????} +>> > + return ret; +>> > + } >> > + ->> > +???????device = kzalloc(sizeof(*device), GFP_KERNEL); ->> > +???????if (!device) ->> > +???????????????return -ENOMEM; +>> > + device = kzalloc(sizeof(*device), GFP_KERNEL); +>> > + if (!device) +>> > + return -ENOMEM; >> > + ->> > +???????device->controller = controller; ->> > +???????device->addr = addr; ->> > +???????device->dev.parent = &device->controller->dev; ->> > +???????device->dev.bus = &peci_bus_type; ->> > +???????device->dev.type = &peci_device_type; +>> > + device->controller = controller; +>> > + device->addr = addr; +>> > + device->dev.parent = &device->controller->dev; +>> > + device->dev.bus = &peci_bus_type; +>> > + device->dev.type = &peci_device_type; >> > + ->> > +???????ret = dev_set_name(&device->dev, "%d-%02x", controller->id, device- +>> > + ret = dev_set_name(&device->dev, "%d-%02x", controller->id, device- >> > >addr); ->> > +???????if (ret) ->> > +???????????????goto err_free; +>> > + if (ret) +>> > + goto err_free; >> > + ->> > +???????ret = device_register(&device->dev); ->> > +???????if (ret) ->> > +???????????????goto err_put; +>> > + ret = device_register(&device->dev); +>> > + if (ret) +>> > + goto err_put; >> > + ->> > +???????return 0; +>> > + return 0; >> > + >> > +err_put: ->> > +???????put_device(&device->dev); +>> > + put_device(&device->dev); >> > +err_free: ->> > +???????kfree(device); +>> > + kfree(device); >> > + ->> > +???????return ret; +>> > + return ret; >> > +} >> > + >> > +void peci_device_destroy(struct peci_device *device) >> > +{ ->> > +???????device_unregister(&device->dev); +>> > + device_unregister(&device->dev); >> > +} >> > + >> > +static void peci_device_release(struct device *dev) >> > +{ ->> > +???????struct peci_device *device = to_peci_device(dev); +>> > + struct peci_device *device = to_peci_device(dev); >> > + ->> > +???????kfree(device); +>> > + kfree(device); >> > +} >> > + >> > +struct device_type peci_device_type = { ->> > +???????.groups?????????= peci_device_groups, ->> > +???????.release????????= peci_device_release, +>> > + .groups = peci_device_groups, +>> > + .release = peci_device_release, >> > +}; >> > diff --git a/drivers/peci/internal.h b/drivers/peci/internal.h >> > index 80c61bcdfc6b..6b139adaf6b8 100644 @@ -239,8 +239,8 @@ just make that slightly more explicit. >> > +struct peci_request; >> > + >> > +/* PECI CPU address range 0x30-0x37 */ ->> > +#define PECI_BASE_ADDR?????????0x30 ->> > +#define PECI_DEVICE_NUM_MAX????????????8 +>> > +#define PECI_BASE_ADDR 0x30 +>> > +#define PECI_DEVICE_NUM_MAX 8 >> > + >> > +struct peci_request *peci_request_alloc(struct peci_device *device, u8 >> > tx_len, u8 rx_len); @@ -283,42 +283,42 @@ just make that slightly more explicit. >> > +struct peci_request *peci_request_alloc(struct peci_device *device, u8 >> > tx_len, u8 rx_len) >> > +{ ->> > +???????struct peci_request *req; ->> > +???????u8 *tx_buf, *rx_buf; +>> > + struct peci_request *req; +>> > + u8 *tx_buf, *rx_buf; >> > + ->> > +???????req = kzalloc(sizeof(*req), GFP_KERNEL); ->> > +???????if (!req) ->> > +???????????????return NULL; +>> > + req = kzalloc(sizeof(*req), GFP_KERNEL); +>> > + if (!req) +>> > + return NULL; >> > + ->> > +???????req->device = device; +>> > + req->device = device; >> > + ->> > +???????/* ->> > +??????? * PECI controllers that we are using now don't support DMA, this ->> > +??????? * should be converted to DMA API once support for controllers that +>> > + /* +>> > + * PECI controllers that we are using now don't support DMA, this +>> > + * should be converted to DMA API once support for controllers that >> > do ->> > +??????? * allow it is added to avoid an extra copy. ->> > +??????? */ ->> > +???????if (tx_len) { ->> > +???????????????tx_buf = kzalloc(tx_len, GFP_KERNEL); ->> > +???????????????if (!tx_buf) ->> > +???????????????????????goto err_free_req; ->> > + ->> > +???????????????req->tx.buf = tx_buf; ->> > +???????????????req->tx.len = tx_len; ->> > +???????} ->> > + ->> > +???????if (rx_len) { ->> > +???????????????rx_buf = kzalloc(rx_len, GFP_KERNEL); ->> > +???????????????if (!rx_buf) ->> > +???????????????????????goto err_free_tx; ->> > + ->> > +???????????????req->rx.buf = rx_buf; ->> > +???????????????req->rx.len = rx_len; ->> > +???????} +>> > + * allow it is added to avoid an extra copy. +>> > + */ +>> > + if (tx_len) { +>> > + tx_buf = kzalloc(tx_len, GFP_KERNEL); +>> > + if (!tx_buf) +>> > + goto err_free_req; +>> > + +>> > + req->tx.buf = tx_buf; +>> > + req->tx.len = tx_len; +>> > + } +>> > + +>> > + if (rx_len) { +>> > + rx_buf = kzalloc(rx_len, GFP_KERNEL); +>> > + if (!rx_buf) +>> > + goto err_free_tx; +>> > + +>> > + req->rx.buf = rx_buf; +>> > + req->rx.len = rx_len; +>> > + } >> > + >> >> As long as we're punting on DMA support, could we do the whole thing in ->> a single allocation instead of three?? It'd add some pointer arithmetic, +>> a single allocation instead of three? It'd add some pointer arithmetic, >> but would also simplify the error-handling/deallocation paths a bit. >> >> Or, given that the one controller we're currently supporting has a @@ -370,14 +370,14 @@ by a mutex anyway? >-Iwona > >> ->> > +???????return req; +>> > + return req; >> > + >> > +err_free_tx: ->> > +???????kfree(req->tx.buf); +>> > + kfree(req->tx.buf); >> > +err_free_req: ->> > +???????kfree(req); +>> > + kfree(req); >> > + ->> > +???????return NULL; +>> > + return NULL; >> > +} >> > +EXPORT_SYMBOL_NS_GPL(peci_request_alloc, PECI); >> > + @@ -387,9 +387,9 @@ by a mutex anyway? >> > + */ >> > +void peci_request_free(struct peci_request *req) >> > +{ ->> > +???????kfree(req->rx.buf); ->> > +???????kfree(req->tx.buf); ->> > +???????kfree(req); +>> > + kfree(req->rx.buf); +>> > + kfree(req->tx.buf); +>> > + kfree(req); >> > +} >> > +EXPORT_SYMBOL_NS_GPL(peci_request_free, PECI); >> > diff --git a/drivers/peci/sysfs.c b/drivers/peci/sysfs.c @@ -406,41 +406,41 @@ by a mutex anyway? >> > >> > #include "internal.h" >> > @@ -46,3 +48,35 @@ const struct attribute_group *peci_bus_groups[] = { ->> > ????????&peci_bus_group, ->> > ????????NULL +>> > &peci_bus_group, +>> > NULL >> > }; >> > + >> > +static ssize_t remove_store(struct device *dev, struct device_attribute >> > *attr, ->> > +?????????????????????????? const char *buf, size_t count) +>> > + const char *buf, size_t count) >> > +{ ->> > +???????struct peci_device *device = to_peci_device(dev); ->> > +???????bool res; ->> > +???????int ret; +>> > + struct peci_device *device = to_peci_device(dev); +>> > + bool res; +>> > + int ret; >> > + ->> > +???????ret = kstrtobool(buf, &res); ->> > +???????if (ret) ->> > +???????????????return ret; +>> > + ret = kstrtobool(buf, &res); +>> > + if (ret) +>> > + return ret; >> > + ->> > +???????if (res && device_remove_file_self(dev, attr)) ->> > +???????????????peci_device_destroy(device); +>> > + if (res && device_remove_file_self(dev, attr)) +>> > + peci_device_destroy(device); >> > + ->> > +???????return count; +>> > + return count; >> > +} >> > +static DEVICE_ATTR_IGNORE_LOCKDEP(remove, 0200, NULL, remove_store); >> > + >> > +static struct attribute *peci_device_attrs[] = { ->> > +???????&dev_attr_remove.attr, ->> > +???????NULL +>> > + &dev_attr_remove.attr, +>> > + NULL >> > +}; >> > + >> > +static const struct attribute_group peci_device_group = { ->> > +???????.attrs = peci_device_attrs, +>> > + .attrs = peci_device_attrs, >> > +}; >> > + >> > +const struct attribute_group *peci_device_groups[] = { ->> > +???????&peci_device_group, ->> > +???????NULL +>> > + &peci_device_group, +>> > + NULL >> > +}; >> > -- >> > 2.31.1 diff --git a/a/content_digest b/N1/content_digest index 1620083..b7e5444 100644 --- a/a/content_digest +++ b/N1/content_digest @@ -3,9 +3,36 @@ "ref\020210727174900.GR8018@packtop\0" "ref\047440a8329ce06c41ca9746db42cb1d66154ea46.camel@intel.com\0" "From\0Zev Weiss <zweiss@equinix.com>\0" - "Subject\0[PATCH 08/14] peci: Add device detection\0" + "Subject\0Re: [PATCH 08/14] peci: Add device detection\0" "Date\0Thu, 29 Jul 2021 20:50:13 +0000\0" - "To\0linux-aspeed@lists.ozlabs.org\0" + "To\0Winiarska" + " Iwona <iwona.winiarska@intel.com>\0" + "Cc\0corbet@lwn.net <corbet@lwn.net>" + jae.hyun.yoo@linux.intel.com <jae.hyun.yoo@linux.intel.com> + Lutomirski + Andy <luto@kernel.org> + linux-hwmon@vger.kernel.org <linux-hwmon@vger.kernel.org> + Luck + Tony <tony.luck@intel.com> + andrew@aj.id.au <andrew@aj.id.au> + mchehab@kernel.org <mchehab@kernel.org> + jdelvare@suse.com <jdelvare@suse.com> + linux-kernel@vger.kernel.org <linux-kernel@vger.kernel.org> + mingo@redhat.com <mingo@redhat.com> + devicetree@vger.kernel.org <devicetree@vger.kernel.org> + tglx@linutronix.de <tglx@linutronix.de> + linux@roeck-us.net <linux@roeck-us.net> + linux-aspeed@lists.ozlabs.org <linux-aspeed@lists.ozlabs.org> + linux-doc@vger.kernel.org <linux-doc@vger.kernel.org> + yazen.ghannam@amd.com <yazen.ghannam@amd.com> + robh+dt@kernel.org <robh+dt@kernel.org> + openbmc@lists.ozlabs.org <openbmc@lists.ozlabs.org> + bp@alien8.de <bp@alien8.de> + linux-arm-kernel@lists.infradead.org <linux-arm-kernel@lists.infradead.org> + pierre-louis.bossart@linux.intel.com <pierre-louis.bossart@linux.intel.com> + andriy.shevchenko@linux.intel.com <andriy.shevchenko@linux.intel.com> + x86@kernel.org <x86@kernel.org> + " gregkh@linuxfoundation.org <gregkh@linuxfoundation.org>\0" "\00:1\0" "b\0" "On Thu, Jul 29, 2021 at 01:55:19PM CDT, Winiarska, Iwona wrote:\n" @@ -21,12 +48,12 @@ ">> > Signed-off-by: Iwona Winiarska <iwona.winiarska@intel.com>\n" ">> > Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>\n" ">> > ---\n" - ">> > drivers/peci/Makefile?? |?? 2 +-\n" - ">> > drivers/peci/core.c???? |? 13 ++++-\n" - ">> > drivers/peci/device.c?? | 111 ++++++++++++++++++++++++++++++++++++++++\n" - ">> > drivers/peci/internal.h |? 15 ++++++\n" - ">> > drivers/peci/request.c? |? 74 +++++++++++++++++++++++++++\n" - ">> > drivers/peci/sysfs.c??? |? 34 ++++++++++++\n" + ">> > drivers/peci/Makefile\302\240\302\240 |\302\240\302\240 2 +-\n" + ">> > drivers/peci/core.c\302\240\302\240\302\240\302\240 |\302\240 13 ++++-\n" + ">> > drivers/peci/device.c\302\240\302\240 | 111 ++++++++++++++++++++++++++++++++++++++++\n" + ">> > drivers/peci/internal.h |\302\240 15 ++++++\n" + ">> > drivers/peci/request.c\302\240 |\302\240 74 +++++++++++++++++++++++++++\n" + ">> > drivers/peci/sysfs.c\302\240\302\240\302\240 |\302\240 34 ++++++++++++\n" ">> > 6 files changed, 246 insertions(+), 3 deletions(-)\n" ">> > create mode 100644 drivers/peci/device.c\n" ">> > create mode 100644 drivers/peci/request.c\n" @@ -52,28 +79,28 @@ ">> >\n" ">> > int peci_controller_scan_devices(struct peci_controller *controller)\n" ">> > {\n" - ">> > -???????/* Just a stub, no support for actual devices yet */\n" - ">> > +???????int ret;\n" - ">> > +???????u8 addr;\n" + ">> > -\302\240\302\240\302\240\302\240\302\240\302\240\302\240/* Just a stub, no support for actual devices yet */\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240int ret;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240u8 addr;\n" ">> > +\n" - ">> > +???????for (addr = PECI_BASE_ADDR; addr < PECI_BASE_ADDR +\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240for (addr = PECI_BASE_ADDR; addr < PECI_BASE_ADDR +\n" ">> > PECI_DEVICE_NUM_MAX; addr++) {\n" - ">> > +???????????????ret = peci_device_create(controller, addr);\n" - ">> > +???????????????if (ret)\n" - ">> > +???????????????????????return ret;\n" - ">> > +???????}\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240ret = peci_device_create(controller, addr);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (ret)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240return ret;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240}\n" ">> > +\n" - ">> > ????????return 0;\n" + ">> > \302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240return 0;\n" ">> > }\n" ">> >\n" ">> > @@ -106,7 +114,8 @@ EXPORT_SYMBOL_NS_GPL(peci_controller_add, PECI);\n" ">> >\n" ">> > static int _unregister(struct device *dev, void *dummy)\n" ">> > {\n" - ">> > -???????/* Just a stub, no support for actual devices yet */\n" - ">> > +???????peci_device_destroy(to_peci_device(dev));\n" + ">> > -\302\240\302\240\302\240\302\240\302\240\302\240\302\240/* Just a stub, no support for actual devices yet */\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240peci_device_destroy(to_peci_device(dev));\n" ">> > +\n" - ">> > ????????return 0;\n" + ">> > \302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240return 0;\n" ">> > }\n" ">> >\n" ">> > diff --git a/drivers/peci/device.c b/drivers/peci/device.c\n" @@ -92,12 +119,12 @@ ">> > +\n" ">> > +static int peci_detect(struct peci_controller *controller, u8 addr)\n" ">> > +{\n" - ">> > +???????struct peci_request *req;\n" - ">> > +???????int ret;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240struct peci_request *req;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240int ret;\n" ">> > +\n" - ">> > +???????req = peci_request_alloc(NULL, 0, 0);\n" - ">> > +???????if (!req)\n" - ">> > +???????????????return -ENOMEM;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240req = peci_request_alloc(NULL, 0, 0);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (!req)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240return -ENOMEM;\n" ">> > +\n" ">>\n" ">> Might be worth a brief comment here noting that an empty request happens\n" @@ -115,45 +142,45 @@ "just make that slightly more explicit.\n" "\n" ">>\n" - ">> > +???????mutex_lock(&controller->bus_lock);\n" - ">> > +???????ret = controller->xfer(controller, addr, req);\n" - ">> > +???????mutex_unlock(&controller->bus_lock);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240mutex_lock(&controller->bus_lock);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240ret = controller->xfer(controller, addr, req);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240mutex_unlock(&controller->bus_lock);\n" ">> > +\n" - ">> > +???????peci_request_free(req);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240peci_request_free(req);\n" ">> > +\n" - ">> > +???????return ret;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240return ret;\n" ">> > +}\n" ">> > +\n" ">> > +static bool peci_addr_valid(u8 addr)\n" ">> > +{\n" - ">> > +???????return addr >= PECI_BASE_ADDR && addr < PECI_BASE_ADDR +\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240return addr >= PECI_BASE_ADDR && addr < PECI_BASE_ADDR +\n" ">> > PECI_DEVICE_NUM_MAX;\n" ">> > +}\n" ">> > +\n" ">> > +static int peci_dev_exists(struct device *dev, void *data)\n" ">> > +{\n" - ">> > +???????struct peci_device *device = to_peci_device(dev);\n" - ">> > +???????u8 *addr = data;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240struct peci_device *device = to_peci_device(dev);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240u8 *addr = data;\n" ">> > +\n" - ">> > +???????if (device->addr == *addr)\n" - ">> > +???????????????return -EBUSY;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (device->addr == *addr)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240return -EBUSY;\n" ">> > +\n" - ">> > +???????return 0;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240return 0;\n" ">> > +}\n" ">> > +\n" ">> > +int peci_device_create(struct peci_controller *controller, u8 addr)\n" ">> > +{\n" - ">> > +???????struct peci_device *device;\n" - ">> > +???????int ret;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240struct peci_device *device;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240int ret;\n" ">> > +\n" - ">> > +???????if (WARN_ON(!peci_addr_valid(addr)))\n" - ">> > +???????????????return -EINVAL;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (WARN_ON(!peci_addr_valid(addr)))\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240return -EINVAL;\n" ">>\n" ">> Wondering about the necessity of this check (and the peci_addr_valid()\n" ">> function) -- as of the end of this patch series, there's only one caller\n" ">> of peci_device_create(), and it's peci_controller_scan_devices() looping\n" ">> from PECI_BASE_ADDR to PECI_BASE_ADDR + PECI_DEVICE_NUM_MAX, so\n" - ">> checking that the address is in that range seems a bit redundant.? Do we\n" + ">> checking that the address is in that range seems a bit redundant.\302\240 Do we\n" ">> anticipate that we might gain additional callers in the future that\n" ">> could run a non-zero risk of passing a bad address?\n" ">\n" @@ -162,25 +189,25 @@ ">\n" ">>\n" ">> > +\n" - ">> > +???????/* Check if we have already detected this device before. */\n" - ">> > +???????ret = device_for_each_child(&controller->dev, &addr,\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240/* Check if we have already detected this device before. */\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240ret = device_for_each_child(&controller->dev, &addr,\n" ">> > peci_dev_exists);\n" - ">> > +???????if (ret)\n" - ">> > +???????????????return 0;\n" - ">> > +\n" - ">> > +???????ret = peci_detect(controller, addr);\n" - ">> > +???????if (ret) {\n" - ">> > +???????????????/*\n" - ">> > +??????????????? * Device not present or host state doesn't allow successful\n" - ">> > +??????????????? * detection at this time.\n" - ">> > +??????????????? */\n" - ">> > +???????????????if (ret == -EIO || ret == -ETIMEDOUT)\n" - ">> > +???????????????????????return 0;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (ret)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240return 0;\n" + ">> > +\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240ret = peci_detect(controller, addr);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (ret) {\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240/*\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240 * Device not present or host state doesn't allow successful\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240 * detection at this time.\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240 */\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (ret == -EIO || ret == -ETIMEDOUT)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240return 0;\n" ">>\n" - ">> Do we really want to be ignoring EIO here?? From a look at\n" + ">> Do we really want to be ignoring EIO here?\302\240 From a look at\n" ">> aspeed_peci_xfer(), it looks like the only path that would produce that\n" ">> is the non-timeout, non-CMD_DONE case, which I guess happens on\n" - ">> contention or FCS errors and such.? Should we maybe have some automatic\n" + ">> contention or FCS errors and such.\302\240 Should we maybe have some automatic\n" ">> (limited) retry loop for cases like those?\n" ">\n" ">Yes, we want to ignore EIO here.\n" @@ -189,53 +216,53 @@ ">\n" ">>\n" ">> > +\n" - ">> > +???????????????return ret;\n" - ">> > +???????}\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240return ret;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240}\n" ">> > +\n" - ">> > +???????device = kzalloc(sizeof(*device), GFP_KERNEL);\n" - ">> > +???????if (!device)\n" - ">> > +???????????????return -ENOMEM;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240device = kzalloc(sizeof(*device), GFP_KERNEL);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (!device)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240return -ENOMEM;\n" ">> > +\n" - ">> > +???????device->controller = controller;\n" - ">> > +???????device->addr = addr;\n" - ">> > +???????device->dev.parent = &device->controller->dev;\n" - ">> > +???????device->dev.bus = &peci_bus_type;\n" - ">> > +???????device->dev.type = &peci_device_type;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240device->controller = controller;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240device->addr = addr;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240device->dev.parent = &device->controller->dev;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240device->dev.bus = &peci_bus_type;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240device->dev.type = &peci_device_type;\n" ">> > +\n" - ">> > +???????ret = dev_set_name(&device->dev, \"%d-%02x\", controller->id, device-\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240ret = dev_set_name(&device->dev, \"%d-%02x\", controller->id, device-\n" ">> > >addr);\n" - ">> > +???????if (ret)\n" - ">> > +???????????????goto err_free;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (ret)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240goto err_free;\n" ">> > +\n" - ">> > +???????ret = device_register(&device->dev);\n" - ">> > +???????if (ret)\n" - ">> > +???????????????goto err_put;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240ret = device_register(&device->dev);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (ret)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240goto err_put;\n" ">> > +\n" - ">> > +???????return 0;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240return 0;\n" ">> > +\n" ">> > +err_put:\n" - ">> > +???????put_device(&device->dev);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240put_device(&device->dev);\n" ">> > +err_free:\n" - ">> > +???????kfree(device);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240kfree(device);\n" ">> > +\n" - ">> > +???????return ret;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240return ret;\n" ">> > +}\n" ">> > +\n" ">> > +void peci_device_destroy(struct peci_device *device)\n" ">> > +{\n" - ">> > +???????device_unregister(&device->dev);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240device_unregister(&device->dev);\n" ">> > +}\n" ">> > +\n" ">> > +static void peci_device_release(struct device *dev)\n" ">> > +{\n" - ">> > +???????struct peci_device *device = to_peci_device(dev);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240struct peci_device *device = to_peci_device(dev);\n" ">> > +\n" - ">> > +???????kfree(device);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240kfree(device);\n" ">> > +}\n" ">> > +\n" ">> > +struct device_type peci_device_type = {\n" - ">> > +???????.groups?????????= peci_device_groups,\n" - ">> > +???????.release????????= peci_device_release,\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240.groups\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240= peci_device_groups,\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240.release\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240= peci_device_release,\n" ">> > +};\n" ">> > diff --git a/drivers/peci/internal.h b/drivers/peci/internal.h\n" ">> > index 80c61bcdfc6b..6b139adaf6b8 100644\n" @@ -249,8 +276,8 @@ ">> > +struct peci_request;\n" ">> > +\n" ">> > +/* PECI CPU address range 0x30-0x37 */\n" - ">> > +#define PECI_BASE_ADDR?????????0x30\n" - ">> > +#define PECI_DEVICE_NUM_MAX????????????8\n" + ">> > +#define PECI_BASE_ADDR\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\2400x30\n" + ">> > +#define PECI_DEVICE_NUM_MAX\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\2408\n" ">> > +\n" ">> > +struct peci_request *peci_request_alloc(struct peci_device *device, u8\n" ">> > tx_len, u8 rx_len);\n" @@ -293,42 +320,42 @@ ">> > +struct peci_request *peci_request_alloc(struct peci_device *device, u8\n" ">> > tx_len, u8 rx_len)\n" ">> > +{\n" - ">> > +???????struct peci_request *req;\n" - ">> > +???????u8 *tx_buf, *rx_buf;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240struct peci_request *req;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240u8 *tx_buf, *rx_buf;\n" ">> > +\n" - ">> > +???????req = kzalloc(sizeof(*req), GFP_KERNEL);\n" - ">> > +???????if (!req)\n" - ">> > +???????????????return NULL;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240req = kzalloc(sizeof(*req), GFP_KERNEL);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (!req)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240return NULL;\n" ">> > +\n" - ">> > +???????req->device = device;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240req->device = device;\n" ">> > +\n" - ">> > +???????/*\n" - ">> > +??????? * PECI controllers that we are using now don't support DMA, this\n" - ">> > +??????? * should be converted to DMA API once support for controllers that\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240/*\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240 * PECI controllers that we are using now don't support DMA, this\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240 * should be converted to DMA API once support for controllers that\n" ">> > do\n" - ">> > +??????? * allow it is added to avoid an extra copy.\n" - ">> > +??????? */\n" - ">> > +???????if (tx_len) {\n" - ">> > +???????????????tx_buf = kzalloc(tx_len, GFP_KERNEL);\n" - ">> > +???????????????if (!tx_buf)\n" - ">> > +???????????????????????goto err_free_req;\n" - ">> > +\n" - ">> > +???????????????req->tx.buf = tx_buf;\n" - ">> > +???????????????req->tx.len = tx_len;\n" - ">> > +???????}\n" - ">> > +\n" - ">> > +???????if (rx_len) {\n" - ">> > +???????????????rx_buf = kzalloc(rx_len, GFP_KERNEL);\n" - ">> > +???????????????if (!rx_buf)\n" - ">> > +???????????????????????goto err_free_tx;\n" - ">> > +\n" - ">> > +???????????????req->rx.buf = rx_buf;\n" - ">> > +???????????????req->rx.len = rx_len;\n" - ">> > +???????}\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240 * allow it is added to avoid an extra copy.\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240 */\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (tx_len) {\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240tx_buf = kzalloc(tx_len, GFP_KERNEL);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (!tx_buf)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240goto err_free_req;\n" + ">> > +\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240req->tx.buf = tx_buf;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240req->tx.len = tx_len;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240}\n" + ">> > +\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (rx_len) {\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240rx_buf = kzalloc(rx_len, GFP_KERNEL);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (!rx_buf)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240goto err_free_tx;\n" + ">> > +\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240req->rx.buf = rx_buf;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240req->rx.len = rx_len;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240}\n" ">> > +\n" ">>\n" ">> As long as we're punting on DMA support, could we do the whole thing in\n" - ">> a single allocation instead of three?? It'd add some pointer arithmetic,\n" + ">> a single allocation instead of three?\302\240 It'd add some pointer arithmetic,\n" ">> but would also simplify the error-handling/deallocation paths a bit.\n" ">>\n" ">> Or, given that the one controller we're currently supporting has a\n" @@ -380,14 +407,14 @@ ">-Iwona\n" ">\n" ">>\n" - ">> > +???????return req;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240return req;\n" ">> > +\n" ">> > +err_free_tx:\n" - ">> > +???????kfree(req->tx.buf);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240kfree(req->tx.buf);\n" ">> > +err_free_req:\n" - ">> > +???????kfree(req);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240kfree(req);\n" ">> > +\n" - ">> > +???????return NULL;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240return NULL;\n" ">> > +}\n" ">> > +EXPORT_SYMBOL_NS_GPL(peci_request_alloc, PECI);\n" ">> > +\n" @@ -397,9 +424,9 @@ ">> > + */\n" ">> > +void peci_request_free(struct peci_request *req)\n" ">> > +{\n" - ">> > +???????kfree(req->rx.buf);\n" - ">> > +???????kfree(req->tx.buf);\n" - ">> > +???????kfree(req);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240kfree(req->rx.buf);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240kfree(req->tx.buf);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240kfree(req);\n" ">> > +}\n" ">> > +EXPORT_SYMBOL_NS_GPL(peci_request_free, PECI);\n" ">> > diff --git a/drivers/peci/sysfs.c b/drivers/peci/sysfs.c\n" @@ -416,44 +443,44 @@ ">> >\n" ">> > #include \"internal.h\"\n" ">> > @@ -46,3 +48,35 @@ const struct attribute_group *peci_bus_groups[] = {\n" - ">> > ????????&peci_bus_group,\n" - ">> > ????????NULL\n" + ">> > \302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240&peci_bus_group,\n" + ">> > \302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240NULL\n" ">> > };\n" ">> > +\n" ">> > +static ssize_t remove_store(struct device *dev, struct device_attribute\n" ">> > *attr,\n" - ">> > +?????????????????????????? const char *buf, size_t count)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240 const char *buf, size_t count)\n" ">> > +{\n" - ">> > +???????struct peci_device *device = to_peci_device(dev);\n" - ">> > +???????bool res;\n" - ">> > +???????int ret;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240struct peci_device *device = to_peci_device(dev);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240bool res;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240int ret;\n" ">> > +\n" - ">> > +???????ret = kstrtobool(buf, &res);\n" - ">> > +???????if (ret)\n" - ">> > +???????????????return ret;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240ret = kstrtobool(buf, &res);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (ret)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240return ret;\n" ">> > +\n" - ">> > +???????if (res && device_remove_file_self(dev, attr))\n" - ">> > +???????????????peci_device_destroy(device);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (res && device_remove_file_self(dev, attr))\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240peci_device_destroy(device);\n" ">> > +\n" - ">> > +???????return count;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240return count;\n" ">> > +}\n" ">> > +static DEVICE_ATTR_IGNORE_LOCKDEP(remove, 0200, NULL, remove_store);\n" ">> > +\n" ">> > +static struct attribute *peci_device_attrs[] = {\n" - ">> > +???????&dev_attr_remove.attr,\n" - ">> > +???????NULL\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240&dev_attr_remove.attr,\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240NULL\n" ">> > +};\n" ">> > +\n" ">> > +static const struct attribute_group peci_device_group = {\n" - ">> > +???????.attrs = peci_device_attrs,\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240.attrs = peci_device_attrs,\n" ">> > +};\n" ">> > +\n" ">> > +const struct attribute_group *peci_device_groups[] = {\n" - ">> > +???????&peci_device_group,\n" - ">> > +???????NULL\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240&peci_device_group,\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240NULL\n" ">> > +};\n" ">> > --\n" ">> > 2.31.1\n" > -1d638fbf92fea69e3e8bcf8a80ff14134bac0a1c6d90a619556236ffcef3d338 +844a331e7c8d1b767e5437e590769550b377869558399f3c946660fcfc5a04b0
diff --git a/a/1.txt b/N2/1.txt index 7e773e1..16b134b 100644 --- a/a/1.txt +++ b/N2/1.txt @@ -11,12 +11,12 @@ On Thu, Jul 29, 2021 at 01:55:19PM CDT, Winiarska, Iwona wrote: >> > Signed-off-by: Iwona Winiarska <iwona.winiarska@intel.com> >> > Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> >> > --- ->> > drivers/peci/Makefile?? |?? 2 +- ->> > drivers/peci/core.c???? |? 13 ++++- ->> > drivers/peci/device.c?? | 111 ++++++++++++++++++++++++++++++++++++++++ ->> > drivers/peci/internal.h |? 15 ++++++ ->> > drivers/peci/request.c? |? 74 +++++++++++++++++++++++++++ ->> > drivers/peci/sysfs.c??? |? 34 ++++++++++++ +>> > drivers/peci/Makefile | 2 +- +>> > drivers/peci/core.c | 13 ++++- +>> > drivers/peci/device.c | 111 ++++++++++++++++++++++++++++++++++++++++ +>> > drivers/peci/internal.h | 15 ++++++ +>> > drivers/peci/request.c | 74 +++++++++++++++++++++++++++ +>> > drivers/peci/sysfs.c | 34 ++++++++++++ >> > 6 files changed, 246 insertions(+), 3 deletions(-) >> > create mode 100644 drivers/peci/device.c >> > create mode 100644 drivers/peci/request.c @@ -42,28 +42,28 @@ On Thu, Jul 29, 2021 at 01:55:19PM CDT, Winiarska, Iwona wrote: >> > >> > int peci_controller_scan_devices(struct peci_controller *controller) >> > { ->> > -???????/* Just a stub, no support for actual devices yet */ ->> > +???????int ret; ->> > +???????u8 addr; +>> > - /* Just a stub, no support for actual devices yet */ +>> > + int ret; +>> > + u8 addr; >> > + ->> > +???????for (addr = PECI_BASE_ADDR; addr < PECI_BASE_ADDR + +>> > + for (addr = PECI_BASE_ADDR; addr < PECI_BASE_ADDR + >> > PECI_DEVICE_NUM_MAX; addr++) { ->> > +???????????????ret = peci_device_create(controller, addr); ->> > +???????????????if (ret) ->> > +???????????????????????return ret; ->> > +???????} +>> > + ret = peci_device_create(controller, addr); +>> > + if (ret) +>> > + return ret; +>> > + } >> > + ->> > ????????return 0; +>> > return 0; >> > } >> > >> > @@ -106,7 +114,8 @@ EXPORT_SYMBOL_NS_GPL(peci_controller_add, PECI); >> > >> > static int _unregister(struct device *dev, void *dummy) >> > { ->> > -???????/* Just a stub, no support for actual devices yet */ ->> > +???????peci_device_destroy(to_peci_device(dev)); +>> > - /* Just a stub, no support for actual devices yet */ +>> > + peci_device_destroy(to_peci_device(dev)); >> > + ->> > ????????return 0; +>> > return 0; >> > } >> > >> > diff --git a/drivers/peci/device.c b/drivers/peci/device.c @@ -82,12 +82,12 @@ On Thu, Jul 29, 2021 at 01:55:19PM CDT, Winiarska, Iwona wrote: >> > + >> > +static int peci_detect(struct peci_controller *controller, u8 addr) >> > +{ ->> > +???????struct peci_request *req; ->> > +???????int ret; +>> > + struct peci_request *req; +>> > + int ret; >> > + ->> > +???????req = peci_request_alloc(NULL, 0, 0); ->> > +???????if (!req) ->> > +???????????????return -ENOMEM; +>> > + req = peci_request_alloc(NULL, 0, 0); +>> > + if (!req) +>> > + return -ENOMEM; >> > + >> >> Might be worth a brief comment here noting that an empty request happens @@ -105,45 +105,45 @@ PECI_CMD_PING' or anything), so I was hoping for something that would just make that slightly more explicit. >> ->> > +???????mutex_lock(&controller->bus_lock); ->> > +???????ret = controller->xfer(controller, addr, req); ->> > +???????mutex_unlock(&controller->bus_lock); +>> > + mutex_lock(&controller->bus_lock); +>> > + ret = controller->xfer(controller, addr, req); +>> > + mutex_unlock(&controller->bus_lock); >> > + ->> > +???????peci_request_free(req); +>> > + peci_request_free(req); >> > + ->> > +???????return ret; +>> > + return ret; >> > +} >> > + >> > +static bool peci_addr_valid(u8 addr) >> > +{ ->> > +???????return addr >= PECI_BASE_ADDR && addr < PECI_BASE_ADDR + +>> > + return addr >= PECI_BASE_ADDR && addr < PECI_BASE_ADDR + >> > PECI_DEVICE_NUM_MAX; >> > +} >> > + >> > +static int peci_dev_exists(struct device *dev, void *data) >> > +{ ->> > +???????struct peci_device *device = to_peci_device(dev); ->> > +???????u8 *addr = data; +>> > + struct peci_device *device = to_peci_device(dev); +>> > + u8 *addr = data; >> > + ->> > +???????if (device->addr == *addr) ->> > +???????????????return -EBUSY; +>> > + if (device->addr == *addr) +>> > + return -EBUSY; >> > + ->> > +???????return 0; +>> > + return 0; >> > +} >> > + >> > +int peci_device_create(struct peci_controller *controller, u8 addr) >> > +{ ->> > +???????struct peci_device *device; ->> > +???????int ret; +>> > + struct peci_device *device; +>> > + int ret; >> > + ->> > +???????if (WARN_ON(!peci_addr_valid(addr))) ->> > +???????????????return -EINVAL; +>> > + if (WARN_ON(!peci_addr_valid(addr))) +>> > + return -EINVAL; >> >> Wondering about the necessity of this check (and the peci_addr_valid() >> function) -- as of the end of this patch series, there's only one caller >> of peci_device_create(), and it's peci_controller_scan_devices() looping >> from PECI_BASE_ADDR to PECI_BASE_ADDR + PECI_DEVICE_NUM_MAX, so ->> checking that the address is in that range seems a bit redundant.? Do we +>> checking that the address is in that range seems a bit redundant. Do we >> anticipate that we might gain additional callers in the future that >> could run a non-zero risk of passing a bad address? > @@ -152,25 +152,25 @@ just make that slightly more explicit. > >> >> > + ->> > +???????/* Check if we have already detected this device before. */ ->> > +???????ret = device_for_each_child(&controller->dev, &addr, +>> > + /* Check if we have already detected this device before. */ +>> > + ret = device_for_each_child(&controller->dev, &addr, >> > peci_dev_exists); ->> > +???????if (ret) ->> > +???????????????return 0; ->> > + ->> > +???????ret = peci_detect(controller, addr); ->> > +???????if (ret) { ->> > +???????????????/* ->> > +??????????????? * Device not present or host state doesn't allow successful ->> > +??????????????? * detection at this time. ->> > +??????????????? */ ->> > +???????????????if (ret == -EIO || ret == -ETIMEDOUT) ->> > +???????????????????????return 0; +>> > + if (ret) +>> > + return 0; +>> > + +>> > + ret = peci_detect(controller, addr); +>> > + if (ret) { +>> > + /* +>> > + * Device not present or host state doesn't allow successful +>> > + * detection at this time. +>> > + */ +>> > + if (ret == -EIO || ret == -ETIMEDOUT) +>> > + return 0; >> ->> Do we really want to be ignoring EIO here?? From a look at +>> Do we really want to be ignoring EIO here? From a look at >> aspeed_peci_xfer(), it looks like the only path that would produce that >> is the non-timeout, non-CMD_DONE case, which I guess happens on ->> contention or FCS errors and such.? Should we maybe have some automatic +>> contention or FCS errors and such. Should we maybe have some automatic >> (limited) retry loop for cases like those? > >Yes, we want to ignore EIO here. @@ -179,53 +179,53 @@ just make that slightly more explicit. > >> >> > + ->> > +???????????????return ret; ->> > +???????} +>> > + return ret; +>> > + } >> > + ->> > +???????device = kzalloc(sizeof(*device), GFP_KERNEL); ->> > +???????if (!device) ->> > +???????????????return -ENOMEM; +>> > + device = kzalloc(sizeof(*device), GFP_KERNEL); +>> > + if (!device) +>> > + return -ENOMEM; >> > + ->> > +???????device->controller = controller; ->> > +???????device->addr = addr; ->> > +???????device->dev.parent = &device->controller->dev; ->> > +???????device->dev.bus = &peci_bus_type; ->> > +???????device->dev.type = &peci_device_type; +>> > + device->controller = controller; +>> > + device->addr = addr; +>> > + device->dev.parent = &device->controller->dev; +>> > + device->dev.bus = &peci_bus_type; +>> > + device->dev.type = &peci_device_type; >> > + ->> > +???????ret = dev_set_name(&device->dev, "%d-%02x", controller->id, device- +>> > + ret = dev_set_name(&device->dev, "%d-%02x", controller->id, device- >> > >addr); ->> > +???????if (ret) ->> > +???????????????goto err_free; +>> > + if (ret) +>> > + goto err_free; >> > + ->> > +???????ret = device_register(&device->dev); ->> > +???????if (ret) ->> > +???????????????goto err_put; +>> > + ret = device_register(&device->dev); +>> > + if (ret) +>> > + goto err_put; >> > + ->> > +???????return 0; +>> > + return 0; >> > + >> > +err_put: ->> > +???????put_device(&device->dev); +>> > + put_device(&device->dev); >> > +err_free: ->> > +???????kfree(device); +>> > + kfree(device); >> > + ->> > +???????return ret; +>> > + return ret; >> > +} >> > + >> > +void peci_device_destroy(struct peci_device *device) >> > +{ ->> > +???????device_unregister(&device->dev); +>> > + device_unregister(&device->dev); >> > +} >> > + >> > +static void peci_device_release(struct device *dev) >> > +{ ->> > +???????struct peci_device *device = to_peci_device(dev); +>> > + struct peci_device *device = to_peci_device(dev); >> > + ->> > +???????kfree(device); +>> > + kfree(device); >> > +} >> > + >> > +struct device_type peci_device_type = { ->> > +???????.groups?????????= peci_device_groups, ->> > +???????.release????????= peci_device_release, +>> > + .groups = peci_device_groups, +>> > + .release = peci_device_release, >> > +}; >> > diff --git a/drivers/peci/internal.h b/drivers/peci/internal.h >> > index 80c61bcdfc6b..6b139adaf6b8 100644 @@ -239,8 +239,8 @@ just make that slightly more explicit. >> > +struct peci_request; >> > + >> > +/* PECI CPU address range 0x30-0x37 */ ->> > +#define PECI_BASE_ADDR?????????0x30 ->> > +#define PECI_DEVICE_NUM_MAX????????????8 +>> > +#define PECI_BASE_ADDR 0x30 +>> > +#define PECI_DEVICE_NUM_MAX 8 >> > + >> > +struct peci_request *peci_request_alloc(struct peci_device *device, u8 >> > tx_len, u8 rx_len); @@ -283,42 +283,42 @@ just make that slightly more explicit. >> > +struct peci_request *peci_request_alloc(struct peci_device *device, u8 >> > tx_len, u8 rx_len) >> > +{ ->> > +???????struct peci_request *req; ->> > +???????u8 *tx_buf, *rx_buf; +>> > + struct peci_request *req; +>> > + u8 *tx_buf, *rx_buf; >> > + ->> > +???????req = kzalloc(sizeof(*req), GFP_KERNEL); ->> > +???????if (!req) ->> > +???????????????return NULL; +>> > + req = kzalloc(sizeof(*req), GFP_KERNEL); +>> > + if (!req) +>> > + return NULL; >> > + ->> > +???????req->device = device; +>> > + req->device = device; >> > + ->> > +???????/* ->> > +??????? * PECI controllers that we are using now don't support DMA, this ->> > +??????? * should be converted to DMA API once support for controllers that +>> > + /* +>> > + * PECI controllers that we are using now don't support DMA, this +>> > + * should be converted to DMA API once support for controllers that >> > do ->> > +??????? * allow it is added to avoid an extra copy. ->> > +??????? */ ->> > +???????if (tx_len) { ->> > +???????????????tx_buf = kzalloc(tx_len, GFP_KERNEL); ->> > +???????????????if (!tx_buf) ->> > +???????????????????????goto err_free_req; ->> > + ->> > +???????????????req->tx.buf = tx_buf; ->> > +???????????????req->tx.len = tx_len; ->> > +???????} ->> > + ->> > +???????if (rx_len) { ->> > +???????????????rx_buf = kzalloc(rx_len, GFP_KERNEL); ->> > +???????????????if (!rx_buf) ->> > +???????????????????????goto err_free_tx; ->> > + ->> > +???????????????req->rx.buf = rx_buf; ->> > +???????????????req->rx.len = rx_len; ->> > +???????} +>> > + * allow it is added to avoid an extra copy. +>> > + */ +>> > + if (tx_len) { +>> > + tx_buf = kzalloc(tx_len, GFP_KERNEL); +>> > + if (!tx_buf) +>> > + goto err_free_req; +>> > + +>> > + req->tx.buf = tx_buf; +>> > + req->tx.len = tx_len; +>> > + } +>> > + +>> > + if (rx_len) { +>> > + rx_buf = kzalloc(rx_len, GFP_KERNEL); +>> > + if (!rx_buf) +>> > + goto err_free_tx; +>> > + +>> > + req->rx.buf = rx_buf; +>> > + req->rx.len = rx_len; +>> > + } >> > + >> >> As long as we're punting on DMA support, could we do the whole thing in ->> a single allocation instead of three?? It'd add some pointer arithmetic, +>> a single allocation instead of three? It'd add some pointer arithmetic, >> but would also simplify the error-handling/deallocation paths a bit. >> >> Or, given that the one controller we're currently supporting has a @@ -370,14 +370,14 @@ by a mutex anyway? >-Iwona > >> ->> > +???????return req; +>> > + return req; >> > + >> > +err_free_tx: ->> > +???????kfree(req->tx.buf); +>> > + kfree(req->tx.buf); >> > +err_free_req: ->> > +???????kfree(req); +>> > + kfree(req); >> > + ->> > +???????return NULL; +>> > + return NULL; >> > +} >> > +EXPORT_SYMBOL_NS_GPL(peci_request_alloc, PECI); >> > + @@ -387,9 +387,9 @@ by a mutex anyway? >> > + */ >> > +void peci_request_free(struct peci_request *req) >> > +{ ->> > +???????kfree(req->rx.buf); ->> > +???????kfree(req->tx.buf); ->> > +???????kfree(req); +>> > + kfree(req->rx.buf); +>> > + kfree(req->tx.buf); +>> > + kfree(req); >> > +} >> > +EXPORT_SYMBOL_NS_GPL(peci_request_free, PECI); >> > diff --git a/drivers/peci/sysfs.c b/drivers/peci/sysfs.c @@ -406,41 +406,41 @@ by a mutex anyway? >> > >> > #include "internal.h" >> > @@ -46,3 +48,35 @@ const struct attribute_group *peci_bus_groups[] = { ->> > ????????&peci_bus_group, ->> > ????????NULL +>> > &peci_bus_group, +>> > NULL >> > }; >> > + >> > +static ssize_t remove_store(struct device *dev, struct device_attribute >> > *attr, ->> > +?????????????????????????? const char *buf, size_t count) +>> > + const char *buf, size_t count) >> > +{ ->> > +???????struct peci_device *device = to_peci_device(dev); ->> > +???????bool res; ->> > +???????int ret; +>> > + struct peci_device *device = to_peci_device(dev); +>> > + bool res; +>> > + int ret; >> > + ->> > +???????ret = kstrtobool(buf, &res); ->> > +???????if (ret) ->> > +???????????????return ret; +>> > + ret = kstrtobool(buf, &res); +>> > + if (ret) +>> > + return ret; >> > + ->> > +???????if (res && device_remove_file_self(dev, attr)) ->> > +???????????????peci_device_destroy(device); +>> > + if (res && device_remove_file_self(dev, attr)) +>> > + peci_device_destroy(device); >> > + ->> > +???????return count; +>> > + return count; >> > +} >> > +static DEVICE_ATTR_IGNORE_LOCKDEP(remove, 0200, NULL, remove_store); >> > + >> > +static struct attribute *peci_device_attrs[] = { ->> > +???????&dev_attr_remove.attr, ->> > +???????NULL +>> > + &dev_attr_remove.attr, +>> > + NULL >> > +}; >> > + >> > +static const struct attribute_group peci_device_group = { ->> > +???????.attrs = peci_device_attrs, +>> > + .attrs = peci_device_attrs, >> > +}; >> > + >> > +const struct attribute_group *peci_device_groups[] = { ->> > +???????&peci_device_group, ->> > +???????NULL +>> > + &peci_device_group, +>> > + NULL >> > +}; >> > -- >> > 2.31.1 diff --git a/a/content_digest b/N2/content_digest index 1620083..25917be 100644 --- a/a/content_digest +++ b/N2/content_digest @@ -3,9 +3,36 @@ "ref\020210727174900.GR8018@packtop\0" "ref\047440a8329ce06c41ca9746db42cb1d66154ea46.camel@intel.com\0" "From\0Zev Weiss <zweiss@equinix.com>\0" - "Subject\0[PATCH 08/14] peci: Add device detection\0" + "Subject\0Re: [PATCH 08/14] peci: Add device detection\0" "Date\0Thu, 29 Jul 2021 20:50:13 +0000\0" - "To\0linux-aspeed@lists.ozlabs.org\0" + "To\0Winiarska" + " Iwona <iwona.winiarska@intel.com>\0" + "Cc\0linux-aspeed@lists.ozlabs.org <linux-aspeed@lists.ozlabs.org>" + linux-doc@vger.kernel.org <linux-doc@vger.kernel.org> + jae.hyun.yoo@linux.intel.com <jae.hyun.yoo@linux.intel.com> + mchehab@kernel.org <mchehab@kernel.org> + corbet@lwn.net <corbet@lwn.net> + openbmc@lists.ozlabs.org <openbmc@lists.ozlabs.org> + x86@kernel.org <x86@kernel.org> + pierre-louis.bossart@linux.intel.com <pierre-louis.bossart@linux.intel.com> + mingo@redhat.com <mingo@redhat.com> + linux@roeck-us.net <linux@roeck-us.net> + devicetree@vger.kernel.org <devicetree@vger.kernel.org> + jdelvare@suse.com <jdelvare@suse.com> + robh+dt@kernel.org <robh+dt@kernel.org> + bp@alien8.de <bp@alien8.de> + Lutomirski + Andy <luto@kernel.org> + tglx@linutronix.de <tglx@linutronix.de> + andriy.shevchenko@linux.intel.com <andriy.shevchenko@linux.intel.com> + linux-arm-kernel@lists.infradead.org <linux-arm-kernel@lists.infradead.org> + linux-hwmon@vger.kernel.org <linux-hwmon@vger.kernel.org> + Luck + Tony <tony.luck@intel.com> + andrew@aj.id.au <andrew@aj.id.au> + gregkh@linuxfoundation.org <gregkh@linuxfoundation.org> + linux-kernel@vger.kernel.org <linux-kernel@vger.kernel.org> + " yazen.ghannam@amd.com <yazen.ghannam@amd.com>\0" "\00:1\0" "b\0" "On Thu, Jul 29, 2021 at 01:55:19PM CDT, Winiarska, Iwona wrote:\n" @@ -21,12 +48,12 @@ ">> > Signed-off-by: Iwona Winiarska <iwona.winiarska@intel.com>\n" ">> > Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>\n" ">> > ---\n" - ">> > drivers/peci/Makefile?? |?? 2 +-\n" - ">> > drivers/peci/core.c???? |? 13 ++++-\n" - ">> > drivers/peci/device.c?? | 111 ++++++++++++++++++++++++++++++++++++++++\n" - ">> > drivers/peci/internal.h |? 15 ++++++\n" - ">> > drivers/peci/request.c? |? 74 +++++++++++++++++++++++++++\n" - ">> > drivers/peci/sysfs.c??? |? 34 ++++++++++++\n" + ">> > drivers/peci/Makefile\302\240\302\240 |\302\240\302\240 2 +-\n" + ">> > drivers/peci/core.c\302\240\302\240\302\240\302\240 |\302\240 13 ++++-\n" + ">> > drivers/peci/device.c\302\240\302\240 | 111 ++++++++++++++++++++++++++++++++++++++++\n" + ">> > drivers/peci/internal.h |\302\240 15 ++++++\n" + ">> > drivers/peci/request.c\302\240 |\302\240 74 +++++++++++++++++++++++++++\n" + ">> > drivers/peci/sysfs.c\302\240\302\240\302\240 |\302\240 34 ++++++++++++\n" ">> > 6 files changed, 246 insertions(+), 3 deletions(-)\n" ">> > create mode 100644 drivers/peci/device.c\n" ">> > create mode 100644 drivers/peci/request.c\n" @@ -52,28 +79,28 @@ ">> >\n" ">> > int peci_controller_scan_devices(struct peci_controller *controller)\n" ">> > {\n" - ">> > -???????/* Just a stub, no support for actual devices yet */\n" - ">> > +???????int ret;\n" - ">> > +???????u8 addr;\n" + ">> > -\302\240\302\240\302\240\302\240\302\240\302\240\302\240/* Just a stub, no support for actual devices yet */\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240int ret;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240u8 addr;\n" ">> > +\n" - ">> > +???????for (addr = PECI_BASE_ADDR; addr < PECI_BASE_ADDR +\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240for (addr = PECI_BASE_ADDR; addr < PECI_BASE_ADDR +\n" ">> > PECI_DEVICE_NUM_MAX; addr++) {\n" - ">> > +???????????????ret = peci_device_create(controller, addr);\n" - ">> > +???????????????if (ret)\n" - ">> > +???????????????????????return ret;\n" - ">> > +???????}\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240ret = peci_device_create(controller, addr);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (ret)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240return ret;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240}\n" ">> > +\n" - ">> > ????????return 0;\n" + ">> > \302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240return 0;\n" ">> > }\n" ">> >\n" ">> > @@ -106,7 +114,8 @@ EXPORT_SYMBOL_NS_GPL(peci_controller_add, PECI);\n" ">> >\n" ">> > static int _unregister(struct device *dev, void *dummy)\n" ">> > {\n" - ">> > -???????/* Just a stub, no support for actual devices yet */\n" - ">> > +???????peci_device_destroy(to_peci_device(dev));\n" + ">> > -\302\240\302\240\302\240\302\240\302\240\302\240\302\240/* Just a stub, no support for actual devices yet */\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240peci_device_destroy(to_peci_device(dev));\n" ">> > +\n" - ">> > ????????return 0;\n" + ">> > \302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240return 0;\n" ">> > }\n" ">> >\n" ">> > diff --git a/drivers/peci/device.c b/drivers/peci/device.c\n" @@ -92,12 +119,12 @@ ">> > +\n" ">> > +static int peci_detect(struct peci_controller *controller, u8 addr)\n" ">> > +{\n" - ">> > +???????struct peci_request *req;\n" - ">> > +???????int ret;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240struct peci_request *req;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240int ret;\n" ">> > +\n" - ">> > +???????req = peci_request_alloc(NULL, 0, 0);\n" - ">> > +???????if (!req)\n" - ">> > +???????????????return -ENOMEM;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240req = peci_request_alloc(NULL, 0, 0);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (!req)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240return -ENOMEM;\n" ">> > +\n" ">>\n" ">> Might be worth a brief comment here noting that an empty request happens\n" @@ -115,45 +142,45 @@ "just make that slightly more explicit.\n" "\n" ">>\n" - ">> > +???????mutex_lock(&controller->bus_lock);\n" - ">> > +???????ret = controller->xfer(controller, addr, req);\n" - ">> > +???????mutex_unlock(&controller->bus_lock);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240mutex_lock(&controller->bus_lock);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240ret = controller->xfer(controller, addr, req);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240mutex_unlock(&controller->bus_lock);\n" ">> > +\n" - ">> > +???????peci_request_free(req);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240peci_request_free(req);\n" ">> > +\n" - ">> > +???????return ret;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240return ret;\n" ">> > +}\n" ">> > +\n" ">> > +static bool peci_addr_valid(u8 addr)\n" ">> > +{\n" - ">> > +???????return addr >= PECI_BASE_ADDR && addr < PECI_BASE_ADDR +\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240return addr >= PECI_BASE_ADDR && addr < PECI_BASE_ADDR +\n" ">> > PECI_DEVICE_NUM_MAX;\n" ">> > +}\n" ">> > +\n" ">> > +static int peci_dev_exists(struct device *dev, void *data)\n" ">> > +{\n" - ">> > +???????struct peci_device *device = to_peci_device(dev);\n" - ">> > +???????u8 *addr = data;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240struct peci_device *device = to_peci_device(dev);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240u8 *addr = data;\n" ">> > +\n" - ">> > +???????if (device->addr == *addr)\n" - ">> > +???????????????return -EBUSY;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (device->addr == *addr)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240return -EBUSY;\n" ">> > +\n" - ">> > +???????return 0;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240return 0;\n" ">> > +}\n" ">> > +\n" ">> > +int peci_device_create(struct peci_controller *controller, u8 addr)\n" ">> > +{\n" - ">> > +???????struct peci_device *device;\n" - ">> > +???????int ret;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240struct peci_device *device;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240int ret;\n" ">> > +\n" - ">> > +???????if (WARN_ON(!peci_addr_valid(addr)))\n" - ">> > +???????????????return -EINVAL;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (WARN_ON(!peci_addr_valid(addr)))\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240return -EINVAL;\n" ">>\n" ">> Wondering about the necessity of this check (and the peci_addr_valid()\n" ">> function) -- as of the end of this patch series, there's only one caller\n" ">> of peci_device_create(), and it's peci_controller_scan_devices() looping\n" ">> from PECI_BASE_ADDR to PECI_BASE_ADDR + PECI_DEVICE_NUM_MAX, so\n" - ">> checking that the address is in that range seems a bit redundant.? Do we\n" + ">> checking that the address is in that range seems a bit redundant.\302\240 Do we\n" ">> anticipate that we might gain additional callers in the future that\n" ">> could run a non-zero risk of passing a bad address?\n" ">\n" @@ -162,25 +189,25 @@ ">\n" ">>\n" ">> > +\n" - ">> > +???????/* Check if we have already detected this device before. */\n" - ">> > +???????ret = device_for_each_child(&controller->dev, &addr,\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240/* Check if we have already detected this device before. */\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240ret = device_for_each_child(&controller->dev, &addr,\n" ">> > peci_dev_exists);\n" - ">> > +???????if (ret)\n" - ">> > +???????????????return 0;\n" - ">> > +\n" - ">> > +???????ret = peci_detect(controller, addr);\n" - ">> > +???????if (ret) {\n" - ">> > +???????????????/*\n" - ">> > +??????????????? * Device not present or host state doesn't allow successful\n" - ">> > +??????????????? * detection at this time.\n" - ">> > +??????????????? */\n" - ">> > +???????????????if (ret == -EIO || ret == -ETIMEDOUT)\n" - ">> > +???????????????????????return 0;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (ret)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240return 0;\n" + ">> > +\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240ret = peci_detect(controller, addr);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (ret) {\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240/*\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240 * Device not present or host state doesn't allow successful\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240 * detection at this time.\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240 */\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (ret == -EIO || ret == -ETIMEDOUT)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240return 0;\n" ">>\n" - ">> Do we really want to be ignoring EIO here?? From a look at\n" + ">> Do we really want to be ignoring EIO here?\302\240 From a look at\n" ">> aspeed_peci_xfer(), it looks like the only path that would produce that\n" ">> is the non-timeout, non-CMD_DONE case, which I guess happens on\n" - ">> contention or FCS errors and such.? Should we maybe have some automatic\n" + ">> contention or FCS errors and such.\302\240 Should we maybe have some automatic\n" ">> (limited) retry loop for cases like those?\n" ">\n" ">Yes, we want to ignore EIO here.\n" @@ -189,53 +216,53 @@ ">\n" ">>\n" ">> > +\n" - ">> > +???????????????return ret;\n" - ">> > +???????}\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240return ret;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240}\n" ">> > +\n" - ">> > +???????device = kzalloc(sizeof(*device), GFP_KERNEL);\n" - ">> > +???????if (!device)\n" - ">> > +???????????????return -ENOMEM;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240device = kzalloc(sizeof(*device), GFP_KERNEL);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (!device)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240return -ENOMEM;\n" ">> > +\n" - ">> > +???????device->controller = controller;\n" - ">> > +???????device->addr = addr;\n" - ">> > +???????device->dev.parent = &device->controller->dev;\n" - ">> > +???????device->dev.bus = &peci_bus_type;\n" - ">> > +???????device->dev.type = &peci_device_type;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240device->controller = controller;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240device->addr = addr;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240device->dev.parent = &device->controller->dev;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240device->dev.bus = &peci_bus_type;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240device->dev.type = &peci_device_type;\n" ">> > +\n" - ">> > +???????ret = dev_set_name(&device->dev, \"%d-%02x\", controller->id, device-\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240ret = dev_set_name(&device->dev, \"%d-%02x\", controller->id, device-\n" ">> > >addr);\n" - ">> > +???????if (ret)\n" - ">> > +???????????????goto err_free;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (ret)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240goto err_free;\n" ">> > +\n" - ">> > +???????ret = device_register(&device->dev);\n" - ">> > +???????if (ret)\n" - ">> > +???????????????goto err_put;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240ret = device_register(&device->dev);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (ret)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240goto err_put;\n" ">> > +\n" - ">> > +???????return 0;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240return 0;\n" ">> > +\n" ">> > +err_put:\n" - ">> > +???????put_device(&device->dev);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240put_device(&device->dev);\n" ">> > +err_free:\n" - ">> > +???????kfree(device);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240kfree(device);\n" ">> > +\n" - ">> > +???????return ret;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240return ret;\n" ">> > +}\n" ">> > +\n" ">> > +void peci_device_destroy(struct peci_device *device)\n" ">> > +{\n" - ">> > +???????device_unregister(&device->dev);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240device_unregister(&device->dev);\n" ">> > +}\n" ">> > +\n" ">> > +static void peci_device_release(struct device *dev)\n" ">> > +{\n" - ">> > +???????struct peci_device *device = to_peci_device(dev);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240struct peci_device *device = to_peci_device(dev);\n" ">> > +\n" - ">> > +???????kfree(device);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240kfree(device);\n" ">> > +}\n" ">> > +\n" ">> > +struct device_type peci_device_type = {\n" - ">> > +???????.groups?????????= peci_device_groups,\n" - ">> > +???????.release????????= peci_device_release,\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240.groups\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240= peci_device_groups,\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240.release\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240= peci_device_release,\n" ">> > +};\n" ">> > diff --git a/drivers/peci/internal.h b/drivers/peci/internal.h\n" ">> > index 80c61bcdfc6b..6b139adaf6b8 100644\n" @@ -249,8 +276,8 @@ ">> > +struct peci_request;\n" ">> > +\n" ">> > +/* PECI CPU address range 0x30-0x37 */\n" - ">> > +#define PECI_BASE_ADDR?????????0x30\n" - ">> > +#define PECI_DEVICE_NUM_MAX????????????8\n" + ">> > +#define PECI_BASE_ADDR\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\2400x30\n" + ">> > +#define PECI_DEVICE_NUM_MAX\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\2408\n" ">> > +\n" ">> > +struct peci_request *peci_request_alloc(struct peci_device *device, u8\n" ">> > tx_len, u8 rx_len);\n" @@ -293,42 +320,42 @@ ">> > +struct peci_request *peci_request_alloc(struct peci_device *device, u8\n" ">> > tx_len, u8 rx_len)\n" ">> > +{\n" - ">> > +???????struct peci_request *req;\n" - ">> > +???????u8 *tx_buf, *rx_buf;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240struct peci_request *req;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240u8 *tx_buf, *rx_buf;\n" ">> > +\n" - ">> > +???????req = kzalloc(sizeof(*req), GFP_KERNEL);\n" - ">> > +???????if (!req)\n" - ">> > +???????????????return NULL;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240req = kzalloc(sizeof(*req), GFP_KERNEL);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (!req)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240return NULL;\n" ">> > +\n" - ">> > +???????req->device = device;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240req->device = device;\n" ">> > +\n" - ">> > +???????/*\n" - ">> > +??????? * PECI controllers that we are using now don't support DMA, this\n" - ">> > +??????? * should be converted to DMA API once support for controllers that\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240/*\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240 * PECI controllers that we are using now don't support DMA, this\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240 * should be converted to DMA API once support for controllers that\n" ">> > do\n" - ">> > +??????? * allow it is added to avoid an extra copy.\n" - ">> > +??????? */\n" - ">> > +???????if (tx_len) {\n" - ">> > +???????????????tx_buf = kzalloc(tx_len, GFP_KERNEL);\n" - ">> > +???????????????if (!tx_buf)\n" - ">> > +???????????????????????goto err_free_req;\n" - ">> > +\n" - ">> > +???????????????req->tx.buf = tx_buf;\n" - ">> > +???????????????req->tx.len = tx_len;\n" - ">> > +???????}\n" - ">> > +\n" - ">> > +???????if (rx_len) {\n" - ">> > +???????????????rx_buf = kzalloc(rx_len, GFP_KERNEL);\n" - ">> > +???????????????if (!rx_buf)\n" - ">> > +???????????????????????goto err_free_tx;\n" - ">> > +\n" - ">> > +???????????????req->rx.buf = rx_buf;\n" - ">> > +???????????????req->rx.len = rx_len;\n" - ">> > +???????}\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240 * allow it is added to avoid an extra copy.\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240 */\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (tx_len) {\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240tx_buf = kzalloc(tx_len, GFP_KERNEL);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (!tx_buf)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240goto err_free_req;\n" + ">> > +\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240req->tx.buf = tx_buf;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240req->tx.len = tx_len;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240}\n" + ">> > +\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (rx_len) {\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240rx_buf = kzalloc(rx_len, GFP_KERNEL);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (!rx_buf)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240goto err_free_tx;\n" + ">> > +\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240req->rx.buf = rx_buf;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240req->rx.len = rx_len;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240}\n" ">> > +\n" ">>\n" ">> As long as we're punting on DMA support, could we do the whole thing in\n" - ">> a single allocation instead of three?? It'd add some pointer arithmetic,\n" + ">> a single allocation instead of three?\302\240 It'd add some pointer arithmetic,\n" ">> but would also simplify the error-handling/deallocation paths a bit.\n" ">>\n" ">> Or, given that the one controller we're currently supporting has a\n" @@ -380,14 +407,14 @@ ">-Iwona\n" ">\n" ">>\n" - ">> > +???????return req;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240return req;\n" ">> > +\n" ">> > +err_free_tx:\n" - ">> > +???????kfree(req->tx.buf);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240kfree(req->tx.buf);\n" ">> > +err_free_req:\n" - ">> > +???????kfree(req);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240kfree(req);\n" ">> > +\n" - ">> > +???????return NULL;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240return NULL;\n" ">> > +}\n" ">> > +EXPORT_SYMBOL_NS_GPL(peci_request_alloc, PECI);\n" ">> > +\n" @@ -397,9 +424,9 @@ ">> > + */\n" ">> > +void peci_request_free(struct peci_request *req)\n" ">> > +{\n" - ">> > +???????kfree(req->rx.buf);\n" - ">> > +???????kfree(req->tx.buf);\n" - ">> > +???????kfree(req);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240kfree(req->rx.buf);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240kfree(req->tx.buf);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240kfree(req);\n" ">> > +}\n" ">> > +EXPORT_SYMBOL_NS_GPL(peci_request_free, PECI);\n" ">> > diff --git a/drivers/peci/sysfs.c b/drivers/peci/sysfs.c\n" @@ -416,44 +443,44 @@ ">> >\n" ">> > #include \"internal.h\"\n" ">> > @@ -46,3 +48,35 @@ const struct attribute_group *peci_bus_groups[] = {\n" - ">> > ????????&peci_bus_group,\n" - ">> > ????????NULL\n" + ">> > \302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240&peci_bus_group,\n" + ">> > \302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240NULL\n" ">> > };\n" ">> > +\n" ">> > +static ssize_t remove_store(struct device *dev, struct device_attribute\n" ">> > *attr,\n" - ">> > +?????????????????????????? const char *buf, size_t count)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240 const char *buf, size_t count)\n" ">> > +{\n" - ">> > +???????struct peci_device *device = to_peci_device(dev);\n" - ">> > +???????bool res;\n" - ">> > +???????int ret;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240struct peci_device *device = to_peci_device(dev);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240bool res;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240int ret;\n" ">> > +\n" - ">> > +???????ret = kstrtobool(buf, &res);\n" - ">> > +???????if (ret)\n" - ">> > +???????????????return ret;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240ret = kstrtobool(buf, &res);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (ret)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240return ret;\n" ">> > +\n" - ">> > +???????if (res && device_remove_file_self(dev, attr))\n" - ">> > +???????????????peci_device_destroy(device);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (res && device_remove_file_self(dev, attr))\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240peci_device_destroy(device);\n" ">> > +\n" - ">> > +???????return count;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240return count;\n" ">> > +}\n" ">> > +static DEVICE_ATTR_IGNORE_LOCKDEP(remove, 0200, NULL, remove_store);\n" ">> > +\n" ">> > +static struct attribute *peci_device_attrs[] = {\n" - ">> > +???????&dev_attr_remove.attr,\n" - ">> > +???????NULL\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240&dev_attr_remove.attr,\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240NULL\n" ">> > +};\n" ">> > +\n" ">> > +static const struct attribute_group peci_device_group = {\n" - ">> > +???????.attrs = peci_device_attrs,\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240.attrs = peci_device_attrs,\n" ">> > +};\n" ">> > +\n" ">> > +const struct attribute_group *peci_device_groups[] = {\n" - ">> > +???????&peci_device_group,\n" - ">> > +???????NULL\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240&peci_device_group,\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240NULL\n" ">> > +};\n" ">> > --\n" ">> > 2.31.1\n" > -1d638fbf92fea69e3e8bcf8a80ff14134bac0a1c6d90a619556236ffcef3d338 +9147d79482ce06eec857dc31e8d0bccb37ee32bc9620f0e978c24a9e5c5f1fae
diff --git a/a/1.txt b/N3/1.txt index 7e773e1..f568ce6 100644 --- a/a/1.txt +++ b/N3/1.txt @@ -11,12 +11,12 @@ On Thu, Jul 29, 2021 at 01:55:19PM CDT, Winiarska, Iwona wrote: >> > Signed-off-by: Iwona Winiarska <iwona.winiarska@intel.com> >> > Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> >> > --- ->> > drivers/peci/Makefile?? |?? 2 +- ->> > drivers/peci/core.c???? |? 13 ++++- ->> > drivers/peci/device.c?? | 111 ++++++++++++++++++++++++++++++++++++++++ ->> > drivers/peci/internal.h |? 15 ++++++ ->> > drivers/peci/request.c? |? 74 +++++++++++++++++++++++++++ ->> > drivers/peci/sysfs.c??? |? 34 ++++++++++++ +>> > drivers/peci/Makefile | 2 +- +>> > drivers/peci/core.c | 13 ++++- +>> > drivers/peci/device.c | 111 ++++++++++++++++++++++++++++++++++++++++ +>> > drivers/peci/internal.h | 15 ++++++ +>> > drivers/peci/request.c | 74 +++++++++++++++++++++++++++ +>> > drivers/peci/sysfs.c | 34 ++++++++++++ >> > 6 files changed, 246 insertions(+), 3 deletions(-) >> > create mode 100644 drivers/peci/device.c >> > create mode 100644 drivers/peci/request.c @@ -42,28 +42,28 @@ On Thu, Jul 29, 2021 at 01:55:19PM CDT, Winiarska, Iwona wrote: >> > >> > int peci_controller_scan_devices(struct peci_controller *controller) >> > { ->> > -???????/* Just a stub, no support for actual devices yet */ ->> > +???????int ret; ->> > +???????u8 addr; +>> > - /* Just a stub, no support for actual devices yet */ +>> > + int ret; +>> > + u8 addr; >> > + ->> > +???????for (addr = PECI_BASE_ADDR; addr < PECI_BASE_ADDR + +>> > + for (addr = PECI_BASE_ADDR; addr < PECI_BASE_ADDR + >> > PECI_DEVICE_NUM_MAX; addr++) { ->> > +???????????????ret = peci_device_create(controller, addr); ->> > +???????????????if (ret) ->> > +???????????????????????return ret; ->> > +???????} +>> > + ret = peci_device_create(controller, addr); +>> > + if (ret) +>> > + return ret; +>> > + } >> > + ->> > ????????return 0; +>> > return 0; >> > } >> > >> > @@ -106,7 +114,8 @@ EXPORT_SYMBOL_NS_GPL(peci_controller_add, PECI); >> > >> > static int _unregister(struct device *dev, void *dummy) >> > { ->> > -???????/* Just a stub, no support for actual devices yet */ ->> > +???????peci_device_destroy(to_peci_device(dev)); +>> > - /* Just a stub, no support for actual devices yet */ +>> > + peci_device_destroy(to_peci_device(dev)); >> > + ->> > ????????return 0; +>> > return 0; >> > } >> > >> > diff --git a/drivers/peci/device.c b/drivers/peci/device.c @@ -82,12 +82,12 @@ On Thu, Jul 29, 2021 at 01:55:19PM CDT, Winiarska, Iwona wrote: >> > + >> > +static int peci_detect(struct peci_controller *controller, u8 addr) >> > +{ ->> > +???????struct peci_request *req; ->> > +???????int ret; +>> > + struct peci_request *req; +>> > + int ret; >> > + ->> > +???????req = peci_request_alloc(NULL, 0, 0); ->> > +???????if (!req) ->> > +???????????????return -ENOMEM; +>> > + req = peci_request_alloc(NULL, 0, 0); +>> > + if (!req) +>> > + return -ENOMEM; >> > + >> >> Might be worth a brief comment here noting that an empty request happens @@ -105,45 +105,45 @@ PECI_CMD_PING' or anything), so I was hoping for something that would just make that slightly more explicit. >> ->> > +???????mutex_lock(&controller->bus_lock); ->> > +???????ret = controller->xfer(controller, addr, req); ->> > +???????mutex_unlock(&controller->bus_lock); +>> > + mutex_lock(&controller->bus_lock); +>> > + ret = controller->xfer(controller, addr, req); +>> > + mutex_unlock(&controller->bus_lock); >> > + ->> > +???????peci_request_free(req); +>> > + peci_request_free(req); >> > + ->> > +???????return ret; +>> > + return ret; >> > +} >> > + >> > +static bool peci_addr_valid(u8 addr) >> > +{ ->> > +???????return addr >= PECI_BASE_ADDR && addr < PECI_BASE_ADDR + +>> > + return addr >= PECI_BASE_ADDR && addr < PECI_BASE_ADDR + >> > PECI_DEVICE_NUM_MAX; >> > +} >> > + >> > +static int peci_dev_exists(struct device *dev, void *data) >> > +{ ->> > +???????struct peci_device *device = to_peci_device(dev); ->> > +???????u8 *addr = data; +>> > + struct peci_device *device = to_peci_device(dev); +>> > + u8 *addr = data; >> > + ->> > +???????if (device->addr == *addr) ->> > +???????????????return -EBUSY; +>> > + if (device->addr == *addr) +>> > + return -EBUSY; >> > + ->> > +???????return 0; +>> > + return 0; >> > +} >> > + >> > +int peci_device_create(struct peci_controller *controller, u8 addr) >> > +{ ->> > +???????struct peci_device *device; ->> > +???????int ret; +>> > + struct peci_device *device; +>> > + int ret; >> > + ->> > +???????if (WARN_ON(!peci_addr_valid(addr))) ->> > +???????????????return -EINVAL; +>> > + if (WARN_ON(!peci_addr_valid(addr))) +>> > + return -EINVAL; >> >> Wondering about the necessity of this check (and the peci_addr_valid() >> function) -- as of the end of this patch series, there's only one caller >> of peci_device_create(), and it's peci_controller_scan_devices() looping >> from PECI_BASE_ADDR to PECI_BASE_ADDR + PECI_DEVICE_NUM_MAX, so ->> checking that the address is in that range seems a bit redundant.? Do we +>> checking that the address is in that range seems a bit redundant. Do we >> anticipate that we might gain additional callers in the future that >> could run a non-zero risk of passing a bad address? > @@ -152,25 +152,25 @@ just make that slightly more explicit. > >> >> > + ->> > +???????/* Check if we have already detected this device before. */ ->> > +???????ret = device_for_each_child(&controller->dev, &addr, +>> > + /* Check if we have already detected this device before. */ +>> > + ret = device_for_each_child(&controller->dev, &addr, >> > peci_dev_exists); ->> > +???????if (ret) ->> > +???????????????return 0; ->> > + ->> > +???????ret = peci_detect(controller, addr); ->> > +???????if (ret) { ->> > +???????????????/* ->> > +??????????????? * Device not present or host state doesn't allow successful ->> > +??????????????? * detection at this time. ->> > +??????????????? */ ->> > +???????????????if (ret == -EIO || ret == -ETIMEDOUT) ->> > +???????????????????????return 0; +>> > + if (ret) +>> > + return 0; +>> > + +>> > + ret = peci_detect(controller, addr); +>> > + if (ret) { +>> > + /* +>> > + * Device not present or host state doesn't allow successful +>> > + * detection at this time. +>> > + */ +>> > + if (ret == -EIO || ret == -ETIMEDOUT) +>> > + return 0; >> ->> Do we really want to be ignoring EIO here?? From a look at +>> Do we really want to be ignoring EIO here? From a look at >> aspeed_peci_xfer(), it looks like the only path that would produce that >> is the non-timeout, non-CMD_DONE case, which I guess happens on ->> contention or FCS errors and such.? Should we maybe have some automatic +>> contention or FCS errors and such. Should we maybe have some automatic >> (limited) retry loop for cases like those? > >Yes, we want to ignore EIO here. @@ -179,53 +179,53 @@ just make that slightly more explicit. > >> >> > + ->> > +???????????????return ret; ->> > +???????} +>> > + return ret; +>> > + } >> > + ->> > +???????device = kzalloc(sizeof(*device), GFP_KERNEL); ->> > +???????if (!device) ->> > +???????????????return -ENOMEM; +>> > + device = kzalloc(sizeof(*device), GFP_KERNEL); +>> > + if (!device) +>> > + return -ENOMEM; >> > + ->> > +???????device->controller = controller; ->> > +???????device->addr = addr; ->> > +???????device->dev.parent = &device->controller->dev; ->> > +???????device->dev.bus = &peci_bus_type; ->> > +???????device->dev.type = &peci_device_type; +>> > + device->controller = controller; +>> > + device->addr = addr; +>> > + device->dev.parent = &device->controller->dev; +>> > + device->dev.bus = &peci_bus_type; +>> > + device->dev.type = &peci_device_type; >> > + ->> > +???????ret = dev_set_name(&device->dev, "%d-%02x", controller->id, device- +>> > + ret = dev_set_name(&device->dev, "%d-%02x", controller->id, device- >> > >addr); ->> > +???????if (ret) ->> > +???????????????goto err_free; +>> > + if (ret) +>> > + goto err_free; >> > + ->> > +???????ret = device_register(&device->dev); ->> > +???????if (ret) ->> > +???????????????goto err_put; +>> > + ret = device_register(&device->dev); +>> > + if (ret) +>> > + goto err_put; >> > + ->> > +???????return 0; +>> > + return 0; >> > + >> > +err_put: ->> > +???????put_device(&device->dev); +>> > + put_device(&device->dev); >> > +err_free: ->> > +???????kfree(device); +>> > + kfree(device); >> > + ->> > +???????return ret; +>> > + return ret; >> > +} >> > + >> > +void peci_device_destroy(struct peci_device *device) >> > +{ ->> > +???????device_unregister(&device->dev); +>> > + device_unregister(&device->dev); >> > +} >> > + >> > +static void peci_device_release(struct device *dev) >> > +{ ->> > +???????struct peci_device *device = to_peci_device(dev); +>> > + struct peci_device *device = to_peci_device(dev); >> > + ->> > +???????kfree(device); +>> > + kfree(device); >> > +} >> > + >> > +struct device_type peci_device_type = { ->> > +???????.groups?????????= peci_device_groups, ->> > +???????.release????????= peci_device_release, +>> > + .groups = peci_device_groups, +>> > + .release = peci_device_release, >> > +}; >> > diff --git a/drivers/peci/internal.h b/drivers/peci/internal.h >> > index 80c61bcdfc6b..6b139adaf6b8 100644 @@ -239,8 +239,8 @@ just make that slightly more explicit. >> > +struct peci_request; >> > + >> > +/* PECI CPU address range 0x30-0x37 */ ->> > +#define PECI_BASE_ADDR?????????0x30 ->> > +#define PECI_DEVICE_NUM_MAX????????????8 +>> > +#define PECI_BASE_ADDR 0x30 +>> > +#define PECI_DEVICE_NUM_MAX 8 >> > + >> > +struct peci_request *peci_request_alloc(struct peci_device *device, u8 >> > tx_len, u8 rx_len); @@ -283,42 +283,42 @@ just make that slightly more explicit. >> > +struct peci_request *peci_request_alloc(struct peci_device *device, u8 >> > tx_len, u8 rx_len) >> > +{ ->> > +???????struct peci_request *req; ->> > +???????u8 *tx_buf, *rx_buf; +>> > + struct peci_request *req; +>> > + u8 *tx_buf, *rx_buf; >> > + ->> > +???????req = kzalloc(sizeof(*req), GFP_KERNEL); ->> > +???????if (!req) ->> > +???????????????return NULL; +>> > + req = kzalloc(sizeof(*req), GFP_KERNEL); +>> > + if (!req) +>> > + return NULL; >> > + ->> > +???????req->device = device; +>> > + req->device = device; >> > + ->> > +???????/* ->> > +??????? * PECI controllers that we are using now don't support DMA, this ->> > +??????? * should be converted to DMA API once support for controllers that +>> > + /* +>> > + * PECI controllers that we are using now don't support DMA, this +>> > + * should be converted to DMA API once support for controllers that >> > do ->> > +??????? * allow it is added to avoid an extra copy. ->> > +??????? */ ->> > +???????if (tx_len) { ->> > +???????????????tx_buf = kzalloc(tx_len, GFP_KERNEL); ->> > +???????????????if (!tx_buf) ->> > +???????????????????????goto err_free_req; ->> > + ->> > +???????????????req->tx.buf = tx_buf; ->> > +???????????????req->tx.len = tx_len; ->> > +???????} ->> > + ->> > +???????if (rx_len) { ->> > +???????????????rx_buf = kzalloc(rx_len, GFP_KERNEL); ->> > +???????????????if (!rx_buf) ->> > +???????????????????????goto err_free_tx; ->> > + ->> > +???????????????req->rx.buf = rx_buf; ->> > +???????????????req->rx.len = rx_len; ->> > +???????} +>> > + * allow it is added to avoid an extra copy. +>> > + */ +>> > + if (tx_len) { +>> > + tx_buf = kzalloc(tx_len, GFP_KERNEL); +>> > + if (!tx_buf) +>> > + goto err_free_req; +>> > + +>> > + req->tx.buf = tx_buf; +>> > + req->tx.len = tx_len; +>> > + } +>> > + +>> > + if (rx_len) { +>> > + rx_buf = kzalloc(rx_len, GFP_KERNEL); +>> > + if (!rx_buf) +>> > + goto err_free_tx; +>> > + +>> > + req->rx.buf = rx_buf; +>> > + req->rx.len = rx_len; +>> > + } >> > + >> >> As long as we're punting on DMA support, could we do the whole thing in ->> a single allocation instead of three?? It'd add some pointer arithmetic, +>> a single allocation instead of three? It'd add some pointer arithmetic, >> but would also simplify the error-handling/deallocation paths a bit. >> >> Or, given that the one controller we're currently supporting has a @@ -370,14 +370,14 @@ by a mutex anyway? >-Iwona > >> ->> > +???????return req; +>> > + return req; >> > + >> > +err_free_tx: ->> > +???????kfree(req->tx.buf); +>> > + kfree(req->tx.buf); >> > +err_free_req: ->> > +???????kfree(req); +>> > + kfree(req); >> > + ->> > +???????return NULL; +>> > + return NULL; >> > +} >> > +EXPORT_SYMBOL_NS_GPL(peci_request_alloc, PECI); >> > + @@ -387,9 +387,9 @@ by a mutex anyway? >> > + */ >> > +void peci_request_free(struct peci_request *req) >> > +{ ->> > +???????kfree(req->rx.buf); ->> > +???????kfree(req->tx.buf); ->> > +???????kfree(req); +>> > + kfree(req->rx.buf); +>> > + kfree(req->tx.buf); +>> > + kfree(req); >> > +} >> > +EXPORT_SYMBOL_NS_GPL(peci_request_free, PECI); >> > diff --git a/drivers/peci/sysfs.c b/drivers/peci/sysfs.c @@ -406,42 +406,46 @@ by a mutex anyway? >> > >> > #include "internal.h" >> > @@ -46,3 +48,35 @@ const struct attribute_group *peci_bus_groups[] = { ->> > ????????&peci_bus_group, ->> > ????????NULL +>> > &peci_bus_group, +>> > NULL >> > }; >> > + >> > +static ssize_t remove_store(struct device *dev, struct device_attribute >> > *attr, ->> > +?????????????????????????? const char *buf, size_t count) +>> > + const char *buf, size_t count) >> > +{ ->> > +???????struct peci_device *device = to_peci_device(dev); ->> > +???????bool res; ->> > +???????int ret; +>> > + struct peci_device *device = to_peci_device(dev); +>> > + bool res; +>> > + int ret; >> > + ->> > +???????ret = kstrtobool(buf, &res); ->> > +???????if (ret) ->> > +???????????????return ret; +>> > + ret = kstrtobool(buf, &res); +>> > + if (ret) +>> > + return ret; >> > + ->> > +???????if (res && device_remove_file_self(dev, attr)) ->> > +???????????????peci_device_destroy(device); +>> > + if (res && device_remove_file_self(dev, attr)) +>> > + peci_device_destroy(device); >> > + ->> > +???????return count; +>> > + return count; >> > +} >> > +static DEVICE_ATTR_IGNORE_LOCKDEP(remove, 0200, NULL, remove_store); >> > + >> > +static struct attribute *peci_device_attrs[] = { ->> > +???????&dev_attr_remove.attr, ->> > +???????NULL +>> > + &dev_attr_remove.attr, +>> > + NULL >> > +}; >> > + >> > +static const struct attribute_group peci_device_group = { ->> > +???????.attrs = peci_device_attrs, +>> > + .attrs = peci_device_attrs, >> > +}; >> > + >> > +const struct attribute_group *peci_device_groups[] = { ->> > +???????&peci_device_group, ->> > +???????NULL +>> > + &peci_device_group, +>> > + NULL >> > +}; >> > -- >> > 2.31.1 > +_______________________________________________ +linux-arm-kernel mailing list +linux-arm-kernel@lists.infradead.org +http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/a/content_digest b/N3/content_digest index 1620083..7f48ce5 100644 --- a/a/content_digest +++ b/N3/content_digest @@ -3,9 +3,36 @@ "ref\020210727174900.GR8018@packtop\0" "ref\047440a8329ce06c41ca9746db42cb1d66154ea46.camel@intel.com\0" "From\0Zev Weiss <zweiss@equinix.com>\0" - "Subject\0[PATCH 08/14] peci: Add device detection\0" + "Subject\0Re: [PATCH 08/14] peci: Add device detection\0" "Date\0Thu, 29 Jul 2021 20:50:13 +0000\0" - "To\0linux-aspeed@lists.ozlabs.org\0" + "To\0Winiarska" + " Iwona <iwona.winiarska@intel.com>\0" + "Cc\0corbet@lwn.net <corbet@lwn.net>" + jae.hyun.yoo@linux.intel.com <jae.hyun.yoo@linux.intel.com> + Lutomirski + Andy <luto@kernel.org> + linux-hwmon@vger.kernel.org <linux-hwmon@vger.kernel.org> + Luck + Tony <tony.luck@intel.com> + andrew@aj.id.au <andrew@aj.id.au> + mchehab@kernel.org <mchehab@kernel.org> + jdelvare@suse.com <jdelvare@suse.com> + linux-kernel@vger.kernel.org <linux-kernel@vger.kernel.org> + mingo@redhat.com <mingo@redhat.com> + devicetree@vger.kernel.org <devicetree@vger.kernel.org> + tglx@linutronix.de <tglx@linutronix.de> + linux@roeck-us.net <linux@roeck-us.net> + linux-aspeed@lists.ozlabs.org <linux-aspeed@lists.ozlabs.org> + linux-doc@vger.kernel.org <linux-doc@vger.kernel.org> + yazen.ghannam@amd.com <yazen.ghannam@amd.com> + robh+dt@kernel.org <robh+dt@kernel.org> + openbmc@lists.ozlabs.org <openbmc@lists.ozlabs.org> + bp@alien8.de <bp@alien8.de> + linux-arm-kernel@lists.infradead.org <linux-arm-kernel@lists.infradead.org> + pierre-louis.bossart@linux.intel.com <pierre-louis.bossart@linux.intel.com> + andriy.shevchenko@linux.intel.com <andriy.shevchenko@linux.intel.com> + x86@kernel.org <x86@kernel.org> + " gregkh@linuxfoundation.org <gregkh@linuxfoundation.org>\0" "\00:1\0" "b\0" "On Thu, Jul 29, 2021 at 01:55:19PM CDT, Winiarska, Iwona wrote:\n" @@ -21,12 +48,12 @@ ">> > Signed-off-by: Iwona Winiarska <iwona.winiarska@intel.com>\n" ">> > Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>\n" ">> > ---\n" - ">> > drivers/peci/Makefile?? |?? 2 +-\n" - ">> > drivers/peci/core.c???? |? 13 ++++-\n" - ">> > drivers/peci/device.c?? | 111 ++++++++++++++++++++++++++++++++++++++++\n" - ">> > drivers/peci/internal.h |? 15 ++++++\n" - ">> > drivers/peci/request.c? |? 74 +++++++++++++++++++++++++++\n" - ">> > drivers/peci/sysfs.c??? |? 34 ++++++++++++\n" + ">> > drivers/peci/Makefile\302\240\302\240 |\302\240\302\240 2 +-\n" + ">> > drivers/peci/core.c\302\240\302\240\302\240\302\240 |\302\240 13 ++++-\n" + ">> > drivers/peci/device.c\302\240\302\240 | 111 ++++++++++++++++++++++++++++++++++++++++\n" + ">> > drivers/peci/internal.h |\302\240 15 ++++++\n" + ">> > drivers/peci/request.c\302\240 |\302\240 74 +++++++++++++++++++++++++++\n" + ">> > drivers/peci/sysfs.c\302\240\302\240\302\240 |\302\240 34 ++++++++++++\n" ">> > 6 files changed, 246 insertions(+), 3 deletions(-)\n" ">> > create mode 100644 drivers/peci/device.c\n" ">> > create mode 100644 drivers/peci/request.c\n" @@ -52,28 +79,28 @@ ">> >\n" ">> > int peci_controller_scan_devices(struct peci_controller *controller)\n" ">> > {\n" - ">> > -???????/* Just a stub, no support for actual devices yet */\n" - ">> > +???????int ret;\n" - ">> > +???????u8 addr;\n" + ">> > -\302\240\302\240\302\240\302\240\302\240\302\240\302\240/* Just a stub, no support for actual devices yet */\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240int ret;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240u8 addr;\n" ">> > +\n" - ">> > +???????for (addr = PECI_BASE_ADDR; addr < PECI_BASE_ADDR +\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240for (addr = PECI_BASE_ADDR; addr < PECI_BASE_ADDR +\n" ">> > PECI_DEVICE_NUM_MAX; addr++) {\n" - ">> > +???????????????ret = peci_device_create(controller, addr);\n" - ">> > +???????????????if (ret)\n" - ">> > +???????????????????????return ret;\n" - ">> > +???????}\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240ret = peci_device_create(controller, addr);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (ret)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240return ret;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240}\n" ">> > +\n" - ">> > ????????return 0;\n" + ">> > \302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240return 0;\n" ">> > }\n" ">> >\n" ">> > @@ -106,7 +114,8 @@ EXPORT_SYMBOL_NS_GPL(peci_controller_add, PECI);\n" ">> >\n" ">> > static int _unregister(struct device *dev, void *dummy)\n" ">> > {\n" - ">> > -???????/* Just a stub, no support for actual devices yet */\n" - ">> > +???????peci_device_destroy(to_peci_device(dev));\n" + ">> > -\302\240\302\240\302\240\302\240\302\240\302\240\302\240/* Just a stub, no support for actual devices yet */\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240peci_device_destroy(to_peci_device(dev));\n" ">> > +\n" - ">> > ????????return 0;\n" + ">> > \302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240return 0;\n" ">> > }\n" ">> >\n" ">> > diff --git a/drivers/peci/device.c b/drivers/peci/device.c\n" @@ -92,12 +119,12 @@ ">> > +\n" ">> > +static int peci_detect(struct peci_controller *controller, u8 addr)\n" ">> > +{\n" - ">> > +???????struct peci_request *req;\n" - ">> > +???????int ret;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240struct peci_request *req;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240int ret;\n" ">> > +\n" - ">> > +???????req = peci_request_alloc(NULL, 0, 0);\n" - ">> > +???????if (!req)\n" - ">> > +???????????????return -ENOMEM;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240req = peci_request_alloc(NULL, 0, 0);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (!req)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240return -ENOMEM;\n" ">> > +\n" ">>\n" ">> Might be worth a brief comment here noting that an empty request happens\n" @@ -115,45 +142,45 @@ "just make that slightly more explicit.\n" "\n" ">>\n" - ">> > +???????mutex_lock(&controller->bus_lock);\n" - ">> > +???????ret = controller->xfer(controller, addr, req);\n" - ">> > +???????mutex_unlock(&controller->bus_lock);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240mutex_lock(&controller->bus_lock);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240ret = controller->xfer(controller, addr, req);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240mutex_unlock(&controller->bus_lock);\n" ">> > +\n" - ">> > +???????peci_request_free(req);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240peci_request_free(req);\n" ">> > +\n" - ">> > +???????return ret;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240return ret;\n" ">> > +}\n" ">> > +\n" ">> > +static bool peci_addr_valid(u8 addr)\n" ">> > +{\n" - ">> > +???????return addr >= PECI_BASE_ADDR && addr < PECI_BASE_ADDR +\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240return addr >= PECI_BASE_ADDR && addr < PECI_BASE_ADDR +\n" ">> > PECI_DEVICE_NUM_MAX;\n" ">> > +}\n" ">> > +\n" ">> > +static int peci_dev_exists(struct device *dev, void *data)\n" ">> > +{\n" - ">> > +???????struct peci_device *device = to_peci_device(dev);\n" - ">> > +???????u8 *addr = data;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240struct peci_device *device = to_peci_device(dev);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240u8 *addr = data;\n" ">> > +\n" - ">> > +???????if (device->addr == *addr)\n" - ">> > +???????????????return -EBUSY;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (device->addr == *addr)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240return -EBUSY;\n" ">> > +\n" - ">> > +???????return 0;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240return 0;\n" ">> > +}\n" ">> > +\n" ">> > +int peci_device_create(struct peci_controller *controller, u8 addr)\n" ">> > +{\n" - ">> > +???????struct peci_device *device;\n" - ">> > +???????int ret;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240struct peci_device *device;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240int ret;\n" ">> > +\n" - ">> > +???????if (WARN_ON(!peci_addr_valid(addr)))\n" - ">> > +???????????????return -EINVAL;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (WARN_ON(!peci_addr_valid(addr)))\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240return -EINVAL;\n" ">>\n" ">> Wondering about the necessity of this check (and the peci_addr_valid()\n" ">> function) -- as of the end of this patch series, there's only one caller\n" ">> of peci_device_create(), and it's peci_controller_scan_devices() looping\n" ">> from PECI_BASE_ADDR to PECI_BASE_ADDR + PECI_DEVICE_NUM_MAX, so\n" - ">> checking that the address is in that range seems a bit redundant.? Do we\n" + ">> checking that the address is in that range seems a bit redundant.\302\240 Do we\n" ">> anticipate that we might gain additional callers in the future that\n" ">> could run a non-zero risk of passing a bad address?\n" ">\n" @@ -162,25 +189,25 @@ ">\n" ">>\n" ">> > +\n" - ">> > +???????/* Check if we have already detected this device before. */\n" - ">> > +???????ret = device_for_each_child(&controller->dev, &addr,\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240/* Check if we have already detected this device before. */\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240ret = device_for_each_child(&controller->dev, &addr,\n" ">> > peci_dev_exists);\n" - ">> > +???????if (ret)\n" - ">> > +???????????????return 0;\n" - ">> > +\n" - ">> > +???????ret = peci_detect(controller, addr);\n" - ">> > +???????if (ret) {\n" - ">> > +???????????????/*\n" - ">> > +??????????????? * Device not present or host state doesn't allow successful\n" - ">> > +??????????????? * detection at this time.\n" - ">> > +??????????????? */\n" - ">> > +???????????????if (ret == -EIO || ret == -ETIMEDOUT)\n" - ">> > +???????????????????????return 0;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (ret)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240return 0;\n" + ">> > +\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240ret = peci_detect(controller, addr);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (ret) {\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240/*\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240 * Device not present or host state doesn't allow successful\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240 * detection at this time.\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240 */\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (ret == -EIO || ret == -ETIMEDOUT)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240return 0;\n" ">>\n" - ">> Do we really want to be ignoring EIO here?? From a look at\n" + ">> Do we really want to be ignoring EIO here?\302\240 From a look at\n" ">> aspeed_peci_xfer(), it looks like the only path that would produce that\n" ">> is the non-timeout, non-CMD_DONE case, which I guess happens on\n" - ">> contention or FCS errors and such.? Should we maybe have some automatic\n" + ">> contention or FCS errors and such.\302\240 Should we maybe have some automatic\n" ">> (limited) retry loop for cases like those?\n" ">\n" ">Yes, we want to ignore EIO here.\n" @@ -189,53 +216,53 @@ ">\n" ">>\n" ">> > +\n" - ">> > +???????????????return ret;\n" - ">> > +???????}\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240return ret;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240}\n" ">> > +\n" - ">> > +???????device = kzalloc(sizeof(*device), GFP_KERNEL);\n" - ">> > +???????if (!device)\n" - ">> > +???????????????return -ENOMEM;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240device = kzalloc(sizeof(*device), GFP_KERNEL);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (!device)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240return -ENOMEM;\n" ">> > +\n" - ">> > +???????device->controller = controller;\n" - ">> > +???????device->addr = addr;\n" - ">> > +???????device->dev.parent = &device->controller->dev;\n" - ">> > +???????device->dev.bus = &peci_bus_type;\n" - ">> > +???????device->dev.type = &peci_device_type;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240device->controller = controller;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240device->addr = addr;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240device->dev.parent = &device->controller->dev;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240device->dev.bus = &peci_bus_type;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240device->dev.type = &peci_device_type;\n" ">> > +\n" - ">> > +???????ret = dev_set_name(&device->dev, \"%d-%02x\", controller->id, device-\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240ret = dev_set_name(&device->dev, \"%d-%02x\", controller->id, device-\n" ">> > >addr);\n" - ">> > +???????if (ret)\n" - ">> > +???????????????goto err_free;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (ret)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240goto err_free;\n" ">> > +\n" - ">> > +???????ret = device_register(&device->dev);\n" - ">> > +???????if (ret)\n" - ">> > +???????????????goto err_put;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240ret = device_register(&device->dev);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (ret)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240goto err_put;\n" ">> > +\n" - ">> > +???????return 0;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240return 0;\n" ">> > +\n" ">> > +err_put:\n" - ">> > +???????put_device(&device->dev);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240put_device(&device->dev);\n" ">> > +err_free:\n" - ">> > +???????kfree(device);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240kfree(device);\n" ">> > +\n" - ">> > +???????return ret;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240return ret;\n" ">> > +}\n" ">> > +\n" ">> > +void peci_device_destroy(struct peci_device *device)\n" ">> > +{\n" - ">> > +???????device_unregister(&device->dev);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240device_unregister(&device->dev);\n" ">> > +}\n" ">> > +\n" ">> > +static void peci_device_release(struct device *dev)\n" ">> > +{\n" - ">> > +???????struct peci_device *device = to_peci_device(dev);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240struct peci_device *device = to_peci_device(dev);\n" ">> > +\n" - ">> > +???????kfree(device);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240kfree(device);\n" ">> > +}\n" ">> > +\n" ">> > +struct device_type peci_device_type = {\n" - ">> > +???????.groups?????????= peci_device_groups,\n" - ">> > +???????.release????????= peci_device_release,\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240.groups\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240= peci_device_groups,\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240.release\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240= peci_device_release,\n" ">> > +};\n" ">> > diff --git a/drivers/peci/internal.h b/drivers/peci/internal.h\n" ">> > index 80c61bcdfc6b..6b139adaf6b8 100644\n" @@ -249,8 +276,8 @@ ">> > +struct peci_request;\n" ">> > +\n" ">> > +/* PECI CPU address range 0x30-0x37 */\n" - ">> > +#define PECI_BASE_ADDR?????????0x30\n" - ">> > +#define PECI_DEVICE_NUM_MAX????????????8\n" + ">> > +#define PECI_BASE_ADDR\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\2400x30\n" + ">> > +#define PECI_DEVICE_NUM_MAX\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\2408\n" ">> > +\n" ">> > +struct peci_request *peci_request_alloc(struct peci_device *device, u8\n" ">> > tx_len, u8 rx_len);\n" @@ -293,42 +320,42 @@ ">> > +struct peci_request *peci_request_alloc(struct peci_device *device, u8\n" ">> > tx_len, u8 rx_len)\n" ">> > +{\n" - ">> > +???????struct peci_request *req;\n" - ">> > +???????u8 *tx_buf, *rx_buf;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240struct peci_request *req;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240u8 *tx_buf, *rx_buf;\n" ">> > +\n" - ">> > +???????req = kzalloc(sizeof(*req), GFP_KERNEL);\n" - ">> > +???????if (!req)\n" - ">> > +???????????????return NULL;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240req = kzalloc(sizeof(*req), GFP_KERNEL);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (!req)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240return NULL;\n" ">> > +\n" - ">> > +???????req->device = device;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240req->device = device;\n" ">> > +\n" - ">> > +???????/*\n" - ">> > +??????? * PECI controllers that we are using now don't support DMA, this\n" - ">> > +??????? * should be converted to DMA API once support for controllers that\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240/*\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240 * PECI controllers that we are using now don't support DMA, this\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240 * should be converted to DMA API once support for controllers that\n" ">> > do\n" - ">> > +??????? * allow it is added to avoid an extra copy.\n" - ">> > +??????? */\n" - ">> > +???????if (tx_len) {\n" - ">> > +???????????????tx_buf = kzalloc(tx_len, GFP_KERNEL);\n" - ">> > +???????????????if (!tx_buf)\n" - ">> > +???????????????????????goto err_free_req;\n" - ">> > +\n" - ">> > +???????????????req->tx.buf = tx_buf;\n" - ">> > +???????????????req->tx.len = tx_len;\n" - ">> > +???????}\n" - ">> > +\n" - ">> > +???????if (rx_len) {\n" - ">> > +???????????????rx_buf = kzalloc(rx_len, GFP_KERNEL);\n" - ">> > +???????????????if (!rx_buf)\n" - ">> > +???????????????????????goto err_free_tx;\n" - ">> > +\n" - ">> > +???????????????req->rx.buf = rx_buf;\n" - ">> > +???????????????req->rx.len = rx_len;\n" - ">> > +???????}\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240 * allow it is added to avoid an extra copy.\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240 */\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (tx_len) {\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240tx_buf = kzalloc(tx_len, GFP_KERNEL);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (!tx_buf)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240goto err_free_req;\n" + ">> > +\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240req->tx.buf = tx_buf;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240req->tx.len = tx_len;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240}\n" + ">> > +\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (rx_len) {\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240rx_buf = kzalloc(rx_len, GFP_KERNEL);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (!rx_buf)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240goto err_free_tx;\n" + ">> > +\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240req->rx.buf = rx_buf;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240req->rx.len = rx_len;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240}\n" ">> > +\n" ">>\n" ">> As long as we're punting on DMA support, could we do the whole thing in\n" - ">> a single allocation instead of three?? It'd add some pointer arithmetic,\n" + ">> a single allocation instead of three?\302\240 It'd add some pointer arithmetic,\n" ">> but would also simplify the error-handling/deallocation paths a bit.\n" ">>\n" ">> Or, given that the one controller we're currently supporting has a\n" @@ -380,14 +407,14 @@ ">-Iwona\n" ">\n" ">>\n" - ">> > +???????return req;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240return req;\n" ">> > +\n" ">> > +err_free_tx:\n" - ">> > +???????kfree(req->tx.buf);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240kfree(req->tx.buf);\n" ">> > +err_free_req:\n" - ">> > +???????kfree(req);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240kfree(req);\n" ">> > +\n" - ">> > +???????return NULL;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240return NULL;\n" ">> > +}\n" ">> > +EXPORT_SYMBOL_NS_GPL(peci_request_alloc, PECI);\n" ">> > +\n" @@ -397,9 +424,9 @@ ">> > + */\n" ">> > +void peci_request_free(struct peci_request *req)\n" ">> > +{\n" - ">> > +???????kfree(req->rx.buf);\n" - ">> > +???????kfree(req->tx.buf);\n" - ">> > +???????kfree(req);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240kfree(req->rx.buf);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240kfree(req->tx.buf);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240kfree(req);\n" ">> > +}\n" ">> > +EXPORT_SYMBOL_NS_GPL(peci_request_free, PECI);\n" ">> > diff --git a/drivers/peci/sysfs.c b/drivers/peci/sysfs.c\n" @@ -416,44 +443,48 @@ ">> >\n" ">> > #include \"internal.h\"\n" ">> > @@ -46,3 +48,35 @@ const struct attribute_group *peci_bus_groups[] = {\n" - ">> > ????????&peci_bus_group,\n" - ">> > ????????NULL\n" + ">> > \302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240&peci_bus_group,\n" + ">> > \302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240NULL\n" ">> > };\n" ">> > +\n" ">> > +static ssize_t remove_store(struct device *dev, struct device_attribute\n" ">> > *attr,\n" - ">> > +?????????????????????????? const char *buf, size_t count)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240 const char *buf, size_t count)\n" ">> > +{\n" - ">> > +???????struct peci_device *device = to_peci_device(dev);\n" - ">> > +???????bool res;\n" - ">> > +???????int ret;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240struct peci_device *device = to_peci_device(dev);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240bool res;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240int ret;\n" ">> > +\n" - ">> > +???????ret = kstrtobool(buf, &res);\n" - ">> > +???????if (ret)\n" - ">> > +???????????????return ret;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240ret = kstrtobool(buf, &res);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (ret)\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240return ret;\n" ">> > +\n" - ">> > +???????if (res && device_remove_file_self(dev, attr))\n" - ">> > +???????????????peci_device_destroy(device);\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240if (res && device_remove_file_self(dev, attr))\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240\302\240peci_device_destroy(device);\n" ">> > +\n" - ">> > +???????return count;\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240return count;\n" ">> > +}\n" ">> > +static DEVICE_ATTR_IGNORE_LOCKDEP(remove, 0200, NULL, remove_store);\n" ">> > +\n" ">> > +static struct attribute *peci_device_attrs[] = {\n" - ">> > +???????&dev_attr_remove.attr,\n" - ">> > +???????NULL\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240&dev_attr_remove.attr,\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240NULL\n" ">> > +};\n" ">> > +\n" ">> > +static const struct attribute_group peci_device_group = {\n" - ">> > +???????.attrs = peci_device_attrs,\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240.attrs = peci_device_attrs,\n" ">> > +};\n" ">> > +\n" ">> > +const struct attribute_group *peci_device_groups[] = {\n" - ">> > +???????&peci_device_group,\n" - ">> > +???????NULL\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240&peci_device_group,\n" + ">> > +\302\240\302\240\302\240\302\240\302\240\302\240\302\240NULL\n" ">> > +};\n" ">> > --\n" ">> > 2.31.1\n" - > + ">\n" + "_______________________________________________\n" + "linux-arm-kernel mailing list\n" + "linux-arm-kernel@lists.infradead.org\n" + http://lists.infradead.org/mailman/listinfo/linux-arm-kernel -1d638fbf92fea69e3e8bcf8a80ff14134bac0a1c6d90a619556236ffcef3d338 +c562a8f91b7a53f2c9746e5b27143a444a171e95c893993c59c7695828e7cc49
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.