Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1393125 > unrolled thread
| Started by | Johannes Thumshirn <jthumshirn@suse.de> |
|---|---|
| First post | 2016-05-03 09:50 +0200 |
| Last post | 2016-05-03 12:50 +0200 |
| Articles | 8 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH 0/6] MCB patches for v4.7 Johannes Thumshirn <jthumshirn@suse.de> - 2016-05-03 09:50 +0200
[PATCH 1/6] mcb: Correctly initialize the bus's device Johannes Thumshirn <jthumshirn@suse.de> - 2016-05-03 09:50 +0200
Re: [PATCH 0/6] MCB patches for v4.7 Johannes Thumshirn <jthmshirn@suse.de> - 2016-05-03 10:10 +0200
Re: [PATCH 0/6] MCB patches for v4.7 Greg KH <gregkh@linuxfoundation.org> - 2016-05-04 01:00 +0200
[PATCH 6/6] mcb: Implement bus->dev.release callback Johannes Thumshirn <jthumshirn@suse.de> - 2016-05-03 12:50 +0200
[PATCH 5/6] mcb: Delete num_cells variable which is not required Johannes Thumshirn <jthumshirn@suse.de> - 2016-05-03 12:50 +0200
[PATCH 4/6] mcb: Replace ioremap and request_region with the devm version Johannes Thumshirn <jthumshirn@suse.de> - 2016-05-03 12:50 +0200
[PATCH 3/6] mcb: Fixed bar number assignment for the gdd Johannes Thumshirn <jthumshirn@suse.de> - 2016-05-03 12:50 +0200
| From | Johannes Thumshirn <jthumshirn@suse.de> |
|---|---|
| Date | 2016-05-03 09:50 +0200 |
| Subject | [PATCH 0/6] MCB patches for v4.7 |
| Message-ID | <ruDfH-3LT-9@gated-at.bofh.it> |
Hi Greg, The following patches are the MCB updates for v4.7. These are mainly cleanups and some bug fixes from Andreas and me. The only non cleanup/bugfix patch is 'mcb: export bus information via sysfs' which exports information about the carrier FPGA to sysfs, like the revision number and model name of the FPGA, so that a field technician can easily obtain these. All patches have been tested by Andreas and have been on lkml for people to comment as well as in my git tree located at: git://git.kernel.org/pub/scm/linux/kernel/git/jth/linux.git tags/for-v4.7 Thanks, Johannes Andreas Werner (3): mcb: Fixed bar number assignment for the gdd mcb: Replace ioremap and request_region with the devm version mcb: Delete num_cells variable which is not required Johannes Thumshirn (3): mcb: Correctly initialize the bus's device mcb: export bus information via sysfs mcb: Implement bus->dev.release callback Documentation/ABI/testing/sysfs-bus-mcb | 29 ++++++++++ drivers/mcb/mcb-core.c | 99 ++++++++++++++++++++++++++++++--- drivers/mcb/mcb-internal.h | 1 - drivers/mcb/mcb-parse.c | 17 ++---- drivers/mcb/mcb-pci.c | 23 +++----- include/linux/mcb.h | 14 ++++- 6 files changed, 144 insertions(+), 39 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-bus-mcb -- 2.8.1
[toc] | [next] | [standalone]
| From | Johannes Thumshirn <jthumshirn@suse.de> |
|---|---|
| Date | 2016-05-03 09:50 +0200 |
| Subject | [PATCH 1/6] mcb: Correctly initialize the bus's device |
| Message-ID | <ruDfI-3LT-37@gated-at.bofh.it> |
| In reply to | #1393125 |
The mcb bus' device member wasn't correctly initialized and thus wasn't placed
correctly into the driver model.
Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Andreas Werner <andreas.werner@men.de>
Tested-by: Andreas Werner <andreas.werner@men.de>
---
drivers/mcb/mcb-core.c | 19 ++++++++++++++++---
include/linux/mcb.h | 5 ++---
2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/drivers/mcb/mcb-core.c b/drivers/mcb/mcb-core.c
index a4be451..1e336cc 100644
--- a/drivers/mcb/mcb-core.c
+++ b/drivers/mcb/mcb-core.c
@@ -187,6 +187,7 @@ struct mcb_bus *mcb_alloc_bus(struct device *carrier)
{
struct mcb_bus *bus;
int bus_nr;
+ int rc;
bus = kzalloc(sizeof(struct mcb_bus), GFP_KERNEL);
if (!bus)
@@ -194,14 +195,26 @@ struct mcb_bus *mcb_alloc_bus(struct device *carrier)
bus_nr = ida_simple_get(&mcb_ida, 0, 0, GFP_KERNEL);
if (bus_nr < 0) {
- kfree(bus);
- return ERR_PTR(bus_nr);
+ rc = bus_nr;
+ goto err_free;
}
- INIT_LIST_HEAD(&bus->children);
bus->bus_nr = bus_nr;
bus->carrier = carrier;
+
+ device_initialize(&bus->dev);
+ bus->dev.parent = carrier;
+ bus->dev.bus = &mcb_bus_type;
+
+ dev_set_name(&bus->dev, "mcb:%d", bus_nr);
+ rc = device_add(&bus->dev);
+ if (rc)
+ goto err_free;
+
return bus;
+err_free:
+ kfree(bus);
+ return ERR_PTR(rc);
}
EXPORT_SYMBOL_GPL(mcb_alloc_bus);
diff --git a/include/linux/mcb.h b/include/linux/mcb.h
index ed06e15..3efafbc 100644
--- a/include/linux/mcb.h
+++ b/include/linux/mcb.h
@@ -21,13 +21,12 @@ struct mcb_device;
/**
* struct mcb_bus - MEN Chameleon Bus
*
- * @dev: pointer to carrier device
- * @children: the child busses
+ * @dev: bus device
+ * @carrier: pointer to carrier device
* @bus_nr: mcb bus number
* @get_irq: callback to get IRQ number
*/
struct mcb_bus {
- struct list_head children;
struct device dev;
struct device *carrier;
int bus_nr;
--
2.8.1
[toc] | [prev] | [next] | [standalone]
| From | Johannes Thumshirn <jthmshirn@suse.de> |
|---|---|
| Date | 2016-05-03 10:10 +0200 |
| Message-ID | <ruDz3-4jj-11@gated-at.bofh.it> |
| In reply to | #1393125 |
On Tue, May 03, 2016 at 09:46:21AM +0200, Johannes Thumshirn wrote: > Hi Greg, > > The following patches are the MCB updates for v4.7. These are mainly cleanups > and some bug fixes from Andreas and me. The only non cleanup/bugfix patch is > 'mcb: export bus information via sysfs' which exports information about the > carrier FPGA to sysfs, like the revision number and model name of the FPGA, > so that a field technician can easily obtain these. > > All patches have been tested by Andreas and have been on lkml for people to > comment as well as in my git tree located at: > > git://git.kernel.org/pub/scm/linux/kernel/git/jth/linux.git tags/for-v4.7 > > Thanks, > Johannes > > Andreas Werner (3): > mcb: Fixed bar number assignment for the gdd > mcb: Replace ioremap and request_region with the devm version > mcb: Delete num_cells variable which is not required > > Johannes Thumshirn (3): > mcb: Correctly initialize the bus's device > mcb: export bus information via sysfs > mcb: Implement bus->dev.release callback > > Documentation/ABI/testing/sysfs-bus-mcb | 29 ++++++++++ > drivers/mcb/mcb-core.c | 99 ++++++++++++++++++++++++++++++--- > drivers/mcb/mcb-internal.h | 1 - > drivers/mcb/mcb-parse.c | 17 ++---- > drivers/mcb/mcb-pci.c | 23 +++----- > include/linux/mcb.h | 14 ++++- > 6 files changed, 144 insertions(+), 39 deletions(-) > create mode 100644 Documentation/ABI/testing/sysfs-bus-mcb > > -- > 2.8.1 > Somehow only two patches did make it through the mailserver, my apologies. I'll re-send once I figured out what went wrong. -- Johannes Thumshirn Storage jthumshirn@suse.de +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
[toc] | [prev] | [next] | [standalone]
| From | Greg KH <gregkh@linuxfoundation.org> |
|---|---|
| Date | 2016-05-04 01:00 +0200 |
| Message-ID | <ruRsm-dq-13@gated-at.bofh.it> |
| In reply to | #1393149 |
On Tue, May 03, 2016 at 10:02:57AM +0200, Johannes Thumshirn wrote: > On Tue, May 03, 2016 at 09:46:21AM +0200, Johannes Thumshirn wrote: > > Hi Greg, > > > > The following patches are the MCB updates for v4.7. These are mainly cleanups > > and some bug fixes from Andreas and me. The only non cleanup/bugfix patch is > > 'mcb: export bus information via sysfs' which exports information about the > > carrier FPGA to sysfs, like the revision number and model name of the FPGA, > > so that a field technician can easily obtain these. > > > > All patches have been tested by Andreas and have been on lkml for people to > > comment as well as in my git tree located at: > > > > git://git.kernel.org/pub/scm/linux/kernel/git/jth/linux.git tags/for-v4.7 > > > > Thanks, > > Johannes > > > > Andreas Werner (3): > > mcb: Fixed bar number assignment for the gdd > > mcb: Replace ioremap and request_region with the devm version > > mcb: Delete num_cells variable which is not required > > > > Johannes Thumshirn (3): > > mcb: Correctly initialize the bus's device > > mcb: export bus information via sysfs > > mcb: Implement bus->dev.release callback > > > > Documentation/ABI/testing/sysfs-bus-mcb | 29 ++++++++++ > > drivers/mcb/mcb-core.c | 99 ++++++++++++++++++++++++++++++--- > > drivers/mcb/mcb-internal.h | 1 - > > drivers/mcb/mcb-parse.c | 17 ++---- > > drivers/mcb/mcb-pci.c | 23 +++----- > > include/linux/mcb.h | 14 ++++- > > 6 files changed, 144 insertions(+), 39 deletions(-) > > create mode 100644 Documentation/ABI/testing/sysfs-bus-mcb > > > > -- > > 2.8.1 > > > > Somehow only two patches did make it through the mailserver, my apologies. > > I'll re-send once I figured out what went wrong. Odd, I got them all here, unless you resent them...
[toc] | [prev] | [next] | [standalone]
| From | Johannes Thumshirn <jthumshirn@suse.de> |
|---|---|
| Date | 2016-05-03 12:50 +0200 |
| Subject | [PATCH 6/6] mcb: Implement bus->dev.release callback |
| Message-ID | <ruG3U-6AZ-1@gated-at.bofh.it> |
| In reply to | #1393125 |
The mcb_bus structure previously was released in mcb_release_bus. This lead to
the following warning on module unload:
------------[ cut here ]------------
WARNING: CPU: 1 PID: 2032 at drivers/base/core.c:251 device_release+0x73/0x90
Device 'mcb:0' does not have a release() function, it is broken and must be fixed.
Modules linked in: men_z135_uart mcb_pci(-) mcb
CPU: 1 PID: 2032 Comm: rmmod Not tainted 4.6.0-rc4+ #3
Hardware name: N/A N/A/COMe-mBTi10, BIOS MVV1R921 X64 10/14/2015
00000286 00000286 c0117de4 c12d6f16 c0117e2c c18be0d3 c0117dfc c104f6e1
000000fb f5ccbe08 f5ccbe00 f5c64600 c0117e18 c104f728 00000009 00000000
c0117e10 c18db674 c0117e2c c0117e3c c13ce5c3 c18be0d3 000000fb c18db674
Call Trace:
[<c12d6f16>] dump_stack+0x47/0x61
[<c104f6e1>] __warn+0xc1/0xe0
[<c104f728>] warn_slowpath_fmt+0x28/0x30
[<c13ce5c3>] device_release+0x73/0x90
[<c12d92e4>] kobject_release+0x34/0x80
[<c12d929d>] ? kobject_del+0x2d/0x40
[<c12d9205>] kobject_put+0x25/0x50
[<c13ce77f>] put_device+0xf/0x20
[<c13d114b>] klist_devices_put+0xb/0x10
[<c1752673>] klist_next+0x73/0xf0
[<c13d1140>] ? unbind_store+0x100/0x100
[<f8a23370>] ? mcb_bus_add_devices+0x30/0x30 [mcb]
[<c13d0a81>] bus_for_each_dev+0x51/0x80
[<f8a23319>] mcb_release_bus+0x19/0x40 [mcb]
[<f8a23370>] ? mcb_bus_add_devices+0x30/0x30 [mcb]
[<f8a2b033>] mcb_pci_remove+0x13/0x20 [mcb_pci]
[<c130d358>] pci_device_remove+0x28/0xb0
[<c13d201b>] __device_release_driver+0x7b/0x110
[<c13d2847>] driver_detach+0x87/0x90
[<c13d1b9b>] bus_remove_driver+0x3b/0x80
[<c13d2ed0>] driver_unregister+0x20/0x50
[<c130be53>] pci_unregister_driver+0x13/0x60
[<f8a2b1f4>] mcb_pci_driver_exit+0xd/0xf [mcb_pci]
[<c10be588>] SyS_delete_module+0x138/0x200
[<c1159208>] ? ____fput+0x8/0x10
[<c1068054>] ? task_work_run+0x74/0x90
[<c1001879>] do_fast_syscall_32+0x69/0x120
[<c1757597>] sysenter_past_esp+0x40/0x6a
---[ end trace 1ed34c2aa3019875 ]---
Release a mcb_bus' memory on the device's release callback, to avoid above
warning.
Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Reported-by: Andreas Werner <andreas.werner@men.de>
Tested-by: Andreas Werner <andreas.werner@men.de>
---
drivers/mcb/mcb-core.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/drivers/mcb/mcb-core.c b/drivers/mcb/mcb-core.c
index 9ae4d15..b73c6e7 100644
--- a/drivers/mcb/mcb-core.c
+++ b/drivers/mcb/mcb-core.c
@@ -83,8 +83,8 @@ static int mcb_remove(struct device *dev)
static void mcb_shutdown(struct device *dev)
{
+ struct mcb_driver *mdrv = to_mcb_driver(dev->driver);
struct mcb_device *mdev = to_mcb_device(dev);
- struct mcb_driver *mdrv = mdev->driver;
if (mdrv && mdrv->shutdown)
mdrv->shutdown(mdev);
@@ -214,6 +214,7 @@ int mcb_device_register(struct mcb_bus *bus, struct mcb_device *dev)
int device_id;
device_initialize(&dev->dev);
+ mcb_bus_get(bus);
dev->dev.bus = &mcb_bus_type;
dev->dev.parent = bus->dev.parent;
dev->dev.release = mcb_release_dev;
@@ -237,6 +238,15 @@ out:
}
EXPORT_SYMBOL_GPL(mcb_device_register);
+static void mcb_free_bus(struct device *dev)
+{
+ struct mcb_bus *bus = to_mcb_bus(dev);
+
+ put_device(bus->carrier);
+ ida_simple_remove(&mcb_ida, bus->bus_nr);
+ kfree(bus);
+}
+
/**
* mcb_alloc_bus() - Allocate a new @mcb_bus
*
@@ -259,12 +269,13 @@ struct mcb_bus *mcb_alloc_bus(struct device *carrier)
}
bus->bus_nr = bus_nr;
- bus->carrier = carrier;
+ bus->carrier = get_device(carrier);
device_initialize(&bus->dev);
bus->dev.parent = carrier;
bus->dev.bus = &mcb_bus_type;
bus->dev.type = &mcb_carrier_device_type;
+ bus->dev.release = &mcb_free_bus;
dev_set_name(&bus->dev, "mcb:%d", bus_nr);
rc = device_add(&bus->dev);
@@ -273,6 +284,7 @@ struct mcb_bus *mcb_alloc_bus(struct device *carrier)
return bus;
err_free:
+ put_device(carrier);
kfree(bus);
return ERR_PTR(rc);
}
@@ -297,10 +309,6 @@ static void mcb_devices_unregister(struct mcb_bus *bus)
void mcb_release_bus(struct mcb_bus *bus)
{
mcb_devices_unregister(bus);
-
- ida_simple_remove(&mcb_ida, bus->bus_nr);
-
- kfree(bus);
}
EXPORT_SYMBOL_GPL(mcb_release_bus);
--
2.8.1
[toc] | [prev] | [next] | [standalone]
| From | Johannes Thumshirn <jthumshirn@suse.de> |
|---|---|
| Date | 2016-05-03 12:50 +0200 |
| Subject | [PATCH 5/6] mcb: Delete num_cells variable which is not required |
| Message-ID | <ruG3U-6AZ-3@gated-at.bofh.it> |
| In reply to | #1393125 |
From: Andreas Werner <andreas.werner@men.de> The num_cells variable is only used in the dev_dbg print, but we can directly use the ret variable which also includes the same value. Signed-off-by: Andreas Werner <andreas.werner@men.de> Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de> --- drivers/mcb/mcb-pci.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/mcb/mcb-pci.c b/drivers/mcb/mcb-pci.c index 99dd9db..b15a034 100644 --- a/drivers/mcb/mcb-pci.c +++ b/drivers/mcb/mcb-pci.c @@ -35,7 +35,6 @@ static int mcb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) struct resource *res; struct priv *priv; int ret; - int num_cells; unsigned long flags; priv = devm_kzalloc(&pdev->dev, sizeof(struct priv), GFP_KERNEL); @@ -92,9 +91,8 @@ static int mcb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) ret = chameleon_parse_cells(priv->bus, priv->mapbase, priv->base); if (ret < 0) goto out_mcb_bus; - num_cells = ret; - dev_dbg(&pdev->dev, "Found %d cells\n", num_cells); + dev_dbg(&pdev->dev, "Found %d cells\n", ret); mcb_bus_add_devices(priv->bus); -- 2.8.1
[toc] | [prev] | [next] | [standalone]
| From | Johannes Thumshirn <jthumshirn@suse.de> |
|---|---|
| Date | 2016-05-03 12:50 +0200 |
| Subject | [PATCH 4/6] mcb: Replace ioremap and request_region with the devm version |
| Message-ID | <ruG3U-6AZ-7@gated-at.bofh.it> |
| In reply to | #1393125 |
From: Andreas Werner <andreas.werner@men.de>
Replaced ioremap with devm_ioremap and request_mem_region with
devm_request_mem_region. This makes the code much more cleaner.
Signed-off-by: Andreas Werner <andreas.werner@men.de>
Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
---
drivers/mcb/mcb-pci.c | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/drivers/mcb/mcb-pci.c b/drivers/mcb/mcb-pci.c
index 67d5e7d..99dd9db 100644
--- a/drivers/mcb/mcb-pci.c
+++ b/drivers/mcb/mcb-pci.c
@@ -55,19 +55,20 @@ static int mcb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
goto out_disable;
}
- res = request_mem_region(priv->mapbase, CHAM_HEADER_SIZE,
- KBUILD_MODNAME);
+ res = devm_request_mem_region(&pdev->dev, priv->mapbase,
+ CHAM_HEADER_SIZE,
+ KBUILD_MODNAME);
if (!res) {
dev_err(&pdev->dev, "Failed to request PCI memory\n");
ret = -EBUSY;
goto out_disable;
}
- priv->base = ioremap(priv->mapbase, CHAM_HEADER_SIZE);
+ priv->base = devm_ioremap(&pdev->dev, priv->mapbase, CHAM_HEADER_SIZE);
if (!priv->base) {
dev_err(&pdev->dev, "Cannot ioremap\n");
ret = -ENOMEM;
- goto out_release;
+ goto out_disable;
}
flags = pci_resource_flags(pdev, 0);
@@ -75,7 +76,7 @@ static int mcb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
ret = -ENOTSUPP;
dev_err(&pdev->dev,
"IO mapped PCI devices are not supported\n");
- goto out_iounmap;
+ goto out_disable;
}
pci_set_drvdata(pdev, priv);
@@ -83,7 +84,7 @@ static int mcb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
priv->bus = mcb_alloc_bus(&pdev->dev);
if (IS_ERR(priv->bus)) {
ret = PTR_ERR(priv->bus);
- goto out_iounmap;
+ goto out_disable;
}
priv->bus->get_irq = mcb_pci_get_irq;
@@ -101,10 +102,6 @@ static int mcb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
out_mcb_bus:
mcb_release_bus(priv->bus);
-out_iounmap:
- iounmap(priv->base);
-out_release:
- pci_release_region(pdev, 0);
out_disable:
pci_disable_device(pdev);
return ret;
@@ -116,8 +113,6 @@ static void mcb_pci_remove(struct pci_dev *pdev)
mcb_release_bus(priv->bus);
- iounmap(priv->base);
- release_region(priv->mapbase, CHAM_HEADER_SIZE);
pci_disable_device(pdev);
}
--
2.8.1
[toc] | [prev] | [next] | [standalone]
| From | Johannes Thumshirn <jthumshirn@suse.de> |
|---|---|
| Date | 2016-05-03 12:50 +0200 |
| Subject | [PATCH 3/6] mcb: Fixed bar number assignment for the gdd |
| Message-ID | <ruG3U-6AZ-11@gated-at.bofh.it> |
| In reply to | #1393125 |
From: Andreas Werner <andreas.werner@men.de> The bar number is found in reg2 within the gdd. Therefore we need to change the assigment from reg1 to reg2 which is the correct location. Signed-off-by: Andreas Werner <andreas.werner@men.de> Fixes: '3764e82e5' drivers: Introduce MEN Chameleon Bus Cc: stable@vger.kernel.org # v3.15+ Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de> --- drivers/mcb/mcb-parse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mcb/mcb-parse.c b/drivers/mcb/mcb-parse.c index 35f385b..dbecbed 100644 --- a/drivers/mcb/mcb-parse.c +++ b/drivers/mcb/mcb-parse.c @@ -57,7 +57,7 @@ static int chameleon_parse_gdd(struct mcb_bus *bus, mdev->id = GDD_DEV(reg1); mdev->rev = GDD_REV(reg1); mdev->var = GDD_VAR(reg1); - mdev->bar = GDD_BAR(reg1); + mdev->bar = GDD_BAR(reg2); mdev->group = GDD_GRP(reg2); mdev->inst = GDD_INS(reg2); -- 2.8.1
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web