Message ID | 20230522112548.1577359-1-ogabbay@kernel.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/4] accel/habanalabs: remove sim code | expand |
Thanks! On Mon, May 22, 2023 at 02:25:45PM +0300, Oded Gabbay wrote: > diff --git a/drivers/accel/habanalabs/common/device.c b/drivers/accel/habanalabs/common/device.c > index cab5a63db8c1..ca15c8d0d042 100644 > --- a/drivers/accel/habanalabs/common/device.c > +++ b/drivers/accel/habanalabs/common/device.c > @@ -2328,13 +2328,9 @@ int hl_device_init(struct hl_device *hdev) > hdev->disabled = true; > if (expose_interfaces_on_err) > cdev_sysfs_debugfs_add(hdev); > - if (hdev->pdev) > - dev_err(&hdev->pdev->dev, > - "Failed to initialize hl%d. Device %s is NOT usable !\n", > - hdev->cdev_idx, dev_name(&(hdev)->pdev->dev)); > - else > - pr_err("Failed to initialize hl%d. Device %s is NOT usable !\n", > - hdev->cdev_idx, dev_name(&(hdev)->pdev->dev)); > + dev_err(&hdev->pdev->dev, ^^^^^^^^^^^^^^^ > + "Failed to initialize hl%d. Device %s is NOT usable !\n", > + hdev->cdev_idx, dev_name(&(hdev)->pdev->dev)); ^^^^^^^^^^^^^^^^^^^ I hate to be picky, but would it be too much to get rid of the parens around (hdev)? regards, dan carpenter
On Mon, May 22, 2023 at 2:33 PM Dan Carpenter <dan.carpenter@linaro.org> wrote: > > Thanks! > > On Mon, May 22, 2023 at 02:25:45PM +0300, Oded Gabbay wrote: > > diff --git a/drivers/accel/habanalabs/common/device.c b/drivers/accel/habanalabs/common/device.c > > index cab5a63db8c1..ca15c8d0d042 100644 > > --- a/drivers/accel/habanalabs/common/device.c > > +++ b/drivers/accel/habanalabs/common/device.c > > @@ -2328,13 +2328,9 @@ int hl_device_init(struct hl_device *hdev) > > hdev->disabled = true; > > if (expose_interfaces_on_err) > > cdev_sysfs_debugfs_add(hdev); > > - if (hdev->pdev) > > - dev_err(&hdev->pdev->dev, > > - "Failed to initialize hl%d. Device %s is NOT usable !\n", > > - hdev->cdev_idx, dev_name(&(hdev)->pdev->dev)); > > - else > > - pr_err("Failed to initialize hl%d. Device %s is NOT usable !\n", > > - hdev->cdev_idx, dev_name(&(hdev)->pdev->dev)); > > + dev_err(&hdev->pdev->dev, > ^^^^^^^^^^^^^^^ > > > + "Failed to initialize hl%d. Device %s is NOT usable !\n", > > + hdev->cdev_idx, dev_name(&(hdev)->pdev->dev)); > ^^^^^^^^^^^^^^^^^^^ > > I hate to be picky, but would it be too much to get rid of the parens > around (hdev)? Sure, np. I'll fix it before pushing it to the branch. Oded > > regards, > dan carpenter
diff --git a/drivers/accel/habanalabs/common/device.c b/drivers/accel/habanalabs/common/device.c index cab5a63db8c1..ca15c8d0d042 100644 --- a/drivers/accel/habanalabs/common/device.c +++ b/drivers/accel/habanalabs/common/device.c @@ -2328,13 +2328,9 @@ int hl_device_init(struct hl_device *hdev) hdev->disabled = true; if (expose_interfaces_on_err) cdev_sysfs_debugfs_add(hdev); - if (hdev->pdev) - dev_err(&hdev->pdev->dev, - "Failed to initialize hl%d. Device %s is NOT usable !\n", - hdev->cdev_idx, dev_name(&(hdev)->pdev->dev)); - else - pr_err("Failed to initialize hl%d. Device %s is NOT usable !\n", - hdev->cdev_idx, dev_name(&(hdev)->pdev->dev)); + dev_err(&hdev->pdev->dev, + "Failed to initialize hl%d. Device %s is NOT usable !\n", + hdev->cdev_idx, dev_name(&(hdev)->pdev->dev)); return rc; } diff --git a/drivers/accel/habanalabs/common/habanalabs.h b/drivers/accel/habanalabs/common/habanalabs.h index e2341a75a4b7..c5aa33eaa826 100644 --- a/drivers/accel/habanalabs/common/habanalabs.h +++ b/drivers/accel/habanalabs/common/habanalabs.h @@ -2558,12 +2558,7 @@ void hl_wreg(struct hl_device *hdev, u32 reg, u32 val); ktime_t __timeout; \ u32 __elbi_read; \ int __rc = 0; \ - if (hdev->pdev) \ - __timeout = ktime_add_us(ktime_get(), timeout_us); \ - else \ - __timeout = ktime_add_us(ktime_get(),\ - min((u64)(timeout_us * 10), \ - (u64) HL_SIM_MAX_TIMEOUT_US)); \ + __timeout = ktime_add_us(ktime_get(), timeout_us); \ might_sleep_if(sleep_us); \ for (;;) { \ if (elbi) { \ @@ -2615,13 +2610,7 @@ void hl_wreg(struct hl_device *hdev, u32 reg, u32 val); u8 __arr_idx; \ int __rc = 0; \ \ - if (hdev->pdev) \ - __timeout = ktime_add_us(ktime_get(), timeout_us); \ - else \ - __timeout = ktime_add_us(ktime_get(),\ - min(((u64)timeout_us * 10), \ - (u64) HL_SIM_MAX_TIMEOUT_US)); \ - \ + __timeout = ktime_add_us(ktime_get(), timeout_us); \ might_sleep_if(sleep_us); \ if (arr_size >= 64) \ __rc = -EINVAL; \ @@ -2679,12 +2668,8 @@ void hl_wreg(struct hl_device *hdev, u32 reg, u32 val); mem_written_by_device) \ ({ \ ktime_t __timeout; \ - if (hdev->pdev) \ - __timeout = ktime_add_us(ktime_get(), timeout_us); \ - else \ - __timeout = ktime_add_us(ktime_get(),\ - min((u64)(timeout_us * 100), \ - (u64) HL_SIM_MAX_TIMEOUT_US)); \ + \ + __timeout = ktime_add_us(ktime_get(), timeout_us); \ might_sleep_if(sleep_us); \ for (;;) { \ /* Verify we read updates done by other cores or by device */ \
There were a few places where simulator only code got into the upstream. Remove those places that can confuse other developers. Fixes: 2a0a839b6a28 ("habanalabs: extend fatal messages to contain PCI info") Cc: Moti Haimovski <mhaimovski@habana.ai> Cc: Dan Carpenter <dan.carpenter@linaro.org> Signed-off-by: Oded Gabbay <ogabbay@kernel.org> --- drivers/accel/habanalabs/common/device.c | 10 +++------ drivers/accel/habanalabs/common/habanalabs.h | 23 ++++---------------- 2 files changed, 7 insertions(+), 26 deletions(-)