Commit Graph

17 Commits

Author SHA1 Message Date
Rado Vrbovsky 96e7e535de Merge: CNB96: auxbus, driver core: towards constant struct device_driver
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/5369

JIRA: https://issues.redhat.com/browse/RHEL-59894

Backport of a series from Greg KH to constify struct device_driver.

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>

Approved-by: Mark Langsdorf <mlangsdo@redhat.com>
Approved-by: Ivan Vecera <ivecera@redhat.com>
Approved-by: Petr Oros <poros@redhat.com>
Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com>

Merged-by: Rado Vrbovsky <rvrbovsk@redhat.com>
2024-10-16 12:20:34 +00:00
Michal Schmidt 3aa8ce2310 auxbus: make to_auxiliary_drv accept and return a constant pointer
JIRA: https://issues.redhat.com/browse/RHEL-59894

commit ff985c759778986f55cbc557055fbeb84ee833eb
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Tue Jun 11 15:01:04 2024 +0200

    auxbus: make to_auxiliary_drv accept and return a constant pointer

    In the quest to make struct device constant, start by making
    to_auxiliary_drv() return a constant pointer so that drivers that call
    this can be fixed up before the driver core changes.

    As the return type previously was not constant, also fix up all callers
    that were assuming that the pointer was not going to be a constant one
    in order to not break the build.

    Cc: Dave Ertman <david.m.ertman@intel.com>
    Cc: Ira Weiny <ira.weiny@intel.com>
    Cc: Rafael J. Wysocki <rafael@kernel.org>
    Cc: Bingbu Cao <bingbu.cao@intel.com>
    Cc: Tianshu Qiu <tian.shu.qiu@intel.com>
    Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
    Cc: Michael Chan <michael.chan@broadcom.com>
    Cc: David S. Miller <davem@davemloft.net>
    Cc: Eric Dumazet <edumazet@google.com>
    Cc: Jakub Kicinski <kuba@kernel.org>
    Cc: Paolo Abeni <pabeni@redhat.com>
    Cc: Jesse Brandeburg <jesse.brandeburg@intel.com>
    Cc: Tony Nguyen <anthony.l.nguyen@intel.com>
    Cc: Saeed Mahameed <saeedm@nvidia.com>
    Cc: Leon Romanovsky <leon@kernel.org>
    Cc: Tariq Toukan <tariqt@nvidia.com>
    Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
    Cc: Liam Girdwood <lgirdwood@gmail.com>
    Cc: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
    Cc: Bard Liao <yung-chuan.liao@linux.intel.com>
    Cc: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
    Cc: Daniel Baluta <daniel.baluta@nxp.com>
    Cc: Kai Vehmanen <kai.vehmanen@linux.intel.com>
    Cc: Jaroslav Kysela <perex@perex.cz>
    Cc: Takashi Iwai <tiwai@suse.com>
    Cc: Richard Cochran <richardcochran@gmail.com>
    Cc: linux-media@vger.kernel.org
    Cc: netdev@vger.kernel.org
    Cc: intel-wired-lan@lists.osuosl.org
    Cc: linux-rdma@vger.kernel.org
    Cc: sound-open-firmware@alsa-project.org
    Cc: linux-sound@vger.kernel.org
    Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> # drivers/media/pci/intel/ipu6
    Acked-by: Mark Brown <broonie@kernel.org>
    Reviewed-by: Martin Habets <habetsm.xilinx@gmail.com>
    Link: https://lore.kernel.org/r/20240611130103.3262749-7-gregkh@linuxfoundation.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>

Conflicts:
	drivers/media/pci/intel/ipu6/ipu6-bus.h
	- Not present in RHEL 9.
2024-10-04 14:25:12 +02:00
Ivan Vecera c5161525f6 driver core: auxiliary bus: show auxiliary device IRQs
JIRA: https://issues.redhat.com/browse/RHEL-61175

