Skip to content

Commit 2fb3bde

Browse files
committed
Merge branch 'for-7.1/cxl-consolidate-endpoint' into cxl-for-next
Add code to ensure the endpoint has completed initialization before usage. cxl/pci: Check memdev driver binding status in cxl_reset_done() cxl/pci: Hold memdev lock in cxl_event_trace_record()
2 parents f3b1d22 + e8069c6 commit 2fb3bde

5 files changed

Lines changed: 13 additions & 6 deletions

File tree

drivers/cxl/core/mbox.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ int cxl_enumerate_cmds(struct cxl_memdev_state *mds)
893893
}
894894
EXPORT_SYMBOL_NS_GPL(cxl_enumerate_cmds, "CXL");
895895

896-
void cxl_event_trace_record(const struct cxl_memdev *cxlmd,
896+
void cxl_event_trace_record(struct cxl_memdev *cxlmd,
897897
enum cxl_event_log_type type,
898898
enum cxl_event_type event_type,
899899
const uuid_t *uuid, union cxl_event *evt)
@@ -920,6 +920,7 @@ void cxl_event_trace_record(const struct cxl_memdev *cxlmd,
920920
* translations. Take topology mutation locks and lookup
921921
* { HPA, REGION } from { DPA, MEMDEV } in the event record.
922922
*/
923+
guard(device)(&cxlmd->dev);
923924
guard(rwsem_read)(&cxl_rwsem.region);
924925
guard(rwsem_read)(&cxl_rwsem.dpa);
925926

@@ -968,7 +969,7 @@ void cxl_event_trace_record(const struct cxl_memdev *cxlmd,
968969
}
969970
EXPORT_SYMBOL_NS_GPL(cxl_event_trace_record, "CXL");
970971

971-
static void __cxl_event_trace_record(const struct cxl_memdev *cxlmd,
972+
static void __cxl_event_trace_record(struct cxl_memdev *cxlmd,
972973
enum cxl_event_log_type type,
973974
struct cxl_event_record_raw *record)
974975
{

drivers/cxl/core/region.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2967,13 +2967,15 @@ static int __cxl_dpa_to_region(struct device *dev, void *arg)
29672967
struct cxl_region *cxl_dpa_to_region(const struct cxl_memdev *cxlmd, u64 dpa)
29682968
{
29692969
struct cxl_dpa_to_region_context ctx;
2970-
struct cxl_port *port;
2970+
struct cxl_port *port = cxlmd->endpoint;
2971+
2972+
if (!cxlmd->dev.driver)
2973+
return NULL;
29712974

29722975
ctx = (struct cxl_dpa_to_region_context) {
29732976
.dpa = dpa,
29742977
};
2975-
port = cxlmd->endpoint;
2976-
if (port && is_cxl_endpoint(port) && cxl_num_decoders_committed(port))
2978+
if (cxl_num_decoders_committed(port))
29772979
device_for_each_child(&port->dev, &ctx, __cxl_dpa_to_region);
29782980

29792981
return ctx.cxlr;

drivers/cxl/cxlmem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ void set_exclusive_cxl_commands(struct cxl_memdev_state *mds,
864864
void clear_exclusive_cxl_commands(struct cxl_memdev_state *mds,
865865
unsigned long *cmds);
866866
void cxl_mem_get_event_records(struct cxl_memdev_state *mds, u32 status);
867-
void cxl_event_trace_record(const struct cxl_memdev *cxlmd,
867+
void cxl_event_trace_record(struct cxl_memdev *cxlmd,
868868
enum cxl_event_log_type type,
869869
enum cxl_event_type event_type,
870870
const uuid_t *uuid, union cxl_event *evt);

drivers/cxl/pci.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,6 +1056,9 @@ static void cxl_reset_done(struct pci_dev *pdev)
10561056
* that no longer exists.
10571057
*/
10581058
guard(device)(&cxlmd->dev);
1059+
if (!cxlmd->dev.driver)
1060+
return;
1061+
10591062
if (cxlmd->endpoint &&
10601063
cxl_endpoint_decoder_reset_detected(cxlmd->endpoint)) {
10611064
device_for_each_child(&cxlmd->endpoint->dev, NULL,

include/linux/device.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,7 @@ static inline void device_unlock(struct device *dev)
911911
}
912912

913913
DEFINE_GUARD(device, struct device *, device_lock(_T), device_unlock(_T))
914+
DEFINE_GUARD_COND(device, _intr, device_lock_interruptible(_T), _RET == 0)
914915

915916
static inline void device_lock_assert(struct device *dev)
916917
{

0 commit comments

Comments
 (0)