Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fcd46b3

Browse files
author
Stefan Richter
committed
firewire: Enable remote DMA above 4 GB
This makes all of a machine's memory accessible to remote debugging via FireWire, using the physical response unit (i.e. RDMA) of OHCI-1394 link layer controllers. This requires actual support by the controller. The only ones currently known to support it are Agere/LSI FW643. Most if not all other OHCI-1394 controllers do not implement the optional Physical Upper Bound register. With them, RDMA will continue to be limited to the lowermost 4 GB. firewire-ohci's startup message in the kernel log is augmented to tell whether the controller does expose more than 4 GB to RDMA. While OHCI-1394 allows for a maximum Physical Upper Bound of 0xffff'0000'0000 (near 256 TB), this implementation sets it to 0x8000'0000'0000 (128 TB) in order to avoid interference with applications that require interrupt-served asynchronous request reception at respectively low addresses. Note, this change does not switch remote DMA on. It only increases the range of remote access to all memory (instead of just 4 GB) whenever remote DMA was switched on by other means. The latter is achieved by setting firewire-ohci's remote_dma parameter, or if the physical DMA filter is opened through firewire-sbp2. Derived from patch "firewire: Enable physical DMA above 4GB" by Peter Hurley <[email protected]> from March 27, 2013. Signed-off-by: Stefan Richter <[email protected]>
1 parent 8bc588e commit fcd46b3

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

Documentation/debugging-via-ohci1394.txt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ locations such as buffers like the printk buffer or the process table.
2222
Retrieving a full system memory dump is also possible over the FireWire,
2323
using data transfer rates in the order of 10MB/s or more.
2424

25-
Memory access is currently limited to the low 4G of physical address
26-
space which can be a problem on IA64 machines where memory is located
27-
mostly above that limit, but it is rarely a problem on more common
28-
hardware such as hardware based on x86, x86-64 and PowerPC.
25+
With most FireWire controllers, memory access is limited to the low 4 GB
26+
of physical address space. This can be a problem on IA64 machines where
27+
memory is located mostly above that limit, but it is rarely a problem on
28+
more common hardware such as x86, x86-64 and PowerPC. However, at least
29+
Agere/LSI FW643e and FW643e2 controllers are known to support access to
30+
physical addresses above 4 GB.
2931

3032
Together with a early initialization of the OHCI-1394 controller for debugging,
3133
this facility proved most useful for examining long debugs logs in the printk
@@ -99,6 +101,9 @@ Step-by-step instructions for using firescope with early OHCI initialization:
99101
compliant, they are based on TI PCILynx chips and require drivers for Win-
100102
dows operating systems.
101103

104+
The mentioned kernel log message contains ">4 GB phys DMA" in case of
105+
OHCI-1394 controllers which support accesses above this limit.
106+
102107
2) Establish a working FireWire cable connection:
103108

104109
Any FireWire cable, as long at it provides electrically and mechanically

drivers/firewire/core-transaction.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,11 +523,11 @@ static DEFINE_SPINLOCK(address_handler_list_lock);
523523
static LIST_HEAD(address_handler_list);
524524

525525
const struct fw_address_region fw_high_memory_region =
526-
{ .start = 0x000100000000ULL, .end = 0xffffe0000000ULL, };
526+
{ .start = FW_MAX_PHYSICAL_RANGE, .end = 0xffffe0000000ULL, };
527527
EXPORT_SYMBOL(fw_high_memory_region);
528528

529529
static const struct fw_address_region low_memory_region =
530-
{ .start = 0x000000000000ULL, .end = 0x000100000000ULL, };
530+
{ .start = 0x000000000000ULL, .end = FW_MAX_PHYSICAL_RANGE, };
531531

532532
#if 0
533533
const struct fw_address_region fw_private_region =
@@ -1217,7 +1217,7 @@ static void handle_low_memory(struct fw_card *card, struct fw_request *request,
12171217
}
12181218

12191219
static struct fw_address_handler low_memory = {
1220-
.length = 0x000100000000ULL,
1220+
.length = FW_MAX_PHYSICAL_RANGE,
12211221
.address_callback = handle_low_memory,
12221222
};
12231223

drivers/firewire/core.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,9 @@ static inline bool is_next_generation(int new_generation, int old_generation)
237237

238238
#define LOCAL_BUS 0xffc0
239239

240+
/* arbitrarily chosen maximum range for physical DMA: 128 TB */
241+
#define FW_MAX_PHYSICAL_RANGE (128ULL << 40)
242+
240243
void fw_core_handle_request(struct fw_card *card, struct fw_packet *request);
241244
void fw_core_handle_response(struct fw_card *card, struct fw_packet *packet);
242245
int fw_get_response_length(struct fw_request *request);

drivers/firewire/ohci.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2367,7 +2367,7 @@ static int ohci_enable(struct fw_card *card,
23672367
reg_write(ohci, OHCI1394_FairnessControl, 0);
23682368
card->priority_budget_implemented = ohci->pri_req_max != 0;
23692369

2370-
reg_write(ohci, OHCI1394_PhyUpperBound, 0x00010000);
2370+
reg_write(ohci, OHCI1394_PhyUpperBound, FW_MAX_PHYSICAL_RANGE >> 16);
23712371
reg_write(ohci, OHCI1394_IntEventClear, ~0);
23722372
reg_write(ohci, OHCI1394_IntMaskClear, ~0);
23732373

@@ -3723,9 +3723,11 @@ static int pci_probe(struct pci_dev *dev,
37233723
version = reg_read(ohci, OHCI1394_Version) & 0x00ff00ff;
37243724
ohci_notice(ohci,
37253725
"added OHCI v%x.%x device as card %d, "
3726-
"%d IR + %d IT contexts, quirks 0x%x\n",
3726+
"%d IR + %d IT contexts, quirks 0x%x%s\n",
37273727
version >> 16, version & 0xff, ohci->card.index,
3728-
ohci->n_ir, ohci->n_it, ohci->quirks);
3728+
ohci->n_ir, ohci->n_it, ohci->quirks,
3729+
reg_read(ohci, OHCI1394_PhyUpperBound) ?
3730+
", >4 GB phys DMA" : "");
37293731

37303732
return 0;
37313733

0 commit comments

Comments
 (0)