commit a808878308a8041ae10a151d69e2d22f94cae9f4
Author: Shay Drory <shayd@nvidia.com>
Date:   Sun Apr 14 11:05:25 2024 +0300

    driver core: auxiliary bus: show auxiliary device IRQs

    PCI subfunctions (SF) are anchored on the auxiliary bus. PCI physical
    and virtual functions are anchored on the PCI bus. The irq information
    of each such function is visible to users via sysfs directory "msi_irqs"
    containing files for each irq entry. However, for PCI SFs such
    information is unavailable. Due to this users have no visibility on IRQs
    used by the SFs.
    Secondly, an SF can be multi function device supporting rdma, netdevice
    and more. Without irq information at the bus level, the user is unable
    to view or use the affinity of the SF IRQs.

    Hence to match to the equivalent PCI PFs and VFs, add "irqs" directory,
    for supporting auxiliary devices, containing file for each irq entry.

    For example:
    $ ls /sys/bus/auxiliary/devices/mlx5_core.sf.1/irqs/
    50  51  52  53  54  55  56  57  58

    Cc: Simon Horman <horms@kernel.org>
    Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
    Reviewed-by: Parav Pandit <parav@nvidia.com>
    Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Shay Drory <shayd@nvidia.com>
    Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>

    ---
    v9-v10:
    - remove Przemek RB
    - add name field to auxiliary_irq_info (Greg and Przemek)
    - handle bogus IRQ in auxiliary_device_sysfs_irq_remove (Greg)
    v8-v9:
    - add Przemek RB
    - use guard() in auxiliary_irq_dir_prepare (Paolo)
    v7-v8:
    - use cleanup.h for info and name fields (Greg)
    - correct error flow in auxiliary_irq_dir_prepare (Przemek)
    - add documentation for new fields of auxiliary_device (Simon)
    v6-v7:
    - dynamically creating irqs directory when first irq file created (Greg)
    - removed irqs flag and simplified the dev_add() API (Greg)
    - move sysfs related new code to a new auxiliary_sysfs.c file (Greg)
    v5-v6:
    - removed concept of shared and exclusive and hence global xarray (Greg)
    v4-v5:
    - restore global mutex and replace refcount_t with simple integer (Greg)
    v3->4:
    - remove global mutex (Przemek)
    v2->v3:
    - fix function declaration in case SYSFS isn't defined
    v1->v2:
    - move #ifdefs from drivers/base/auxiliary.c to
      include/linux/auxiliary_bus.h (Greg)
    - use EXPORT_SYMBOL_GPL instead of EXPORT_SYMBOL (Greg)
    - Fix kzalloc(ref) to kzalloc(*ref) (Simon)
    - Add return description in auxiliary_device_sysfs_irq_add() kdoc (Simon)
    - Fix auxiliary_irq_mode_show doc (kernel test boot)

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2024-10-02 15:24:56 +02:00
Mark Langsdorf 0753f4dc47 driver core: make struct bus_type.uevent() take a const *
JIRA: https://issues.redhat.com/browse/RHEL-1023
Conflicts:
	drivers/gpu/drm/drm_mipi_dsi.c - minor context
differences
	drivers/platform/x86/wmi.c - had to insert a const
in device_to_wblock()
	include/linux/hyperv.h - had to insert a const
in device_to_hv_device()
Omitted-fix: a69ea7a76d52353b17d7bedf43818c2578517e9e
	centos-9 doesn't support SuperH devices, so this
fix for the maple sub-componet of a SuperH isn't
necessary

commit 2a81ada32f0e584fc0c943e0d3a8c9f4fae411d6
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date: Fri, 27 Jan 2023 13:45:52 +0000

The uevent() callback in struct bus_type should not be modifying the
device that is passed into it, so mark it as a const * and propagate the
function signature changes out into all relevant subsystems that use
this callback.

Acked-by: Rafael J. Wysocki <rafael@kernel.org>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20230111113018.459199-16-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
2023-10-23 10:35:56 -05:00
Al Stone a5384e8ee5 bus: Make remove callback return void
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2071830
Depends: https://bugzilla.redhat.com/show_bug.cgi?id=2071840
Tested: This is one of a series of patch sets to enable Arm SystemReady IR
 support in the kernel for NXP i.MX8 platforms.  At this stage, this
 has been tested by ensuring we can survive the CI/CD loop -- i.e.,
 that we have not broken anything else, and a simple boot test.  When
 sufficient drivers have been brought in for i.MX8M, we will be able
 to run further tests.

