Introduce sim_dev and cam_sim_alloc_dev().
Add cam_sim_alloc_dev() as a wrapper to cam_sim_alloc() which takes a device_t instead of the unit_number (which we can derive from the dev again). Add device_t sim_dev to struct cam_sim. It will be used to pass through the bus for cases when both sides of CAM speak newbus already and we want to link them (yet make the calls through CAM for now). SDIO will be the first consumer of this. For that make use of cam_sim_alloc_dev() in sdhci under MMCCAM. This will also allow people to start iterating more on the idea to newbus-ify CAM without changing 50+ device drivers from the start. Also to be clear there are callers to cam_sim_alloc() which do not have a device_t (e.g., XPT) or provide their own unit number so we cannot simply switch the KPI entirely. Submitted by: kibab (original idea, see https://reviews.freebsd.org/D12467) Reviewed by: imp, chuck MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D19746
This commit is contained in:
parent
1729c988e5
commit
e50eccff2b
@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/bus.h>
|
||||
|
||||
#include <cam/cam.h>
|
||||
#include <cam/cam_ccb.h>
|
||||
@ -82,6 +83,7 @@ cam_sim_alloc(sim_action_func sim_action, sim_poll_func sim_poll,
|
||||
sim->sim_name = sim_name;
|
||||
sim->softc = softc;
|
||||
sim->path_id = CAM_PATH_ANY;
|
||||
sim->sim_dev = NULL; /* set only by cam_sim_alloc_dev */
|
||||
sim->unit_number = unit;
|
||||
sim->bus_id = 0; /* set in xpt_bus_register */
|
||||
sim->max_tagged_dev_openings = max_tagged_dev_transactions;
|
||||
@ -100,6 +102,25 @@ cam_sim_alloc(sim_action_func sim_action, sim_poll_func sim_poll,
|
||||
return (sim);
|
||||
}
|
||||
|
||||
struct cam_sim *
|
||||
cam_sim_alloc_dev(sim_action_func sim_action, sim_poll_func sim_poll,
|
||||
const char *sim_name, void *softc, device_t dev,
|
||||
struct mtx *mtx, int max_dev_transactions,
|
||||
int max_tagged_dev_transactions, struct cam_devq *queue)
|
||||
{
|
||||
struct cam_sim *sim;
|
||||
|
||||
KASSERT(dev != NULL, ("%s: dev is null for sim_name %s softc %p\n",
|
||||
__func__, sim_name, softc));
|
||||
|
||||
sim = cam_sim_alloc(sim_action, sim_poll, sim_name, softc,
|
||||
device_get_unit(dev), mtx, max_dev_transactions,
|
||||
max_tagged_dev_transactions, queue);
|
||||
if (sim != NULL)
|
||||
sim->sim_dev = dev;
|
||||
return (sim);
|
||||
}
|
||||
|
||||
void
|
||||
cam_sim_free(struct cam_sim *sim, int free_devq)
|
||||
{
|
||||
|
@ -62,6 +62,15 @@ struct cam_sim * cam_sim_alloc(sim_action_func sim_action,
|
||||
int max_dev_transactions,
|
||||
int max_tagged_dev_transactions,
|
||||
struct cam_devq *queue);
|
||||
struct cam_sim * cam_sim_alloc_dev(sim_action_func sim_action,
|
||||
sim_poll_func sim_poll,
|
||||
const char *sim_name,
|
||||
void *softc,
|
||||
device_t dev,
|
||||
struct mtx *mtx,
|
||||
int max_dev_transactions,
|
||||
int max_tagged_dev_transactions,
|
||||
struct cam_devq *queue);
|
||||
void cam_sim_free(struct cam_sim *sim, int free_devq);
|
||||
void cam_sim_hold(struct cam_sim *sim);
|
||||
void cam_sim_release(struct cam_sim *sim);
|
||||
@ -109,6 +118,7 @@ struct cam_sim {
|
||||
struct callout callout;
|
||||
struct cam_devq *devq; /* Device Queue to use for this SIM */
|
||||
int refcount; /* References to the SIM. */
|
||||
device_t sim_dev; /* For attached peripherals. */
|
||||
};
|
||||
|
||||
#define CAM_SIM_LOCK(sim) mtx_lock((sim)->mtx)
|
||||
|
@ -2513,8 +2513,8 @@ sdhci_start_slot(struct sdhci_slot *slot)
|
||||
goto fail;
|
||||
|
||||
mtx_init(&slot->sim_mtx, "sdhcisim", NULL, MTX_DEF);
|
||||
slot->sim = cam_sim_alloc(sdhci_cam_action, sdhci_cam_poll,
|
||||
"sdhci_slot", slot, device_get_unit(slot->bus),
|
||||
slot->sim = cam_sim_alloc_dev(sdhci_cam_action, sdhci_cam_poll,
|
||||
"sdhci_slot", slot, slot->bus,
|
||||
&slot->sim_mtx, 1, 1, slot->devq);
|
||||
|
||||
if (slot->sim == NULL) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user