HP was a little racist, but so was pretty much everyone else at the time so nothing strange there.
I find it hard to determine, in books "of an era", what the author's actual opinion might be... It could be:
- He/she is genuinely a nasty bit of work, with regard to racism/sexism/whatever the book exhibits,
- He/she is merely a product of a society (and stratum of society) that at that time exhibits such opinions as are now outdated, but leak through into the book, or
- He/she is far more progressive than that, but is depicting an "unreliable narrator" with the qualities (possibly even exaggerated) that the author wishes to satirise or somehow mirror in a form of derision.
As one example,
Richard Hanney, John Buchan's hero of (amongst other books) The Thirty Nine Steps has right-wing tendencies and racial undertones to his attitude. Albeit that there are "good foreigners" and "bad foreigners", not delineated entirely by their origin, and he can at least see the POV of the likes of pacifists.
As another (particularly noteworthy, in my mind) example, Edwin A. Abbott's "Flatland", the eponymous 2D world in which the narrator of the story lives is heavily based upon a caste-system based upon the number (and style) of sides each individual has (and has generally been born with). Hexagons are the least noble of the nobility, with the upper-echelons being closer and closer to a perfect circle. The 'middle classes' are pentagons and squares, and the narrator is A. Square (later given the name "Albert" by Ian Stewart's sequel-ish "Flatterland", written more than a hundred years after the 19thC original). Triangles are tradespeople or (IIRC) soldiers if they are a particularly sharp isosceles shape. Regularity of shape is all, and grossly malformed babies are subjected to various "corrective" procedures to try to make them embody the most regular shape that they can, and if they cannot be so corrected are essentially euthanised. All this is "as it should be" to the teller of the tale (Albert or Edwin?).
Additionally, the females of that world are 'mere' lines (reproduction tends to produce offspring of one more side than the father, excepting for some special case amongst the triangular-classes, IIRC). Dangerously sharp (being pointed at both ends) and treated as second-class to all males in most respects, with separate entrances to the 'houses' of the world so that they don't encounter (and fatally puncture) any of the male residents/visitors of the house coming the other way. It's perhaps hard to say, at first glance, whether this really a sideways view of the class-system and chauvinism of the author's Victorian era (ironically, a time where a woman ruled the land!), or an actual opinion by Abbott put into literature form. Note that Stewart's 'sequel' followed Albert's daughter ('Victoria Line') and some form of emancipation, or perhaps just teenage rebellion, allowed the 21st Century sequel to represent a far less cowed female population (at least the youngsters... I must re-find and re-read both the books to refresh my memory), as she followed in her father's footsteps and "discovered" the world of 3D (and 1D, and 4D, among others), to continue the legacy of learning (amongst many more things) how the 2D creatures perceive our 3D space and (at least in Flatterland) thus enable us 3D beings to appreciate how with might strive to perceive, or at least imagine, the 4D universe and many other strangenesses thereof...
(Interestingly, another book to address the world of Flatterland was one that my memory vaguelly tells me was called "The Magic Umbrella". The titular Umbrella, or some similar device, allowed/encouraged/enforced travel between the protagonist's own world and various other (allegedly) fictional ones, including a Gilbert And Sullivan world featuring Pirates, Policemen, Beefeaters, Royal Navy Sailors, Japanese nobility, etc, in which everyone sings everything they say. But at one point there is a visit to Edwin Abbott Abbott's book-universe of Flatland, shortly after a visit to the world of Sherlock Holmes, where...
Sherlock, being a pretty perfect person in all ways is, near-as-damnit, an actual circle. But as the consummate observer, impersonator and master of disguises he manages to shade himself appropriately and otherwise represent himself in such a way as to be disguised as a female line!
...and why not!)