Conflicts:
    drivers/dma/idxd/sysfs.c -- there is no driver remove function
    to be modified so ignored this portion of the patch.

    drivers/vfio/mdev/mdev_driver.c -- slightly different context
    than expected but again this is a simple type change for
    a function causing a simple "return" to also be removed.

    drivers/net/netdevsim/bus.c -- similar to mdev_driver.c, there
    is a different overall context, but this change is only a simple
    function return type change (int to void).

commit fc7a6209d5710618eb4f72a77cd81b8d694ecf89
Author: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Date:   Tue Jul 13 21:35:22 2021 +0200

    bus: Make remove callback return void

    The driver core ignores the return value of this callback because there
    is only little it can do when a device disappears.

    This is the final bit of a long lasting cleanup quest where several
    buses were converted to also return void from their remove callback.
    Additionally some resource leaks were fixed that were caused by drivers
    returning an error code in the expectation that the driver won't go
    away.

    With struct bus_type::remove returning void it's prevented that newly
    implemented buses return an ignored error code and so don't anticipate
    wrong expectations for driver authors.

    Reviewed-by: Tom Rix <trix@redhat.com> (For fpga)
    Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org>
    Reviewed-by: Cornelia Huck <cohuck@redhat.com> (For drivers/s390 and drivers/vfio)
    Acked-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> (For ARM, Amba and related parts)
    Acked-by: Mark Brown <broonie@kernel.org>
    Acked-by: Chen-Yu Tsai <wens@csie.org> (for sunxi-rsb)
    Acked-by: Pali Rohár <pali@kernel.org>
    Acked-by: Mauro Carvalho Chehab <mchehab@kernel.org> (for media)
    Acked-by: Hans de Goede <hdegoede@redhat.com> (For drivers/platform)
    Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
    Acked-By: Vinod Koul <vkoul@kernel.org>
    Acked-by: Juergen Gross <jgross@suse.com> (For xen)
    Acked-by: Lee Jones <lee.jones@linaro.org> (For mfd)
    Acked-by: Johannes Thumshirn <jth@kernel.org> (For mcb)
    Acked-by: Johan Hovold <johan@kernel.org>
    Acked-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> (For slimbus)
    Acked-by: Kirti Wankhede <kwankhede@nvidia.com> (For vfio)
    Acked-by: Maximilian Luz <luzmaximilian@gmail.com>
    Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> (For ulpi and typec)
    Acked-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com> (For ipack)
    Acked-by: Geoff Levand <geoff@infradead.org> (For ps3)
    Acked-by: Yehezkel Bernat <YehezkelShB@gmail.com> (For thunderbolt)
    Acked-by: Alexander Shishkin <alexander.shishkin@linux.intel.com> (For intel_th)
    Acked-by: Dominik Brodowski <linux@dominikbrodowski.net> (For pcmcia)
    Acked-by: Rafael J. Wysocki <rafael@kernel.org> (For ACPI)
    Acked-by: Bjorn Andersson <bjorn.andersson@linaro.org> (rpmsg and apr)
    Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> (For intel-ish-hid)
    Acked-by: Dan Williams <dan.j.williams@intel.com> (For CXL, DAX, and NVDIMM)
    Acked-by: William Breathitt Gray <vilhelm.gray@gmail.com> (For isa)
    Acked-by: Stefan Richter <stefanr@s5r6.in-berlin.de> (For firewire)
    Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> (For hid)
    Acked-by: Thorsten Scherer <t.scherer@eckelmann.de> (For siox)
    Acked-by: Sven Van Asbroeck <TheSven73@gmail.com> (For anybuss)
    Acked-by: Ulf Hansson <ulf.hansson@linaro.org> (For MMC)
    Acked-by: Wolfram Sang <wsa@kernel.org> # for I2C
    Acked-by: Sudeep Holla <sudeep.holla@arm.com>
    Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
    Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    Acked-by: Finn Thain <fthain@linux-m68k.org>
    Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
    Link: https://lore.kernel.org/r/20210713193522.1770306-6-u.kleine-koenig@pengutronix.de
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    (cherry picked from commit fc7a6209d5710618eb4f72a77cd81b8d694ecf89)

