Skip to contentSkip to conversation

Disaster at annarchy

DISCUSSION Pekka Paalanen 1 participant 1 message Oct 2, 2009 3 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw
Quoted 7 lines · On Fri, 02 Oct 2009 00:07:07 +0100 Stuart Bennett…
Quoted 5 lines · Pekka Paalanen

Hi Stuart,

I'm not sure you know, but annarchy just lost all user homes. Could you push vbtracetool and whatever personal git repos you had, so we can clone them?

Quoted 5 lines

Hey Pekka, I've re-upped vbtracetool and radeontool (they haven't shown up in cgit just yet, but I imagine they will soon). Can't remember if there was anything else particularly useful to other folk there, so if I've missed something someone will have to tell me.

Thanks for the replies!
I'm in a bit of a hurry right now, so I will get back to this next week.

Quoted 165 lines

As a bonus (although it's entirely possible this has long been dealt with, I've not been following development recently), here's the answer to an email of yours from a while ago which I've kept forgetting to answer:

Quoted 46 lines · Pekka Paalanen
Quoted 3 lines · On Thu, 20 Aug 2009 14:40:24 +0300 Pekka Paalanen…
Quoted 3 lines

Hi,

questions will follow.

This patch builds, but I have not tried to run it. I'm hoping Stuart or someone could comment on it.

Quoted 19 lines
Quoted 19 lines

---

(quoted diff) +0 -0

b/drivers/gpu/drm/nouveau/nouveau_bios.c index 99f7bd4..13b3fb1 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c @@ -40,8 +40,6 @@
#define BIOSLOG(sip, fmt, arg...) NV_DEBUG(sip->dev, fmt,
##arg) #define LOG_OLD_VALUE(x) //x

(quoted diff) +0 -2
-#define BIOS_USLEEP(n) mdelay((n)/1000)
-
 #define ROM16(x) le16_to_cpu(*(uint16_t *)&(x))
 #define ROM32(x) le32_to_cpu(*(uint32_t *)&(x))
@@ -50,6 +48,15 @@ struct init_exec {
 	bool repeat;
 };
 
Quoted 8 lines

Review struct init_exec { · line 58

Quoted 8 lines
(quoted diff) +8 -0
+static inline void bios_usleep(unsigned usecs)
+{
+	might_sleep();
+	if (usecs < 1000 * MAX_UDELAY_MS)
+		udelay(usecs);
+	else
+		msleep(usecs / 1000 + 1);
+}

This function is to replace the BIOS_USLEEP() macro with something, that works both for short and long delays. BIOS_USLEEP would truncate all sleeps to milliseconds, meaning delays less than 1000 us would be zero. Also, mdelay() is a busyloop delay burning CPU cycles for nothing. msleep() is not, it will reschedule until the delay has passed. The change raises two questions:

Quoted 3 lines

- Is the bios code ever called in a situation, where scheduling is not allowed (interrupt context, pre-emption disabled, inside spinlocks, etc.)?

not as far as I know, though I'm uncertain of what the conditions are when resuming from suspend

Quoted 1 line

- Is the delay accuracy on the msleep path critical?

no (but on udelay it possibly is)

btw, does might_sleep() imply a possibility of getting rescheduled? If so, you probably only want might_sleep in the msleep() (not udelay()) path?

Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
(quoted diff) +0 -0
 static bool nv_cksum(const uint8_t *data, unsigned int
 length) {
 	/* there's a few checksums in the BIOS, so here's a

generic checking function */ @@ -262,7 +269,7 @@ static int parse_init_table(struct nvbios *, unsigned int, struct init_exec *); static void still_alive(void) {
// sync();

(quoted diff) +3 -2
-//	BIOS_USLEEP(2000);
+//	bios_usleep(2000);
 }
 
 static uint32_t
@@ -1608,17 +1615,18 @@ init_condition_time(struct nvbios
 *bios, uint16_t offset, 
 	for (; retries > 0; retries--)
 		if (bios_condition_met(bios, offset, cond))
 {
-			BIOSLOG(bios, "0x%04X: Condition
 met, continuing\n", offset);
+			BIOSLOG(bios, "0x%04X: Condition
 met, continuing\n",
+
 offset); break;
Quoted 8 lines
Quoted 5 lines

Review init_condition_time(struct nvbios · line 1627

Quoted 5 lines
(quoted diff) +1 -1
 		} else {
 			BIOSLOG(bios, "0x%04X: Condition
 not met, sleeping for 20ms\n", offset);
-			BIOS_USLEEP(20000);
+			bios_usleep(20000);

It so happens, that 20000 was the maximum allowed udelay() constant time for x86. Did the number come from that?

no, sheer coincidence

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
(quoted diff) +0 -0
 		}
 
 	if (!bios_condition_met(bios, offset, cond)) {
 		NV_WARN(bios->dev,
 			"0x%04X: Condition still not met

after %dms, "

(quoted diff) +0 -1
-			"skiping following opcodes\n",

offset, 20 * retries);

(quoted diff) +1 -0
+			"skipping following opcodes\n",

offset, 20 * retries); iexec->execute = false;
}

Quoted 8 lines
Quoted 6 lines

Review init_reset(struct nvbios *bios, · line 1862

Quoted 6 lines
(quoted diff) +1 -1
@@ -1851,7 +1859,7 @@ init_reset(struct nvbios *bios,
 uint16_t offset, struct init_exec *iexec) bios_wr32(bios,
 NV_PBUS_PCI_NV_19, 0); bios_wr32(bios, reg, value1);
 
-	BIOS_USLEEP(10);
+	bios_usleep(10);

With the old BIOS_USLEEP, this delay would vanish.

an error in the ddx -> drm conversion I think

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
(quoted diff) +0 -0
 	bios_wr32(bios, reg, value2);
 	bios_wr32(bios, NV_PBUS_PCI_NV_19, pci_nv_19);
@@ -2233,8 +2241,7 @@ init_time(struct nvbios *bios,
 uint16_t offset, struct init_exec *iexec) BIOSLOG(bios,
 "0x%04X: Sleeping for 0x%04X microseconds\n", offset, time);
 
Quoted 6 lines
Quoted 3 lines

Review init_time(struct nvbios *bios, · line 2244

Quoted 3 lines
(quoted diff) +1 -2
-	BIOS_USLEEP(time);
-
+	bios_usleep(time);

Can here be delay accuracy issues? How much are we allowed to exceed the specified delay?

Shouldn't worry about it. So long as delays are accurate for < 1ms, I think slop on greater values is acceptable

Quoted 18 lines
Quoted 15 lines
Quoted 14 lines
(quoted diff) +0 -0
 	return true;
 }
 
@@ -2872,9 +2879,11 @@ static int

call_lvds_manufacturer_script(struct drm_device *dev, struct dcb_entr run_digital_op_script(dev, scriptofs, dcbent, head, bios->fp.dual_link);

(quoted diff) +1 -2
-	if (script == LVDS_PANEL_OFF)
+	if (script == LVDS_PANEL_OFF) {
 		/* off-on delay in ms */
-

BIOS_USLEEP(ROM16(bios->data[bios->fp.xlated_entry + 7])); + bios_usleep(ROM16(bios->data[bios->fp.xlated_entry + 7]));

Review

Quoted 1 line
(quoted diff) +1 -0
+	}

The comment and code disagree here. Is it microseconds or milliseconds?

Should be milliseconds, code bug.

Regards
Stuart

Signature · 2 lines
Pekka Paalanen
http://www.iki.fi/pq/