Signed-off-by: Al Stone <ahs3@redhat.com>
2022-08-25 10:41:31 -06:00
Mark Langsdorf c9404c8e04 Documentation/auxiliary_bus: Move the text into the code
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2067284
Conflicts:
	Documentation/driver-api/auxiliary_bus.rst - fixup failed
for unknown reasons, but the change was to replace the all the text
with kernel-doc references, so I did that by hand.

commit e1b5186810cc7d4ec60447032636b8e6772dbbc6
Author: Ira Weiny <ira.weiny@intel.com>
Date: Wed, 1 Dec 2021 20:43:05 -0800

The code and documentation are more difficult to maintain when kept
separately.  This is further compounded when the standard structure
documentation infrastructure is not used.

Move the documentation into the code, use the standard documentation
infrastructure, add current documented functions, and reference the text
in the rst file.

Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Link: https://lore.kernel.org/r/20211202044305.4006853-8-ira.weiny@intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
2022-06-14 16:04:14 -05:00
Mark Langsdorf 2c35744f98 Documentation/auxiliary_bus: Clarify the release of devices from find device
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2067284

commit 8a2d6ffe7740cb8c944968aa9b0705e20afeef87
Author: Ira Weiny <ira.weiny@intel.com>
Date: Wed, 1 Dec 2021 20:43:04 -0800

auxiliary_find_device() takes a proper get_device() reference on the
device before returning the matched device.

Users of this call should be informed that they need to properly release
this reference with put_device().

Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Link: https://lore.kernel.org/r/20211202044305.4006853-7-ira.weiny@intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
2022-06-14 16:04:14 -05:00
Mark Langsdorf 5f5a7b7108 Documentation/auxiliary_bus: Clarify __auxiliary_driver_register
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2067284

commit 05021dca787be566886875dc0c683552e1c67e5e
Author: Ira Weiny <ira.weiny@intel.com>
Date: Wed, 1 Dec 2021 20:43:02 -0800

__auxiliary_driver_register is not intended to be called directly unless
a custom name is required.  Add documentation for this fact.

Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Link: https://lore.kernel.org/r/20211202044305.4006853-5-ira.weiny@intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
2022-06-14 16:04:14 -05:00
Mark Langsdorf 83e16c3e0b Documentation/auxiliary_bus: Clarify auxiliary_device creation
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2067284

commit b247703873c4d5088eee52d7902495b24967ce8e
Author: Ira Weiny <ira.weiny@intel.com>
Date: Wed, 1 Dec 2021 20:42:59 -0800

The documentation for creating an auxiliary device is a 3 step not a 2
step process.  Specifically the requirements of setting the name, id,
dev.release, and dev.parent fields was not clear as a precursor to the '2
step' process documented.

Clarify by declaring this a 3 step process starting with setting the
fields of struct auxiliary_device correctly.

Also add some sample code and tie the change into the rest of the
documentation.

Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Link: https://lore.kernel.org/r/20211202044305.4006853-2-ira.weiny@intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
2022-06-14 16:04:14 -05:00
Peter Ujfalusi 4afa0c22ee driver core: auxiliary bus: Fix memory leak when driver_register() fail
If driver_register() returns with error we need to free the memory
allocated for auxdrv->driver.name before returning from
__auxiliary_driver_register()

Fixes: 7de3697e9c ("Add auxiliary bus support")
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20210713093438.3173-1-peter.ujfalusi@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-07-21 16:36:06 +02:00
Dave Jiang bbf44abeea driver core: auxiliary bus: Remove unneeded module bits
Remove module bits in the auxiliary bus code since the auxiliary bus
cannot be built as a module and the relevant code is not needed.

Cc: Dave Ertman <david.m.ertman@intel.com>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/161307488980.1896017.15627190714413338196.stgit@djiang5-desk3.ch.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-03-23 10:47:55 +01:00
Dave Jiang 471b12c43f driver core: auxiliary bus: Fix calling stage for auxiliary bus init
When the auxiliary device code is built into the kernel, it can be executed
before the auxiliary bus is registered. This causes bus->p to be not
allocated and triggers a NULL pointer dereference when the auxiliary bus
device gets added with bus_add_device(). Call the auxiliary_bus_init()
under driver_init() so the bus is initialized before devices.

Below is the kernel splat for the bug:
[ 1.948215] BUG: kernel NULL pointer dereference, address: 0000000000000060
[ 1.950670] #PF: supervisor read access in kernel mode
[ 1.950670] #PF: error_code(0x0000) - not-present page
[ 1.950670] PGD 0
[ 1.950670] Oops: 0000 1 SMP NOPTI
[ 1.950670] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.10.0-intel-nextsvmtest+ #2205
[ 1.950670] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014
[ 1.950670] RIP: 0010:bus_add_device+0x64/0x140
[ 1.950670] Code: 00 49 8b 75 20 48 89 df e8 59 a1 ff ff 41 89 c4 85 c0 75 7b 48 8b 53 50 48 85 d2 75 03 48 8b 13 49 8b 85 a0 00 00 00 48 89 de <48> 8
78 60 48 83 c7 18 e8 ef d9 a9 ff 41 89 c4 85 c0 75 45 48 8b
[ 1.950670] RSP: 0000:ff46032ac001baf8 EFLAGS: 00010246
[ 1.950670] RAX: 0000000000000000 RBX: ff4597f7414aa680 RCX: 0000000000000000
[ 1.950670] RDX: ff4597f74142bbc0 RSI: ff4597f7414aa680 RDI: ff4597f7414aa680
[ 1.950670] RBP: ff46032ac001bb10 R08: 0000000000000044 R09: 0000000000000228
[ 1.950670] R10: ff4597f741141b30 R11: ff4597f740182a90 R12: 0000000000000000
[ 1.950670] R13: ffffffffa5e936c0 R14: 0000000000000000 R15: 0000000000000000
[ 1.950670] FS: 0000000000000000(0000) GS:ff4597f7bba00000(0000) knlGS:0000000000000000
[ 1.950670] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 1.950670] CR2: 0000000000000060 CR3: 000000002140c001 CR4: 0000000000f71ef0
[ 1.950670] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 1.950670] DR3: 0000000000000000 DR6: 00000000fffe07f0 DR7: 0000000000000400
[ 1.950670] PKRU: 55555554
[ 1.950670] Call Trace:
[ 1.950670] device_add+0x3ee/0x850
[ 1.950670] __auxiliary_device_add+0x47/0x60
[ 1.950670] idxd_pci_probe+0xf77/0x1180
[ 1.950670] local_pci_probe+0x4a/0x90
[ 1.950670] pci_device_probe+0xff/0x1b0
[ 1.950670] really_probe+0x1cf/0x440
[ 1.950670] ? rdinit_setup+0x31/0x31
[ 1.950670] driver_probe_device+0xe8/0x150
[ 1.950670] device_driver_attach+0x58/0x60
[ 1.950670] __driver_attach+0x8f/0x150
[ 1.950670] ? device_driver_attach+0x60/0x60
[ 1.950670] ? device_driver_attach+0x60/0x60
[ 1.950670] bus_for_each_dev+0x79/0xc0
[ 1.950670] ? kmem_cache_alloc_trace+0x323/0x430
[ 1.950670] driver_attach+0x1e/0x20
[ 1.950670] bus_add_driver+0x154/0x1f0
[ 1.950670] driver_register+0x70/0xc0
[ 1.950670] __pci_register_driver+0x54/0x60
[ 1.950670] idxd_init_module+0xe2/0xfc
[ 1.950670] ? idma64_platform_driver_init+0x19/0x19
[ 1.950670] do_one_initcall+0x4a/0x1e0
[ 1.950670] kernel_init_freeable+0x1fc/0x25c
[ 1.950670] ? rest_init+0xba/0xba
[ 1.950670] kernel_init+0xe/0x116
[ 1.950670] ret_from_fork+0x1f/0x30
[ 1.950670] Modules linked in:
[ 1.950670] CR2: 0000000000000060
[ 1.950670] --[ end trace cd7d1b226d3ca901 ]--

Fixes: 7de3697e9c ("Add auxiliary bus support")
Reported-by: Jacob Pan <jacob.jun.pan@intel.com>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Acked-by: Dave Ertman <david.m.ertman@intel.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/20210210201611.1611074-1-dave.jiang@intel.com
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-02-11 08:43:03 +01:00
Dave Jiang 784b2c48ac driver core: auxiliary bus: Fix auxiliary bus shutdown null auxdrv ptr
If the probe of the auxdrv failed, the device->driver is set to NULL.
During kernel shutdown, the bus shutdown will call auxdrv->shutdown and
cause an invalid ptr dereference. Add check to make sure device->driver is
not NULL before we proceed.

Fixes: 7de3697e9c ("Add auxiliary bus support")
Cc: Dave Ertman <david.m.ertman@intel.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Link: https://lore.kernel.org/r/160710040926.1889434.8840329810698403478.stgit@djiang5-desk3.ch.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-12-05 16:47:42 +01:00
Greg Kroah-Hartman 0d2bf11a6b driver core: auxiliary bus: minor coding style tweaks
For some reason, the original aux bus patch had some really long lines
in a few places, probably due to it being a very long-lived patch in
development by many different people.  Fix that up so that the two files
all have the same length lines and function formatting styles.

Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Dave Ertman <david.m.ertman@intel.com>
Cc: Fred Oh <fred.oh@linux.intel.com>
Cc: Kiran Patil <kiran.patil@intel.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: Martin Habets <mhabets@solarflare.com>
Cc: Parav Pandit <parav@mellanox.com>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Cc: Shiraz Saleem <shiraz.saleem@intel.com>
Link: https://lore.kernel.org/r/X8oiSFTpYHw1xE/o@kroah.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-12-04 13:30:59 +01:00
Greg Kroah-Hartman 8142a46c50 driver core: auxiliary bus: make remove function return void
There's an effort to move the remove() callback in the driver core to
not return an int, as nothing can be done if this function fails.  To
make that effort easier, make the aux bus remove function void to start
with so that no users have to be changed sometime in the future.

Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Dave Ertman <david.m.ertman@intel.com>
Cc: Fred Oh <fred.oh@linux.intel.com>
Cc: Kiran Patil <kiran.patil@intel.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: Martin Habets <mhabets@solarflare.com>
Cc: Parav Pandit <parav@mellanox.com>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Cc: Shiraz Saleem <shiraz.saleem@intel.com>
Link: https://lore.kernel.org/r/X8ohB1ks1NK7kPop@kroah.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-12-04 13:30:48 +01:00
Greg Kroah-Hartman 7bbb79ff5f driver core: auxiliary bus: move slab.h from include file
No need to include slab.h in include/linux/auxiliary_bus.h, as it is not
needed there.  Move it to drivers/base/auxiliary.c instead.

Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Dave Ertman <david.m.ertman@intel.com>
Cc: Fred Oh <fred.oh@linux.intel.com>
Cc: Kiran Patil <kiran.patil@intel.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: Martin Habets <mhabets@solarflare.com>
Cc: Parav Pandit <parav@mellanox.com>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Cc: Shiraz Saleem <shiraz.saleem@intel.com>
Link: https://lore.kernel.org/r/X8og8xi3WkoYXet9@kroah.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-12-04 13:30:43 +01:00
Dave Ertman 7de3697e9c Add auxiliary bus support
Add support for the Auxiliary Bus, auxiliary_device and auxiliary_driver.
It enables drivers to create an auxiliary_device and bind an
auxiliary_driver to it.

The bus supports probe/remove shutdown and suspend/resume callbacks.
Each auxiliary_device has a unique string based id; driver binds to
an auxiliary_device based on this id through the bus.

Co-developed-by: Kiran Patil <kiran.patil@intel.com>
Co-developed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Co-developed-by: Fred Oh <fred.oh@linux.intel.com>
Co-developed-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Kiran Patil <kiran.patil@intel.com>
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Fred Oh <fred.oh@linux.intel.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Dave Ertman <david.m.ertman@intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Shiraz Saleem <shiraz.saleem@intel.com>
Reviewed-by: Parav Pandit <parav@mellanox.com>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Martin Habets <mhabets@solarflare.com>
Link: https://lore.kernel.org/r/20201113161859.1775473-2-david.m.ertman@intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Link: https://lore.kernel.org/r/160695681289.505290.8978295443574440604.stgit@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-12-04 12:23:25 +01:00